Diffstat (limited to 'kabc/plugins/qtopia/resourceqtopiaconfig.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopiaconfig.cpp | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/kabc/plugins/qtopia/resourceqtopiaconfig.cpp b/kabc/plugins/qtopia/resourceqtopiaconfig.cpp new file mode 100644 index 0000000..8cb8505 --- a/dev/null +++ b/kabc/plugins/qtopia/resourceqtopiaconfig.cpp | |||
@@ -0,0 +1,107 @@ | |||
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 "resourceqtopia.h" | ||
41 | //US #include <qpe/qpeapplication.h> | ||
42 | |||
43 | //US #include "stdaddressbook.h" | ||
44 | |||
45 | #include "resourceqtopiaconfig.h" | ||
46 | |||
47 | using namespace KABC; | ||
48 | |||
49 | ResourceOpieConfig::ResourceOpieConfig( QWidget* parent, const char* name ) | ||
50 | : ConfigWidget( parent, name ) | ||
51 | { | ||
52 | //qDebug("ResourceFileConfig::ResourceFileConfig"); | ||
53 | |||
54 | QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0, | ||
55 | KDialog::spacingHint() ); | ||
56 | |||
57 | QLabel *label = new QLabel( i18n( "Location:" ), this ); | ||
58 | mFileNameEdit = new KURLRequester( this ); | ||
59 | |||
60 | connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ), | ||
61 | SLOT( checkFilePermissions( const QString & ) ) ); | ||
62 | |||
63 | mainLayout->addWidget( label, 0, 0 ); | ||
64 | mainLayout->addWidget( mFileNameEdit, 0, 1 ); | ||
65 | } | ||
66 | |||
67 | void ResourceOpieConfig::loadSettings( KRES::Resource *res ) | ||
68 | { | ||
69 | //US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); | ||
70 | ResourceOpie *resource = (ResourceOpie*)( res ); | ||
71 | |||
72 | if ( !resource ) { | ||
73 | kdDebug(5700) << "ResourceOpieConfig::loadSettings(): cast failed" << endl; | ||
74 | return; | ||
75 | } | ||
76 | |||
77 | mFileNameEdit->setURL( resource->fileName() ); | ||
78 | if ( mFileNameEdit->url().isEmpty() ) | ||
79 | mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" ); | ||
80 | |||
81 | //US Opie resources are ReadOnly by definition | ||
82 | emit setPersistentReadOnly( true ); | ||
83 | } | ||
84 | |||
85 | void ResourceOpieConfig::saveSettings( KRES::Resource *res ) | ||
86 | { | ||
87 | //US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); | ||
88 | ResourceOpie *resource = (ResourceOpie*)( res ); | ||
89 | |||
90 | if ( !resource ) { | ||
91 | kdDebug(5700) << "ResourceOpieConfig::saveSettings(): cast failed" << endl; | ||
92 | return; | ||
93 | } | ||
94 | |||
95 | resource->setFileName( mFileNameEdit->url() ); | ||
96 | } | ||
97 | |||
98 | void ResourceOpieConfig::checkFilePermissions( const QString& fileName ) | ||
99 | { | ||
100 | // If file exist but is not writeable... | ||
101 | /*US | ||
102 | if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) | ||
103 | emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 ); | ||
104 | */ | ||
105 | } | ||
106 | |||
107 | //US #include "resourceopieconfig.moc" | ||