Diffstat (limited to 'kabc/plugins/olaccess/resourceolaccessconfig.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kabc/plugins/olaccess/resourceolaccessconfig.cpp | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/kabc/plugins/olaccess/resourceolaccessconfig.cpp b/kabc/plugins/olaccess/resourceolaccessconfig.cpp new file mode 100644 index 0000000..240f1d7 --- a/dev/null +++ b/kabc/plugins/olaccess/resourceolaccessconfig.cpp | |||
@@ -0,0 +1,108 @@ | |||
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 | #include <unistd.h> | ||
37 | |||
38 | #include <qdir.h> | ||
39 | #include <qfile.h> | ||
40 | #include "resourcesharpdtm.h" | ||
41 | |||
42 | #include "resourcesharpdtmconfig.h" | ||
43 | |||
44 | #include <sl/slzdb.h> | ||
45 | |||
46 | using namespace KABC; | ||
47 | |||
48 | ResourceSharpDTMConfig::ResourceSharpDTMConfig( QWidget* parent, const char* name ) | ||
49 | : ConfigWidget( parent, name ) | ||
50 | { | ||
51 | QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0, | ||
52 | KDialog::spacingHint() ); | ||
53 | |||
54 | QLabel *label = new QLabel( i18n( "Location:" ), this ); | ||
55 | mFileNameEdit = new KURLRequester( this ); | ||
56 | |||
57 | connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ), | ||
58 | SLOT( checkFilePermissions( const QString & ) ) ); | ||
59 | |||
60 | mainLayout->addWidget( label, 0, 0 ); | ||
61 | mainLayout->addWidget( mFileNameEdit, 0, 1 ); | ||
62 | |||
63 | } | ||
64 | |||
65 | void ResourceSharpDTMConfig::loadSettings( KRES::Resource *res ) | ||
66 | { | ||
67 | //US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); | ||
68 | ResourceSharpDTM *resource = (ResourceSharpDTM*)( res ); | ||
69 | |||
70 | if ( !resource ) { | ||
71 | kdDebug(5700) << "ResourceSharpDTMConfig::loadSettings(): cast failed" << endl; | ||
72 | return; | ||
73 | } | ||
74 | |||
75 | mFileNameEdit->setURL( resource->fileName() ); | ||
76 | if ( mFileNameEdit->url().isEmpty() ) | ||
77 | mFileNameEdit->setURL( SlZDataBase::addressbookFileName() ); | ||
78 | |||
79 | //US Sharp DTM resources are ReadOnly by definition | ||
80 | emit setPersistentReadOnly( true ); | ||
81 | |||
82 | //US we can not choose the filename for the sharp backend => make it readonly. | ||
83 | mFileNameEdit->setEnabled( false ); | ||
84 | |||
85 | } | ||
86 | |||
87 | void ResourceSharpDTMConfig::saveSettings( KRES::Resource *res ) | ||
88 | { | ||
89 | //US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); | ||
90 | ResourceSharpDTM *resource = (ResourceSharpDTM*)( res ); | ||
91 | |||
92 | if ( !resource ) { | ||
93 | kdDebug(5700) << "ResourceSharpDTMConfig::saveSettings(): cast failed" << endl; | ||
94 | return; | ||
95 | } | ||
96 | |||
97 | resource->setFileName( mFileNameEdit->url() ); | ||
98 | } | ||
99 | |||
100 | void ResourceSharpDTMConfig::checkFilePermissions( const QString& fileName ) | ||
101 | { | ||
102 | // If file exist but is not writeable... | ||
103 | /*US | ||
104 | if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) | ||
105 | emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 ); | ||
106 | */ | ||
107 | } | ||
108 | |||