1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +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,19 +656,13 @@ void BookmarksManager::insertBookmark(const QUrl &url, const QString &title, con
int index = combo->findText(BookmarksModel::toTranslatedFolder(folder.isEmpty() ? m_bookmarksModel->lastFolder() : folder)); int index = combo->findText(BookmarksModel::toTranslatedFolder(folder.isEmpty() ? m_bookmarksModel->lastFolder() : folder));
// QComboBox::find() returns index related to the item's parent // 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(); QModelIndex rootIndex = combo->rootModelIndex();
combo->setRootModelIndex(combo->model()->index(combo->findText(_bookmarksToolbar),0)); combo->setRootModelIndex(combo->model()->index(combo->findText(_bookmarksToolbar),0));
index = combo->findText(BookmarksModel::toTranslatedFolder(folder.isEmpty() ? m_bookmarksModel->lastFolder() : folder)); 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->setCurrentIndex(index);
combo->setRootModelIndex(rootIndex); combo->setRootModelIndex(rootIndex);
} }
}
else { else {
combo->setCurrentIndex(index); combo->setCurrentIndex(index);
} }
@ -725,19 +719,13 @@ void BookmarksManager::insertAllTabs()
int index = combo->findText(BookmarksModel::toTranslatedFolder(m_bookmarksModel->lastFolder())); int index = combo->findText(BookmarksModel::toTranslatedFolder(m_bookmarksModel->lastFolder()));
// QComboBox::find() returns index related to the item's parent // 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(); QModelIndex rootIndex = combo->rootModelIndex();
combo->setRootModelIndex(combo->model()->index(combo->findText(_bookmarksToolbar),0)); combo->setRootModelIndex(combo->model()->index(combo->findText(_bookmarksToolbar),0));
index = combo->findText(BookmarksModel::toTranslatedFolder(m_bookmarksModel->lastFolder())); index = combo->findText(BookmarksModel::toTranslatedFolder(m_bookmarksModel->lastFolder()));
if (index == -1) { // deleted lastFolder
combo->setRootModelIndex(rootIndex);
combo->setCurrentIndex(0);
}
else {
combo->setCurrentIndex(index); combo->setCurrentIndex(index);
combo->setRootModelIndex(rootIndex); combo->setRootModelIndex(rootIndex);
} }
}
else { else {
combo->setCurrentIndex(index); combo->setCurrentIndex(index);
} }

View File

@ -411,6 +411,10 @@ void BookmarksModel::removeFolder(const QString &name)
query.bindValue(0, name); query.bindValue(0, name);
query.exec(); query.exec();
if (name == m_lastFolder) {
setLastFolder("unsorted");
}
emit folderDeleted(name); emit folderDeleted(name);
mApp->sendMessages(Qz::AM_BookmarksChanged, true); mApp->sendMessages(Qz::AM_BookmarksChanged, true);