0029807: [Regression to 7.0.0] Impossible to cut cone from prism
[occt.git] / tools / VInspector / VInspector_ItemFolderObject.cxx
CommitLineData
6822a3be 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
16#include <inspector/VInspector_ItemFolderObject.hxx>
17
18#include <inspector/VInspector_ItemContext.hxx>
19#include <inspector/VInspector_ItemSelectMgrFilter.hxx>
20
21// =======================================================================
22// function : initValue
23// purpose :
24// =======================================================================
25QVariant VInspector_ItemFolderObject::initValue (int theItemRole) const
26{
27 if (Column() == 0 && (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole))
28 {
29 if (parentItemIsContext()) return "Properties";
30 else if (Row() == 0) return "Filters";
31 else return QVariant();
32 }
33 return QVariant();
34}
35
36// =======================================================================
37// function : initRowCount
38// purpose :
39// =======================================================================
40int VInspector_ItemFolderObject::initRowCount() const
41{
42 return parentItemIsContext() ? 1 : (GetContext().IsNull() ? 0 : GetContext()->Filters().Extent());
43}
44
45// =======================================================================
46// function : createChild
47// purpose :
48// =======================================================================
49TreeModel_ItemBasePtr VInspector_ItemFolderObject::createChild (int theRow, int theColumn)
50{
51 if (parentItemIsContext())
52 return VInspector_ItemFolderObject::CreateItem (currentItem(), theRow, theColumn);
53 else
54 return VInspector_ItemSelectMgrFilter::CreateItem (currentItem(), theRow, theColumn);
55}
56
57// =======================================================================
58// function : Init
59// purpose :
60// =======================================================================
61void VInspector_ItemFolderObject::Init()
62{
63 TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
64}
65
66// =======================================================================
67// function : Reset
68// purpose :
69// =======================================================================
70void VInspector_ItemFolderObject::Reset()
71{
72 VInspector_ItemBase::Reset();
73}
74
75// =======================================================================
76// function : initItem
77// purpose :
78// =======================================================================
79void VInspector_ItemFolderObject::initItem() const
80{
81 if (IsInitialized())
82 return;
83 const_cast<VInspector_ItemFolderObject*> (this)->Init();
84}
85
86// =======================================================================
87// function : parentItemIsContext
88// purpose :
89// =======================================================================
90bool VInspector_ItemFolderObject::parentItemIsContext() const
91{
92 return itemDynamicCast<VInspector_ItemContext> (Parent());
93}