summaryrefslogtreecommitdiff
path: root/src/bookmarks/bookmarkstreemodel.hpp
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2022-08-14 18:47:37 +0300
committeraqua <aqua@iserlohn-fortress.net>2022-09-14 08:51:09 +0300
commitc2d18d73b0e1a74525ec0cda36a2e2e7e5b4ff4c (patch)
treed5b9febb29ef801faa08fce4e56c4f453ddb38d0 /src/bookmarks/bookmarkstreemodel.hpp
parentAdd clazy cmake preset (diff)
downloadrekonq-c2d18d73b0e1a74525ec0cda36a2e2e7e5b4ff4c.tar.xz
Import BookmarkModel from poi
Diffstat (limited to 'src/bookmarks/bookmarkstreemodel.hpp')
-rw-r--r--src/bookmarks/bookmarkstreemodel.hpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/bookmarks/bookmarkstreemodel.hpp b/src/bookmarks/bookmarkstreemodel.hpp
new file mode 100644
index 00000000..ace596b8
--- /dev/null
+++ b/src/bookmarks/bookmarkstreemodel.hpp
@@ -0,0 +1,59 @@
+/* ============================================================
+ * rekonq
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================
+ * Description: rekonq bookmarks model
+ * ============================================================ */
+
+#pragma once
+
+#include "bookmarkstreeitem.hpp"
+#include <QAbstractItemModel>
+
+class QFile;
+class BookmarkModel : public QAbstractItemModel {
+ Q_OBJECT
+
+public:
+ enum Roles { CompletionMatchingRole = Qt::UserRole + 1 };
+
+ explicit BookmarkModel(const QString &path, QObject *parent = nullptr);
+ ~BookmarkModel() override;
+
+ void load(const QIODevice *buffer);
+
+ [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
+ [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
+ bool setData(const QModelIndex &index, const QVariant &value, int role) override;
+ [[nodiscard]] Qt::ItemFlags flags(const QModelIndex &index) const override;
+
+ [[nodiscard]] int rowCount(const QModelIndex &index) const override;
+ bool removeRows(int position, int rows, const QModelIndex &parent) override;
+ [[nodiscard]] int columnCount(const QModelIndex &) const override { return 2; }
+
+ [[nodiscard]] Qt::DropActions supportedDropActions() const override { return Qt::MoveAction; }
+ [[nodiscard]] QStringList mimeTypes() const override { return {mimeType}; }
+ [[nodiscard]] QMimeData *mimeData(const QModelIndexList &indexes) const override;
+ bool dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column,
+ const QModelIndex &parent) override;
+
+ [[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent) const override;
+ [[nodiscard]] QModelIndex parent(const QModelIndex &index) const override;
+ [[nodiscard]] QModelIndex parentFolder(const QModelIndex &index) const;
+
+ [[nodiscard]] BookmarksTreeItem *item(const QModelIndex &index) const;
+ QModelIndex appendItem(BookmarksTreeItem::Types type, BookmarksTreeItem::Attributes_t data,
+ const QModelIndex &parent);
+
+public slots:
+ void save();
+
+private:
+ const QLatin1String mimeType = QLatin1String("application/xbel");
+
+ BookmarksTreeItem *rootItem;
+ bool m_isModified = false;
+ QFile *bookmarksFile;
+};