2016-12-10 22:39:53 +00:00
|
|
|
#ifndef FOLDERMODEL_H
|
|
|
|
#define FOLDERMODEL_H
|
|
|
|
|
|
|
|
#include <stable.h>
|
|
|
|
|
2017-01-01 11:33:14 +01:00
|
|
|
#include "models/folder.h"
|
2017-01-12 21:33:56 +01:00
|
|
|
#include "models/abstractlistmodel.h"
|
2016-12-29 20:19:00 +01:00
|
|
|
#include "database.h"
|
2016-12-10 22:39:53 +00:00
|
|
|
|
|
|
|
namespace jop {
|
|
|
|
|
2017-01-12 21:33:56 +01:00
|
|
|
class FolderModel : public AbstractListModel {
|
2016-12-10 22:39:53 +00:00
|
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2017-01-12 17:59:19 +01:00
|
|
|
FolderModel();
|
2016-12-11 16:09:39 +00:00
|
|
|
|
2016-12-10 22:39:53 +00:00
|
|
|
void addFolder(Folder* folder);
|
|
|
|
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
2016-12-29 20:19:00 +01:00
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
2017-01-01 11:33:14 +01:00
|
|
|
Folder atIndex(int index) const;
|
|
|
|
Folder atIndex(const QModelIndex &index) const;
|
2016-12-29 20:19:00 +01:00
|
|
|
|
2016-12-10 22:39:53 +00:00
|
|
|
protected:
|
|
|
|
|
2017-01-12 21:33:56 +01:00
|
|
|
BaseModel baseModel() const;
|
|
|
|
int baseModelCount() const;
|
2016-12-10 22:39:53 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
QList<Folder> folders_;
|
2016-12-31 10:48:18 +01:00
|
|
|
QString orderBy_;
|
2017-01-01 11:33:14 +01:00
|
|
|
mutable QVector<Folder> cache_;
|
|
|
|
QString lastInsertId_;
|
2016-12-29 20:19:00 +01:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
2016-12-31 10:48:18 +01:00
|
|
|
void addData(const QString& title);
|
|
|
|
void deleteData(const int index);
|
2017-01-12 21:33:56 +01:00
|
|
|
bool setData(int index, const QVariant &value, int role = Qt::EditRole);
|
2017-01-02 13:17:15 +01:00
|
|
|
QString indexToId(int index) const;
|
2016-12-31 10:48:18 +01:00
|
|
|
int idToIndex(const QString& id) const;
|
2017-01-01 11:33:14 +01:00
|
|
|
QString lastInsertId() const;
|
2016-12-31 10:48:18 +01:00
|
|
|
|
2017-01-07 10:40:13 +01:00
|
|
|
void dispatcher_folderCreated(const QString& folderId);
|
|
|
|
void dispatcher_folderUpdated(const QString& folderId);
|
|
|
|
void dispatcher_folderDeleted(const QString& folderId);
|
2017-01-11 15:18:56 +01:00
|
|
|
void dispatcher_allFoldersDeleted();
|
2017-01-07 10:40:13 +01:00
|
|
|
|
2016-12-10 22:39:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FOLDERMODEL_H
|