aboutsummaryrefslogtreecommitdiff
path: root/lib/bookmarks/bookmarkitem.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/bookmarkitem.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/bookmarkitem.h')
-rw-r--r--lib/bookmarks/bookmarkitem.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/lib/bookmarks/bookmarkitem.h b/lib/bookmarks/bookmarkitem.h
new file mode 100644
index 0000000..37a9b5d
--- /dev/null
+++ b/lib/bookmarks/bookmarkitem.h
@@ -0,0 +1,68 @@
+/*
+ * 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_BOOKMARKITEM_H
+#define SMOLBOTE_BOOKMARKITEM_H
+
+#include <QIcon>
+#include <QVariant>
+#include <QVector>
+
+class BookmarkItem
+{
+public:
+ enum Type {
+ Folder,
+ Bookmark,
+ };
+
+ enum Fields {
+ Title,
+ Href,
+ Tags,
+ Description,
+ FieldCount
+ };
+
+ explicit BookmarkItem(const QVector<QVariant> &data, Type type, BookmarkItem *parent = nullptr);
+ ~BookmarkItem();
+
+ BookmarkItem *parent() const;
+
+ bool appendChild(BookmarkItem *childItem);
+ bool insertChild(int position, BookmarkItem *childItem);
+ bool removeChildAt(int index, int count = 1);
+ BookmarkItem *takeChild(int index, BookmarkItem *newParent);
+
+ BookmarkItem *child(int index);
+ int childCount() const;
+
+ QVariant data(int column) const;
+ bool setData(Fields column, const QVariant &data);
+
+ QIcon icon() const;
+ bool isExpanded() const;
+ void setExpanded(bool expanded);
+
+ QString tooltip() const;
+ Type type() const;
+ int row() const;
+
+private:
+ QVector<BookmarkItem *> m_children;
+ BookmarkItem *m_parentItem;
+
+ Type m_type;
+ QIcon m_icon;
+ bool m_isExpanded = false;
+
+ // fields
+ QVector<QVariant> m_data;
+};
+
+#endif //SMOLBOTE_BOOKMARKITEM_H