summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/dir/resourcedirconfig.cpp
Unidiff
Diffstat (limited to 'kabc/plugins/dir/resourcedirconfig.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/dir/resourcedirconfig.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/kabc/plugins/dir/resourcedirconfig.cpp b/kabc/plugins/dir/resourcedirconfig.cpp
index 98d18fe..8fa48d0 100644
--- a/kabc/plugins/dir/resourcedirconfig.cpp
+++ b/kabc/plugins/dir/resourcedirconfig.cpp
@@ -1,123 +1,125 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 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 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, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qlayout.h> 29#include <qlayout.h>
30//Added by qt3to4:
31#include <Q3GridLayout>
30 32
31#include <kdebug.h> 33#include <kdebug.h>
32#include <klocale.h> 34#include <klocale.h>
33#include <kstandarddirs.h> 35#include <kstandarddirs.h>
34#include <kdialog.h> 36#include <kdialog.h>
35 37
36//US #include "formatfactory.h" 38//US #include "formatfactory.h"
37#include "resourcedir.h" 39#include "resourcedir.h"
38#include "stdaddressbook.h" 40#include "stdaddressbook.h"
39 41
40#include "resourcedirconfig.h" 42#include "resourcedirconfig.h"
41 43
42using namespace KABC; 44using namespace KABC;
43 45
44ResourceDirConfig::ResourceDirConfig( QWidget* parent, const char* name ) 46ResourceDirConfig::ResourceDirConfig( QWidget* parent, const char* name )
45 : KRES::ConfigWidget( parent, name ) 47 : KRES::ConfigWidget( parent, name )
46{ 48{
47 QGridLayout *mainLayout = new QGridLayout( this, 2, 2, 0, 49 Q3GridLayout *mainLayout = new Q3GridLayout( this, 2, 2, 0,
48 KDialog::spacingHint() ); 50 KDialog::spacingHint() );
49 51
50 QLabel *label = new QLabel( i18n( "Format:" ), this ); 52 QLabel *label = new QLabel( i18n( "Format:" ), this );
51 mFormatBox = new KComboBox( this ); 53 mFormatBox = new KComboBox( this );
52 54
53 mainLayout->addWidget( label, 0, 0 ); 55 mainLayout->addWidget( label, 0, 0 );
54 mainLayout->addWidget( mFormatBox, 0, 1 ); 56 mainLayout->addWidget( mFormatBox, 0, 1 );
55 57
56 label = new QLabel( i18n( "Location:" ), this ); 58 label = new QLabel( i18n( "Location:" ), this );
57 mFileNameEdit = new KURLRequester( this ); 59 mFileNameEdit = new KURLRequester( this );
58//US mFileNameEdit->setMode( KFile::Directory ); 60//US mFileNameEdit->setMode( KFile::Directory );
59 61
60 mainLayout->addWidget( label, 1, 0 ); 62 mainLayout->addWidget( label, 1, 0 );
61 mainLayout->addWidget( mFileNameEdit, 1, 1 ); 63 mainLayout->addWidget( mFileNameEdit, 1, 1 );
62 64
63/*US lets hardcode the formats instead of using a factory 65/*US lets hardcode the formats instead of using a factory
64 FormatFactory *factory = FormatFactory::self(); 66 FormatFactory *factory = FormatFactory::self();
65 QStringList formats = factory->formats(); 67 QStringList formats = factory->formats();
66 QStringList::Iterator it; 68 QStringList::Iterator it;
67 for ( it = formats.begin(); it != formats.end(); ++it ) { 69 for ( it = formats.begin(); it != formats.end(); ++it ) {
68 FormatInfo *info = factory->info( *it ); 70 FormatInfo *info = factory->info( *it );
69 if ( info ) { 71 if ( info ) {
70 mFormatTypes << (*it); 72 mFormatTypes << (*it);
71 mFormatBox->insertItem( info->nameLabel ); 73 mFormatBox->insertItem( info->nameLabel );
72 } 74 }
73 } 75 }
74*/ 76*/
75 mFormatTypes << "vcard"; 77 mFormatTypes << "vcard";
76 mFormatTypes << "binary"; 78 mFormatTypes << "binary";
77 mFormatBox->insertItem( "vcard" ); 79 mFormatBox->insertItem( "vcard" );
78 mFormatBox->insertItem( "binary" ); 80 mFormatBox->insertItem( "binary" );
79 81
80 82
81 mInEditMode = false; 83 mInEditMode = false;
82} 84}
83 85
84void ResourceDirConfig::setEditMode( bool value ) 86void ResourceDirConfig::setEditMode( bool value )
85{ 87{
86 mFormatBox->setEnabled( !value ); 88 mFormatBox->setEnabled( !value );
87 mInEditMode = value; 89 mInEditMode = value;
88} 90}
89 91
90void ResourceDirConfig::loadSettings( KRES::Resource *res ) 92void ResourceDirConfig::loadSettings( KRES::Resource *res )
91{ 93{
92//US ResourceDir *resource = dynamic_cast<ResourceDir*>( res ); 94//US ResourceDir *resource = dynamic_cast<ResourceDir*>( res );
93 ResourceDir *resource = (ResourceDir*)( res ); 95 ResourceDir *resource = (ResourceDir*)( res );
94 96
95 if ( !resource ) { 97 if ( !resource ) {
96 kdDebug(5700) << "ResourceDirConfig::loadSettings(): cast failed" << endl; 98 kdDebug(5700) << "ResourceDirConfig::loadSettings(): cast failed" << endl;
97 return; 99 return;
98 } 100 }
99 101
100 mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->format() ) ); 102 mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->format() ) );
101 103
102 mFileNameEdit->setURL( resource->path() ); 104 mFileNameEdit->setURL( resource->path() );
103 if ( mFileNameEdit->url().isEmpty() ) 105 if ( mFileNameEdit->url().isEmpty() )
104 mFileNameEdit->setURL( KABC::StdAddressBook::directoryName() ); 106 mFileNameEdit->setURL( KABC::StdAddressBook::directoryName() );
105} 107}
106 108
107void ResourceDirConfig::saveSettings( KRES::Resource *res ) 109void ResourceDirConfig::saveSettings( KRES::Resource *res )
108{ 110{
109//US ResourceDir *resource = dynamic_cast<ResourceDir*>( res ); 111//US ResourceDir *resource = dynamic_cast<ResourceDir*>( res );
110 ResourceDir *resource = (ResourceDir*)( res ); 112 ResourceDir *resource = (ResourceDir*)( res );
111 113
112 if ( !resource ) { 114 if ( !resource ) {
113 kdDebug(5700) << "ResourceDirConfig::loadSettings(): cast failed" << endl; 115 kdDebug(5700) << "ResourceDirConfig::loadSettings(): cast failed" << endl;
114 return; 116 return;
115 } 117 }
116 118
117 if ( mInEditMode ) 119 if ( mInEditMode )
118 resource->setFormat( mFormatTypes[ mFormatBox->currentItem() ] ); 120 resource->setFormat( mFormatTypes[ mFormatBox->currentItem() ] );
119 121
120 resource->setPath( mFileNameEdit->url() ); 122 resource->setPath( mFileNameEdit->url() );
121} 123}
122 124
123//US #include "resourcedirconfig.moc" 125//US #include "resourcedirconfig.moc"