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/VInspector_ViewModelHistory.hxx>
18 #include <inspector/VInspector_ItemHistoryElement.hxx>
19 #include <inspector/VInspector_ItemHistoryRoot.hxx>
20 #include <inspector/VInspector_ItemHistoryType.hxx>
22 #include <QStringList>
24 // =======================================================================
25 // function : Constructor
27 // =======================================================================
28 VInspector_ViewModelHistory::VInspector_ViewModelHistory (QObject* theParent, const int theHistoryTypesMaxAmount)
29 : TreeModel_ModelBase (theParent)
31 for (int aColumnId = 0, aNbColumns = columnCount(); aColumnId < aNbColumns; aColumnId++)
33 myRootItems.insert(aColumnId, VInspector_ItemHistoryRoot::CreateItem(TreeModel_ItemBasePtr(), 0, aColumnId));
34 VInspector_ItemHistoryRootPtr aRootItem = itemDynamicCast<VInspector_ItemHistoryRoot>(myRootItems[aColumnId]);
35 aRootItem->SetHistoryTypesMaxAmount(theHistoryTypesMaxAmount);
37 m_pRootItem = myRootItems[0];
40 // =======================================================================
41 // function : AddElement
43 // =======================================================================
44 void VInspector_ViewModelHistory::AddElement (const VInspector_CallBackMode& theMode, const QList<QVariant>& theInfo)
46 // fill root item by the application
47 for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++)
49 VInspector_ItemHistoryRootPtr aRootItem = itemDynamicCast<VInspector_ItemHistoryRoot>(myRootItems[aColId]);
50 aRootItem->AddElement(theMode, theInfo);
56 // =======================================================================
57 // function : GetSelectedPointers
59 // =======================================================================
60 QStringList VInspector_ViewModelHistory::GetSelectedPointers (const QModelIndex& theIndex)
62 QStringList aPointers;
63 TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (theIndex);
67 VInspector_ItemHistoryTypePtr aHistoryItem = itemDynamicCast<VInspector_ItemHistoryType>(anItem);
70 QString aPointerInfo = aHistoryItem->PointerInfo();
71 QString anOwnerInfo = aHistoryItem->OwnerInfo();
73 if (!aPointerInfo.isEmpty())
74 aPointers.append (aPointerInfo);
75 if (!anOwnerInfo.isEmpty())
76 aPointers.append (anOwnerInfo.split (", "));
80 VInspector_ItemHistoryElementPtr anElementItem = itemDynamicCast<VInspector_ItemHistoryElement>(anItem);
83 QString aPointerInfo = anElementItem->PointerInfo();
84 if (!aPointerInfo.isEmpty())
85 aPointers.append (aPointerInfo);
91 // =======================================================================
92 // function : headerData
94 // =======================================================================
95 QVariant VInspector_ViewModelHistory::headerData (int theSection, Qt::Orientation theOrientation, int theRole) const
97 if (theOrientation != Qt::Horizontal || theRole != Qt::DisplayRole)
102 case 0: return "Name";
103 case 1: return "Size";
104 case 2: return "Pointer";
105 case 3: return "Shape type";
106 case 4: return "AIS Name";
107 case 5: return "Selected/Highlighted";