1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-24 04:36:34 +01:00

Bookmarks: when deleting lastFolder set it to default.

This commit is contained in:
S. Razi Alavizadeh 2013-01-10 20:35:02 +03:30
parent da13a65c35
commit 05b5ebd1ef
2 changed files with 10 additions and 18 deletions

View File

@ -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);

View File

@ -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);