#ifndef DATABASE_H
#define DATABASE_H

#include <QObject>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QDir>
#include <QProgressDialog>

class Database : public QObject
{
    Q_OBJECT
    QSqlQuery m_markQuery;
    QSqlQuery m_unmarkQuery;
    QSqlQuery m_isMarkedQuery;

    QSqlQuery m_insertFile;
    QSqlQuery m_insertFitsHeader;
    QSqlQuery m_checkFile;
    QSqlQuery m_headerKeywords;
    QSqlQuery m_deleteFile;

    int m_progress;
public:
    explicit Database(QObject *parent = 0);
    bool init();
    bool mark(const QString &filename);
    bool unmark(const QString &filename);
    bool isMarked(const QString &filename);
    QStringList getMarkedFiles();

    void indexDir(const QDir &dir, QProgressDialog *progress);
    QStringList getFitsKeywords();
protected:
    bool indexDir2(const QDir &dir, QProgressDialog *progress);
    bool checkError(QSqlQuery &query);
};

#endif // DATABASE_H
