1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <inspector/DFBrowser_TreeLevelLineModel.hxx>
18 #include <inspector/DFBrowser_ItemBase.hxx>
19 #include <inspector/TreeModel_ModelBase.hxx>
21 #include <Standard_WarningsDisable.hxx>
24 #include <Standard_WarningsRestore.hxx>
26 // =======================================================================
29 // =======================================================================
30 void DFBrowser_TreeLevelLineModel::Init (const QModelIndex& theTreeIndex)
32 myTreeIndex = theTreeIndex;
35 if (theTreeIndex.isValid())
37 myLevelItems.prepend (theTreeIndex);
38 QModelIndex aParent = theTreeIndex.parent();
39 while (aParent.isValid())
41 myLevelItems.prepend (aParent);
42 aParent = aParent.parent();
48 // =======================================================================
51 // =======================================================================
52 QVariant DFBrowser_TreeLevelLineModel::data (const QModelIndex& theIndex, int theRole) const
55 int aColumns = theIndex.column();
56 if (aColumns < myLevelItems.size())
58 QModelIndex aTreeIndex = myLevelItems[aColumns];
59 if (theRole == Qt::DecorationRole) //! do not show icons presented in tree view
61 TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (aTreeIndex);
65 DFBrowser_ItemBasePtr aDBrowserItem = itemDynamicCast<DFBrowser_ItemBase> (anItemBase);
69 bool aPrevValue = aDBrowserItem->SetUseAdditionalInfo (false);
70 aValue = aDBrowserItem->data (aTreeIndex, theRole);
71 aDBrowserItem->SetUseAdditionalInfo (aPrevValue);
73 if (theRole == Qt::DisplayRole)
74 aValue = aValue.toString() + " "; //! TEMPORARY to leave place for the action icon
79 // =======================================================================
80 // function : headerData
82 // =======================================================================
83 QVariant DFBrowser_TreeLevelLineModel::headerData (int theSection, Qt::Orientation theOrientation, int theRole) const
86 if (theOrientation == Qt::Horizontal && theSection < myLevelItems.size())
88 QModelIndex aTreeIndex = myLevelItems[theSection];
89 if (!aTreeIndex.isValid()) // level change action
91 if (theRole == Qt::SizeHintRole)
92 aValue = QSize (2, 2);
93 else if (theRole == Qt::DisplayRole)