summaryrefslogtreecommitdiff
path: root/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsItem.h
blob: 38257b16f5458b3bfba1255ffc3a4ceb2dfd6710 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/* $Id$ */
/** @file
 * VBox Qt GUI - UIDetailsItem class declaration.
 */

/*
 * Copyright (C) 2012-2022 Oracle and/or its affiliates.
 *
 * This file is part of VirtualBox base platform packages, as
 * available from https://www.virtualbox.org.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, in version 3 of the
 * License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <https://www.gnu.org/licenses>.
 *
 * SPDX-License-Identifier: GPL-3.0-only
 */

#ifndef FEQT_INCLUDED_SRC_manager_details_UIDetailsItem_h
#define FEQT_INCLUDED_SRC_manager_details_UIDetailsItem_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif

/* Qt includes */
#include <QUuid>

/* GUI includes: */
#include "QIGraphicsWidget.h"
#include "QIWithRetranslateUI.h"

/* Forward declaration: */
class QGraphicsSceneHoverEvent;
class QGraphicsSceneMouseEvent;
class UIDetailsElement;
class UIDetailsGroup;
class UIDetailsModel;
class UIDetailsSet;


/** UIDetailsItem types. */
enum UIDetailsItemType
{
    UIDetailsItemType_Any     = QGraphicsItem::UserType,
    UIDetailsItemType_Group,
    UIDetailsItemType_Set,
    UIDetailsItemType_Element,
    UIDetailsItemType_Preview
};


/** QIGraphicsWidget extension used as interface
  * for graphics details model/view architecture. */
class UIDetailsItem : public QIWithRetranslateUI4<QIGraphicsWidget>
{
    Q_OBJECT;

signals:

    /** @name Item stuff.
      * @{ */
        /** Notifies listeners about step build should be started.
          * @param  uStepId    Brings the step ID.
          * @param  iStepNumber  Brings the step number. */
        void sigBuildStep(const QUuid &uStepId, int iStepNumber);
        /** Notifies listeners about step build complete. */
        void sigBuildDone();
    /** @} */

public:

    /** Constructs item passing @a pParent to the base-class. */
    UIDetailsItem(UIDetailsItem *pParent);

    /** @name Item stuff.
      * @{ */
        /** Returns parent  reference. */
        UIDetailsItem *parentItem() const { return m_pParent; }

        /** Casts item to group one. */
        UIDetailsGroup *toGroup();
        /** Casts item to set one. */
        UIDetailsSet *toSet();
        /** Casts item to element one. */
        UIDetailsElement *toElement();

        /** Returns model reference. */
        UIDetailsModel *model() const;

        /** Returns the description of the item. */
        virtual QString description() const = 0;

        /** Installs event-filter for @a pSource object.
          * @note  Base-class implementation does nothing. */
        virtual void installEventFilterHelper(QObject *pSource) { Q_UNUSED(pSource); }
    /** @} */

    /** @name Children stuff.
      * @{ */
        /** Adds child @a pItem. */
        virtual void addItem(UIDetailsItem *pItem) = 0;
        /** Removes child @a pItem. */
        virtual void removeItem(UIDetailsItem *pItem) = 0;

        /** Returns children items of certain @a enmType. */
        virtual QList<UIDetailsItem*> items(UIDetailsItemType enmType = UIDetailsItemType_Any) const = 0;
        /** Returns whether there are children items of certain @a enmType. */
        virtual bool hasItems(UIDetailsItemType enmType = UIDetailsItemType_Any) const = 0;
        /** Clears children items of certain @a enmType. */
        virtual void clearItems(UIDetailsItemType enmType = UIDetailsItemType_Any) = 0;
    /** @} */

    /** @name Layout stuff.
      * @{ */
        /** Updates geometry. */
        virtual void updateGeometry() RT_OVERRIDE;

        /** Updates layout. */
        virtual void updateLayout() = 0;

        /** Returns minimum width-hint. */
        virtual int minimumWidthHint() const = 0;
        /** Returns minimum height-hint. */
        virtual int minimumHeightHint() const = 0;

        /** Returns size-hint.
          * @param  enmWhich    Brings size-hint type.
          * @param  constraint  Brings size constraint. */
        virtual QSizeF sizeHint(Qt::SizeHint enmWhich, const QSizeF &constraint = QSizeF()) const RT_OVERRIDE;
    /** @} */

public slots:

    /** @name Item stuff.
      * @{ */
        /** Handles request about starting step build.
          * @param  uStepId    Brings the step ID.
          * @param  iStepNumber  Brings the step number. */
    /** @} */
    virtual void sltBuildStep(const QUuid &uStepId, int iStepNumber);

protected:

    /** @name Event-handling stuff.
      * @{ */
        /** Handles translation event. */
        virtual void retranslateUi() RT_OVERRIDE {}
    /** @} */

private:

    /** Holds the parent item reference. */
    UIDetailsItem *m_pParent;
};


/** QObject extension used to prepare details steps. */
class UIPrepareStep : public QObject
{
    Q_OBJECT;

signals:

    /** Notifies listeners about step preparing is complete.
      * @param  strStepId    Brings the step ID.
      * @param  iStepNumber  Brings the step number. */
    void sigStepDone(const QUuid& aStepId, int iStepNumber);

public:

    /** Constructs step preparing object passing @a pParent to the base-class.
      * @param  pBuildObject  Brings the build object reference.
      * @param  uStepId       Brings the step ID.
      * @param  iStepNumber   Brings the step number.*/
    UIPrepareStep(QObject *pParent, QObject *pBuildObject, const QUuid &uStepId, int iStepNumber);

private slots:

    /** Handles step prepare completion. */
    void sltStepDone();

private:

    /** Holds the step ID. */
    QUuid  m_uStepId;
    /** Holds the step number. */
    int    m_iStepNumber;
};


#endif /* !FEQT_INCLUDED_SRC_manager_details_UIDetailsItem_h */