aboutsummaryrefslogtreecommitdiff
path: root/test/firefox-bookmarks-json-parser/main.cpp
blob: b145d02671484d665e6886a32402036258246e93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "bookmarkmodel.h"
#include <QApplication>
#include <QDebug>
#include <QFile>
#include <QTreeView>

int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    QFile f(qgetenv("FILE"));

    auto *model = new BookmarkModel;

    if(f.open(QIODevice::ReadOnly)) {
        BookmarkFormat<FirefoxJsonFormat>(&f) >> model;
        f.close();
    } else
        return -1;

    auto *view = new QTreeView;
    view->setModel(model);

    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();
}