aboutsummaryrefslogtreecommitdiff
path: root/lib/bookmarks/bookmarkmodel.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-09-25 16:49:56 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-09-25 16:49:56 +0200
commite0badcc7ef354b4bfdeedfde8f5ec3e82c27e741 (patch)
treecd997551fcd5c67c770d55f8182f678666fef240 /lib/bookmarks/bookmarkmodel.cpp
parentBookmarks: integrate model/view (diff)
downloadsmolbote-e0badcc7ef354b4bfdeedfde8f5ec3e82c27e741.tar.xz
Bookmarks: add tags and description fields to xbel
Diffstat (limited to 'lib/bookmarks/bookmarkmodel.cpp')
-rw-r--r--lib/bookmarks/bookmarkmodel.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/bookmarks/bookmarkmodel.cpp b/lib/bookmarks/bookmarkmodel.cpp
index b55dcdd..78e42b8 100644
--- a/lib/bookmarks/bookmarkmodel.cpp
+++ b/lib/bookmarks/bookmarkmodel.cpp
@@ -15,7 +15,7 @@
BookmarkModel::BookmarkModel(QObject *parent)
: QAbstractItemModel(parent)
{
- rootItem = new BookmarkItem({ "Title", "Address" }, BookmarkItem::Folder, nullptr);
+ rootItem = new BookmarkItem({ tr("Title"), tr("Address") }, BookmarkItem::Root, nullptr);
}
BookmarkModel::~BookmarkModel()
@@ -26,7 +26,7 @@ BookmarkModel::~BookmarkModel()
QVariant BookmarkModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if(orientation == Qt::Horizontal && role == Qt::DisplayRole)
- return rootItem->data(section);
+ return rootItem->data(static_cast<BookmarkItem::Fields>(section));
return QVariant();
}
@@ -43,7 +43,7 @@ QVariant BookmarkModel::data(const QModelIndex &index, int role) const
return static_cast<BookmarkItem *>(index.internalPointer())->tooltip();
else if(role == Qt::DisplayRole)
- return static_cast<BookmarkItem *>(index.internalPointer())->data(index.column());
+ return static_cast<BookmarkItem *>(index.internalPointer())->data(static_cast<BookmarkItem::Fields>(index.column()));
else
return QVariant();
@@ -55,7 +55,7 @@ QVariant BookmarkModel::data(const QModelIndex &index, int column, int role) con
return QVariant();
if(role == Qt::DisplayRole)
- return static_cast<BookmarkItem *>(index.internalPointer())->data(column);
+ return static_cast<BookmarkItem *>(index.internalPointer())->data(static_cast<BookmarkItem::Fields>(column));
return QVariant();
}
@@ -216,7 +216,6 @@ QMimeData *BookmarkModel::mimeData(const QModelIndexList &indexes) const
{
auto *mimeData = new QMimeData();
QByteArray data;
- XbelWriter writer;
QDataStream stream(&data, QIODevice::WriteOnly);
for(const QModelIndex &index : indexes) {
@@ -225,7 +224,7 @@ QMimeData *BookmarkModel::mimeData(const QModelIndexList &indexes) const
QBuffer buffer(&encodedData);
buffer.open(QIODevice::WriteOnly);
- writer.write(&buffer, getItem(index));
+ Xbel::write(&buffer, getItem(index));
stream << encodedData;
}
@@ -256,10 +255,9 @@ bool BookmarkModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction actio
QBuffer buffer(&encodedData);
buffer.open(QIODevice::ReadOnly);
- XbelReader reader(&buffer);
auto *fakeRoot = new BookmarkItem({}, BookmarkItem::Folder, nullptr);
auto *parentItem = getItem(parent);
- reader.read(fakeRoot);
+ Xbel::read(&buffer, fakeRoot);
beginInsertRows(parent, row, row + fakeRoot->childCount() - 1);
for(int i = 0; i < fakeRoot->childCount(); ++i) {