-rw-r--r-- | microkde/kresources/manager.h | 44 | ||||
-rw-r--r-- | microkde/kresources/managerimpl.cpp | 70 | ||||
-rw-r--r-- | microkde/kresources/syncwidget.cpp | 46 | ||||
-rw-r--r-- | microkde/kresources/syncwidget.h | 62 |
4 files changed, 180 insertions, 42 deletions
diff --git a/microkde/kresources/manager.h b/microkde/kresources/manager.h index b5e97fc..7e9e19a 100644 --- a/microkde/kresources/manager.h +++ b/microkde/kresources/manager.h @@ -6,2 +6,3 @@ Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> + Copyright (c) 2004 Ulf Schenk @@ -23,2 +24,9 @@ +/* +Enhanced Version of the file for platform independent KDE tools. +Copyright (c) 2004 Ulf Schenk + +$Id$ +*/ + #ifndef KRESOURCES_MANAGER_H @@ -50,3 +58,3 @@ class ManagerListener // -// The manager should also keep track of which (or at least +// The manager should also keep track of which (or at least // how many) applications hve opened a resource, so that it @@ -73,3 +81,3 @@ class Manager : private ManagerImplListener - private: + private: Resource::List::Iterator mIt; @@ -83,3 +91,3 @@ class Manager : private ManagerImplListener } - + Iterator end() @@ -161,3 +169,8 @@ class Manager : private ManagerImplListener - Manager( const QString &family ) + /** + Return true, if the manager manages syncable resources. + */ + bool manageSyncable() { return mImpl->manageSyncable(); } + + Manager( const QString &family, bool syncable ) { @@ -166,5 +179,5 @@ class Manager : private ManagerImplListener // because of the Factory::self() pattern - mImpl = new ManagerImpl( family ); + mImpl = new ManagerImpl( family, syncable ); mImpl->setListener( this ); - + mListeners = new QPtrList<ManagerListener<T> >; @@ -173,3 +186,3 @@ class Manager : private ManagerImplListener virtual ~Manager() - { + { mImpl->setListener( 0 ); @@ -241,4 +254,4 @@ class Manager : private ManagerImplListener /** - Creates a new resource of type @param type, with default - settings. The resource is + Creates a new resource of type @param type, with default + settings. The resource is not added to the manager, the application has to do that. @@ -246,5 +259,6 @@ class Manager : private ManagerImplListener if resource type doesn't exist. - - @param type The type of the resource, one of those returned + + @param type The type of the resource, one of those returned by @ref resourceTypeNames() + * @param syncable If the resource should support syncing capabilities. */ @@ -252,3 +266,3 @@ class Manager : private ManagerImplListener { - return (T *)( mFactory->resource( type, 0 ) ); + return (T *)( mFactory->resource( type, 0, mImpl->manageSyncable() ) ); } @@ -280,4 +294,4 @@ class Manager : private ManagerImplListener void resourceChanged( T *resource ) - { - mImpl->resourceChanged( resource ); + { + mImpl->resourceChanged( resource ); } @@ -311,3 +325,3 @@ class Manager : private ManagerImplListener } - + virtual void resourceDeleted( Resource *res ) diff --git a/microkde/kresources/managerimpl.cpp b/microkde/kresources/managerimpl.cpp index 785b6b4..3655f50 100644 --- a/microkde/kresources/managerimpl.cpp +++ b/microkde/kresources/managerimpl.cpp @@ -2,3 +2,3 @@ This file is part of libkresources. - + Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> @@ -23,2 +23,9 @@ +/* +Enhanced Version of the file for platform independent KDE tools. +Copyright (c) 2004 Ulf Schenk + +$Id$ +*/ + #include <kglobal.h> @@ -36,4 +43,4 @@ using namespace KRES; -ManagerImpl::ManagerImpl( const QString &family ) - : mFamily( family ), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ), +ManagerImpl::ManagerImpl( const QString &family, bool syncable ) + : mFamily( family ), mSyncable(syncable), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ), mFactory( 0 ) @@ -42,4 +49,4 @@ ManagerImpl::ManagerImpl( const QString &family ) kdDebug(5650) << "ManagerImpl::ManagerImpl()" << endl; - - + + } @@ -54,3 +61,3 @@ ManagerImpl::~ManagerImpl() } - + delete mStdConfig; @@ -61,3 +68,3 @@ void ManagerImpl::createStandardConfig() if ( !mStdConfig ) { - QString file = locateLocal( "data", KGlobal::getAppName() + QString file = locateLocal( "data", KGlobal::getAppName() + "/kresources/" + mFamily + "rc" ); @@ -65,3 +72,3 @@ void ManagerImpl::createStandardConfig() } - + mConfig = mStdConfig; @@ -81,3 +88,3 @@ void ManagerImpl::readConfig( KConfig *cfg ) } - + mStandard = 0; @@ -94,3 +101,3 @@ void ManagerImpl::readConfig( KConfig *cfg ) } - + } @@ -99,5 +106,5 @@ void ManagerImpl::writeConfig( KConfig *cfg ) { -//USqDebug("ManagerImpl::writeConfig begin this= %ul cfg=%ul", this, cfg); - - +//USqDebug("ManagerImpl::writeConfig begin this= %ul cfg=%ul", this, cfg); + + kdDebug(5650) << "ManagerImpl::writeConfig()" << endl; @@ -109,3 +116,3 @@ void ManagerImpl::writeConfig( KConfig *cfg ) } - + QStringList activeKeys; @@ -131,3 +138,3 @@ void ManagerImpl::writeConfig( KConfig *cfg ) mConfig->writeEntry( "PassiveResourceKeys", passiveKeys ); - if ( mStandard ) + if ( mStandard ) mConfig->writeEntry( "Standard", mStandard->identifier() ); @@ -138,5 +145,5 @@ void ManagerImpl::writeConfig( KConfig *cfg ) kdDebug(5650) << "ManagerImpl::save() finished" << endl; - -//US qDebug("ManagerImpl::writeConfig end this= %ul cfg=%ul", this, cfg); - + +//US qDebug("ManagerImpl::writeConfig end this= %ul cfg=%ul", this, cfg); + } @@ -145,4 +152,4 @@ void ManagerImpl::add( Resource *resource, bool useDCOP ) { -qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource); - +qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource); + resource->setActive( true ); @@ -157,3 +164,3 @@ qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource); - qDebug("ManagerImpl::add end this= %ul resource=%ul", this, resource); + qDebug("ManagerImpl::add end this= %ul resource=%ul", this, resource); @@ -180,3 +187,3 @@ void ManagerImpl::setActive( Resource *resource, bool active ) -Resource *ManagerImpl::standardResource() +Resource *ManagerImpl::standardResource() { @@ -185,3 +192,3 @@ Resource *ManagerImpl::standardResource() -void ManagerImpl::setStandardResource( Resource *resource ) +void ManagerImpl::setStandardResource( Resource *resource ) { @@ -251,3 +258,3 @@ Resource* ManagerImpl::readResourceConfig( const QString& identifier, kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl; - + // qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1()); @@ -263,3 +270,3 @@ Resource* ManagerImpl::readResourceConfig( const QString& identifier, QString name = mConfig->readEntry( "ResourceName" ); - Resource *resource = mFactory->resource( type, mConfig ); + Resource *resource = mFactory->resource( type, mConfig, mSyncable ); if ( !resource ) { @@ -307,3 +314,3 @@ void ManagerImpl::writeResourceConfig( Resource *resource, mConfig->writeEntry( "Standard", "" ); - + if ( checkActive ) { @@ -327,3 +334,3 @@ void ManagerImpl::removeResource( Resource *resource ) if ( !mConfig ) createStandardConfig(); - + mConfig->setGroup( "General" ); @@ -358 +365,10 @@ Resource* ManagerImpl::getResource( const QString& identifier ) } + +/** + Return true, if the manager manages syncable resources. +*/ +bool ManagerImpl::manageSyncable() const +{ + return mSyncable; +} + diff --git a/microkde/kresources/syncwidget.cpp b/microkde/kresources/syncwidget.cpp new file mode 100644 index 0000000..9bb0df6 --- a/dev/null +++ b/microkde/kresources/syncwidget.cpp @@ -0,0 +1,46 @@ +/* + This file is part of libkresources. + + Copyright (c) 2004 Ulf Schenk + + 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. +*/ + +// $Id$ + +#include "syncwidget.h" + +using namespace KRES; + + +SyncWidget::SyncWidget( QWidget *parent, const char *name ) + : QWidget( parent, name ) +{ +} + +void SyncWidget::setInEditMode( bool ) +{ +} + +void SyncWidget::loadSettings( Resource * ) +{ +} + +void SyncWidget::saveSettings( Resource * ) +{ +} + + diff --git a/microkde/kresources/syncwidget.h b/microkde/kresources/syncwidget.h new file mode 100644 index 0000000..e94252c --- a/dev/null +++ b/microkde/kresources/syncwidget.h @@ -0,0 +1,62 @@ +/* + This file is part of libkresources. + Copyright (c) 2004 Ulf Schenk + + 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. +*/ + +// $Id$ + +#ifndef KRESOURCES_SYNCWIDGET_H +#define KRESOURCES_SYNCWIDGET_H + +#include <qwidget.h> + +#include <kconfig.h> + +#include "resource.h" + +namespace KRES { + +class SyncWidget : public QWidget +{ + Q_OBJECT + +public: + SyncWidget( QWidget *parent = 0, const char *name = 0 ); + + /** + Sets the widget to 'edit' mode. Reimplement this method if you are + interested in the mode change (to disable some GUI element for + example). By default the widget is in 'create new' mode. + */ + 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; +}; + +} +#endif |