VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.h@ 104158

Last change on this file since 104158 was 103982, checked in by vboxsync, 9 months ago

FE/Qt: bugref:10624. Replacing override and final keywords with RT_OVERRIDE and RT_FINAL defines.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1/* $Id: UIMediumSelector.h 103982 2024-03-21 11:43:53Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMediumSelector class declaration.
4 */
5
6/*
7 * Copyright (C) 2006-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_UIMediumSelector_h
29#define FEQT_INCLUDED_SRC_medium_UIMediumSelector_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* GUI includes: */
35#include "QIMainDialog.h"
36#include "QIWithRetranslateUI.h"
37#include "QIWithRestorableGeometry.h"
38#include "UIMedium.h"
39#include "UIMediumDefs.h"
40
41
42/* Forward declarations: */
43class QAction;
44class QTreeWidgetItem;
45class QITreeWidget;
46class QITreeWidgetItem;
47class QVBoxLayout;
48class QIDialogButtonBox;
49class QIToolBar;
50class UIActionPool;
51class UIMediumItem;
52class UIMediumSearchWidget;
53
54/** QIDialog extension providing GUI with a dialog to select an existing medium. */
55class SHARED_LIBRARY_STUFF UIMediumSelector : public QIWithRetranslateUI<QIWithRestorableGeometry<QIMainDialog> >
56{
57
58 Q_OBJECT;
59
60signals:
61
62public:
63
64 UIMediumSelector(const QUuid &uCurrentMediumId, UIMediumDeviceType enmMediumType, const QString &machineName,
65 const QString &machineSettingsFilePath, const QString &strMachineGuestOSTypeId,
66 const QUuid &uMachineID, QWidget *pParent, UIActionPool *pActionPool);
67 /** Disables/enables the create action and controls its visibility. */
68 void setEnableCreateAction(bool fEnable);
69 QList<QUuid> selectedMediumIds() const;
70
71 enum ReturnCode
72 {
73 ReturnCode_Rejected = 0,
74 ReturnCode_Accepted,
75 ReturnCode_LeftEmpty,
76 ReturnCode_Max
77 };
78
79 /** Creates and shows a UIMediumSelector dialog.
80 * @param parent Passes the parent of the dialog,
81 * @param enmMediumType Passes the medium type,
82 * @param uCurrentMediumId Passes the id of the currently selected medium,
83 * @param uSelectedMediumUuid Gets the selected medium id from selection dialog,
84 * @param strMachineFolder Passes the machine folder,
85 * @param strMachineName Passes the name of the machine,
86 * @param strMachineGuestOSTypeId Passes the type ID of machine's guest os,
87 * @param fEnableCreate Passes whether to show/enable create action in the medium selector dialog,
88 * @param uMachineID Passes the machine UUID,
89 * @param pActionPool Passes the action pool instance pointer,
90 * returns the return code of the UIMediumSelector::ReturnCode as int. In case of a medium selection
91 * UUID of the selected medium is returned in @param uSelectedMediumUuid.*/
92 static int openMediumSelectorDialog(QWidget *pParent, UIMediumDeviceType enmMediumType, const QUuid &uCurrentMediumId,
93 QUuid &uSelectedMediumUuid, const QString &strMachineFolder, const QString &strMachineName,
94 const QString &strMachineGuestOSTypeId, bool fEnableCreate, const QUuid &uMachineID,
95 UIActionPool *pActionPool);
96
97protected:
98
99 /** @name Event-handling stuff.
100 * @{ */
101 /** Handles translation event. */
102 virtual void retranslateUi() RT_OVERRIDE RT_FINAL;
103 void showEvent(QShowEvent *pEvent) RT_OVERRIDE RT_FINAL;
104 bool event(QEvent *pEvent) RT_OVERRIDE RT_FINAL;
105 /** @} */
106
107private slots:
108
109 void sltButtonLeaveEmpty();
110 void sltButtonCancel();
111 void sltButtonChoose();
112 void sltAddMedium();
113 void sltCreateMedium();
114 void sltHandleItemSelectionChanged();
115 void sltHandleTreeWidgetDoubleClick(QTreeWidgetItem * item, int column);
116 void sltHandleMediumCreated(const QUuid &uMediumId);
117 void sltHandleMediumEnumerationStart();
118 void sltHandleMediumEnumerated();
119 void sltHandleMediumEnumerationFinish();
120 void sltHandleRefresh();
121 void sltHandlePerformSearch();
122 void sltHandleTreeContextMenuRequest(const QPoint &point);
123 void sltHandleTreeExpandAllSignal();
124 void sltHandleTreeCollapseAllSignal();
125
126private:
127
128 /** @name Prepare/cleanup cascade.
129 * @{ */
130 /** Configures all. */
131 void configure();
132 void prepareWidgets();
133 void prepareActions();
134 void prepareMenuAndToolBar();
135 void prepareConnections();
136 /** Perform final preparations. */
137 void finalize();
138 /** @} */
139
140 void repopulateTreeWidget();
141 /** Disable/enable 'ok' button on the basis of having a selected item */
142 void updateChooseButton();
143 UIMediumItem* addTreeItem(const UIMedium &medium, QITreeWidgetItem *pParent);
144 void restoreSelection(const QList<QUuid> &selectedMediums, QVector<UIMediumItem*> &mediumList);
145 /** Recursively create the hard disk hierarchy under the tree widget */
146 UIMediumItem* createHardDiskItem(const UIMedium &medium, QITreeWidgetItem *pParent);
147 UIMediumItem* searchItem(const QTreeWidgetItem *pParent, const QUuid &mediumId);
148 /** Remember the default foreground brush of the tree so that we can reset tree items' foreground later */
149 void saveDefaultForeground();
150 void selectMedium(const QUuid &uMediumID);
151 void setTitle();
152 void saveDialogGeometry();
153 void loadSettings();
154 QWidget *m_pCentralWidget;
155 QVBoxLayout *m_pMainLayout;
156 QITreeWidget *m_pTreeWidget;
157 UIMediumDeviceType m_enmMediumType;
158 QIDialogButtonBox *m_pButtonBox;
159 QPushButton *m_pCancelButton;
160 QPushButton *m_pChooseButton;
161 QPushButton *m_pLeaveEmptyButton;
162 QMenu *m_pMainMenu;
163 QIToolBar *m_pToolBar;
164 QAction *m_pActionAdd;
165 QAction *m_pActionCreate;
166 QAction *m_pActionRefresh;
167 /** All the known media that are already attached to some vm are added under the following top level tree item */
168 QITreeWidgetItem *m_pAttachedSubTreeRoot;
169 /** All the known media that are not attached to any vm are added under the following top level tree item */
170 QITreeWidgetItem *m_pNotAttachedSubTreeRoot;
171 QWidget *m_pParent;
172 UIMediumSearchWidget *m_pSearchWidget;
173 /** The list all items added to tree. kept in sync. with tree to make searching easier (faster). */
174 QList<UIMediumItem*> m_mediumItemList;
175 /** List of items that are matching to the search. */
176 QList<UIMediumItem*> m_mathingItemList;
177 /** Index of the currently shown (scrolled) item in the m_mathingItemList. */
178 int m_iCurrentShownIndex;
179 QBrush m_defaultItemForeground;
180 QString m_strMachineFolder;
181 QString m_strMachineName;
182 QString m_strMachineGuestOSTypeId;
183 QUuid m_uMachineID;
184 QUuid m_uCurrentMediumId;
185 UIActionPool *m_pActionPool;
186 int m_iGeometrySaveTimerId;
187};
188
189#endif /* !FEQT_INCLUDED_SRC_medium_UIMediumSelector_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