author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /kabc/plugins/dir/resourcedirconfig.cpp | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
Diffstat (limited to 'kabc/plugins/dir/resourcedirconfig.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kabc/plugins/dir/resourcedirconfig.cpp | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/kabc/plugins/dir/resourcedirconfig.cpp b/kabc/plugins/dir/resourcedirconfig.cpp new file mode 100644 index 0000000..98d18fe --- a/dev/null +++ b/kabc/plugins/dir/resourcedirconfig.cpp | |||
@@ -0,0 +1,123 @@ | |||
1 | /* | ||
2 | This file is part of libkabc. | ||
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., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /* | ||
22 | Enhanced Version of the file for platform independent KDE tools. | ||
23 | Copyright (c) 2004 Ulf Schenk | ||
24 | |||
25 | $Id$ | ||
26 | */ | ||
27 | |||
28 | #include <qlabel.h> | ||
29 | #include <qlayout.h> | ||
30 | |||
31 | #include <kdebug.h> | ||
32 | #include <klocale.h> | ||
33 | #include <kstandarddirs.h> | ||
34 | #include <kdialog.h> | ||
35 | |||
36 | //US #include "formatfactory.h" | ||
37 | #include "resourcedir.h" | ||
38 | #include "stdaddressbook.h" | ||
39 | |||
40 | #include "resourcedirconfig.h" | ||
41 | |||
42 | using namespace KABC; | ||
43 | |||
44 | ResourceDirConfig::ResourceDirConfig( QWidget* parent, const char* name ) | ||
45 | : KRES::ConfigWidget( parent, name ) | ||
46 | { | ||
47 | QGridLayout *mainLayout = new QGridLayout( this, 2, 2, 0, | ||
48 | KDialog::spacingHint() ); | ||
49 | |||
50 | QLabel *label = new QLabel( i18n( "Format:" ), this ); | ||
51 | mFormatBox = new KComboBox( this ); | ||
52 | |||
53 | mainLayout->addWidget( label, 0, 0 ); | ||
54 | mainLayout->addWidget( mFormatBox, 0, 1 ); | ||
55 | |||
56 | label = new QLabel( i18n( "Location:" ), this ); | ||
57 | mFileNameEdit = new KURLRequester( this ); | ||
58 | //US mFileNameEdit->setMode( KFile::Directory ); | ||
59 | |||
60 | mainLayout->addWidget( label, 1, 0 ); | ||
61 | mainLayout->addWidget( mFileNameEdit, 1, 1 ); | ||
62 | |||
63 | /*US lets hardcode the formats instead of using a factory | ||
64 | FormatFactory *factory = FormatFactory::self(); | ||
65 | QStringList formats = factory->formats(); | ||
66 | QStringList::Iterator it; | ||
67 | for ( it = formats.begin(); it != formats.end(); ++it ) { | ||
68 | FormatInfo *info = factory->info( *it ); | ||
69 | if ( info ) { | ||
70 | mFormatTypes << (*it); | ||
71 | mFormatBox->insertItem( info->nameLabel ); | ||
72 | } | ||
73 | } | ||
74 | */ | ||
75 | mFormatTypes << "vcard"; | ||
76 | mFormatTypes << "binary"; | ||
77 | mFormatBox->insertItem( "vcard" ); | ||
78 | mFormatBox->insertItem( "binary" ); | ||
79 | |||
80 | |||
81 | mInEditMode = false; | ||
82 | } | ||
83 | |||
84 | void ResourceDirConfig::setEditMode( bool value ) | ||
85 | { | ||
86 | mFormatBox->setEnabled( !value ); | ||
87 | mInEditMode = value; | ||
88 | } | ||
89 | |||
90 | void ResourceDirConfig::loadSettings( KRES::Resource *res ) | ||
91 | { | ||
92 | //US ResourceDir *resource = dynamic_cast<ResourceDir*>( res ); | ||
93 | ResourceDir *resource = (ResourceDir*)( res ); | ||
94 | |||
95 | if ( !resource ) { | ||
96 | kdDebug(5700) << "ResourceDirConfig::loadSettings(): cast failed" << endl; | ||
97 | return; | ||
98 | } | ||
99 | |||
100 | mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->format() ) ); | ||
101 | |||
102 | mFileNameEdit->setURL( resource->path() ); | ||
103 | if ( mFileNameEdit->url().isEmpty() ) | ||
104 | mFileNameEdit->setURL( KABC::StdAddressBook::directoryName() ); | ||
105 | } | ||
106 | |||
107 | void ResourceDirConfig::saveSettings( KRES::Resource *res ) | ||
108 | { | ||
109 | //US ResourceDir *resource = dynamic_cast<ResourceDir*>( res ); | ||
110 | ResourceDir *resource = (ResourceDir*)( res ); | ||
111 | |||
112 | if ( !resource ) { | ||
113 | kdDebug(5700) << "ResourceDirConfig::loadSettings(): cast failed" << endl; | ||
114 | return; | ||
115 | } | ||
116 | |||
117 | if ( mInEditMode ) | ||
118 | resource->setFormat( mFormatTypes[ mFormatBox->currentItem() ] ); | ||
119 | |||
120 | resource->setPath( mFileNameEdit->url() ); | ||
121 | } | ||
122 | |||
123 | //US #include "resourcedirconfig.moc" | ||