- Core library header files added to core.h file.

- Fixed windows build.
- Added AccommodationService class.
This commit is contained in:
2015-10-30 13:57:13 +01:00
parent 53d56f2e13
commit 096605a39e
18 changed files with 94 additions and 41 deletions
+4 -5
View File
@@ -2,11 +2,10 @@
#include <QApplication>
#include <QPluginLoader>
#include "context.h"
#include "iplugin.h"
#include <odb/sqlite/database.hxx>
#include "core.h"
Context &Context::instance()
{
static Context ctx;
@@ -22,14 +21,14 @@ void Context::loadPlugins()
{
QDir pluginsDir(qApp->applicationDirPath() + "/../plugins");
foreach (QString fileName, pluginsDir.entryList(QStringList() << "*.so")) {
foreach (QString fileName, pluginsDir.entryList(QStringList() << "*.so" << "*.dll")) {
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
QObject *p = pluginLoader.instance();
if (p != NULL) {
IPlugin *plugin = qobject_cast<IPlugin*>(p);
if (plugin != NULL) {
plugin->init();
plugin->init(pluginLoader.metaData());
m_plugins.append(plugin);
}
}
+4 -2
View File
@@ -2,18 +2,20 @@
#define CONTEXT_H
#include <QList>
#include "core_global.h"
#include <odb/database.hxx>
class IPlugin;
class Context
class CORESHARED_EXPORT Context
{
public:
static Context &instance();
QList<IPlugin*> plugins();
void loadPlugins();
void openDb(const QString &path);
odb::database *db();
odb::database *db() { return m_db; }
private:
Context();
-6
View File
@@ -1,6 +0,0 @@
#include "core.h"
Core::Core()
{
}
+2 -8
View File
@@ -1,13 +1,7 @@
#ifndef CORE_H
#define CORE_H
#include "core_global.h"
class CORESHARED_EXPORT Core
{
public:
Core();
};
#include "context.h"
#include "iplugin.h"
#endif // CORE_H
+1 -1
View File
@@ -11,7 +11,7 @@ TEMPLATE = lib
DEFINES += CORE_LIBRARY
SOURCES += core.cpp \
SOURCES += \
data/user.cpp \
context.cpp
+3 -2
View File
@@ -4,6 +4,7 @@
#include <QString>
#include <QWidget>
#include <QtPlugin>
#include <QJsonObject>
#include "service.h"
@@ -18,13 +19,13 @@ public:
virtual ~IPlugin() { }
virtual QString pluginName() = 0;
virtual QString pluginId() = 0;
virtual void init() = 0;
virtual void init(const QJsonObject &metaData) = 0;
virtual QWidget *ui() {
return m_ui;
}
template<class T>
Service<T> *service() {
(Service<T>*)m_service;
return (Service<T>*)m_service;
}
protected:
+3 -1
View File
@@ -9,6 +9,8 @@
#include <odb/database.hxx>
#include <odb/result.hxx>
#include "core_global.h"
template<class T>
class Service
{
@@ -22,7 +24,7 @@ public:
QList<QSharedPointer<T> > ret;
for (typename odb::result<T>::iterator it = res.begin(); it != res.end(); it++) {
QSharedPointer<T> entity = db->template load<T>(((T*)*it)->id());
QSharedPointer<T> entity = db->template load<T>(((T)*it).getId());
ret.append(entity);
}