diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-08-30 15:28:15 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-08-30 15:28:34 +0300 |
commit | a200259c7d9583f2b0cf40ec9ee9c7d67349ceca (patch) | |
tree | 5f372310a6d3a24f73eb120a4043fda921930f72 /src/Authoring/Studio/Palettes/Project | |
parent | 18a97e8ea04082f1de96fa4a916dc8a33c5f1ca0 (diff) | |
parent | 9b46f36ba93def7ec3e007b38aeb7a94c1d16616 (diff) |
Merge branch 'master' into wip/refmaterial
Change-Id: I7a48e08645eb6817f1027ad9e0f9143cb11617c2
Diffstat (limited to 'src/Authoring/Studio/Palettes/Project')
4 files changed, 36 insertions, 12 deletions
diff --git a/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp b/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp index df2472ee..47eaf410 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp +++ b/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp @@ -763,21 +763,18 @@ bool ProjectFileSystemModel::hasVisibleChildren(const QModelIndex &modelIndex) c bool ProjectFileSystemModel::isVisible(const QModelIndex &modelIndex) const { - bool result = false; + QString path = modelIndex.data(QFileSystemModel::FilePathRole).toString(); - if (modelIndex == m_rootIndex) { - result = true; - } else { - QString path = modelIndex.data(QFileSystemModel::FilePathRole).toString(); - QFileInfo fileInfo(path); - if (fileInfo.isFile()) { - result = getIconType(path) != OBJTYPE_UNKNOWN; - } else { - result = true; - } + if (modelIndex == m_rootIndex || QFileInfo(path).isDir()) + return true; + + if (path.endsWith(QLatin1String("_autosave.uip")) + || path.endsWith(QLatin1String("_@preview@.uip")) + || path.endsWith(QLatin1String(".uia"))) { + return false; } - return result; + return getIconType(path) != OBJTYPE_UNKNOWN; } void ProjectFileSystemModel::modelRowsInserted(const QModelIndex &parent, int start, int end) diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp index e32f2f92..a58986dd 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp +++ b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp @@ -398,6 +398,28 @@ bool ProjectView::toolTipsEnabled() return CStudioPreferences::ShouldShowTooltips(); } +void ProjectView::openFile(int row) +{ + if (row == -1) + return; + + QFileInfo fi(m_ProjectModel->filePath(row)); + if (fi.isDir() || isCurrentPresentation(row)) + return; + + QString filePath = QDir::cleanPath(fi.absoluteFilePath()); + QTimer::singleShot(0, [filePath]() { + // .uip files should be opened in this studio instance + if (filePath.endsWith(QLatin1String(".uip"), Qt::CaseInsensitive)) { + if (g_StudioApp.PerformSavePrompt()) + g_StudioApp.OnLoadDocument(filePath); + } else { + // TODO: materials to be opened in inspector, pending materials handling overhaul + QDesktopServices::openUrl(QUrl::fromLocalFile(filePath)); + } + }); +} + void ProjectView::refreshImport(int row) const { if (row == -1) diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.h b/src/Authoring/Studio/Palettes/Project/ProjectView.h index 84c40ca6..ae52ad8d 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectView.h +++ b/src/Authoring/Studio/Palettes/Project/ProjectView.h @@ -81,6 +81,8 @@ public: Q_INVOKABLE bool isRefreshable(int row) const; Q_INVOKABLE void showContextMenu(int x, int y, int index); Q_INVOKABLE bool toolTipsEnabled(); + Q_INVOKABLE void openFile(int row); + bool isPresentation(int row) const; bool isQmlStream(int row) const; bool isCurrentPresentation(int row) const; diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.qml b/src/Authoring/Studio/Palettes/Project/ProjectView.qml index 387bbba2..4e946fda 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectView.qml +++ b/src/Authoring/Studio/Palettes/Project/ProjectView.qml @@ -195,7 +195,10 @@ Rectangle { projectTree.model.collapse(index); else projectTree.model.expand(index); + } else { + _parentView.openFile(index); } + clickPending = false; } else { clickPending = true; |