]> OCCT Git - occt-copy.git/commitdiff
0031362: Inspectors - MessageView plugin for message alerts
authornds <nds@opencascade.com>
Wed, 7 Oct 2020 05:40:41 +0000 (08:40 +0300)
committernds <nds@opencascade.com>
Mon, 12 Oct 2020 08:50:53 +0000 (11:50 +0300)
15 files changed:
tools/DFBrowser/DFBrowser_TreeModel.cxx
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNodeModel.cxx
tools/MessageModel/MessageModel_ItemAlert.cxx
tools/MessageModel/MessageModel_ItemReport.cxx
tools/MessageModel/MessageModel_TreeModel.cxx
tools/MessageView/MessageView_Window.cxx
tools/MessageView/MessageView_Window.hxx
tools/TInspectorEXE/TInspectorEXE.cxx
tools/TreeModel/TreeModel_ContextMenu.cxx
tools/TreeModel/TreeModel_ModelBase.cxx
tools/TreeModel/TreeModel_ModelBase.hxx
tools/TreeModel/TreeModel_Tools.cxx
tools/VInspector/VInspector_ViewModel.cxx
tools/VInspector/VInspector_ViewModelHistory.cxx
tools/VInspector/VInspector_Window.cxx

index 23ab2c2aa837e07d1034ab245d8a4ae4f73aa5f5..70857bc046c8f010b358c1de83628e2ba8014c22 100644 (file)
@@ -49,7 +49,7 @@ DFBrowser_TreeModel::DFBrowser_TreeModel (QObject* theParent)
 // =======================================================================
 void DFBrowser_TreeModel::InitColumns()
 {
-  SetHeaderItem (0, TreeModel_HeaderSection ("Name"));
+  setHeaderItem (0, TreeModel_HeaderSection ("Name"));
 }
 
 // =======================================================================
index 4f8a4847f0dabca1173e63ebad4041ef783c60a6..0d6b98f12fa9cb65aa094ea319b1c1256f3c7c47 100644 (file)
@@ -37,7 +37,7 @@ DFBrowserPane_TDataStdTreeNodeModel::DFBrowserPane_TDataStdTreeNodeModel (QObjec
 // =======================================================================
 void DFBrowserPane_TDataStdTreeNodeModel::InitColumns()
 {
-  SetHeaderItem (0, TreeModel_HeaderSection ("Name"));
+  setHeaderItem (0, TreeModel_HeaderSection ("Name"));
 }
 
 // =======================================================================
index 6aa1c7bb693d336ccf8259291077b56ba26cac8f..37439fd45912804651d4fda8ef823f8279ffefa4 100644 (file)
@@ -119,6 +119,9 @@ QVariant MessageModel_ItemAlert::initValue (const int theRole) const
     if (anAttribute.IsNull() || !anAttribute->HasMetric (aMetricType))
       return QVariant();
 
+    if (!anAttribute->IsMetricValid (aMetricType))
+      return QVariant ("in process");
+
     if (aMetricType == Message_MetricType_UserTimeCPU ||
         aMetricType == Message_MetricType_SystemTimeInfo)
     {
index 32ef4ff4e1deb30248caf03b3e5472c5738b9af0..ce9b4efc05748ab92a78cfeea16a29d6e8aded74 100644 (file)
@@ -210,8 +210,9 @@ Standard_Real MessageModel_ItemReport::CumulativeMetric (const Handle(Message_Re
       if (anAlert.IsNull())
         continue;
       Handle(Message_AttributeMeter) anAttribute = Handle(Message_AttributeMeter)::DownCast (anAlert->Attribute());
-      if (anAttribute.IsNull() || !anAttribute->HasMetric(theMetricType))
+      if (anAttribute.IsNull() || !anAttribute->HasMetric (theMetricType) || !anAttribute->IsMetricValid (theMetricType))
         continue;
+
       //if (aFirstAttribute.IsNull())
       //  aFirstAttribute = anAttribute;
       //else
index 7806eb35f75b7fe17106ad9e2e9a535f27437c67..b5950bd8b5337706e73f83ddbb29e8ed3bd96001 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <Message.hxx>
 
-const int COLUMN_NAME_WIDTH = 460;
+const int COLUMN_NAME_WIDTH = 230;
 const int COLUMN_SIZE_WIDTH = 30;
 
 const int COLUMN_REAL_VALUE_WIDTH = 115;
@@ -44,9 +44,9 @@ MessageModel_TreeModel::MessageModel_TreeModel (QObject* theParent)
 void MessageModel_TreeModel::InitColumns()
 {
   // 0 - Name, 1 - visibility, 2 - Row
-  SetHeaderItem (TreeModel_ColumnType_Name,       TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
-  SetHeaderItem (TreeModel_ColumnType_Visibility, TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth()));
-  SetHeaderItem (TreeModel_ColumnType_Row,        TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH, Standard_True /*hidden*/));
+  setHeaderItem (TreeModel_ColumnType_Name,       TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
+  setHeaderItem (TreeModel_ColumnType_Visibility, TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth()));
+  setHeaderItem (TreeModel_ColumnType_Row,        TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH, Standard_True /*hidden*/));
 
   int aNextIndex = 3;
   for (int aMetricId = (int)Message_MetricType_None + 1; aMetricId <= (int)Message_MetricType_MemHeapUsage; aMetricId++)
@@ -55,10 +55,10 @@ void MessageModel_TreeModel::InitColumns()
     OSD_MemInfo::Counter aMemInfo;
     bool isMemInfo = Message::ToOSDMetric (aMetricType, aMemInfo);
 
-    SetHeaderItem (aNextIndex++,
+    setHeaderItem (aNextIndex++,
       TreeModel_HeaderSection (QString("%1 [%2]").arg (Message::MetricToString (aMetricType)).arg(isMemInfo ? "Mb" : "s"),
       COLUMN_REAL_VALUE_WIDTH));
-    SetHeaderItem (aNextIndex++, TreeModel_HeaderSection (isMemInfo ? "Delta" : "%", COLUMN_PERCENT_VALUE_WIDTH));
+    setHeaderItem (aNextIndex++, TreeModel_HeaderSection (isMemInfo ? "Delta" : "%", COLUMN_PERCENT_VALUE_WIDTH));
   }
 }
 
index 7e9104db2eb78f4959e3b09b88a027bcd0f18240..a2270827d1cc2302f9bcf11006fcbd882fff879a 100644 (file)
@@ -80,7 +80,7 @@
 #include <QWidget>
 #include <QVBoxLayout>
 
-const int DEFAULT_TEXT_VIEW_WIDTH = 400;// 800;
+const int DEFAULT_TEXT_VIEW_WIDTH = 800;// 800;
 const int DEFAULT_TEXT_VIEW_HEIGHT = 700;
 const int DEFAULT_TEXT_VIEW_POSITION_X = 430;
 const int DEFAULT_TEXT_VIEW_POSITION_Y = 30;
@@ -149,6 +149,9 @@ MessageView_Window::MessageView_Window (QWidget* theParent)
   aModel->InitColumns();
   //aModel->SetReversed (Standard_True);
 
+  connect (myTreeView->header(), SIGNAL (sectionResized (int, int, int)),
+           this, SLOT(onHeaderResized (int, int, int)));
+
   myTreeView->setModel (aModel);
   MessageView_VisibilityState* aVisibilityState = new MessageView_VisibilityState (aModel);
   aModel->SetVisibilityState (aVisibilityState);
@@ -171,6 +174,9 @@ MessageView_Window::MessageView_Window (QWidget* theParent)
           this, SLOT (onTreeViewContextMenuRequested (const QPoint&)));
   //new TreeModel_ContextMenu (myTreeView);
 
+  connect (myTreeView->header(), SIGNAL (sectionResized (int, int, int)),
+           this, SLOT(onHeaderResized (int, int, int)));
+
   QModelIndex aParentIndex = myTreeView->model()->index (0, 0);
   myTreeView->setExpanded (aParentIndex, true);
 
@@ -251,15 +257,18 @@ void MessageView_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theIt
   theItem.Bind ("geometry",  TreeModel_Tools::ToString (myMainWindow->saveState()).toStdString().c_str());
 
   QMap<QString, QString> anItems;
-  //TreeModel_Tools::SaveState (myTreeView, anItems);
-
-  anItems.clear();
-  View_Window::SaveState(myViewWindow, anItems);
+  TreeModel_Tools::SaveState (myTreeView, anItems);
   for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
+  {
     theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
+  }
 
+  anItems.clear();
+  View_Window::SaveState(myViewWindow, anItems);
   for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
+  {
     theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
+  }
 }
 
 // =======================================================================
@@ -272,8 +281,8 @@ void MessageView_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap&
   {
     if (anItemIt.Key().IsEqual ("geometry"))
       myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemIt.Value().ToCString()));
-    //else if (TreeModel_Tools::RestoreState (myTreeView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
-    //  continue;
+    else if (TreeModel_Tools::RestoreState (myTreeView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
+      continue;
     else if (myViewWindow && View_Window::RestoreState(myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
       continue;
   }
@@ -305,7 +314,7 @@ void MessageView_Window::UpdateContent()
     myParameters->SetFileNames (aName, aNames);
     isUpdated = true;
   }
-  Handle(Message_Report) aDefaultReport = Message::DefaultReport (Standard_False);
+  Handle(Message_Report) aDefaultReport = Message::DefaultReport();
   MessageModel_TreeModel* aViewModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
   if (!aDefaultReport.IsNull() && !aViewModel->HasReport (aDefaultReport))
   {
@@ -315,6 +324,7 @@ void MessageView_Window::UpdateContent()
   //onReloadReport();
 
   updateTreeModel();
+  updateVisibleColumns();
 }
 
 // =======================================================================
@@ -372,7 +382,10 @@ void MessageView_Window::Init (NCollection_List<Handle(Standard_Transient)>& the
 // =======================================================================
 void MessageView_Window::openFile(const TCollection_AsciiString& theFileName)
 {
-  const Handle(Message_Report)& aReport = Message::DefaultReport();
+  if (theFileName.IsEmpty())
+    return;
+
+  const Handle(Message_Report)& aReport = Message::DefaultReport (Standard_True);
 
   //Handle(Message_Report) aReport = new Message_Report();
   if (aReport->MessageWriter().IsNull())
@@ -407,7 +420,7 @@ void MessageView_Window::addReport (const Handle(Message_Report)& theReport,
   MessageModel_TreeModel* aModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
   aModel->AddReport (theReport, theReportDescription);
 
-  updateVisibleColumns();
+  //updateVisibleColumns();
 }
 
 // =======================================================================
@@ -466,7 +479,8 @@ void MessageView_Window::onTreeViewContextMenuRequested (const QPoint& thePositi
   }
   if (aRootItem)
   {
-    aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Import Report"), SLOT (onImportReport()), myMainWindow, this));
+    aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Create Default Report"),
+                      SLOT (onCreateDefaultReport()), myMainWindow, this));
     // unite
     //MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
     //aMenu->addAction (ViewControl_Tools::CreateAction (aTreeModel->IsUniteAlerts() ? tr ("SetUniteAlerts - OFF") : tr ("SetUniteAlerts - ON"),
@@ -545,6 +559,18 @@ void MessageView_Window::onPropertyViewDataChanged()
   updatePreviewPresentation();
 }
 
+// =======================================================================
+// function : onHeaderResized
+// purpose :
+// =======================================================================
+void MessageView_Window::onHeaderResized (int theSectionId, int, int)
+{
+  TreeModel_ModelBase* aViewModel = dynamic_cast<TreeModel_ModelBase*> (myTreeView->model());
+
+  TreeModel_HeaderSection* aSection = aViewModel->ChangeHeaderItem (theSectionId);
+  aSection->SetWidth (myTreeView->columnWidth (theSectionId));
+}
+
 // =======================================================================
 // function : onEraseAllPerformed
 // purpose :
@@ -576,32 +602,36 @@ void MessageView_Window::onExportReport()
   if (!aReportItem)
     return;
 
-  QString aFilter (tr ("Document file (*.xml *)"));
+  QString aFilter (tr ("Document file (*.json *)"));
   QString aSelectedFilter;
   QString aFileName = QFileDialog::getSaveFileName (0, tr ("Export report to file"), QString(), aFilter, &aSelectedFilter);
 
   Handle(Message_Report) aReport = aReportItem->GetReport();
-  if (aReport->MessageWriter().IsNull())
-    aReport->SetMessageWriter (new XmlDrivers_MessageReportStorage());
+  Standard_SStream aStream;
+  aReport->DumpJson(aStream);
 
-  aReport->MessageWriter()->SetFileName (TCollection_AsciiString (aFileName.toStdString().c_str()));
-  aReport->MessageWriter()->ExportReport (aReport);
+  QFile aLogFile(aFileName);
+  if (!aLogFile.open(QFile::WriteOnly | QFile::Text))
+  {
+    return;
+  }
+  QTextStream anOut( &aLogFile );
+  anOut << Standard_Dump::FormatJson (aStream).ToCString();//aStream.str().c_str();
+  aLogFile.close();
 }
 
 // =======================================================================
-// function : onImportReport
+// function : onCreateDefaultReport
 // purpose :
 // =======================================================================
-void MessageView_Window::onImportReport()
+void MessageView_Window::onCreateDefaultReport()
 {
-  QString aFilter (tr ("Document file (*.cbf *)"));
-  QString aSelectedFilter;
-
-  QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
-  aSelectionModel->clear();
+  if (!Message::DefaultReport().IsNull())
+  {
+    return;
+  }
 
-  QString aFileName = QFileDialog::getOpenFileName (0, tr("Import report"), QString(), aSelectedFilter);
-  openFile (TCollection_AsciiString (aFileName.toStdString().c_str()));
+  addReport (Message::DefaultReport (Standard_True));
 }
 
 // =======================================================================
@@ -742,10 +772,13 @@ void MessageView_Window::onPreviewChildren()
 // =======================================================================
 void MessageView_Window::addActivateMetricActions (QMenu* theMenu)
 {
-  QMenu* aSubMenu = new QMenu ("Activate metric");
-
-  Handle(Message_Report) aReport = Message::DefaultReport (Standard_True);
+  Handle(Message_Report) aReport = Message::DefaultReport();
+  if (aReport.IsNull())
+  {
+    return;
+  }
 
+  QMenu* aSubMenu = new QMenu ("Activate metric");
   for (int aMetricId = (int)Message_MetricType_None + 1; aMetricId <= (int)Message_MetricType_MemHeapUsage; aMetricId++)
   {
     Message_MetricType aMetricType = (Message_MetricType)aMetricId;
@@ -773,7 +806,7 @@ void MessageView_Window::OnActivateMetric()
   if (!Message::MetricFromString (anAction->text().toStdString().c_str(), aMetricType))
     return;
 
-  Handle(Message_Report) aReport = Message::DefaultReport (Standard_True);
+  Handle(Message_Report) aReport = Message::DefaultReport();
   const NCollection_Map<Message_MetricType>& anActiveMetrics = aReport->ActiveMetrics();
 
   aReport->SetActiveMetric (aMetricType, !anActiveMetrics.Contains (aMetricType));
@@ -901,9 +934,8 @@ void MessageView_Window::updateVisibleColumns()
     {
       int aColumnId = aMetricColumns[i];
       myTreeView->setColumnHidden (aColumnId, isColumnHidden);
-      TreeModel_HeaderSection aSection = aViewModel->GetHeaderItem (aColumnId);
-      aSection.SetIsHidden (isColumnHidden);
-      aViewModel->SetHeaderItem (aColumnId, aSection);
+      TreeModel_HeaderSection* aSection = aViewModel->ChangeHeaderItem (aColumnId);
+      aSection->SetIsHidden (isColumnHidden);
     }
   }
 }
index dbaf64c6af0b5caf348654dc1bdd04ef42a5993f..bae2ad6fa812efb3056cdc014896a9b8f9136fb4 100644 (file)
@@ -136,14 +136,17 @@ protected slots:
   //! Update tree view item, preview presentation by item value change
   void onPropertyViewDataChanged();
 
+  //! Update tree view header item width
+  void onHeaderResized (int theSectionId, int, int);
+
   //! Updates visibility states by erase all in context
   void onEraseAllPerformed();
 
   //! Export report into document
   void onExportReport();
 
-  //! Import report into document
-  void onImportReport();
+  //! Create default report into document
+  void onCreateDefaultReport();
 
   //! Unite alerts in view model
   //void onUniteAlerts();
index 2c1aac570a025e473e8e59ae5d6d1a8367336f51..f3b29732f20a7c707fa72bc5d003a03228bc85f7 100644 (file)
@@ -128,8 +128,8 @@ int main (int argc, char** argv)
     aPlugins.insert("TKShapeView");
     aPlugins.insert("TKVInspector");
 
-    Handle(Message_Report) aReport = Message::DefaultReport (Standard_True);
-    aReport->SetLimit (100);//30);
+    //Handle(Message_Report) aReport = Message::DefaultReport (Standard_True);
+    //aReport->SetLimit (100);//30);
     aPlugins.insert("TKMessageView");
 
     //anActivatedPluginName = "TKVInspector";
index 9a60792c6098179c2a22a107cb7a7a67559563a7..9cd0d07ab6f9ee4db73fd73848b89a01dc43870d 100644 (file)
@@ -55,7 +55,7 @@ void TreeModel_ContextMenu::onTreeViewHeaderContextMenuRequested (const QPoint&
   int aNbSections = aModel->columnCount();
   for (int aColumnId = 0; aColumnId < aNbSections; aColumnId++)
   {
-    QAction* anAction = ViewControl_Tools::CreateAction (aModel->GetHeaderItem (aColumnId).GetName(),
+    QAction* anAction = ViewControl_Tools::CreateAction (aModel->ChangeHeaderItem (aColumnId)->GetName(),
                                                        SLOT (onColumnVisibilityChanged()), myTreeView, this);
     anAction->setCheckable (true);
     anAction->setChecked (!myTreeView->isColumnHidden (aColumnId));
index 34214396596ca8058ecbcbfb7ff71020c1a89901..5dd4055b7e027ed4f5dae409bc25710dc6509f04 100644 (file)
@@ -47,9 +47,9 @@ TreeModel_ModelBase::TreeModel_ModelBase (QObject* theParent)
 // =======================================================================
 void TreeModel_ModelBase::InitColumns()
 {
-  SetHeaderItem (TreeModel_ColumnType_Name,       TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
-  SetHeaderItem (TreeModel_ColumnType_Visibility, TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth()));
-  SetHeaderItem (TreeModel_ColumnType_Row,        TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH));
+  setHeaderItem (TreeModel_ColumnType_Name,       TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
+  setHeaderItem (TreeModel_ColumnType_Visibility, TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth()));
+  setHeaderItem (TreeModel_ColumnType_Row,        TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH));
 }
 
 // =======================================================================
@@ -178,7 +178,7 @@ QVariant TreeModel_ModelBase::headerData (int theSection, Qt::Orientation theOri
   if (IsUseVisibilityColumn() && theSection == TreeModel_ColumnType_Visibility)
     return QVariant();
 
-  return GetHeaderItem (theSection).GetName();
+  return myHeaderValues[theSection].GetName();
 }
 
 // =======================================================================
@@ -232,23 +232,6 @@ void TreeModel_ModelBase::EmitDataChanged (const QModelIndex& theTopLeft, const
 #endif
 }
 
-// =======================================================================
-// function : SetHeaderItem
-// purpose :
-// =======================================================================
-void TreeModel_ModelBase::SetHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection)
-{
-  if (theSection.IsEmpty())
-  {
-    // remove section
-    myHeaderValues.remove (theColumnId);
-    myRootItems.remove (theColumnId);
-  }
-
-  myHeaderValues[theColumnId] = theSection;
-  createRoot (theColumnId);
-}
-
 // =======================================================================
 // function : Selected
 // purpose :
@@ -339,6 +322,23 @@ void TreeModel_ModelBase::createRoot (const int theColumnId)
   myRootItems.insert (theColumnId, createRootItem (theColumnId));
 }
 
+// =======================================================================
+// function : setHeaderItem
+// purpose :
+// =======================================================================
+void TreeModel_ModelBase::setHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection)
+{
+  if (theSection.IsEmpty())
+  {
+    // remove section
+    myHeaderValues.remove (theColumnId);
+    myRootItems.remove (theColumnId);
+  }
+
+  myHeaderValues[theColumnId] = theSection;
+  createRoot (theColumnId);
+}
+
 // =======================================================================
 // function :  getIndexValue
 // purpose :
index 20b17ae9b3627f7fa2183b83b54d9a63604ba2e7..f616846496b73805883e6973db6aaec092aec256 100644 (file)
@@ -141,12 +141,7 @@ public:
   //! Returns whether the column is hidden by default
   //! \param theColumnId a column index
   //! \return header section values container
-  TreeModel_HeaderSection GetHeaderItem (const int theColumnId) const { return myHeaderValues[theColumnId]; }
-
-  //! Sets header properties item.
-  //! \param theColumnId a column index
-  //! \param theSection a section value
-  Standard_EXPORT void SetHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection);
+  TreeModel_HeaderSection* ChangeHeaderItem (const int theColumnId) { return &myHeaderValues[theColumnId]; }
 
   //! Returns count of columns in the model
   //! \param theParent an index of the parent item
@@ -191,6 +186,11 @@ protected:
   //! \param theColumnId index of a column
   virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) = 0;
 
+  //! Sets header properties item.
+  //! \param theColumnId a column index
+  //! \param theSection a section value
+  Standard_EXPORT void setHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection);
+
   //! Converts the item shared pointer to void* type
   //! \param theItem
   //!  \return an item pointer
index e3d8b2afa54f7d917b1ec5861f55a0e0751314c1..00bc92f59fb3c17048e82883da6d2a777361aa21 100644 (file)
@@ -89,6 +89,7 @@ void TreeModel_Tools::SaveState (QTreeView* theTreeView, QMap<QString, QString>&
   QStringList aColumnWidths, aHiddenColumns;
   for (int aColumnId = 0; aColumnId < theTreeView->model()->columnCount(); aColumnId++)
   {
+    int aWidth = theTreeView->columnWidth (aColumnId);
     if (theTreeView->isColumnHidden (aColumnId))
     {
       aHiddenColumns.append (QString::number (aColumnId));
@@ -121,18 +122,18 @@ bool TreeModel_Tools::RestoreState (QTreeView* theTreeView, const QString& theKe
   }
   else if (theKey == thePrefix + "columns_hidden")
   {
-    int aColumnSize = theTreeView->model()->columnCount();
-    QStringList aValues = theValue.split (",", QString::SkipEmptyParts);
-    QList<int> aColumnIds;
-    for (int aValueId = 0; aValueId < aValues.size(); aValueId++)
-    {
-      if (aValueId < aColumnSize)
-        aColumnIds.append (aValues.at (aValueId).toInt());
-    }
-    for (int aColumnId = 0; aColumnId < aColumnSize; aColumnId++)
-    {
-      theTreeView->setColumnHidden (aColumnId, aColumnIds.contains(aColumnId) == true);
-    }
+    //int aColumnSize = theTreeView->model()->columnCount();
+    //QStringList aValues = theValue.split (",", QString::SkipEmptyParts);
+    //QList<int> aColumnIds;
+    //for (int aValueId = 0; aValueId < aValues.size(); aValueId++)
+    //{
+    //  if (aValueId < aColumnSize)
+    //    aColumnIds.append (aValues.at (aValueId).toInt());
+    //}
+    //for (int aColumnId = 0; aColumnId < aColumnSize; aColumnId++)
+    //{
+    //  theTreeView->setColumnHidden (aColumnId, aColumnIds.contains(aColumnId) == true);
+    //}
   }
   else
     return false;
@@ -149,9 +150,9 @@ void TreeModel_Tools::SetDefaultHeaderSections(QTreeView* theTreeView)
 
   for (int aColumnId = 0, aNbColumns = aTreeModel->columnCount(); aColumnId < aNbColumns; aColumnId++)
   {
-    TreeModel_HeaderSection aSection = aTreeModel->GetHeaderItem (aColumnId);
-    theTreeView->setColumnWidth (aColumnId, aSection.GetWidth());
-    theTreeView->setColumnHidden (aColumnId, aSection.IsHidden());
+    TreeModel_HeaderSection* aSection = aTreeModel->ChangeHeaderItem (aColumnId);
+    theTreeView->setColumnWidth (aColumnId, aSection->GetWidth());
+    theTreeView->setColumnHidden (aColumnId, aSection->IsHidden());
   }
 }
 
@@ -170,8 +171,10 @@ void TreeModel_Tools::UseVisibilityColumn (QTreeView* theTreeView, const bool th
   aHeader->moveSection (TreeModel_ColumnType_Name, TreeModel_ColumnType_Visibility);
 
   TreeModel_ModelBase* aModel = dynamic_cast<TreeModel_ModelBase*> (theTreeView->model());
-  aModel->SetHeaderItem (TreeModel_ColumnType_Visibility,
-    TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth()));
+  TreeModel_HeaderSection* anItem = aModel->ChangeHeaderItem ((int)TreeModel_ColumnType_Visibility);
+  anItem->SetIsHidden (theActive);
+  anItem->SetWidth (TreeModel_ModelBase::ColumnVisibilityWidth());
+
   aModel->SetUseVisibilityColumn (theActive);
 }
 
index 2ca792b334b158835662706cc562885cd7648344..894d0a3ba3087fa9c53402afa0fef4596cc05096 100644 (file)
@@ -43,8 +43,8 @@ void VInspector_ViewModel::InitColumns()
 {
   TreeModel_ModelBase::InitColumns();
 
-  SetHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
-  SetHeaderItem (4, TreeModel_HeaderSection ("SelectedOwners", -1));
+  setHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
+  setHeaderItem (4, TreeModel_HeaderSection ("SelectedOwners", -1));
 }
 
 // =======================================================================
index 980dc1e865890ff6dbfa76424b1c9dcce94b68a1..0b50eca7d8834aadcee893bf1824a82dd31900e8 100644 (file)
@@ -54,13 +54,13 @@ void VInspector_ViewModelHistory::InitColumns()
 {
   TreeModel_ModelBase::InitColumns();
 
-  SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
-  SetHeaderItem (1, TreeModel_HeaderSection ("Visibility", COLUMN_SIZE_WIDTH)); // visualization item
-  SetHeaderItem (2, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
-  SetHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
-  SetHeaderItem (4, TreeModel_HeaderSection ("Shape type", COLUMN_SHAPE_TYPE_WIDTH));
-  SetHeaderItem (5, TreeModel_HeaderSection ("AIS Name", COLUMN_AIS_NAME_WIDTH));
-  SetHeaderItem (6, TreeModel_HeaderSection ("Selected/Highlighted", -1));
+  setHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
+  setHeaderItem (1, TreeModel_HeaderSection ("Visibility", COLUMN_SIZE_WIDTH)); // visualization item
+  setHeaderItem (2, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
+  setHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
+  setHeaderItem (4, TreeModel_HeaderSection ("Shape type", COLUMN_SHAPE_TYPE_WIDTH));
+  setHeaderItem (5, TreeModel_HeaderSection ("AIS Name", COLUMN_AIS_NAME_WIDTH));
+  setHeaderItem (6, TreeModel_HeaderSection ("Selected/Highlighted", -1));
 
   for (int aColumnId = 0, aNbColumns = columnCount(); aColumnId < aNbColumns; aColumnId++)
   {
index 4e76e981135a6031ed7e12d28a1af54d23cfe5eb..163df690dd1c1d596f250aee31427b917fc17110 100644 (file)
@@ -112,9 +112,8 @@ VInspector_Window::VInspector_Window()
   aTreeModel->InitColumns();
   myTreeView->setModel (aTreeModel);
   // hide Visibility column
-  TreeModel_HeaderSection anItem = aTreeModel->GetHeaderItem ((int)TreeModel_ColumnType_Visibility);
-  anItem.SetIsHidden (true);
-  aTreeModel->SetHeaderItem ((int)TreeModel_ColumnType_Visibility, anItem);
+  TreeModel_HeaderSection* anItem = aTreeModel->ChangeHeaderItem ((int)TreeModel_ColumnType_Visibility);
+  anItem->SetIsHidden (true);
 
   connect (myTreeView, SIGNAL(customContextMenuRequested(const QPoint&)),
            this, SLOT (onTreeViewContextMenuRequested(const QPoint&)));
@@ -157,12 +156,11 @@ VInspector_Window::VInspector_Window()
   connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
     this, SLOT (onHistoryViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
 
-  anItem = aHistoryModel->GetHeaderItem (0);
+  anItem = aHistoryModel->ChangeHeaderItem (0);
   // hide Visibility column
   TreeModel_Tools::UseVisibilityColumn (myHistoryView, false);
-  anItem = aHistoryModel->GetHeaderItem ((int)TreeModel_ColumnType_Visibility);
-  anItem.SetIsHidden (true);
-  aHistoryModel->SetHeaderItem ((int)TreeModel_ColumnType_Visibility, anItem);
+  anItem = aHistoryModel->ChangeHeaderItem ((int)TreeModel_ColumnType_Visibility);
+  anItem->SetIsHidden (true);
 
   QModelIndex aParentIndex = myHistoryView->model()->index (0, 0);
   myHistoryView->setExpanded (aParentIndex, true);