summaryrefslogtreecommitdiffabout
path: root/microkde
Unidiff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/configdialog.cpp78
-rw-r--r--microkde/kresources/configdialog.h4
-rw-r--r--microkde/kresources/configpage.cpp15
-rw-r--r--microkde/kresources/factory.cpp4
-rw-r--r--microkde/kresources/factory.h5
-rw-r--r--microkde/kresources/resource.h8
-rw-r--r--microkde/kresources/syncwidget.h10
7 files changed, 97 insertions, 27 deletions
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
@@ -26,14 +26,16 @@
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"
@@ -43,25 +45,30 @@
43 45
44using namespace KRES; 46using namespace KRES;
45 47
46ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, 48ConfigDialog::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
@@ -95,25 +102,59 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
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 &)),
@@ -128,14 +169,18 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
128 169
129void ConfigDialog::setInEditMode( bool value ) 170void 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
139void ConfigDialog::slotNameChanged( const QString &text) 184void ConfigDialog::slotNameChanged( const QString &text)
140{ 185{
141 enableButtonOK( !text.isEmpty() ); 186 enableButtonOK( !text.isEmpty() );
@@ -179,17 +224,18 @@ void ConfigDialog::accept()
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
@@ -48,13 +48,15 @@ class ConfigDialog : public KDialogBase
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;
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
@@ -202,12 +202,14 @@ void ConfigPage::load()
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
@@ -308,19 +310,19 @@ void ConfigPage::slotAdd()
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
@@ -331,13 +333,20 @@ void ConfigPage::slotAdd()
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
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
@@ -184,13 +184,13 @@ ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
184 return 0; 184 return 0;
185 } 185 }
186 return wdg; 186 return wdg;
187 187
188} 188}
189 189
190SyncWidget *Factory::syncWidget( const QString& type, QWidget *parent ) 190SyncWidgetContainer *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() );
@@ -207,13 +207,13 @@ SyncWidget *Factory::syncWidget( const QString& type, QWidget *parent )
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;
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
@@ -31,12 +31,15 @@
31 31
32 32
33#include "resource.h" 33#include "resource.h"
34 34
35namespace KRES { 35namespace KRES {
36 36
37class SyncWidgetContainer;
38class ConfigWidget;
39
37//US 40//US
38struct PluginInfo 41struct PluginInfo
39{ 42{
40 QString library; 43 QString library;
41 QString nameLabel; 44 QString nameLabel;
42 QString descriptionLabel; 45 QString descriptionLabel;
@@ -89,13 +92,13 @@ class Factory
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()
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
@@ -37,13 +37,13 @@
37 37
38class KConfig; 38class KConfig;
39 39
40namespace KRES { 40namespace KRES {
41 41
42class ConfigWidget; 42class ConfigWidget;
43class SyncWidget; 43class 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
@@ -375,13 +375,13 @@ 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;
@@ -399,15 +399,15 @@ class PluginFactory : public PluginFactoryBase
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
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
@@ -55,8 +55,18 @@ signals:
55 55
56 56
57protected: 57protected:
58//US Resource* mResource; 58//US Resource* mResource;
59}; 59};
60 60
61class SyncWidgetContainer : public QObject
62{
63 Q_OBJECT
64
65public:
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