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
@@ -18,137 +18,178 @@
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <klocale.h>
#include <kglobal.h>
#include <kmessagebox.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qcheckbox.h>
#include <kbuttonbox.h>
#include <kdialog.h>
#include <klineedit.h>
#include "factory.h"
#include "configwidget.h"
#include "configdialog.h"
+#include "syncwidget.h"
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 );
//US resize( 250, 240 );
resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240));
//US QFrame *main = makeMainWidget();
QFrame *main = plainPage();
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( i18n( "Name:" ), generalGroupBox );
+ new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox );
mName = new KLineEdit( generalGroupBox );
- 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() );
mainLayout->addWidget( generalGroupBox );
QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main );
resourceGroupBox->layout()->setSpacing( spacingHint());
resourceGroupBox->setTitle( i18n( "%1 Resource Settings" )
.arg( factory->typeName( resource->type() ) ) );
mainLayout->addWidget( resourceGroupBox );
mainLayout->addStretch();
mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox );
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 ) ) );
mConfigWidget->setInEditMode( false );
mConfigWidget->loadSettings( mResource );
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 &)));
slotNameChanged( mName->text() );
-
+
//US setMinimumSize( 400, 250 );
setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250));
}
void ConfigDialog::setInEditMode( bool value )
{
if ( mConfigWidget )
mConfigWidget->setInEditMode( value );
+
+ if ( mSyncWidget )
+ mSyncWidget->setInEditMode( value );
+
}
void ConfigDialog::slotNameChanged( const QString &text)
{
enableButtonOK( !text.isEmpty() );
}
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 );
+ }
}
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 );
+ }
}
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;
}
mResource->setResourceName( mName->text() );
- mResource->setReadOnly( mReadOnly->isChecked() );
+ if (!mResource->isSyncable())
+ mResource->setReadOnly( mReadOnly->isChecked() );
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 );
+ }
+
+
KDialog::accept();
}
//US #include "configdialog.moc"
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
@@ -10,54 +10,56 @@
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KRESOURCES_CONFIGDIALOG_H
#define KRESOURCES_CONFIGDIALOG_H
#include <kdialogbase.h>
class KLineEdit;
class QCheckBox;
class KButtonBox;
namespace KRES {
class Resource;
class ConfigWidget;
+ class SyncWidget;
class ConfigDialog : public KDialogBase
{
Q_OBJECT
public:
// Resource=0: create new resource
ConfigDialog( QWidget *parent, const QString& resourceFamily,
Resource* resource, const char *name = 0);
void setInEditMode( bool value );
protected slots:
void accept();
void setReadOnly( bool value );
void setPersistentReadOnly( bool value );
void slotNameChanged( const QString &text);
private:
ConfigWidget *mConfigWidget;
+ SyncWidget *mSyncWidget;
Resource* mResource;
KLineEdit *mName;
QCheckBox *mReadOnly;
//US add a persistent readonly flag. We need that for opie and qtopia addressbooks.
- bool mPersistentReadOnly;
+ bool mPersistentReadOnly;
};
}
#endif
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
@@ -1,76 +1,86 @@
/*
This file is part of libkresources.
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
+/*
+Enhanced Version of the file for platform independent KDE tools.
+Copyright (c) 2004 Ulf Schenk
+
+$Id$
+*/
+
#include <qgroupbox.h>
#include <qinputdialog.h>
#include <qlabel.h>
#include <qlayout.h>
#include <kapplication.h>
#include <kcombobox.h>
#include <kdebug.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <ksimpleconfig.h>
#include <kstandarddirs.h>
#include <kurlrequester.h>
#include <klistview.h>
#include <kbuttonbox.h>
//US #include <ktrader.h>
#include "resource.h"
#include "configdialog.h"
#include "configpage.h"
//US
#include <qpushbutton.h>
#include <qfile.h>
#include <kglobal.h>
using namespace KRES;
+const QString ConfigPage::syncfamily = "syncprofiles";
+
+
class ConfigViewItem : public QCheckListItem
{
public:
ConfigViewItem( QListView *parent, Resource* resource ) :
QCheckListItem( parent, resource->resourceName(), CheckBox ),
mResource( resource ),
mIsStandard( false )
{
setText( 1, mResource->type() );
setOn( mResource->isActive() );
}
void setStandard( bool value )
{
setText( 2, ( value ? i18n( "Yes" ) : QString::null ) );
mIsStandard = value;
}
bool standard() const { return mIsStandard; }
bool readOnly() const { return mResource->readOnly(); }
Resource *resource() { return mResource; }
private:
@@ -143,55 +153,57 @@ ConfigPage::~ConfigPage()
(*it).mManager->removeListener( this );
delete (*it).mManager;
delete (*it).mConfig;
}
mConfig->writeEntry( "CurrentFamily", mFamilyCombo->currentItem() );
delete mConfig;
mConfig = 0;
}
void ConfigPage::load()
{
kdDebug(5650) << "ConfigPage::load()" << endl;
mListView->clear();
//US we remove the dynamic pluginloader, and set the one family we need (contact) manually.
//US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" );
//US KTrader::OfferList::ConstIterator it;
//US for ( it = plugins.begin(); it != plugins.end(); ++it ) {
//US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" );
//US QString family = tmp.toString();
QStringList families;
- families << "contact" << "sync-contacts";
+ families << "contact" << syncfamily;
+
+
for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it )
- {
+ {
QString family = (*it);
if ( !family.isEmpty() ) {
if ( !mFamilyMap.contains( family ) ) {
- mCurrentManager = new Manager<Resource>( family );
+ mCurrentManager = new Manager<Resource>( family, (family == syncfamily) );
if ( mCurrentManager ) {
mFamilyMap.append( family );
mCurrentManager->addListener( this );
ResourcePageInfo info;
info.mManager = mCurrentManager;
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 {
QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) );
info.mConfig = new KConfig( configFile );
}
info.mManager->readConfig( info.mConfig );
mInfoMap.append( info );
}
}
}
}
mCurrentManager = 0;
@@ -207,106 +219,119 @@ void ConfigPage::save()
{
saveResourceSettings();
QValueList<ResourcePageInfo>::Iterator it;
for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it )
(*it).mManager->writeConfig( (*it).mConfig );
emit changed( false );
}
void ConfigPage::defaults()
{
}
void ConfigPage::slotFamilyChanged( int pos )
{
if ( pos < 0 || pos >= (int)mFamilyMap.count() )
return;
saveResourceSettings();
mFamily = mFamilyMap[ pos ];
//US qDebug("ConfigPage::slotFamilyChanged 4 family=%s", mFamily.latin1());
-
+
mCurrentManager = mInfoMap[ pos ].mManager;
mCurrentConfig = mInfoMap[ pos ].mConfig;
if ( !mCurrentManager )
kdDebug(5650) << "ERROR: cannot create ResourceManager<Resource>( mFamily )" << endl;
mListView->clear();
if ( mCurrentManager->isEmpty() ) {
//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;
for ( it = mCurrentManager->begin(); it != mCurrentManager->end(); ++it ) {
ConfigViewItem *item = new ConfigViewItem( mListView, *it );
if ( *it == standardResource )
item->setStandard( true );
}
-
+
if ( mListView->childCount() == 0 ) {
//US qDebug("ConfigPage::slotFamilyChanged 4.5 ");
defaults();
emit changed( true );
mCurrentManager->writeConfig( mCurrentConfig );
} else {
//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" );
-
+
}
emit changed( false );
}
}
void ConfigPage::slotAdd()
{
if ( !mCurrentManager )
return;
QStringList types = mCurrentManager->resourceTypeNames();
QStringList descs = mCurrentManager->resourceTypeDescriptions();
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 )
return;
QString type = types[ descs.findIndex( desc ) ];
// Create new resource
Resource *resource = mCurrentManager->createResource( type );
if ( !resource ) {
KMessageBox::error( this, i18n("Unable to create resource of type '%1'.")
.arg( type ) );
return;
}
resource->setResourceName( type + "-resource" );
ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" );
if ( dlg.exec() ) {
mCurrentManager->add( resource );
ConfigViewItem *item = new ConfigViewItem( mListView, resource );
mLastItem = item;
@@ -359,73 +384,73 @@ void ConfigPage::slotRemove()
delete item;
emit changed( true );
}
void ConfigPage::slotEdit()
{
if ( !mCurrentManager )
return;
QListViewItem *item = mListView->currentItem();
ConfigViewItem *configItem = static_cast<ConfigViewItem*>( item );
if ( !configItem )
return;
Resource *resource = configItem->resource();
ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" );
if ( dlg.exec() ) {
configItem->setText( 0, resource->resourceName() );
configItem->setText( 1, resource->type() );
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 );
}
mCurrentManager->resourceChanged( resource );
emit changed( true );
}
}
void ConfigPage::slotStandard()
{
if ( !mCurrentManager )
return;
ConfigViewItem *item = static_cast<ConfigViewItem*>( mListView->currentItem() );
if ( !item )
return;
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;
}
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;
}
QListViewItem *it = mListView->firstChild();
while ( it != 0 ) {
ConfigViewItem *configItem = static_cast<ConfigViewItem*>( it );
if ( configItem->standard() )
configItem->setStandard( false );
it = it->itemBelow();
}
item->setStandard( true );
mCurrentManager->setStandardResource( item->resource() );
emit changed( true );
}
void ConfigPage::slotSelectionChanged()
{
bool state = ( mListView->currentItem() != 0 );
mRemoveButton->setEnabled( state );
mEditButton->setEnabled( state );
mStandardButton->setEnabled( state );
@@ -443,68 +468,68 @@ void ConfigPage::resourceAdded( Resource* resource )
mLastItem = item;
emit changed( true );
}
void ConfigPage::resourceModified( Resource* resource )
{
qDebug("ConfigPage::resourceModified : %s", resource->resourceName().latin1());
kdDebug(5650) << "ConfigPage::resourceModified( " << resource->resourceName() << " )" << endl;
}
void ConfigPage::resourceDeleted( Resource* resource )
{
qDebug("ConfigPage::resourceDeleted : %s", resource->resourceName().latin1());
kdDebug(5650) << "ConfigPage::resourceDeleted( " << resource->resourceName() << " )" << endl;
}
void ConfigPage::slotItemClicked( QListViewItem *item )
{
ConfigViewItem *configItem = static_cast<ConfigViewItem *>( item );
if ( !configItem ) return;
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 );
return;
}
if ( configItem->isOn() != configItem->resource()->isActive() ) {
emit changed( true );
}
}
void ConfigPage::saveResourceSettings()
{
qDebug("ConfigPage::saveResourceSettings() begin");
if ( mCurrentManager ) {
-
+
QListViewItem *item = mListView->firstChild();
while ( item ) {
ConfigViewItem *configItem = static_cast<ConfigViewItem*>( item );
// check if standard resource
if ( configItem->standard() && !configItem->readOnly() &&
configItem->isOn() ) {
-
+
mCurrentManager->setStandardResource( configItem->resource() );
}
-
+
// check if active or passive resource
configItem->resource()->setActive( configItem->isOn() );
item = item->nextSibling();
}
mCurrentManager->writeConfig( mCurrentConfig );
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");
-
+
}
//US #include "configpage.moc"
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
@@ -75,29 +75,30 @@ class ConfigPage : public QWidget, public ManagerListener<Resource>
protected slots:
void slotItemClicked( QListViewItem * );
signals:
void changed( bool );
private:
void saveResourceSettings();
Manager<Resource>* mCurrentManager;
KConfig* mCurrentConfig;
KConfig* mConfig;
QString mFamily;
QStringList mFamilyMap;
QValueList<ResourcePageInfo> mInfoMap;
KComboBox* mFamilyCombo;
KListView* mListView;
QPushButton* mAddButton;
QPushButton* mRemoveButton;
QPushButton* mEditButton;
QPushButton* mStandardButton;
QListViewItem* mLastItem;
+ static const QString syncfamily;
};
}
#endif
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
@@ -18,69 +18,69 @@
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <kdebug.h>
#include <klocale.h>
#include <ksimpleconfig.h>
#include <kstandarddirs.h>
#include <kstaticdeleter.h>
//#ifndef DESKTOP_VERSION
#include <klibloader.h>
//#endif
#include <qfile.h>
#include "resource.h"
#include "factory.h"
using namespace KRES;
QDict<Factory> *Factory::mSelves = 0;
static KStaticDeleter< QDict<Factory> > staticDeleter;
-Factory *Factory::self( const QString& resourceFamily )
+Factory *Factory::self( const QString& resourceFamily)
{
Factory *factory = 0;
if ( !mSelves )
{
mSelves = staticDeleter.setObject( new QDict<Factory> );
}
factory = mSelves->find( resourceFamily );
if ( !factory ) {
- factory = new Factory( resourceFamily );
+ factory = new Factory( resourceFamily);
mSelves->insert( resourceFamily, factory );
}
return factory;
}
-Factory::Factory( const QString& resourceFamily ) :
+Factory::Factory( const QString& resourceFamily) :
mResourceFamily( resourceFamily )
{
//US so far we have three types available for resourceFamily "contact"
// and that are "file", "dir", "ldap"
/*US
KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" )
.arg( resourceFamily ) );
KTrader::OfferList::ConstIterator it;
for ( it = plugins.begin(); it != plugins.end(); ++it ) {
QVariant type = (*it)->property( "X-KDE-ResourceType" );
if ( !type.toString().isEmpty() )
mTypeMap.insert( type.toString(), *it );
}
*/
//US new
PluginInfo* info = new PluginInfo;
info->library = "microkabc_file";
info->nameLabel = i18n( "file" );
info->descriptionLabel = i18n( "Choose one file" );
mTypeMap.insert( "file", info );
info = new PluginInfo;
@@ -166,90 +166,124 @@ ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
if ( !factory ) {
qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1());
kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl;
return 0;
}
PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
if ( !pluginFactory ) {
qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1());
kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl;
return 0;
}
ConfigWidget *wdg = pluginFactory->configWidget( 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;
}
+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
{
if ( type.isEmpty() || !mTypeMap.contains( type ) )
return QString();
//US KService::Ptr ptr = mTypeMap[ type ];
//US return ptr->name();
PluginInfo* pi = mTypeMap[ type ];
return pi->nameLabel;
}
QString Factory::typeDescription( const QString &type ) const
{
if ( type.isEmpty() || !mTypeMap.contains( type ) )
return QString();
//US KService::Ptr ptr = mTypeMap[ type ];
//US return ptr->comment();
PluginInfo* pi = mTypeMap[ type ];
return pi->descriptionLabel;
}
-Resource *Factory::resource( const QString& type, const KConfig *config )
+Resource *Factory::resource( const QString& type, const KConfig *config, bool syncable )
{
if ( type.isEmpty() || !mTypeMap.contains( type ) )
return 0;
/*US load the lib not dynamicly. !!
KService::Ptr ptr = mTypeMap[ type ];
KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
if ( !factory ) {
kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
return 0;
}
*/
PluginInfo* pi = mTypeMap[ type ];
KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
if ( !factory ) {
qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1());
kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
return 0;
}
PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
if ( !pluginFactory ) {
qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1());
kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl;
return 0;
}
- Resource *resource = pluginFactory->resource( config );
+ Resource *resource = pluginFactory->resource( config, syncable );
if ( !resource ) {
//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
return 0;
}
resource->setType( type );
return 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
@@ -13,112 +13,124 @@
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KRESOURCES_FACTORY_H
#define KRESOURCES_FACTORY_H
#include <qdict.h>
#include <qstring.h>
#include <kconfig.h>
#include "resource.h"
namespace KRES {
-//US
+//US
struct PluginInfo
{
QString library;
QString nameLabel;
QString descriptionLabel;
};
/**
* Class for loading resource plugins.
* Do not use this class directly. Use ResourceManager instead
*
* Example:
*
* <pre>
* KABC::Factory<Calendar> *factory = KABC::Factory<Calendar>::self();
*
* QStringList list = factory->resources();
* QStringList::Iterator it;
* for ( it = list.begin(); it != list.end(); ++it ) {
* Resource<Calendar> *resource = factory->resource( (*it),
* KABC::StdAddressBook::self(), 0 );
* // do something with resource
* }
* </pre>
*/
class Factory
{
public:
-
+
/**
* Returns the global resource factory.
*/
static Factory *self( const QString& resourceFamily );
~Factory();
/**
* Returns the config widget for the given resource type,
* or a null pointer if resource type doesn't exist.
*
* @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
*/
ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 );
/**
+ * 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
* if resource type doesn't exist.
*
* @param type The type of the resource, returned by @ref resources()
* @param ab The address book, the resource should belong to
* @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 );
/**
* Returns a list of all available resource types.
*/
QStringList typeNames() const;
/**
* Returns the name for a special type.
*/
QString typeName( const QString &type ) const;
/**
* Returns the description for a special type.
*/
QString typeDescription( const QString &type ) const;
protected:
- Factory( const QString& resourceFamily );
+ Factory( const QString& resourceFamily);
private:
static QDict<Factory> *mSelves;
QString mResourceFamily;
//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;
};
}
#endif
diff --git a/microkde/microkdeE.pro b/microkde/microkdeE.pro
index ec2b1f7..b664c9a 100644
--- a/microkde/microkdeE.pro
+++ b/microkde/microkdeE.pro
@@ -68,48 +68,49 @@ osmartpointer.h \
kdeui/klistview.h \
kdeui/kjanuswidget.h \
kdeui/kseparator.h \
kdeui/kmainwindow.h \
kdeui/knuminput.h \
kdeui/knumvalidator.h \
kdeui/ksqueezedtextlabel.h \
kdeui/ktoolbar.h \
kdeui/ktoolbarbutton.h \
kdeui/ktoolbarhandler.h \
kdeui/kxmlguiclient.h \
kio/job.h \
kio/kio/kdirwatch.h \
kio/kio/kdirwatch_p.h \
kio/kfile/kurlrequester.h \
kresources/resource.h \
kresources/factory.h \
kresources/managerimpl.h \
kresources/manager.h \
kresources/selectdialog.h \
kresources/configpage.h \
kresources/configwidget.h \
kresources/configdialog.h \
kresources/kcmkresources.h \
+ kresources/syncwidget.h \
kdecore/kmdcodec.h \
kdecore/kconfigbase.h \
kdecore/klocale.h \
kdecore/klibloader.h \
kdecore/kcatalogue.h \
kdecore/ksharedptr.h \
kdecore/kshell.h \
kdecore/kstandarddirs.h \
kdecore/kstringhandler.h \
kdecore/kshortcut.h \
kutils/kcmultidialog.h
SOURCES = \
KDGanttMinimizeSplitter.cpp \
kapplication.cpp \
kcalendarsystem.cpp \
kcalendarsystemgregorian.cpp \
kcolorbutton.cpp \
kcolordialog.cpp \
kconfig.cpp \
kdatetbl.cpp \
@@ -148,26 +149,27 @@ oprocess.cpp \
kdeui/kguiitem.cpp \
kdeui/kjanuswidget.cpp \
kdeui/klistbox.cpp \
kdeui/klistview.cpp \
kdeui/kmainwindow.cpp \
kdeui/knuminput.cpp \
kdeui/knumvalidator.cpp \
kdeui/kseparator.cpp \
kdeui/kstdaction.cpp \
kdeui/ksqueezedtextlabel.cpp \
kdeui/ktoolbar.cpp \
kdeui/ktoolbarbutton.cpp \
kdeui/ktoolbarhandler.cpp \
kdeui/kxmlguiclient.cpp \
kio/kfile/kurlrequester.cpp \
kio/kio/kdirwatch.cpp \
kresources/configpage.cpp \
kresources/configdialog.cpp \
kresources/configwidget.cpp \
kresources/factory.cpp \
kresources/kcmkresources.cpp \
kresources/managerimpl.cpp \
kresources/resource.cpp \
kresources/selectdialog.cpp \
+ kresources/syncwidget.cpp \
kutils/kcmultidialog.cpp