forked from qt-creator/qt-creator
ProjectTree: Select only (complete) file basename on rename
Change-Id: I29effc5f61fbaa214d7a1a01d92de5d5a726cec4 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
committed by
Alexandr Akulich
parent
783b310ee6
commit
48a68851fc
@@ -54,6 +54,7 @@
|
|||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -416,6 +417,18 @@ void ProjectTreeWidget::editCurrentItem()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_view->edit(currentIndex);
|
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)
|
void ProjectTreeWidget::renamed(const FileName &oldPath, const FileName &newPath)
|
||||||
|
Reference in New Issue
Block a user