diff options
author | aqua <aqua@iserlohn-fortress.net> | 2022-09-13 10:08:28 +0300 |
---|---|---|
committer | aqua <aqua@iserlohn-fortress.net> | 2022-09-14 08:51:10 +0300 |
commit | 0576870ebdbe813b5a084e1a279cb77077e6373e (patch) | |
tree | 01cad50191f9418aeebd55dfdde5d12c1eb289a9 /src/bookmarks/bookmarkstreemodel.cpp | |
parent | bugfix: don't wipe bookmarks if they're not modified (diff) | |
download | rekonq-0576870ebdbe813b5a084e1a279cb77077e6373e.tar.xz |
Rename BookmarkModel to BookmarksTreeModel
- remove BookmarkManager
- remove BookmarkOwner
Diffstat (limited to 'src/bookmarks/bookmarkstreemodel.cpp')
-rw-r--r-- | src/bookmarks/bookmarkstreemodel.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp index a4f322b8..d64f1588 100644 --- a/src/bookmarks/bookmarkstreemodel.cpp +++ b/src/bookmarks/bookmarkstreemodel.cpp @@ -13,20 +13,20 @@ #include <QDateTime> #include <QMimeData> -BookmarkModel::BookmarkModel(QObject *parent) : QAbstractItemModel(parent) +BookmarksTreeModel::BookmarksTreeModel(QObject *parent) : QAbstractItemModel(parent) { rootItem = new BookmarksTreeItem(BookmarksTreeItem::Root, {.title = tr("Title"), .href = tr("Address")}, nullptr); } -BookmarkModel::~BookmarkModel() { delete rootItem; } +BookmarksTreeModel::~BookmarksTreeModel() { delete rootItem; } -QVariant BookmarkModel::headerData(int section, Qt::Orientation, int role) const +QVariant BookmarksTreeModel::headerData(int section, Qt::Orientation, int role) const { if (role != Qt::DisplayRole) return {}; return rootItem->data(static_cast<BookmarksTreeItem::Attributes>(section)); } -QVariant BookmarkModel::data(const QModelIndex &index, int role) const +QVariant BookmarksTreeModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return {}; @@ -61,7 +61,7 @@ QVariant BookmarkModel::data(const QModelIndex &index, int role) const return {}; } -bool BookmarkModel::setData(const QModelIndex &index, const QVariant &value, int role) +bool BookmarksTreeModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (!index.isValid()) return false; @@ -80,7 +80,7 @@ bool BookmarkModel::setData(const QModelIndex &index, const QVariant &value, int return success; } -Qt::ItemFlags BookmarkModel::flags(const QModelIndex &index) const +Qt::ItemFlags BookmarksTreeModel::flags(const QModelIndex &index) const { switch (item(index)->type()) { case BookmarksTreeItem::Root: @@ -100,14 +100,14 @@ Qt::ItemFlags BookmarkModel::flags(const QModelIndex &index) const __builtin_unreachable(); } -int BookmarkModel::rowCount(const QModelIndex &index) const +int BookmarksTreeModel::rowCount(const QModelIndex &index) const { if (index.column() > 0) return 0; return static_cast<int>(item(index)->childCount()); } -QModelIndex BookmarkModel::appendItem(BookmarksTreeItem::Types type, BookmarksTreeItem::Attributes_t data, - const QModelIndex &parent) +QModelIndex BookmarksTreeModel::appendItem(BookmarksTreeItem::Types type, BookmarksTreeItem::Attributes_t data, + const QModelIndex &parent) { auto *parentItem = item(parent); const auto row = rowCount(parent); @@ -126,7 +126,7 @@ QModelIndex BookmarkModel::appendItem(BookmarksTreeItem::Types type, BookmarksTr return {}; } -bool BookmarkModel::removeRows(int position, int rows, const QModelIndex &parent) +bool BookmarksTreeModel::removeRows(int position, int rows, const QModelIndex &parent) { auto *parentItem = item(parent); @@ -138,7 +138,7 @@ bool BookmarkModel::removeRows(int position, int rows, const QModelIndex &parent return success; } -QModelIndex BookmarkModel::index(int row, int column, const QModelIndex &parent) const +QModelIndex BookmarksTreeModel::index(int row, int column, const QModelIndex &parent) const { if (!this->hasIndex(row, column, parent)) return {}; @@ -148,7 +148,7 @@ QModelIndex BookmarkModel::index(int row, int column, const QModelIndex &parent) return {}; } -QModelIndex BookmarkModel::parent(const QModelIndex &index) const +QModelIndex BookmarksTreeModel::parent(const QModelIndex &index) const { if (!index.isValid()) return {}; @@ -160,7 +160,7 @@ QModelIndex BookmarkModel::parent(const QModelIndex &index) const return createIndex(parentItem->row(), 0, parentItem); } -QModelIndex BookmarkModel::parentFolder(const QModelIndex &index) const +QModelIndex BookmarksTreeModel::parentFolder(const QModelIndex &index) const { // invalid index is the root index -> return it back if (!index.isValid()) return {}; @@ -170,7 +170,7 @@ QModelIndex BookmarkModel::parentFolder(const QModelIndex &index) const return index; } -BookmarksTreeItem *BookmarkModel::item(const QModelIndex &index) const +BookmarksTreeItem *BookmarksTreeModel::item(const QModelIndex &index) const { if (!index.isValid()) return rootItem; return static_cast<BookmarksTreeItem *>(index.internalPointer()); @@ -178,12 +178,12 @@ BookmarksTreeItem *BookmarkModel::item(const QModelIndex &index) const /* * Drag'n'Drop implementation - * How drag and drop actually works: the view encodes the data of the original item (using BookmarkModel::mimeData), and - * then uses BookmarkModel::dropMimeData to create the new item. If successful, the old item is removed (through - * BookmarkModel::removeRows). + * How drag and drop actually works: the view encodes the data of the original item (using + * BookmarksTreeModel::mimeData), and then uses BookmarksTreeModel::dropMimeData to create the new item. If successful, + * the old item is removed (through BookmarksTreeModel::removeRows). */ -QMimeData *BookmarkModel::mimeData(const QModelIndexList &indexes) const +QMimeData *BookmarksTreeModel::mimeData(const QModelIndexList &indexes) const { QByteArray data; QBuffer buffer(&data); @@ -201,8 +201,8 @@ QMimeData *BookmarkModel::mimeData(const QModelIndexList &indexes) const return mimeData; } -bool BookmarkModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, - const QModelIndex &parent) +bool BookmarksTreeModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, + const QModelIndex &parent) { if (action == Qt::IgnoreAction) return true; if (action != Qt::MoveAction) return false; // we only implement MoveAction's @@ -229,9 +229,9 @@ bool BookmarkModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction actio return true; } -QList<QString> BookmarkModel::load(QIODevice *buffer) { return readFns[Formats::FormatXbel](buffer, rootItem); } +QList<QString> BookmarksTreeModel::load(QIODevice *buffer) { return readFns[Formats::FormatXbel](buffer, rootItem); } -void BookmarkModel::save(QIODevice *buffer) +void BookmarksTreeModel::save(QIODevice *buffer) { if (!buffer->isOpen() || !buffer->isWritable()) return; m_isModified = !writeFns[Formats::FormatXbel](buffer, {rootItem}); |