VirtualBox

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

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

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: Always choose newly registered cloud VM.

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