summaryrefslogtreecommitdiffabout
path: root/microkde
Side-by-side diff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/configdialog.cpp78
-rw-r--r--microkde/kresources/configdialog.h4
-rw-r--r--microkde/kresources/configpage.cpp15
-rw-r--r--microkde/kresources/factory.cpp4
-rw-r--r--microkde/kresources/factory.h5
-rw-r--r--microkde/kresources/resource.h8
-rw-r--r--microkde/kresources/syncwidget.h10
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
@@ -16,62 +16,69 @@
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.
*/
#include <klocale.h>
#include <kglobal.h>
#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"
#include "configwidget.h"
#include "configdialog.h"
#include "syncwidget.h"
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 );
mName = new KLineEdit( generalGroupBox );
if (!mResource->isSyncable()) {
mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox );
mReadOnly->setChecked( mResource->readOnly() );
}
mName->setText( mResource->resourceName() );
mainLayout->addWidget( generalGroupBox );
@@ -85,67 +92,105 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
mainLayout->addStretch();
mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox );
if ( mConfigWidget ) {
connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ),
SLOT( setReadOnly( bool ) ) );
connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ),
SLOT( setPersistentReadOnly( bool ) ) );
mConfigWidget->setInEditMode( false );
mConfigWidget->loadSettings( mResource );
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() );
+
+ 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();
}
+ */
}
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 );
+ 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() );
}
void ConfigDialog::setReadOnly( bool value )
{
if (!mResource->isSyncable()) {
if (mPersistentReadOnly == false)
mReadOnly->setChecked( value );
else
mReadOnly->setChecked( true );
@@ -169,27 +214,28 @@ void ConfigDialog::accept()
{
if ( mName->text().isEmpty() ) {
KMessageBox::sorry( this, mResource->isSyncable()?i18n( "Please enter a profile name" ):i18n( "Please enter a resource name" ) );
return;
}
mResource->setResourceName( mName->text() );
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 );
- }
+ 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
@@ -38,28 +38,30 @@ 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;
+ 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;
};
}
#endif
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
@@ -192,32 +192,34 @@ void ConfigPage::load()
QString family = (*it);
if ( !family.isEmpty() ) {
if ( !mFamilyMap.contains( 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 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 );
mInfoMap.append( info );
}
}
}
}
mCurrentManager = 0;
mFamilyCombo->insertStringList( mFamilyMap );
int currentFamily = mConfig->readNumEntry( "CurrentFamily", 0 );
@@ -298,56 +300,63 @@ void ConfigPage::slotFamilyChanged( int pos )
}
void ConfigPage::slotAdd()
{
if ( !mCurrentManager )
return;
QStringList types = mCurrentManager->resourceTypeNames();
QStringList descs = mCurrentManager->resourceTypeDescriptions();
bool ok = false;
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;
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" );
+ 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 );
ConfigViewItem *item = new ConfigViewItem( mListView, resource );
mLastItem = item;
// if there are only read-only resources we'll set this resource
// as standard resource
if ( !resource->readOnly() ) {
bool onlyReadOnly = true;
QListViewItem *it = mListView->firstChild();
while ( it != 0 ) {
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
@@ -174,56 +174,56 @@ ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
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 )
+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() );
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 );
+ 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;
}
QString Factory::typeName( const QString &type ) const
{
if ( type.isEmpty() || !mTypeMap.contains( type ) )
return QString();
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
@@ -21,32 +21,35 @@
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 {
+class SyncWidgetContainer;
+class ConfigWidget;
+
//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>
@@ -79,33 +82,33 @@ 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
*/
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 );
+ 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()
* @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, bool syncable );
/**
* Returns a list of all available resource types.
*/
QStringList typeNames() const;
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
@@ -27,33 +27,33 @@
#ifdef QT_THREAD_SUPPORT
#include <qmutex.h>
#endif //QT_THREAD_SUPPORT
#include <qvaluelist.h>
#include <qwidget.h>
#include <qobject.h>
#include <klibloader.h>
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
* interface, it is in constant flux.
*
* The KDE Resource framework can be used to manage resources of
* different types, organized in families. The Resource framework
* is currently used for addressbook resources in libkabc and for
* calendar resources in libkcal.
*
* When you want to use the framework for a new family, you need to
* <ul><li>Define a name for your resource family</li>
* <li>subclass Resource and add the fields and method that are needed
@@ -365,52 +365,52 @@ class Resource : public QObject
void setIdentifier( const QString& identifier );
void setType( const QString& type );
private:
class ResourcePrivate;
ResourcePrivate *d;
};
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;
}
};
template<class TR,class TC, class TS>
class PluginFactory : public PluginFactoryBase
{
public:
Resource *resource( const KConfig *config, bool syncable )
{
return new TR( config, syncable );
}
ConfigWidget *configWidget( QWidget *parent )
{
return new TC( parent );
}
- virtual SyncWidget *syncWidget( QWidget *parent )
+ SyncWidgetContainer *syncWidgetContainer()
{
- return new TS( parent );
+ return new TS();
}
};
}
#endif
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
@@ -45,18 +45,28 @@ public:
*/
virtual void setInEditMode( bool value );
public slots:
virtual void loadSettings( Resource *resource );
virtual void saveSettings( Resource *resource );
signals:
//US void setReadOnly( bool value );
//US void setPersistentReadOnly( bool value );
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