#ifndef MAPPLICATION_H
#define MAPPLICATION_H

#include <QApplication>
#include <QtSql>

class MApplication;
class QString;
class QSettings;
class DatabaseManager;
class MainWindow;

#if defined(qApp)
#undef qApp
#endif
#if defined(dApp)
#undef dApp
#endif
#define dApp (static_cast<MApplication *>(QCoreApplication::instance()))

class MApplication : public QApplication
{
public:
    MApplication(int &argc, char** argv);
    ~MApplication();

    QString dataFolder();
    QString configFolder();
    QSqlDatabase EnterpriseList();
    QSqlDatabase Enterprise();
    void listCompanies();
    bool openCompany(QString ID);
    bool closeCompany();

    void setMainWindow(MainWindow *val);
    MainWindow *mainWindow();

private:
    MainWindow *mwindow;
    QString mDataFolder;
    QString mConfigFolder;

    QSettings *mSettings;
    DatabaseManager *dbManager;

    QSqlDatabase EnterpriseListDB;
    QSqlDatabase EnterpriseDB;
    void initDB();
};

#endif // MAPPLICATION_H
