aboutsummaryrefslogtreecommitdiff
path: root/lib/bookmarks/bookmarksmodel.h
blob: baf2ba93249cd2f3a998ad2db3a8863b4916d778 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * 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: git://neueland.iserlohn-fortress.net/smolbote.git
 *
 * SPDX-License-Identifier: GPL-3.0
 */

#include "bookmarkitem.h"
#include <QAbstractItemModel>
#include <QIcon>

#ifndef BOOKMARKSMODEL_H
#define BOOKMARKSMODEL_H

class QStyle;
class BookmarksModel : public QAbstractItemModel
{
    Q_OBJECT

public:
    enum {
        OpenUrlRole = Qt::UserRole + 1
    };

    explicit BookmarksModel(QStyle *style, QObject *parent = nullptr);
    ~BookmarksModel() override;

    void setRoot(BookmarkItem *root);

    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;

    QModelIndex index(BookmarkItem *node, int column = 0) const;
    QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
    QModelIndex parent(const QModelIndex &index) const override;
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;
    QVariant data(const QModelIndex &index, int role) const override;

    bool hasChildren(const QModelIndex &parent) const override;

    QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits, Qt::MatchFlags flags) const override;

private:
    QIcon folderIcon;
    QIcon bookmarkIcon;

    BookmarkItem *m_rootItem;
};

#endif //BOOKMARKSMODEL_H