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/bookmarkformat.h | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 lib/bookmarks/bookmarkformat.h (limited to 'lib/bookmarks/bookmarkformat.h') diff --git a/lib/bookmarks/bookmarkformat.h b/lib/bookmarks/bookmarkformat.h new file mode 100644 index 0000000..673acbd --- /dev/null +++ b/lib/bookmarks/bookmarkformat.h @@ -0,0 +1,67 @@ +/* + * 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 BOOKMARKFORMAT_H +#define BOOKMARKFORMAT_H + +#include "bookmarkmodel.h" + +class QIODevice; + +enum BookmarkFormats { + XbelFormat +}; + +template +class BookmarkFormat +{ +public: + explicit BookmarkFormat(QIODevice *device) + { + m_device = device; + } + ~BookmarkFormat() + { + m_device->close(); + } + + void read(BookmarkItem *root) const; + void write(BookmarkItem *root); + +protected: + QIODevice *m_device; +}; + +template +void operator<<(BookmarkModel *model, const BookmarkFormat &format) +{ + format.read(model->root()); +} + +template +void operator>>(const BookmarkFormat &format, BookmarkModel *model) +{ + format.read(model->root()); +} + +template +void operator<<(BookmarkFormat &format, BookmarkModel *model) +{ + format.write(model->root()); + model->resetModified(); +} + +template +void operator>>(BookmarkModel *model, BookmarkFormat &format) +{ + format.write(model->root()); + model->resetModified(); +} + +#endif // BOOKMARKSFORMAT_H + -- cgit v1.2.1 From 198be208d49990c3535ac765735768ad1ae79c1b Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Thu, 16 Jan 2020 21:40:15 +0200 Subject: Add Firefox bookmarks.json format to libbookmarks - can only read folders and bookmarks, their title and uri fields Not supported by Bookmark Model: - Separator items - Date added and Date modified fields --- lib/bookmarks/bookmarkformat.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/bookmarks/bookmarkformat.h') diff --git a/lib/bookmarks/bookmarkformat.h b/lib/bookmarks/bookmarkformat.h index 673acbd..5cd1860 100644 --- a/lib/bookmarks/bookmarkformat.h +++ b/lib/bookmarks/bookmarkformat.h @@ -14,7 +14,8 @@ class QIODevice; enum BookmarkFormats { - XbelFormat + XbelFormat, + FirefoxJsonFormat }; template @@ -23,6 +24,7 @@ class BookmarkFormat public: explicit BookmarkFormat(QIODevice *device) { + Q_CHECK_PTR(m_device); m_device = device; } ~BookmarkFormat() -- 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/bookmarkformat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/bookmarks/bookmarkformat.h') diff --git a/lib/bookmarks/bookmarkformat.h b/lib/bookmarks/bookmarkformat.h index 5cd1860..8b64420 100644 --- a/lib/bookmarks/bookmarkformat.h +++ b/lib/bookmarks/bookmarkformat.h @@ -24,7 +24,7 @@ class BookmarkFormat public: explicit BookmarkFormat(QIODevice *device) { - Q_CHECK_PTR(m_device); + Q_CHECK_PTR(device); m_device = device; } ~BookmarkFormat() -- cgit v1.2.1 From d75794508e1c202d28bdf77c25afb85d80d42554 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 17 Jan 2020 11:46:20 +0200 Subject: Add Import option to BookmarksWidget --- lib/bookmarks/bookmarkformat.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/bookmarks/bookmarkformat.h') diff --git a/lib/bookmarks/bookmarkformat.h b/lib/bookmarks/bookmarkformat.h index 8b64420..c886546 100644 --- a/lib/bookmarks/bookmarkformat.h +++ b/lib/bookmarks/bookmarkformat.h @@ -27,10 +27,6 @@ public: Q_CHECK_PTR(device); m_device = device; } - ~BookmarkFormat() - { - m_device->close(); - } void read(BookmarkItem *root) const; void write(BookmarkItem *root); -- cgit v1.2.1