aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/projecttreewidget.cpp
diff options
context:
space:
mode:
authorAlexander Akulich <akulichalexander@gmail.com>2018-03-08 02:04:34 +0300
committerAlexandr Akulich <akulichalexander@gmail.com>2018-03-09 11:52:05 +0000
commit48a68851fcec74f8ac5eefb9ab8155e78fd7c70e (patch)
tree64d189f69545a75f1b0d67b7802ace8603eab25c /src/plugins/projectexplorer/projecttreewidget.cpp
parent783b310ee66e2e91b8b59ccf9594cfc215eb8987 (diff)
ProjectTree: Select only (complete) file basename on rename
Change-Id: I29effc5f61fbaa214d7a1a01d92de5d5a726cec4 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer/projecttreewidget.cpp')
-rw-r--r--src/plugins/projectexplorer/projecttreewidget.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp
index 9ce7431051..961b9fa894 100644
--- a/src/plugins/projectexplorer/projecttreewidget.cpp
+++ b/src/plugins/projectexplorer/projecttreewidget.cpp
@@ -54,6 +54,7 @@
#include <QToolButton>
#include <QPainter>
#include <QAction>
+#include <QLineEdit>
#include <QMenu>
#include <memory>
@@ -416,6 +417,18 @@ void ProjectTreeWidget::editCurrentItem()
return;
m_view->edit(currentIndex);
+ // Select complete file basename for renaming
+ const Node *node = m_model->nodeForIndex(currentIndex);
+ if (!node || node->nodeType() != NodeType::File)
+ return;
+ QLineEdit *editor = qobject_cast<QLineEdit*>(m_view->indexWidget(currentIndex));
+ if (!editor)
+ return;
+
+ const QString text = editor->text();
+ const int dotIndex = text.lastIndexOf(QLatin1Char('.'));
+ if (dotIndex > 0)
+ editor->setSelection(0, dotIndex);
}
void ProjectTreeWidget::renamed(const FileName &oldPath, const FileName &newPath)