aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-01-17 13:14:11 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2020-01-17 13:34:34 +0200
commit2c982ae87935c2ce2e2144694a4d55c5e1a688b6 (patch)
treefa8693aed8f8a96d3348dc263c03fcd78416352b
parentAdd Import option to BookmarksWidget (diff)
downloadsmolbote-2c982ae87935c2ce2e2144694a4d55c5e1a688b6.tar.xz
Parse Tags and Descriptions in FFJson
-rw-r--r--lib/bookmarks/formats/ffjson.cpp13
-rw-r--r--test/firefox-bookmarks-json-parser/main.cpp7
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/bookmarks/formats/ffjson.cpp b/lib/bookmarks/formats/ffjson.cpp
index 98f8e60..1fe6a96 100644
--- a/lib/bookmarks/formats/ffjson.cpp
+++ b/lib/bookmarks/formats/ffjson.cpp
@@ -25,6 +25,19 @@ inline void readElementData(const QJsonObject &object, BookmarkItem *item)
item->setData(BookmarkItem::Title, object["title"].toString());
item->setData(BookmarkItem::DateAdded, asDate(object["dateAdded"]));
item->setData(BookmarkItem::LastModified, asDate(object["lastModified"]));
+
+ // tags
+ const auto tags = object["tags"].toString().split(",");
+ if(!tags.isEmpty())
+ item->setData(BookmarkItem::Tags, tags);
+
+ // descriptions
+ for(const auto &a : object["annos"].toArray()) {
+ const auto anno = a.toObject();
+ if(anno["name"] == "bookmarkProperties/description") {
+ item->setData(BookmarkItem::Description, anno["value"].toString());
+ }
+ }
}
void readChildElements(const QJsonObject &object, BookmarkItem *item)
diff --git a/test/firefox-bookmarks-json-parser/main.cpp b/test/firefox-bookmarks-json-parser/main.cpp
index 48093ec..54819a2 100644
--- a/test/firefox-bookmarks-json-parser/main.cpp
+++ b/test/firefox-bookmarks-json-parser/main.cpp
@@ -2,6 +2,7 @@
#include "bookmarkformat.h"
#include <QTreeView>
#include <QApplication>
+#include <QDebug>
int main(int argc, char** argv)
{
@@ -23,6 +24,12 @@ int main(int argc, char** argv)
if(qgetenv("NOGUI") == "1")
return 0;
+ QObject::connect(view, &QTreeView::activated, [model](const QModelIndex &index) {
+ const auto tags = model->data(index, BookmarkItem::Tags, Qt::DisplayRole).toStringList();
+ qDebug() << tags.join(" || ");
+ });
+
+
view->show();
return app.exec();
}