/* * 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 */ #include "bookmarkitem.h" #include "xbel.h" #include #include #include #ifndef BOOKMARKSMODEL_H #define BOOKMARKSMODEL_H class QStyle; class BookmarksModel : public QAbstractItemModel { Q_OBJECT public: enum { TitleRole = Qt::UserRole + 1, OpenUrlRole = Qt::UserRole + 2 }; explicit BookmarksModel(QStyle *style, QObject *parent = nullptr); ~BookmarksModel() override; bool isModified() const; bool read(Xbel *xbel); bool write(Xbel *xbel); 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; QModelIndex insertItem(BookmarkItem::BookmarkItemType type, const QModelIndex &parent); bool removeItem(const QModelIndex &node); int columnCount(const QModelIndex &parent = QModelIndex()) const override; Qt::ItemFlags flags(const QModelIndex &index) const override; BookmarkItem::BookmarkItemType type(const QModelIndex &index) const; QVariant data(const QModelIndex &index, int role) const override; bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) 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; void expandItems(QTreeView *view, BookmarkItem *root = nullptr); // drag and drop Qt::DropActions supportedDropActions() const override { return Qt::CopyAction | Qt::MoveAction; } QStringList mimeTypes() const override { return {"application/bookmarks.xbel"}; } QMimeData *mimeData(const QModelIndexList &indexes) const override; bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; private: QIcon folderIcon; QIcon bookmarkIcon; bool modified = false; BookmarkItem *m_rootItem; }; #endif //BOOKMARKSMODEL_H