1 | /* $Id: UIDetailsItem.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIDetailsItem class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef FEQT_INCLUDED_SRC_manager_details_UIDetailsItem_h
|
---|
29 | #define FEQT_INCLUDED_SRC_manager_details_UIDetailsItem_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes */
|
---|
35 | #include <QUuid>
|
---|
36 |
|
---|
37 | /* GUI includes: */
|
---|
38 | #include "QIGraphicsWidget.h"
|
---|
39 | #include "QIWithRetranslateUI.h"
|
---|
40 |
|
---|
41 | /* Forward declaration: */
|
---|
42 | class QGraphicsSceneHoverEvent;
|
---|
43 | class QGraphicsSceneMouseEvent;
|
---|
44 | class UIDetailsElement;
|
---|
45 | class UIDetailsGroup;
|
---|
46 | class UIDetailsModel;
|
---|
47 | class UIDetailsSet;
|
---|
48 |
|
---|
49 |
|
---|
50 | /** UIDetailsItem types. */
|
---|
51 | enum UIDetailsItemType
|
---|
52 | {
|
---|
53 | UIDetailsItemType_Any = QGraphicsItem::UserType,
|
---|
54 | UIDetailsItemType_Group,
|
---|
55 | UIDetailsItemType_Set,
|
---|
56 | UIDetailsItemType_Element,
|
---|
57 | UIDetailsItemType_Preview
|
---|
58 | };
|
---|
59 |
|
---|
60 |
|
---|
61 | /** QIGraphicsWidget extension used as interface
|
---|
62 | * for graphics details model/view architecture. */
|
---|
63 | class UIDetailsItem : public QIWithRetranslateUI4<QIGraphicsWidget>
|
---|
64 | {
|
---|
65 | Q_OBJECT;
|
---|
66 |
|
---|
67 | signals:
|
---|
68 |
|
---|
69 | /** @name Item stuff.
|
---|
70 | * @{ */
|
---|
71 | /** Notifies listeners about step build should be started.
|
---|
72 | * @param uStepId Brings the step ID.
|
---|
73 | * @param iStepNumber Brings the step number. */
|
---|
74 | void sigBuildStep(const QUuid &uStepId, int iStepNumber);
|
---|
75 | /** Notifies listeners about step build complete. */
|
---|
76 | void sigBuildDone();
|
---|
77 | /** @} */
|
---|
78 |
|
---|
79 | public:
|
---|
80 |
|
---|
81 | /** Constructs item passing @a pParent to the base-class. */
|
---|
82 | UIDetailsItem(UIDetailsItem *pParent);
|
---|
83 |
|
---|
84 | /** @name Item stuff.
|
---|
85 | * @{ */
|
---|
86 | /** Returns parent reference. */
|
---|
87 | UIDetailsItem *parentItem() const { return m_pParent; }
|
---|
88 |
|
---|
89 | /** Casts item to group one. */
|
---|
90 | UIDetailsGroup *toGroup();
|
---|
91 | /** Casts item to set one. */
|
---|
92 | UIDetailsSet *toSet();
|
---|
93 | /** Casts item to element one. */
|
---|
94 | UIDetailsElement *toElement();
|
---|
95 |
|
---|
96 | /** Returns model reference. */
|
---|
97 | UIDetailsModel *model() const;
|
---|
98 |
|
---|
99 | /** Returns the description of the item. */
|
---|
100 | virtual QString description() const = 0;
|
---|
101 |
|
---|
102 | /** Installs event-filter for @a pSource object.
|
---|
103 | * @note Base-class implementation does nothing. */
|
---|
104 | virtual void installEventFilterHelper(QObject *pSource) { Q_UNUSED(pSource); }
|
---|
105 | /** @} */
|
---|
106 |
|
---|
107 | /** @name Children stuff.
|
---|
108 | * @{ */
|
---|
109 | /** Adds child @a pItem. */
|
---|
110 | virtual void addItem(UIDetailsItem *pItem) = 0;
|
---|
111 | /** Removes child @a pItem. */
|
---|
112 | virtual void removeItem(UIDetailsItem *pItem) = 0;
|
---|
113 |
|
---|
114 | /** Returns children items of certain @a enmType. */
|
---|
115 | virtual QList<UIDetailsItem*> items(UIDetailsItemType enmType = UIDetailsItemType_Any) const = 0;
|
---|
116 | /** Returns whether there are children items of certain @a enmType. */
|
---|
117 | virtual bool hasItems(UIDetailsItemType enmType = UIDetailsItemType_Any) const = 0;
|
---|
118 | /** Clears children items of certain @a enmType. */
|
---|
119 | virtual void clearItems(UIDetailsItemType enmType = UIDetailsItemType_Any) = 0;
|
---|
120 | /** @} */
|
---|
121 |
|
---|
122 | /** @name Layout stuff.
|
---|
123 | * @{ */
|
---|
124 | /** Updates geometry. */
|
---|
125 | virtual void updateGeometry() RT_OVERRIDE;
|
---|
126 |
|
---|
127 | /** Updates layout. */
|
---|
128 | virtual void updateLayout() = 0;
|
---|
129 |
|
---|
130 | /** Returns minimum width-hint. */
|
---|
131 | virtual int minimumWidthHint() const = 0;
|
---|
132 | /** Returns minimum height-hint. */
|
---|
133 | virtual int minimumHeightHint() const = 0;
|
---|
134 |
|
---|
135 | /** Returns size-hint.
|
---|
136 | * @param enmWhich Brings size-hint type.
|
---|
137 | * @param constraint Brings size constraint. */
|
---|
138 | virtual QSizeF sizeHint(Qt::SizeHint enmWhich, const QSizeF &constraint = QSizeF()) const RT_OVERRIDE;
|
---|
139 | /** @} */
|
---|
140 |
|
---|
141 | public slots:
|
---|
142 |
|
---|
143 | /** @name Item stuff.
|
---|
144 | * @{ */
|
---|
145 | /** Handles request about starting step build.
|
---|
146 | * @param uStepId Brings the step ID.
|
---|
147 | * @param iStepNumber Brings the step number. */
|
---|
148 | /** @} */
|
---|
149 | virtual void sltBuildStep(const QUuid &uStepId, int iStepNumber);
|
---|
150 |
|
---|
151 | protected:
|
---|
152 |
|
---|
153 | /** @name Event-handling stuff.
|
---|
154 | * @{ */
|
---|
155 | /** Handles translation event. */
|
---|
156 | virtual void retranslateUi() RT_OVERRIDE {}
|
---|
157 | /** @} */
|
---|
158 |
|
---|
159 | private:
|
---|
160 |
|
---|
161 | /** Holds the parent item reference. */
|
---|
162 | UIDetailsItem *m_pParent;
|
---|
163 | };
|
---|
164 |
|
---|
165 |
|
---|
166 | /** QObject extension used to prepare details steps. */
|
---|
167 | class UIPrepareStep : public QObject
|
---|
168 | {
|
---|
169 | Q_OBJECT;
|
---|
170 |
|
---|
171 | signals:
|
---|
172 |
|
---|
173 | /** Notifies listeners about step preparing is complete.
|
---|
174 | * @param strStepId Brings the step ID.
|
---|
175 | * @param iStepNumber Brings the step number. */
|
---|
176 | void sigStepDone(const QUuid& aStepId, int iStepNumber);
|
---|
177 |
|
---|
178 | public:
|
---|
179 |
|
---|
180 | /** Constructs step preparing object passing @a pParent to the base-class.
|
---|
181 | * @param pBuildObject Brings the build object reference.
|
---|
182 | * @param uStepId Brings the step ID.
|
---|
183 | * @param iStepNumber Brings the step number.*/
|
---|
184 | UIPrepareStep(QObject *pParent, QObject *pBuildObject, const QUuid &uStepId, int iStepNumber);
|
---|
185 |
|
---|
186 | private slots:
|
---|
187 |
|
---|
188 | /** Handles step prepare completion. */
|
---|
189 | void sltStepDone();
|
---|
190 |
|
---|
191 | private:
|
---|
192 |
|
---|
193 | /** Holds the step ID. */
|
---|
194 | QUuid m_uStepId;
|
---|
195 | /** Holds the step number. */
|
---|
196 | int m_iStepNumber;
|
---|
197 | };
|
---|
198 |
|
---|
199 |
|
---|
200 | #endif /* !FEQT_INCLUDED_SRC_manager_details_UIDetailsItem_h */
|
---|