forked from qt-creator/qt-creator
QmlDesigner: Fix project tree widget renaming
When renaming an item in the project tree widget which has concatenated filename extensions like *.ui.qml the selection in the LineEdit will reach till the last dot. * Extend FilePath suffix and completeBaseName function so they will treat the suffix *.ui.qml as one * Make use of the function in ProjectTreeWidget::editCurrentItem * Replace QFileInfo::suffix with Utils::FilePath::suffix in FlatModel::setData Task-number: QDS-2713 Change-Id: I30d0e6d87a7512d42fd3d40b2282b94e79b43684 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
3930679f27
commit
a09ec2e0e9
@@ -528,22 +528,28 @@ QString FilePath::baseName() const
|
||||
/// \returns the complete base name of the file without the path.
|
||||
///
|
||||
/// The complete base name consists of all characters in the file up to
|
||||
/// (but not including) the last '.' character
|
||||
/// (but not including) the last '.' character. In case of ".ui.qml"
|
||||
/// it will be treated as one suffix.
|
||||
|
||||
QString FilePath::completeBaseName() const
|
||||
{
|
||||
const QString &name = fileName();
|
||||
if (name.endsWith(".ui.qml"))
|
||||
return name.left(name.length() - QString(".ui.qml").length());
|
||||
return name.left(name.lastIndexOf('.'));
|
||||
}
|
||||
|
||||
/// \returns the suffix (extension) of the file.
|
||||
///
|
||||
/// The suffix consists of all characters in the file after
|
||||
/// (but not including) the last '.'.
|
||||
/// (but not including) the last '.'. In case of ".ui.qml" it will
|
||||
/// be treated as one suffix.
|
||||
|
||||
QString FilePath::suffix() const
|
||||
{
|
||||
const QString &name = fileName();
|
||||
if (name.endsWith(".ui.qml"))
|
||||
return "ui.qml";
|
||||
const int index = name.lastIndexOf('.');
|
||||
if (index >= 0)
|
||||
return name.mid(index + 1);
|
||||
|
||||
Reference in New Issue
Block a user