resource.h
/*
This file is part of libkresources
Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org>
Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KRESOURCES_RESOURCE_H
#define KRESOURCES_RESOURCE_H
#include <qmutex.h>
#include <qvaluelist.h>
#include <qwidget.h>
#include <klibloader.h>
class KConfig;
namespace KRES {
class ConfigWidget;
class KRESOURCES_EXPORT Resource : public QObject
{
friend class Factory;
friend class ManagerImpl;
Q_OBJECT
public:
typedef QValueList<Resource *> List;
Resource( const KConfig *config );
virtual ~Resource();
virtual void writeConfig( KConfig *config );
bool open();
void close();
bool isOpen() const;
QString identifier() const;
QString type() const;
virtual void setReadOnly( bool value );
virtual bool readOnly() const;
virtual void setResourceName( const QString &name );
virtual QString resourceName() const;
void setActive( bool active );
bool isActive() const;
virtual void dump() const;
protected:
virtual bool doOpen() { return true; }
virtual void doClose() {}
void setIdentifier( const QString &identifier );
void setType( const QString &type );
private:
class ResourcePrivate;
ResourcePrivate *d;
};
class KRESOURCES_EXPORT PluginFactoryBase : public KLibFactory
{
public:
virtual Resource *resource( const KConfig *config ) = 0;
virtual ConfigWidget *configWidget( QWidget *parent ) = 0;
protected:
virtual QObject* createObject( QObject *parent, const char *name, const char *className,
const QStringList & args)
{
Q_UNUSED(parent);
Q_UNUSED(name);
Q_UNUSED(className);
Q_UNUSED(args);
return 0;
}
};
template<class TR,class TC>
class PluginFactory : public PluginFactoryBase
{
public:
Resource *resource( const KConfig *config )
{
return new TR( config );
}
ConfigWidget *configWidget( QWidget *parent )
{
return new TC( parent );
}
};
}
#endif
KRES::Resource
This class provides a resource which is managed in a general way.
Definition: resource.h:255
KRES::Resource::doClose
virtual void doClose()
Close this resource.
Definition: resource.h:374
KRES::Factory
Class for loading resource plugins.
Definition: factory.h:62
KRES::Resource::doOpen
virtual bool doOpen()
Open this resource.
Definition: resource.h:368

KDE Home | KDE Accessibility Home | Description of Access Keys