VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumEnumerator.h@ 82781

Last change on this file since 82781 was 80926, checked in by vboxsync, 5 years ago

FE/Qt: bugref:8472: Merge startMediumEnumeration & enumerateAdditionalMedia into one consolidated mechanism which can enumerate all media at once or selected media only.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
Line 
1/* $Id: UIMediumEnumerator.h 80926 2019-09-20 13:24:33Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMediumEnumerator class declaration.
4 */
5
6/*
7 * Copyright (C) 2013-2019 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_medium_UIMediumEnumerator_h
19#define FEQT_INCLUDED_SRC_medium_UIMediumEnumerator_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/* Qt includes: */
25#include <QObject>
26#include <QSet>
27
28/* GUI includes: */
29#include "QIWithRetranslateUI.h"
30#include "UILibraryDefs.h"
31#include "UIMedium.h"
32
33/* COM includes: */
34# include "CMedium.h"
35# include "CMediumAttachment.h"
36
37/* Forward declarations: */
38class UITask;
39class UIThreadPool;
40
41/** A map of CMedium objects ordered by their IDs. */
42typedef QMap<QUuid, CMedium> CMediumMap;
43
44/** QObject extension operating as medium-enumeration object.
45 * Manages access to cached UIMedium information via public API.
46 * Updates cache on corresponding Main events using thread-pool interface. */
47class SHARED_LIBRARY_STUFF UIMediumEnumerator : public QIWithRetranslateUI3<QObject>
48{
49 Q_OBJECT;
50
51signals:
52
53 /** Notifies listeners about UIMedium with @a uMediumID created. */
54 void sigMediumCreated(const QUuid &uMediumID);
55 /** Notifies listeners about UIMedium with @a uMediumID deleted. */
56 void sigMediumDeleted(const QUuid &uMediumID);
57
58 /** Notifies listeners about consolidated medium-enumeration process has started. */
59 void sigMediumEnumerationStarted();
60 /** Notifies listeners about UIMedium with @a uMediumID updated. */
61 void sigMediumEnumerated(const QUuid &uMediumID);
62 /** Notifies listeners about consolidated medium-enumeration process has finished. */
63 void sigMediumEnumerationFinished();
64
65public:
66
67 /** Constructs medium-enumerator object. */
68 UIMediumEnumerator();
69
70 /** Returns cached UIMedium ID list. */
71 QList<QUuid> mediumIDs() const;
72 /** Returns a wrapper of cached UIMedium with specified @a uMediumID. */
73 UIMedium medium(const QUuid &uMediumID) const;
74
75 /** Creates UIMedium thus caching it internally on the basis of passed @a guiMedium information. */
76 void createMedium(const UIMedium &guiMedium);
77
78 /** Returns whether full consolidated medium-enumeration process is requested. */
79 bool isFullMediumEnumerationRequested() const { return m_fFullMediumEnumerationRequested; }
80 /** Returns whether any consolidated medium-enumeration process is in progress. */
81 bool isMediumEnumerationInProgress() const { return m_fMediumEnumerationInProgress; }
82 /** Makes a request to enumerate specified @a comMedia.
83 * @note Empty passed map means that full/overall medium-enumeration is requested.
84 * In that case previous map will be replaced with the new one, values
85 * present in both maps will be merged from the previous to new one.
86 * @note Non-empty passed map means that additional medium-enumeration is requested.
87 * In that case previous map will be extended with the new one, values
88 * present in both maps will be merged from the previous to new one. */
89 void enumerateMedia(const CMediumVector &comMedia = CMediumVector());
90 /** Refresh all the lightweight UIMedium information for all the cached UIMedium(s).
91 * @note Please note that this is a lightweight version, which doesn't perform
92 * heavy state/accessibility checks thus doesn't require to be performed
93 * by a worker COM-aware thread. */
94 void refreshMedia();
95
96protected:
97
98 /** Handles translation event. */
99 virtual void retranslateUi() /* override */;
100
101private slots:
102
103 /** Handles machine-data-change event for a machine with specified @a uMachineId. */
104 void sltHandleMachineDataChange(const QUuid &uMachineId);
105
106 /** Handles signal about storage controller change.
107 * @param uMachineId Brings the ID of machine corresponding controller belongs to.
108 * @param strControllerName Brings the name of controller this event is related to. */
109 void sltHandleStorageControllerChange(const QUuid &uMachineId, const QString &strControllerName);
110 /** Handles signal about storage device change.
111 * @param comAttachment Brings corresponding attachment.
112 * @param fRemoved Brings whether medium is removed or added.
113 * @param fSilent Brings whether this change has gone silent for guest. */
114 void sltHandleStorageDeviceChange(CMediumAttachment comAttachment, bool fRemoved, bool fSilent);
115 /** Handles signal about storage medium @a comAttachment state change. */
116 void sltHandleMediumChange(CMediumAttachment comAttachment);
117 /** Handles signal about storage @a comMedium config change. */
118 void sltHandleMediumConfigChange(CMedium comMedium);
119 /** Handles signal about storage medium is (un)registered.
120 * @param uMediumId Brings corresponding medium ID.
121 * @param enmMediumType Brings corresponding medium type.
122 * @param fRegistered Brings whether medium is registered or unregistered. */
123 void sltHandleMediumRegistered(const QUuid &uMediumId, KDeviceType enmMediumType, bool fRegistered);
124
125 /** Handles medium-enumeration @a pTask complete signal. */
126 void sltHandleMediumEnumerationTaskComplete(UITask *pTask);
127
128private:
129
130 /** Creates medium-enumeration task for certain @a guiMedium. */
131 void createMediumEnumerationTask(const UIMedium &guiMedium);
132 /** Adds NULL UIMedium to specified @a outputMedia map. */
133 void addNullMediumToMap(UIMediumMap &outputMedia);
134 /** Adds @a inputMedia to specified @a outputMedia map. */
135 void addMediaToMap(const CMediumVector &inputMedia, UIMediumMap &outputMedia);
136
137 /** Parses incoming @a comAttachment, enumerating the media it has attached.
138 * @param result Brings the list of previously enumerated media
139 * IDs to be appended with newly enumerated. */
140 void parseAttachment(CMediumAttachment comAttachment, QList<QUuid> &result);
141 /** Parses incoming @a comMedium, enumerating the media it represents.
142 * @param result Brings the list of previously enumerated media
143 * IDs to be appended with newly enumerated. */
144 void parseMedium(CMedium comMedium, QList<QUuid> &result);
145
146 /** Enumerates all the known media attached to machine with certain @a uMachineId.
147 * @param result Brings the list of previously enumerated media
148 * IDs to be appended with newly enumerated. */
149 void enumerateAllMediaOfMachineWithId(const QUuid &uMachineId, QList<QUuid> &result);
150 /** Enumerates all the children media of medium with certain @a uMediumId.
151 * @param result Brings the list of previously enumerated media
152 * IDs to be appended with newly enumerated. */
153 void enumerateAllMediaOfMediumWithId(const QUuid &uMediumId, QList<QUuid> &result);
154
155 /** Holds whether full consolidated medium-enumeration process is requested. */
156 bool m_fFullMediumEnumerationRequested;
157 /** Holds whether any consolidated medium-enumeration process is in progress. */
158 bool m_fMediumEnumerationInProgress;
159
160 /** Holds a set of current medium-enumeration tasks. */
161 QSet<UITask*> m_tasks;
162
163 /** Holds a map of current cached (enumerated) media. */
164 UIMediumMap m_media;
165};
166
167#endif /* !FEQT_INCLUDED_SRC_medium_UIMediumEnumerator_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use