From 9203de811f049c8e604a9c3065781157fa506155 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Tue, 25 Sep 2018 14:44:01 +0200 Subject: Bookmarks: integrate model/view - fix addBookmark and search signals - fix drag'n'drop - add xbel::write --- lib/bookmarks/bookmarkmodel.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'lib/bookmarks/bookmarkmodel.h') diff --git a/lib/bookmarks/bookmarkmodel.h b/lib/bookmarks/bookmarkmodel.h index 90fdb2a..ea51caf 100644 --- a/lib/bookmarks/bookmarkmodel.h +++ b/lib/bookmarks/bookmarkmodel.h @@ -9,8 +9,11 @@ #ifndef SMOLBOTE_BOOKMARKMODEL_H #define SMOLBOTE_BOOKMARKMODEL_H -#include #include "bookmarkitem.h" +#include + +/* TODO BookmarkModel: moving items internally instead of copying during drag-drop + */ class BookmarkModel : public QAbstractItemModel { @@ -30,22 +33,30 @@ public: bool isItemExpanded(const QModelIndex &index) const; int rowCount(const QModelIndex &index) const override; - bool insertRows(int position, int rows, const QModelIndex &parent) override; + bool appendBookmark(const QString &title, const QString &url, const QModelIndex &parent); 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; + QStringList mimeTypes() const override; + QMimeData *mimeData(const QModelIndexList &indexes) const override; + bool dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; QModelIndex index(int row, int column, const QModelIndex &parent) const override; QModelIndex parent(const QModelIndex &index) const override; - BookmarkItem *root() { + BookmarkItem *root() + { return rootItem; } + QStringList search(const QString &term) const; + private: + const QLatin1Literal mimeType = QLatin1Literal("application/xbel"); + BookmarkItem *getItem(const QModelIndex &index) const; BookmarkItem *rootItem; }; -#endif //SMOLBOTE_BOOKMARKMODEL_H +#endif // SMOLBOTE_BOOKMARKMODEL_H -- cgit v1.2.1