summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/configdialog.cpp89
-rw-r--r--microkde/kresources/configdialog.h4
-rw-r--r--microkde/kresources/configpage.cpp75
-rw-r--r--microkde/kresources/configpage.h1
-rw-r--r--microkde/kresources/factory.cpp44
-rw-r--r--microkde/kresources/factory.h26
-rw-r--r--microkde/microkdeE.pro2
7 files changed, 179 insertions, 62 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 @@
#include "configdialog.h"
+#include "syncwidget.h"
@@ -45,6 +46,7 @@ using namespace KRES;
ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
- /*const QString& type,*/ Resource* resource, /*KConfig *config, */const char *name )
- : KDialogBase( parent, name, true, i18n( "Resource Configuration" ),
- Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ), mPersistentReadOnly(false)
+ 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)
{
+
Factory *factory = Factory::self( resourceFamily );
@@ -63,3 +65,3 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
- new QLabel( i18n( "Name:" ), generalGroupBox );
+ new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox );
@@ -67,6 +69,8 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
- mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox );
+ if (!mResource->isSyncable()) {
+ mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox );
+ mReadOnly->setChecked( mResource->readOnly() );
+ }
mName->setText( mResource->resourceName() );
- mReadOnly->setChecked( mResource->readOnly() );
@@ -84,5 +88,5 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
if ( mConfigWidget ) {
- connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ),
+ connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ),
SLOT( setReadOnly( bool ) ) );
- connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ),
+ connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ),
SLOT( setPersistentReadOnly( bool ) ) );
@@ -91,6 +95,26 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
mConfigWidget->show();
-
+
}
- connect( mName, SIGNAL( textChanged(const QString &)),
+ if (mResource->isSyncable())
+ {
+ QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, main );
+ syncGroupBox->layout()->setSpacing( spacingHint());
+ syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) );
+ mainLayout->addWidget( syncGroupBox );
+
+ mainLayout->addStretch();
+
+ mSyncWidget = factory->syncWidget( resource->type(), syncGroupBox );
+ if ( mSyncWidget ) {
+ mSyncWidget->setInEditMode( false );
+ mSyncWidget->loadSettings( mResource );
+ mSyncWidget->show();
+ }
+ }
+
+
+
+
+ connect( mName, SIGNAL( textChanged(const QString &)),
SLOT( slotNameChanged(const QString &)));
@@ -98,3 +122,3 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
slotNameChanged( mName->text() );
-
+
//US setMinimumSize( 400, 250 );
@@ -108,2 +132,6 @@ void ConfigDialog::setInEditMode( bool value )
mConfigWidget->setInEditMode( value );
+
+ if ( mSyncWidget )
+ mSyncWidget->setInEditMode( value );
+
}
@@ -117,6 +145,9 @@ void ConfigDialog::setReadOnly( bool value )
{
- if (mPersistentReadOnly == false)
- mReadOnly->setChecked( value );
- else
- mReadOnly->setChecked( true );
+ if (!mResource->isSyncable()) {
+
+ if (mPersistentReadOnly == false)
+ mReadOnly->setChecked( value );
+ else
+ mReadOnly->setChecked( true );
+ }
}
@@ -125,9 +156,11 @@ void ConfigDialog::setPersistentReadOnly( bool value )
{
- mPersistentReadOnly = value;
-
- if (value == true)
- setReadOnly( true );
-
- mReadOnly->setEnabled( !value );
-
+ if (!mResource->isSyncable()) {
+
+ mPersistentReadOnly = value;
+
+ if (value == true)
+ setReadOnly( true );
+
+ mReadOnly->setEnabled( !value );
+ }
}
@@ -137,3 +170,3 @@ void ConfigDialog::accept()
if ( mName->text().isEmpty() ) {
- KMessageBox::sorry( this, i18n( "Please enter a resource name" ) );
+ KMessageBox::sorry( this, mResource->isSyncable()?i18n( "Please enter a profile name" ):i18n( "Please enter a resource name" ) );
return;
@@ -142,3 +175,4 @@ void ConfigDialog::accept()
mResource->setResourceName( mName->text() );
- mResource->setReadOnly( mReadOnly->isChecked() );
+ if (!mResource->isSyncable())
+ mResource->setReadOnly( mReadOnly->isChecked() );
@@ -150,2 +184,9 @@ void ConfigDialog::accept()
+ if ( mSyncWidget ) {
+ // First save generic information
+ // Also save setting of specific resource type
+ mSyncWidget->saveSettings( mResource );
+ }
+
+
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 {
class ConfigWidget;
+ class SyncWidget;
@@ -52,2 +53,3 @@ class ConfigDialog : public KDialogBase
ConfigWidget *mConfigWidget;
+ SyncWidget *mSyncWidget;
Resource* mResource;
@@ -57,3 +59,3 @@ class ConfigDialog : public KDialogBase
//US add a persistent readonly flag. We need that for opie and qtopia addressbooks.
- bool mPersistentReadOnly;
+ bool mPersistentReadOnly;
};
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 @@
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
#include <qgroupbox.h>
@@ -52,2 +59,5 @@ using namespace KRES;
+const QString ConfigPage::syncfamily = "syncprofiles";
+
+
class ConfigViewItem : public QCheckListItem
@@ -166,5 +176,7 @@ void ConfigPage::load()
QStringList families;
- families << "contact" << "sync-contacts";
+ families << "contact" << syncfamily;
+
+
for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it )
- {
+ {
QString family = (*it);
@@ -172,3 +184,3 @@ void ConfigPage::load()
if ( !mFamilyMap.contains( family ) ) {
- mCurrentManager = new Manager<Resource>( family );
+ mCurrentManager = new Manager<Resource>( family, (family == syncfamily) );
if ( mCurrentManager ) {
@@ -230,3 +242,3 @@ void ConfigPage::slotFamilyChanged( int pos )
//US qDebug("ConfigPage::slotFamilyChanged 4 family=%s", mFamily.latin1());
-
+
mCurrentManager = mInfoMap[ pos ].mManager;
@@ -241,11 +253,11 @@ void ConfigPage::slotFamilyChanged( int pos )
//US qDebug("ConfigPage::slotFamilyChanged 4.1 mCurrentManager=%ul", mCurrentManager );
-
+
defaults();
}
-
+
Resource *standardResource = mCurrentManager->standardResource();
-
+
//US qDebug("ConfigPage::slotFamilyChanged 4.4 resourcename=%s", standardResource->resourceName().latin1());
-
+
Manager<Resource>::Iterator it;
@@ -256,3 +268,3 @@ void ConfigPage::slotFamilyChanged( int pos )
}
-
+
if ( mListView->childCount() == 0 ) {
@@ -265,8 +277,8 @@ void ConfigPage::slotFamilyChanged( int pos )
//US qDebug("ConfigPage::slotFamilyChanged 4.6 ");
-
+
if ( !standardResource ) {
- KMessageBox::sorry( this, i18n( "There is no standard resource! Please select one." ) );
-
+ KMessageBox::sorry( this, i18n( "There is no standard resource!<br> Please select one." ) );
+
//US qDebug("ConfigPage::slotFamilyChanged 4.7" );
-
+
}
@@ -285,5 +297,18 @@ void ConfigPage::slotAdd()
bool ok = false;
- QString desc = QInputDialog::getItem( i18n( "Resource Configuration" ),
- i18n( "Please select type of the new resource:" ), descs, 0,
+
+ QString desc;
+
+ if (mFamily == syncfamily)
+ {
+ desc = QInputDialog::getItem( i18n( "Sync Configuration" ),
+ i18n( "Please select resource type for 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,
false, &ok, this );
+ }
+
if ( !ok )
@@ -382,3 +407,3 @@ void ConfigPage::slotEdit()
if ( configItem->standard() && configItem->readOnly() ) {
- KMessageBox::sorry( this, i18n( "You cannot use a read-only resource as standard!" ) );
+ KMessageBox::sorry( this, i18n( "You cannot use a read-only<br> resource as standard!" ) );
configItem->setStandard( false );
@@ -401,3 +426,3 @@ void ConfigPage::slotStandard()
if ( item->readOnly() ) {
- KMessageBox::sorry( this, i18n( "You cannot use a read-only resource as standard!" ) );
+ KMessageBox::sorry( this, i18n( "You cannot use a read-only<br>resource as standard!" ) );
return;
@@ -406,3 +431,3 @@ void ConfigPage::slotStandard()
if ( !item->isOn() ) {
- KMessageBox::sorry( this, i18n( "You cannot use an inactive resource as standard!" ) );
+ KMessageBox::sorry( this, i18n( "You cannot use an inactive<br>resource as standard!" ) );
return;
@@ -466,3 +491,3 @@ void ConfigPage::slotItemClicked( QListViewItem *item )
if ( configItem->standard() && !configItem->isOn() ) {
- KMessageBox::sorry( this, i18n( "You cannot deactivate the standard resource. Choose another standard resource first." ) );
+ KMessageBox::sorry( this, i18n( "You cannot deactivate the<br>standard resource. Choose<br>another standard resource first." ) );
configItem->setOn( true );
@@ -481,3 +506,3 @@ void ConfigPage::saveResourceSettings()
if ( mCurrentManager ) {
-
+
QListViewItem *item = mListView->firstChild();
@@ -489,6 +514,6 @@ void ConfigPage::saveResourceSettings()
configItem->isOn() ) {
-
+
mCurrentManager->setStandardResource( configItem->resource() );
}
-
+
// check if active or passive resource
@@ -501,7 +526,7 @@ void ConfigPage::saveResourceSettings()
if ( !mCurrentManager->standardResource() )
- KMessageBox::sorry( this, i18n( "There is no valid standard resource! Please select one which is neither read-only nor inactive." ) );
+ KMessageBox::sorry( this, i18n( "There is no valid standard resource!<br>Please select one which is neither read-only nor inactive." ) );
}
-
+
qDebug("ConfigPage::saveResourceSettings() end");
-
+
}
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>
QListViewItem* mLastItem;
+ static const QString syncfamily;
};
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
@@ -41,3 +41,3 @@ static KStaticDeleter< QDict<Factory> > staticDeleter;
-Factory *Factory::self( const QString& resourceFamily )
+Factory *Factory::self( const QString& resourceFamily)
{
@@ -54,3 +54,3 @@ Factory *Factory::self( const QString& resourceFamily )
if ( !factory ) {
- factory = new Factory( resourceFamily );
+ factory = new Factory( resourceFamily);
mSelves->insert( resourceFamily, factory );
@@ -61,3 +61,3 @@ Factory *Factory::self( const QString& resourceFamily )
-Factory::Factory( const QString& resourceFamily ) :
+Factory::Factory( const QString& resourceFamily) :
mResourceFamily( resourceFamily )
@@ -189,2 +189,36 @@ ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
+SyncWidget *Factory::syncWidget( const QString& type, QWidget *parent )
+{
+ if ( type.isEmpty() || !mTypeMap.contains( type ) )
+ return 0;
+
+//US KService::Ptr ptr = mTypeMap[ type ];
+//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
+ PluginInfo* pi = mTypeMap[ type ];
+ KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
+ if ( !factory ) {
+ qDebug("KRES::Factory::syncWidget(): Factory creation failed for library %s", pi->library.latin1());
+ kdDebug() << "KRES::Factory::syncWidget(): Factory creation failed" << endl;
+ return 0;
+ }
+
+ PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
+
+ 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 );
+ 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;
+
+}
+
+
QString Factory::typeName( const QString &type ) const
@@ -213,3 +247,3 @@ QString Factory::typeDescription( const QString &type ) const
-Resource *Factory::resource( const QString& type, const KConfig *config )
+Resource *Factory::resource( const QString& type, const KConfig *config, bool syncable )
{
@@ -244,3 +278,3 @@ Resource *Factory::resource( const QString& type, const KConfig *config )
- Resource *resource = pluginFactory->resource( config );
+ Resource *resource = pluginFactory->resource( config, syncable );
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
@@ -36,3 +36,3 @@ namespace KRES {
-//US
+//US
struct PluginInfo
@@ -67,3 +67,3 @@ class Factory
-
+
/**
@@ -80,3 +80,3 @@ class Factory
* @param type The type of the resource, returned by @ref resources()
- * @param resource The resource to be editted.
+ * @param resource The resource to be editted.
* @param parent The parent widget
@@ -86,2 +86,13 @@ class Factory
/**
+ * Returns the sync widget for the given resource type,
+ * or a null pointer if resource type doesn't exist,
+ * 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 );
+
+ /**
* Returns a pointer to a resource object or a null pointer
@@ -92,4 +103,5 @@ class Factory
* @param config The config object where the resource get it settings from, or 0 if a new resource should be created.
+ * @param syncable If the resource should support syncing capabilities.
*/
- Resource *resource( const QString& type, const KConfig *config );
+ Resource *resource( const QString& type, const KConfig *config, bool syncable );
@@ -111,3 +123,3 @@ class Factory
protected:
- Factory( const QString& resourceFamily );
+ Factory( const QString& resourceFamily);
@@ -118,4 +130,4 @@ class Factory
//US QMap<QString, KService::Ptr> mTypeMap;
-//US lets store the pluginfo struct as value instead of a KService
- QMap<QString, PluginInfo*> mTypeMap;
+//US lets store the pluginfo struct as value instead of a KService
+ QMap<QString, PluginInfo*> mTypeMap;
};
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 \
kresources/kcmkresources.h \
+ kresources/syncwidget.h \
kdecore/kmdcodec.h \
@@ -171,2 +172,3 @@ oprocess.cpp \
kresources/selectdialog.cpp \
+ kresources/syncwidget.cpp \
kutils/kcmultidialog.cpp