14bbbdcb |
1 | // Created on: 2017-06-16 |
2 | // Created by: Natalia ERMOLAEVA |
3 | // Copyright (c) 2017 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
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. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
0cb512c0 |
16 | #include <inspector/VInspector_ItemHistoryType.hxx> |
14bbbdcb |
17 | |
0cb512c0 |
18 | #include <inspector/VInspector_CallBack.hxx> |
19 | #include <inspector/VInspector_ItemHistoryRoot.hxx> |
20 | #include <inspector/VInspector_ItemHistoryElement.hxx> |
21 | #include <inspector/VInspector_Tools.hxx> |
14bbbdcb |
22 | |
23 | // ======================================================================= |
24 | // function : PointerInfo |
25 | // purpose : |
26 | // ======================================================================= |
27 | QString VInspector_ItemHistoryType::PointerInfo() const |
28 | { |
29 | if (rowCount() <= 0) |
30 | return QString(); |
31 | |
32 | VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent()); |
33 | const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row()); |
34 | QList<QVariant> anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item |
35 | return anElements.size() > 1 ? anElements[1].toString() : QString(); |
36 | } |
37 | |
38 | // ======================================================================= |
39 | // function : PointerInfo |
40 | // purpose : |
41 | // ======================================================================= |
42 | QString VInspector_ItemHistoryType::OwnerInfo() const |
43 | { |
44 | if (rowCount() <= 0) |
45 | return QString(); |
46 | |
47 | VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent()); |
48 | const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row()); |
49 | QList<QVariant> anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item |
50 | return anElements.size() > 3 ? anElements[3].toString() : QString(); |
51 | } |
52 | |
53 | // ======================================================================= |
54 | // function : data |
55 | // purpose : |
56 | // ======================================================================= |
57 | QVariant VInspector_ItemHistoryType::initValue(const int theRole) const |
58 | { |
59 | if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole) |
60 | return QVariant(); |
61 | |
62 | VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent()); |
63 | const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row()); |
64 | QList<QVariant> anElements = rowCount() > 0 ? aTypeInfo.myElements[rowCount() - 1] : QList<QVariant>(); // the last item |
65 | int anInfoSize = anElements.size(); |
66 | switch (Column()) |
67 | { |
68 | case 0: return VInspector_CallBack::GetInfo(aTypeInfo.myMode); |
69 | case 1: return rowCount(); |
70 | case 2: return anInfoSize > 1 ? anElements[1].toString() : QVariant(); // pointer info |
71 | case 3: return anInfoSize > 2 ? anElements[2].toString() : QVariant(); // shape type |
72 | case 4: return anInfoSize > 0 ? anElements[0].toString() : QVariant(); // AIS name |
73 | case 5: return anInfoSize > 3 ? anElements[3].toString() : QVariant(); // owner info |
74 | default: break; |
75 | } |
76 | return QVariant(); |
77 | } |
78 | |
79 | // ======================================================================= |
80 | // function : rowCount |
81 | // purpose : |
82 | // ======================================================================= |
83 | int VInspector_ItemHistoryType::initRowCount() const |
84 | { |
85 | VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent()); |
86 | const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row()); |
87 | return aTypeInfo.myElements.size(); |
88 | } |
89 | |
90 | // ======================================================================= |
91 | // function : createChild |
92 | // purpose : |
93 | // ======================================================================= |
94 | TreeModel_ItemBasePtr VInspector_ItemHistoryType::createChild (int theRow, int theColumn) |
95 | { |
96 | return VInspector_ItemHistoryElement::CreateItem (currentItem(), theRow, theColumn); |
97 | } |
98 | |
99 | // ======================================================================= |
100 | // function : initItem |
101 | // purpose : |
102 | // ======================================================================= |
103 | void VInspector_ItemHistoryType::initItem() const |
104 | { |
105 | if (IsInitialized()) |
106 | return; |
107 | const_cast<VInspector_ItemHistoryType*>(this)->Init(); |
108 | // an empty method to don't initialize the main label, as it was not cleared in Reset() |
109 | } |