summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
authorkh1 <qt-info@nokia.com>2010-02-17 12:46:40 (GMT)
committerkh1 <qt-info@nokia.com>2010-02-17 14:49:42 (GMT)
commit29aa6e9d15a28e9a384d6a70585a43888745d34b (patch)
tree191e3c43d6ce67fbe5e17701b7d560667f4732ab /tools/assistant
parentfd717e5e182433a8c68a6e84ad207e6bba154334 (diff)
downloadQt-29aa6e9d15a28e9a384d6a70585a43888745d34b.zip
Qt-29aa6e9d15a28e9a384d6a70585a43888745d34b.tar.gz
Qt-29aa6e9d15a28e9a384d6a70585a43888745d34b.tar.bz2
Prevent renaming the bookmarks menu root item, it's just a placeholder.
Reviewed-by: ck
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/tools/assistant/bookmarkdialog.cpp20
-rw-r--r--tools/assistant/tools/assistant/bookmarkdialog.h1
2 files changed, 17 insertions, 4 deletions
diff --git a/tools/assistant/tools/assistant/bookmarkdialog.cpp b/tools/assistant/tools/assistant/bookmarkdialog.cpp
index c053b62..8b195c1 100644
--- a/tools/assistant/tools/assistant/bookmarkdialog.cpp
+++ b/tools/assistant/tools/assistant/bookmarkdialog.cpp
@@ -105,6 +105,11 @@ BookmarkDialog::~BookmarkDialog()
TRACE_OBJ
}
+bool BookmarkDialog::isRootItem(const QModelIndex &index) const
+{
+ return !bookmarkTreeModel->parent(index).isValid();
+}
+
bool BookmarkDialog::eventFilter(QObject *object, QEvent *event)
{
TRACE_OBJ
@@ -115,9 +120,12 @@ bool BookmarkDialog::eventFilter(QObject *object, QEvent *event)
QKeyEvent *ke = static_cast<QKeyEvent*>(event);
switch (ke->key()) {
case Qt::Key_F2: {
- bookmarkModel->setItemsEditable(true);
- ui.treeView->edit(ui.treeView->currentIndex());
- bookmarkModel->setItemsEditable(false);
+ const QModelIndex &index = ui.treeView->currentIndex();
+ if (!isRootItem(index)) {
+ bookmarkModel->setItemsEditable(true);
+ ui.treeView->edit(index);
+ bookmarkModel->setItemsEditable(false);
+ }
} break;
default: break;
}
@@ -212,13 +220,17 @@ void BookmarkDialog::textChanged(const QString& text)
void BookmarkDialog::customContextMenuRequested(const QPoint &point)
{
TRACE_OBJ
+ const QModelIndex &index = ui.treeView->currentIndex();
+ if (isRootItem(index))
+ return; // check if we go to rename the "Bookmarks Menu", bail
+
QMenu menu(QLatin1String(""), this);
QAction *renameItem = menu.addAction(tr("Rename Folder"));
QAction *picked = menu.exec(ui.treeView->mapToGlobal(point));
if (picked == renameItem) {
bookmarkModel->setItemsEditable(true);
- ui.treeView->edit(ui.treeView->currentIndex());
+ ui.treeView->edit(index);
bookmarkModel->setItemsEditable(false);
}
}
diff --git a/tools/assistant/tools/assistant/bookmarkdialog.h b/tools/assistant/tools/assistant/bookmarkdialog.h
index ba38c7a..e177af6 100644
--- a/tools/assistant/tools/assistant/bookmarkdialog.h
+++ b/tools/assistant/tools/assistant/bookmarkdialog.h
@@ -58,6 +58,7 @@ public:
~BookmarkDialog();
private:
+ bool isRootItem(const QModelIndex &index) const;
bool eventFilter(QObject *object, QEvent *event);
private slots: