• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kabc
 

kabc

  • kabc
  • plugins
  • net
resourcenetconfig.cpp
1 /*
2  This file is part of libkabc.
3  Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include <tqlabel.h>
22 #include <tqlayout.h>
23 
24 #include <kdebug.h>
25 #include <klocale.h>
26 #include <kdialog.h>
27 
28 #include "formatfactory.h"
29 #include "resourcenet.h"
30 #include "stdaddressbook.h"
31 
32 #include "resourcenetconfig.h"
33 
34 using namespace KABC;
35 
36 ResourceNetConfig::ResourceNetConfig( TQWidget* parent, const char* name )
37  : ConfigWidget( parent, name ), mInEditMode( false )
38 {
39  TQGridLayout *mainLayout = new TQGridLayout( this, 2, 2, 0,
40  KDialog::spacingHint() );
41 
42  TQLabel *label = new TQLabel( i18n( "Format:" ), this );
43  mFormatBox = new KComboBox( this );
44 
45  mainLayout->addWidget( label, 0, 0 );
46  mainLayout->addWidget( mFormatBox, 0, 1 );
47 
48  label = new TQLabel( i18n( "Location:" ), this );
49  mUrlEdit = new KURLRequester( this );
50  mUrlEdit->setMode( KFile::File );
51 
52  mainLayout->addWidget( label, 1, 0 );
53  mainLayout->addWidget( mUrlEdit, 1, 1 );
54 
55  FormatFactory *factory = FormatFactory::self();
56  TQStringList formats = factory->formats();
57  TQStringList::Iterator it;
58  for ( it = formats.begin(); it != formats.end(); ++it ) {
59  FormatInfo *info = factory->info( *it );
60  if ( info ) {
61  mFormatTypes << (*it);
62  mFormatBox->insertItem( info->nameLabel );
63  }
64  }
65 }
66 
67 void ResourceNetConfig::setEditMode( bool value )
68 {
69  mFormatBox->setEnabled( !value );
70  mInEditMode = value;
71 }
72 
73 void ResourceNetConfig::loadSettings( KRES::Resource *res )
74 {
75  ResourceNet *resource = dynamic_cast<ResourceNet*>( res );
76 
77  if ( !resource ) {
78  kdDebug(5700) << "ResourceNetConfig::loadSettings(): cast failed" << endl;
79  return;
80  }
81 
82  mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->format() ) );
83 
84  mUrlEdit->setURL( resource->url().url() );
85 }
86 
87 void ResourceNetConfig::saveSettings( KRES::Resource *res )
88 {
89  ResourceNet *resource = dynamic_cast<ResourceNet*>( res );
90 
91  if ( !resource ) {
92  kdDebug(5700) << "ResourceNetConfig::saveSettings(): cast failed" << endl;
93  return;
94  }
95 
96  if ( !mInEditMode )
97  resource->setFormat( mFormatTypes[ mFormatBox->currentItem() ] );
98 
99  resource->setUrl( KURL( mUrlEdit->url() ) );
100 }
101 
102 #include "resourcenetconfig.moc"
KABC::FormatFactory
Class for loading format plugins.
Definition: formatfactory.h:57
KURL
KABC::FormatFactory::self
static FormatFactory * self()
Returns the global format factory.
Definition: formatfactory.cpp:38
KABC::FormatFactory::formats
TQStringList formats()
Returns a list of all available format types.
Definition: formatfactory.cpp:86
KStdAccel::label
TQString label(StdAccel id)
kdDebug
kdbgstream kdDebug(int area=0)
klocale.h
KDialog::spacingHint
static int spacingHint()
KABC::FormatFactory::info
FormatInfo * info(const TQString &type)
Returns the info structure for a special type.
Definition: formatfactory.cpp:101
KABC
static data, shared by ALL addressee objects
Definition: address.h:48
KComboBox
endl
kndbgstream & endl(kndbgstream &s)

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kabc

Skip menu "kabc"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kabc by doxygen 1.8.11
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |