kresources Library API Documentation

resource.h

00001 /* 00002 This file is part of libkresources 00003 00004 Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org> 00005 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00020 Boston, MA 02111-1307, USA. 00021 */ 00022 #ifndef KRESOURCES_RESOURCE_H 00023 #define KRESOURCES_RESOURCE_H 00024 00025 #include <qmutex.h> 00026 #include <qvaluelist.h> 00027 #include <qwidget.h> 00028 00029 #include <klibloader.h> 00030 00031 class KConfig; 00032 00033 namespace KRES { 00034 00035 class ConfigWidget; 00036 00255 class Resource : public QObject 00256 { 00257 friend class Factory; 00258 friend class ManagerImpl; 00259 00260 Q_OBJECT 00261 public: 00262 typedef QValueList<Resource *> List; 00263 00269 Resource( const KConfig *config ); 00270 00274 virtual ~Resource(); 00275 00282 virtual void writeConfig( KConfig *config ); 00283 00293 bool open(); 00294 00301 void close(); 00302 00306 bool isOpen() const; 00307 00314 QString identifier() const; 00315 00319 QString type() const; 00320 00325 virtual void setReadOnly( bool value ); 00326 00330 virtual bool readOnly() const; 00331 00336 virtual void setResourceName( const QString &name ); 00337 00341 virtual QString resourceName() const; 00342 00346 void setActive( bool active ); 00347 00351 bool isActive() const; 00352 00356 virtual void dump() const; 00357 00358 protected: 00368 virtual bool doOpen() { return true; } 00369 00374 virtual void doClose() {} 00375 00376 void setIdentifier( const QString &identifier ); 00377 void setType( const QString &type ); 00378 00379 private: 00380 class ResourcePrivate; 00381 ResourcePrivate *d; 00382 }; 00383 00384 class PluginFactoryBase : public KLibFactory 00385 { 00386 public: 00387 virtual Resource *resource( const KConfig *config ) = 0; 00388 00389 virtual ConfigWidget *configWidget( QWidget *parent ) = 0; 00390 00391 protected: 00392 virtual QObject* createObject( QObject *, const char *, const char *, 00393 const QStringList & ) 00394 { 00395 return 0; 00396 } 00397 }; 00398 00399 template<class TR,class TC> 00400 class PluginFactory : public PluginFactoryBase 00401 { 00402 public: 00403 Resource *resource( const KConfig *config ) 00404 { 00405 return new TR( config ); 00406 } 00407 00408 ConfigWidget *configWidget( QWidget *parent ) 00409 { 00410 return new TC( parent ); 00411 } 00412 }; 00413 00414 } 00415 00416 #endif
KDE Logo
This file is part of the documentation for kresources Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Aug 30 22:55:16 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003