aboutsummaryrefslogtreecommitdiff
path: root/lib/bookmarks/bookmarksmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bookmarks/bookmarksmodel.cpp')
-rw-r--r--lib/bookmarks/bookmarksmodel.cpp41
1 files changed, 29 insertions, 12 deletions
diff --git a/lib/bookmarks/bookmarksmodel.cpp b/lib/bookmarks/bookmarksmodel.cpp
index 3498f71..418d456 100644
--- a/lib/bookmarks/bookmarksmodel.cpp
+++ b/lib/bookmarks/bookmarksmodel.cpp
@@ -175,6 +175,15 @@ Qt::ItemFlags BookmarksModel::flags(const QModelIndex &index) const
return flags;
}
+BookmarkItem::BookmarkItemType BookmarksModel::type(const QModelIndex &index) const
+{
+ if(!index.isValid()) {
+ return BookmarkItem::Root;
+ }
+
+ return static_cast<BookmarkItem *>(index.internalPointer())->type();
+}
+
QVariant BookmarksModel::data(const QModelIndex &index, int role) const
{
// get data of invalid index?
@@ -207,6 +216,9 @@ QVariant BookmarksModel::data(const QModelIndex &index, int role) const
return QVariant();
}
+ case TitleRole:
+ return item->title;
+
case OpenUrlRole:
if(item->type() == BookmarkItem::Bookmark) {
return item->href;
@@ -230,25 +242,30 @@ bool BookmarksModel::setData(const QModelIndex &index, const QVariant &value, in
return false;
case BookmarkItem::Folder:
- if(index.column() == 0) {
+ if(role == TitleRole && (node->title != value.toString())) {
node->title = value.toString();
modified = true;
- emit dataChanged(index, index);
+ emit dataChanged(this->index(node, 0), this->index(node, 1));
+ //emit dataChanged(index, index);
return true;
}
return false;
case BookmarkItem::Bookmark:
- if(index.column() == 0) {
- node->title = value.toString();
- modified = true;
- emit dataChanged(index, index);
- return true;
- } else if(index.column() == 1) {
- node->href = value.toString();
- modified = true;
- emit dataChanged(index, index);
- return true;
+ if(role == TitleRole && (node->title != value.toString())) {
+ node->title = value.toString();
+ modified = true;
+ emit dataChanged(this->index(node, 0), this->index(node, 1));
+ //emit dataChanged(index, index);
+ return true;
+
+ } else if(role == OpenUrlRole && (node->href != value.toString())) {
+ node->href = value.toString();
+ modified = true;
+ emit dataChanged(this->index(node, 0), this->index(node, 1));
+ //emit dataChanged(index, index);
+ return true;
+
}
return false;
}