summaryrefslogtreecommitdiffabout
Side-by-side diff
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 @@
#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,
+ if (!mResource->isSyncable()) {
mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox );
+ mReadOnly->setChecked( mResource->readOnly() );
+ }
mName->setText( mResource->resourceName() );
- mReadOnly->setChecked( mResource->readOnly() );
@@ -94,2 +98,22 @@ 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 );
+
+ mainLayout->addStretch();
+
+ mSyncWidget = factory->syncWidget( resource->type(), syncGroupBox );
+ if ( mSyncWidget ) {
+ mSyncWidget->setInEditMode( false );
+ mSyncWidget->loadSettings( mResource );
+ mSyncWidget->show();
+ }
+ }
+
+
+
+
connect( mName, SIGNAL( textChanged(const QString &)),
@@ -108,2 +132,6 @@ void ConfigDialog::setInEditMode( bool value )
mConfigWidget->setInEditMode( value );
+
+ if ( mSyncWidget )
+ mSyncWidget->setInEditMode( value );
+
}
@@ -117,2 +145,4 @@ void ConfigDialog::setReadOnly( bool value )
{
+ if (!mResource->isSyncable()) {
+
if (mPersistentReadOnly == false)
@@ -122,2 +152,3 @@ void ConfigDialog::setReadOnly( bool value )
}
+}
@@ -125,2 +156,4 @@ void ConfigDialog::setPersistentReadOnly( bool value )
{
+ if (!mResource->isSyncable()) {
+
mPersistentReadOnly = value;
@@ -131,3 +164,3 @@ void ConfigDialog::setPersistentReadOnly( bool value )
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,2 +175,3 @@ void ConfigDialog::accept()
mResource->setResourceName( mName->text() );
+ 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;
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,3 +176,5 @@ void ConfigPage::load()
QStringList families;
- families << "contact" << "sync-contacts";
+ families << "contact" << syncfamily;
+
+
for ( QStringList::Iterator it = families.begin(); it != families.end(); ++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 ) {
@@ -267,3 +279,3 @@ void ConfigPage::slotFamilyChanged( int pos )
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." ) );
@@ -285,5 +297,18 @@ void ConfigPage::slotAdd()
bool ok = false;
- QString desc = QInputDialog::getItem( i18n( "Resource Configuration" ),
+
+ 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 );
@@ -501,3 +526,3 @@ 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." ) );
}
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
@@ -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
@@ -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 );
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