aboutsummaryrefslogtreecommitdiff
path: root/lib/bookmarks/bookmarkmodel.h
blob: 90fdb2a5771e6c6a1eab36564da25237cb84ec86 (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: https://neueland.iserlohn-fortress.net/smolbote.hg
 *
 * SPDX-License-Identifier: GPL-3.0
 */

#ifndef SMOLBOTE_BOOKMARKMODEL_H
#define SMOLBOTE_BOOKMARKMODEL_H

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

class BookmarkModel : public QAbstractItemModel
{
    Q_OBJECT

public:
    explicit BookmarkModel(QObject *parent = nullptr);
    ~BookmarkModel() override;

    QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
    QVariant data(const QModelIndex &index, int role) const override;
    QVariant data(const QModelIndex &index, int column, int role) const;
    bool setData(const QModelIndex &index, const QVariant &value, int role) override;
    bool setData(const QModelIndex &index, const QVariant &value, BookmarkItem::Fields column, int role);
    Qt::ItemFlags flags(const QModelIndex &index) const override;

    bool isItemExpanded(const QModelIndex &index) const;

    int rowCount(const QModelIndex &index) const override;
    bool insertRows(int position, int rows, const QModelIndex &parent) override;
    bool removeRows(int position, int rows, const QModelIndex &parent) override;
    bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
    int columnCount(const QModelIndex &index) const override;
    Qt::DropActions supportedDropActions() const override;

    QModelIndex index(int row, int column, const QModelIndex &parent) const override;
    QModelIndex parent(const QModelIndex &index) const override;

    BookmarkItem *root() {
        return rootItem;
    }

private:
    BookmarkItem *getItem(const QModelIndex &index) const;
    BookmarkItem *rootItem;
};

#endif //SMOLBOTE_BOOKMARKMODEL_H