summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-07-09 08:12:00 (UTC)
committer ulf69 <ulf69>2004-07-09 08:12:00 (UTC)
commitaae8af24992bf3b7b59fb425955153b86f31bb5d (patch) (unidiff)
tree2ad2e501a14c5a96bf5c7deebd3638bed405350e
parentde99e22a7093e857ee3c08a67ccc389d6374099a (diff)
downloadkdepimpi-aae8af24992bf3b7b59fb425955153b86f31bb5d.zip
kdepimpi-aae8af24992bf3b7b59fb425955153b86f31bb5d.tar.gz
kdepimpi-aae8af24992bf3b7b59fb425955153b86f31bb5d.tar.bz2
IntDateFormat is now an enum instead of an ionteger value
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/field.cpp8
-rw-r--r--kabc/plugins/opie/resourceopie.cpp16
-rw-r--r--kabc/plugins/opie/resourceopieconfig.cpp11
-rw-r--r--kabc/plugins/opie/resourceopieconfig.h3
4 files changed, 20 insertions, 18 deletions
diff --git a/kabc/field.cpp b/kabc/field.cpp
index bc2e176..e27970e 100644
--- a/kabc/field.cpp
+++ b/kabc/field.cpp
@@ -240,52 +240,52 @@ QString Field::value( const KABC::Addressee &a )
240 case FieldImpl::AdditionalName: 240 case FieldImpl::AdditionalName:
241 return a.additionalName(); 241 return a.additionalName();
242 case FieldImpl::Prefix: 242 case FieldImpl::Prefix:
243 return a.prefix(); 243 return a.prefix();
244 case FieldImpl::Suffix: 244 case FieldImpl::Suffix:
245 return a.suffix(); 245 return a.suffix();
246 case FieldImpl::NickName: 246 case FieldImpl::NickName:
247 return a.nickName(); 247 return a.nickName();
248 case FieldImpl::Mailer: 248 case FieldImpl::Mailer:
249 return a.mailer(); 249 return a.mailer();
250 case FieldImpl::Title: 250 case FieldImpl::Title:
251 return a.title(); 251 return a.title();
252 case FieldImpl::Role: 252 case FieldImpl::Role:
253 return a.role(); 253 return a.role();
254 case FieldImpl::Organization: 254 case FieldImpl::Organization:
255 return a.organization(); 255 return a.organization();
256 case FieldImpl::Note: 256 case FieldImpl::Note:
257 return a.note(); 257 return a.note();
258 case FieldImpl::Email: 258 case FieldImpl::Email:
259 return a.preferredEmail(); 259 return a.preferredEmail();
260 case FieldImpl::Birthday: 260 case FieldImpl::Birthday:
261 if ( a.birthday().isValid() ) { 261 if ( a.birthday().isValid() ) {
262//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); 262//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate );
263// But Qt::IsoDate was not specified. 263// But Qt::IsoDate was not specified.
264 QString _oldFormat = KGlobal::locale()->dateFormat(); 264// QString _oldFormat = KGlobal::locale()->dateFormat();
265 KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate 265// KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate
266 QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false); 266 QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate);
267 KGlobal::locale()->setDateFormat(_oldFormat); 267// KGlobal::locale()->setDateFormat(_oldFormat);
268 return dt; 268 return dt;
269 } 269 }
270 else 270 else
271 return QString::null; 271 return QString::null;
272 case FieldImpl::Url: 272 case FieldImpl::Url:
273 return a.url().prettyURL(); 273 return a.url().prettyURL();
274//US 274//US
275 case FieldImpl::Resource: 275 case FieldImpl::Resource:
276 return a.resource()->resourceName(); 276 return a.resource()->resourceName();
277 case FieldImpl::HomePhone: 277 case FieldImpl::HomePhone:
278 return a.phoneNumber( PhoneNumber::Home ).number(); 278 return a.phoneNumber( PhoneNumber::Home ).number();
279 case FieldImpl::BusinessPhone: 279 case FieldImpl::BusinessPhone:
280 return a.phoneNumber( PhoneNumber::Work ).number(); 280 return a.phoneNumber( PhoneNumber::Work ).number();
281 case FieldImpl::MobilePhone: 281 case FieldImpl::MobilePhone:
282 return a.phoneNumber( PhoneNumber::Cell ).number(); 282 return a.phoneNumber( PhoneNumber::Cell ).number();
283 case FieldImpl::HomeFax: 283 case FieldImpl::HomeFax:
284 return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); 284 return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number();
285 case FieldImpl::BusinessFax: 285 case FieldImpl::BusinessFax:
286 return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); 286 return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number();
287 case FieldImpl::CarPhone: 287 case FieldImpl::CarPhone:
288 return a.phoneNumber( PhoneNumber::Car ).number(); 288 return a.phoneNumber( PhoneNumber::Car ).number();
289 case FieldImpl::Isdn: 289 case FieldImpl::Isdn:
290 return a.phoneNumber( PhoneNumber::Isdn ).number(); 290 return a.phoneNumber( PhoneNumber::Isdn ).number();
291 case FieldImpl::Pager: 291 case FieldImpl::Pager:
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index 3b2a6b7..a7d271f 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -76,64 +76,64 @@ ResourceOpie::ResourceOpie( const KConfig *config )
76 76
77 } 77 }
78 78
79// qDebug("ResourceOpie::ResourceOpie : %s", fileName.latin1() ); 79// qDebug("ResourceOpie::ResourceOpie : %s", fileName.latin1() );
80 80
81 init( fileName ); 81 init( fileName );
82} 82}
83 83
84ResourceOpie::ResourceOpie( const QString &fileName ) 84ResourceOpie::ResourceOpie( const QString &fileName )
85 : Resource( 0 ) 85 : Resource( 0 )
86{ 86{
87// qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1()); 87// qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1());
88 init( fileName ); 88 init( fileName );
89} 89}
90 90
91void ResourceOpie::init( const QString &fileName ) 91void ResourceOpie::init( const QString &fileName )
92{ 92{
93 93
94/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods 94/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods
95 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 95 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
96 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 96 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
97 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 97 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
98*/ 98*/
99 //US opie addressbook is always readonly 99 //US opie addressbook is always readonly
100 setReadOnly( true ); 100//US setReadOnly( true );
101 101
102 setFileName( fileName ); 102 setFileName( fileName );
103 103
104} 104}
105 105
106ResourceOpie::~ResourceOpie() 106ResourceOpie::~ResourceOpie()
107{ 107{
108 if (mConverter != 0) 108 if (mConverter != 0)
109 delete mConverter; 109 delete mConverter;
110} 110}
111 111
112void ResourceOpie::writeConfig( KConfig *config ) 112void ResourceOpie::writeConfig( KConfig *config )
113{ 113{
114 //US opie addressbook is always readonly 114 //US opie addressbook is always readonly
115 setReadOnly( true ); 115//US setReadOnly( true );
116 116
117 Resource::writeConfig( config ); 117 Resource::writeConfig( config );
118 118
119 config->writeEntry( "FileName", mFileName ); 119 config->writeEntry( "FileName", mFileName );
120 120
121// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); 121// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
122 122
123} 123}
124 124
125Ticket *ResourceOpie::requestSaveTicket() 125Ticket *ResourceOpie::requestSaveTicket()
126{ 126{
127 kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl; 127 kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl;
128 128
129 if ( !addressBook() ) return 0; 129 if ( !addressBook() ) return 0;
130 130
131 if ( !lock( mFileName ) ) { 131 if ( !lock( mFileName ) ) {
132 kdDebug(5700) << "ResourceOpie::requestSaveTicket(): Unable to lock file '" 132 kdDebug(5700) << "ResourceOpie::requestSaveTicket(): Unable to lock file '"
133 << mFileName << "'" << endl; 133 << mFileName << "'" << endl;
134 return 0; 134 return 0;
135 } 135 }
136 return createTicket( this ); 136 return createTicket( this );
137} 137}
138 138
139 139
@@ -173,55 +173,65 @@ bool ResourceOpie::doOpen()
173 173
174void ResourceOpie::doClose() 174void ResourceOpie::doClose()
175{ 175{
176// qDebug("ResourceOpie::doClose() %s", mFileName.latin1()); 176// qDebug("ResourceOpie::doClose() %s", mFileName.latin1());
177} 177}
178 178
179bool ResourceOpie::load() 179bool ResourceOpie::load()
180{ 180{
181// qDebug("ResourceOpie::load() %s", mFileName.latin1()); 181// qDebug("ResourceOpie::load() %s", mFileName.latin1());
182 kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl; 182 kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl;
183 183
184 qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1()); 184 qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1());
185 185
186 OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName ); 186 OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName );
187 OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false); 187 OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false);
188 188
189 if ( !access ) { 189 if ( !access ) {
190 qDebug("Unable to load file() %s", mFileName.latin1()); 190 qDebug("Unable to load file() %s", mFileName.latin1());
191 addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) ); 191 addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) );
192 return false; 192 return false;
193 } 193 }
194 194
195 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available 195 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available
196 196
197 bool res = false;
197 if (mConverter == 0) 198 if (mConverter == 0)
199 {
198 mConverter = new OpieConverter(); 200 mConverter = new OpieConverter();
201 res = mConverter->init();
202 if ( !res )
203 {
204 qDebug("Unable to initialize opie converter. Most likely a problem with the category file");
205 addressBook()->error( i18n( "Unable to initialize opie converter. Most likely a problem with the category file" ) );
206 delete access;
207 return false;
208 }
209 }
199 210
200 211
201 OContactAccess::List::Iterator it; 212 OContactAccess::List::Iterator it;
202 OContactAccess::List allList = access->allRecords(); 213 OContactAccess::List allList = access->allRecords();
203 bool res = false;
204 for ( it = allList.begin(); it != allList.end(); ++it ) 214 for ( it = allList.begin(); it != allList.end(); ++it )
205 { 215 {
206 OContact c = (*it); 216 OContact c = (*it);
207 217
208 KABC::Addressee addressee; 218 KABC::Addressee addressee;
209 219
210 res = mConverter->opieToAddressee( c, addressee ); 220 res = mConverter->opieToAddressee( c, addressee );
211 221
212 if ( !addressee.isEmpty() && res ) 222 if ( !addressee.isEmpty() && res )
213 { 223 {
214 addressee.setResource( this ); 224 addressee.setResource( this );
215 addressBook()->insertAddressee( addressee ); 225 addressBook()->insertAddressee( addressee );
216 } 226 }
217 227
218// qDebug("found %s", c.fullName().latin1()); 228// qDebug("found %s", c.fullName().latin1());
219 } 229 }
220 230
221 delete access; 231 delete access;
222 // it seems so, that deletion of access deletes backend as well 232 // it seems so, that deletion of access deletes backend as well
223 //delete backend; 233 //delete backend;
224 234
225 return true; 235 return true;
226} 236}
227 237
diff --git a/kabc/plugins/opie/resourceopieconfig.cpp b/kabc/plugins/opie/resourceopieconfig.cpp
index f4cc4f9..eef9cc9 100644
--- a/kabc/plugins/opie/resourceopieconfig.cpp
+++ b/kabc/plugins/opie/resourceopieconfig.cpp
@@ -41,71 +41,66 @@ $Id$
41//US #include <qpe/qpeapplication.h> 41//US #include <qpe/qpeapplication.h>
42 42
43//US #include "stdaddressbook.h" 43//US #include "stdaddressbook.h"
44 44
45#include "resourceopieconfig.h" 45#include "resourceopieconfig.h"
46 46
47using namespace KABC; 47using namespace KABC;
48 48
49ResourceOpieConfig::ResourceOpieConfig( QWidget* parent, const char* name ) 49ResourceOpieConfig::ResourceOpieConfig( QWidget* parent, const char* name )
50 : ConfigWidget( parent, name ) 50 : ConfigWidget( parent, name )
51{ 51{
52//qDebug("ResourceFileConfig::ResourceFileConfig"); 52//qDebug("ResourceFileConfig::ResourceFileConfig");
53 53
54 QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0, 54 QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0,
55 KDialog::spacingHint() ); 55 KDialog::spacingHint() );
56 56
57 QLabel *label = new QLabel( i18n( "Location:" ), this ); 57 QLabel *label = new QLabel( i18n( "Location:" ), this );
58 mFileNameEdit = new KURLRequester( this ); 58 mFileNameEdit = new KURLRequester( this );
59 59
60 connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ), 60 connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ),
61 SLOT( checkFilePermissions( const QString & ) ) ); 61 SLOT( checkFilePermissions( const QString & ) ) );
62 62
63 mainLayout->addWidget( label, 0, 0 ); 63 mainLayout->addWidget( label, 0, 0 );
64 mainLayout->addWidget( mFileNameEdit, 0, 1 ); 64 mainLayout->addWidget( mFileNameEdit, 0, 1 );
65
66//US mInEditMode = false;
67}
68/*US
69void ResourceOpieConfig::setEditMode( bool value )
70{
71 mInEditMode = value;
72} 65}
73*/
74 66
75void ResourceOpieConfig::loadSettings( KRES::Resource *res ) 67void ResourceOpieConfig::loadSettings( KRES::Resource *res )
76{ 68{
77//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); 69//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
78 ResourceOpie *resource = (ResourceOpie*)( res ); 70 ResourceOpie *resource = (ResourceOpie*)( res );
79 71
80 if ( !resource ) { 72 if ( !resource ) {
81 kdDebug(5700) << "ResourceOpieConfig::loadSettings(): cast failed" << endl; 73 kdDebug(5700) << "ResourceOpieConfig::loadSettings(): cast failed" << endl;
82 return; 74 return;
83 } 75 }
84 76
85 mFileNameEdit->setURL( resource->fileName() ); 77 mFileNameEdit->setURL( resource->fileName() );
86 if ( mFileNameEdit->url().isEmpty() ) 78 if ( mFileNameEdit->url().isEmpty() )
87 mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" ); 79 mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" );
80
81 //US Opie resources are ReadOnly by definition
82 emit setPersistentReadOnly( true );
88} 83}
89 84
90void ResourceOpieConfig::saveSettings( KRES::Resource *res ) 85void ResourceOpieConfig::saveSettings( KRES::Resource *res )
91{ 86{
92//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); 87//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
93 ResourceOpie *resource = (ResourceOpie*)( res ); 88 ResourceOpie *resource = (ResourceOpie*)( res );
94 89
95 if ( !resource ) { 90 if ( !resource ) {
96 kdDebug(5700) << "ResourceOpieConfig::saveSettings(): cast failed" << endl; 91 kdDebug(5700) << "ResourceOpieConfig::saveSettings(): cast failed" << endl;
97 return; 92 return;
98 } 93 }
99 94
100 resource->setFileName( mFileNameEdit->url() ); 95 resource->setFileName( mFileNameEdit->url() );
101} 96}
102 97
103void ResourceOpieConfig::checkFilePermissions( const QString& fileName ) 98void ResourceOpieConfig::checkFilePermissions( const QString& fileName )
104{ 99{
105 // If file exist but is not writeable... 100 // If file exist but is not writeable...
106/*US 101/*US
107 if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) 102 if ( access( QFile::encodeName( fileName ), F_OK ) == 0 )
108 emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 ); 103 emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 );
109*/ 104*/
110} 105}
111 106
diff --git a/kabc/plugins/opie/resourceopieconfig.h b/kabc/plugins/opie/resourceopieconfig.h
index 533b7f4..8cc192c 100644
--- a/kabc/plugins/opie/resourceopieconfig.h
+++ b/kabc/plugins/opie/resourceopieconfig.h
@@ -21,41 +21,38 @@
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#ifndef RESOURCEOPIECONFIG_H 29#ifndef RESOURCEOPIECONFIG_H
30#define RESOURCEOPIECONFIG_H 30#define RESOURCEOPIECONFIG_H
31 31
32#include <kurlrequester.h> 32#include <kurlrequester.h>
33 33
34#include <kresources/configwidget.h> 34#include <kresources/configwidget.h>
35 35
36namespace KABC { 36namespace KABC {
37 37
38class ResourceOpieConfig : public KRES::ConfigWidget 38class ResourceOpieConfig : public KRES::ConfigWidget
39{ 39{
40 Q_OBJECT 40 Q_OBJECT
41 41
42public: 42public:
43 ResourceOpieConfig( QWidget* parent = 0, const char* name = 0 ); 43 ResourceOpieConfig( QWidget* parent = 0, const char* name = 0 );
44 44
45//US void setEditMode( bool value );
46
47public slots: 45public slots:
48 void loadSettings( KRES::Resource *resource ); 46 void loadSettings( KRES::Resource *resource );
49 void saveSettings( KRES::Resource *resource ); 47 void saveSettings( KRES::Resource *resource );
50 48
51protected slots: 49protected slots:
52 void checkFilePermissions( const QString& fileName ); 50 void checkFilePermissions( const QString& fileName );
53 51
54private: 52private:
55 KURLRequester* mFileNameEdit; 53 KURLRequester* mFileNameEdit;
56//US bool mInEditMode;
57}; 54};
58 55
59} 56}
60 57
61#endif 58#endif