summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--microkde/kresources/configdialog.cpp55
-rw-r--r--microkde/kresources/configdialog.h2
-rw-r--r--microkde/kresources/configpage.cpp43
-rw-r--r--microkde/kresources/configpage.h1
-rw-r--r--microkde/kresources/factory.cpp38
-rw-r--r--microkde/kresources/factory.h14
-rw-r--r--microkde/microkdeE.pro2
7 files changed, 136 insertions, 19 deletions
diff --git a/microkde/kresources/configdialog.cpp b/microkde/kresources/configdialog.cpp
index 0fc199c..90febca 100644
--- a/microkde/kresources/configdialog.cpp
+++ b/microkde/kresources/configdialog.cpp
@@ -41,2 +41,3 @@
41#include "configdialog.h" 41#include "configdialog.h"
42#include "syncwidget.h"
42 43
@@ -45,6 +46,7 @@ using namespace KRES;
45ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, 46ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
46 /*const QString& type,*/ Resource* resource, /*KConfig *config, */const char *name ) 47 Resource* resource, const char *name )
47 : KDialogBase( parent, name, true, i18n( "Resource Configuration" ), 48 : KDialogBase( parent, name, true, resource->isSyncable()?i18n( "Sync Profile Configuration" ):i18n( "Resource Configuration" ),
48 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ), mPersistentReadOnly(false) 49 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mSyncWidget(0), mResource( resource ), mPersistentReadOnly(false)
49{ 50{
51
50 Factory *factory = Factory::self( resourceFamily ); 52 Factory *factory = Factory::self( resourceFamily );
@@ -63,3 +65,3 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
63 65
64 new QLabel( i18n( "Name:" ), generalGroupBox ); 66 new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox );
65 67
@@ -67,6 +69,8 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
67 69
70 if (!mResource->isSyncable()) {
68 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); 71 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox );
72 mReadOnly->setChecked( mResource->readOnly() );
73 }
69 74
70 mName->setText( mResource->resourceName() ); 75 mName->setText( mResource->resourceName() );
71 mReadOnly->setChecked( mResource->readOnly() );
72 76
@@ -94,2 +98,22 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
94 98
99 if (mResource->isSyncable())
100 {
101 QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, main );
102 syncGroupBox->layout()->setSpacing( spacingHint());
103 syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) );
104 mainLayout->addWidget( syncGroupBox );
105
106 mainLayout->addStretch();
107
108 mSyncWidget = factory->syncWidget( resource->type(), syncGroupBox );
109 if ( mSyncWidget ) {
110 mSyncWidget->setInEditMode( false );
111 mSyncWidget->loadSettings( mResource );
112 mSyncWidget->show();
113 }
114 }
115
116
117
118
95 connect( mName, SIGNAL( textChanged(const QString &)), 119 connect( mName, SIGNAL( textChanged(const QString &)),
@@ -108,2 +132,6 @@ void ConfigDialog::setInEditMode( bool value )
108 mConfigWidget->setInEditMode( value ); 132 mConfigWidget->setInEditMode( value );
133
134 if ( mSyncWidget )
135 mSyncWidget->setInEditMode( value );
136
109} 137}
@@ -117,2 +145,4 @@ void ConfigDialog::setReadOnly( bool value )
117{ 145{
146 if (!mResource->isSyncable()) {
147
118 if (mPersistentReadOnly == false) 148 if (mPersistentReadOnly == false)
@@ -122,2 +152,3 @@ void ConfigDialog::setReadOnly( bool value )
122} 152}
153}
123 154
@@ -125,2 +156,4 @@ void ConfigDialog::setPersistentReadOnly( bool value )
125{ 156{
157 if (!mResource->isSyncable()) {
158
126 mPersistentReadOnly = value; 159 mPersistentReadOnly = value;
@@ -131,3 +164,3 @@ void ConfigDialog::setPersistentReadOnly( bool value )
131 mReadOnly->setEnabled( !value ); 164 mReadOnly->setEnabled( !value );
132 165 }
133} 166}
@@ -137,3 +170,3 @@ void ConfigDialog::accept()
137 if ( mName->text().isEmpty() ) { 170 if ( mName->text().isEmpty() ) {
138 KMessageBox::sorry( this, i18n( "Please enter a resource name" ) ); 171 KMessageBox::sorry( this, mResource->isSyncable()?i18n( "Please enter a profile name" ):i18n( "Please enter a resource name" ) );
139 return; 172 return;
@@ -142,2 +175,3 @@ void ConfigDialog::accept()
142 mResource->setResourceName( mName->text() ); 175 mResource->setResourceName( mName->text() );
176 if (!mResource->isSyncable())
143 mResource->setReadOnly( mReadOnly->isChecked() ); 177 mResource->setReadOnly( mReadOnly->isChecked() );
@@ -150,2 +184,9 @@ void ConfigDialog::accept()
150 184
185 if ( mSyncWidget ) {
186 // First save generic information
187 // Also save setting of specific resource type
188 mSyncWidget->saveSettings( mResource );
189 }
190
191
151 KDialog::accept(); 192 KDialog::accept();
diff --git a/microkde/kresources/configdialog.h b/microkde/kresources/configdialog.h
index ba66f8e..b629347 100644
--- a/microkde/kresources/configdialog.h
+++ b/microkde/kresources/configdialog.h
@@ -33,2 +33,3 @@ namespace KRES {
33 class ConfigWidget; 33 class ConfigWidget;
34 class SyncWidget;
34 35
@@ -52,2 +53,3 @@ class ConfigDialog : public KDialogBase
52 ConfigWidget *mConfigWidget; 53 ConfigWidget *mConfigWidget;
54 SyncWidget *mSyncWidget;
53 Resource* mResource; 55 Resource* mResource;
diff --git a/microkde/kresources/configpage.cpp b/microkde/kresources/configpage.cpp
index 8782ffd..912c62e 100644
--- a/microkde/kresources/configpage.cpp
+++ b/microkde/kresources/configpage.cpp
@@ -23,2 +23,9 @@
23 23
24/*
25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk
27
28$Id$
29*/
30
24#include <qgroupbox.h> 31#include <qgroupbox.h>
@@ -52,2 +59,5 @@ using namespace KRES;
52 59
60const QString ConfigPage::syncfamily = "syncprofiles";
61
62
53class ConfigViewItem : public QCheckListItem 63class ConfigViewItem : public QCheckListItem
@@ -166,3 +176,5 @@ void ConfigPage::load()
166 QStringList families; 176 QStringList families;
167 families << "contact" << "sync-contacts"; 177 families << "contact" << syncfamily;
178
179
168 for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) 180 for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it )
@@ -172,3 +184,3 @@ void ConfigPage::load()
172 if ( !mFamilyMap.contains( family ) ) { 184 if ( !mFamilyMap.contains( family ) ) {
173 mCurrentManager = new Manager<Resource>( family ); 185 mCurrentManager = new Manager<Resource>( family, (family == syncfamily) );
174 if ( mCurrentManager ) { 186 if ( mCurrentManager ) {
@@ -267,3 +279,3 @@ void ConfigPage::slotFamilyChanged( int pos )
267 if ( !standardResource ) { 279 if ( !standardResource ) {
268 KMessageBox::sorry( this, i18n( "There is no standard resource! Please select one." ) ); 280 KMessageBox::sorry( this, i18n( "There is no standard resource!<br> Please select one." ) );
269 281
@@ -285,5 +297,18 @@ void ConfigPage::slotAdd()
285 bool ok = false; 297 bool ok = false;
286 QString desc = QInputDialog::getItem( i18n( "Resource Configuration" ), 298
299 QString desc;
300
301 if (mFamily == syncfamily)
302 {
303 desc = QInputDialog::getItem( i18n( "Sync Configuration" ),
304 i18n( "Please select resource type for new sync profile:" ), descs, 0,
305 false, &ok, this );
306 }
307 else
308 {
309 desc = QInputDialog::getItem( i18n( "Resource Configuration" ),
287 i18n( "Please select type of the new resource:" ), descs, 0, 310 i18n( "Please select type of the new resource:" ), descs, 0,
288 false, &ok, this ); 311 false, &ok, this );
312 }
313
289 if ( !ok ) 314 if ( !ok )
@@ -382,3 +407,3 @@ void ConfigPage::slotEdit()
382 if ( configItem->standard() && configItem->readOnly() ) { 407 if ( configItem->standard() && configItem->readOnly() ) {
383 KMessageBox::sorry( this, i18n( "You cannot use a read-only resource as standard!" ) ); 408 KMessageBox::sorry( this, i18n( "You cannot use a read-only<br> resource as standard!" ) );
384 configItem->setStandard( false ); 409 configItem->setStandard( false );
@@ -401,3 +426,3 @@ void ConfigPage::slotStandard()
401 if ( item->readOnly() ) { 426 if ( item->readOnly() ) {
402 KMessageBox::sorry( this, i18n( "You cannot use a read-only resource as standard!" ) ); 427 KMessageBox::sorry( this, i18n( "You cannot use a read-only<br>resource as standard!" ) );
403 return; 428 return;
@@ -406,3 +431,3 @@ void ConfigPage::slotStandard()
406 if ( !item->isOn() ) { 431 if ( !item->isOn() ) {
407 KMessageBox::sorry( this, i18n( "You cannot use an inactive resource as standard!" ) ); 432 KMessageBox::sorry( this, i18n( "You cannot use an inactive<br>resource as standard!" ) );
408 return; 433 return;
@@ -466,3 +491,3 @@ void ConfigPage::slotItemClicked( QListViewItem *item )
466 if ( configItem->standard() && !configItem->isOn() ) { 491 if ( configItem->standard() && !configItem->isOn() ) {
467 KMessageBox::sorry( this, i18n( "You cannot deactivate the standard resource. Choose another standard resource first." ) ); 492 KMessageBox::sorry( this, i18n( "You cannot deactivate the<br>standard resource. Choose<br>another standard resource first." ) );
468 configItem->setOn( true ); 493 configItem->setOn( true );
@@ -501,3 +526,3 @@ void ConfigPage::saveResourceSettings()
501 if ( !mCurrentManager->standardResource() ) 526 if ( !mCurrentManager->standardResource() )
502 KMessageBox::sorry( this, i18n( "There is no valid standard resource! Please select one which is neither read-only nor inactive." ) ); 527 KMessageBox::sorry( this, i18n( "There is no valid standard resource!<br>Please select one which is neither read-only nor inactive." ) );
503 } 528 }
diff --git a/microkde/kresources/configpage.h b/microkde/kresources/configpage.h
index 492ea54..be9239e 100644
--- a/microkde/kresources/configpage.h
+++ b/microkde/kresources/configpage.h
@@ -98,2 +98,3 @@ class ConfigPage : public QWidget, public ManagerListener<Resource>
98 QListViewItem* mLastItem; 98 QListViewItem* mLastItem;
99 static const QString syncfamily;
99}; 100};
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp
index f82e94c..7a5c2f6 100644
--- a/microkde/kresources/factory.cpp
+++ b/microkde/kresources/factory.cpp
@@ -189,2 +189,36 @@ ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
189 189
190SyncWidget *Factory::syncWidget( const QString& type, QWidget *parent )
191{
192 if ( type.isEmpty() || !mTypeMap.contains( type ) )
193 return 0;
194
195//US KService::Ptr ptr = mTypeMap[ type ];
196//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
197 PluginInfo* pi = mTypeMap[ type ];
198 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
199 if ( !factory ) {
200 qDebug("KRES::Factory::syncWidget(): Factory creation failed for library %s", pi->library.latin1());
201 kdDebug() << "KRES::Factory::syncWidget(): Factory creation failed" << endl;
202 return 0;
203 }
204
205 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
206
207 if ( !pluginFactory ) {
208 qDebug("KRES::Factory::syncWidget(): no plugin factory for library %s", pi->library.latin1());
209 kdDebug() << "KRES::Factory::syncWidget(): no plugin factory." << endl;
210 return 0;
211 }
212
213 SyncWidget *wdg = pluginFactory->syncWidget( parent );
214 if ( !wdg ) {
215//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
216 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
217 return 0;
218 }
219 return wdg;
220
221}
222
223
190QString Factory::typeName( const QString &type ) const 224QString Factory::typeName( const QString &type ) const
@@ -213,3 +247,3 @@ QString Factory::typeDescription( const QString &type ) const
213 247
214Resource *Factory::resource( const QString& type, const KConfig *config ) 248Resource *Factory::resource( const QString& type, const KConfig *config, bool syncable )
215{ 249{
@@ -244,3 +278,3 @@ Resource *Factory::resource( const QString& type, const KConfig *config )
244 278
245 Resource *resource = pluginFactory->resource( config ); 279 Resource *resource = pluginFactory->resource( config, syncable );
246 if ( !resource ) { 280 if ( !resource ) {
diff --git a/microkde/kresources/factory.h b/microkde/kresources/factory.h
index ad67ab3..a265bc8 100644
--- a/microkde/kresources/factory.h
+++ b/microkde/kresources/factory.h
@@ -86,2 +86,13 @@ class Factory
86 /** 86 /**
87 * Returns the sync widget for the given resource type,
88 * or a null pointer if resource type doesn't exist,
89 * or a null pointer if resource does not support syncing.
90 *
91 * @param type The type of the resource, returned by @ref resources()
92 * @param resource The resource to be editted.
93 * @param parent The parent widget
94 */
95 SyncWidget *syncWidget( const QString& type, QWidget *parent = 0 );
96
97 /**
87 * Returns a pointer to a resource object or a null pointer 98 * Returns a pointer to a resource object or a null pointer
@@ -92,4 +103,5 @@ class Factory
92 * @param config The config object where the resource get it settings from, or 0 if a new resource should be created. 103 * @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.
93 */ 105 */
94 Resource *resource( const QString& type, const KConfig *config ); 106 Resource *resource( const QString& type, const KConfig *config, bool syncable );
95 107
diff --git a/microkde/microkdeE.pro b/microkde/microkdeE.pro
index ec2b1f7..b664c9a 100644
--- a/microkde/microkdeE.pro
+++ b/microkde/microkdeE.pro
@@ -91,2 +91,3 @@ osmartpointer.h \
91 kresources/kcmkresources.h \ 91 kresources/kcmkresources.h \
92 kresources/syncwidget.h \
92 kdecore/kmdcodec.h \ 93 kdecore/kmdcodec.h \
@@ -171,2 +172,3 @@ oprocess.cpp \
171 kresources/selectdialog.cpp \ 172 kresources/selectdialog.cpp \
173 kresources/syncwidget.cpp \
172 kutils/kcmultidialog.cpp 174 kutils/kcmultidialog.cpp