From 4c71c8571ceb10b29e6550cd0d8eb928049e6851 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Tue, 14 Jan 2020 23:34:13 +0200 Subject: Move/rename files for readability - add BookmarkFormat <<|>> BookmarkModel operators --- lib/bookmarks/bookmarkitem.h | 69 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 lib/bookmarks/bookmarkitem.h (limited to 'lib/bookmarks/bookmarkitem.h') diff --git a/lib/bookmarks/bookmarkitem.h b/lib/bookmarks/bookmarkitem.h new file mode 100644 index 0000000..8c9463f --- /dev/null +++ b/lib/bookmarks/bookmarkitem.h @@ -0,0 +1,69 @@ +/* + * 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/gitea/aqua/smolbote + * + * SPDX-License-Identifier: GPL-3.0 + */ + +#ifndef SMOLBOTE_BOOKMARKITEM_H +#define SMOLBOTE_BOOKMARKITEM_H + +#include +#include +#include + +class BookmarkItem +{ +public: + enum Type { + Root, + Folder, + Bookmark, + }; + + enum Fields { + Title, + Href, + Tags, + Description, + FieldCount + }; + + explicit BookmarkItem(const QVector &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) const; + int childCount() const; + + QVariant data(Fields 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 m_children; + BookmarkItem *m_parentItem; + + Type m_type; + QIcon m_icon; + bool m_isExpanded = false; + + // fields + QVector m_data; +}; + +#endif // SMOLBOTE_BOOKMARKITEM_H -- cgit v1.2.1 From 5f708d4618d739d14442b85c466fdbac84a74cc8 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 17 Jan 2020 10:25:27 +0200 Subject: BookmarkItem::DateAdded and LastModified fields - add read support in FFJson for DateAdded and LastModified fields - add read/write support in Xbel for DateAdded and LastModified fields - BookmarkModel: set DateAdded on appendBookmark and appendFolder - EditBookmarkDialog: set LastModified field when saving changes --- lib/bookmarks/bookmarkitem.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/bookmarks/bookmarkitem.h') diff --git a/lib/bookmarks/bookmarkitem.h b/lib/bookmarks/bookmarkitem.h index 8c9463f..6751526 100644 --- a/lib/bookmarks/bookmarkitem.h +++ b/lib/bookmarks/bookmarkitem.h @@ -27,6 +27,8 @@ public: Href, Tags, Description, + DateAdded, + LastModified, FieldCount }; -- cgit v1.2.1