1 // copyright (c) 2017-2021 hors<horsicq@gmail.com>
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 
10 // The above copyright notice and this permission notice shall be included in all
11 // copies or substantial portions of the Software.
12 
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 //
21 #include "staticscanitem.h"
22 
StaticScanItem(const QString & sString,StaticScanItem * pParentItem,int nNumberOfColumns)23 StaticScanItem::StaticScanItem(const QString &sString, StaticScanItem *pParentItem, int nNumberOfColumns)
24 {
25     this->g_pParentItem=pParentItem;
26     this->g_sString=sString;
27     this->g_nNumberOfColumns=nNumberOfColumns;
28 }
29 
~StaticScanItem()30 StaticScanItem::~StaticScanItem()
31 {
32     qDeleteAll(g_listChildItems);
33 }
34 
appendChild(StaticScanItem * pChild)35 void StaticScanItem::appendChild(StaticScanItem *pChild)
36 {
37     g_listChildItems.append(pChild);
38 }
39 
child(int nRow)40 StaticScanItem *StaticScanItem::child(int nRow)
41 {
42     return g_listChildItems.value(nRow);
43 }
44 
childCount() const45 int StaticScanItem::childCount() const
46 {
47     return g_listChildItems.count();
48 }
49 
columnCount() const50 int StaticScanItem::columnCount() const
51 {
52     return g_nNumberOfColumns;
53 }
54 
data(int nColumn) const55 QVariant StaticScanItem::data(int nColumn) const
56 {
57     QVariant result;
58 
59     if(nColumn==0)
60     {
61         result=g_sString;
62     }
63 
64     return result;
65 }
66 
setScanStruct(const SpecAbstract::SCAN_STRUCT & scanStruct)67 void StaticScanItem::setScanStruct(const SpecAbstract::SCAN_STRUCT &scanStruct)
68 {
69     this->g_scanStruct=scanStruct;
70 }
71 
scanStruct() const72 SpecAbstract::SCAN_STRUCT StaticScanItem::scanStruct() const
73 {
74     return g_scanStruct;
75 }
76 
row() const77 int StaticScanItem::row() const
78 {
79     int nResult=0;
80 
81     if(g_pParentItem)
82     {
83         nResult=g_pParentItem->g_listChildItems.indexOf(const_cast<StaticScanItem*>(this));
84     }
85 
86     return nResult;
87 }
88 
parentItem()89 StaticScanItem *StaticScanItem::parentItem()
90 {
91     return g_pParentItem;
92 }
93