author | ulf69 <ulf69> | 2004-08-04 22:45:22 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-04 22:45:22 (UTC) |
commit | c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852 (patch) (side-by-side diff) | |
tree | dc59744a6d59ba241e793ce051da485d0bf16d06 /microkde/kresources | |
parent | b83866e08ddcc5cb2734801977927f48b53a2e1c (diff) | |
download | kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.zip kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.tar.gz kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.tar.bz2 |
final changes for addressbook sync config dialog
-rw-r--r-- | microkde/kresources/configdialog.cpp | 78 | ||||
-rw-r--r-- | microkde/kresources/configdialog.h | 4 | ||||
-rw-r--r-- | microkde/kresources/configpage.cpp | 13 | ||||
-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, 96 insertions, 26 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 @@ #include <kmessagebox.h> #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> #include "factory.h" @@ -43,25 +45,30 @@ 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" ) ); new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox ); @@ -95,25 +102,59 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, mConfigWidget->show(); } 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() ); - mainLayout->addStretch(); + 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 ); + + + 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(); } + */ } connect( mName, SIGNAL( textChanged(const QString &)), @@ -128,14 +169,18 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, 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) { enableButtonOK( !text.isEmpty() ); @@ -179,17 +224,18 @@ void ConfigDialog::accept() if ( mConfigWidget ) { // First save generic information // 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(); } //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 void setReadOnly( bool value ); void setPersistentReadOnly( bool value ); 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; //US add a persistent readonly flag. We need that for opie and qtopia addressbooks. 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() QString configDir = KGlobal::dirs()->saveLocation( "config" ); //QString configDir = KStandardDirs::appDir() + "/config"; 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 ); } info.mManager->readConfig( info.mConfig ); @@ -308,19 +310,19 @@ void ConfigPage::slotAdd() QString desc; 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 ) return; @@ -331,13 +333,20 @@ void ConfigPage::slotAdd() if ( !resource ) { KMessageBox::error( this, i18n("Unable to create resource of type '%1'.") .arg( type ) ); return; } + if (mFamily == syncfamily) + { + resource->setResourceName( type + "-syncprofile" ); + } + else + { resource->setResourceName( type + "-resource" ); + } ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" ); if ( dlg.exec() ) { mCurrentManager->add( resource ); 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 ) return 0; } return wdg; } -SyncWidget *Factory::syncWidget( const QString& type, QWidget *parent ) +SyncWidgetContainer *Factory::syncWidgetContainer( const QString& type ) { if ( type.isEmpty() || !mTypeMap.contains( type ) ) return 0; //US KService::Ptr ptr = mTypeMap[ type ]; //US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); @@ -207,13 +207,13 @@ SyncWidget *Factory::syncWidget( const QString& type, QWidget *parent ) if ( !pluginFactory ) { qDebug("KRES::Factory::syncWidget(): no plugin factory for library %s", pi->library.latin1()); 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; } 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 @@ #include "resource.h" namespace KRES { +class SyncWidgetContainer; +class ConfigWidget; + //US struct PluginInfo { QString library; QString nameLabel; QString descriptionLabel; @@ -89,13 +92,13 @@ class Factory * or a null pointer if resource does not support syncing. * * @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. * * @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 @@ class KConfig; namespace KRES { class ConfigWidget; -class SyncWidget; +class SyncWidgetContainer; /** * @internal * @libdoc The KDE Resource library * * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this @@ -375,13 +375,13 @@ class PluginFactoryBase : public KLibFactory { public: 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 & ) { return 0; @@ -399,15 +399,15 @@ class PluginFactory : public PluginFactoryBase ConfigWidget *configWidget( QWidget *parent ) { 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 @@ -55,8 +55,18 @@ 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 |