1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-04-20 11:28:40 +02:00

59 lines
1.2 KiB
C
Raw Normal View History

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);
BaseModel* atIndex(int 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
int baseModelCount() const;
BaseModel* cacheGet(int index) const;
void cacheSet(int index, BaseModel *baseModel) const;
bool cacheIsset(int index) const;
void cacheClear() const;
int cacheSize() const;
2016-12-10 22:39:53 +00:00
private:
QList<Folder> folders_;
2016-12-31 10:48:18 +01:00
QString orderBy_;
mutable std::vector<std::unique_ptr<Folder>> cache_;
2017-01-01 11:33:14 +01:00
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);
bool setTitle(int index, const QVariant &value, int role = Qt::EditRole);
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