0031939: Coding - correction of spelling errors in comments [part 2]
[occt.git] / tools / VInspector / VInspector_ItemHistoryType.cxx
CommitLineData
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// =======================================================================
27QString 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());
7e1c1e48 34 if (aTypeInfo.myElements.size() < rowCount())
35 return QString();
14bbbdcb 36 QList<QVariant> anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item
37 return anElements.size() > 1 ? anElements[1].toString() : QString();
38}
39
40// =======================================================================
41// function : PointerInfo
42// purpose :
43// =======================================================================
44QString VInspector_ItemHistoryType::OwnerInfo() const
45{
46 if (rowCount() <= 0)
47 return QString();
48
49 VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
50 const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
7e1c1e48 51 if ( aTypeInfo.myElements.size() < rowCount())
52 return QString();
14bbbdcb 53 QList<QVariant> anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item
54 return anElements.size() > 3 ? anElements[3].toString() : QString();
55}
56
57// =======================================================================
58// function : data
59// purpose :
60// =======================================================================
61QVariant VInspector_ItemHistoryType::initValue(const int theRole) const
62{
7e1c1e48 63 QVariant aParentValue = VInspector_ItemBase::initValue (theRole);
64 if (aParentValue.isValid())
65 return aParentValue;
66
14bbbdcb 67 if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
68 return QVariant();
69
70 VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
71 const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
7e1c1e48 72 int aRowCount = rowCount();
73 if (aRowCount <= 0 || aTypeInfo.myElements.size() < aRowCount)
74 return QVariant();
75
14bbbdcb 76 QList<QVariant> anElements = rowCount() > 0 ? aTypeInfo.myElements[rowCount() - 1] : QList<QVariant>(); // the last item
77 int anInfoSize = anElements.size();
78 switch (Column())
79 {
80 case 0: return VInspector_CallBack::GetInfo(aTypeInfo.myMode);
7e1c1e48 81 case 3: return rowCount();
82 case 4: return anInfoSize > 1 ? anElements[1].toString() : QVariant(); // pointer info
83 case 5: return anInfoSize > 2 ? anElements[2].toString() : QVariant(); // shape type
84 case 6: return anInfoSize > 0 ? anElements[0].toString() : QVariant(); // AIS name
85 case 7: return anInfoSize > 3 ? anElements[3].toString() : QVariant(); // owner info
14bbbdcb 86 default: break;
87 }
88 return QVariant();
89}
90
91// =======================================================================
92// function : rowCount
93// purpose :
94// =======================================================================
95int VInspector_ItemHistoryType::initRowCount() const
96{
97 VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
98 const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
99 return aTypeInfo.myElements.size();
100}
101
102// =======================================================================
103// function : createChild
104// purpose :
105// =======================================================================
106TreeModel_ItemBasePtr VInspector_ItemHistoryType::createChild (int theRow, int theColumn)
107{
108 return VInspector_ItemHistoryElement::CreateItem (currentItem(), theRow, theColumn);
109}
110
111// =======================================================================
112// function : initItem
113// purpose :
114// =======================================================================
115void VInspector_ItemHistoryType::initItem() const
116{
117 if (IsInitialized())
118 return;
119 const_cast<VInspector_ItemHistoryType*>(this)->Init();
120 // an empty method to don't initialize the main label, as it was not cleared in Reset()
121}