diff options
author | Alexander Volkov <a.volkov@rusbitech.ru> | 2015-03-05 19:11:51 +0300 |
---|---|---|
committer | Alexander Volkov <a.volkov@rusbitech.ru> | 2015-03-06 21:17:32 +0000 |
commit | 7152ec2f4783027b5c2f4d0c0816e4931acf32cc (patch) | |
tree | 8547b040f2bd2bd1831184ad2ab642cf6225e255 | |
parent | ccbae6677e52f2b02cbd43608777f93c2b663a80 (diff) | |
download | qttools-7152ec2f4783027b5c2f4d0c0816e4931acf32cc.tar.gz |
Assistant: Fix an export and an import of bookmarks
Use the correct root index for BookmarkModel.
Allow to remove top-level bookmark folders if they were
created by importing bookmarks.
Task-number: QTBUG-44042
Change-Id: I423b141d0e64dec8c4cebfdba0d4401d575d1b96
Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
-rw-r--r-- | src/assistant/assistant/bookmarkmanagerwidget.cpp | 2 | ||||
-rw-r--r-- | src/assistant/assistant/bookmarkmodel.cpp | 2 | ||||
-rw-r--r-- | src/assistant/assistant/xbelsupport.cpp | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/src/assistant/assistant/bookmarkmanagerwidget.cpp b/src/assistant/assistant/bookmarkmanagerwidget.cpp index 6c55ce7f4..3469f5925 100644 --- a/src/assistant/assistant/bookmarkmanagerwidget.cpp +++ b/src/assistant/assistant/bookmarkmanagerwidget.cpp @@ -239,7 +239,7 @@ void BookmarkManagerWidget::removeItem(const QModelIndex &index) { TRACE_OBJ QModelIndex current = index.isValid() ? index : ui.treeView->currentIndex(); - if (!bookmarkModel->parent(current).isValid()) + if (!current.parent().isValid() && current.row() < 2) return; // check if we should delete the "Bookmarks Menu", bail if (bookmarkModel->hasChildren(current)) { diff --git a/src/assistant/assistant/bookmarkmodel.cpp b/src/assistant/assistant/bookmarkmodel.cpp index 367f8c8be..9e20ff097 100644 --- a/src/assistant/assistant/bookmarkmodel.cpp +++ b/src/assistant/assistant/bookmarkmodel.cpp @@ -330,7 +330,7 @@ BookmarkModel::indexListFor(const QString &label) const bool BookmarkModel::insertRows(int position, int rows, const QModelIndex &parent) { - if (!parent.data(UserRoleFolder).toBool()) + if (parent.isValid() && !parent.data(UserRoleFolder).toBool()) return false; bool success = false; diff --git a/src/assistant/assistant/xbelsupport.cpp b/src/assistant/assistant/xbelsupport.cpp index 7fc12dea9..baf8e3799 100644 --- a/src/assistant/assistant/xbelsupport.cpp +++ b/src/assistant/assistant/xbelsupport.cpp @@ -66,7 +66,7 @@ void XbelWriter::writeToFile(QIODevice *device) writeStartElement(QLatin1String("xbel")); writeAttribute(QLatin1String("version"), QLatin1String("1.0")); - const QModelIndex &root = bookmarkModel->index(0,0, QModelIndex()); + const QModelIndex root; for (int i = 0; i < bookmarkModel->rowCount(root); ++i) writeData(bookmarkModel->index(i, 0, root)); writeEndDocument(); @@ -120,7 +120,7 @@ bool XbelReader::readFromFile(QIODevice *device) if (name() == QLatin1String("xbel") && attributes().value(QLatin1String("version")) == QLatin1String("1.0")) { - const QModelIndex &root = bookmarkModel->index(0,0, QModelIndex()); + const QModelIndex root; parents.append(bookmarkModel->addItem(root, true)); readXBEL(); bookmarkModel->setData(parents.first(), |