Bookmarks: Ask for confirmation before removing all bookmarks

Change-Id: Ib55d38269e6a2c5a28d320b115d3491a4e1b479b
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
hjk
2013-06-06 17:35:58 +02:00
parent 8800018224
commit 3958a83e9f

View File

@@ -43,6 +43,7 @@
#include <utils/tooltip/tooltip.h> #include <utils/tooltip/tooltip.h>
#include <utils/tooltip/tipcontents.h> #include <utils/tooltip/tipcontents.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/checkablemessagebox.h>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
@@ -279,10 +280,23 @@ void BookmarkView::removeBookmark(const QModelIndex& index)
m_manager->removeBookmark(bm); m_manager->removeBookmark(bm);
} }
// The perforcemance of this function could be greatly improved.
//
void BookmarkView::removeAll() void BookmarkView::removeAll()
{ {
const QString key = QLatin1String("Bookmarks.DontAskAgain");
QSettings *settings = ICore::settings();
bool checked = settings->value(key).toBool();
if (!checked) {
if (Utils::CheckableMessageBox::question(this,
tr("Remove All Bookmarks"),
tr("Are you sure you want to remove all bookmarks from all files in the current session?"),
tr("Do not &ask again."),
&checked, QDialogButtonBox::Yes | QDialogButtonBox::No, QDialogButtonBox::No)
!= QDialogButtonBox::Yes)
return;
settings->setValue(key, checked);
}
// The performance of this function could be greatly improved.
while (m_manager->rowCount()) { while (m_manager->rowCount()) {
QModelIndex index = m_manager->index(0, 0); QModelIndex index = m_manager->index(0, 0);
removeBookmark(index); removeBookmark(index);