VirtualBox

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

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

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: Rework List Cloud Machines task handler to determine which VMs were [un]registered; This behavior have to replace missed cloud machine registration event.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.4 KB
Line 
1/* $Id: UIChooserAbstractModel.h 86611 2020-10-16 14:47:32Z 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 unregistering for a list of @a ids.
175 * @param strProviderShortName Brings provider short name.
176 * @param strProfileName Brings profile name. */
177 virtual void sltCloudMachinesUnregistered(const QString &strProviderShortName,
178 const QString &strProfileName,
179 const QList<QUuid> &ids);
180 /** Handles cloud machine registering for @a comMachine.
181 * @param strProviderShortName Brings provider short name.
182 * @param strProfileName Brings profile name. */
183 virtual void sltCloudMachineRegistered(const QString &strProviderShortName,
184 const QString &strProfileName,
185 const CCloudMachine &comMachine);
186 /** Handles cloud machine registering for a list of @a machines.
187 * @param strProviderShortName Brings provider short name.
188 * @param strProfileName Brings profile name. */
189 virtual void sltCloudMachinesRegistered(const QString &strProviderShortName,
190 const QString &strProfileName,
191 const QVector<CCloudMachine> &machines);
192
193 /** Handles list cloud machines task complete signal. */
194 virtual void sltHandleCloudListMachinesTaskComplete(UITask *pTask);
195
196 /** Handles Cloud Profile Manager cumulative change. */
197 virtual void sltHandleCloudProfileManagerCumulativeChange();
198 /** @} */
199
200private slots:
201
202 /** @name Group saving stuff.
203 * @{ */
204 /** Handles request to start group saving. */
205 void sltStartGroupSaving();
206 /** @} */
207
208private:
209
210 /** @name Prepare/Cleanup cascade.
211 * @{ */
212 /** Prepares all. */
213 void prepare();
214 /** Prepares connections. */
215 void prepareConnections();
216 /** @} */
217
218 /** @name Children stuff.
219 * @{ */
220 /** Reloads local tree. */
221 void reloadLocalTree();
222 /** Reloads cloud tree. */
223 void reloadCloudTree();
224
225 /** Adds local machine item based on certain @a comMachine and optionally @a fMakeItVisible. */
226 void addLocalMachineIntoTheTree(const CMachine &comMachine, bool fMakeItVisible = false);
227 /** Adds cloud machine item based on certain @a comMachine and optionally @a fMakeItVisible, into @a strGroup. */
228 void addCloudMachineIntoTheTree(const QString &strGroup, const CCloudMachine &comMachine, bool fMakeItVisible = false);
229
230 /** Acquires local group node, creates one if necessary.
231 * @param strName Brings the name of group we looking for.
232 * @param pParentNode Brings the parent we starting to look for a group from.
233 * @param fAllGroupsOpened Brings whether we should open all the groups till the required one. */
234 UIChooserNode *getLocalGroupNode(const QString &strName, UIChooserNode *pParentNode, bool fAllGroupsOpened);
235 /** Acquires cloud group node, never create new, returns root if nothing found.
236 * @param strName Brings the name of group we looking for.
237 * @param pParentNode Brings the parent we starting to look for a group from.
238 * @param fAllGroupsOpened Brings whether we should open all the groups till the required one. */
239 UIChooserNode *getCloudGroupNode(const QString &strName, UIChooserNode *pParentNode, bool fAllGroupsOpened);
240
241 /** Returns whether group node * with specified @a enmDataType and @a strName should be opened,
242 * searching starting from the passed @a pParentNode. */
243 bool shouldGroupNodeBeOpened(UIChooserNode *pParentNode,
244 UIChooserNodeDataPrefixType enmDataType,
245 const QString &strName) const;
246 /** Returns whether global node should be favorite,
247 * searching starting from the passed @a pParentNode. */
248 bool shouldGlobalNodeBeFavorite(UIChooserNode *pParentNode) const;
249
250 /** Wipes out empty groups starting from @a pParentItem. */
251 void wipeOutEmptyGroupsStartingFrom(UIChooserNode *pParentNode);
252
253 /** Acquires desired position for a child of @a pParentNode with specified @a enmDataType and @a strName. */
254 int getDesiredNodePosition(UIChooserNode *pParentNode, UIChooserNodeDataPrefixType enmDataType, const QString &strName);
255 /** Acquires defined position for a child of @a pParentNode with specified @a enmDataType and @a strName. */
256 int getDefinedNodePosition(UIChooserNode *pParentNode, UIChooserNodeDataPrefixType enmDataType, const QString &strName);
257
258 /** Creates local machine node based on certain @a comMachine as a child of specified @a pParentNode. */
259 void createLocalMachineNode(UIChooserNode *pParentNode, const CMachine &comMachine);
260 /** Creates cloud machine node based on certain @a comMachine as a child of specified @a pParentNode. */
261 void createCloudMachineNode(UIChooserNode *pParentNode, const CCloudMachine &comMachine);
262
263 /** Gathers a list of possible group node names for machine nodes listed in @a exceptions, starting from @a pCurrentNode. */
264 QStringList gatherPossibleGroupNodeNames(UIChooserNode *pCurrentNode, QList<UIChooserNode*> exceptions) const;
265 /** @} */
266
267 /** @name Group saving stuff.
268 * @{ */
269 /** Saves group settings. */
270 void saveGroupSettings();
271 /** Saves group definitions. */
272 void saveGroupDefinitions();
273
274 /** Gathers group @a settings of @a pParentGroup. */
275 void gatherGroupSettings(QMap<QString, QStringList> &settings, UIChooserNode *pParentGroup);
276 /** Gathers group @a definitions of @a pParentGroup. */
277 void gatherGroupDefinitions(QMap<QString, QStringList> &definitions, UIChooserNode *pParentGroup);
278
279 /** Makes sure group settings saving is finished. */
280 void makeSureGroupSettingsSaveIsFinished();
281 /** Makes sure group definitions saving is finished. */
282 void makeSureGroupDefinitionsSaveIsFinished();
283 /** @} */
284
285 /** @name General stuff.
286 * @{ */
287 /** Holds the parent widget reference. */
288 UIChooser *m_pParent;
289 /** @} */
290
291 /** @name Children stuff.
292 * @{ */
293 /** Holds the invisible root node instance. */
294 UIChooserNode *m_pInvisibleRootNode;
295 /** @} */
296
297 /** @name Search stuff.
298 * @{ */
299 /** Stores the results of the current search. */
300 QList<UIChooserNode*> m_searchResults;
301 /** @} */
302
303 /** @name Group saving stuff.
304 * @{ */
305 /** Holds the consolidated map of group settings/definitions. */
306 QMap<QString, QStringList> m_groups;
307 /** @} */
308};
309
310#endif /* !FEQT_INCLUDED_SRC_manager_chooser_UIChooserAbstractModel_h */
Note: See TracBrowser for help on using the repository browser.

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