VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h@ 86608

Last change on this file since 86608 was 86608, checked in by vboxsync, 4 years ago

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: Replace common handler for registering/unregistering cloud VMs with separate handlers.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.5 KB
Line 
1/* $Id: UIChooserAbstractModel.h 86608 2020-10-16 14:19:08Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIChooserAbstractModel class declaration.
4 */
5
6/*
7 * Copyright (C) 2012-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef FEQT_INCLUDED_SRC_manager_chooser_UIChooserAbstractModel_h
19#define FEQT_INCLUDED_SRC_manager_chooser_UIChooserAbstractModel_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/* Qt includes: */
25#include <QUuid>
26
27/* GUI includes: */
28#include "UIChooserDefs.h"
29
30/* COM includes: */
31#include "COMEnums.h"
32
33/* Forward declaration: */
34class UIChooser;
35class UIChooserNode;
36class UITask;
37class CCloudMachine;
38class CMachine;
39
40/** QObject extension used as VM Chooser-pane abstract model.
41 * This class is used to load/save a tree of abstract invisible
42 * nodes representing VMs and their groups from/to extra-data. */
43class UIChooserAbstractModel : public QObject
44{
45 Q_OBJECT;
46
47signals:
48
49 /** @name Cloud machine stuff.
50 * @{ */
51 /** Notifies listeners about state change for cloud machine with certain @a uId. */
52 void sigCloudMachineStateChange(const QUuid &uId);
53 /** @} */
54
55 /** @name Group saving stuff.
56 * @{ */
57 /** Commands to start group saving. */
58 void sigStartGroupSaving();
59 /** Notifies listeners about group saving state changed. */
60 void sigGroupSavingStateChanged();
61 /** @} */
62
63public:
64
65 /** Constructs abstract Chooser-model passing @a pParent to the base-class. */
66 UIChooserAbstractModel(UIChooser *pParent);
67
68 /** @name General stuff.
69 * @{ */
70 /** Inits model. */
71 virtual void init();
72 /** Deinits model. */
73 virtual void deinit();
74 /** @} */
75
76 /** @name Children stuff.
77 * @{ */
78 /** Returns invisible root node instance. */
79 UIChooserNode *invisibleRoot() const { return m_pInvisibleRootNode; }
80
81 /** Wipes out empty groups. */
82 void wipeOutEmptyGroups();
83
84 /** Returns possible group node names for machine node with passed @a uId to move to. */
85 QStringList possibleGroupNodeNamesForMachineNodeToMove(const QUuid &uId);
86 /** Returns possible group node names for group node with passed @a strFullName to move to. */
87 QStringList possibleGroupNodeNamesForGroupNodeToMove(const QString &strFullName);
88
89 /** Generates unique group name traversing recursively starting from @a pRoot. */
90 static QString uniqueGroupName(UIChooserNode *pRoot);
91 /** @} */
92
93 /** @name Search stuff.
94 * @{ */
95 /** Performs a search using @a strSearchTerm and @a iSearchFlags specified. */
96 virtual void performSearch(const QString &strSearchTerm, int iSearchFlags);
97 /** Resets the search result data members and disables item's visual effects.
98 * Also returns a list of all nodes which may be utilized by the calling code. */
99 virtual QList<UIChooserNode*> resetSearch();
100 /** Returns search result. */
101 QList<UIChooserNode*> searchResult() const;
102 /** @} */
103
104 /** @name Group saving stuff.
105 * @{ */
106 /** Commands to save groups. */
107 void saveGroups();
108 /** Returns whether group saving is in progress. */
109 bool isGroupSavingInProgress() const;
110
111 /** Returns QString representation for passed @a uId, wiping out {} symbols.
112 * @note Required for backward compatibility after QString=>QUuid change. */
113 static QString toOldStyleUuid(const QUuid &uId);
114
115 /** Returns node extra-data prefix of certain @a enmType. */
116 static QString prefixToString(UIChooserNodeDataPrefixType enmType);
117 /** Returns node extra-data option of certain @a enmType. */
118 static QString optionToString(UIChooserNodeDataOptionType enmType);
119 /** Returns node extra-data value of certain @a enmType. */
120 static QString valueToString(UIChooserNodeDataValueType enmType);
121 /** @} */
122
123public slots:
124
125 /** @name Cloud machine stuff.
126 * @{ */
127 /** Handles cloud machine state change. */
128 void sltHandleCloudMachineStateChange();
129 /** @} */
130
131 /** @name Group saving stuff.
132 * @{ */
133 /** Handles group settings saving complete. */
134 void sltGroupSettingsSaveComplete();
135 /** Handles group definitions saving complete. */
136 void sltGroupDefinitionsSaveComplete();
137 /** @} */
138
139protected slots:
140
141 /** @name Main event handling stuff.
142 * @{ */
143 /** Handles local machine @a enmState change for machine with certain @a uMachineId. */
144 virtual void sltLocalMachineStateChanged(const QUuid &uMachineId, const KMachineState enmState);
145 /** Handles local machine data change for machine with certain @a uMachineId. */
146 virtual void sltLocalMachineDataChanged(const QUuid &uMachineId);
147 /** Handles local machine registering/unregistering for machine with certain @a uMachineId. */
148 virtual void sltLocalMachineRegistrationChanged(const QUuid &uMachineId, const bool fRegistered);
149
150 /** Handles session @a enmState change for machine with certain @a uMachineId. */
151 virtual void sltSessionStateChanged(const QUuid &uMachineId, const KSessionState enmState);
152
153 /** Handles snapshot change for machine/snapshot with certain @a uMachineId / @a uSnapshotId. */
154 virtual void sltSnapshotChanged(const QUuid &uMachineId, const QUuid &uSnapshotId);
155
156 /** Handles event about cloud provider with @a uProviderId being uninstalled. */
157 virtual void sltHandleCloudProviderUninstall(const QUuid &uProviderId);
158 /** @} */
159
160 /** @name Children stuff.
161 * @{ */
162 /** Handles reload machine with certain @a uMachineId request. */
163 virtual void sltReloadMachine(const QUuid &uMachineId);
164 /** @} */
165
166 /** @name Cloud stuff.
167 * @{ */
168 /** Handles cloud machine unregistering for @a uId.
169 * @param strProviderShortName Brings provider short name.
170 * @param strProfileName Brings profile name. */
171 virtual void sltCloudMachineUnregistered(const QString &strProviderShortName,
172 const QString &strProfileName,
173 const QUuid &uId);
174 /** Handles cloud machine registering for @a comMachine.
175 * @param strProviderShortName Brings provider short name.
176 * @param strProfileName Brings profile name. */
177 virtual void sltCloudMachineRegistered(const QString &strProviderShortName,
178 const QString &strProfileName,
179 const CCloudMachine &comMachine);
180
181 /** Handles list cloud machines task complete signal. */
182 virtual void sltHandleCloudListMachinesTaskComplete(UITask *pTask);
183
184 /** Handles Cloud Profile Manager cumulative change. */
185 virtual void sltHandleCloudProfileManagerCumulativeChange();
186 /** @} */
187
188private slots:
189
190 /** @name Group saving stuff.
191 * @{ */
192 /** Handles request to start group saving. */
193 void sltStartGroupSaving();
194 /** @} */
195
196private:
197
198 /** @name Prepare/Cleanup cascade.
199 * @{ */
200 /** Prepares all. */
201 void prepare();
202 /** Prepares connections. */
203 void prepareConnections();
204 /** @} */
205
206 /** @name Children stuff.
207 * @{ */
208 /** Reloads local tree. */
209 void reloadLocalTree();
210 /** Reloads cloud tree. */
211 void reloadCloudTree();
212
213 /** Adds local machine item based on certain @a comMachine and optionally @a fMakeItVisible. */
214 void addLocalMachineIntoTheTree(const CMachine &comMachine, bool fMakeItVisible = false);
215 /** Adds cloud machine item based on certain @a comMachine and optionally @a fMakeItVisible, into @a strGroup. */
216 void addCloudMachineIntoTheTree(const QString &strGroup, const CCloudMachine &comMachine, bool fMakeItVisible = false);
217
218 /** Acquires local group node, creates one if necessary.
219 * @param strName Brings the name of group we looking for.
220 * @param pParentNode Brings the parent we starting to look for a group from.
221 * @param fAllGroupsOpened Brings whether we should open all the groups till the required one. */
222 UIChooserNode *getLocalGroupNode(const QString &strName, UIChooserNode *pParentNode, bool fAllGroupsOpened);
223 /** Acquires cloud group node, never create new, returns root if nothing found.
224 * @param strName Brings the name of group we looking for.
225 * @param pParentNode Brings the parent we starting to look for a group from.
226 * @param fAllGroupsOpened Brings whether we should open all the groups till the required one. */
227 UIChooserNode *getCloudGroupNode(const QString &strName, UIChooserNode *pParentNode, bool fAllGroupsOpened);
228
229 /** Returns whether group node * with specified @a enmDataType and @a strName should be opened,
230 * searching starting from the passed @a pParentNode. */
231 bool shouldGroupNodeBeOpened(UIChooserNode *pParentNode,
232 UIChooserNodeDataPrefixType enmDataType,
233 const QString &strName) const;
234 /** Returns whether global node should be favorite,
235 * searching starting from the passed @a pParentNode. */
236 bool shouldGlobalNodeBeFavorite(UIChooserNode *pParentNode) const;
237
238 /** Wipes out empty groups starting from @a pParentItem. */
239 void wipeOutEmptyGroupsStartingFrom(UIChooserNode *pParentNode);
240
241 /** Acquires desired position for a child of @a pParentNode with specified @a enmDataType and @a strName. */
242 int getDesiredNodePosition(UIChooserNode *pParentNode, UIChooserNodeDataPrefixType enmDataType, const QString &strName);
243 /** Acquires defined position for a child of @a pParentNode with specified @a enmDataType and @a strName. */
244 int getDefinedNodePosition(UIChooserNode *pParentNode, UIChooserNodeDataPrefixType enmDataType, const QString &strName);
245
246 /** Creates local machine node based on certain @a comMachine as a child of specified @a pParentNode. */
247 void createLocalMachineNode(UIChooserNode *pParentNode, const CMachine &comMachine);
248 /** Creates cloud machine node based on certain @a comMachine as a child of specified @a pParentNode. */
249 void createCloudMachineNode(UIChooserNode *pParentNode, const CCloudMachine &comMachine);
250
251 /** Gathers a list of possible group node names for machine nodes listed in @a exceptions, starting from @a pCurrentNode. */
252 QStringList gatherPossibleGroupNodeNames(UIChooserNode *pCurrentNode, QList<UIChooserNode*> exceptions) const;
253 /** @} */
254
255 /** @name Group saving stuff.
256 * @{ */
257 /** Saves group settings. */
258 void saveGroupSettings();
259 /** Saves group definitions. */
260 void saveGroupDefinitions();
261
262 /** Gathers group @a settings of @a pParentGroup. */
263 void gatherGroupSettings(QMap<QString, QStringList> &settings, UIChooserNode *pParentGroup);
264 /** Gathers group @a definitions of @a pParentGroup. */
265 void gatherGroupDefinitions(QMap<QString, QStringList> &definitions, UIChooserNode *pParentGroup);
266
267 /** Makes sure group settings saving is finished. */
268 void makeSureGroupSettingsSaveIsFinished();
269 /** Makes sure group definitions saving is finished. */
270 void makeSureGroupDefinitionsSaveIsFinished();
271 /** @} */
272
273 /** @name General stuff.
274 * @{ */
275 /** Holds the parent widget reference. */
276 UIChooser *m_pParent;
277 /** @} */
278
279 /** @name Children stuff.
280 * @{ */
281 /** Holds the invisible root node instance. */
282 UIChooserNode *m_pInvisibleRootNode;
283 /** @} */
284
285 /** @name Search stuff.
286 * @{ */
287 /** Stores the results of the current search. */
288 QList<UIChooserNode*> m_searchResults;
289 /** @} */
290
291 /** @name Group saving stuff.
292 * @{ */
293 /** Holds the consolidated map of group settings/definitions. */
294 QMap<QString, QStringList> m_groups;
295 /** @} */
296};
297
298#endif /* !FEQT_INCLUDED_SRC_manager_chooser_UIChooserAbstractModel_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