-rw-r--r-- | kabc/addressbook.cpp | 2 | ||||
-rw-r--r-- | kabc/plugins/dir/resourcedir.cpp | 2 | ||||
-rw-r--r-- | kabc/plugins/file/resourcefile.cpp | 28 | ||||
-rw-r--r-- | kabc/plugins/ldap/resourceldap.cpp | 2 | ||||
-rw-r--r-- | kabc/plugins/opie/resourceopie.cpp | 2 | ||||
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 2 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 2 | ||||
-rw-r--r-- | kabc/resource.cpp | 5 | ||||
-rw-r--r-- | kabc/resource.h | 2 | ||||
-rw-r--r-- | kabc/stdaddressbook.cpp | 36 | ||||
-rw-r--r-- | kabc/syncprefwidget.cpp | 681 | ||||
-rw-r--r-- | kabc/syncprefwidget.h | 138 | ||||
-rw-r--r-- | microkde/kresources/configdialog.cpp | 78 | ||||
-rw-r--r-- | microkde/kresources/configdialog.h | 4 | ||||
-rw-r--r-- | microkde/kresources/configpage.cpp | 15 | ||||
-rw-r--r-- | microkde/kresources/factory.cpp | 4 | ||||
-rw-r--r-- | microkde/kresources/factory.h | 5 | ||||
-rw-r--r-- | microkde/kresources/resource.h | 8 | ||||
-rw-r--r-- | microkde/kresources/syncwidget.h | 10 |
19 files changed, 512 insertions, 514 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 20310a0..c61b387 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -206,65 +206,65 @@ AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | |||
206 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 206 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
207 | { | 207 | { |
208 | return ( d->mIt == it.d->mIt ); | 208 | return ( d->mIt == it.d->mIt ); |
209 | } | 209 | } |
210 | 210 | ||
211 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 211 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
212 | { | 212 | { |
213 | return ( d->mIt != it.d->mIt ); | 213 | return ( d->mIt != it.d->mIt ); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | AddressBook::AddressBook() | 217 | AddressBook::AddressBook() |
218 | { | 218 | { |
219 | init(0, "contact"); | 219 | init(0, "contact"); |
220 | } | 220 | } |
221 | 221 | ||
222 | AddressBook::AddressBook( const QString &config ) | 222 | AddressBook::AddressBook( const QString &config ) |
223 | { | 223 | { |
224 | init(config, "contact"); | 224 | init(config, "contact"); |
225 | } | 225 | } |
226 | 226 | ||
227 | AddressBook::AddressBook( const QString &config, const QString &family ) | 227 | AddressBook::AddressBook( const QString &config, const QString &family ) |
228 | { | 228 | { |
229 | init(config, family); | 229 | init(config, family); |
230 | 230 | ||
231 | } | 231 | } |
232 | 232 | ||
233 | // the default family is "contact" | 233 | // the default family is "contact" |
234 | void AddressBook::init(const QString &config, const QString &family ) | 234 | void AddressBook::init(const QString &config, const QString &family ) |
235 | { | 235 | { |
236 | d = new AddressBookData; | 236 | d = new AddressBookData; |
237 | if (config != 0) { | 237 | if (config != 0) { |
238 | d->mConfig = new KConfig( config ); | 238 | d->mConfig = new KConfig( locateLocal("config", config) ); |
239 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 239 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
240 | } | 240 | } |
241 | else { | 241 | else { |
242 | d->mConfig = 0; | 242 | d->mConfig = 0; |
243 | // qDebug("AddressBook::init 1 config=0"); | 243 | // qDebug("AddressBook::init 1 config=0"); |
244 | } | 244 | } |
245 | 245 | ||
246 | //US d->mErrorHandler = 0; | 246 | //US d->mErrorHandler = 0; |
247 | d->mManager = new KRES::Manager<Resource>( family, false ); | 247 | d->mManager = new KRES::Manager<Resource>( family, false ); |
248 | d->mManager->readConfig( d->mConfig ); | 248 | d->mManager->readConfig( d->mConfig ); |
249 | } | 249 | } |
250 | 250 | ||
251 | AddressBook::~AddressBook() | 251 | AddressBook::~AddressBook() |
252 | { | 252 | { |
253 | delete d->mConfig; d->mConfig = 0; | 253 | delete d->mConfig; d->mConfig = 0; |
254 | delete d->mManager; d->mManager = 0; | 254 | delete d->mManager; d->mManager = 0; |
255 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 255 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
256 | delete d; d = 0; | 256 | delete d; d = 0; |
257 | } | 257 | } |
258 | 258 | ||
259 | bool AddressBook::load() | 259 | bool AddressBook::load() |
260 | { | 260 | { |
261 | 261 | ||
262 | 262 | ||
263 | clear(); | 263 | clear(); |
264 | 264 | ||
265 | KRES::Manager<Resource>::ActiveIterator it; | 265 | KRES::Manager<Resource>::ActiveIterator it; |
266 | bool ok = true; | 266 | bool ok = true; |
267 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 267 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
268 | if ( !(*it)->load() ) { | 268 | if ( !(*it)->load() ) { |
269 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 269 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
270 | ok = false; | 270 | ok = false; |
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp index 29f1e3a..eccd482 100644 --- a/kabc/plugins/dir/resourcedir.cpp +++ b/kabc/plugins/dir/resourcedir.cpp | |||
@@ -42,65 +42,65 @@ $Id$ | |||
42 | //US #include <kgenericfactory.h> | 42 | //US #include <kgenericfactory.h> |
43 | #include <kglobal.h> | 43 | #include <kglobal.h> |
44 | #include <klocale.h> | 44 | #include <klocale.h> |
45 | #include <kstandarddirs.h> | 45 | #include <kstandarddirs.h> |
46 | #include <kurlrequester.h> | 46 | #include <kurlrequester.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | 48 | ||
49 | #include "addressbook.h" | 49 | #include "addressbook.h" |
50 | 50 | ||
51 | #include "formatfactory.h" | 51 | #include "formatfactory.h" |
52 | 52 | ||
53 | #include "resourcedirconfig.h" | 53 | #include "resourcedirconfig.h" |
54 | #include "stdaddressbook.h" | 54 | #include "stdaddressbook.h" |
55 | 55 | ||
56 | //US | 56 | //US |
57 | #include <qdir.h> | 57 | #include <qdir.h> |
58 | 58 | ||
59 | #include "resourcedir.h" | 59 | #include "resourcedir.h" |
60 | #include "syncprefwidget.h" | 60 | #include "syncprefwidget.h" |
61 | 61 | ||
62 | using namespace KABC; | 62 | using namespace KABC; |
63 | 63 | ||
64 | extern "C" | 64 | extern "C" |
65 | #ifdef _WIN32_ | 65 | #ifdef _WIN32_ |
66 | __declspec(dllexport) | 66 | __declspec(dllexport) |
67 | #else | 67 | #else |
68 | { | 68 | { |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | //US void *init_kabc_dir() | 71 | //US void *init_kabc_dir() |
72 | void *init_microkabc_dir() | 72 | void *init_microkabc_dir() |
73 | { | 73 | { |
74 | return new KRES::PluginFactory<ResourceDir,ResourceDirConfig, SyncPrefWidget>(); | 74 | return new KRES::PluginFactory<ResourceDir,ResourceDirConfig, SyncPrefWidgetContainer>(); |
75 | } | 75 | } |
76 | #ifndef _WIN32_ | 76 | #ifndef _WIN32_ |
77 | } | 77 | } |
78 | #endif | 78 | #endif |
79 | 79 | ||
80 | ResourceDir::ResourceDir( const KConfig *config, bool syncable ) | 80 | ResourceDir::ResourceDir( const KConfig *config, bool syncable ) |
81 | : Resource( config, syncable ) | 81 | : Resource( config, syncable ) |
82 | { | 82 | { |
83 | QString path; | 83 | QString path; |
84 | 84 | ||
85 | KConfig *cfg = (KConfig *)config; | 85 | KConfig *cfg = (KConfig *)config; |
86 | if ( cfg ) { | 86 | if ( cfg ) { |
87 | //US path = config->readEntry( "FilePath" ); | 87 | //US path = config->readEntry( "FilePath" ); |
88 | path = cfg->readEntry( "FilePath", StdAddressBook::directoryName() ); | 88 | path = cfg->readEntry( "FilePath", StdAddressBook::directoryName() ); |
89 | //US mFormatName = config->readEntry( "FileFormat" ); | 89 | //US mFormatName = config->readEntry( "FileFormat" ); |
90 | mFormatName = cfg->readEntry( "FileFormat", "vcard" ); | 90 | mFormatName = cfg->readEntry( "FileFormat", "vcard" ); |
91 | } else { | 91 | } else { |
92 | path = StdAddressBook::directoryName(); | 92 | path = StdAddressBook::directoryName(); |
93 | mFormatName = "vcard"; | 93 | mFormatName = "vcard"; |
94 | } | 94 | } |
95 | 95 | ||
96 | 96 | ||
97 | FormatFactory *factory = FormatFactory::self(); | 97 | FormatFactory *factory = FormatFactory::self(); |
98 | mFormat = factory->format( mFormatName ); | 98 | mFormat = factory->format( mFormatName ); |
99 | 99 | ||
100 | if ( !mFormat ) { | 100 | if ( !mFormat ) { |
101 | mFormatName = "vcard"; | 101 | mFormatName = "vcard"; |
102 | mFormat = factory->format( mFormatName ); | 102 | mFormat = factory->format( mFormatName ); |
103 | } | 103 | } |
104 | 104 | ||
105 | /*US | 105 | /*US |
106 | //US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1()); | 106 | //US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1()); |
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp index d98efc8..da2e4d7 100644 --- a/kabc/plugins/file/resourcefile.cpp +++ b/kabc/plugins/file/resourcefile.cpp | |||
@@ -37,122 +37,112 @@ $Id$ | |||
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | 38 | ||
39 | #include <kapplication.h> | 39 | #include <kapplication.h> |
40 | #include <kconfig.h> | 40 | #include <kconfig.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <klocale.h> | 42 | #include <klocale.h> |
43 | //US #include <ksavefile.h> | 43 | //US #include <ksavefile.h> |
44 | #include <kstandarddirs.h> | 44 | #include <kstandarddirs.h> |
45 | #include <kmessagebox.h> | 45 | #include <kmessagebox.h> |
46 | 46 | ||
47 | #include "formatfactory.h" | 47 | #include "formatfactory.h" |
48 | 48 | ||
49 | #include "resource.h" | 49 | #include "resource.h" |
50 | #include "resourcefileconfig.h" | 50 | #include "resourcefileconfig.h" |
51 | #include "stdaddressbook.h" | 51 | #include "stdaddressbook.h" |
52 | 52 | ||
53 | #include "resourcefile.h" | 53 | #include "resourcefile.h" |
54 | #include "syncprefwidget.h" | 54 | #include "syncprefwidget.h" |
55 | 55 | ||
56 | 56 | ||
57 | using namespace KABC; | 57 | using namespace KABC; |
58 | 58 | ||
59 | extern "C" | 59 | extern "C" |
60 | #ifdef _WIN32_ | 60 | #ifdef _WIN32_ |
61 | __declspec(dllexport) | 61 | __declspec(dllexport) |
62 | #else | 62 | #else |
63 | { | 63 | { |
64 | #endif | 64 | #endif |
65 | 65 | ||
66 | //US void *init_kabc_file() | 66 | //US void *init_kabc_file() |
67 | void *init_microkabc_file() | 67 | void *init_microkabc_file() |
68 | { | 68 | { |
69 | return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, SyncPrefWidget>(); | 69 | return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, SyncPrefWidgetContainer>(); |
70 | } | 70 | } |
71 | #ifndef _WIN32_ | 71 | #ifndef _WIN32_ |
72 | } | 72 | } |
73 | #endif | 73 | #endif |
74 | 74 | ||
75 | ResourceFile::ResourceFile( const KConfig *config, bool syncable ) | 75 | ResourceFile::ResourceFile( const KConfig *config, bool syncable ) |
76 | : Resource( config, syncable ) , mFormat( 0 ) | 76 | : Resource( config, syncable ) , mFormat( 0 ) |
77 | { | 77 | { |
78 | QString fileName, formatName; | 78 | QString fileName, formatName, default_fileName; |
79 | |||
80 | if (syncable == true) | ||
81 | default_fileName = "/home/polo/kdepim/apps/kabc/localfile.vcf"; | ||
82 | else | ||
83 | default_fileName = StdAddressBook::fileName(); | ||
79 | 84 | ||
80 | KConfig *cfg = (KConfig *)config; | 85 | KConfig *cfg = (KConfig *)config; |
81 | if ( cfg ) { | 86 | if ( cfg ) { |
82 | fileName = cfg->readEntry( "FileName", StdAddressBook::fileName() ); | 87 | fileName = cfg->readEntry( "FileName", default_fileName ); |
83 | formatName = cfg->readEntry( "FileFormat", "vcard" ); | 88 | formatName = cfg->readEntry( "FileFormat", "vcard" ); |
84 | // qDebug("ResourceFile::ResourceFile : 1 %s, %s", fileName.latin1(), formatName.latin1() ); | ||
85 | } else { | 89 | } else { |
86 | fileName = StdAddressBook::fileName(); | 90 | fileName = default_fileName; |
87 | formatName = "vcard"; | 91 | formatName = "vcard"; |
88 | // qDebug("ResourceFile::ResourceFile : 2 %s, %s", fileName.latin1(), formatName.latin1() ); | ||
89 | } | 92 | } |
90 | 93 | ||
91 | init( fileName, formatName ); | 94 | init( fileName, formatName ); |
92 | } | 95 | } |
93 | 96 | ||
94 | ResourceFile::ResourceFile( const QString &fileName, bool syncable , | 97 | ResourceFile::ResourceFile( const QString &fileName, bool syncable , |
95 | const QString &formatName ) | 98 | const QString &formatName ) |
96 | : Resource( 0, syncable ) | 99 | : Resource( 0, syncable ) |
97 | { | 100 | { |
98 | // qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); | 101 | // qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); |
99 | init( fileName, formatName ); | 102 | init( fileName, formatName ); |
100 | } | 103 | } |
101 | 104 | ||
102 | void ResourceFile::init( const QString &fileName, const QString &formatName ) | 105 | void ResourceFile::init( const QString &fileName, const QString &formatName ) |
103 | { | 106 | { |
104 | mFormatName = formatName; | 107 | mFormatName = formatName; |
105 | 108 | ||
106 | FormatFactory *factory = FormatFactory::self(); | 109 | FormatFactory *factory = FormatFactory::self(); |
107 | mFormat = factory->format( mFormatName ); | 110 | mFormat = factory->format( mFormatName ); |
108 | 111 | ||
109 | if ( !mFormat ) { | 112 | if ( !mFormat ) { |
110 | mFormatName = "vcard"; | 113 | mFormatName = "vcard"; |
111 | mFormat = factory->format( mFormatName ); | 114 | mFormat = factory->format( mFormatName ); |
112 | } | 115 | } |
113 | 116 | ||
114 | /*US | ||
115 | //US qDebug("ResourceFile::init initialized with format %s ", formatName.latin1()); | ||
116 | if (mFormatName == "vcard") { | ||
117 | mFormat = new VCardFormatPlugin2(); | ||
118 | // qDebug("ResourceFile::init format VCardFormatPlugin2"); | ||
119 | } | ||
120 | else if (mFormatName == "binary") { | ||
121 | mFormat = new BinaryFormat(); | ||
122 | // qDebug("ResourceFile::init format BinaryFormat"); | ||
123 | } | ||
124 | else | ||
125 | qDebug("ResourceFile::init format unknown !!! %s ", formatName.latin1()); | ||
126 | */ | ||
127 | 117 | ||
128 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | 118 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); |
129 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | 119 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); |
130 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | 120 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); |
131 | 121 | ||
132 | setFileName( fileName ); | 122 | setFileName( fileName ); |
133 | } | 123 | } |
134 | 124 | ||
135 | ResourceFile::~ResourceFile() | 125 | ResourceFile::~ResourceFile() |
136 | { | 126 | { |
137 | delete mFormat; | 127 | delete mFormat; |
138 | mFormat = 0; | 128 | mFormat = 0; |
139 | } | 129 | } |
140 | 130 | ||
141 | void ResourceFile::writeConfig( KConfig *config ) | 131 | void ResourceFile::writeConfig( KConfig *config ) |
142 | { | 132 | { |
143 | 133 | ||
144 | config->setGroup( "Resource_" + identifier() ); | 134 | config->setGroup( "Resource_" + identifier() ); |
145 | Resource::writeConfig( config ); | 135 | Resource::writeConfig( config ); |
146 | 136 | ||
147 | config->writeEntry( "FileName", mFileName ); | 137 | config->writeEntry( "FileName", mFileName ); |
148 | config->writeEntry( "FileFormat", mFormatName ); | 138 | config->writeEntry( "FileFormat", mFormatName ); |
149 | 139 | ||
150 | // qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 140 | // qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); |
151 | 141 | ||
152 | } | 142 | } |
153 | 143 | ||
154 | Ticket *ResourceFile::requestSaveTicket() | 144 | Ticket *ResourceFile::requestSaveTicket() |
155 | { | 145 | { |
156 | kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl; | 146 | kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl; |
157 | 147 | ||
158 | if ( !addressBook() ) return 0; | 148 | if ( !addressBook() ) return 0; |
diff --git a/kabc/plugins/ldap/resourceldap.cpp b/kabc/plugins/ldap/resourceldap.cpp index 198e80a..17f115d 100644 --- a/kabc/plugins/ldap/resourceldap.cpp +++ b/kabc/plugins/ldap/resourceldap.cpp | |||
@@ -16,65 +16,65 @@ | |||
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 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <kdebug.h> | 28 | #include <kdebug.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #include <klineedit.h> | 30 | #include <klineedit.h> |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <kstringhandler.h> | 33 | #include <kstringhandler.h> |
34 | 34 | ||
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | 36 | ||
37 | #include "resourceldap.h" | 37 | #include "resourceldap.h" |
38 | #include "resourceldapconfig.h" | 38 | #include "resourceldapconfig.h" |
39 | #include "syncprefwidget.h" | 39 | #include "syncprefwidget.h" |
40 | 40 | ||
41 | using namespace KABC; | 41 | using namespace KABC; |
42 | 42 | ||
43 | extern "C" | 43 | extern "C" |
44 | { | 44 | { |
45 | //US void *init_kabc_ldap() | 45 | //US void *init_kabc_ldap() |
46 | void *init_microkabc_ldap() | 46 | void *init_microkabc_ldap() |
47 | { | 47 | { |
48 | return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig, SyncPrefWidget>(); | 48 | return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig, SyncPrefWidgetContainer>(); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | void addModOp( LDAPMod ***pmods, const QString &attr, const QString &value ); | 52 | void addModOp( LDAPMod ***pmods, const QString &attr, const QString &value ); |
53 | 53 | ||
54 | 54 | ||
55 | ResourceLDAP::ResourceLDAP( const KConfig *config, bool syncable ) | 55 | ResourceLDAP::ResourceLDAP( const KConfig *config, bool syncable ) |
56 | : Resource( config, syncable ), mPort( 389 ), mLdap( 0 ) | 56 | : Resource( config, syncable ), mPort( 389 ), mLdap( 0 ) |
57 | { | 57 | { |
58 | KConfig *cfg = (KConfig *)config; | 58 | KConfig *cfg = (KConfig *)config; |
59 | if ( cfg ) { | 59 | if ( cfg ) { |
60 | mUser = cfg->readEntry( "LdapUser" ); | 60 | mUser = cfg->readEntry( "LdapUser" ); |
61 | mPassword = KStringHandler::obscure( cfg->readEntry( "LdapPassword" ) ); | 61 | mPassword = KStringHandler::obscure( cfg->readEntry( "LdapPassword" ) ); |
62 | mDn = cfg->readEntry( "LdapDn" ); | 62 | mDn = cfg->readEntry( "LdapDn" ); |
63 | mHost = cfg->readEntry( "LdapHost" ); | 63 | mHost = cfg->readEntry( "LdapHost" ); |
64 | mPort = cfg->readNumEntry( "LdapPort", 389 ); | 64 | mPort = cfg->readNumEntry( "LdapPort", 389 ); |
65 | mFilter = cfg->readEntry( "LdapFilter" ); | 65 | mFilter = cfg->readEntry( "LdapFilter" ); |
66 | mAnonymous = cfg->readBoolEntry( "LdapAnonymous" ); | 66 | mAnonymous = cfg->readBoolEntry( "LdapAnonymous" ); |
67 | 67 | ||
68 | QStringList attributes = cfg->readListEntry( "LdapAttributes" ); | 68 | QStringList attributes = cfg->readListEntry( "LdapAttributes" ); |
69 | for ( uint pos = 0; pos < attributes.count(); pos += 2 ) | 69 | for ( uint pos = 0; pos < attributes.count(); pos += 2 ) |
70 | mAttributes.insert( attributes[ pos ], attributes[ pos + 1 ] ); | 70 | mAttributes.insert( attributes[ pos ], attributes[ pos + 1 ] ); |
71 | } | 71 | } |
72 | 72 | ||
73 | /** | 73 | /** |
74 | If you want to add new attributes, append them here, add a | 74 | If you want to add new attributes, append them here, add a |
75 | translation string in the ctor of AttributesDialog and | 75 | translation string in the ctor of AttributesDialog and |
76 | handle them in the load() method below. | 76 | handle them in the load() method below. |
77 | These are the default values from | 77 | These are the default values from |
78 | */ | 78 | */ |
79 | if ( mAttributes.count() == 0 ) { | 79 | if ( mAttributes.count() == 0 ) { |
80 | mAttributes.insert( "commonName", "cn" ); | 80 | mAttributes.insert( "commonName", "cn" ); |
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp index 9dfd473..4b811e9 100644 --- a/kabc/plugins/opie/resourceopie.cpp +++ b/kabc/plugins/opie/resourceopie.cpp | |||
@@ -32,65 +32,65 @@ $Id$ | |||
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qfileinfo.h> | 34 | #include <qfileinfo.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | 36 | ||
37 | #include <kapplication.h> | 37 | #include <kapplication.h> |
38 | #include <kconfig.h> | 38 | #include <kconfig.h> |
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | //US #include <ksavefile.h> | 41 | //US #include <ksavefile.h> |
42 | #include <kstandarddirs.h> | 42 | #include <kstandarddirs.h> |
43 | #include <kmessagebox.h> | 43 | #include <kmessagebox.h> |
44 | 44 | ||
45 | //US #include "formatfactory.h" | 45 | //US #include "formatfactory.h" |
46 | //US #include <qpe/qpeapplication.h> | 46 | //US #include <qpe/qpeapplication.h> |
47 | 47 | ||
48 | #include <opie/ocontactaccess.h> | 48 | #include <opie/ocontactaccess.h> |
49 | #include <opie/ocontactaccessbackend_xml.h> | 49 | #include <opie/ocontactaccessbackend_xml.h> |
50 | 50 | ||
51 | #include "resourceopieconfig.h" | 51 | #include "resourceopieconfig.h" |
52 | #include "stdaddressbook.h" | 52 | #include "stdaddressbook.h" |
53 | #include "syncprefwidget.h" | 53 | #include "syncprefwidget.h" |
54 | 54 | ||
55 | #include "opieconverter.h" | 55 | #include "opieconverter.h" |
56 | 56 | ||
57 | #include "resourceopie.h" | 57 | #include "resourceopie.h" |
58 | 58 | ||
59 | using namespace KABC; | 59 | using namespace KABC; |
60 | extern "C" | 60 | extern "C" |
61 | { | 61 | { |
62 | void *init_microkabc_opie() | 62 | void *init_microkabc_opie() |
63 | { | 63 | { |
64 | return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig, SyncPrefWidget>(); | 64 | return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig, SyncPrefWidgetContainer>(); |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | ResourceOpie::ResourceOpie( const KConfig *config, bool syncable ) | 68 | ResourceOpie::ResourceOpie( const KConfig *config, bool syncable ) |
69 | : Resource( config, syncable ), mAccess(0), mConverter (0) | 69 | : Resource( config, syncable ), mAccess(0), mConverter (0) |
70 | { | 70 | { |
71 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | 71 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; |
72 | 72 | ||
73 | KConfig *cfg = (KConfig *)config; | 73 | KConfig *cfg = (KConfig *)config; |
74 | if ( cfg ) { | 74 | if ( cfg ) { |
75 | fileName = cfg->readEntry( "FileName", fileName ); | 75 | fileName = cfg->readEntry( "FileName", fileName ); |
76 | 76 | ||
77 | } | 77 | } |
78 | 78 | ||
79 | init( fileName ); | 79 | init( fileName ); |
80 | } | 80 | } |
81 | 81 | ||
82 | ResourceOpie::ResourceOpie( const QString &fileName, bool syncable ) | 82 | ResourceOpie::ResourceOpie( const QString &fileName, bool syncable ) |
83 | : Resource( 0, syncable ) | 83 | : Resource( 0, syncable ) |
84 | { | 84 | { |
85 | init( fileName ); | 85 | init( fileName ); |
86 | } | 86 | } |
87 | 87 | ||
88 | void ResourceOpie::init( const QString &fileName ) | 88 | void ResourceOpie::init( const QString &fileName ) |
89 | { | 89 | { |
90 | qDebug("ResourceOpie::init()"); | 90 | qDebug("ResourceOpie::init()"); |
91 | 91 | ||
92 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | 92 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); |
93 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | 93 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); |
94 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | 94 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); |
95 | 95 | ||
96 | setFileName( fileName ); | 96 | setFileName( fileName ); |
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp index 5565580..93a4d33 100644 --- a/kabc/plugins/qtopia/resourceqtopia.cpp +++ b/kabc/plugins/qtopia/resourceqtopia.cpp | |||
@@ -29,65 +29,65 @@ $Id$ | |||
29 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | 30 | ||
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qfileinfo.h> | 33 | #include <qfileinfo.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | //US #include <qtimer.h> | 35 | //US #include <qtimer.h> |
36 | 36 | ||
37 | #include <kapplication.h> | 37 | #include <kapplication.h> |
38 | #include <kconfig.h> | 38 | #include <kconfig.h> |
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | //US #include <ksavefile.h> | 41 | //US #include <ksavefile.h> |
42 | #include <kstandarddirs.h> | 42 | #include <kstandarddirs.h> |
43 | #include <kmessagebox.h> | 43 | #include <kmessagebox.h> |
44 | 44 | ||
45 | #include <qpe/pim/addressbookaccess.h> | 45 | #include <qpe/pim/addressbookaccess.h> |
46 | 46 | ||
47 | 47 | ||
48 | #include "resourceqtopiaconfig.h" | 48 | #include "resourceqtopiaconfig.h" |
49 | #include "stdaddressbook.h" | 49 | #include "stdaddressbook.h" |
50 | 50 | ||
51 | #include "qtopiaconverter.h" | 51 | #include "qtopiaconverter.h" |
52 | #include "syncprefwidget.h" | 52 | #include "syncprefwidget.h" |
53 | 53 | ||
54 | #include "resourceqtopia.h" | 54 | #include "resourceqtopia.h" |
55 | 55 | ||
56 | using namespace KABC; | 56 | using namespace KABC; |
57 | extern "C" | 57 | extern "C" |
58 | { | 58 | { |
59 | void *init_microkabc_qtopia() | 59 | void *init_microkabc_qtopia() |
60 | { | 60 | { |
61 | return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, SyncPrefWidget>(); | 61 | return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, SyncPrefWidgetContainer>(); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | ResourceQtopia::ResourceQtopia( const KConfig *config, bool syncable ) | 65 | ResourceQtopia::ResourceQtopia( const KConfig *config, bool syncable ) |
66 | : Resource( config, syncable ), mConverter (0) | 66 | : Resource( config, syncable ), mConverter (0) |
67 | { | 67 | { |
68 | // we can not choose the filename. Therefore use the default to display | 68 | // we can not choose the filename. Therefore use the default to display |
69 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | 69 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; |
70 | init( fileName ); | 70 | init( fileName ); |
71 | } | 71 | } |
72 | 72 | ||
73 | ResourceQtopia::ResourceQtopia( const QString &fileName, bool syncable ) | 73 | ResourceQtopia::ResourceQtopia( const QString &fileName, bool syncable ) |
74 | : Resource( 0, syncable ) | 74 | : Resource( 0, syncable ) |
75 | { | 75 | { |
76 | init( fileName ); | 76 | init( fileName ); |
77 | } | 77 | } |
78 | 78 | ||
79 | void ResourceQtopia::init( const QString &fileName ) | 79 | void ResourceQtopia::init( const QString &fileName ) |
80 | { | 80 | { |
81 | 81 | ||
82 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | 82 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); |
83 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | 83 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); |
84 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | 84 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); |
85 | 85 | ||
86 | setFileName( fileName ); | 86 | setFileName( fileName ); |
87 | } | 87 | } |
88 | 88 | ||
89 | ResourceQtopia::~ResourceQtopia() | 89 | ResourceQtopia::~ResourceQtopia() |
90 | { | 90 | { |
91 | if (mConverter != 0) | 91 | if (mConverter != 0) |
92 | delete mConverter; | 92 | delete mConverter; |
93 | 93 | ||
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index 70c3718..b63df0c 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp | |||
@@ -31,65 +31,65 @@ $Id$ | |||
31 | 31 | ||
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qfileinfo.h> | 34 | #include <qfileinfo.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | //US #include <qtimer.h> | 36 | //US #include <qtimer.h> |
37 | 37 | ||
38 | #include <kapplication.h> | 38 | #include <kapplication.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <kdebug.h> | 40 | #include <kdebug.h> |
41 | #include <klocale.h> | 41 | #include <klocale.h> |
42 | //US #include <ksavefile.h> | 42 | //US #include <ksavefile.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kmessagebox.h> | 44 | #include <kmessagebox.h> |
45 | 45 | ||
46 | #include <sl/slzdb.h> | 46 | #include <sl/slzdb.h> |
47 | 47 | ||
48 | 48 | ||
49 | #include "resourcesharpdtmconfig.h" | 49 | #include "resourcesharpdtmconfig.h" |
50 | #include "resourcesharpdtm.h" | 50 | #include "resourcesharpdtm.h" |
51 | 51 | ||
52 | #include "syncprefwidget.h" | 52 | #include "syncprefwidget.h" |
53 | 53 | ||
54 | #include "stdaddressbook.h" | 54 | #include "stdaddressbook.h" |
55 | 55 | ||
56 | #include "sharpdtmconverter.h" | 56 | #include "sharpdtmconverter.h" |
57 | 57 | ||
58 | using namespace KABC; | 58 | using namespace KABC; |
59 | extern "C" | 59 | extern "C" |
60 | { | 60 | { |
61 | void *init_microkabc_sharpdtm() | 61 | void *init_microkabc_sharpdtm() |
62 | { | 62 | { |
63 | return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig,SyncPrefWidget>(); | 63 | return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig,SyncPrefWidgetContainer>(); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | ResourceSharpDTM::ResourceSharpDTM( const KConfig *config, bool syncable ) | 67 | ResourceSharpDTM::ResourceSharpDTM( const KConfig *config, bool syncable ) |
68 | : Resource( config, syncable ), mConverter (0) | 68 | : Resource( config, syncable ), mConverter (0) |
69 | { | 69 | { |
70 | // we can not choose the filename. Therefore use the default to display | 70 | // we can not choose the filename. Therefore use the default to display |
71 | 71 | ||
72 | QString fileName = SlZDataBase::addressbookFileName(); | 72 | QString fileName = SlZDataBase::addressbookFileName(); |
73 | init( fileName ); | 73 | init( fileName ); |
74 | } | 74 | } |
75 | 75 | ||
76 | ResourceSharpDTM::ResourceSharpDTM( const QString &fileName, bool syncable ) | 76 | ResourceSharpDTM::ResourceSharpDTM( const QString &fileName, bool syncable ) |
77 | : Resource( 0, syncable ) | 77 | : Resource( 0, syncable ) |
78 | { | 78 | { |
79 | init( fileName ); | 79 | init( fileName ); |
80 | } | 80 | } |
81 | 81 | ||
82 | void ResourceSharpDTM::init( const QString &fileName ) | 82 | void ResourceSharpDTM::init( const QString &fileName ) |
83 | { | 83 | { |
84 | 84 | ||
85 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | 85 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); |
86 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | 86 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); |
87 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | 87 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); |
88 | 88 | ||
89 | setFileName( fileName ); | 89 | setFileName( fileName ); |
90 | } | 90 | } |
91 | 91 | ||
92 | ResourceSharpDTM::~ResourceSharpDTM() | 92 | ResourceSharpDTM::~ResourceSharpDTM() |
93 | { | 93 | { |
94 | if (mConverter != 0) | 94 | if (mConverter != 0) |
95 | delete mConverter; | 95 | delete mConverter; |
diff --git a/kabc/resource.cpp b/kabc/resource.cpp index 2f03927..d39fd6a 100644 --- a/kabc/resource.cpp +++ b/kabc/resource.cpp | |||
@@ -84,56 +84,61 @@ Ticket *Resource::requestSaveTicket() | |||
84 | } | 84 | } |
85 | 85 | ||
86 | bool Resource::load() | 86 | bool Resource::load() |
87 | { | 87 | { |
88 | return true; | 88 | return true; |
89 | } | 89 | } |
90 | 90 | ||
91 | bool Resource::save( Ticket * ) | 91 | bool Resource::save( Ticket * ) |
92 | { | 92 | { |
93 | return false; | 93 | return false; |
94 | } | 94 | } |
95 | 95 | ||
96 | Ticket *Resource::createTicket( Resource *resource ) | 96 | Ticket *Resource::createTicket( Resource *resource ) |
97 | { | 97 | { |
98 | return new Ticket( resource ); | 98 | return new Ticket( resource ); |
99 | } | 99 | } |
100 | 100 | ||
101 | void Resource::removeAddressee( const Addressee& ) | 101 | void Resource::removeAddressee( const Addressee& ) |
102 | { | 102 | { |
103 | // do nothing | 103 | // do nothing |
104 | } | 104 | } |
105 | 105 | ||
106 | void Resource::cleanUp() | 106 | void Resource::cleanUp() |
107 | { | 107 | { |
108 | // do nothing | 108 | // do nothing |
109 | } | 109 | } |
110 | 110 | ||
111 | bool Resource::isSyncable() const | 111 | bool Resource::isSyncable() const |
112 | { | 112 | { |
113 | return (mSyncProfile != 0); | 113 | return (mSyncProfile != 0); |
114 | } | 114 | } |
115 | 115 | ||
116 | KSyncProfile* Resource::getSyncProfile() | ||
117 | { | ||
118 | return mSyncProfile; | ||
119 | } | ||
120 | |||
116 | 121 | ||
117 | QString Resource::fileName() const | 122 | QString Resource::fileName() const |
118 | { | 123 | { |
119 | return mFileName; | 124 | return mFileName; |
120 | } | 125 | } |
121 | 126 | ||
122 | void Resource::setFileName( const QString &fileName ) | 127 | void Resource::setFileName( const QString &fileName ) |
123 | { | 128 | { |
124 | mFileName = fileName; | 129 | mFileName = fileName; |
125 | } | 130 | } |
126 | 131 | ||
127 | /** | 132 | /** |
128 | * Set the name of resource.You can override this method, | 133 | * Set the name of resource.You can override this method, |
129 | * but also remember to call Resource::setResourceName(). | 134 | * but also remember to call Resource::setResourceName(). |
130 | */ | 135 | */ |
131 | void Resource::setResourceName( const QString &name ) | 136 | void Resource::setResourceName( const QString &name ) |
132 | { | 137 | { |
133 | KRES::Resource::setResourceName(name); | 138 | KRES::Resource::setResourceName(name); |
134 | if(mSyncProfile != 0) { | 139 | if(mSyncProfile != 0) { |
135 | mSyncProfile->setName( name ); | 140 | mSyncProfile->setName( name ); |
136 | } | 141 | } |
137 | 142 | ||
138 | } | 143 | } |
139 | 144 | ||
diff --git a/kabc/resource.h b/kabc/resource.h index 7d42f81..2024d2d 100644 --- a/kabc/resource.h +++ b/kabc/resource.h | |||
@@ -113,57 +113,59 @@ public: | |||
113 | * Save all addressees to the addressbook. | 113 | * Save all addressees to the addressbook. |
114 | * | 114 | * |
115 | * @param ticket The ticket you get by @ref requestSaveTicket() | 115 | * @param ticket The ticket you get by @ref requestSaveTicket() |
116 | */ | 116 | */ |
117 | virtual bool save( Ticket *ticket ); | 117 | virtual bool save( Ticket *ticket ); |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * Removes a addressee from resource. This method is mainly | 120 | * Removes a addressee from resource. This method is mainly |
121 | * used by record-based resources like LDAP or SQL. | 121 | * used by record-based resources like LDAP or SQL. |
122 | */ | 122 | */ |
123 | virtual void removeAddressee( const Addressee& addr ); | 123 | virtual void removeAddressee( const Addressee& addr ); |
124 | 124 | ||
125 | 125 | ||
126 | /** | 126 | /** |
127 | * This method is called by an error handler if the application | 127 | * This method is called by an error handler if the application |
128 | * crashed | 128 | * crashed |
129 | */ | 129 | */ |
130 | virtual void cleanUp(); | 130 | virtual void cleanUp(); |
131 | 131 | ||
132 | /** | 132 | /** |
133 | * Set name of file to be used for saving. | 133 | * Set name of file to be used for saving. |
134 | */ | 134 | */ |
135 | virtual void setFileName( const QString & ); | 135 | virtual void setFileName( const QString & ); |
136 | 136 | ||
137 | /** | 137 | /** |
138 | * Return name of file used for loading and saving the address book. | 138 | * Return name of file used for loading and saving the address book. |
139 | */ | 139 | */ |
140 | virtual QString fileName() const; | 140 | virtual QString fileName() const; |
141 | 141 | ||
142 | 142 | ||
143 | virtual bool isSyncable() const; | 143 | virtual bool isSyncable() const; |
144 | 144 | ||
145 | virtual KSyncProfile* getSyncProfile(); | ||
146 | |||
145 | /** | 147 | /** |
146 | * Set the name of resource.You can override this method, | 148 | * Set the name of resource.You can override this method, |
147 | * but also remember to call Resource::setResourceName(). | 149 | * but also remember to call Resource::setResourceName(). |
148 | */ | 150 | */ |
149 | virtual void setResourceName( const QString &name ); | 151 | virtual void setResourceName( const QString &name ); |
150 | 152 | ||
151 | 153 | ||
152 | 154 | ||
153 | protected: | 155 | protected: |
154 | Ticket *createTicket( Resource * ); | 156 | Ticket *createTicket( Resource * ); |
155 | virtual void doClose(); | 157 | virtual void doClose(); |
156 | 158 | ||
157 | private: | 159 | private: |
158 | AddressBook *mAddressBook; | 160 | AddressBook *mAddressBook; |
159 | KSyncProfile *mSyncProfile; | 161 | KSyncProfile *mSyncProfile; |
160 | QString mFileName; | 162 | QString mFileName; |
161 | 163 | ||
162 | }; | 164 | }; |
163 | 165 | ||
164 | 166 | ||
165 | } | 167 | } |
166 | 168 | ||
167 | 169 | ||
168 | 170 | ||
169 | #endif | 171 | #endif |
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp index 1e00cc6..760820e 100644 --- a/kabc/stdaddressbook.cpp +++ b/kabc/stdaddressbook.cpp | |||
@@ -30,199 +30,197 @@ $Id$ | |||
30 | #include <kresources/manager.h> | 30 | #include <kresources/manager.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <klocale.h> | 32 | #include <klocale.h> |
33 | #include <kstaticdeleter.h> | 33 | #include <kstaticdeleter.h> |
34 | #include <kstandarddirs.h> | 34 | #include <kstandarddirs.h> |
35 | 35 | ||
36 | #include "stdaddressbook.h" | 36 | #include "stdaddressbook.h" |
37 | 37 | ||
38 | using namespace KABC; | 38 | using namespace KABC; |
39 | 39 | ||
40 | StdAddressBook *StdAddressBook::mSelf = 0; | 40 | StdAddressBook *StdAddressBook::mSelf = 0; |
41 | bool StdAddressBook::mAutomaticSave = true; | 41 | bool StdAddressBook::mAutomaticSave = true; |
42 | 42 | ||
43 | static KStaticDeleter<StdAddressBook> addressBookDeleter; | 43 | static KStaticDeleter<StdAddressBook> addressBookDeleter; |
44 | 44 | ||
45 | QString StdAddressBook::fileName() | 45 | QString StdAddressBook::fileName() |
46 | { | 46 | { |
47 | return locateLocal( "data", "kabc/std.vcf" ); | 47 | return locateLocal( "data", "kabc/std.vcf" ); |
48 | } | 48 | } |
49 | 49 | ||
50 | QString StdAddressBook::directoryName() | 50 | QString StdAddressBook::directoryName() |
51 | { | 51 | { |
52 | return locateLocal( "data", "kabc/stdvcf" ); | 52 | return locateLocal( "data", "kabc/stdvcf" ); |
53 | } | 53 | } |
54 | 54 | ||
55 | void StdAddressBook::handleCrash() | 55 | void StdAddressBook::handleCrash() |
56 | { | 56 | { |
57 | StdAddressBook::self()->cleanUp(); | 57 | StdAddressBook::self()->cleanUp(); |
58 | } | 58 | } |
59 | 59 | ||
60 | StdAddressBook *StdAddressBook::self() | 60 | StdAddressBook *StdAddressBook::self() |
61 | { | 61 | { |
62 | 62 | ||
63 | if ( !mSelf ) | 63 | if ( !mSelf ) |
64 | { | 64 | { |
65 | QString appdir = StdAddressBook::setTempAppDir(); | 65 | QString appdir = StdAddressBook::setTempAppDir(); |
66 | 66 | ||
67 | kdDebug(5700) << "StdAddressBook::self()" << endl; | 67 | kdDebug(5700) << "StdAddressBook::self()" << endl; |
68 | // US im am not sure why I have to use the other format here?? | 68 | // US im am not sure why I have to use the other format here?? |
69 | #ifdef KAB_EMBEDDED | 69 | #ifdef KAB_EMBEDDED |
70 | mSelf = addressBookDeleter.setObject( new StdAddressBook ); | 70 | mSelf = addressBookDeleter.setObject( new StdAddressBook ); |
71 | #else //KAB_EMBEDDED | 71 | #else //KAB_EMBEDDED |
72 | addressBookDeleter.setObject( mSelf, new StdAddressBook ); | 72 | addressBookDeleter.setObject( mSelf, new StdAddressBook ); |
73 | #endif //KAB_EMBEDDED | 73 | #endif //KAB_EMBEDDED |
74 | KStandardDirs::setAppDir( appdir ); | 74 | KStandardDirs::setAppDir( appdir ); |
75 | } | 75 | } |
76 | 76 | ||
77 | return mSelf; | 77 | return mSelf; |
78 | } | 78 | } |
79 | 79 | ||
80 | QString StdAddressBook::setTempAppDir() | 80 | QString StdAddressBook::setTempAppDir() |
81 | { | 81 | { |
82 | QString appDIR = KStandardDirs::appDir(); | 82 | QString appDIR = KStandardDirs::appDir(); |
83 | #ifdef DESKTOP_VERSION | 83 | #ifdef DESKTOP_VERSION |
84 | QString appdir = QDir::homeDirPath(); | 84 | QString appdir = QDir::homeDirPath(); |
85 | if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) | 85 | if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) |
86 | appdir += "kaddressbook/"; | 86 | appdir += "kaddressbook/"; |
87 | else | 87 | else |
88 | appdir += "/kaddressbook/"; | 88 | appdir += "/kaddressbook/"; |
89 | KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); | 89 | KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); |
90 | #else | 90 | #else |
91 | QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook"; | 91 | QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook"; |
92 | 92 | ||
93 | KStandardDirs::setAppDir( appdir ); | 93 | KStandardDirs::setAppDir( appdir ); |
94 | #endif | 94 | #endif |
95 | 95 | ||
96 | return appDIR; | 96 | return appDIR; |
97 | } | 97 | } |
98 | StdAddressBook *StdAddressBook::self( bool onlyFastResources ) | 98 | StdAddressBook *StdAddressBook::self( bool onlyFastResources ) |
99 | { | 99 | { |
100 | 100 | ||
101 | if ( !mSelf ) | 101 | if ( !mSelf ) |
102 | { | 102 | { |
103 | QString appdir =StdAddressBook::setTempAppDir(); | 103 | QString appdir =StdAddressBook::setTempAppDir(); |
104 | #ifdef KAB_EMBEDDED | 104 | #ifdef KAB_EMBEDDED |
105 | mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); | 105 | mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); |
106 | #else //KAB_EMBEDDED | 106 | #else //KAB_EMBEDDED |
107 | addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); | 107 | addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); |
108 | #endif //KAB_EMBEDDED | 108 | #endif //KAB_EMBEDDED |
109 | KStandardDirs::setAppDir( appdir ); | 109 | KStandardDirs::setAppDir( appdir ); |
110 | } | 110 | } |
111 | return mSelf; | 111 | return mSelf; |
112 | } | 112 | } |
113 | 113 | ||
114 | StdAddressBook::StdAddressBook() | 114 | StdAddressBook::StdAddressBook() |
115 | //US : AddressBook( "kabcrc" ) | 115 | : AddressBook( "kabcrc" ) |
116 | : AddressBook( locateLocal( "config", "kabcrc") ) | ||
117 | { | 116 | { |
118 | 117 | ||
119 | init( false ); | 118 | init( false ); |
120 | } | 119 | } |
121 | 120 | ||
122 | StdAddressBook::StdAddressBook( bool onlyFastResources ) | 121 | StdAddressBook::StdAddressBook( bool onlyFastResources ) |
123 | //US : AddressBook( "kabcrc" ) | 122 | : AddressBook( "kabcrc" ) |
124 | : AddressBook( locateLocal( "config", "kabcrc") ) | ||
125 | { | 123 | { |
126 | 124 | ||
127 | init( onlyFastResources ); | 125 | init( onlyFastResources ); |
128 | } | 126 | } |
129 | 127 | ||
130 | StdAddressBook::~StdAddressBook() | 128 | StdAddressBook::~StdAddressBook() |
131 | { | 129 | { |
132 | if ( mAutomaticSave ) | 130 | if ( mAutomaticSave ) |
133 | save(); | 131 | save(); |
134 | } | 132 | } |
135 | 133 | ||
136 | void StdAddressBook::init( bool ) | 134 | void StdAddressBook::init( bool ) |
137 | { | 135 | { |
138 | KRES::Manager<Resource> *manager = resourceManager(); | 136 | KRES::Manager<Resource> *manager = resourceManager(); |
139 | KRES::Manager<Resource>::ActiveIterator it; | 137 | KRES::Manager<Resource>::ActiveIterator it; |
140 | 138 | ||
141 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 139 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
142 | (*it)->setAddressBook( this ); | 140 | (*it)->setAddressBook( this ); |
143 | if ( !(*it)->open() ) | 141 | if ( !(*it)->open() ) |
144 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 142 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
145 | } | 143 | } |
146 | 144 | ||
147 | Resource *res = standardResource(); | 145 | Resource *res = standardResource(); |
148 | if ( !res ) { | 146 | if ( !res ) { |
149 | res = manager->createResource( "file" ); | 147 | res = manager->createResource( "file" ); |
150 | if ( res ) | 148 | if ( res ) |
151 | { | 149 | { |
152 | addResource( res ); | 150 | addResource( res ); |
153 | } | 151 | } |
154 | else | 152 | else |
155 | qDebug(" No resource available!!!"); | 153 | qDebug(" No resource available!!!"); |
156 | } | 154 | } |
157 | 155 | ||
158 | setStandardResource( res ); | 156 | setStandardResource( res ); |
159 | manager->writeConfig(); | 157 | manager->writeConfig(); |
160 | 158 | ||
161 | load(); | 159 | load(); |
162 | } | 160 | } |
163 | 161 | ||
164 | bool StdAddressBook::save() | 162 | bool StdAddressBook::save() |
165 | { | 163 | { |
166 | kdDebug(5700) << "StdAddressBook::save()" << endl; | 164 | kdDebug(5700) << "StdAddressBook::save()" << endl; |
167 | 165 | ||
168 | bool ok = true; | 166 | bool ok = true; |
169 | AddressBook *ab = self(); | 167 | AddressBook *ab = self(); |
170 | 168 | ||
171 | ab->deleteRemovedAddressees(); | 169 | ab->deleteRemovedAddressees(); |
172 | 170 | ||
173 | KRES::Manager<Resource>::ActiveIterator it; | 171 | KRES::Manager<Resource>::ActiveIterator it; |
174 | KRES::Manager<Resource> *manager = ab->resourceManager(); | 172 | KRES::Manager<Resource> *manager = ab->resourceManager(); |
175 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 173 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
176 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 174 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
177 | Ticket *ticket = ab->requestSaveTicket( *it ); | 175 | Ticket *ticket = ab->requestSaveTicket( *it ); |
178 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 176 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
179 | if ( !ticket ) { | 177 | if ( !ticket ) { |
180 | ab->error( i18n( "Unable to save to resource '%1'. It is locked." ) | 178 | ab->error( i18n( "Unable to save to resource '%1'. It is locked." ) |
181 | .arg( (*it)->resourceName() ) ); | 179 | .arg( (*it)->resourceName() ) ); |
182 | return false; | 180 | return false; |
183 | } | 181 | } |
184 | 182 | ||
185 | if ( !ab->save( ticket ) ) | 183 | if ( !ab->save( ticket ) ) |
186 | ok = false; | 184 | ok = false; |
187 | } | 185 | } |
188 | } | 186 | } |
189 | 187 | ||
190 | return ok; | 188 | return ok; |
191 | } | 189 | } |
192 | 190 | ||
193 | void StdAddressBook::close() | 191 | void StdAddressBook::close() |
194 | { | 192 | { |
195 | //US destructObject is not defined on my system???. Is setObject(0) the same ??? | 193 | //US destructObject is not defined on my system???. Is setObject(0) the same ??? |
196 | //US addressBookDeleter.destructObject(); | 194 | //US addressBookDeleter.destructObject(); |
197 | addressBookDeleter.setObject(0); | 195 | addressBookDeleter.setObject(0); |
198 | 196 | ||
199 | } | 197 | } |
200 | 198 | ||
201 | void StdAddressBook::setAutomaticSave( bool enable ) | 199 | void StdAddressBook::setAutomaticSave( bool enable ) |
202 | { | 200 | { |
203 | mAutomaticSave = enable; | 201 | mAutomaticSave = enable; |
204 | } | 202 | } |
205 | 203 | ||
206 | bool StdAddressBook::automaticSave() | 204 | bool StdAddressBook::automaticSave() |
207 | { | 205 | { |
208 | return mAutomaticSave; | 206 | return mAutomaticSave; |
209 | } | 207 | } |
210 | 208 | ||
211 | // should get const for 4.X | 209 | // should get const for 4.X |
212 | Addressee StdAddressBook::whoAmI() | 210 | Addressee StdAddressBook::whoAmI() |
213 | { | 211 | { |
214 | //US KConfig config( "kabcrc" ); | 212 | //US KConfig config( "kabcrc" ); |
215 | KConfig config( locateLocal("config", "kabcrc") ); | 213 | KConfig config( locateLocal("config", "kabcrc") ); |
216 | config.setGroup( "General" ); | 214 | config.setGroup( "General" ); |
217 | 215 | ||
218 | return findByUid( config.readEntry( "WhoAmI" ) ); | 216 | return findByUid( config.readEntry( "WhoAmI" ) ); |
219 | } | 217 | } |
220 | 218 | ||
221 | void StdAddressBook::setWhoAmI( const Addressee &addr ) | 219 | void StdAddressBook::setWhoAmI( const Addressee &addr ) |
222 | { | 220 | { |
223 | //US KConfig config( "kabcrc" ); | 221 | //US KConfig config( "kabcrc" ); |
224 | KConfig config( locateLocal("config", "kabcrc") ); | 222 | KConfig config( locateLocal("config", "kabcrc") ); |
225 | config.setGroup( "General" ); | 223 | config.setGroup( "General" ); |
226 | 224 | ||
227 | config.writeEntry( "WhoAmI", addr.uid() ); | 225 | config.writeEntry( "WhoAmI", addr.uid() ); |
228 | } | 226 | } |
diff --git a/kabc/syncprefwidget.cpp b/kabc/syncprefwidget.cpp index 51a8040..a2bde72 100644 --- a/kabc/syncprefwidget.cpp +++ b/kabc/syncprefwidget.cpp | |||
@@ -1,495 +1,410 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KABC for platform independent KDE tools. | 2 | This file is part of KABC for platform independent KDE tools. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program 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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | /*US | ||
29 | #include <qlayout.h> | ||
30 | #include <qlabel.h> | ||
31 | #include <qgroupbox.h> | ||
32 | #include <qbuttongroup.h> | ||
33 | #include <qlineedit.h> | ||
34 | #include <qfont.h> | ||
35 | #include <qslider.h> | ||
36 | #include <qfile.h> | ||
37 | #include <qtextstream.h> | ||
38 | #include <qcombobox.h> | ||
39 | #include <qvbox.h> | ||
40 | #include <qhbox.h> | ||
41 | #include <qspinbox.h> | ||
42 | #include <qdatetime.h> | ||
43 | #include <qcheckbox.h> | ||
44 | #include <qradiobutton.h> | ||
45 | #include <qpushbutton.h> | ||
46 | #include <qstrlist.h> | ||
47 | #include <qapplication.h> | ||
48 | |||
49 | #include <kcolorbutton.h> | ||
50 | #include <kdebug.h> | ||
51 | #include <klocale.h> | ||
52 | #include <kglobal.h> | ||
53 | #include <kfontdialog.h> | ||
54 | #include <kmessagebox.h> | ||
55 | #include <kcolordialog.h> | ||
56 | #include <kiconloader.h> | ||
57 | #include <kemailsettings.h> | ||
58 | #include <kstandarddirs.h> | ||
59 | #include <kfiledialog.h> | ||
60 | #include <kmessagebox.h> | ||
61 | |||
62 | #include <kurlrequester.h> | ||
63 | #include <klineedit.h> | ||
64 | #include <libkdepim/ksyncprofile.h> | ||
65 | |||
66 | |||
67 | #include "koprefs.h" | ||
68 | |||
69 | #include "kosyncprefsdialog.h" | ||
70 | #include "koglobals.h" | ||
71 | */ | ||
72 | 28 | ||
73 | #include <qlayout.h> | 29 | #include <qlayout.h> |
74 | #include <qbuttongroup.h> | 30 | #include <qbuttongroup.h> |
75 | #include <qcheckbox.h> | 31 | #include <qcheckbox.h> |
76 | #include <qradiobutton.h> | 32 | #include <qradiobutton.h> |
77 | #include <qvbox.h> | 33 | #include <qvbox.h> |
78 | #include <qhbox.h> | 34 | #include <qhbox.h> |
79 | #include <qlabel.h> | 35 | #include <qlabel.h> |
80 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
81 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qscrollview.h> | ||
39 | #include <qcombobox.h> | ||
82 | 40 | ||
83 | 41 | ||
84 | #include <klocale.h> | 42 | #include <klocale.h> |
85 | #include <kdialog.h> | 43 | #include <kdialog.h> |
86 | 44 | ||
87 | 45 | #include "ksyncprofile.h" | |
46 | #include "resource.h" | ||
88 | #include "syncprefwidget.h" | 47 | #include "syncprefwidget.h" |
89 | 48 | ||
90 | 49 | ||
91 | SyncPrefWidget::SyncPrefWidget(QWidget *parent) : | 50 | SyncPrefWidget_Settings::SyncPrefWidget_Settings(QWidget *parent, const char *name) : |
92 | KRES::SyncWidget(parent) | 51 | KRES::SyncWidget(parent, name) |
93 | { | 52 | { |
94 | 53 | init(); | |
95 | //US setCaption( i18n("Synchronization Preferences")); | ||
96 | |||
97 | //US mSyncProfiles.setAutoDelete( true ); | ||
98 | init(); | ||
99 | } | 54 | } |
100 | 55 | ||
101 | 56 | ||
102 | SyncPrefWidget::~SyncPrefWidget() | 57 | SyncPrefWidget_Settings::~SyncPrefWidget_Settings() |
103 | { | 58 | { |
104 | } | 59 | } |
105 | 60 | ||
106 | //US #include <qlayout.h> | 61 | void SyncPrefWidget_Settings::init() |
107 | //US #include <qscrollview.h> | ||
108 | void SyncPrefWidget::init() | ||
109 | { | 62 | { |
110 | QLabel * lab; | ||
111 | QPushButton* button; | ||
112 | |||
113 | /*US | ||
114 | //QFrame *page = addPage(i18n("Sync Prefs"),0,0); | ||
115 | QVBox * mainbox = new QVBox( this ); | ||
116 | QScrollView* sv = new QScrollView( mainbox ); | ||
117 | QHBoxLayout * lay = new QHBoxLayout( this ); | ||
118 | lay->addWidget( mainbox ); | ||
119 | QHBox * b_box = new QHBox( mainbox ); | ||
120 | */ | ||
121 | /*US | ||
122 | QPushButton* button = new QPushButton( i18n("Ok"), b_box ); | ||
123 | connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); | ||
124 | button = new QPushButton( i18n("Cancel"), b_box ); | ||
125 | connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); | ||
126 | */ | ||
127 | //QBoxLayout * sl = new QVBoxLayout(this ); | ||
128 | //sl->addWidget ( sv ); | ||
129 | /*US | ||
130 | sv->setResizePolicy ( QScrollView::AutoOneFit ); | ||
131 | QFrame *topFrame = new QFrame ( sv ); | ||
132 | sv->addChild( topFrame ); | ||
133 | mSetupSyncAlgTab = topFrame; | ||
134 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | ||
135 | topLayout->setSpacing(spacingHint()); | ||
136 | topLayout->setMargin(marginHint()); | ||
137 | */ | ||
138 | //US new code for the layout | ||
139 | QGridLayout *topLayout = new QGridLayout( this, 6,2 ); | 63 | QGridLayout *topLayout = new QGridLayout( this, 6,2 ); |
140 | topLayout->setMargin( KDialog::marginHint() ); | 64 | topLayout->setMargin( KDialog::marginHint() ); |
141 | topLayout->setSpacing( KDialog::spacingHint() ); | 65 | topLayout->setSpacing( KDialog::spacingHint() ); |
142 | 66 | ||
143 | //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); | 67 | int iii = 0; |
144 | int iii = 0; | 68 | mIncludeInRing = new QCheckBox( i18n("Include in multiple sync"), this ); |
145 | //topLayout->addMultiCellWidget(lab , iii,iii,0,1); | 69 | topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1); |
146 | //++iii; | 70 | ++iii; |
147 | |||
148 | /*US | ||
149 | mMyMachineName = new QLineEdit(topFrame); | ||
150 | lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); | ||
151 | topLayout->addWidget(lab ,iii,0); | ||
152 | topLayout->addWidget(mMyMachineName,iii,1); | ||
153 | ++iii; | ||
154 | |||
155 | QHBox* buttonbox = new QHBox( topFrame); | ||
156 | topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); | ||
157 | ++iii; | ||
158 | button = new QPushButton( i18n("New profile"), buttonbox ); | ||
159 | connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); | ||
160 | |||
161 | button = new QPushButton( i18n("Clone profile"), buttonbox ); | ||
162 | connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); | ||
163 | |||
164 | button = new QPushButton( i18n("Delete profile"), buttonbox ); | ||
165 | connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); | ||
166 | |||
167 | mProfileBox = new QComboBox(topFrame); | ||
168 | mProfileBox->setEditable ( true ); | ||
169 | connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); | ||
170 | connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); | ||
171 | |||
172 | lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); | ||
173 | topLayout->addWidget(lab ,iii,0); | ||
174 | topLayout->addWidget(mProfileBox, iii,1); | ||
175 | ++iii; | ||
176 | */ | ||
177 | mIncludeInRing = new QCheckBox( i18n("Include in multiple sync"), this ); | ||
178 | topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1); | ||
179 | ++iii; | ||
180 | |||
181 | mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), this ); | ||
182 | topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); | ||
183 | ++iii; | ||
184 | QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), this); | ||
185 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); | ||
186 | ++iii; | ||
187 | loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); | ||
188 | rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); | ||
189 | newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); | ||
190 | ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); | ||
191 | f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); | ||
192 | f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); | ||
193 | // both = new QRadioButton ( i18n("Take both on conflict"), gr ); | ||
194 | 71 | ||
195 | mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), this ); | 72 | mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), this ); |
196 | topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); | 73 | topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); |
197 | ++iii; | 74 | ++iii; |
198 | |||
199 | mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), this ); | ||
200 | topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); | ||
201 | ++iii; | ||
202 | |||
203 | mWriteBackFile = new QCheckBox( i18n("Write back file"), this ); | ||
204 | topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); | ||
205 | ++iii; | ||
206 | |||
207 | mIsNotLocal = new QCheckBox( i18n("Remote file (w down/upload command)"), this ); | ||
208 | topLayout->addMultiCellWidget(mIsNotLocal, iii,iii,0,1); | ||
209 | connect (mIsNotLocal, SIGNAL( checked(bool)), this, SLOT (kindChanged(bool) ) ); | ||
210 | /*US | ||
211 | proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), this); | ||
212 | gr = proGr; | ||
213 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); | ||
214 | ++iii; | ||
215 | mIsLocal = new QRadioButton ( i18n("Local file"), gr ); | ||
216 | mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); | ||
217 | connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | ||
218 | */ | ||
219 | 75 | ||
220 | /*US | 76 | mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), this ); |
221 | localFileWidget = new QVBox( topFrame); | 77 | topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); |
222 | topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); | 78 | ++iii; |
223 | ++iii; | ||
224 | QHBox* temphb = new QHBox( localFileWidget ); | ||
225 | lab = new QLabel( i18n("Local file:"), temphb); | ||
226 | mRemoteFile = new QLineEdit(localFileWidget); | ||
227 | 79 | ||
228 | button = new QPushButton( i18n("Choose..."), temphb ); | 80 | mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), this ); |
229 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); | 81 | topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); |
230 | */ | 82 | ++iii; |
231 | QHBox* temphb; | ||
232 | 83 | ||
233 | remoteFileWidget = new QVBox( this); | 84 | mWriteBackFile = new QCheckBox( i18n("Write back synced data"), this ); |
234 | topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); | 85 | topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); |
235 | ++iii; | 86 | ++iii; |
236 | lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); | ||
237 | mRemotePrecommand = new QLineEdit(remoteFileWidget); | ||
238 | 87 | ||
239 | lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); | 88 | } |
240 | mLocalTempFile = new QLineEdit(remoteFileWidget); | ||
241 | 89 | ||
90 | void SyncPrefWidget_Settings::loadSettings( KRES::Resource *res ) | ||
91 | { | ||
92 | KABC::Resource* resource = (KABC::Resource*)( res ); | ||
93 | KSyncProfile* prof = resource->getSyncProfile(); | ||
94 | |||
95 | if (prof == 0) | ||
96 | { | ||
97 | qDebug("SyncPrefWidget_Settings::loadSettings: something is wrong, because resource does have no syncprofile" ); | ||
98 | return; | ||
99 | } | ||
100 | |||
101 | mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); | ||
102 | mAskForPreferences->setChecked( prof->getAskForPreferences()); | ||
103 | mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); | ||
104 | mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); | ||
105 | mWriteBackFile->setChecked( prof->getWriteBackFile()); | ||
106 | } | ||
242 | 107 | ||
243 | lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); | 108 | void SyncPrefWidget_Settings::saveSettings( KRES::Resource *res ) |
244 | mRemotePostcommand = new QLineEdit(remoteFileWidget); | 109 | { |
110 | KABC::Resource* resource = (KABC::Resource*)( res ); | ||
111 | KSyncProfile* prof = resource->getSyncProfile(); | ||
112 | |||
113 | if (prof == 0) | ||
114 | { | ||
115 | qDebug("SyncPrefWidget_Settings::saveSettings: something is wrong, because resource does have no syncprofile" ); | ||
116 | return; | ||
117 | } | ||
118 | |||
119 | prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); | ||
120 | prof->setAskForPreferences( mAskForPreferences->isChecked()); | ||
121 | prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); | ||
122 | prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); | ||
123 | prof->setWriteBackFile( mWriteBackFile->isChecked()); | ||
124 | } | ||
245 | 125 | ||
246 | lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); | ||
247 | temphb = new QHBox( remoteFileWidget ); | ||
248 | button = new QPushButton( i18n("ssh/scp"), temphb ); | ||
249 | connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); | ||
250 | button = new QPushButton( i18n("ftp"), temphb ); | ||
251 | connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); | ||
252 | lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); | ||
253 | 126 | ||
127 | /*********************************************************************** | ||
128 | * | ||
129 | * | ||
130 | **********************************************************************/ | ||
254 | 131 | ||
255 | } | 132 | SyncPrefWidget_Conflict::SyncPrefWidget_Conflict(QWidget *parent, const char *name) : |
256 | /*US | 133 | KRES::SyncWidget(parent, name) |
257 | void SyncPrefWidget::slotOK() | ||
258 | { | 134 | { |
259 | if ( mMyMachineName->text() == "undefined" ) { | 135 | init(); |
260 | KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); | ||
261 | return; | ||
262 | } | ||
263 | int i; | ||
264 | for (i = 0; i < mSyncProfileNames.count(); ++ i) { | ||
265 | if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { | ||
266 | KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); | ||
267 | return; | ||
268 | } | ||
269 | } | ||
270 | usrWriteConfig(); | ||
271 | QDialog::accept(); | ||
272 | } | 136 | } |
273 | void SyncPrefWidget::accept() | 137 | |
138 | |||
139 | SyncPrefWidget_Conflict::~SyncPrefWidget_Conflict() | ||
274 | { | 140 | { |
275 | slotOK(); | ||
276 | } | 141 | } |
277 | void KOSyncPrefsDialog::chooseFile() | 142 | |
143 | void SyncPrefWidget_Conflict::init() | ||
278 | { | 144 | { |
279 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | 145 | QGridLayout *topLayout = new QGridLayout( this, 6,2 ); |
146 | topLayout->setMargin( KDialog::marginHint() ); | ||
147 | topLayout->setSpacing( KDialog::spacingHint() ); | ||
280 | 148 | ||
281 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 149 | int iii = 0; |
282 | if ( fn == "" ) | 150 | |
283 | return; | 151 | QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("In case of conflicts"), this); |
284 | mRemoteFile->setText( fn ); | 152 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); |
153 | ++iii; | ||
154 | loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); | ||
155 | rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); | ||
156 | newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); | ||
157 | ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); | ||
158 | f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); | ||
159 | f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); | ||
160 | // both = new QRadioButton ( i18n("Take both on conflict"), gr ); | ||
285 | } | 161 | } |
286 | 162 | ||
287 | void KOSyncPrefsDialog::textChanged( const QString & s ) | 163 | void SyncPrefWidget_Conflict::loadSettings( KRES::Resource *res ) |
288 | { | 164 | { |
289 | if ( mProfileBox->count() == 0 ) | 165 | KABC::Resource* resource = (KABC::Resource*)( res ); |
290 | return; | 166 | KSyncProfile* prof = resource->getSyncProfile(); |
291 | if ( currentSelection < 3 ) { | 167 | |
292 | //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); | 168 | if (prof == 0) |
293 | mProfileBox->blockSignals( true ); | 169 | { |
294 | mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); | 170 | qDebug("SyncPrefWidget_Conflict::loadSettings: something is wrong, because resource does have no syncprofile" ); |
295 | mProfileBox->blockSignals( false ); | 171 | return; |
296 | return; | 172 | } |
297 | } | 173 | |
298 | //qDebug("cur i %d ",mProfileBox-> currentItem () ); | 174 | switch ( prof->getSyncPrefs() ) { |
299 | mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; | 175 | case 0: |
300 | KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; | 176 | loc->setChecked( true); |
301 | prof->setName( s ); | 177 | break; |
302 | mSyncProfileNames[mProfileBox-> currentItem ()] = s; | 178 | case 1: |
179 | rem->setChecked( true ); | ||
180 | break; | ||
181 | case 2: | ||
182 | newest->setChecked( true); | ||
183 | break; | ||
184 | case 3: | ||
185 | ask->setChecked( true); | ||
186 | break; | ||
187 | case 4: | ||
188 | f_loc->setChecked( true); | ||
189 | break; | ||
190 | case 5: | ||
191 | f_rem->setChecked( true); | ||
192 | break; | ||
193 | case 6: | ||
194 | //both->setChecked( true); | ||
195 | break; | ||
196 | default: | ||
197 | break; | ||
198 | } | ||
303 | } | 199 | } |
304 | void KOSyncPrefsDialog::profileChanged( int item ) | 200 | |
201 | void SyncPrefWidget_Conflict::saveSettings( KRES::Resource *res ) | ||
305 | { | 202 | { |
306 | //qDebug("KOSyncPrefsDialog::profileChanged %d ", item ); | 203 | KABC::Resource* resource = (KABC::Resource*)( res ); |
307 | KSyncProfile* prof; | 204 | KSyncProfile* prof = resource->getSyncProfile(); |
308 | saveProfile(); | 205 | |
309 | currentSelection = item; | 206 | if (prof == 0) |
310 | prof = mSyncProfiles.at(item) ; | 207 | { |
311 | mRemotePrecommand->setText(prof->getPreSyncCommand()); | 208 | qDebug("SyncPrefWidget_Conftlict::saveSettings: something is wrong, because resource does have no syncprofile" ); |
312 | mRemotePostcommand->setText(prof->getPostSyncCommand()); | 209 | return; |
313 | mLocalTempFile->setText(prof->getLocalTempFile()); | 210 | } |
314 | mRemoteFile->setText(prof->getRemoteFileName()) ; | 211 | |
315 | mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); | 212 | int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; |
316 | mAskForPreferences->setChecked( prof->getAskForPreferences()); | 213 | prof->setSyncPrefs( syncprefs ); |
317 | mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); | 214 | |
318 | mWriteBackFile->setChecked( prof->getWriteBackFile()); | 215 | } |
319 | mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); | 216 | |
320 | 217 | ||
321 | switch ( prof->getSyncPrefs() ) { | 218 | /*********************************************************************** |
322 | case 0: | 219 | * |
323 | loc->setChecked( true); | 220 | * |
324 | break; | 221 | **********************************************************************/ |
325 | case 1: | 222 | |
326 | rem->setChecked( true ); | 223 | SyncPrefWidget_Remote::SyncPrefWidget_Remote(QWidget *parent, const char *name) : |
327 | break; | 224 | KRES::SyncWidget(parent, name) |
328 | case 2: | 225 | { |
329 | newest->setChecked( true); | 226 | init(); |
330 | break; | ||
331 | case 3: | ||
332 | ask->setChecked( true); | ||
333 | break; | ||
334 | case 4: | ||
335 | f_loc->setChecked( true); | ||
336 | break; | ||
337 | case 5: | ||
338 | f_rem->setChecked( true); | ||
339 | break; | ||
340 | case 6: | ||
341 | //both->setChecked( true); | ||
342 | break; | ||
343 | default: | ||
344 | break; | ||
345 | } | ||
346 | mIsLocal->setChecked(prof->getIsLocalFileSync()) ; | ||
347 | mIsNotLocal->setChecked(!prof->getIsLocalFileSync()); | ||
348 | proGr->setEnabled( item > 2 ); | ||
349 | if ( item < 3 ) { | ||
350 | localFileWidget->setEnabled(false); | ||
351 | remoteFileWidget->setEnabled(false); | ||
352 | |||
353 | } else | ||
354 | kindChanged( prof->getIsLocalFileSync() ); | ||
355 | } | 227 | } |
356 | 228 | ||
357 | void KOSyncPrefsDialog::fillSSH() | 229 | |
230 | SyncPrefWidget_Remote::~SyncPrefWidget_Remote() | ||
358 | { | 231 | { |
359 | mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); | ||
360 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); | ||
361 | mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); | ||
362 | } | 232 | } |
363 | void KOSyncPrefsDialog::fillFTP() | 233 | |
234 | void SyncPrefWidget_Remote::init() | ||
364 | { | 235 | { |
365 | mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); | 236 | QLabel * lab; |
366 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); | 237 | QPushButton* button; |
367 | mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); | 238 | |
239 | |||
240 | QGridLayout *topLayout = new QGridLayout( this, 6,2 ); | ||
241 | topLayout->setMargin( KDialog::marginHint() ); | ||
242 | topLayout->setSpacing( KDialog::spacingHint() ); | ||
243 | |||
244 | int iii = 0; | ||
245 | |||
246 | QButtonGroup* gr; | ||
247 | |||
248 | QButtonGroup *proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), this); | ||
249 | gr = proGr; | ||
250 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); | ||
251 | ++iii; | ||
252 | mProfileKind = new QComboBox( gr ); | ||
253 | |||
254 | mProfileKind->insertItem( i18n("Local file"), Local ); | ||
255 | mProfileKind->insertItem( i18n("Remote file (w down/upload cmd)"),Remote ); | ||
256 | mProfileKind->insertItem( i18n("Mobile device (cell phone)"), Mobile ); | ||
257 | |||
258 | connect( mProfileKind, SIGNAL( activated( int ) ), | ||
259 | this, SLOT (kindChanged( int ) ) ); | ||
260 | |||
261 | |||
262 | QHBox* temphb; | ||
263 | |||
264 | remoteFileWidget = new QVBox( this); | ||
265 | topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); | ||
266 | ++iii; | ||
267 | lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); | ||
268 | mRemotePrecommand = new QLineEdit(remoteFileWidget); | ||
269 | |||
270 | lab = new QLabel( i18n("Local temp file (=Location):"), remoteFileWidget); | ||
271 | mLocalTempFile = new QLineEdit(remoteFileWidget); | ||
272 | mLocalTempFile->setEnabled(false); | ||
273 | |||
274 | |||
275 | lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); | ||
276 | mRemotePostcommand = new QLineEdit(remoteFileWidget); | ||
277 | |||
278 | lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); | ||
279 | temphb = new QHBox( remoteFileWidget ); | ||
280 | button = new QPushButton( i18n("ssh/scp"), temphb ); | ||
281 | connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); | ||
282 | button = new QPushButton( i18n("ftp"), temphb ); | ||
283 | connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); | ||
284 | lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); | ||
368 | 285 | ||
369 | } | 286 | } |
370 | void KOSyncPrefsDialog::kindChanged( bool b ) | 287 | |
288 | void SyncPrefWidget_Remote::loadSettings( KRES::Resource *res ) | ||
371 | { | 289 | { |
290 | KABC::Resource* resource = (KABC::Resource*)( res ); | ||
291 | KSyncProfile* prof = resource->getSyncProfile(); | ||
292 | |||
293 | if (prof == 0) | ||
294 | { | ||
295 | qDebug("SyncPrefWidget_Remote::loadSettings: something is wrong, because resource does have no syncprofile" ); | ||
296 | return; | ||
297 | } | ||
372 | 298 | ||
373 | localFileWidget->setEnabled(b); | 299 | int val; |
374 | remoteFileWidget->setEnabled(!b); | ||
375 | 300 | ||
301 | if (prof->getIsPhoneSync()) | ||
302 | val = Mobile; | ||
303 | else if (!prof->getIsLocalFileSync()) | ||
304 | val = Remote; | ||
305 | else // default value | ||
306 | val = Local; | ||
307 | |||
308 | mProfileKind->setCurrentItem( val ); | ||
309 | kindChanged( val ); | ||
310 | |||
311 | |||
312 | mRemotePrecommand->setText(prof->getPreSyncCommand()); | ||
313 | mLocalTempFile->setText(resource->fileName()); | ||
314 | mRemotePostcommand->setText(prof->getPostSyncCommand()); | ||
376 | } | 315 | } |
377 | void KOSyncPrefsDialog::deleteProfile() | 316 | |
317 | void SyncPrefWidget_Remote::saveSettings( KRES::Resource *res ) | ||
378 | { | 318 | { |
379 | //qDebug("KOSyncPrefsDialog::deleteProfile() "); | 319 | KABC::Resource* resource = (KABC::Resource*)( res ); |
380 | if ( currentSelection >= 0 ) { | 320 | KSyncProfile* prof = resource->getSyncProfile(); |
381 | if ( currentSelection < 3 ) { | 321 | |
382 | KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); | 322 | if (prof == 0) |
383 | return; | 323 | { |
384 | } | 324 | qDebug("SyncPrefWidget_Remote::saveSettings: something is wrong, because resource does have no syncprofile" ); |
385 | KSyncProfile* temp = mSyncProfiles.at(currentSelection); | 325 | return; |
386 | mSyncProfiles.remove( temp ); | 326 | } |
387 | mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); | 327 | |
388 | insertProfiles(); | 328 | int val = mProfileKind->currentItem(); |
389 | } | 329 | |
330 | if (val == Mobile) | ||
331 | { | ||
332 | prof->setIsLocalFileSync(true); | ||
333 | prof->setIsPhoneSync(true); | ||
334 | } | ||
335 | else if (val == Remote) | ||
336 | { | ||
337 | prof->setIsLocalFileSync(false); | ||
338 | prof->setIsPhoneSync(false); | ||
339 | } | ||
340 | else // default value is Local | ||
341 | { | ||
342 | prof->setIsLocalFileSync(true); | ||
343 | prof->setIsPhoneSync(false); | ||
344 | } | ||
345 | |||
346 | |||
347 | prof->setPreSyncCommand( mRemotePrecommand->text()); | ||
348 | //US prof->setLocalTempFile( mLocalTempFile->text()); | ||
349 | prof->setPostSyncCommand( mRemotePostcommand->text() ); | ||
390 | } | 350 | } |
391 | 351 | ||
392 | void KOSyncPrefsDialog::saveProfile() | 352 | |
353 | void SyncPrefWidget_Remote::fillSSH() | ||
393 | { | 354 | { |
394 | KSyncProfile* prof; | 355 | QString location = mLocalTempFile->text(); |
395 | if ( currentSelection >= 0 ) { | ||
396 | prof = mSyncProfiles.at(currentSelection) ; | ||
397 | prof->setPreSyncCommand( mRemotePrecommand->text()); | ||
398 | prof->setPostSyncCommand( mRemotePostcommand->text() ); | ||
399 | prof->setLocalTempFile( mLocalTempFile->text()); | ||
400 | prof->setRemoteFileName( mRemoteFile->text() ); | ||
401 | prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); | ||
402 | prof->setAskForPreferences( mAskForPreferences->isChecked()); | ||
403 | prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); | ||
404 | prof->setWriteBackFile( mWriteBackFile->isChecked()); | ||
405 | prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); | ||
406 | int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; | ||
407 | prof->setSyncPrefs( syncprefs); | ||
408 | prof->setIsLocalFileSync( mIsLocal->isChecked() ); | ||
409 | } | ||
410 | 356 | ||
357 | mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/"+location + " " + location ); | ||
358 | //US mLocalTempFile->setText("/tmp/mycalendar.ics" ); | ||
359 | mRemotePostcommand->setText("scp " + location + " zaurus@192.168.0.65:/home/zaurus/kdepim/"+location ); | ||
411 | } | 360 | } |
412 | 361 | ||
413 | void KOSyncPrefsDialog::insertProfiles() | 362 | void SyncPrefWidget_Remote::fillFTP() |
414 | { | 363 | { |
415 | int curItem = mProfileBox->currentItem(); | 364 | QString location = mLocalTempFile->text(); |
416 | mProfileBox->blockSignals( true ); | 365 | |
417 | mProfileBox->clear(); | 366 | mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/" + location ); |
418 | mProfileBox->insertStringList (mSyncProfileNames ); | 367 | //US mLocalTempFile->setText("/tmp/mycalendar.ics" ); |
419 | int item = mSyncProfileNames.count() -1; | 368 | mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/"+location+ " " + location); |
420 | if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) | 369 | |
421 | mProfileBox->setCurrentItem( curItem ); | ||
422 | else if ( item >= 0 ) { | ||
423 | mProfileBox->setCurrentItem( item ); | ||
424 | } | ||
425 | currentSelection = -1; | ||
426 | if ( mSyncProfileNames.count() > 0 ) { | ||
427 | //qDebug(" profileChanged( mProfileBox->currentItem() "); | ||
428 | profileChanged( mProfileBox->currentItem() ); | ||
429 | currentSelection = mProfileBox->currentItem(); | ||
430 | } | ||
431 | mProfileBox->blockSignals( false ); | ||
432 | } | 370 | } |
433 | 371 | ||
434 | void KOSyncPrefsDialog::addProfile ( KSyncProfile* temp ) | 372 | |
373 | void SyncPrefWidget_Remote::kindChanged( int newKind ) | ||
435 | { | 374 | { |
436 | saveProfile(); | 375 | |
437 | mSyncProfiles.append( temp ); | 376 | if (newKind == Mobile) |
438 | mSyncProfileNames << temp->getName(); | 377 | remoteFileWidget->setEnabled(false); |
439 | insertProfiles(); | 378 | else if (newKind == Remote) |
440 | int last = mProfileBox->count() -1; | 379 | remoteFileWidget->setEnabled(true); |
441 | mProfileBox->blockSignals( true ); | 380 | else // default value is local |
442 | mProfileBox->setCurrentItem( last ); | 381 | remoteFileWidget->setEnabled(false); |
443 | mProfileBox->blockSignals( false ); | 382 | |
444 | profileChanged(last); | ||
445 | } | 383 | } |
446 | void KOSyncPrefsDialog::newProfile() | 384 | |
385 | /*********************************************************************** | ||
386 | * | ||
387 | * | ||
388 | **********************************************************************/ | ||
389 | |||
390 | |||
391 | SyncPrefWidgetContainer::SyncPrefWidgetContainer() | ||
392 | : SyncWidgetContainer() | ||
447 | { | 393 | { |
448 | addProfile ( new KSyncProfile () ); | ||
449 | } | 394 | } |
450 | 395 | ||
451 | void KOSyncPrefsDialog::cloneProfile() | 396 | KRES::SyncWidget* SyncPrefWidgetContainer::generateSettingsTab(QWidget *parent = 0, const char *name = 0) |
452 | { | 397 | { |
453 | if ( currentSelection >= 0 ) | 398 | return new SyncPrefWidget_Settings(parent, name); |
454 | addProfile (mSyncProfiles.at(currentSelection)->clone()) ; | ||
455 | else | ||
456 | newProfile(); | ||
457 | } | 399 | } |
458 | 400 | ||
459 | 401 | KRES::SyncWidget* SyncPrefWidgetContainer::generateConflictsTab(QWidget *parent = 0, const char *name = 0) | |
460 | void KOSyncPrefsDialog::usrReadConfig() | ||
461 | { | 402 | { |
462 | KConfig *config = KOGlobals::config(); | 403 | return new SyncPrefWidget_Conflict(parent, name); |
463 | config->setGroup("SyncProfiles"); | ||
464 | mSyncProfileNames = KOPrefs::instance()->mSyncProfileNames; | ||
465 | int i; | ||
466 | KSyncProfile* temp ; | ||
467 | mSyncProfiles.clear(); | ||
468 | for ( i = 0; i < mSyncProfileNames.count();++i ) { | ||
469 | temp = new KSyncProfile (); | ||
470 | temp->setName( mSyncProfileNames[i] ); | ||
471 | temp->readConfig( config ); | ||
472 | mSyncProfiles.append( temp ); | ||
473 | } | ||
474 | insertProfiles(); | ||
475 | mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); | ||
476 | } | 404 | } |
477 | 405 | ||
478 | 406 | KRES::SyncWidget* SyncPrefWidgetContainer::generateRemoteTab(QWidget *parent = 0, const char *name = 0) | |
479 | void KOSyncPrefsDialog::usrWriteConfig() | ||
480 | { | 407 | { |
481 | saveProfile(); | 408 | return new SyncPrefWidget_Remote(parent, name); |
482 | if ( currentSelection >= 0 ) | ||
483 | profileChanged(currentSelection); | ||
484 | KConfig *config = KOGlobals::config(); | ||
485 | config->setGroup("SyncProfiles"); | ||
486 | KSyncProfile* prof = mSyncProfiles.first(); | ||
487 | while ( prof ) { | ||
488 | prof->writeConfig(config); | ||
489 | prof = mSyncProfiles.next(); | ||
490 | } | ||
491 | KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; | ||
492 | KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); | ||
493 | config->writeEntry("SyncProfileNames",&mSyncProfileNames); | ||
494 | } | 409 | } |
495 | */ | 410 | |
diff --git a/kabc/syncprefwidget.h b/kabc/syncprefwidget.h index 3709d78..b20a68e 100644 --- a/kabc/syncprefwidget.h +++ b/kabc/syncprefwidget.h | |||
@@ -1,121 +1,139 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KABC/Pi. | 2 | This file is part of KABC/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program 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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef _SYNCPREFWIDGET_H | 28 | #ifndef _SYNCPREFWIDGET_H |
29 | #define _SYNCPREFWIDGET_H | 29 | #define _SYNCPREFWIDGET_H |
30 | 30 | ||
31 | #include <kresources/syncwidget.h> | 31 | #include <kresources/syncwidget.h> |
32 | 32 | ||
33 | /*US | ||
34 | //#include <qframe.h> | ||
35 | //#include <qdict.h> | ||
36 | #include <qvbox.h> | ||
37 | #include <qhbox.h> | ||
38 | //#include <qcolor.h> | ||
39 | //#include <qlistview.h> | ||
40 | |||
41 | #include <kdialogbase.h> | ||
42 | |||
43 | #include <libkdepim/kprefsdialog.h> | ||
44 | */ | ||
45 | |||
46 | //US class KColorButton; | ||
47 | //US class QSpinBox;; | ||
48 | class QRadioButton; | 33 | class QRadioButton; |
49 | class QCheckBox; | 34 | class QCheckBox; |
50 | class QVBox; | 35 | class QVBox; |
51 | //US class QSlider; | 36 | class QComboBox; |
52 | //US class KURLRequester; | ||
53 | //US class QComboBox; | ||
54 | class QLineEdit; | 37 | class QLineEdit; |
55 | //US class QStringList; | 38 | class KRES::Resource; |
56 | //US class KSyncProfile; | ||
57 | 39 | ||
58 | 40 | class SyncPrefWidget_Settings : public KRES::SyncWidget | |
59 | /** Dialog to change the korganizer configuration. | ||
60 | */ | ||
61 | class SyncPrefWidget : public KRES::SyncWidget | ||
62 | { | 41 | { |
63 | Q_OBJECT | 42 | Q_OBJECT |
64 | public: | 43 | public: |
65 | SyncPrefWidget(QWidget *parent=0); | 44 | SyncPrefWidget_Settings(QWidget *parent=0, const char *name = 0 ); |
66 | ~SyncPrefWidget(); | 45 | ~SyncPrefWidget_Settings(); |
67 | //US void usrReadConfig(); | ||
68 | 46 | ||
69 | public slots: | 47 | public slots: |
70 | protected slots: | 48 | virtual void loadSettings( KRES::Resource *resource ); |
71 | //US void accept(); | 49 | virtual void saveSettings( KRES::Resource *resource ); |
72 | //US void deleteProfile(); | ||
73 | //US void newProfile(); | ||
74 | //US void cloneProfile(); | ||
75 | //US void kindChanged(bool); | ||
76 | //US void fillSSH(); | ||
77 | //US void fillFTP(); | ||
78 | //US void textChanged( const QString & ); | ||
79 | //US void profileChanged( int ); | ||
80 | //US void chooseFile(); | ||
81 | //US void slotOK(); | ||
82 | 50 | ||
83 | protected: | ||
84 | //US void usrWriteConfig(); | ||
85 | 51 | ||
52 | protected: | ||
86 | void init(); | 53 | void init(); |
87 | 54 | ||
88 | private: | 55 | private: |
56 | QCheckBox* mIncludeInRing; | ||
57 | QCheckBox* mWriteBackFile; | ||
58 | QCheckBox* mWriteBackExisting; | ||
59 | QCheckBox* mAskForPreferences; | ||
60 | QCheckBox* mShowSummaryAfterSync; | ||
61 | }; | ||
89 | 62 | ||
90 | 63 | ||
91 | //US int currentSelection; | ||
92 | //US QPtrList<KSyncProfile> mSyncProfiles; | ||
93 | //US QStringList mSyncProfileNames; | ||
94 | //US QLineEdit * mMyMachineName; | ||
95 | //US QComboBox * mProfileBox; | ||
96 | //US QRadioButton* mIsLocal; | ||
97 | QCheckBox* mIsNotLocal; | ||
98 | QCheckBox* mIncludeInRing; | ||
99 | //US void addProfile ( KSyncProfile* ); | ||
100 | //US void insertProfiles(); | ||
101 | //US void saveProfile(); | ||
102 | //US QButtonGroup* proGr; | ||
103 | 64 | ||
65 | class SyncPrefWidget_Conflict : public KRES::SyncWidget | ||
66 | { | ||
67 | Q_OBJECT | ||
68 | public: | ||
69 | SyncPrefWidget_Conflict(QWidget *parent=0, const char *name = 0 ); | ||
70 | ~SyncPrefWidget_Conflict(); | ||
71 | |||
72 | public slots: | ||
73 | virtual void loadSettings( KRES::Resource *resource ); | ||
74 | virtual void saveSettings( KRES::Resource *resource ); | ||
75 | |||
76 | protected: | ||
77 | void init(); | ||
78 | |||
79 | private: | ||
104 | QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both; | 80 | QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both; |
81 | }; | ||
82 | |||
83 | |||
84 | |||
105 | 85 | ||
86 | class SyncPrefWidget_Remote : public KRES::SyncWidget | ||
87 | { | ||
88 | Q_OBJECT | ||
89 | public: | ||
90 | SyncPrefWidget_Remote(QWidget *parent=0, const char *name = 0 ); | ||
91 | ~SyncPrefWidget_Remote(); | ||
92 | |||
93 | enum Types { | ||
94 | Local = 0, | ||
95 | Remote = 1, | ||
96 | Mobile =2 | ||
97 | }; | ||
106 | 98 | ||
99 | |||
100 | public slots: | ||
101 | virtual void loadSettings( KRES::Resource *resource ); | ||
102 | virtual void saveSettings( KRES::Resource *resource ); | ||
103 | |||
104 | protected slots: | ||
105 | void fillSSH(); | ||
106 | void fillFTP(); | ||
107 | void kindChanged( int newKind ); | ||
108 | |||
109 | protected: | ||
110 | void init(); | ||
111 | |||
112 | private: | ||
113 | QComboBox* mProfileKind; | ||
107 | QLineEdit * mRemotePostcommand; | 114 | QLineEdit * mRemotePostcommand; |
108 | QLineEdit * mRemotePrecommand; | 115 | QLineEdit * mRemotePrecommand; |
109 | QLineEdit * mRemoteFile; | 116 | QLineEdit * mRemoteFile; |
110 | QLineEdit * mLocalTempFile; | 117 | QLineEdit * mLocalTempFile; |
111 | //US QWidget* mSetupSyncAlgTab; | ||
112 | |||
113 | //US QVBox* localFileWidget; | ||
114 | QVBox* remoteFileWidget; | 118 | QVBox* remoteFileWidget; |
115 | QCheckBox* mWriteBackFile; | ||
116 | QCheckBox* mWriteBackExisting; | ||
117 | QCheckBox* mAskForPreferences; | ||
118 | QCheckBox* mShowSummaryAfterSync; | ||
119 | }; | 119 | }; |
120 | 120 | ||
121 | |||
122 | |||
123 | |||
124 | |||
125 | class SyncPrefWidgetContainer : public KRES::SyncWidgetContainer | ||
126 | { | ||
127 | Q_OBJECT | ||
128 | |||
129 | public: | ||
130 | SyncPrefWidgetContainer(); | ||
131 | |||
132 | virtual KRES::SyncWidget* generateSettingsTab(QWidget *parent, const char *name); | ||
133 | virtual KRES::SyncWidget* generateConflictsTab(QWidget *parent, const char *name); | ||
134 | virtual KRES::SyncWidget* generateRemoteTab(QWidget *parent, const char *name); | ||
135 | }; | ||
136 | |||
137 | |||
138 | |||
121 | #endif | 139 | #endif |
diff --git a/microkde/kresources/configdialog.cpp b/microkde/kresources/configdialog.cpp index 90febca..f8240f9 100644 --- a/microkde/kresources/configdialog.cpp +++ b/microkde/kresources/configdialog.cpp | |||
@@ -1,195 +1,241 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkresources. | 2 | This file is part of libkresources. |
3 | 3 | ||
4 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 4 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
5 | Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> | 5 | Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> |
6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
7 | 7 | ||
8 | This library is free software; you can redistribute it and/or | 8 | This library is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU Library General Public | 9 | modify it under the terms of the GNU Library General Public |
10 | License as published by the Free Software Foundation; either | 10 | License as published by the Free Software Foundation; either |
11 | version 2 of the License, or (at your option) any later version. | 11 | version 2 of the License, or (at your option) any later version. |
12 | 12 | ||
13 | This library is distributed in the hope that it will be useful, | 13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Library General Public License for more details. | 16 | Library General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU Library General Public License | 18 | You should have received a copy of the GNU Library General Public License |
19 | along with this library; see the file COPYING.LIB. If not, write to | 19 | along with this library; see the file COPYING.LIB. If not, write to |
20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
21 | Boston, MA 02111-1307, USA. | 21 | Boston, MA 02111-1307, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <klocale.h> | 24 | #include <klocale.h> |
25 | #include <kglobal.h> | 25 | #include <kglobal.h> |
26 | #include <kmessagebox.h> | 26 | #include <kmessagebox.h> |
27 | 27 | ||
28 | #include <qgroupbox.h> | 28 | #include <qgroupbox.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
32 | #include <qvbox.h> | ||
32 | 33 | ||
33 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | #include <qscrollview.h> | ||
34 | 36 | ||
35 | #include <kbuttonbox.h> | 37 | #include <kbuttonbox.h> |
36 | #include <kdialog.h> | 38 | #include <kdialog.h> |
37 | #include <klineedit.h> | 39 | #include <klineedit.h> |
38 | 40 | ||
39 | #include "factory.h" | 41 | #include "factory.h" |
40 | #include "configwidget.h" | 42 | #include "configwidget.h" |
41 | #include "configdialog.h" | 43 | #include "configdialog.h" |
42 | #include "syncwidget.h" | 44 | #include "syncwidget.h" |
43 | 45 | ||
44 | using namespace KRES; | 46 | using namespace KRES; |
45 | 47 | ||
46 | ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, | 48 | ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, |
47 | Resource* resource, const char *name ) | 49 | Resource* resource, const char *name ) |
48 | : KDialogBase( parent, name, true, resource->isSyncable()?i18n( "Sync Profile Configuration" ):i18n( "Resource Configuration" ), | 50 | : KDialogBase( parent, name, true, resource->isSyncable()?i18n( "Sync Profile Configuration" ):i18n( "Resource Configuration" ), |
49 | Ok|Cancel, Ok, true )/*, mConfig( config )*/, mSyncWidget(0), mResource( resource ), mPersistentReadOnly(false) | 51 | Ok|Cancel, Ok, true )/*, mConfig( config )*/, mSyncWidget_Settings(0), mSyncWidget_Conflicts(0),mSyncWidget_Remote(0), mResource( resource ), mPersistentReadOnly(false) |
50 | { | 52 | { |
51 | 53 | ||
52 | Factory *factory = Factory::self( resourceFamily ); | 54 | Factory *factory = Factory::self( resourceFamily ); |
53 | 55 | ||
54 | //US resize( 250, 240 ); | 56 | //US resize( 250, 240 ); |
55 | resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); | 57 | resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); |
56 | 58 | ||
57 | //US QFrame *main = makeMainWidget(); | 59 | QFrame *main; |
58 | QFrame *main = plainPage(); | 60 | |
61 | if (!mResource->isSyncable()) | ||
62 | main = plainPage(); | ||
63 | else | ||
64 | main = addPage("Profile"); | ||
59 | 65 | ||
60 | QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); | 66 | QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); |
61 | 67 | ||
68 | |||
62 | QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); | 69 | QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); |
63 | generalGroupBox->layout()->setSpacing( spacingHint() ); | 70 | generalGroupBox->layout()->setSpacing( spacingHint() ); |
64 | generalGroupBox->setTitle( i18n( "General Settings" ) ); | 71 | generalGroupBox->setTitle( i18n( "General Settings" ) ); |
65 | 72 | ||
66 | new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox ); | 73 | new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox ); |
67 | 74 | ||
68 | mName = new KLineEdit( generalGroupBox ); | 75 | mName = new KLineEdit( generalGroupBox ); |
69 | 76 | ||
70 | if (!mResource->isSyncable()) { | 77 | if (!mResource->isSyncable()) { |
71 | mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); | 78 | mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); |
72 | mReadOnly->setChecked( mResource->readOnly() ); | 79 | mReadOnly->setChecked( mResource->readOnly() ); |
73 | } | 80 | } |
74 | 81 | ||
75 | mName->setText( mResource->resourceName() ); | 82 | mName->setText( mResource->resourceName() ); |
76 | 83 | ||
77 | mainLayout->addWidget( generalGroupBox ); | 84 | mainLayout->addWidget( generalGroupBox ); |
78 | 85 | ||
79 | QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); | 86 | QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); |
80 | resourceGroupBox->layout()->setSpacing( spacingHint()); | 87 | resourceGroupBox->layout()->setSpacing( spacingHint()); |
81 | resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) | 88 | resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) |
82 | .arg( factory->typeName( resource->type() ) ) ); | 89 | .arg( factory->typeName( resource->type() ) ) ); |
83 | mainLayout->addWidget( resourceGroupBox ); | 90 | mainLayout->addWidget( resourceGroupBox ); |
84 | 91 | ||
85 | mainLayout->addStretch(); | 92 | mainLayout->addStretch(); |
86 | 93 | ||
87 | mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); | 94 | mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); |
88 | if ( mConfigWidget ) { | 95 | if ( mConfigWidget ) { |
89 | connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), | 96 | connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), |
90 | SLOT( setReadOnly( bool ) ) ); | 97 | SLOT( setReadOnly( bool ) ) ); |
91 | connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), | 98 | connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), |
92 | SLOT( setPersistentReadOnly( bool ) ) ); | 99 | SLOT( setPersistentReadOnly( bool ) ) ); |
93 | mConfigWidget->setInEditMode( false ); | 100 | mConfigWidget->setInEditMode( false ); |
94 | mConfigWidget->loadSettings( mResource ); | 101 | mConfigWidget->loadSettings( mResource ); |
95 | mConfigWidget->show(); | 102 | mConfigWidget->show(); |
96 | 103 | ||
97 | } | 104 | } |
98 | 105 | ||
99 | if (mResource->isSyncable()) | 106 | if (mResource->isSyncable()) |
100 | { | 107 | { |
101 | QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); | 108 | SyncWidgetContainer* c = factory->syncWidgetContainer( resource->type() ); |
102 | syncGroupBox->layout()->setSpacing( spacingHint()); | 109 | |
103 | syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) ); | 110 | QFrame* syncPage = addPage("Settings"); |
104 | mainLayout->addWidget( syncGroupBox ); | 111 | QVBoxLayout *syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() ); |
112 | mSyncWidget_Settings = c->generateSettingsTab(syncPage); | ||
113 | syncLayout->addWidget( mSyncWidget_Settings ); | ||
114 | |||
115 | syncPage = addPage("Conflicts"); | ||
116 | syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() ); | ||
117 | mSyncWidget_Conflicts = c->generateConflictsTab(syncPage); | ||
118 | syncLayout->addWidget( mSyncWidget_Conflicts ); | ||
119 | |||
120 | syncPage = addPage("Remote"); | ||
121 | syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() ); | ||
122 | mSyncWidget_Remote = c->generateRemoteTab(syncPage); | ||
123 | syncLayout->addWidget( mSyncWidget_Remote ); | ||
124 | |||
105 | 125 | ||
106 | mainLayout->addStretch(); | 126 | mSyncWidget_Settings->setInEditMode( false ); |
127 | mSyncWidget_Settings->loadSettings( mResource ); | ||
128 | mSyncWidget_Settings->show(); | ||
107 | 129 | ||
108 | mSyncWidget = factory->syncWidget( resource->type(), syncGroupBox ); | 130 | mSyncWidget_Conflicts->setInEditMode( false ); |
131 | mSyncWidget_Conflicts->loadSettings( mResource ); | ||
132 | mSyncWidget_Conflicts->show(); | ||
133 | |||
134 | mSyncWidget_Remote->setInEditMode( false ); | ||
135 | mSyncWidget_Remote->loadSettings( mResource ); | ||
136 | mSyncWidget_Remote->show(); | ||
137 | |||
138 | delete c; | ||
139 | |||
140 | // QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, syncPage ); | ||
141 | // syncGroupBox->layout()->setSpacing( spacingHint()); | ||
142 | // syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) ); | ||
143 | // syncLayout->addWidget( syncGroupBox ); | ||
144 | |||
145 | // syncLayout->addStretch(); | ||
146 | /*US | ||
147 | mSyncWidget = factory->syncWidget( resource->type(), syncPage ); | ||
148 | syncLayout->addWidget( mSyncWidget ); | ||
109 | if ( mSyncWidget ) { | 149 | if ( mSyncWidget ) { |
110 | mSyncWidget->setInEditMode( false ); | 150 | mSyncWidget->setInEditMode( false ); |
111 | mSyncWidget->loadSettings( mResource ); | 151 | mSyncWidget->loadSettings( mResource ); |
112 | mSyncWidget->show(); | 152 | mSyncWidget->show(); |
113 | } | 153 | } |
154 | */ | ||
114 | } | 155 | } |
115 | 156 | ||
116 | 157 | ||
117 | 158 | ||
118 | 159 | ||
119 | connect( mName, SIGNAL( textChanged(const QString &)), | 160 | connect( mName, SIGNAL( textChanged(const QString &)), |
120 | SLOT( slotNameChanged(const QString &))); | 161 | SLOT( slotNameChanged(const QString &))); |
121 | 162 | ||
122 | slotNameChanged( mName->text() ); | 163 | slotNameChanged( mName->text() ); |
123 | 164 | ||
124 | //US setMinimumSize( 400, 250 ); | 165 | //US setMinimumSize( 400, 250 ); |
125 | setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); | 166 | setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); |
126 | 167 | ||
127 | } | 168 | } |
128 | 169 | ||
129 | void ConfigDialog::setInEditMode( bool value ) | 170 | void ConfigDialog::setInEditMode( bool value ) |
130 | { | 171 | { |
131 | if ( mConfigWidget ) | 172 | if ( mConfigWidget ) |
132 | mConfigWidget->setInEditMode( value ); | 173 | mConfigWidget->setInEditMode( value ); |
133 | 174 | ||
134 | if ( mSyncWidget ) | 175 | if ( mSyncWidget_Settings ) |
135 | mSyncWidget->setInEditMode( value ); | 176 | mSyncWidget_Settings->setInEditMode( value ); |
177 | if ( mSyncWidget_Conflicts ) | ||
178 | mSyncWidget_Conflicts->setInEditMode( value ); | ||
179 | if ( mSyncWidget_Remote ) | ||
180 | mSyncWidget_Remote->setInEditMode( value ); | ||
136 | 181 | ||
137 | } | 182 | } |
138 | 183 | ||
139 | void ConfigDialog::slotNameChanged( const QString &text) | 184 | void ConfigDialog::slotNameChanged( const QString &text) |
140 | { | 185 | { |
141 | enableButtonOK( !text.isEmpty() ); | 186 | enableButtonOK( !text.isEmpty() ); |
142 | } | 187 | } |
143 | 188 | ||
144 | void ConfigDialog::setReadOnly( bool value ) | 189 | void ConfigDialog::setReadOnly( bool value ) |
145 | { | 190 | { |
146 | if (!mResource->isSyncable()) { | 191 | if (!mResource->isSyncable()) { |
147 | 192 | ||
148 | if (mPersistentReadOnly == false) | 193 | if (mPersistentReadOnly == false) |
149 | mReadOnly->setChecked( value ); | 194 | mReadOnly->setChecked( value ); |
150 | else | 195 | else |
151 | mReadOnly->setChecked( true ); | 196 | mReadOnly->setChecked( true ); |
152 | } | 197 | } |
153 | } | 198 | } |
154 | 199 | ||
155 | void ConfigDialog::setPersistentReadOnly( bool value ) | 200 | void ConfigDialog::setPersistentReadOnly( bool value ) |
156 | { | 201 | { |
157 | if (!mResource->isSyncable()) { | 202 | if (!mResource->isSyncable()) { |
158 | 203 | ||
159 | mPersistentReadOnly = value; | 204 | mPersistentReadOnly = value; |
160 | 205 | ||
161 | if (value == true) | 206 | if (value == true) |
162 | setReadOnly( true ); | 207 | setReadOnly( true ); |
163 | 208 | ||
164 | mReadOnly->setEnabled( !value ); | 209 | mReadOnly->setEnabled( !value ); |
165 | } | 210 | } |
166 | } | 211 | } |
167 | 212 | ||
168 | void ConfigDialog::accept() | 213 | void ConfigDialog::accept() |
169 | { | 214 | { |
170 | if ( mName->text().isEmpty() ) { | 215 | if ( mName->text().isEmpty() ) { |
171 | KMessageBox::sorry( this, mResource->isSyncable()?i18n( "Please enter a profile name" ):i18n( "Please enter a resource name" ) ); | 216 | KMessageBox::sorry( this, mResource->isSyncable()?i18n( "Please enter a profile name" ):i18n( "Please enter a resource name" ) ); |
172 | return; | 217 | return; |
173 | } | 218 | } |
174 | 219 | ||
175 | mResource->setResourceName( mName->text() ); | 220 | mResource->setResourceName( mName->text() ); |
176 | if (!mResource->isSyncable()) | 221 | if (!mResource->isSyncable()) |
177 | mResource->setReadOnly( mReadOnly->isChecked() ); | 222 | mResource->setReadOnly( mReadOnly->isChecked() ); |
178 | 223 | ||
179 | if ( mConfigWidget ) { | 224 | if ( mConfigWidget ) { |
180 | // First save generic information | 225 | // First save generic information |
181 | // Also save setting of specific resource type | 226 | // Also save setting of specific resource type |
182 | mConfigWidget->saveSettings( mResource ); | 227 | mConfigWidget->saveSettings( mResource ); |
183 | } | 228 | } |
184 | 229 | ||
185 | if ( mSyncWidget ) { | 230 | if ( mSyncWidget_Settings ) |
186 | // First save generic information | 231 | mSyncWidget_Settings->saveSettings( mResource ); |
187 | // Also save setting of specific resource type | 232 | if ( mSyncWidget_Conflicts ) |
188 | mSyncWidget->saveSettings( mResource ); | 233 | mSyncWidget_Conflicts->saveSettings( mResource ); |
189 | } | 234 | if ( mSyncWidget_Remote ) |
235 | mSyncWidget_Remote->saveSettings( mResource ); | ||
190 | 236 | ||
191 | 237 | ||
192 | KDialog::accept(); | 238 | KDialog::accept(); |
193 | } | 239 | } |
194 | 240 | ||
195 | //US #include "configdialog.moc" | 241 | //US #include "configdialog.moc" |
diff --git a/microkde/kresources/configdialog.h b/microkde/kresources/configdialog.h index b629347..63cd4e9 100644 --- a/microkde/kresources/configdialog.h +++ b/microkde/kresources/configdialog.h | |||
@@ -22,44 +22,46 @@ | |||
22 | #ifndef KRESOURCES_CONFIGDIALOG_H | 22 | #ifndef KRESOURCES_CONFIGDIALOG_H |
23 | #define KRESOURCES_CONFIGDIALOG_H | 23 | #define KRESOURCES_CONFIGDIALOG_H |
24 | 24 | ||
25 | #include <kdialogbase.h> | 25 | #include <kdialogbase.h> |
26 | 26 | ||
27 | class KLineEdit; | 27 | class KLineEdit; |
28 | class QCheckBox; | 28 | class QCheckBox; |
29 | class KButtonBox; | 29 | class KButtonBox; |
30 | 30 | ||
31 | namespace KRES { | 31 | namespace KRES { |
32 | class Resource; | 32 | class Resource; |
33 | class ConfigWidget; | 33 | class ConfigWidget; |
34 | class SyncWidget; | 34 | class SyncWidget; |
35 | 35 | ||
36 | class ConfigDialog : public KDialogBase | 36 | class ConfigDialog : public KDialogBase |
37 | { | 37 | { |
38 | Q_OBJECT | 38 | Q_OBJECT |
39 | public: | 39 | public: |
40 | // Resource=0: create new resource | 40 | // Resource=0: create new resource |
41 | ConfigDialog( QWidget *parent, const QString& resourceFamily, | 41 | ConfigDialog( QWidget *parent, const QString& resourceFamily, |
42 | Resource* resource, const char *name = 0); | 42 | Resource* resource, const char *name = 0); |
43 | 43 | ||
44 | void setInEditMode( bool value ); | 44 | void setInEditMode( bool value ); |
45 | 45 | ||
46 | protected slots: | 46 | protected slots: |
47 | void accept(); | 47 | void accept(); |
48 | void setReadOnly( bool value ); | 48 | void setReadOnly( bool value ); |
49 | void setPersistentReadOnly( bool value ); | 49 | void setPersistentReadOnly( bool value ); |
50 | void slotNameChanged( const QString &text); | 50 | void slotNameChanged( const QString &text); |
51 | 51 | ||
52 | private: | 52 | private: |
53 | ConfigWidget *mConfigWidget; | 53 | ConfigWidget *mConfigWidget; |
54 | SyncWidget *mSyncWidget; | 54 | SyncWidget *mSyncWidget_Settings; |
55 | SyncWidget *mSyncWidget_Conflicts; | ||
56 | SyncWidget *mSyncWidget_Remote; | ||
55 | Resource* mResource; | 57 | Resource* mResource; |
56 | 58 | ||
57 | KLineEdit *mName; | 59 | KLineEdit *mName; |
58 | QCheckBox *mReadOnly; | 60 | QCheckBox *mReadOnly; |
59 | //US add a persistent readonly flag. We need that for opie and qtopia addressbooks. | 61 | //US add a persistent readonly flag. We need that for opie and qtopia addressbooks. |
60 | bool mPersistentReadOnly; | 62 | bool mPersistentReadOnly; |
61 | }; | 63 | }; |
62 | 64 | ||
63 | } | 65 | } |
64 | 66 | ||
65 | #endif | 67 | #endif |
diff --git a/microkde/kresources/configpage.cpp b/microkde/kresources/configpage.cpp index 2fe021d..1a3a22c 100644 --- a/microkde/kresources/configpage.cpp +++ b/microkde/kresources/configpage.cpp | |||
@@ -176,64 +176,66 @@ void ConfigPage::load() | |||
176 | 176 | ||
177 | mListView->clear(); | 177 | mListView->clear(); |
178 | 178 | ||
179 | //US we remove the dynamic pluginloader, and set the one family we need (contact) manually. | 179 | //US we remove the dynamic pluginloader, and set the one family we need (contact) manually. |
180 | 180 | ||
181 | //US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" ); | 181 | //US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" ); |
182 | //US KTrader::OfferList::ConstIterator it; | 182 | //US KTrader::OfferList::ConstIterator it; |
183 | //US for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 183 | //US for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
184 | //US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" ); | 184 | //US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" ); |
185 | //US QString family = tmp.toString(); | 185 | //US QString family = tmp.toString(); |
186 | QStringList families; | 186 | QStringList families; |
187 | families << "contact" << syncfamily; | 187 | families << "contact" << syncfamily; |
188 | 188 | ||
189 | 189 | ||
190 | for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) | 190 | for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) |
191 | { | 191 | { |
192 | QString family = (*it); | 192 | QString family = (*it); |
193 | if ( !family.isEmpty() ) { | 193 | if ( !family.isEmpty() ) { |
194 | if ( !mFamilyMap.contains( family ) ) { | 194 | if ( !mFamilyMap.contains( family ) ) { |
195 | mCurrentManager = new Manager<Resource>( family, (family == syncfamily) ); | 195 | mCurrentManager = new Manager<Resource>( family, (family == syncfamily) ); |
196 | if ( mCurrentManager ) { | 196 | if ( mCurrentManager ) { |
197 | mFamilyMap.append( family ); | 197 | mFamilyMap.append( family ); |
198 | mCurrentManager->addListener( this ); | 198 | mCurrentManager->addListener( this ); |
199 | 199 | ||
200 | ResourcePageInfo info; | 200 | ResourcePageInfo info; |
201 | info.mManager = mCurrentManager; | 201 | info.mManager = mCurrentManager; |
202 | QString configDir = KGlobal::dirs()->saveLocation( "config" ); | 202 | QString configDir = KGlobal::dirs()->saveLocation( "config" ); |
203 | //QString configDir = KStandardDirs::appDir() + "/config"; | 203 | //QString configDir = KStandardDirs::appDir() + "/config"; |
204 | if ( family == "contact" && QFile::exists( configDir + "/kabcrc" ) ) { | 204 | if ( family == "contact" && QFile::exists( configDir + "/kabcrc" ) ) { |
205 | info.mConfig = new KConfig( locateLocal( "config", "kabcrc" ) ); | 205 | info.mConfig = new KConfig( locateLocal( "config", "kabcrc" ) ); |
206 | } else if ( family == "calendar" && QFile::exists( configDir + "/kcalrc" ) ) { | 206 | } else if ( family == "calendar" && QFile::exists( configDir + "/kcalrc" ) ) { |
207 | info.mConfig = new KConfig( locateLocal( "config", "kcalrc" ) ); | 207 | info.mConfig = new KConfig( locateLocal( "config", "kcalrc" ) ); |
208 | } else if ( family == syncfamily && QFile::exists( configDir + "/kabcsyncrc" ) ) { | ||
209 | info.mConfig = new KConfig( locateLocal( "config", "kabcsyncrc" ) ); | ||
208 | } else { | 210 | } else { |
209 | QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) ); | 211 | QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) ); |
210 | info.mConfig = new KConfig( configFile ); | 212 | info.mConfig = new KConfig( configFile ); |
211 | } | 213 | } |
212 | info.mManager->readConfig( info.mConfig ); | 214 | info.mManager->readConfig( info.mConfig ); |
213 | 215 | ||
214 | mInfoMap.append( info ); | 216 | mInfoMap.append( info ); |
215 | } | 217 | } |
216 | } | 218 | } |
217 | } | 219 | } |
218 | } | 220 | } |
219 | mCurrentManager = 0; | 221 | mCurrentManager = 0; |
220 | 222 | ||
221 | mFamilyCombo->insertStringList( mFamilyMap ); | 223 | mFamilyCombo->insertStringList( mFamilyMap ); |
222 | 224 | ||
223 | int currentFamily = mConfig->readNumEntry( "CurrentFamily", 0 ); | 225 | int currentFamily = mConfig->readNumEntry( "CurrentFamily", 0 ); |
224 | mFamilyCombo->setCurrentItem( currentFamily ); | 226 | mFamilyCombo->setCurrentItem( currentFamily ); |
225 | slotFamilyChanged( currentFamily ); | 227 | slotFamilyChanged( currentFamily ); |
226 | } | 228 | } |
227 | 229 | ||
228 | void ConfigPage::save() | 230 | void ConfigPage::save() |
229 | { | 231 | { |
230 | saveResourceSettings(); | 232 | saveResourceSettings(); |
231 | 233 | ||
232 | QValueList<ResourcePageInfo>::Iterator it; | 234 | QValueList<ResourcePageInfo>::Iterator it; |
233 | for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) | 235 | for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) |
234 | (*it).mManager->writeConfig( (*it).mConfig ); | 236 | (*it).mManager->writeConfig( (*it).mConfig ); |
235 | 237 | ||
236 | emit changed( false ); | 238 | emit changed( false ); |
237 | } | 239 | } |
238 | 240 | ||
239 | void ConfigPage::defaults() | 241 | void ConfigPage::defaults() |
@@ -282,88 +284,95 @@ void ConfigPage::slotFamilyChanged( int pos ) | |||
282 | 284 | ||
283 | defaults(); | 285 | defaults(); |
284 | emit changed( true ); | 286 | emit changed( true ); |
285 | mCurrentManager->writeConfig( mCurrentConfig ); | 287 | mCurrentManager->writeConfig( mCurrentConfig ); |
286 | } else { | 288 | } else { |
287 | //US qDebug("ConfigPage::slotFamilyChanged 4.6 "); | 289 | //US qDebug("ConfigPage::slotFamilyChanged 4.6 "); |
288 | 290 | ||
289 | if ( !standardResource ) { | 291 | if ( !standardResource ) { |
290 | KMessageBox::sorry( this, i18n( "There is no standard resource!<br> Please select one." ) ); | 292 | KMessageBox::sorry( this, i18n( "There is no standard resource!<br> Please select one." ) ); |
291 | 293 | ||
292 | //US qDebug("ConfigPage::slotFamilyChanged 4.7" ); | 294 | //US qDebug("ConfigPage::slotFamilyChanged 4.7" ); |
293 | 295 | ||
294 | } | 296 | } |
295 | 297 | ||
296 | emit changed( false ); | 298 | emit changed( false ); |
297 | } | 299 | } |
298 | } | 300 | } |
299 | 301 | ||
300 | void ConfigPage::slotAdd() | 302 | void ConfigPage::slotAdd() |
301 | { | 303 | { |
302 | if ( !mCurrentManager ) | 304 | if ( !mCurrentManager ) |
303 | return; | 305 | return; |
304 | 306 | ||
305 | QStringList types = mCurrentManager->resourceTypeNames(); | 307 | QStringList types = mCurrentManager->resourceTypeNames(); |
306 | QStringList descs = mCurrentManager->resourceTypeDescriptions(); | 308 | QStringList descs = mCurrentManager->resourceTypeDescriptions(); |
307 | bool ok = false; | 309 | bool ok = false; |
308 | 310 | ||
309 | QString desc; | 311 | QString desc; |
310 | 312 | ||
311 | if (mFamily == syncfamily) | 313 | if (mFamily == syncfamily) |
312 | { | 314 | { |
313 | desc = QInputDialog::getItem( i18n( "Sync Configuration" ), | 315 | desc = QInputDialog::getItem( i18n( "Sync Configuration" ), |
314 | i18n( "Please select resource type for new sync profile:" ), descs, 0, | 316 | i18n( "Select resource type for the new sync profile:" ), descs, 0, |
315 | false, &ok, this ); | 317 | false, &ok, this ); |
316 | } | 318 | } |
317 | else | 319 | else |
318 | { | 320 | { |
319 | desc = QInputDialog::getItem( i18n( "Resource Configuration" ), | 321 | desc = QInputDialog::getItem( i18n( "Resource Configuration" ), |
320 | i18n( "Please select type of the new resource:" ), descs, 0, | 322 | i18n( "Select type of the new resource:" ), descs, 0, |
321 | false, &ok, this ); | 323 | false, &ok, this ); |
322 | } | 324 | } |
323 | 325 | ||
324 | if ( !ok ) | 326 | if ( !ok ) |
325 | return; | 327 | return; |
326 | 328 | ||
327 | QString type = types[ descs.findIndex( desc ) ]; | 329 | QString type = types[ descs.findIndex( desc ) ]; |
328 | 330 | ||
329 | // Create new resource | 331 | // Create new resource |
330 | Resource *resource = mCurrentManager->createResource( type ); | 332 | Resource *resource = mCurrentManager->createResource( type ); |
331 | if ( !resource ) { | 333 | if ( !resource ) { |
332 | KMessageBox::error( this, i18n("Unable to create resource of type '%1'.") | 334 | KMessageBox::error( this, i18n("Unable to create resource of type '%1'.") |
333 | .arg( type ) ); | 335 | .arg( type ) ); |
334 | return; | 336 | return; |
335 | } | 337 | } |
336 | 338 | ||
337 | resource->setResourceName( type + "-resource" ); | 339 | if (mFamily == syncfamily) |
340 | { | ||
341 | resource->setResourceName( type + "-syncprofile" ); | ||
342 | } | ||
343 | else | ||
344 | { | ||
345 | resource->setResourceName( type + "-resource" ); | ||
346 | } | ||
338 | 347 | ||
339 | ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" ); | 348 | ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" ); |
340 | 349 | ||
341 | if ( dlg.exec() ) { | 350 | if ( dlg.exec() ) { |
342 | mCurrentManager->add( resource ); | 351 | mCurrentManager->add( resource ); |
343 | 352 | ||
344 | ConfigViewItem *item = new ConfigViewItem( mListView, resource ); | 353 | ConfigViewItem *item = new ConfigViewItem( mListView, resource ); |
345 | 354 | ||
346 | mLastItem = item; | 355 | mLastItem = item; |
347 | 356 | ||
348 | // if there are only read-only resources we'll set this resource | 357 | // if there are only read-only resources we'll set this resource |
349 | // as standard resource | 358 | // as standard resource |
350 | if ( !resource->readOnly() ) { | 359 | if ( !resource->readOnly() ) { |
351 | bool onlyReadOnly = true; | 360 | bool onlyReadOnly = true; |
352 | QListViewItem *it = mListView->firstChild(); | 361 | QListViewItem *it = mListView->firstChild(); |
353 | while ( it != 0 ) { | 362 | while ( it != 0 ) { |
354 | ConfigViewItem *confIt = static_cast<ConfigViewItem*>( it ); | 363 | ConfigViewItem *confIt = static_cast<ConfigViewItem*>( it ); |
355 | if ( !confIt->readOnly() && confIt != item ) | 364 | if ( !confIt->readOnly() && confIt != item ) |
356 | onlyReadOnly = false; | 365 | onlyReadOnly = false; |
357 | 366 | ||
358 | it = it->itemBelow(); | 367 | it = it->itemBelow(); |
359 | } | 368 | } |
360 | 369 | ||
361 | if ( onlyReadOnly ) | 370 | if ( onlyReadOnly ) |
362 | item->setStandard( true ); | 371 | item->setStandard( true ); |
363 | } | 372 | } |
364 | 373 | ||
365 | emit changed( true ); | 374 | emit changed( true ); |
366 | } else { | 375 | } else { |
367 | delete resource; | 376 | delete resource; |
368 | resource = 0; | 377 | resource = 0; |
369 | } | 378 | } |
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp index 7a5c2f6..e44fce3 100644 --- a/microkde/kresources/factory.cpp +++ b/microkde/kresources/factory.cpp | |||
@@ -158,88 +158,88 @@ ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent ) | |||
158 | { | 158 | { |
159 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) | 159 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) |
160 | return 0; | 160 | return 0; |
161 | 161 | ||
162 | //US KService::Ptr ptr = mTypeMap[ type ]; | 162 | //US KService::Ptr ptr = mTypeMap[ type ]; |
163 | //US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); | 163 | //US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); |
164 | PluginInfo* pi = mTypeMap[ type ]; | 164 | PluginInfo* pi = mTypeMap[ type ]; |
165 | KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); | 165 | KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); |
166 | if ( !factory ) { | 166 | if ( !factory ) { |
167 | qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1()); | 167 | qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1()); |
168 | kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl; | 168 | kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl; |
169 | return 0; | 169 | return 0; |
170 | } | 170 | } |
171 | 171 | ||
172 | PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); | 172 | PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); |
173 | 173 | ||
174 | if ( !pluginFactory ) { | 174 | if ( !pluginFactory ) { |
175 | qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1()); | 175 | qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1()); |
176 | kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl; | 176 | kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl; |
177 | return 0; | 177 | return 0; |
178 | } | 178 | } |
179 | 179 | ||
180 | ConfigWidget *wdg = pluginFactory->configWidget( parent ); | 180 | ConfigWidget *wdg = pluginFactory->configWidget( parent ); |
181 | if ( !wdg ) { | 181 | if ( !wdg ) { |
182 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; | 182 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; |
183 | qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); | 183 | qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); |
184 | return 0; | 184 | return 0; |
185 | } | 185 | } |
186 | return wdg; | 186 | return wdg; |
187 | 187 | ||
188 | } | 188 | } |
189 | 189 | ||
190 | SyncWidget *Factory::syncWidget( const QString& type, QWidget *parent ) | 190 | SyncWidgetContainer *Factory::syncWidgetContainer( const QString& type ) |
191 | { | 191 | { |
192 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) | 192 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) |
193 | return 0; | 193 | return 0; |
194 | 194 | ||
195 | //US KService::Ptr ptr = mTypeMap[ type ]; | 195 | //US KService::Ptr ptr = mTypeMap[ type ]; |
196 | //US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); | 196 | //US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); |
197 | PluginInfo* pi = mTypeMap[ type ]; | 197 | PluginInfo* pi = mTypeMap[ type ]; |
198 | KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); | 198 | KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); |
199 | if ( !factory ) { | 199 | if ( !factory ) { |
200 | qDebug("KRES::Factory::syncWidget(): Factory creation failed for library %s", pi->library.latin1()); | 200 | qDebug("KRES::Factory::syncWidget(): Factory creation failed for library %s", pi->library.latin1()); |
201 | kdDebug() << "KRES::Factory::syncWidget(): Factory creation failed" << endl; | 201 | kdDebug() << "KRES::Factory::syncWidget(): Factory creation failed" << endl; |
202 | return 0; | 202 | return 0; |
203 | } | 203 | } |
204 | 204 | ||
205 | PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); | 205 | PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); |
206 | 206 | ||
207 | if ( !pluginFactory ) { | 207 | if ( !pluginFactory ) { |
208 | qDebug("KRES::Factory::syncWidget(): no plugin factory for library %s", pi->library.latin1()); | 208 | qDebug("KRES::Factory::syncWidget(): no plugin factory for library %s", pi->library.latin1()); |
209 | kdDebug() << "KRES::Factory::syncWidget(): no plugin factory." << endl; | 209 | kdDebug() << "KRES::Factory::syncWidget(): no plugin factory." << endl; |
210 | return 0; | 210 | return 0; |
211 | } | 211 | } |
212 | 212 | ||
213 | SyncWidget *wdg = pluginFactory->syncWidget( parent ); | 213 | SyncWidgetContainer *wdg = pluginFactory->syncWidgetContainer( ); |
214 | if ( !wdg ) { | 214 | if ( !wdg ) { |
215 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; | 215 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; |
216 | qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); | 216 | qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); |
217 | return 0; | 217 | return 0; |
218 | } | 218 | } |
219 | return wdg; | 219 | return wdg; |
220 | 220 | ||
221 | } | 221 | } |
222 | 222 | ||
223 | 223 | ||
224 | QString Factory::typeName( const QString &type ) const | 224 | QString Factory::typeName( const QString &type ) const |
225 | { | 225 | { |
226 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) | 226 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) |
227 | return QString(); | 227 | return QString(); |
228 | 228 | ||
229 | 229 | ||
230 | //US KService::Ptr ptr = mTypeMap[ type ]; | 230 | //US KService::Ptr ptr = mTypeMap[ type ]; |
231 | //US return ptr->name(); | 231 | //US return ptr->name(); |
232 | PluginInfo* pi = mTypeMap[ type ]; | 232 | PluginInfo* pi = mTypeMap[ type ]; |
233 | return pi->nameLabel; | 233 | return pi->nameLabel; |
234 | 234 | ||
235 | } | 235 | } |
236 | 236 | ||
237 | QString Factory::typeDescription( const QString &type ) const | 237 | QString Factory::typeDescription( const QString &type ) const |
238 | { | 238 | { |
239 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) | 239 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) |
240 | return QString(); | 240 | return QString(); |
241 | 241 | ||
242 | //US KService::Ptr ptr = mTypeMap[ type ]; | 242 | //US KService::Ptr ptr = mTypeMap[ type ]; |
243 | //US return ptr->comment(); | 243 | //US return ptr->comment(); |
244 | PluginInfo* pi = mTypeMap[ type ]; | 244 | PluginInfo* pi = mTypeMap[ type ]; |
245 | return pi->descriptionLabel; | 245 | return pi->descriptionLabel; |
diff --git a/microkde/kresources/factory.h b/microkde/kresources/factory.h index a265bc8..0e4231b 100644 --- a/microkde/kresources/factory.h +++ b/microkde/kresources/factory.h | |||
@@ -5,123 +5,126 @@ | |||
5 | Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> | 5 | Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> |
6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
7 | 7 | ||
8 | This library is free software; you can redistribute it and/or | 8 | This library is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU Library General Public | 9 | modify it under the terms of the GNU Library General Public |
10 | License as published by the Free Software Foundation; either | 10 | License as published by the Free Software Foundation; either |
11 | version 2 of the License, or (at your option) any later version. | 11 | version 2 of the License, or (at your option) any later version. |
12 | 12 | ||
13 | This library is distributed in the hope that it will be useful, | 13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Library General Public License for more details. | 16 | Library General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU Library General Public License | 18 | You should have received a copy of the GNU Library General Public License |
19 | along with this library; see the file COPYING.LIB. If not, write to | 19 | along with this library; see the file COPYING.LIB. If not, write to |
20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
21 | Boston, MA 02111-1307, USA. | 21 | Boston, MA 02111-1307, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KRESOURCES_FACTORY_H | 24 | #ifndef KRESOURCES_FACTORY_H |
25 | #define KRESOURCES_FACTORY_H | 25 | #define KRESOURCES_FACTORY_H |
26 | 26 | ||
27 | #include <qdict.h> | 27 | #include <qdict.h> |
28 | #include <qstring.h> | 28 | #include <qstring.h> |
29 | 29 | ||
30 | #include <kconfig.h> | 30 | #include <kconfig.h> |
31 | 31 | ||
32 | 32 | ||
33 | #include "resource.h" | 33 | #include "resource.h" |
34 | 34 | ||
35 | namespace KRES { | 35 | namespace KRES { |
36 | 36 | ||
37 | class SyncWidgetContainer; | ||
38 | class ConfigWidget; | ||
39 | |||
37 | //US | 40 | //US |
38 | struct PluginInfo | 41 | struct PluginInfo |
39 | { | 42 | { |
40 | QString library; | 43 | QString library; |
41 | QString nameLabel; | 44 | QString nameLabel; |
42 | QString descriptionLabel; | 45 | QString descriptionLabel; |
43 | }; | 46 | }; |
44 | 47 | ||
45 | 48 | ||
46 | /** | 49 | /** |
47 | * Class for loading resource plugins. | 50 | * Class for loading resource plugins. |
48 | * Do not use this class directly. Use ResourceManager instead | 51 | * Do not use this class directly. Use ResourceManager instead |
49 | * | 52 | * |
50 | * Example: | 53 | * Example: |
51 | * | 54 | * |
52 | * <pre> | 55 | * <pre> |
53 | * KABC::Factory<Calendar> *factory = KABC::Factory<Calendar>::self(); | 56 | * KABC::Factory<Calendar> *factory = KABC::Factory<Calendar>::self(); |
54 | * | 57 | * |
55 | * QStringList list = factory->resources(); | 58 | * QStringList list = factory->resources(); |
56 | * QStringList::Iterator it; | 59 | * QStringList::Iterator it; |
57 | * for ( it = list.begin(); it != list.end(); ++it ) { | 60 | * for ( it = list.begin(); it != list.end(); ++it ) { |
58 | * Resource<Calendar> *resource = factory->resource( (*it), | 61 | * Resource<Calendar> *resource = factory->resource( (*it), |
59 | * KABC::StdAddressBook::self(), 0 ); | 62 | * KABC::StdAddressBook::self(), 0 ); |
60 | * // do something with resource | 63 | * // do something with resource |
61 | * } | 64 | * } |
62 | * </pre> | 65 | * </pre> |
63 | */ | 66 | */ |
64 | class Factory | 67 | class Factory |
65 | { | 68 | { |
66 | public: | 69 | public: |
67 | 70 | ||
68 | 71 | ||
69 | /** | 72 | /** |
70 | * Returns the global resource factory. | 73 | * Returns the global resource factory. |
71 | */ | 74 | */ |
72 | static Factory *self( const QString& resourceFamily ); | 75 | static Factory *self( const QString& resourceFamily ); |
73 | 76 | ||
74 | ~Factory(); | 77 | ~Factory(); |
75 | 78 | ||
76 | /** | 79 | /** |
77 | * Returns the config widget for the given resource type, | 80 | * Returns the config widget for the given resource type, |
78 | * or a null pointer if resource type doesn't exist. | 81 | * or a null pointer if resource type doesn't exist. |
79 | * | 82 | * |
80 | * @param type The type of the resource, returned by @ref resources() | 83 | * @param type The type of the resource, returned by @ref resources() |
81 | * @param resource The resource to be editted. | 84 | * @param resource The resource to be editted. |
82 | * @param parent The parent widget | 85 | * @param parent The parent widget |
83 | */ | 86 | */ |
84 | ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 ); | 87 | ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 ); |
85 | 88 | ||
86 | /** | 89 | /** |
87 | * Returns the sync widget for the given resource type, | 90 | * Returns the sync widget for the given resource type, |
88 | * or a null pointer if resource type doesn't exist, | 91 | * or a null pointer if resource type doesn't exist, |
89 | * or a null pointer if resource does not support syncing. | 92 | * or a null pointer if resource does not support syncing. |
90 | * | 93 | * |
91 | * @param type The type of the resource, returned by @ref resources() | 94 | * @param type The type of the resource, returned by @ref resources() |
92 | * @param resource The resource to be editted. | 95 | * @param resource The resource to be editted. |
93 | * @param parent The parent widget | 96 | * @param parent The parent widget |
94 | */ | 97 | */ |
95 | SyncWidget *syncWidget( const QString& type, QWidget *parent = 0 ); | 98 | SyncWidgetContainer *syncWidgetContainer( const QString& type ); |
96 | 99 | ||
97 | /** | 100 | /** |
98 | * Returns a pointer to a resource object or a null pointer | 101 | * Returns a pointer to a resource object or a null pointer |
99 | * if resource type doesn't exist. | 102 | * if resource type doesn't exist. |
100 | * | 103 | * |
101 | * @param type The type of the resource, returned by @ref resources() | 104 | * @param type The type of the resource, returned by @ref resources() |
102 | * @param ab The address book, the resource should belong to | 105 | * @param ab The address book, the resource should belong to |
103 | * @param config The config object where the resource get it settings from, or 0 if a new resource should be created. | 106 | * @param config The config object where the resource get it settings from, or 0 if a new resource should be created. |
104 | * @param syncable If the resource should support syncing capabilities. | 107 | * @param syncable If the resource should support syncing capabilities. |
105 | */ | 108 | */ |
106 | Resource *resource( const QString& type, const KConfig *config, bool syncable ); | 109 | Resource *resource( const QString& type, const KConfig *config, bool syncable ); |
107 | 110 | ||
108 | /** | 111 | /** |
109 | * Returns a list of all available resource types. | 112 | * Returns a list of all available resource types. |
110 | */ | 113 | */ |
111 | QStringList typeNames() const; | 114 | QStringList typeNames() const; |
112 | 115 | ||
113 | /** | 116 | /** |
114 | * Returns the name for a special type. | 117 | * Returns the name for a special type. |
115 | */ | 118 | */ |
116 | QString typeName( const QString &type ) const; | 119 | QString typeName( const QString &type ) const; |
117 | 120 | ||
118 | /** | 121 | /** |
119 | * Returns the description for a special type. | 122 | * Returns the description for a special type. |
120 | */ | 123 | */ |
121 | QString typeDescription( const QString &type ) const; | 124 | QString typeDescription( const QString &type ) const; |
122 | 125 | ||
123 | protected: | 126 | protected: |
124 | Factory( const QString& resourceFamily); | 127 | Factory( const QString& resourceFamily); |
125 | 128 | ||
126 | private: | 129 | private: |
127 | static QDict<Factory> *mSelves; | 130 | static QDict<Factory> *mSelves; |
diff --git a/microkde/kresources/resource.h b/microkde/kresources/resource.h index c9202c9..580b5d1 100644 --- a/microkde/kresources/resource.h +++ b/microkde/kresources/resource.h | |||
@@ -11,65 +11,65 @@ | |||
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #ifndef KRESOURCES_RESOURCE_H | 23 | #ifndef KRESOURCES_RESOURCE_H |
24 | #define KRESOURCES_RESOURCE_H | 24 | #define KRESOURCES_RESOURCE_H |
25 | 25 | ||
26 | //US | 26 | //US |
27 | #ifdef QT_THREAD_SUPPORT | 27 | #ifdef QT_THREAD_SUPPORT |
28 | #include <qmutex.h> | 28 | #include <qmutex.h> |
29 | #endif //QT_THREAD_SUPPORT | 29 | #endif //QT_THREAD_SUPPORT |
30 | 30 | ||
31 | #include <qvaluelist.h> | 31 | #include <qvaluelist.h> |
32 | #include <qwidget.h> | 32 | #include <qwidget.h> |
33 | 33 | ||
34 | #include <qobject.h> | 34 | #include <qobject.h> |
35 | 35 | ||
36 | #include <klibloader.h> | 36 | #include <klibloader.h> |
37 | 37 | ||
38 | class KConfig; | 38 | class KConfig; |
39 | 39 | ||
40 | namespace KRES { | 40 | namespace KRES { |
41 | 41 | ||
42 | class ConfigWidget; | 42 | class ConfigWidget; |
43 | class SyncWidget; | 43 | class SyncWidgetContainer; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * @internal | 46 | * @internal |
47 | * @libdoc The KDE Resource library | 47 | * @libdoc The KDE Resource library |
48 | * | 48 | * |
49 | * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this | 49 | * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this |
50 | * interface, it is in constant flux. | 50 | * interface, it is in constant flux. |
51 | * | 51 | * |
52 | * The KDE Resource framework can be used to manage resources of | 52 | * The KDE Resource framework can be used to manage resources of |
53 | * different types, organized in families. The Resource framework | 53 | * different types, organized in families. The Resource framework |
54 | * is currently used for addressbook resources in libkabc and for | 54 | * is currently used for addressbook resources in libkabc and for |
55 | * calendar resources in libkcal. | 55 | * calendar resources in libkcal. |
56 | * | 56 | * |
57 | * When you want to use the framework for a new family, you need to | 57 | * When you want to use the framework for a new family, you need to |
58 | * <ul><li>Define a name for your resource family</li> | 58 | * <ul><li>Define a name for your resource family</li> |
59 | * <li>subclass Resource and add the fields and method that are needed | 59 | * <li>subclass Resource and add the fields and method that are needed |
60 | * in your application</li> | 60 | * in your application</li> |
61 | * <li>If needed, override the doOpen() and doClose() methods. | 61 | * <li>If needed, override the doOpen() and doClose() methods. |
62 | * <li> Provide a configuration possibility for resources in your | 62 | * <li> Provide a configuration possibility for resources in your |
63 | * new family. You can use @ref ResourcesConfigPage to easily create a | 63 | * new family. You can use @ref ResourcesConfigPage to easily create a |
64 | * KControl applet</li> | 64 | * KControl applet</li> |
65 | * <li>In your application, you can use @ref ResourceManager to keep track | 65 | * <li>In your application, you can use @ref ResourceManager to keep track |
66 | * of the resources in your family, and you can use @ref ResourceSelectDialog | 66 | * of the resources in your family, and you can use @ref ResourceSelectDialog |
67 | * to let the user select a single resource.</li> | 67 | * to let the user select a single resource.</li> |
68 | * </ul> | 68 | * </ul> |
69 | * | 69 | * |
70 | * When you want to add a new resource type to an existing resource family, | 70 | * When you want to add a new resource type to an existing resource family, |
71 | * you need to | 71 | * you need to |
72 | * <ul><li>Further subclass the family-specific Resource to implement | 72 | * <ul><li>Further subclass the family-specific Resource to implement |
73 | * resource type-specific operation</li> | 73 | * resource type-specific operation</li> |
74 | * <li>Subclass ResourceConfigWidget to provide a configuration widget | 74 | * <li>Subclass ResourceConfigWidget to provide a configuration widget |
75 | * for your new resource type</li> | 75 | * for your new resource type</li> |
@@ -349,68 +349,68 @@ class Resource : public QObject | |||
349 | /** | 349 | /** |
350 | * Open this resource. When called, the resource must be in | 350 | * Open this resource. When called, the resource must be in |
351 | * a closed state. | 351 | * a closed state. |
352 | * | 352 | * |
353 | * Returns true if the resource was opened successfully; | 353 | * Returns true if the resource was opened successfully; |
354 | * returns false if the resource was not opened successfully. | 354 | * returns false if the resource was not opened successfully. |
355 | * | 355 | * |
356 | * The result of this call can be accessed later by @ref isOpen() | 356 | * The result of this call can be accessed later by @ref isOpen() |
357 | */ | 357 | */ |
358 | virtual bool doOpen() { return true; } | 358 | virtual bool doOpen() { return true; } |
359 | 359 | ||
360 | /** | 360 | /** |
361 | * Close this resource. Pre-condition: resource is open. | 361 | * Close this resource. Pre-condition: resource is open. |
362 | * Post-condition: resource is closed. | 362 | * Post-condition: resource is closed. |
363 | */ | 363 | */ |
364 | virtual void doClose() {} | 364 | virtual void doClose() {} |
365 | 365 | ||
366 | void setIdentifier( const QString& identifier ); | 366 | void setIdentifier( const QString& identifier ); |
367 | void setType( const QString& type ); | 367 | void setType( const QString& type ); |
368 | 368 | ||
369 | private: | 369 | private: |
370 | class ResourcePrivate; | 370 | class ResourcePrivate; |
371 | ResourcePrivate *d; | 371 | ResourcePrivate *d; |
372 | }; | 372 | }; |
373 | 373 | ||
374 | class PluginFactoryBase : public KLibFactory | 374 | class PluginFactoryBase : public KLibFactory |
375 | { | 375 | { |
376 | public: | 376 | public: |
377 | virtual Resource *resource( const KConfig *config, bool syncable ) = 0; | 377 | virtual Resource *resource( const KConfig *config, bool syncable ) = 0; |
378 | 378 | ||
379 | virtual ConfigWidget *configWidget( QWidget *parent ) = 0; | 379 | virtual ConfigWidget *configWidget( QWidget *parent ) = 0; |
380 | 380 | ||
381 | virtual SyncWidget *syncWidget( QWidget *parent ) = 0; | 381 | virtual SyncWidgetContainer *syncWidgetContainer() = 0; |
382 | 382 | ||
383 | protected: | 383 | protected: |
384 | virtual QObject* createObject( QObject*, const char*, const char*, | 384 | virtual QObject* createObject( QObject*, const char*, const char*, |
385 | const QStringList & ) | 385 | const QStringList & ) |
386 | { | 386 | { |
387 | return 0; | 387 | return 0; |
388 | } | 388 | } |
389 | }; | 389 | }; |
390 | 390 | ||
391 | template<class TR,class TC, class TS> | 391 | template<class TR,class TC, class TS> |
392 | class PluginFactory : public PluginFactoryBase | 392 | class PluginFactory : public PluginFactoryBase |
393 | { | 393 | { |
394 | public: | 394 | public: |
395 | Resource *resource( const KConfig *config, bool syncable ) | 395 | Resource *resource( const KConfig *config, bool syncable ) |
396 | { | 396 | { |
397 | return new TR( config, syncable ); | 397 | return new TR( config, syncable ); |
398 | } | 398 | } |
399 | 399 | ||
400 | ConfigWidget *configWidget( QWidget *parent ) | 400 | ConfigWidget *configWidget( QWidget *parent ) |
401 | { | 401 | { |
402 | return new TC( parent ); | 402 | return new TC( parent ); |
403 | } | 403 | } |
404 | 404 | ||
405 | virtual SyncWidget *syncWidget( QWidget *parent ) | 405 | SyncWidgetContainer *syncWidgetContainer() |
406 | { | 406 | { |
407 | return new TS( parent ); | 407 | return new TS(); |
408 | } | 408 | } |
409 | 409 | ||
410 | }; | 410 | }; |
411 | 411 | ||
412 | 412 | ||
413 | 413 | ||
414 | } | 414 | } |
415 | 415 | ||
416 | #endif | 416 | #endif |
diff --git a/microkde/kresources/syncwidget.h b/microkde/kresources/syncwidget.h index e94252c..6632b69 100644 --- a/microkde/kresources/syncwidget.h +++ b/microkde/kresources/syncwidget.h | |||
@@ -29,34 +29,44 @@ | |||
29 | 29 | ||
30 | #include "resource.h" | 30 | #include "resource.h" |
31 | 31 | ||
32 | namespace KRES { | 32 | namespace KRES { |
33 | 33 | ||
34 | class SyncWidget : public QWidget | 34 | class SyncWidget : public QWidget |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | 37 | ||
38 | public: | 38 | public: |
39 | SyncWidget( QWidget *parent = 0, const char *name = 0 ); | 39 | SyncWidget( QWidget *parent = 0, const char *name = 0 ); |
40 | 40 | ||
41 | /** | 41 | /** |
42 | Sets the widget to 'edit' mode. Reimplement this method if you are | 42 | Sets the widget to 'edit' mode. Reimplement this method if you are |
43 | interested in the mode change (to disable some GUI element for | 43 | interested in the mode change (to disable some GUI element for |
44 | example). By default the widget is in 'create new' mode. | 44 | example). By default the widget is in 'create new' mode. |
45 | */ | 45 | */ |
46 | virtual void setInEditMode( bool value ); | 46 | virtual void setInEditMode( bool value ); |
47 | 47 | ||
48 | public slots: | 48 | public slots: |
49 | virtual void loadSettings( Resource *resource ); | 49 | virtual void loadSettings( Resource *resource ); |
50 | virtual void saveSettings( Resource *resource ); | 50 | virtual void saveSettings( Resource *resource ); |
51 | 51 | ||
52 | signals: | 52 | signals: |
53 | //US void setReadOnly( bool value ); | 53 | //US void setReadOnly( bool value ); |
54 | //US void setPersistentReadOnly( bool value ); | 54 | //US void setPersistentReadOnly( bool value ); |
55 | 55 | ||
56 | 56 | ||
57 | protected: | 57 | protected: |
58 | //US Resource* mResource; | 58 | //US Resource* mResource; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | class SyncWidgetContainer : public QObject | ||
62 | { | ||
63 | Q_OBJECT | ||
64 | |||
65 | public: | ||
66 | virtual SyncWidget* generateSettingsTab(QWidget *parent = 0, const char *name = 0) = 0; | ||
67 | virtual SyncWidget* generateConflictsTab(QWidget *parent = 0, const char *name = 0) = 0; | ||
68 | virtual SyncWidget* generateRemoteTab(QWidget *parent = 0, const char *name = 0) = 0; | ||
69 | }; | ||
70 | |||
61 | } | 71 | } |
62 | #endif | 72 | #endif |