From 05b5ebd1ef33c23a42b6d1356ff4c79f0e52c24a Mon Sep 17 00:00:00 2001 From: "S. Razi Alavizadeh" Date: Thu, 10 Jan 2013 20:35:02 +0330 Subject: [PATCH] Bookmarks: when deleting lastFolder set it to default. --- src/lib/bookmarks/bookmarksmanager.cpp | 24 ++++++------------------ src/lib/bookmarks/bookmarksmodel.cpp | 4 ++++ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/lib/bookmarks/bookmarksmanager.cpp b/src/lib/bookmarks/bookmarksmanager.cpp index 12d5b493e..ff9804aed 100644 --- a/src/lib/bookmarks/bookmarksmanager.cpp +++ b/src/lib/bookmarks/bookmarksmanager.cpp @@ -656,18 +656,12 @@ void BookmarksManager::insertBookmark(const QUrl &url, const QString &title, con int index = combo->findText(BookmarksModel::toTranslatedFolder(folder.isEmpty() ? m_bookmarksModel->lastFolder() : folder)); // QComboBox::find() returns index related to the item's parent - if (index == -1) { // subfolder or a deleted lastFolder + if (index == -1) { // subfolder QModelIndex rootIndex = combo->rootModelIndex(); combo->setRootModelIndex(combo->model()->index(combo->findText(_bookmarksToolbar),0)); index = combo->findText(BookmarksModel::toTranslatedFolder(folder.isEmpty() ? m_bookmarksModel->lastFolder() : folder)); - if (index == -1) { // deleted lastFolder - combo->setRootModelIndex(rootIndex); - combo->setCurrentIndex(0); - } - else { - combo->setCurrentIndex(index); - combo->setRootModelIndex(rootIndex); - } + combo->setCurrentIndex(index); + combo->setRootModelIndex(rootIndex); } else { combo->setCurrentIndex(index); @@ -725,18 +719,12 @@ void BookmarksManager::insertAllTabs() int index = combo->findText(BookmarksModel::toTranslatedFolder(m_bookmarksModel->lastFolder())); // QComboBox::find() returns index related to the item's parent - if (index == -1) { // subfolder or a deleted lastFolder + if (index == -1) { // subfolder QModelIndex rootIndex = combo->rootModelIndex(); combo->setRootModelIndex(combo->model()->index(combo->findText(_bookmarksToolbar),0)); index = combo->findText(BookmarksModel::toTranslatedFolder(m_bookmarksModel->lastFolder())); - if (index == -1) { // deleted lastFolder - combo->setRootModelIndex(rootIndex); - combo->setCurrentIndex(0); - } - else { - combo->setCurrentIndex(index); - combo->setRootModelIndex(rootIndex); - } + combo->setCurrentIndex(index); + combo->setRootModelIndex(rootIndex); } else { combo->setCurrentIndex(index); diff --git a/src/lib/bookmarks/bookmarksmodel.cpp b/src/lib/bookmarks/bookmarksmodel.cpp index 564a9de82..1a57153ed 100644 --- a/src/lib/bookmarks/bookmarksmodel.cpp +++ b/src/lib/bookmarks/bookmarksmodel.cpp @@ -411,6 +411,10 @@ void BookmarksModel::removeFolder(const QString &name) query.bindValue(0, name); query.exec(); + if (name == m_lastFolder) { + setLastFolder("unsorted"); + } + emit folderDeleted(name); mApp->sendMessages(Qz::AM_BookmarksChanged, true);