diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-02-07 21:08:39 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-02-07 21:08:39 +0100 |
commit | f779510603e01de438e337c82c439cc6649cd7c3 (patch) | |
tree | 98254e5ab079edcc6e207d692af28378573d4f0f /lib/bookmarks/bookmarksmodel.h | |
parent | Bookmarks bugfixes (diff) | |
download | smolbote-f779510603e01de438e337c82c439cc6649cd7c3.tar.xz |
Rewrote bookmark manager to use QTreeWidget over QTreeView
- cut out all the boilerplate that was BookmarkItem/BookmarksModel
- deleting items no longer crash; proper drag'n'drop
- Split Xbel into XbelReader and XbelWriter
Diffstat (limited to 'lib/bookmarks/bookmarksmodel.h')
-rw-r--r-- | lib/bookmarks/bookmarksmodel.h | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/lib/bookmarks/bookmarksmodel.h b/lib/bookmarks/bookmarksmodel.h deleted file mode 100644 index 7ae20fa..0000000 --- a/lib/bookmarks/bookmarksmodel.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 <QAbstractItemModel> -#include <QIcon> -#include <QTreeView> - -#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 |