VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNode.h

Last change on this file was 106061, checked in by vboxsync, 4 weeks ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
Line 
1/* $Id: UIChooserNode.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIChooserNode class declaration.
4 */
5
6/*
7 * Copyright (C) 2012-2024 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_chooser_UIChooserNode_h
29#define FEQT_INCLUDED_SRC_manager_chooser_UIChooserNode_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QObject>
36#include <QPointer>
37#include <QString>
38
39/* GUI includes: */
40#include "UIChooserDefs.h"
41#include "UIChooserItem.h"
42
43/* Forward declaration: */
44class UIChooserAbstractModel;
45class UIChooserNodeGroup;
46class UIChooserNodeGlobal;
47class UIChooserNodeMachine;
48
49
50/** QObject subclass used as interface for invisible tree-view nodes.
51 * These nodes can be of three types (group, global and machine node).
52 * They can be used to compose a tree of nodes loaded from VBox setting. */
53class UIChooserNode : public QObject
54{
55 Q_OBJECT;
56
57public:
58
59 /** Constructs chooser node passing @a pParent to the base-class.
60 * @param fFavorite Brings whether the node is favorite. */
61 UIChooserNode(UIChooserNode *pParent = 0, bool fFavorite = false);
62 /** Destructs chooser node. */
63 virtual ~UIChooserNode() RT_OVERRIDE;
64
65 /** Returns RTTI node type. */
66 virtual UIChooserNodeType type() const = 0;
67
68 /** Casts node to group one. */
69 UIChooserNodeGroup *toGroupNode();
70 /** Casts node to global one. */
71 UIChooserNodeGlobal *toGlobalNode();
72 /** Casts node to machine one. */
73 UIChooserNodeMachine *toMachineNode();
74
75 /** Returns parent node reference. */
76 UIChooserNode *parentNode() const { return m_pParent; }
77 /** Returns whether node is of root kind. */
78 bool isRoot() const { return !m_pParent; }
79 /** Returns root node reference. */
80 UIChooserNode *rootNode() const;
81
82 /** Returns whether the node is favorite. */
83 bool isFavorite() const { return m_fFavorite; }
84 /** Defines whether the node is @a fFavorite. */
85 void setFavorite(bool fFavorite) { m_fFavorite = fFavorite; }
86
87 /** Defines the @a pModel reference. */
88 void setModel(UIChooserAbstractModel *pModel) { m_pModel = pModel; }
89 /** Returns the model reference. */
90 UIChooserAbstractModel *model() const;
91
92 /** Returns node name. */
93 virtual QString name() const = 0;
94 /** Returns full node name. */
95 virtual QString fullName() const = 0;
96 /** Returns item description. */
97 virtual QString description() const = 0;
98 /** Returns item definition.
99 * @param fFull Brings whether full definition is required
100 * which is used while saving group definitions,
101 * otherwise short definition will be returned,
102 * which is used while saving last chosen node. */
103 virtual QString definition(bool fFull = false) const = 0;
104
105 /** Returns whether there are children of certain @a enmType. */
106 virtual bool hasNodes(UIChooserNodeType enmType = UIChooserNodeType_Any) const = 0;
107 /** Returns a list of nodes of certain @a enmType. */
108 virtual QList<UIChooserNode*> nodes(UIChooserNodeType enmType = UIChooserNodeType_Any) const = 0;
109
110 /** Adds passed @a pNode to specified @a iPosition. */
111 virtual void addNode(UIChooserNode *pNode, int iPosition) = 0;
112 /** Removes passed @a pNode. */
113 virtual void removeNode(UIChooserNode *pNode) = 0;
114
115 /** Removes all children with specified @a uId recursively. */
116 virtual void removeAllNodes(const QUuid &uId) = 0;
117 /** Updates all children with specified @a uId recursively. */
118 virtual void updateAllNodes(const QUuid &uId) = 0;
119
120 /** Returns node position. */
121 int position();
122 /** Returns position of specified node inside this one. */
123 virtual int positionOf(UIChooserNode *pNode) = 0;
124
125 /** Defines linked @a pItem. */
126 void setItem(UIChooserItem *pItem) { m_pItem = pItem; }
127 /** Returns linked item. */
128 UIChooserItem *item() const { return m_pItem.data(); }
129
130 /** Performs search wrt. @a strSearchTerm and @a iSearchFlags and updates @a matchedItems. For an empty
131 * @a strSearchTerm all items are added wrt. node type from @a iSearchFlags. */
132 virtual void searchForNodes(const QString &strSearchTerm, int iSearchFlags, QList<UIChooserNode*> &matchedItems) = 0;
133
134 /** Performs sorting of children nodes. */
135 virtual void sortNodes() = 0;
136
137 /** Returns if node is disabled. */
138 bool isDisabled() const;
139 /** Sets the disabled flag. */
140 void setDisabled(bool fDisabled);
141
142protected:
143
144 /** Holds the parent node reference. */
145 UIChooserNode *m_pParent;
146 /** Holds whether the node is favorite. */
147 bool m_fFavorite;
148
149 /** Holds the model reference. */
150 UIChooserAbstractModel *m_pModel;
151
152 /** Holds the linked item reference. */
153 QPointer<UIChooserItem> m_pItem;
154
155 /** Holds item description. */
156 QString m_strDescription;
157
158 /** Holds the flag to indicate whether the node is disabled or not. */
159 bool m_fDisabled;
160
161};
162
163
164#endif /* !FEQT_INCLUDED_SRC_manager_chooser_UIChooserNode_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette