From a4b57a11a440d7f98849a95e00fc41b971f42614 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 18 Sep 2015 19:24:02 +0200 Subject: [PATCH] Added display of class names to preferences Use flag in pdmUiTreeViewEditor to control display of class names --- ApplicationCode/Application/RiaApplication.cpp | 9 +++++++-- ApplicationCode/Application/RiaPreferences.cpp | 1 + ApplicationCode/Application/RiaPreferences.h | 1 + .../cafUserInterface/cafPdmUiTreeView.cpp | 8 ++++++++ Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h | 1 + .../cafUserInterface/cafPdmUiTreeViewEditor.cpp | 17 +++++++++++++++++ .../cafUserInterface/cafPdmUiTreeViewEditor.h | 4 ++++ .../cafUserInterface/cafPdmUiTreeViewModel.cpp | 15 +++++++-------- 8 files changed, 46 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index c9441a9ec2..02ddb81934 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -88,6 +88,7 @@ #include "RimMainPlotCollection.h" #include "RimWellLogPlotCollection.h" #include "RimWellLogPlot.h" +#include "cafPdmUiTreeView.h" namespace caf { @@ -1364,12 +1365,16 @@ void RiaApplication::applyPreferences() caf::EffectGenerator::setRenderingMode(caf::EffectGenerator::FIXED_FUNCTION); } + if (RiuMainWindow::instance() && RiuMainWindow::instance()->projectTreeView()) + { + RiuMainWindow::instance()->projectTreeView()->enableAppendOfClassNameToUiItemText(m_preferences->appendClassNameToUiText()); + } + if (this->project()) { this->project()->setScriptDirectories(m_preferences->scriptDirectories()); - this->project()->scriptCollection()->updateConnectedEditors(); + this->project()->updateConnectedEditors(); } - } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index c5cbef8ca3..dc5e18a996 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -62,6 +62,7 @@ RiaPreferences::RiaPreferences(void) CAF_PDM_InitField(&useShaders, "useShaders", true, "Use Shaders", "", "", ""); CAF_PDM_InitField(&showHud, "showHud", false, "Show 3D Information", "", "", ""); + CAF_PDM_InitField(&appendClassNameToUiText, "appendClassNameToUiText", false, "[System] Show Class Names", "", "", ""); CAF_PDM_InitFieldNoDefault(&lastUsedProjectFileName,"lastUsedProjectFileName", "Last Used Project File", "", "", ""); lastUsedProjectFileName.uiCapability()->setUiHidden(true); diff --git a/ApplicationCode/Application/RiaPreferences.h b/ApplicationCode/Application/RiaPreferences.h index 72f1ee0158..16869fd8e1 100644 --- a/ApplicationCode/Application/RiaPreferences.h +++ b/ApplicationCode/Application/RiaPreferences.h @@ -62,6 +62,7 @@ public: // Pdm Fields caf::PdmField useShaders; caf::PdmField showHud; + caf::PdmField appendClassNameToUiText; caf::PdmField lastUsedProjectFileName; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp index c4d0940947..7ebf252f1e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp @@ -195,5 +195,13 @@ void PdmUiTreeView::setDragDropHandle(PdmUiDragDropHandle* dragDropHandle) m_treeViewEditor->setDragDropHandle(dragDropHandle); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiTreeView::enableAppendOfClassNameToUiItemText(bool enable) +{ + m_treeViewEditor->enableAppendOfClassNameToUiItemText(enable); +} + } //End of namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h index 37b8ca4e36..bdc55bbbb6 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h @@ -66,6 +66,7 @@ public: void enableDefaultContextMenu(bool enable); void enableSelectionManagerUpdating(bool enable); // TODO: rename + void enableAppendOfClassNameToUiItemText(bool enable); void setUiConfigurationName(QString uiConfigName); void setPdmItem(caf::PdmUiItem* object); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp index d6b3373347..153b35cc05 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp @@ -63,6 +63,7 @@ PdmUiTreeViewEditor::PdmUiTreeViewEditor() { m_useDefaultContextMenu = false; m_updateSelectionManager = false; + m_appendClassNameToUiItemText = false; } @@ -324,5 +325,21 @@ void PdmUiTreeViewEditor::updateSelectionManager() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiTreeViewEditor::enableAppendOfClassNameToUiItemText(bool enable) +{ + m_appendClassNameToUiItemText = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool PdmUiTreeViewEditor::isAppendOfClassNameToUiItemTextEnabled() +{ + return m_appendClassNameToUiItemText; +} + } // end namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h index b556e344a2..2c0057cd8c 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h @@ -85,6 +85,9 @@ public: void enableDefaultContextMenu(bool enable); void enableSelectionManagerUpdating(bool enable); + + void enableAppendOfClassNameToUiItemText(bool enable); + bool isAppendOfClassNameToUiItemTextEnabled(); QTreeView* treeView(); @@ -133,6 +136,7 @@ private: bool m_useDefaultContextMenu; bool m_updateSelectionManager; + bool m_appendClassNameToUiItemText; }; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewModel.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewModel.cpp index 9cdc399820..962c4c4b97 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewModel.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewModel.cpp @@ -501,16 +501,15 @@ QVariant PdmUiTreeViewModel::data(const QModelIndex &index, int role ) const QString txt = v.toString(); -// Uncomment following to show class names of objects in property viewer -//#define SHOW_CLASS_NAME_IN_TREE -#ifdef SHOW_CLASS_NAME_IN_TREE - PdmObjectHandle* pdmObjHandle = pdmUiObject->objectHandle(); - if (pdmObjHandle) + if (m_treeViewEditor->isAppendOfClassNameToUiItemTextEnabled()) { - txt += " - "; - txt += typeid(*pdmObjHandle).name(); + PdmObjectHandle* pdmObjHandle = pdmUiObject->objectHandle(); + if (pdmObjHandle) + { + txt += " - "; + txt += typeid(*pdmObjHandle).name(); + } } -#endif return txt; }