author | zautrix <zautrix> | 2004-10-13 14:23:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-13 14:23:28 (UTC) |
commit | 2cfda2af7cba3c9aff2d7722421b5d33b7f56cb6 (patch) (side-by-side diff) | |
tree | f1e664ddf31aae347b1a119c9111cbd1c931bf89 /microkde/kresources/resource.h | |
parent | d41893fb0a49fbb080326a4c1fd98e1a032a182a (diff) | |
download | kdepimpi-2cfda2af7cba3c9aff2d7722421b5d33b7f56cb6.zip kdepimpi-2cfda2af7cba3c9aff2d7722421b5d33b7f56cb6.tar.gz kdepimpi-2cfda2af7cba3c9aff2d7722421b5d33b7f56cb6.tar.bz2 |
more sync fixes
Diffstat (limited to 'microkde/kresources/resource.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kresources/resource.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/microkde/kresources/resource.h b/microkde/kresources/resource.h index 580b5d1..70b5613 100644 --- a/microkde/kresources/resource.h +++ b/microkde/kresources/resource.h @@ -121,296 +121,298 @@ void ResourceExample::writeConfig( KConfig *config ) } extern "C" { KRES::ResourceExample *config_widget( QWidget *parent ) { return new ResourceExampleConfig( parent, "Configure Example Resource" ); } KRES::Resource *resource( const KConfig *config ) { return new ResourceExample( config ); } } </pre> * <B>resourceexampleconfig.h</B>: <pre> #include <klineedit.h> #include <kresources/resourceconfigwidget.h> #include "resourceexample.h" class ResourceExampleConfig : public KRES::ResourceConfigWidget { Q_OBJECT public: ResourceExampleConfig( QWidget* parent = 0, const char* name = 0 ); public slots: virtual void loadSettings( KRES::Resource *resource); virtual void saveSettings( KRES::Resource *resource ); private: KLineEdit* mLocationEdit; KLineEdit* mPasswordEdit; }; </pre> * <B>resourceexampleconfig.cpp</B>: <pre> #include <qlayout.h> #include <qlabel.h" #include <kresources/resourceconfigwidget.h> #include "resourceexample.h" #include "resourceexampleconfig.h" ResourceExampleConfig::ResourceExampleConfig( QWidget* parent, const char* name ) : KRES::ResourceConfigWidget( parent, name ) { resize( 245, 115 ); QGridLayout *mainLayout = new QGridLayout( this, 2, 2 ); QLabel *label = new QLabel( i18n( "Location:" ), this ); mHostEdit = new KLineEdit( this ); mainLayout->addWidget( label, 1, 0 ); mainLayout->addWidget( mHostEdit, 1, 1 ); label = new QLabel( i18n( "Password:" ), this ); mPasswordEdit = new KLineEdit( this ); mPasswordEdit->setEchoMode( QLineEdit::Password ); mainLayout->addWidget( label, 2, 0 ); mainLayout->addWidget( mPasswordEdit, 2, 1 ); } void ResourceExampleConfig::loadSettings( KRES::Resource *resource ) { ResourceExample* res = dynamic_cast<ResourceExample *>( resource ); if (res) { mHostEdit->setText( res->host() ); mPasswordEdit->setText( res->password() ); } else kdDebug(5700) << "ERROR: ResourceExampleConfig::loadSettings(): no ResourceExample, cast failed" << endl; } void ResourceExampleConfig::saveSettings( KRES::Resource *resource ) { ResourceExample* res = dynamic_cast<ResourceExample *>( resource ); if (res) { res->setHost(mHostEdit->text()); res->setPassword(mPasswordEdit->text()); } else kdDebug(5700) << "ERROR: ResourceExampleConfig::saveSettings(): no ResourceExample, cast failed" << endl; } </pre> * <B>resourceexample.desktop</B>: <pre> [Desktop Entry] Type=Service [Misc] Encoding=UTF-8 Name=Example Resource [Plugin] Type=exchange X-KDE-Library=resourceexample </pre> * <B>Makefile.am</B> <pre> kde_module_LTLIBRARIES = resourceexample.la resourceexample_la_SOURCES = resourceexample.cpp resourceexampleconfig.cpp resourceexample_la_LDFLAGS= $(all_libraries) -module $(KDE_PLUGIN) resourceexample_la_LIBADD= -lkderesources linkdir= $(kde_datadir)/resources/family link_DATA= resourceexample.desktop </pre> * * */ /** * A @ref Resource is a ... * * A subclass should reimplement at least the constructor and the * @ref writeConfig method. * */ class Resource : public QObject { Q_OBJECT public: typedef QValueList<Resource *> List; /** * Constructor. Construct resource from config. * @param config Configuration to read persistence information from. * If config==0, create object using default settings. */ Resource( const KConfig* config ); /** * Destructor. */ virtual ~Resource(); /** * Write configuration information for this resource to a configuration * file. If you override this method, remember to call Resource::writeConfig * or Terrible Things(TM) will happen. * @param config Configuration to write persistence information to. */ virtual void writeConfig( KConfig* config ); /** * Open this resource, if it not already open. Increase the open * count of this object, and open the resource by calling @ref doOpen(). * This method may block while another thread is concurrently opening * or closing the resource. * * Returns true if the resource was already opened or if it was opened * successfully; returns false if the resource was not opened successfully. */ bool open(); /** * Decrease the open count of this object, and if the count reaches * zero, close this resource by calling @ref doClose(). * This method may block while another thread is concurrently closing * or opening the resource. */ void close(); /** * Returns whether the resource is open or not. */ bool isOpen() const; /** * Returns a unique identifier. The identifier is unique for this resource. * It is created when the resource is first created, and it is retained * in the resource family configuration file for this resource. * @return This resource's identifier */ QString identifier() const; /** * Returns the type of this resource. */ QString type() const; /** * Mark the resource as read-only. You can override this method, * but also remember to call Resource::setReadOnly(). */ virtual void setReadOnly( bool value ); /** * Returns, if the resource is read-only. */ virtual bool readOnly() const; + void setIncludeInSync( bool value ); + bool includeInSync() const; /** * Set the name of resource.You can override this method, * but also remember to call Resource::setResourceName(). */ virtual void setResourceName( const QString &name ); /** * Returns the name of resource. */ virtual QString resourceName() const; virtual bool isSyncable() const = 0; /** Sets, if the resource is active. */ void setActive( bool active ); /** Return true, if the resource is active. */ bool isActive() const; friend class Factory; friend class ManagerImpl; /** Print resource information as debug output. */ virtual void dump() const; protected: /** * Open this resource. When called, the resource must be in * a closed state. * * Returns true if the resource was opened successfully; * returns false if the resource was not opened successfully. * * The result of this call can be accessed later by @ref isOpen() */ virtual bool doOpen() { return true; } /** * Close this resource. Pre-condition: resource is open. * Post-condition: resource is closed. */ virtual void doClose() {} 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 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 ); } SyncWidgetContainer *syncWidgetContainer() { return new TS(); } }; } #endif |