#include <klflib.h>
Public Types | |
enum | SchemeFunctions { FuncOpen = 0x01, FuncCreate = 0x02, FuncSaveTo = 0x04 } |
typedef QMap< QString, QVariant > | Parameters |
Public Member Functions | |
KLFLibEngineFactory (QObject *parent=NULL) | |
virtual | ~KLFLibEngineFactory () |
virtual QStringList | supportedTypes () const =0 |
A list of supported URL schemes this factory can open. More... | |
virtual uint | schemeFunctions (const QString &scheme) const |
What this factory is capable of doing. More... | |
virtual QString | schemeTitle (const QString &scheme) const =0 |
virtual QString | correspondingWidgetType (const QString &scheme) const =0 |
virtual KLFLibResourceEngine * | openResource (const QUrl &location, QObject *parent=NULL)=0 |
virtual KLFLibResourceEngine * | createResource (const QString &scheme, const Parameters ¶meters, QObject *parent=NULL) |
Create a new resource of given type and parameters. More... | |
virtual bool | saveResourceTo (KLFLibResourceEngine *resource, const QUrl &newLocation) |
Save the given resource to a new location. More... | |
![]() | |
QObject (QObject *parent=0) | |
blockSignals (bool block) | |
childEvent (QChildEvent *event) | |
children () | |
connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type=Qt::AutoCompatConnection) | |
connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type=Qt::AutoCompatConnection) | |
connectNotify (const char *signal) | |
customEvent (QEvent *event) | |
deleteLater () | |
destroyed (QObject *obj=0) | |
disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) | |
disconnect (const char *signal=0, const QObject *receiver=0, const char *method=0) | |
disconnect (const QObject *receiver, const char *method=0) | |
disconnectNotify (const char *signal) | |
dumpObjectInfo () | |
dumpObjectTree () | |
dynamicPropertyNames () | |
event (QEvent *e) | |
eventFilter (QObject *watched, QEvent *event) | |
findChild (const QString &name=QString() | |
findChildren (const QString &name=QString() | |
findChildren (const QRegExp ®Exp) | |
inherits (const char *className) | |
installEventFilter (QObject *filterObj) | |
isWidgetType () | |
killTimer (int id) | |
metaObject () | |
moveToThread (QThread *targetThread) | |
parent () | |
property (const char *name) | |
receivers (const char *signal) | |
removeEventFilter (QObject *obj) | |
sender () | |
setParent (QObject *parent) | |
setProperty (const char *name, const QVariant &value) | |
signalsBlocked () | |
startTimer (int interval) | |
thread () | |
timerEvent (QTimerEvent *event) | |
tr (const char *sourceText, const char *comment=0, int n=-1) | |
trUtf8 (const char *sourceText, const char *comment=0, int n=-1) | |
staticMetaObject | |
QObject (QObject *parent, const char *name) | |
checkConnectArgs (const char *signal, const QObject *object, const char *method) | |
child (const char *objName, const char *inheritsClass=0, bool recursiveSearch=true) | |
className () | |
insertChild (QObject *object) | |
isA (const char *className) | |
name () | |
name (const char *defaultName) | |
normalizeSignalSlot (const char *signalSlot) | |
removeChild (QObject *object) | |
setName (const char *name) | |
![]() | |
KLFFactoryBase (KLFFactoryManager *factoryManager) | |
virtual | ~KLFFactoryBase () |
Static Public Member Functions | |
static KLFLibEngineFactory * | findFactoryFor (const QUrl &url) |
static KLFLibEngineFactory * | findFactoryFor (const QString &urlScheme) |
static QStringList | allSupportedSchemes () |
static KLFLibResourceEngine * | openURL (const QUrl &location, QObject *parent=NULL) |
static QStringList | listSubResources (const QUrl &url) |
static QMap< QString, QString > | listSubResourcesWithTitles (const QUrl &url) |
An abstract factory class for opening resources identified by their URL, and creating objects of the currect subclass of KLFLibResourceEngine.
See also KLFLibResourceEngine, KLFLibDBEngine, KLFLibLegacyEngine. More about factory common functions in KLFFactoryManager documentation.
KLFLibEngineFactory::KLFLibEngineFactory | ( | QObject * | parent = NULL | ) |
Constructs an engine factory and automatically regisers it.
Definition at line 1150 of file klflib.cpp.
|
virtual |
Destroys this engine factory and unregisters it.
Definition at line 1154 of file klflib.cpp.
|
static |
Returns a concatenated list of all schemes that all registered factories support
Definition at line 1173 of file klflib.cpp.
References KLFFactoryManager::allSupportedTypes().
|
pure virtual |
Returns the widget type that should be used to present to user to "open" or "create" or "save" a resource of the given scheme
.
For example, both "klf+sqlite"
and "klf+legacy"
schemes could return a "LocalFile" widget that prompts to open/create/save-as a file.
Implemented in KLFLibDBEngineFactory, and KLFLibLegacyEngineFactory.
Referenced by KLFLibOpenResourceDlg::KLFLibOpenResourceDlg(), and KLFLibDBEngineFactory::~KLFLibDBEngineFactory().
|
virtual |
Create a new resource of given type and parameters.
Create the new resource, with the given settings. This function opens the resource and returns the KLFLibResourceEngine object, which is instantiated as child of parent
.
The parameters' structure are defined for each widget type. That is, if the correspondingWidgetType() for a given scheme is eg. "LocalFile"
, then the parameters are defined by whatever the "LocalFile"
widget sets. For example "LocalFile"
documents its parameters in KLFLibBasicWidgetFactory::retrieveCreateParametersFromWidget(), eg. parameter "Filename"
contains a QString with the entered local file name.
Additional parameters may also be set by KLFLibCreateResourceDlg itself (eg. default sub-resource name/title, .........TODO............)
The default implementation of this function does nothing and returns NULL
. To enable creating resources, reimplement schemeFunctions() to return also FuncCreate and reimplement this function.
Reimplemented in KLFLibDBEngineFactory, and KLFLibLegacyEngineFactory.
Definition at line 1178 of file klflib.cpp.
Referenced by KLFLibCreateResourceDlg::createResource(), KLFMainWin::loadLibrary(), KLFLibExportDialog::showExportDialogCreateResource(), KLFLibBrowser::slotExportSelection(), and KLFLibDBEngineFactory::~KLFLibDBEngineFactory().
|
static |
Finds the last registered factory that should be able to open URL url
(determined by the URL's scheme) and returns a pointer to that factory.
This function is provided for convenience; it is equivalent to
Definition at line 1163 of file klflib.cpp.
References QUrl::scheme().
Referenced by KLFLibCreateResourceDlg::createResource(), KLFLibOpenResourceDlg::KLFLibOpenResourceDlg(), KLFMainWin::loadLibrary(), KLFLibBrowser::openResource(), openURL(), KLFLibExportDialog::showExportDialogCreateResource(), and KLFLibBrowser::slotExportSelection().
|
static |
Finds the last registered factory that should be able to open URLs with scheme urlScheme
and returns a pointer to that factory.
Definition at line 1168 of file klflib.cpp.
References KLFFactoryManager::findFactoryFor().
|
static |
Opens resource designated by url
, and then lists the subresources. An empty list is returned if the resource cannot be opened, or if the resource does not support sub-resources.
The resource is immedately closed after reading the list of sub-resources.
This function:
Definition at line 1231 of file klflib.cpp.
References listSubResourcesWithTitles().
Referenced by KLFMainWin::openLibFile(), and KLFLibBrowser::slotOpenAll().
Opens resource designated by url
, and then lists the subresources with as key the resource name and as value the sub-resource title (if sub-resource properties are supported, or an empty string if not). An empty map is returned if the resource cannot be opened, or if the resource does not support sub-resources.
This function works in a very similar way to listSubResources().
The resource is immedately closed after reading the list of sub-resources.
Definition at line 1202 of file klflib.cpp.
References QUrl::addQueryItem(), KLFLibResourceEngine::FeatureSubResourceProps, KLFLibResourceEngine::FeatureSubResources, openURL(), QMap::size(), KLFLibResourceEngine::subResourceList(), KLFLibResourceEngine::subResourceProperty(), KLFLibResourceEngine::SubResPropTitle, KLFLibResourceEngine::supportedFeatureFlags(), and QVariant::toString().
Referenced by listSubResources(), and KLFLibOpenResourceDlg::updateReadyToOpen().
|
pure virtual |
Instantiate a library engine that opens resource stored at location
. The resource engine should be constructed as a child of object parent
.
Implemented in KLFLibDBEngineFactory, and KLFLibLegacyEngineFactory.
Referenced by KLFMainWin::loadLibrary(), KLFLibBrowser::openResource(), openURL(), and KLFLibDBEngineFactory::~KLFLibDBEngineFactory().
|
static |
Finds the good factory for URL location
, and opens the resource using that factory. The created resource will be a child of parent
.
Definition at line 1191 of file klflib.cpp.
References findFactoryFor(), openResource(), and QUrl::scheme().
Referenced by listSubResourcesWithTitles(), and KLFMainWin::loadLibrary().
|
virtual |
Save the given resource to a new location.
Save the resource resource
to the new location given by newLocation
.
The caller should garantee that resource
is a resource engine of a scheme supported by this factory.
resource
will still continue pointing to the previous location.For example, an "klf+sqlite"
Sqlite database may choose to simply copy the database file to the new location. This example is implemented in KLFLibDBEngine::saveTo().
The default implementation of this function does nothing and returns false. To enable creating resources, reimplement schemeFunctions() to return also FuncCreate and reimplement this function.
Definition at line 1185 of file klflib.cpp.
|
virtual |
What this factory is capable of doing.
Informs the caller of what functionality this factory provides for the given scheme
.
The FuncOpen
must be provided in every factory.
The default implementation returns FuncOpen
.
Reimplemented in KLFLibDBEngineFactory, and KLFLibLegacyEngineFactory.
Definition at line 1158 of file klflib.cpp.
References FuncOpen.
Referenced by KLFLibDBEngineFactory::~KLFLibDBEngineFactory().
Should return a human (short) description of the given scheme (which is one returned by supportedTypes())
Implemented in KLFLibDBEngineFactory, and KLFLibLegacyEngineFactory.
Referenced by KLFLibBrowser::slotExportSelection(), and KLFLibDBEngineFactory::~KLFLibDBEngineFactory().
|
pure virtual |
A list of supported URL schemes this factory can open.
If two factories provide a common scheme name, only the last instantiated is used; the consequent ones will be ignored for that scheme name. See KLFFactoryBase::supportedTypes() and KLFFactoryManager::findFactoryFor()
Implements KLFFactoryBase.
Implemented in KLFLibDBEngineFactory, and KLFLibLegacyEngineFactory.
Referenced by KLFLibDBEngineFactory::~KLFLibDBEngineFactory().