1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt4 GUI ("VirtualBox"):
|
---|
4 | * VBoxDiskImageManagerDlg class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2008 Sun Microsystems, Inc.
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | * additional information or have any questions.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef __VBoxDiskImageManagerDlg_h__
|
---|
24 | #define __VBoxDiskImageManagerDlg_h__
|
---|
25 |
|
---|
26 | #include "VBoxDiskImageManagerDlg.gen.h"
|
---|
27 | #include "QIWithRetranslateUI.h"
|
---|
28 | #include "COMDefs.h"
|
---|
29 | #include "VBoxDefs.h"
|
---|
30 | #include "VBoxMediaComboBox.h"
|
---|
31 |
|
---|
32 | /* Qt includes */
|
---|
33 | #include <QPointer>
|
---|
34 |
|
---|
35 | class DiskImageItem;
|
---|
36 | class VBoxToolBar;
|
---|
37 | class InfoPaneLabel;
|
---|
38 |
|
---|
39 | class VBoxDiskImageManagerDlg : public QIWithRetranslateUI2<QMainWindow>,
|
---|
40 | public Ui::VBoxDiskImageManagerDlg
|
---|
41 | {
|
---|
42 | Q_OBJECT;
|
---|
43 |
|
---|
44 | enum TabIndex { HDTab = 0,
|
---|
45 | CDTab,
|
---|
46 | FDTab };
|
---|
47 |
|
---|
48 | public:
|
---|
49 |
|
---|
50 | enum ResultCode { Rejected,
|
---|
51 | Accepted };
|
---|
52 |
|
---|
53 | VBoxDiskImageManagerDlg (QWidget *aParent = NULL, Qt::WindowFlags aFlags = Qt::Dialog);
|
---|
54 |
|
---|
55 | void setup (int aType, bool aDoSelect, const QUuid *aTargetVMId = NULL, bool aRefresh = true, CMachine aMachine = NULL, const QUuid & aHdId = QUuid(), const QUuid & aCdId = QUuid(), const QUuid & aFdId = QUuid());
|
---|
56 |
|
---|
57 | static void showModeless (bool aRefresh = true);
|
---|
58 | int exec();
|
---|
59 | int result() const;
|
---|
60 |
|
---|
61 | QUuid selectedUuid() const;
|
---|
62 | QString selectedPath() const;
|
---|
63 |
|
---|
64 | static QString composeHdToolTip (CHardDisk &aHd, VBoxMedia::Status aStatus, DiskImageItem *aItem = NULL);
|
---|
65 | static QString composeCdToolTip (CDVDImage &aCd, VBoxMedia::Status aStatus, DiskImageItem *aItem = NULL);
|
---|
66 | static QString composeFdToolTip (CFloppyImage &aFd, VBoxMedia::Status aStatus, DiskImageItem *aItem = NULL);
|
---|
67 |
|
---|
68 | public slots:
|
---|
69 |
|
---|
70 | void refreshAll();
|
---|
71 | virtual void setVisible (bool aVisible);
|
---|
72 |
|
---|
73 | protected:
|
---|
74 |
|
---|
75 | void retranslateUi();
|
---|
76 | virtual void closeEvent (QCloseEvent *aEvent);
|
---|
77 | virtual void keyPressEvent (QKeyEvent *aEvent);
|
---|
78 | virtual bool eventFilter (QObject *aObject, QEvent *aEvent);
|
---|
79 | /* @todo: Currently not used (Ported from Qt3): */
|
---|
80 | virtual void machineStateChanged (const VBoxMachineStateChangeEvent &aEvent);
|
---|
81 |
|
---|
82 | private slots:
|
---|
83 |
|
---|
84 | void mediaAdded (const VBoxMedia &aMedia);
|
---|
85 | void mediaUpdated (const VBoxMedia &aMedia);
|
---|
86 | void mediaRemoved (VBoxDefs::DiskType aType, const QUuid &aId);
|
---|
87 |
|
---|
88 | void mediaEnumStarted();
|
---|
89 | void mediaEnumerated (const VBoxMedia &aMedia, int aIndex);
|
---|
90 | void mediaEnumFinished (const VBoxMediaList &aList);
|
---|
91 |
|
---|
92 | void newImage();
|
---|
93 | void addImage();
|
---|
94 | void removeImage();
|
---|
95 | void releaseImage();
|
---|
96 |
|
---|
97 | void releaseDisk (const QUuid &aMachineId, const QUuid &aItemId, VBoxDefs::DiskType aDiskType);
|
---|
98 |
|
---|
99 | void processCurrentChanged (int index = -1);
|
---|
100 | void processCurrentChanged (QTreeWidgetItem *aItem, QTreeWidgetItem *aPrevItem = NULL);
|
---|
101 | void processDoubleClick (QTreeWidgetItem *aItem, int aColumn);
|
---|
102 | void processRightClick (const QPoint &aPos, QTreeWidgetItem *aItem, int aColumn);
|
---|
103 |
|
---|
104 | void accept();
|
---|
105 | void reject();
|
---|
106 | void done (int aRescode);
|
---|
107 |
|
---|
108 | void setResult (int aRescode);
|
---|
109 |
|
---|
110 | private:
|
---|
111 |
|
---|
112 | QTreeWidget* treeWidget (VBoxDefs::DiskType aType) const;
|
---|
113 | VBoxDefs::DiskType currentTreeWidgetType() const;
|
---|
114 | QTreeWidget* currentTreeWidget() const;
|
---|
115 |
|
---|
116 | QTreeWidgetItem *selectedItem (const QTreeWidget *aTree) const;
|
---|
117 | DiskImageItem *toDiskImageItem (QTreeWidgetItem *aItem) const;
|
---|
118 |
|
---|
119 | void setCurrentItem (QTreeWidget *aTree, QTreeWidgetItem *aItem);
|
---|
120 |
|
---|
121 | void addImageToList (const QString &aSource, VBoxDefs::DiskType aDiskType);
|
---|
122 | DiskImageItem* createImageNode (QTreeWidget *aTree, DiskImageItem *aRoot, const VBoxMedia &aMedia) const;
|
---|
123 |
|
---|
124 | DiskImageItem* createHdItem (QTreeWidget *aTree, const VBoxMedia &aMedia) const;
|
---|
125 | DiskImageItem* createCdItem (QTreeWidget *aTree, const VBoxMedia &aMedia) const;
|
---|
126 | DiskImageItem* createFdItem (QTreeWidget *aTree, const VBoxMedia &aMedia) const;
|
---|
127 |
|
---|
128 | void updateHdItem (DiskImageItem *aItem, const VBoxMedia &aMedia) const;
|
---|
129 | void updateCdItem (DiskImageItem *aItem, const VBoxMedia &aMedia) const;
|
---|
130 | void updateFdItem (DiskImageItem *aItem, const VBoxMedia &aMedia) const;
|
---|
131 |
|
---|
132 | DiskImageItem* searchItem (QTreeWidget *aTree, const QUuid &aId) const;
|
---|
133 | DiskImageItem* searchItem (QTreeWidget *aTree, VBoxMedia::Status aStatus) const;
|
---|
134 |
|
---|
135 | bool checkImage (DiskImageItem *aItem);
|
---|
136 |
|
---|
137 | bool checkDndUrls (const QList<QUrl> &aUrls) const;
|
---|
138 | void addDndUrls (const QList<QUrl> &aUrls);
|
---|
139 |
|
---|
140 | void clearInfoPanes();
|
---|
141 | void prepareToRefresh (int aTotal = 0);
|
---|
142 | void createInfoString (InfoPaneLabel *&aInfo, QWidget* aRoot, int aRow, int aCol, int aRowSpan = 1, int aColSpan = 1) const;
|
---|
143 |
|
---|
144 | void makeWarningMark (DiskImageItem *aItem, VBoxMedia::Status aStatus, VBoxDefs::DiskType aType) const;
|
---|
145 |
|
---|
146 | static QString DVDImageUsage (const QUuid &aId, QString &aSnapshotUsage);
|
---|
147 | static QString FloppyImageUsage (const QUuid &aId, QString &aSnapshotUsage);
|
---|
148 | static void DVDImageSnapshotUsage (const QUuid &aId, const CSnapshot &aSnapshot, QString &aUsage);
|
---|
149 | static void FloppyImageSnapshotUsage (const QUuid &aId, const CSnapshot &aSnapshot, QString &aUsage);
|
---|
150 |
|
---|
151 | /* Private member vars */
|
---|
152 | /* Window status */
|
---|
153 | bool mDoSelect;
|
---|
154 | int mRescode;
|
---|
155 | static VBoxDiskImageManagerDlg *mModelessDialog;
|
---|
156 | QPointer<QEventLoop> mEventLoop;
|
---|
157 |
|
---|
158 | /* Type if we are in the select modus */
|
---|
159 | int mType;
|
---|
160 |
|
---|
161 | /* Icon definitions */
|
---|
162 | QIcon mIconInaccessible;
|
---|
163 | QIcon mIconErroneous;
|
---|
164 | QIcon mIconHD;
|
---|
165 | QIcon mIconCD;
|
---|
166 | QIcon mIconFD;
|
---|
167 |
|
---|
168 | /* Menu & Toolbar */
|
---|
169 | QMenu *mActionsContextMenu;
|
---|
170 | QMenu *mActionsMenu;
|
---|
171 | VBoxToolBar *mActionsToolBar;
|
---|
172 | QAction *mNewAction;
|
---|
173 | QAction *mAddAction;
|
---|
174 | QAction *mEditAction;
|
---|
175 | QAction *mRemoveAction;
|
---|
176 | QAction *mReleaseAction;
|
---|
177 | QAction *mRefreshAction;
|
---|
178 |
|
---|
179 | /* The grid entries in the various information panels */
|
---|
180 | InfoPaneLabel *mHdsPane1;
|
---|
181 | InfoPaneLabel *mHdsPane2;
|
---|
182 | InfoPaneLabel *mHdsPane3;
|
---|
183 | InfoPaneLabel *mHdsPane4;
|
---|
184 | InfoPaneLabel *mHdsPane5;
|
---|
185 | InfoPaneLabel *mHdsPane6;
|
---|
186 | InfoPaneLabel *mHdsPane7;
|
---|
187 | InfoPaneLabel *mCdsPane1;
|
---|
188 | InfoPaneLabel *mCdsPane2;
|
---|
189 | InfoPaneLabel *mFdsPane1;
|
---|
190 | InfoPaneLabel *mFdsPane2;
|
---|
191 |
|
---|
192 | /* Machine */
|
---|
193 | CMachine mMachine;
|
---|
194 | QUuid mTargetVMId;
|
---|
195 | QUuid mHdSelectedId;
|
---|
196 | QUuid mCdSelectedId;
|
---|
197 | QUuid mFdSelectedId;
|
---|
198 | };
|
---|
199 |
|
---|
200 | #endif /* __VBoxDiskImageManagerDlg_h__ */
|
---|
201 |
|
---|