1 | /* $Id: UIMediumSelector.h 81563 2019-10-29 10:23:58Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIMediumSelector class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-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_UIMediumSelector_h
|
---|
19 | #define FEQT_INCLUDED_SRC_medium_UIMediumSelector_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /* GUI includes: */
|
---|
25 | #include "QIMainDialog.h"
|
---|
26 | #include "QIWithRetranslateUI.h"
|
---|
27 | #include "UIMedium.h"
|
---|
28 | #include "UIMediumDefs.h"
|
---|
29 |
|
---|
30 |
|
---|
31 | /* Forward declarations: */
|
---|
32 | class QAction;
|
---|
33 | class QTreeWidgetItem;
|
---|
34 | class QITreeWidget;
|
---|
35 | class QITreeWidgetItem;
|
---|
36 | class QVBoxLayout;
|
---|
37 | class QIDialogButtonBox;
|
---|
38 | class UIMediumItem;
|
---|
39 | class UIMediumSearchWidget;
|
---|
40 | class UIToolBar;
|
---|
41 |
|
---|
42 |
|
---|
43 | /** QIDialog extension providing GUI with a dialog to select an existing medium. */
|
---|
44 | class SHARED_LIBRARY_STUFF UIMediumSelector : public QIWithRetranslateUI<QIMainDialog>
|
---|
45 | {
|
---|
46 |
|
---|
47 | Q_OBJECT;
|
---|
48 |
|
---|
49 | signals:
|
---|
50 |
|
---|
51 | public:
|
---|
52 |
|
---|
53 | UIMediumSelector(UIMediumDeviceType enmMediumType, const QString &machineName,
|
---|
54 | const QString &machineSettingsFilePath, const QString &strMachineGuestOSTypeId,
|
---|
55 | const QUuid &uMachineID, QWidget *pParent);
|
---|
56 | /** Disables/enables the create action and controls its visibility. */
|
---|
57 | void setEnableCreateAction(bool fEnable);
|
---|
58 | QList<QUuid> selectedMediumIds() const;
|
---|
59 |
|
---|
60 | enum ReturnCode
|
---|
61 | {
|
---|
62 | ReturnCode_Rejected = 0,
|
---|
63 | ReturnCode_Accepted,
|
---|
64 | ReturnCode_LeftEmpty,
|
---|
65 | ReturnCode_Max
|
---|
66 | };
|
---|
67 |
|
---|
68 | protected:
|
---|
69 |
|
---|
70 | void showEvent(QShowEvent *pEvent);
|
---|
71 |
|
---|
72 |
|
---|
73 | private slots:
|
---|
74 |
|
---|
75 | void sltButtonLeaveEmpty();
|
---|
76 | void sltButtonCancel();
|
---|
77 | void sltButtonChoose();
|
---|
78 | void sltAddMedium();
|
---|
79 | void sltCreateMedium();
|
---|
80 | void sltHandleItemSelectionChanged();
|
---|
81 | void sltHandleTreeWidgetDoubleClick(QTreeWidgetItem * item, int column);
|
---|
82 | void sltHandleMediumEnumerationStart();
|
---|
83 | void sltHandleMediumEnumerated();
|
---|
84 | void sltHandleMediumEnumerationFinish();
|
---|
85 | void sltHandleRefresh();
|
---|
86 | void sltHandlePerformSearch();
|
---|
87 | void sltHandleTreeContextMenuRequest(const QPoint &point);
|
---|
88 | void sltHandleTreeExpandAllSignal();
|
---|
89 | void sltHandleTreeCollapseAllSignal();
|
---|
90 |
|
---|
91 | private:
|
---|
92 |
|
---|
93 |
|
---|
94 | /** @name Event-handling stuff.
|
---|
95 | * @{ */
|
---|
96 | /** Handles translation event. */
|
---|
97 | virtual void retranslateUi() /* override */;
|
---|
98 | /** @} */
|
---|
99 |
|
---|
100 | /** @name Prepare/cleanup cascade.
|
---|
101 | * @{ */
|
---|
102 | /** Configures all. */
|
---|
103 | void configure();
|
---|
104 | void prepareWidgets();
|
---|
105 | void prepareActions();
|
---|
106 | void prepareMenuAndToolBar();
|
---|
107 | void prepareConnections();
|
---|
108 | /** Perform final preparations. */
|
---|
109 | void finalize();
|
---|
110 | /** @} */
|
---|
111 |
|
---|
112 | void repopulateTreeWidget();
|
---|
113 | /** Disable/enable 'ok' button on the basis of having a selected item */
|
---|
114 | void updateChooseButton();
|
---|
115 | UIMediumItem* addTreeItem(const UIMedium &medium, QITreeWidgetItem *pParent);
|
---|
116 | void restoreSelection(const QList<QUuid> &selectedMediums, QVector<UIMediumItem*> &mediumList);
|
---|
117 | /** Recursively create the hard disk hierarchy under the tree widget */
|
---|
118 | UIMediumItem* createHardDiskItem(const UIMedium &medium, QITreeWidgetItem *pParent);
|
---|
119 | UIMediumItem* searchItem(const QTreeWidgetItem *pParent, const QUuid &mediumId);
|
---|
120 | /** Remember the default foreground brush of the tree so that we can reset tree items' foreground later */
|
---|
121 | void saveDefaultForeground();
|
---|
122 | void selectMedium(const QUuid &uMediumID);
|
---|
123 | void scrollToItem(UIMediumItem* pItem);
|
---|
124 | void setTitle();
|
---|
125 | QWidget *m_pCentralWidget;
|
---|
126 | QVBoxLayout *m_pMainLayout;
|
---|
127 | QITreeWidget *m_pTreeWidget;
|
---|
128 | UIMediumDeviceType m_enmMediumType;
|
---|
129 | QIDialogButtonBox *m_pButtonBox;
|
---|
130 | QPushButton *m_pCancelButton;
|
---|
131 | QPushButton *m_pChooseButton;
|
---|
132 | QPushButton *m_pLeaveEmptyButton;
|
---|
133 | QMenu *m_pMainMenu;
|
---|
134 | UIToolBar *m_pToolBar;
|
---|
135 | QAction *m_pActionAdd;
|
---|
136 | QAction *m_pActionCreate;
|
---|
137 | QAction *m_pActionRefresh;
|
---|
138 | /** All the known media that are already attached to some vm are added under the following top level tree item */
|
---|
139 | QITreeWidgetItem *m_pAttachedSubTreeRoot;
|
---|
140 | /** All the known media that are not attached to any vm are added under the following top level tree item */
|
---|
141 | QITreeWidgetItem *m_pNotAttachedSubTreeRoot;
|
---|
142 | QWidget *m_pParent;
|
---|
143 | UIMediumSearchWidget *m_pSearchWidget;
|
---|
144 | /** The list all items added to tree. kept in sync. with tree to make searching easier (faster). */
|
---|
145 | QList<UIMediumItem*> m_mediumItemList;
|
---|
146 | /** List of items that are matching to the search. */
|
---|
147 | QList<UIMediumItem*> m_mathingItemList;
|
---|
148 | /** Index of the currently shown (scrolled) item in the m_mathingItemList. */
|
---|
149 | int m_iCurrentShownIndex;
|
---|
150 | QBrush m_defaultItemForeground;
|
---|
151 | QString m_strMachineFolder;
|
---|
152 | QString m_strMachineName;
|
---|
153 | QString m_strMachineGuestOSTypeId;
|
---|
154 | QUuid m_uMachineID;
|
---|
155 | };
|
---|
156 |
|
---|
157 | #endif /* !FEQT_INCLUDED_SRC_medium_UIMediumSelector_h */
|
---|