VirtualBox

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

Last change on this file was 106061, checked in by vboxsync, 3 weeks ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 17.0 KB
RevLine 
[55401]1/* $Id: UIMediumManager.h 106061 2024-09-16 14:03:52Z vboxsync $ */
[41650]2/** @file
[50767]3 * VBox Qt GUI - UIMediumManager class declaration.
[41650]4 */
5
6/*
[106061]7 * Copyright (C) 2006-2024 Oracle and/or its affiliates.
[41650]8 *
[96407]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
[41650]26 */
27
[76581]28#ifndef FEQT_INCLUDED_SRC_medium_UIMediumManager_h
29#define FEQT_INCLUDED_SRC_medium_UIMediumManager_h
[76532]30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
[41650]33
[99389]34/* Qt includes: */
35#include <QUuid>
36
[48086]37/* GUI includes: */
[67046]38#include "QIManagerDialog.h"
[48316]39#include "UIMediumDefs.h"
[41650]40
[103803]41/* COM includes: */
42#include "KMachineState.h"
43
[41650]44/* Forward declarations: */
[67765]45class QAbstractButton;
[67704]46class QLabel;
[69518]47class QProgressBar;
[67704]48class QTabWidget;
49class QTreeWidgetItem;
50class QIDialogButtonBox;
51class QILabel;
52class QITreeWidget;
[73717]53class UIActionPool;
[50767]54class UIMedium;
[67750]55class UIMediumDetailsWidget;
[50767]56class UIMediumItem;
[77014]57class UIMediumSearchWidget;
[86233]58class QIToolBar;
[41650]59
[66916]60
[49582]61/** Functor interface allowing to check if passed UIMediumItem is suitable. */
62class CheckIfSuitableBy
63{
64public:
[66916]65
66 /** Destructs functor. */
[63315]67 virtual ~CheckIfSuitableBy() { /* Makes MSC happy. */ }
68
[50767]69 /** Determines whether passed @a pItem is suitable. */
[49582]70 virtual bool isItSuitable(UIMediumItem *pItem) const = 0;
71};
72
[66916]73
[69518]74/** Medium manager progress-bar.
[78722]75 * Reflects medium-enumeration progress, stays hidden otherwise. */
[69518]76class UIEnumerationProgressBar : public QWidget
77{
78 Q_OBJECT;
79
80public:
81
82 /** Constructor on the basis of passed @a pParent. */
83 UIEnumerationProgressBar(QWidget *pParent = 0);
84
85 /** Defines progress-bar label-text. */
86 void setText(const QString &strText);
87
88 /** Returns progress-bar current-value. */
89 int value() const;
90 /** Defines progress-bar current-value. */
91 void setValue(int iValue);
92 /** Defines progress-bar maximum-value. */
93 void setMaximum(int iValue);
94
95private:
96
97 /** Prepares progress-bar content. */
98 void prepare();
99
100 /** Progress-bar label. */
101 QLabel *m_pLabel;
102 /** Progress-bar itself. */
103 QProgressBar *m_pProgressBar;
104};
105
106
[67122]107/** QWidget extension providing GUI with the pane to control media related functionality. */
[104226]108class UIMediumManagerWidget : public QWidget
[41650]109{
110 Q_OBJECT;
111
[66916]112 /** Item action types. */
[69130]113 enum Action { Action_Add, Action_Edit, Action_Copy, Action_Remove, Action_Release };
[50700]114
[67765]115signals:
116
[99390]117 /** Notifies listeners about creation procedure was requested. */
118 void sigCreateMedium();
[99389]119 /** Notifies listeners about copy procedure was requested for medium with specified @a uMediumId. */
120 void sigCopyMedium(const QUuid &uMediumId);
121
[67765]122 /** Notifies listeners about medium details-widget @a fVisible. */
123 void sigMediumDetailsVisibilityChanged(bool fVisible);
[68326]124 /** Notifies listeners about accept is @a fAllowed. */
125 void sigAcceptAllowed(bool fAllowed);
126 /** Notifies listeners about reject is @a fAllowed. */
127 void sigRejectAllowed(bool fAllowed);
[67765]128
[48086]129public:
[41650]130
[73721]131 /** Constructs Virtual Media Manager widget.
132 * @param enmEmbedding Brings the type of widget embedding.
133 * @param pActionPool Brings the action-pool reference.
134 * @param fShowToolbar Brings whether we should create/show toolbar. */
135 UIMediumManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool, bool fShowToolbar = true, QWidget *pParent = 0);
[41650]136
[67046]137 /** Returns the menu. */
[73717]138 QMenu *menu() const;
[67046]139
140#ifdef VBOX_WS_MAC
141 /** Returns the toolbar. */
[86233]142 QIToolBar *toolbar() const { return m_pToolBar; }
[67046]143#endif
144
[69519]145 /** Defines @a pProgressBar reference. */
146 void setProgressBar(UIEnumerationProgressBar *pProgressBar);
147
[67765]148public slots:
149
150 /** @name Details-widget stuff.
151 * @{ */
152 /** Handles command to reset medium details changes. */
153 void sltResetMediumDetailsChanges();
154 /** Handles command to apply medium details changes. */
155 void sltApplyMediumDetailsChanges();
156 /** @} */
157
[50363]158private slots:
[41650]159
[66916]160 /** @name Medium operation stuff.
161 * @{ */
[104904]162 /** Handles UIMediumEnumerator::sigMediumCreated signal. */
[74942]163 void sltHandleMediumCreated(const QUuid &uMediumID);
[104904]164 /** Handles UIMediumEnumerator::sigMediumDeleted signal. */
[74942]165 void sltHandleMediumDeleted(const QUuid &uMediumID);
[66916]166 /** @} */
[41650]167
[66916]168 /** @name Medium enumeration stuff.
169 * @{ */
[104904]170 /** Handles UIMediumEnumerator::sigMediumEnumerationStarted signal. */
[66916]171 void sltHandleMediumEnumerationStart();
[104904]172 /** Handles UIMediumEnumerator::sigMediumEnumerated signal. */
[74942]173 void sltHandleMediumEnumerated(const QUuid &uMediumID);
[104904]174 /** Handles UIMediumEnumerator::sigMediumEnumerationFinished signal. */
[66916]175 void sltHandleMediumEnumerationFinish();
[78353]176 void sltHandleMachineStateChange(const QUuid &uId, const KMachineState state);
[66916]177 /** @} */
[41650]178
[66916]179 /** @name Menu/action stuff.
180 * @{ */
[72344]181 /** Handles command to add medium. */
182 void sltAddMedium();
[77255]183 /** Handles command to create medium. */
184 void sltCreateMedium();
[66916]185 /** Handles command to copy medium. */
186 void sltCopyMedium();
[69130]187 /** Handles command to move medium. */
188 void sltMoveMedium();
[66916]189 /** Handles command to remove medium. */
190 void sltRemoveMedium();
191 /** Handles command to release medium. */
192 void sltReleaseMedium();
[94294]193 /** Removes all inaccessible media. */
194 void sltClear();
[67765]195 /** Handles command to make medium details @a fVisible. */
196 void sltToggleMediumDetailsVisibility(bool fVisible);
[77014]197 /** Handles command to make medium search pane @a fVisible. */
198 void sltToggleMediumSearchVisibility(bool fVisible);
[66916]199 /** Handles command to refresh medium. */
200 void sltRefreshAll();
201 /** @} */
[41650]202
[90423]203 /** @name Menu/action handler stuff.
204 * @{ */
205 /** Handles medium move progress finished signal. */
206 void sltHandleMoveProgressFinished();
207 /** Handles medium resize progress finished signal. */
208 void sltHandleResizeProgressFinished();
209 /** @} */
210
[66916]211 /** @name Tab-widget stuff.
212 * @{ */
213 /** Handles tab change case. */
214 void sltHandleCurrentTabChanged();
215 /** Handles item change case. */
216 void sltHandleCurrentItemChanged();
217 /** Handles item context-menu-call case. */
[73734]218 void sltHandleContextMenuRequest(const QPoint &position);
[66916]219 /** @} */
[41650]220
[66916]221 /** @name Tree-widget stuff.
222 * @{ */
223 /** Adjusts tree-widgets according content. */
224 void sltPerformTablesAdjustment();
225 /** @} */
[41650]226
[88742]227 /** @name Medium search stuff.
[77014]228 * @{ */
229 /** Adjusts tree-widgets according content. */
230 void sltHandlePerformSearch();
231 /** @} */
232
[88742]233 /** @name Medium search stuff.
234 * @{ */
235 /** Handles command to detach COM stuff. */
236 void sltDetachCOM();
237 /** @} */
238
[104226]239 /** @name Event-handling stuff.
240 * @{ */
241 /** Handles translation event. */
242 void sltRetranslateUI();
243 /** @} */
244
[41650]245private:
246
[66916]247 /** @name Prepare/cleanup cascade.
248 * @{ */
249 /** Prepares all. */
250 void prepare();
251 /** Prepares connections. */
252 void prepareConnections();
253 /** Prepares actions. */
254 void prepareActions();
[67046]255 /** Prepares widgets. */
256 void prepareWidgets();
[66916]257 /** Prepares toolbar. */
258 void prepareToolBar();
259 /** Prepares tab-widget. */
260 void prepareTabWidget();
261 /** Prepares tab-widget's tab. */
[73953]262 void prepareTab(UIMediumDeviceType type);
[66916]263 /** Prepares tab-widget's tree-widget. */
[73953]264 void prepareTreeWidget(UIMediumDeviceType type, int iColumns);
[67765]265 /** Prepares details-widget. */
266 void prepareDetailsWidget();
[77014]267 /** Prepares search-widget. */
268 void prepareSearchWidget();
[68962]269 /** Load settings: */
270 void loadSettings();
[41650]271
[66916]272 /** Repopulates tree-widgets content. */
273 void repopulateTreeWidgets();
[41650]274
[66916]275 /** Updates details according latest changes in current item of passed @a type. */
[73953]276 void refetchCurrentMediumItem(UIMediumDeviceType type);
[66916]277 /** Updates details according latest changes in current item of chosen type. */
278 void refetchCurrentChosenMediumItem();
279 /** Updates details according latest changes in all current items. */
280 void refetchCurrentMediumItems();
[50368]281
[66916]282 /** Updates actions according currently chosen item. */
283 void updateActions();
284 /** Updates action icons according currently chosen tab. */
285 void updateActionIcons();
286 /** Updates tab icons according last @a action happened with @a pItem. */
287 void updateTabIcons(UIMediumItem *pItem, Action action);
288 /** @} */
[41650]289
[66916]290 /** @name Widget operation stuff.
291 * @{ */
292 /** Creates UIMediumItem for corresponding @a medium. */
293 UIMediumItem *createMediumItem(const UIMedium &medium);
294 /** Creates UIMediumItemHD for corresponding @a medium. */
295 UIMediumItem *createHardDiskItem(const UIMedium &medium);
296 /** Updates UIMediumItem for corresponding @a medium. */
297 void updateMediumItem(const UIMedium &medium);
[74942]298 /** Deletes UIMediumItem for corresponding @a uMediumID. */
299 void deleteMediumItem(const QUuid &uMediumID);
[50325]300
[66916]301 /** Returns tab for passed medium @a type. */
[73953]302 QWidget *tab(UIMediumDeviceType type) const;
[66916]303 /** Returns tree-widget for passed medium @a type. */
[73953]304 QITreeWidget *treeWidget(UIMediumDeviceType type) const;
[66916]305 /** Returns item for passed medium @a type. */
[73953]306 UIMediumItem *mediumItem(UIMediumDeviceType type) const;
[50368]307
[66916]308 /** Returns medium type for passed @a pTreeWidget. */
[73953]309 UIMediumDeviceType mediumType(QITreeWidget *pTreeWidget) const;
[50960]310
[66916]311 /** Returns current medium type. */
[73953]312 UIMediumDeviceType currentMediumType() const;
[66916]313 /** Returns current tree-widget. */
314 QITreeWidget *currentTreeWidget() const;
315 /** Returns current item. */
316 UIMediumItem *currentMediumItem() const;
[50327]317
[66916]318 /** Defines current item for passed @a pTreeWidget as @a pItem. */
319 void setCurrentItem(QITreeWidget *pTreeWidget, QTreeWidgetItem *pItem);
[94823]320
321 void enableClearAction();
[66916]322 /** @} */
[50327]323
[78432]324 /** @name Search stuff.
325 * @{ */
326 /** Calls the UIMediumSearchWidget::search(..). */
327 void performSearch(bool fSelectNext);
328 /** @} */
329
[66916]330 /** @name Helper stuff.
331 * @{ */
[73953]332 /** Returns tab index for passed UIMediumDeviceType. */
333 static int tabIndex(UIMediumDeviceType type);
[50966]334
[66916]335 /** Performs search for the @a pTree child which corresponds to the @a condition but not @a pException. */
[67122]336 static UIMediumItem *searchItem(QITreeWidget *pTree,
337 const CheckIfSuitableBy &condition,
338 CheckIfSuitableBy *pException = 0);
[66916]339 /** Performs search for the @a pParentItem child which corresponds to the @a condition but not @a pException. */
[67122]340 static UIMediumItem *searchItem(QTreeWidgetItem *pParentItem,
341 const CheckIfSuitableBy &condition,
342 CheckIfSuitableBy *pException = 0);
[41650]343
[77014]344
[66916]345 /** Checks if @a action can be used for @a pItem. */
346 static bool checkMediumFor(UIMediumItem *pItem, Action action);
[41650]347
[66916]348 /** Casts passed QTreeWidgetItem @a pItem to UIMediumItem if possible. */
349 static UIMediumItem *toMediumItem(QTreeWidgetItem *pItem);
350 /** @} */
[41650]351
[66916]352 /** @name General variables.
353 * @{ */
[67075]354 /** Holds the widget embedding type. */
355 const EmbedTo m_enmEmbedding;
[73717]356 /** Holds the action-pool reference. */
357 UIActionPool *m_pActionPool;
[73721]358 /** Holds whether we should create/show toolbar. */
359 const bool m_fShowToolbar;
[73717]360
[67765]361 /** Holds whether Virtual Media Manager should preserve current item change. */
[67046]362 bool m_fPreventChangeCurrentItem;
[50767]363 /** @} */
[41650]364
[50767]365 /** @name Tab-widget variables.
[66916]366 * @{ */
367 /** Holds the tab-widget instance. */
368 QTabWidget *m_pTabWidget;
369 /** Holds the tab-widget tab-count. */
370 const int m_iTabCount;
371 /** Holds the map of tree-widget instances. */
372 QMap<int, QITreeWidget*> m_trees;
373 /** Holds whether hard-drive tab-widget have inaccessible item. */
374 bool m_fInaccessibleHD;
375 /** Holds whether optical-disk tab-widget have inaccessible item. */
376 bool m_fInaccessibleCD;
377 /** Holds whether floppy-disk tab-widget have inaccessible item. */
378 bool m_fInaccessibleFD;
379 /** Holds cached hard-drive tab-widget icon. */
380 const QIcon m_iconHD;
381 /** Holds cached optical-disk tab-widget icon. */
382 const QIcon m_iconCD;
383 /** Holds cached floppy-disk tab-widget icon. */
384 const QIcon m_iconFD;
385 /** Holds current hard-drive tree-view item ID. */
[74878]386 QUuid m_uCurrentIdHD;
[66916]387 /** Holds current optical-disk tree-view item ID. */
[74878]388 QUuid m_uCurrentIdCD;
[66916]389 /** Holds current floppy-disk tree-view item ID. */
[74878]390 QUuid m_uCurrentIdFD;
[50767]391 /** @} */
[41650]392
[67750]393 /** @name Details-widget variables.
394 * @{ */
395 /** Holds the medium details-widget instance. */
396 UIMediumDetailsWidget *m_pDetailsWidget;
397 /** @} */
398
[66916]399 /** @name Toolbar and menu variables.
400 * @{ */
401 /** Holds the toolbar widget instance. */
[86233]402 QIToolBar *m_pToolBar;
[50767]403 /** @} */
[41650]404
[67046]405 /** @name Progress-bar variables.
[66916]406 * @{ */
[69519]407 /** Holds the progress-bar widget reference. */
[66916]408 UIEnumerationProgressBar *m_pProgressBar;
[50767]409 /** @} */
[77014]410
411 /** @name Search-widget variables.
412 * @{ */
413 /** Holds the medium details-widget instance. */
414 UIMediumSearchWidget *m_pSearchWidget;
415 /** @} */
416
[41650]417};
418
[67046]419
[67765]420/** QIManagerDialogFactory extension used as a factory for Virtual Media Manager dialog. */
[67046]421class UIMediumManagerFactory : public QIManagerDialogFactory
422{
[73717]423public:
424
425 /** Constructs Media Manager factory acquiring additional arguments.
426 * @param pActionPool Brings the action-pool reference. */
427 UIMediumManagerFactory(UIActionPool *pActionPool = 0);
428
[67046]429protected:
430
431 /** Creates derived @a pDialog instance.
432 * @param pCenterWidget Brings the widget reference to center according to. */
[93990]433 virtual void create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) RT_OVERRIDE;
[73717]434
435 /** Holds the action-pool reference. */
436 UIActionPool *m_pActionPool;
[67046]437};
438
439
[67122]440/** QIManagerDialog extension providing GUI with the dialog to control media related functionality. */
[104226]441class UIMediumManager : public QIManagerDialog
[67046]442{
443 Q_OBJECT;
444
[67765]445signals:
[67046]446
[67765]447 /** Notifies listeners about data change rejected and should be reseted. */
448 void sigDataChangeRejected();
449 /** Notifies listeners about data change accepted and should be applied. */
450 void sigDataChangeAccepted();
451
452private slots:
453
454 /** @name Button-box stuff.
455 * @{ */
456 /** Handles button-box button click. */
457 void sltHandleButtonBoxClick(QAbstractButton *pButton);
458 /** @} */
459
[104226]460 /** @name Event-handling stuff.
461 * @{ */
462 /** Handles translation event. */
463 void sltRetranslateUI();
464 /** @} */
465
[67765]466private:
467
[87342]468 /** Constructs Medium Manager dialog.
[73717]469 * @param pCenterWidget Brings the widget reference to center according to.
470 * @param pActionPool Brings the action-pool reference. */
471 UIMediumManager(QWidget *pCenterWidget, UIActionPool *pActionPool);
[67046]472
473 /** @name Prepare/cleanup cascade.
474 * @{ */
[67573]475 /** Configures all. */
[93990]476 virtual void configure() RT_OVERRIDE;
[67573]477 /** Configures central-widget. */
[93990]478 virtual void configureCentralWidget() RT_OVERRIDE;
[67765]479 /** Configures button-box. */
[93990]480 virtual void configureButtonBox() RT_OVERRIDE;
[67573]481 /** Perform final preparations. */
[93990]482 virtual void finalize() RT_OVERRIDE;
[67046]483 /** @} */
484
[67573]485 /** @name Widget stuff.
486 * @{ */
487 /** Returns the widget. */
[93990]488 virtual UIMediumManagerWidget *widget() RT_OVERRIDE;
[67573]489 /** @} */
490
[73717]491 /** @name Action related variables.
492 * @{ */
493 /** Holds the action-pool reference. */
494 UIActionPool *m_pActionPool;
495 /** @} */
496
[69519]497 /** @name Progress-bar variables.
498 * @{ */
499 /** Holds the progress-bar widget instance. */
500 UIEnumerationProgressBar *m_pProgressBar;
501 /** @} */
502
[67046]503 /** Allow factory access to private/protected members: */
504 friend class UIMediumManagerFactory;
505};
506
[76581]507#endif /* !FEQT_INCLUDED_SRC_medium_UIMediumManager_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