You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.5 KiB
C++

#ifndef CONTEXT_H
#define CONTEXT_H
#include <QList>
#include <QMap>
#include <QString>
#include <QSqlDatabase>
#include <QStringList>
#include <QSettings>
#include <QSharedPointer>
#include "define.h"
#include "core_global.h"
#include "data/core-data.h"
class IPlugin;
class CORESHARED_EXPORT Context
{
public:
~Context();
static Context &instance();
QList<IPlugin*> plugins();
IPlugin *plugin(const QString &pluginId);
void loadPlugins();
void openDb(const QString &path);
void* db() { return nullptr; }
QSettings *settings() { return m_settings; }
bool dbOpened() { return m_dbOpened; }
void destroy();
QStringList defaultPerms();
QSharedPointer<User> currentUser() const;
void setCurrentUser(const QSharedPointer<User> &currentUser);
//odb::session &session();
SeasonPtr currentSeason() const;
void setCurrentSeason(const SeasonPtr &currentSeason);
void checkNumberSeries();
private:
Context();
QList<IPlugin*> m_plugins;
QSettings *m_settings;
bool m_dbOpened;
QSharedPointer<User> m_currentUser;
SeasonPtr m_currentSeason;
QStringList m_solved;
void checkDb(const QString &path);
void checkSchema(const QSqlDatabase &db, const QMap<QString, int> &schemaMap);
void solveDep(IPlugin *plugin, const QSqlDatabase &db, const QMap<QString, int> &schemaMap);
void createSchema(IPlugin *plugin, const QSqlDatabase &db, const QMap<QString, int> &schemaMap);
void checkPermissions();
void checkSeason();
};
#endif // CONTEXT_H