1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the test suite of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | #ifndef PatternistSDK_TreeItem_H |
30 | #define PatternistSDK_TreeItem_H |
31 | |
32 | #include <QObject> |
33 | |
34 | #include "Global.h" |
35 | |
36 | QT_BEGIN_NAMESPACE |
37 | |
38 | class QVariant; |
39 | template<typename T> class QList; |
40 | template<typename T> class QPointer; |
41 | |
42 | namespace QPatternistSDK |
43 | { |
44 | /** |
45 | * @short TreeItem is a node in a hierachial structure and is used together |
46 | * with TreeModel. |
47 | * |
48 | * TreeItem is abstract base class. Instances of sub-classes of TreeItem |
49 | * can be used with TreeModel in order to use hierarchial data in Qt's |
50 | * model/view framework. |
51 | * |
52 | * TreeItem is a QObject in order to be able to be used with QPointer. |
53 | * |
54 | * @author Frans Englich <frans.englich@nokia.com> |
55 | * @see TreeModel |
56 | * @ingroup PatternistSDK |
57 | */ |
58 | class TreeItem : public QObject |
59 | { |
60 | Q_OBJECT |
61 | public: |
62 | typedef QList<QPointer<TreeItem> > List; |
63 | |
64 | virtual ~TreeItem() {} |
65 | virtual void appendChild(TreeItem *item) = 0; |
66 | virtual TreeItem *child(const unsigned int row) const = 0; |
67 | virtual unsigned int childCount() const = 0; |
68 | virtual TreeItem *parent() const = 0; |
69 | |
70 | virtual TreeItem::List children() const = 0; |
71 | virtual int columnCount() const = 0; |
72 | |
73 | /** |
74 | * Determines the position among the children of |
75 | * this TreeItem's parent. This is done by introspecting the result |
76 | * of children(). |
77 | */ |
78 | int row() const; |
79 | |
80 | virtual QVariant data(const Qt::ItemDataRole role, int column) const = 0; |
81 | |
82 | static QPair<int,int> executeRange; |
83 | static int executions; |
84 | |
85 | Q_SIGNALS: |
86 | /** |
87 | * Emitted whenever this item changed. This is used for keeping |
88 | * views in synchronization with the item model which houses |
89 | * this item. |
90 | * |
91 | * @param item the item which changed. That is, this TreeItem. |
92 | */ |
93 | void changed(TreeItem *item); |
94 | }; |
95 | } |
96 | |
97 | QT_END_NAMESPACE |
98 | |
99 | #endif |
100 | // vim: et:ts=4:sw=4:sts=4 |
101 | |