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

tdeabc

  • tdeabc
  • plugins
  • dir
resourcedirconfig.cpp
1/*
2 This file is part of libtdeabc.
3 Copyright (c) 2002 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 <tdelocale.h>
26#include <tdestandarddirs.h>
27#include <kdialog.h>
28
29#include "formatfactory.h"
30#include "resourcedir.h"
31#include "stdaddressbook.h"
32
33#include "resourcedirconfig.h"
34
35using namespace TDEABC;
36
37ResourceDirConfig::ResourceDirConfig( TQWidget* parent, const char* name )
38 : KRES::ConfigWidget( parent, name )
39{
40 TQGridLayout *mainLayout = new TQGridLayout( this, 2, 2, 0,
41 KDialog::spacingHint() );
42
43 TQLabel *label = new TQLabel( i18n( "Format:" ), this );
44 mFormatBox = new KComboBox( this );
45
46 mainLayout->addWidget( label, 0, 0 );
47 mainLayout->addWidget( mFormatBox, 0, 1 );
48
49 label = new TQLabel( i18n( "Location:" ), this );
50 mFileNameEdit = new KURLRequester( this );
51 mFileNameEdit->setMode( KFile::Directory );
52
53 mainLayout->addWidget( label, 1, 0 );
54 mainLayout->addWidget( mFileNameEdit, 1, 1 );
55
56 FormatFactory *factory = FormatFactory::self();
57 TQStringList formats = factory->formats();
58 TQStringList::Iterator it;
59 for ( it = formats.begin(); it != formats.end(); ++it ) {
60 FormatInfo *info = factory->info( *it );
61 if ( info ) {
62 mFormatTypes << (*it);
63 mFormatBox->insertItem( info->nameLabel );
64 }
65 }
66
67 mInEditMode = false;
68}
69
70void ResourceDirConfig::setEditMode( bool value )
71{
72 mFormatBox->setEnabled( !value );
73 mInEditMode = value;
74}
75
76void ResourceDirConfig::loadSettings( KRES::Resource *res )
77{
78 ResourceDir *resource = dynamic_cast<ResourceDir*>( res );
79
80 if ( !resource ) {
81 kdDebug(5700) << "ResourceDirConfig::loadSettings(): cast failed" << endl;
82 return;
83 }
84
85 mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->format() ) );
86
87 mFileNameEdit->setURL( resource->path() );
88 if ( mFileNameEdit->url().isEmpty() )
89 mFileNameEdit->setURL( TDEABC::StdAddressBook::directoryName() );
90}
91
92void ResourceDirConfig::saveSettings( KRES::Resource *res )
93{
94 ResourceDir *resource = dynamic_cast<ResourceDir*>( res );
95
96 if ( !resource ) {
97 kdDebug(5700) << "ResourceDirConfig::loadSettings(): cast failed" << endl;
98 return;
99 }
100
101 if ( mInEditMode )
102 resource->setFormat( mFormatTypes[ mFormatBox->currentItem() ] );
103
104 resource->setPath( mFileNameEdit->url() );
105}
106
107#include "resourcedirconfig.moc"
KComboBox
KDialog::spacingHint
static int spacingHint()
TDEABC::FormatFactory
Class for loading format plugins.
Definition: formatfactory.h:58
TDEABC::FormatFactory::formats
TQStringList formats()
Returns a list of all available format types.
Definition: formatfactory.cpp:86
TDEABC::FormatFactory::info
FormatInfo * info(const TQString &type)
Returns the info structure for a special type.
Definition: formatfactory.cpp:101
TDEABC::StdAddressBook::directoryName
static TQString directoryName()
Returns the default directory name for vcard-based addressbook.
Definition: stdaddressbook.cpp:48
endl
kndbgstream & endl(kndbgstream &s)
kdDebug
kdbgstream kdDebug(int area=0)
TDEABC
static data, shared by ALL addressee objects
Definition: address.h:48
TDEStdAccel::name
TQString name(StdAccel id)
TDEStdAccel::label
TQString label(StdAccel id)
tdelocale.h

tdeabc

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

tdeabc

Skip menu "tdeabc"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeabc by doxygen 1.9.4
This website is maintained by Timothy Pearson.