-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 |
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 @@ -28,10 +28,12 @@ #include <qgroupbox.h> #include <qlabel.h> #include <qlayout.h> #include <qpushbutton.h> +#include <qvbox.h> #include <qcheckbox.h> +#include <qscrollview.h> #include <kbuttonbox.h> #include <kdialog.h> #include <klineedit.h> @@ -45,21 +47,26 @@ using namespace KRES; ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, Resource* resource, const char *name ) : KDialogBase( parent, name, true, resource->isSyncable()?i18n( "Sync Profile Configuration" ):i18n( "Resource Configuration" ), - Ok|Cancel, Ok, true )/*, mConfig( config )*/, mSyncWidget(0), mResource( resource ), mPersistentReadOnly(false) + Ok|Cancel, Ok, true )/*, mConfig( config )*/, mSyncWidget_Settings(0), mSyncWidget_Conflicts(0),mSyncWidget_Remote(0), mResource( resource ), mPersistentReadOnly(false) { Factory *factory = Factory::self( resourceFamily ); //US resize( 250, 240 ); resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); -//US QFrame *main = makeMainWidget(); - QFrame *main = plainPage(); + QFrame *main; + + if (!mResource->isSyncable()) + main = plainPage(); + else + main = addPage("Profile"); QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); + QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); generalGroupBox->layout()->setSpacing( spacingHint() ); generalGroupBox->setTitle( i18n( "General Settings" ) ); @@ -97,21 +104,55 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, } if (mResource->isSyncable()) { - QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); - syncGroupBox->layout()->setSpacing( spacingHint()); - syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) ); - mainLayout->addWidget( syncGroupBox ); + SyncWidgetContainer* c = factory->syncWidgetContainer( resource->type() ); + + QFrame* syncPage = addPage("Settings"); + QVBoxLayout *syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() ); + mSyncWidget_Settings = c->generateSettingsTab(syncPage); + syncLayout->addWidget( mSyncWidget_Settings ); + + syncPage = addPage("Conflicts"); + syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() ); + mSyncWidget_Conflicts = c->generateConflictsTab(syncPage); + syncLayout->addWidget( mSyncWidget_Conflicts ); + + syncPage = addPage("Remote"); + syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() ); + mSyncWidget_Remote = c->generateRemoteTab(syncPage); + syncLayout->addWidget( mSyncWidget_Remote ); + - mainLayout->addStretch(); + mSyncWidget_Settings->setInEditMode( false ); + mSyncWidget_Settings->loadSettings( mResource ); + mSyncWidget_Settings->show(); - mSyncWidget = factory->syncWidget( resource->type(), syncGroupBox ); + mSyncWidget_Conflicts->setInEditMode( false ); + mSyncWidget_Conflicts->loadSettings( mResource ); + mSyncWidget_Conflicts->show(); + + mSyncWidget_Remote->setInEditMode( false ); + mSyncWidget_Remote->loadSettings( mResource ); + mSyncWidget_Remote->show(); + + delete c; + +// QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, syncPage ); +// syncGroupBox->layout()->setSpacing( spacingHint()); +// syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) ); +// syncLayout->addWidget( syncGroupBox ); + +// syncLayout->addStretch(); +/*US + mSyncWidget = factory->syncWidget( resource->type(), syncPage ); + syncLayout->addWidget( mSyncWidget ); if ( mSyncWidget ) { mSyncWidget->setInEditMode( false ); mSyncWidget->loadSettings( mResource ); mSyncWidget->show(); } + */ } @@ -130,10 +171,14 @@ void ConfigDialog::setInEditMode( bool value ) { if ( mConfigWidget ) mConfigWidget->setInEditMode( value ); - if ( mSyncWidget ) - mSyncWidget->setInEditMode( value ); + if ( mSyncWidget_Settings ) + mSyncWidget_Settings->setInEditMode( value ); + if ( mSyncWidget_Conflicts ) + mSyncWidget_Conflicts->setInEditMode( value ); + if ( mSyncWidget_Remote ) + mSyncWidget_Remote->setInEditMode( value ); } void ConfigDialog::slotNameChanged( const QString &text) @@ -181,13 +226,14 @@ void ConfigDialog::accept() // Also save setting of specific resource type mConfigWidget->saveSettings( mResource ); } - if ( mSyncWidget ) { - // First save generic information - // Also save setting of specific resource type - mSyncWidget->saveSettings( mResource ); - } + if ( mSyncWidget_Settings ) + mSyncWidget_Settings->saveSettings( mResource ); + if ( mSyncWidget_Conflicts ) + mSyncWidget_Conflicts->saveSettings( mResource ); + if ( mSyncWidget_Remote ) + mSyncWidget_Remote->saveSettings( mResource ); KDialog::accept(); } 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 @@ -50,9 +50,11 @@ class ConfigDialog : public KDialogBase void slotNameChanged( const QString &text); private: ConfigWidget *mConfigWidget; - SyncWidget *mSyncWidget; + SyncWidget *mSyncWidget_Settings; + SyncWidget *mSyncWidget_Conflicts; + SyncWidget *mSyncWidget_Remote; Resource* mResource; KLineEdit *mName; QCheckBox *mReadOnly; 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 @@ -204,8 +204,10 @@ void ConfigPage::load() if ( family == "contact" && QFile::exists( configDir + "/kabcrc" ) ) { info.mConfig = new KConfig( locateLocal( "config", "kabcrc" ) ); } else if ( family == "calendar" && QFile::exists( configDir + "/kcalrc" ) ) { info.mConfig = new KConfig( locateLocal( "config", "kcalrc" ) ); + } else if ( family == syncfamily && QFile::exists( configDir + "/kabcsyncrc" ) ) { + info.mConfig = new KConfig( locateLocal( "config", "kabcsyncrc" ) ); } else { QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) ); info.mConfig = new KConfig( configFile ); } @@ -310,15 +312,15 @@ void ConfigPage::slotAdd() if (mFamily == syncfamily) { desc = QInputDialog::getItem( i18n( "Sync Configuration" ), - i18n( "Please select resource type for new sync profile:" ), descs, 0, + i18n( "Select resource type for the new sync profile:" ), descs, 0, false, &ok, this ); } else { desc = QInputDialog::getItem( i18n( "Resource Configuration" ), - i18n( "Please select type of the new resource:" ), descs, 0, + i18n( "Select type of the new resource:" ), descs, 0, false, &ok, this ); } if ( !ok ) @@ -333,9 +335,16 @@ void ConfigPage::slotAdd() .arg( type ) ); return; } - resource->setResourceName( type + "-resource" ); + if (mFamily == syncfamily) + { + resource->setResourceName( type + "-syncprofile" ); + } + else + { + resource->setResourceName( type + "-resource" ); + } ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" ); if ( dlg.exec() ) { 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 @@ -186,9 +186,9 @@ ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent ) return wdg; } -SyncWidget *Factory::syncWidget( const QString& type, QWidget *parent ) +SyncWidgetContainer *Factory::syncWidgetContainer( const QString& type ) { if ( type.isEmpty() || !mTypeMap.contains( type ) ) return 0; @@ -209,9 +209,9 @@ SyncWidget *Factory::syncWidget( const QString& type, QWidget *parent ) kdDebug() << "KRES::Factory::syncWidget(): no plugin factory." << endl; return 0; } - SyncWidget *wdg = pluginFactory->syncWidget( parent ); + SyncWidgetContainer *wdg = pluginFactory->syncWidgetContainer( ); if ( !wdg ) { //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); return 0; 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 @@ -33,8 +33,11 @@ #include "resource.h" namespace KRES { +class SyncWidgetContainer; +class ConfigWidget; + //US struct PluginInfo { QString library; @@ -91,9 +94,9 @@ class Factory * @param type The type of the resource, returned by @ref resources() * @param resource The resource to be editted. * @param parent The parent widget */ - SyncWidget *syncWidget( const QString& type, QWidget *parent = 0 ); + SyncWidgetContainer *syncWidgetContainer( const QString& type ); /** * Returns a pointer to a resource object or a null pointer * if resource type doesn't exist. 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 @@ -39,9 +39,9 @@ class KConfig; namespace KRES { class ConfigWidget; -class SyncWidget; +class SyncWidgetContainer; /** * @internal * @libdoc The KDE Resource library @@ -377,9 +377,9 @@ class PluginFactoryBase : public KLibFactory virtual Resource *resource( const KConfig *config, bool syncable ) = 0; virtual ConfigWidget *configWidget( QWidget *parent ) = 0; - virtual SyncWidget *syncWidget( QWidget *parent ) = 0; + virtual SyncWidgetContainer *syncWidgetContainer() = 0; protected: virtual QObject* createObject( QObject*, const char*, const char*, const QStringList & ) @@ -401,11 +401,11 @@ class PluginFactory : public PluginFactoryBase { return new TC( parent ); } - virtual SyncWidget *syncWidget( QWidget *parent ) + SyncWidgetContainer *syncWidgetContainer() { - return new TS( parent ); + return new TS(); } }; 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 @@ -57,6 +57,16 @@ signals: protected: //US Resource* mResource; }; +class SyncWidgetContainer : public QObject +{ + Q_OBJECT + +public: + virtual SyncWidget* generateSettingsTab(QWidget *parent = 0, const char *name = 0) = 0; + virtual SyncWidget* generateConflictsTab(QWidget *parent = 0, const char *name = 0) = 0; + virtual SyncWidget* generateRemoteTab(QWidget *parent = 0, const char *name = 0) = 0; +}; + } #endif |