0030268: Inspectors - improvements in VInspector plugin
[occt.git] / tools / ViewControl / ViewControl_TableModel.cxx
CommitLineData
7e1c1e48 1// Created on: 2020-01-25
2// Created by: Natalia ERMOLAEVA
3// Copyright (c) 2020 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/ViewControl_TableModel.hxx>
17
18// =======================================================================
19// function : SetModelValues
20// purpose :
21// =======================================================================
22void ViewControl_TableModel::SetModelValues (ViewControl_TableModelValues* theModelValues)
23{
24 if (myModelValues)
25 delete myModelValues;
26
27 myModelValues = theModelValues;
28}
29
30// =======================================================================
31// function : columnCount
32// purpose :
33// =======================================================================
34int ViewControl_TableModel::columnCount(const QModelIndex& theParent) const
35{
36 if (!myModelValues)
37 return 0;
38
39 return myModelValues->ColumnCount (theParent);
40}
41
42// =======================================================================
43// function : rowCount
44// purpose :
45// =======================================================================
46int ViewControl_TableModel::rowCount(const QModelIndex& theParent ) const
47{
48 if (!myModelValues)
49 return 0;
50
51 return myModelValues->RowCount (theParent);
52}
53
54// =======================================================================
55// function : data
56// purpose :
57// =======================================================================
58QVariant ViewControl_TableModel::data (const QModelIndex& theIndex, int theRole) const
59{
60 if (!myModelValues)
61 return QVariant();
62
63 int aRow = theIndex.row(), aColumn = theIndex.column();
64 return myModelValues->Data (aRow, aColumn, theRole);
65}
66
67// =======================================================================
68// function : setData
69// purpose :
70// =======================================================================
71bool ViewControl_TableModel::setData (const QModelIndex& theIndex, const QVariant& theValue, int theRole)
72{
73 if (!myModelValues)
74 return false;
75
76 int aRow = theIndex.row(), aColumn = theIndex.column();
77 bool aResult = myModelValues->SetData (aRow, aColumn, theValue, theRole);
78
79 emit dataChanged (theIndex, theIndex);
80
81 return aResult;
82}