VirtualBox

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

Last change on this file was 104226, checked in by vboxsync, 6 weeks ago

FE/Qt. bugref:10622. Using new UITranslationEventListener in medium manager related classes.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use