aboutsummaryrefslogtreecommitdiff
path: root/lib/bookmarks/bookmarkmodel.h
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-09-24 14:55:35 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-09-24 14:55:35 +0200
commit579c713959c150a276f42b3f69ccfb89d9e6eebb (patch)
tree7c4f2082e2ff5dcdee7fcfe7887e7bbc82ec8bf6 /lib/bookmarks/bookmarkmodel.h
parentAdd bookmark auto-save (5min) (diff)
downloadsmolbote-579c713959c150a276f42b3f69ccfb89d9e6eebb.tar.xz
Bookmarks: add BookmarkItem and BookmarkModel
- read-only xbel - only enabled in debug build
Diffstat (limited to 'lib/bookmarks/bookmarkmodel.h')
-rw-r--r--lib/bookmarks/bookmarkmodel.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/bookmarks/bookmarkmodel.h b/lib/bookmarks/bookmarkmodel.h
new file mode 100644
index 0000000..90fdb2a
--- /dev/null
+++ b/lib/bookmarks/bookmarkmodel.h
@@ -0,0 +1,51 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: https://neueland.iserlohn-fortress.net/smolbote.hg
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#ifndef SMOLBOTE_BOOKMARKMODEL_H
+#define SMOLBOTE_BOOKMARKMODEL_H
+
+#include <QAbstractItemModel>
+#include "bookmarkitem.h"
+
+class BookmarkModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+public:
+ explicit BookmarkModel(QObject *parent = nullptr);
+ ~BookmarkModel() override;
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+ QVariant data(const QModelIndex &index, int column, int role) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role) override;
+ bool setData(const QModelIndex &index, const QVariant &value, BookmarkItem::Fields column, int role);
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
+
+ bool isItemExpanded(const QModelIndex &index) const;
+
+ int rowCount(const QModelIndex &index) const override;
+ bool insertRows(int position, int rows, const QModelIndex &parent) override;
+ bool removeRows(int position, int rows, const QModelIndex &parent) override;
+ bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
+ int columnCount(const QModelIndex &index) const override;
+ Qt::DropActions supportedDropActions() const override;
+
+ QModelIndex index(int row, int column, const QModelIndex &parent) const override;
+ QModelIndex parent(const QModelIndex &index) const override;
+
+ BookmarkItem *root() {
+ return rootItem;
+ }
+
+private:
+ BookmarkItem *getItem(const QModelIndex &index) const;
+ BookmarkItem *rootItem;
+};
+
+#endif //SMOLBOTE_BOOKMARKMODEL_H