diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-11-13 13:08:15 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-11-14 08:47:26 +0000 |
commit | 12db076d2bbb1f1561b4afa06654fbe91cf2defc (patch) | |
tree | 84f0973c20464ceda8de015580e7e93331de6e5f /src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp | |
parent | d1ed4c807cb18e6828f0928fd2f1626c4318b075 (diff) |
Don't close various chooser dialogs immediately on selection
Now the chooser dialogs stick around until you doubleclick on item
or they lose focus naturally. Also fixes some related issues like
fixed choices never highlighting as selected.
Task-number: QT3DS-2655
Change-Id: I33b42383a303f9ba2ae10e1b7e3131e4bfd0c62f
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Janne Kangas <janne.kangas@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp')
-rw-r--r-- | src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp b/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp index 3f5583ea..b9b5f92a 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp @@ -153,23 +153,29 @@ QVariant ChooserModelBase::data(const QModelIndex &index, int role) const void ChooserModelBase::setCurrentFile(const QString &path) { + const auto fixedItems = getFixedItems(); + const int fixedItemCount = fixedItems.count(); + const auto getFixedItemIndex = [fixedItemCount, &fixedItems](const QString &path) -> int { + for (int i = 0; i < fixedItemCount; ++i) { + const auto &item = fixedItems.at(i); + if (item.name == path) + return i; + } + return -1; + }; + int fixedItemIndex = getFixedItemIndex(path); + const auto doc = g_StudioApp.GetCore()->GetDoc(); const QDir documentDir(doc->GetDocumentDirectory().toQString()); - const QString fullPath = QDir::cleanPath(documentDir.filePath(path)); + const QString fullPath = fixedItemIndex == -1 ? QDir::cleanPath(documentDir.filePath(path)) + : path; if (fullPath != m_currentFile) { - const auto fixedItems = getFixedItems(); - - const auto fileRow = [this, &fixedItems](const QString &path) + const auto fileRow = [this, getFixedItemIndex, fixedItemCount](const QString &path) -> int { - const int fixedItemCount = fixedItems.count(); - - for (int i = 0; i < fixedItemCount; ++i) { - const auto &item = fixedItems.at(i); - - if (item.name == path) - return i; - } + const int fixedItemIndex = getFixedItemIndex(path); + if (fixedItemIndex != -1) + return fixedItemIndex; const int itemCount = m_items.count(); |