1 | /**
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * "Virtual Disk Manager" dialog UI include (Qt Designer)
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
14 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
15 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
16 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * If you received this file as part of a commercial VirtualBox
|
---|
19 | * distribution, then only the terms of your commercial VirtualBox
|
---|
20 | * license agreement apply instead of the previous paragraph.
|
---|
21 | */
|
---|
22 |
|
---|
23 | /****************************************************************************
|
---|
24 | ** ui.h extension file, included from the uic-generated form implementation.
|
---|
25 | **
|
---|
26 | ** If you wish to add, delete or rename functions or slots use
|
---|
27 | ** Qt Designer which will update this file, preserving your code. Create an
|
---|
28 | ** init() function in place of a constructor, and a destroy() function in
|
---|
29 | ** place of a destructor.
|
---|
30 | *****************************************************************************/
|
---|
31 |
|
---|
32 |
|
---|
33 | class DiskImageItem : public QListViewItem
|
---|
34 | {
|
---|
35 | public:
|
---|
36 |
|
---|
37 | DiskImageItem (DiskImageItem *parent, QString aLabel1,
|
---|
38 | QString aLabel2 = QString::null,
|
---|
39 | QString aLabel3 = QString::null,
|
---|
40 | QString aLabel4 = QString::null,
|
---|
41 | QString aLabel5 = QString::null,
|
---|
42 | QString aLabel6 = QString::null,
|
---|
43 | QString aLabel7 = QString::null,
|
---|
44 | QString aLabel8 = QString::null) :
|
---|
45 | QListViewItem (parent, aLabel1, aLabel2, aLabel3, aLabel4, aLabel5,
|
---|
46 | aLabel6, aLabel7, aLabel8),
|
---|
47 | mName (aLabel1), mStatus (VBoxMedia::Unknown) {}
|
---|
48 |
|
---|
49 | DiskImageItem (QListView *parent, QString aLabel1,
|
---|
50 | QString aLabel2 = QString::null,
|
---|
51 | QString aLabel3 = QString::null,
|
---|
52 | QString aLabel4 = QString::null,
|
---|
53 | QString aLabel5 = QString::null,
|
---|
54 | QString aLabel6 = QString::null,
|
---|
55 | QString aLabel7 = QString::null,
|
---|
56 | QString aLabel8 = QString::null) :
|
---|
57 | QListViewItem (parent, aLabel1, aLabel2, aLabel3, aLabel4, aLabel5,
|
---|
58 | aLabel6, aLabel7, aLabel8),
|
---|
59 | mName (aLabel1), mStatus (VBoxMedia::Unknown) {}
|
---|
60 |
|
---|
61 | QString getName() { return mName; }
|
---|
62 |
|
---|
63 | void setPath (QString aPath) { mPath = aPath; }
|
---|
64 | const QString &getPath() { return mPath; }
|
---|
65 |
|
---|
66 | void setUsage (QString aUsage) { mUsage = aUsage; }
|
---|
67 | const QString &getUsage() { return mUsage; }
|
---|
68 |
|
---|
69 | void setSnapshotName (QString aSnapshotName) { mSnapshotName = aSnapshotName; }
|
---|
70 | const QString &getSnapshotName() { return mSnapshotName; }
|
---|
71 |
|
---|
72 | void setDiskType (QString aDiskType) { mDiskType = aDiskType; }
|
---|
73 | const QString &getDiskType() { return mDiskType; }
|
---|
74 |
|
---|
75 | void setStorageType (QString aStorageType) { mStorageType = aStorageType; }
|
---|
76 | const QString &getStorageType() { return mStorageType; }
|
---|
77 |
|
---|
78 | void setVirtualSize (QString aVirtualSize) { mVirtualSize = aVirtualSize; }
|
---|
79 | const QString &getVirtualSize() { return mVirtualSize; }
|
---|
80 |
|
---|
81 | void setActualSize (QString aActualSize) { mActualSize = aActualSize; }
|
---|
82 | const QString &getActualSize() { return mActualSize; }
|
---|
83 |
|
---|
84 |
|
---|
85 | void setUuid (QUuid aUuid) { mUuid = aUuid; }
|
---|
86 | const QString &getUuid() { return mUuid; }
|
---|
87 |
|
---|
88 | void setMachineId (QString aMachineId) { mMachineId = aMachineId; }
|
---|
89 | const QString &getMachineId() { return mMachineId; }
|
---|
90 |
|
---|
91 |
|
---|
92 | void setStatus (VBoxMedia::Status aStatus) { mStatus = aStatus; }
|
---|
93 | VBoxMedia::Status getStatus() { return mStatus; }
|
---|
94 |
|
---|
95 |
|
---|
96 | void setToolTip (QString aToolTip) { mToolTip = aToolTip; }
|
---|
97 | const QString &getToolTip() { return mToolTip; }
|
---|
98 |
|
---|
99 | QString getInformation (const QString &aInfo, bool aCompact = true,
|
---|
100 | const QString &aElipsis = "middle")
|
---|
101 | {
|
---|
102 | QString compactString = QString ("<compact elipsis=\"%1\">").arg (aElipsis);
|
---|
103 | QString info = QString ("<nobr>%1%2%3</nobr>")
|
---|
104 | .arg (aCompact ? compactString : "")
|
---|
105 | .arg (aInfo.isEmpty() ? QObject::tr ("--") : aInfo)
|
---|
106 | .arg (aCompact ? "</compact>" : "");
|
---|
107 | return info;
|
---|
108 | }
|
---|
109 |
|
---|
110 | int rtti() const { return 1001; }
|
---|
111 |
|
---|
112 | int compare (QListViewItem *aItem, int aColumn, bool aAscending) const
|
---|
113 | {
|
---|
114 | ULONG64 thisValue = vboxGlobal().parseSize ( text (aColumn));
|
---|
115 | ULONG64 thatValue = vboxGlobal().parseSize (aItem->text (aColumn));
|
---|
116 | if (thisValue && thatValue)
|
---|
117 | {
|
---|
118 | if (thisValue == thatValue)
|
---|
119 | return 0;
|
---|
120 | else
|
---|
121 | return thisValue > thatValue ? 1 : -1;
|
---|
122 | }
|
---|
123 | else
|
---|
124 | return QListViewItem::compare (aItem, aColumn, aAscending);
|
---|
125 | }
|
---|
126 |
|
---|
127 | DiskImageItem* nextSibling() const
|
---|
128 | {
|
---|
129 | return (QListViewItem::nextSibling() &&
|
---|
130 | QListViewItem::nextSibling()->rtti() == 1001) ?
|
---|
131 | static_cast<DiskImageItem*> (QListViewItem::nextSibling()) : 0;
|
---|
132 | }
|
---|
133 |
|
---|
134 | void paintCell (QPainter *aPainter, const QColorGroup &aColorGroup,
|
---|
135 | int aColumn, int aWidth, int aSlign)
|
---|
136 | {
|
---|
137 | QColorGroup cGroup (aColorGroup);
|
---|
138 | if (mStatus == VBoxMedia::Unknown)
|
---|
139 | cGroup.setColor (QColorGroup::Text, cGroup.mid());
|
---|
140 | QListViewItem::paintCell (aPainter, cGroup, aColumn, aWidth, aSlign);
|
---|
141 | }
|
---|
142 |
|
---|
143 | protected:
|
---|
144 |
|
---|
145 | QString mName;
|
---|
146 | QString mPath;
|
---|
147 | QString mUsage;
|
---|
148 | QString mSnapshotName;
|
---|
149 | QString mDiskType;
|
---|
150 | QString mStorageType;
|
---|
151 | QString mVirtualSize;
|
---|
152 | QString mActualSize;
|
---|
153 |
|
---|
154 | QString mUuid;
|
---|
155 | QString mMachineId;
|
---|
156 |
|
---|
157 | QString mToolTip;
|
---|
158 |
|
---|
159 | VBoxMedia::Status mStatus;
|
---|
160 | };
|
---|
161 |
|
---|
162 |
|
---|
163 | VBoxDiskImageManagerDlg *VBoxDiskImageManagerDlg::mModelessDialog = 0;
|
---|
164 |
|
---|
165 |
|
---|
166 | void VBoxDiskImageManagerDlg::showModeless (const VBoxMediaList *list /* = NULL */)
|
---|
167 | {
|
---|
168 | if (!mModelessDialog)
|
---|
169 | {
|
---|
170 | mModelessDialog =
|
---|
171 | new VBoxDiskImageManagerDlg (NULL,
|
---|
172 | "VBoxDiskImageManagerDlg",
|
---|
173 | WType_TopLevel | WDestructiveClose);
|
---|
174 | mModelessDialog->setup (VBoxDefs::HD | VBoxDefs::CD | VBoxDefs::FD,
|
---|
175 | false, NULL, list);
|
---|
176 |
|
---|
177 | /* listen to events that may change the media status and refresh
|
---|
178 | * the contents of the modeless dialog */
|
---|
179 | /// @todo refreshAll() may be slow, so it may be better to analyze
|
---|
180 | // event details and update only what is changed */
|
---|
181 | //connect (&vboxGlobal(), SIGNAL (machineDataChanged (const VBoxMachineDataChangeEvent &)),
|
---|
182 | // mModelessDialog, SLOT (refreshAll()));
|
---|
183 | connect (&vboxGlobal(), SIGNAL (machineRegistered (const VBoxMachineRegisteredEvent &)),
|
---|
184 | mModelessDialog, SLOT (refreshAll()));
|
---|
185 | connect (&vboxGlobal(), SIGNAL (snapshotChanged (const VBoxSnapshotEvent &)),
|
---|
186 | mModelessDialog, SLOT (refreshAll()));
|
---|
187 |
|
---|
188 | /* listen also to the machine state change because hard disks of running
|
---|
189 | * VMs are inaccessible by the current design */
|
---|
190 | connect (&vboxGlobal(), SIGNAL (machineStateChanged (const VBoxMachineStateChangeEvent &)),
|
---|
191 | mModelessDialog, SLOT (machineStateChanged (const VBoxMachineStateChangeEvent &)));
|
---|
192 | }
|
---|
193 |
|
---|
194 | mModelessDialog->show();
|
---|
195 | mModelessDialog->setWindowState (mModelessDialog->windowState() &
|
---|
196 | ~WindowMinimized);
|
---|
197 | mModelessDialog->setActiveWindow();
|
---|
198 | }
|
---|
199 |
|
---|
200 |
|
---|
201 | void VBoxDiskImageManagerDlg::init()
|
---|
202 | {
|
---|
203 | polished = false;
|
---|
204 |
|
---|
205 | mToBeRefreshed = false;
|
---|
206 | mInLoop = false;
|
---|
207 |
|
---|
208 | defaultButton = searchDefaultButton();
|
---|
209 |
|
---|
210 | vbox = vboxGlobal().virtualBox();
|
---|
211 | Assert (!vbox.isNull());
|
---|
212 |
|
---|
213 | setIcon (QPixmap::fromMimeSource ("diskim_16px.png"));
|
---|
214 |
|
---|
215 | type = VBoxDefs::InvalidType;
|
---|
216 |
|
---|
217 | QImage img =
|
---|
218 | QMessageBox::standardIcon (QMessageBox::Warning).convertToImage();
|
---|
219 | img = img.smoothScale (16, 16);
|
---|
220 | pxInaccessible.convertFromImage (img);
|
---|
221 | Assert (!pxInaccessible.isNull());
|
---|
222 |
|
---|
223 | img =
|
---|
224 | QMessageBox::standardIcon (QMessageBox::Critical).convertToImage();
|
---|
225 | img = img.smoothScale (16, 16);
|
---|
226 | pxErroneous.convertFromImage (img);
|
---|
227 | Assert (!pxErroneous.isNull());
|
---|
228 |
|
---|
229 |
|
---|
230 | /* setup tab widget icons */
|
---|
231 | twImages->setTabIconSet (twImages->page (0),
|
---|
232 | VBoxGlobal::iconSet ("hd_16px.png",
|
---|
233 | "hd_disabled_16px.png"));
|
---|
234 | twImages->setTabIconSet (twImages->page (1),
|
---|
235 | VBoxGlobal::iconSet ("cd_16px.png",
|
---|
236 | "cd_disabled_16px.png"));
|
---|
237 | twImages->setTabIconSet (twImages->page (2),
|
---|
238 | VBoxGlobal::iconSet ("fd_16px.png",
|
---|
239 | "fd_disabled_16px.png"));
|
---|
240 |
|
---|
241 |
|
---|
242 | /* setup image list views */
|
---|
243 | hdsView->setColumnAlignment (1, Qt::AlignRight);
|
---|
244 | hdsView->setColumnAlignment (2, Qt::AlignRight);
|
---|
245 | hdsView->header()->setStretchEnabled (false);
|
---|
246 | hdsView->header()->setStretchEnabled (true, 0);
|
---|
247 |
|
---|
248 | fdsView->setColumnAlignment (1, Qt::AlignRight);
|
---|
249 | fdsView->header()->setStretchEnabled (false);
|
---|
250 | fdsView->header()->setStretchEnabled (true, 0);
|
---|
251 |
|
---|
252 | cdsView->setColumnAlignment (1, Qt::AlignRight);
|
---|
253 | cdsView->header()->setStretchEnabled (false);
|
---|
254 | cdsView->header()->setStretchEnabled (true, 0);
|
---|
255 |
|
---|
256 |
|
---|
257 | /* setup list-view's item tooltip */
|
---|
258 | hdsView->setShowToolTips (false);
|
---|
259 | cdsView->setShowToolTips (false);
|
---|
260 | fdsView->setShowToolTips (false);
|
---|
261 | connect (hdsView, SIGNAL (onItem (QListViewItem*)),
|
---|
262 | this, SLOT (mouseOnItem(QListViewItem*)));
|
---|
263 | connect (cdsView, SIGNAL (onItem (QListViewItem*)),
|
---|
264 | this, SLOT (mouseOnItem(QListViewItem*)));
|
---|
265 | connect (fdsView, SIGNAL (onItem (QListViewItem*)),
|
---|
266 | this, SLOT (mouseOnItem(QListViewItem*)));
|
---|
267 |
|
---|
268 |
|
---|
269 | /* status-bar currently disabled */
|
---|
270 | statusBar()->setHidden (true);
|
---|
271 |
|
---|
272 |
|
---|
273 | /* context menu composing */
|
---|
274 | itemMenu = new QPopupMenu (this, "itemMenu");
|
---|
275 |
|
---|
276 | imNewAction = new QAction (this, "imNewAction");
|
---|
277 | imAddAction = new QAction (this, "imAddAction");
|
---|
278 | // imEditAction = new QAction (this, "imEditAction");
|
---|
279 | imRemoveAction = new QAction (this, "imRemoveAction");
|
---|
280 | imReleaseAction = new QAction (this, "imReleaseAction");
|
---|
281 | imRefreshAction = new QAction (this, "imRefreshAction");
|
---|
282 |
|
---|
283 | connect (imNewAction, SIGNAL (activated()),
|
---|
284 | this, SLOT (newImage()));
|
---|
285 | connect (imAddAction, SIGNAL (activated()),
|
---|
286 | this, SLOT (addImage()));
|
---|
287 | // connect (imEditAction, SIGNAL (activated()),
|
---|
288 | // this, SLOT (editImage()));
|
---|
289 | connect (imRemoveAction, SIGNAL (activated()),
|
---|
290 | this, SLOT (removeImage()));
|
---|
291 | connect (imReleaseAction, SIGNAL (activated()),
|
---|
292 | this, SLOT (releaseImage()));
|
---|
293 | connect (imRefreshAction, SIGNAL (activated()),
|
---|
294 | this, SLOT (refreshAll()));
|
---|
295 |
|
---|
296 | imNewAction->setMenuText (tr ("&New..."));
|
---|
297 | imAddAction->setMenuText (tr ("&Add..."));
|
---|
298 | // imEditAction->setMenuText (tr ("&Edit..."));
|
---|
299 | imRemoveAction->setMenuText (tr ("R&emove"));
|
---|
300 | imReleaseAction->setMenuText (tr ("Re&lease"));
|
---|
301 | imRefreshAction->setMenuText (tr ("Re&fresh"));
|
---|
302 |
|
---|
303 | imNewAction->setText (tr ("New"));
|
---|
304 | imAddAction->setText (tr ("Add"));
|
---|
305 | // imEditAction->setText (tr ("Edit"));
|
---|
306 | imRemoveAction->setText (tr ("Remove"));
|
---|
307 | imReleaseAction->setText (tr ("Release"));
|
---|
308 | imRefreshAction->setText (tr ("Refresh"));
|
---|
309 |
|
---|
310 | imNewAction->setAccel (tr ("Ctrl+N"));
|
---|
311 | imAddAction->setAccel (tr ("Ctrl+A"));
|
---|
312 | // imEditAction->setAccel (tr ("Ctrl+E"));
|
---|
313 | imRemoveAction->setAccel (tr ("Ctrl+D"));
|
---|
314 | imReleaseAction->setAccel (tr ("Ctrl+L"));
|
---|
315 | imRefreshAction->setAccel (tr ("Ctrl+R"));
|
---|
316 |
|
---|
317 | imNewAction->setStatusTip (tr ("Create new VDI file and attach it to media list"));
|
---|
318 | imAddAction->setStatusTip (tr ("Add existing media image file to media list"));
|
---|
319 | // imEditAction->setStatusTip (tr ("Edit properties of selected media image file"));
|
---|
320 | imRemoveAction->setStatusTip (tr ("Remove selected media image file from media list"));
|
---|
321 | imReleaseAction->setStatusTip (tr ("Release selected media image file from being using in some VM"));
|
---|
322 | imRefreshAction->setStatusTip (tr ("Refresh media image list"));
|
---|
323 |
|
---|
324 | imNewAction->setIconSet (VBoxGlobal::iconSet ("hd_16px.png", "hd_disabled_16px.png"));
|
---|
325 | imAddAction->setIconSet (VBoxGlobal::iconSet ("cd_16px.png", "cd_disabled_16px.png"));
|
---|
326 | // imEditAction->setIconSet (VBoxGlobal::iconSet ("guesttools_16px.png", "guesttools_disabled_16px.png"));
|
---|
327 | imRemoveAction->setIconSet (VBoxGlobal::iconSet ("delete_16px.png", "delete_dis_16px.png"));
|
---|
328 | imReleaseAction->setIconSet (VBoxGlobal::iconSet ("start_16px.png", "start_dis_16px.png"));
|
---|
329 | imRefreshAction->setIconSet (VBoxGlobal::iconSet ("settings_16px.png", "settings_dis_16px.png"));
|
---|
330 |
|
---|
331 | // imEditAction->addTo (itemMenu);
|
---|
332 | imRemoveAction->addTo (itemMenu);
|
---|
333 | imReleaseAction->addTo (itemMenu);
|
---|
334 |
|
---|
335 |
|
---|
336 | /* toolbar composing */
|
---|
337 | toolBar = new VBoxToolBar (this, centralWidget(), "toolBar");
|
---|
338 | toolBar->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Minimum);
|
---|
339 | ((QVBoxLayout*)centralWidget()->layout())->insertWidget(0, toolBar);
|
---|
340 | setUsesTextLabel (true);
|
---|
341 |
|
---|
342 | imNewAction->addTo (toolBar);
|
---|
343 | imAddAction->addTo (toolBar);
|
---|
344 | toolBar->addSeparator();
|
---|
345 | // imEditAction->addTo (toolBar);
|
---|
346 | imRemoveAction->addTo (toolBar);
|
---|
347 | imReleaseAction->addTo (toolBar);
|
---|
348 | toolBar->addSeparator();
|
---|
349 | imRefreshAction->addTo (toolBar);
|
---|
350 |
|
---|
351 |
|
---|
352 | /* menu bar */
|
---|
353 | QPopupMenu *actionMenu = new QPopupMenu (this, "actionMenu");
|
---|
354 | imNewAction->addTo (actionMenu);
|
---|
355 | imAddAction->addTo (actionMenu);
|
---|
356 | actionMenu->insertSeparator();
|
---|
357 | // imEditAction->addTo (toolBar);
|
---|
358 | imRemoveAction->addTo (actionMenu);
|
---|
359 | imReleaseAction->addTo (actionMenu);
|
---|
360 | actionMenu->insertSeparator();
|
---|
361 | imRefreshAction->addTo (actionMenu);
|
---|
362 | menuBar()->insertItem (QString (tr ("&Actions")), actionMenu, 1);
|
---|
363 |
|
---|
364 |
|
---|
365 | /* setup size grip */
|
---|
366 | sizeGrip = new QSizeGrip (centralWidget(), "sizeGrip");
|
---|
367 | sizeGrip->resize (sizeGrip->sizeHint());
|
---|
368 | sizeGrip->stackUnder(buttonOk);
|
---|
369 |
|
---|
370 | /* setup information pane */
|
---|
371 | QApplication::setGlobalMouseTracking (true);
|
---|
372 | qApp->installEventFilter (this);
|
---|
373 | /* setup information pane layouts */
|
---|
374 | QGridLayout *hdsContainerLayout = new QGridLayout (hdsContainer, 4, 4);
|
---|
375 | hdsContainerLayout->setMargin (10);
|
---|
376 | QGridLayout *cdsContainerLayout = new QGridLayout (cdsContainer, 2, 4);
|
---|
377 | cdsContainerLayout->setMargin (10);
|
---|
378 | QGridLayout *fdsContainerLayout = new QGridLayout (fdsContainer, 2, 4);
|
---|
379 | fdsContainerLayout->setMargin (10);
|
---|
380 | /* create info-pane for hd list-view */
|
---|
381 | hdsPane1 = createInfoString (tr ("Location"), hdsContainer, 0, -1);
|
---|
382 | hdsPane2 = createInfoString (tr ("Disk Type"), hdsContainer, 1, 0);
|
---|
383 | hdsPane3 = createInfoString (tr ("Storage Type"), hdsContainer, 1, 1);
|
---|
384 | hdsPane4 = createInfoString (tr ("Attached to"), hdsContainer, 2, 0);
|
---|
385 | hdsPane5 = createInfoString (tr ("Snapshot"), hdsContainer, 2, 1);
|
---|
386 | /* create info-pane for cd list-view */
|
---|
387 | cdsPane1 = createInfoString (tr ("Location"), cdsContainer, 0, -1);
|
---|
388 | cdsPane2 = createInfoString (tr ("Attached to"), cdsContainer, 1, -1);
|
---|
389 | /* create info-pane for fd list-view */
|
---|
390 | fdsPane1 = createInfoString (tr ("Location"), fdsContainer, 0, -1);
|
---|
391 | fdsPane2 = createInfoString (tr ("Attached to"), fdsContainer, 1, -1);
|
---|
392 |
|
---|
393 |
|
---|
394 | /* enumeration progressbar creation */
|
---|
395 | mProgressText = new QLabel (tr ("Checking accessibility"), centralWidget());
|
---|
396 | mProgressText->setHidden (true);
|
---|
397 | buttonLayout->insertWidget (2, mProgressText);
|
---|
398 | mProgressBar = new QProgressBar (centralWidget());
|
---|
399 | mProgressBar->setHidden (true);
|
---|
400 | mProgressBar->setFrameShadow (QFrame::Sunken);
|
---|
401 | mProgressBar->setFrameShape (QFrame::Panel);
|
---|
402 | mProgressBar->setPercentageVisible (false);
|
---|
403 | mProgressBar->setMaximumWidth (100);
|
---|
404 | buttonLayout->insertWidget (3, mProgressBar);
|
---|
405 |
|
---|
406 | if (!vboxGlobal().isInEnumeratingProcess()) loadListViews();
|
---|
407 | }
|
---|
408 |
|
---|
409 |
|
---|
410 | void VBoxDiskImageManagerDlg::loadListViews()
|
---|
411 | {
|
---|
412 | /* load hd list */
|
---|
413 | CHardDiskEnumerator hdEnum = vbox.GetHardDisks().Enumerate();
|
---|
414 | while (hdEnum.HasMore())
|
---|
415 | {
|
---|
416 | CHardDisk hd = hdEnum.GetNext();
|
---|
417 | DiskImageItem *item = createHdItem (hdsView, 0, hd, VBoxMedia::Unknown);
|
---|
418 | createHdChildren (item, hd, VBoxMedia::Unknown);
|
---|
419 | }
|
---|
420 |
|
---|
421 | /* load cd list */
|
---|
422 | CDVDImageEnumerator cdEnum = vbox.GetDVDImages().Enumerate();
|
---|
423 | while (cdEnum.HasMore())
|
---|
424 | {
|
---|
425 | CDVDImage cd = cdEnum.GetNext();
|
---|
426 | DiskImageItem *item = createCdItem (cdsView, 0, cd, VBoxMedia::Unknown);
|
---|
427 | NOREF(item);
|
---|
428 | }
|
---|
429 |
|
---|
430 | /* load fd list */
|
---|
431 | CFloppyImageEnumerator fdEnum = vbox.GetFloppyImages().Enumerate();
|
---|
432 | while (fdEnum.HasMore())
|
---|
433 | {
|
---|
434 | CFloppyImage fd = fdEnum.GetNext();
|
---|
435 | DiskImageItem *item = createFdItem (fdsView, 0, fd, VBoxMedia::Unknown);
|
---|
436 | NOREF(item);
|
---|
437 | }
|
---|
438 | }
|
---|
439 |
|
---|
440 |
|
---|
441 | QIRichLabel *VBoxDiskImageManagerDlg::createInfoString (QString name, QWidget *root, int row, int column)
|
---|
442 | {
|
---|
443 | QLabel *nameLabel = new QLabel (name, root, "nameLabel");
|
---|
444 | QIRichLabel *infoLabel = new QIRichLabel (root, "infoPane");
|
---|
445 |
|
---|
446 | /* prevent the name columns from being expanded */
|
---|
447 | nameLabel->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
|
---|
448 |
|
---|
449 | if (column == -1)
|
---|
450 | {
|
---|
451 | /* add qt-html tags to prevent wrapping and to have the same initial
|
---|
452 | * height of nameLabel and infoLabel (plain text gets a height smaller
|
---|
453 | * than rich text */
|
---|
454 | nameLabel->setText (QString ("<nobr>%1:</nobr>").arg (name));
|
---|
455 |
|
---|
456 | ((QGridLayout *) root->layout())->addWidget (nameLabel, row, 0);
|
---|
457 | ((QGridLayout *) root->layout())->
|
---|
458 | addMultiCellWidget (infoLabel, row, row,
|
---|
459 | 1, ((QGridLayout *) root->layout())->numCols() - 1);
|
---|
460 | }
|
---|
461 | else
|
---|
462 | {
|
---|
463 | /* add some spacing to the left of the name field for all columns but
|
---|
464 | * the first one, to separate it from the value field (note that adding
|
---|
465 | * spacing to the right is not necessary since Qt does it anyway for
|
---|
466 | * rich text for whatever stupid reason). */
|
---|
467 | if (column == 0)
|
---|
468 | nameLabel->setText (QString ("<nobr>%1:</nobr>").arg (name));
|
---|
469 | else
|
---|
470 | nameLabel->setText (QString ("<nobr> %1:</nobr>").arg (name));
|
---|
471 |
|
---|
472 | ((QGridLayout *) root->layout())->addWidget (nameLabel, row, column * 2);
|
---|
473 | ((QGridLayout *) root->layout())->addWidget (infoLabel, row, column * 2 + 1);
|
---|
474 | }
|
---|
475 |
|
---|
476 | return infoLabel;
|
---|
477 | }
|
---|
478 |
|
---|
479 |
|
---|
480 | void VBoxDiskImageManagerDlg::showEvent (QShowEvent *e)
|
---|
481 | {
|
---|
482 | QMainWindow::showEvent (e);
|
---|
483 |
|
---|
484 | /* one may think that QWidget::polish() is the right place to do things
|
---|
485 | * below, but apparently, by the time when QWidget::polish() is called,
|
---|
486 | * the widget style & layout are not fully done, at least the minimum
|
---|
487 | * size hint is not properly calculated. Since this is sometimes necessary,
|
---|
488 | * we provide our own "polish" implementation. */
|
---|
489 |
|
---|
490 | if (polished)
|
---|
491 | return;
|
---|
492 |
|
---|
493 | polished = true;
|
---|
494 |
|
---|
495 | VBoxGlobal::centerWidget (this, parentWidget());
|
---|
496 | }
|
---|
497 |
|
---|
498 |
|
---|
499 | void VBoxDiskImageManagerDlg::mouseOnItem (QListViewItem *aItem)
|
---|
500 | {
|
---|
501 | QListView *currentList = getCurrentListView();
|
---|
502 | QString tip;
|
---|
503 | switch (aItem->rtti())
|
---|
504 | {
|
---|
505 | case 1001:
|
---|
506 | tip = static_cast<DiskImageItem*> (aItem)->getToolTip();
|
---|
507 | break;
|
---|
508 | default:
|
---|
509 | Assert (0);
|
---|
510 | }
|
---|
511 | QToolTip::add (currentList->viewport(), currentList->itemRect (aItem), tip);
|
---|
512 | }
|
---|
513 |
|
---|
514 |
|
---|
515 | void VBoxDiskImageManagerDlg::resizeEvent (QResizeEvent*)
|
---|
516 | {
|
---|
517 | sizeGrip->move (centralWidget()->rect().bottomRight() -
|
---|
518 | QPoint(sizeGrip->rect().width() - 1, sizeGrip->rect().height() - 1));
|
---|
519 | }
|
---|
520 |
|
---|
521 |
|
---|
522 | void VBoxDiskImageManagerDlg::closeEvent (QCloseEvent *aEvent)
|
---|
523 | {
|
---|
524 | mModelessDialog = 0;
|
---|
525 | aEvent->accept();
|
---|
526 | }
|
---|
527 |
|
---|
528 |
|
---|
529 | void VBoxDiskImageManagerDlg::keyPressEvent (QKeyEvent *aEvent)
|
---|
530 | {
|
---|
531 | if ( aEvent->state() == 0 ||
|
---|
532 | (aEvent->state() & Keypad && aEvent->key() == Key_Enter) )
|
---|
533 | {
|
---|
534 | switch ( aEvent->key() )
|
---|
535 | {
|
---|
536 | case Key_Enter:
|
---|
537 | case Key_Return:
|
---|
538 | {
|
---|
539 | QPushButton *currentDefault = searchDefaultButton();
|
---|
540 | if (currentDefault)
|
---|
541 | currentDefault->animateClick();
|
---|
542 | break;
|
---|
543 | }
|
---|
544 | case Key_Escape:
|
---|
545 | {
|
---|
546 | reject();
|
---|
547 | break;
|
---|
548 | }
|
---|
549 | }
|
---|
550 | }
|
---|
551 | else
|
---|
552 | aEvent->ignore();
|
---|
553 | }
|
---|
554 |
|
---|
555 |
|
---|
556 | QPushButton* VBoxDiskImageManagerDlg::searchDefaultButton()
|
---|
557 | {
|
---|
558 | QPushButton *defButton = 0;
|
---|
559 | QObjectList *list = queryList ("QPushButton");
|
---|
560 | QObjectListIt it (*list);
|
---|
561 | while ( (defButton = (QPushButton*)it.current()) && !defButton->isDefault() )
|
---|
562 | {
|
---|
563 | ++it;
|
---|
564 | }
|
---|
565 | return defButton;
|
---|
566 | }
|
---|
567 |
|
---|
568 |
|
---|
569 | int VBoxDiskImageManagerDlg::result() { return mRescode; }
|
---|
570 | void VBoxDiskImageManagerDlg::setResult (int aRescode) { mRescode = aRescode; }
|
---|
571 | void VBoxDiskImageManagerDlg::accept() { done( Accepted ); }
|
---|
572 | void VBoxDiskImageManagerDlg::reject() { done( Rejected ); }
|
---|
573 |
|
---|
574 | int VBoxDiskImageManagerDlg::exec()
|
---|
575 | {
|
---|
576 | setResult (0);
|
---|
577 |
|
---|
578 | if (mInLoop) return result();
|
---|
579 | show();
|
---|
580 | mInLoop = true;
|
---|
581 | qApp->eventLoop()->enterLoop();
|
---|
582 | mInLoop = false;
|
---|
583 |
|
---|
584 | return result();
|
---|
585 | }
|
---|
586 |
|
---|
587 | void VBoxDiskImageManagerDlg::done (int aResult)
|
---|
588 | {
|
---|
589 | setResult (aResult);
|
---|
590 |
|
---|
591 | if (mInLoop)
|
---|
592 | {
|
---|
593 | hide();
|
---|
594 | qApp->eventLoop()->exitLoop();
|
---|
595 | }
|
---|
596 | else
|
---|
597 | {
|
---|
598 | close();
|
---|
599 | }
|
---|
600 | }
|
---|
601 |
|
---|
602 |
|
---|
603 | QListView* VBoxDiskImageManagerDlg::getCurrentListView()
|
---|
604 | {
|
---|
605 | QListView *clv = static_cast<QListView*>(twImages->currentPage()->
|
---|
606 | queryList("QListView")->getFirst());
|
---|
607 | Assert(clv);
|
---|
608 | return clv;
|
---|
609 | }
|
---|
610 |
|
---|
611 |
|
---|
612 | bool VBoxDiskImageManagerDlg::eventFilter (QObject *aObject, QEvent *aEvent)
|
---|
613 | {
|
---|
614 | QListView *currentList = getCurrentListView();
|
---|
615 |
|
---|
616 | switch (aEvent->type())
|
---|
617 | {
|
---|
618 | case QEvent::DragEnter:
|
---|
619 | {
|
---|
620 | if (aObject == currentList)
|
---|
621 | {
|
---|
622 | QDragEnterEvent *dragEnterEvent =
|
---|
623 | static_cast<QDragEnterEvent*>(aEvent);
|
---|
624 | dragEnterEvent->acceptAction();
|
---|
625 | return true;
|
---|
626 | }
|
---|
627 | break;
|
---|
628 | }
|
---|
629 | case QEvent::Drop:
|
---|
630 | {
|
---|
631 | if (aObject == currentList)
|
---|
632 | {
|
---|
633 | QDropEvent *dropEvent =
|
---|
634 | static_cast<QDropEvent*>(aEvent);
|
---|
635 | QStringList *droppedList = new QStringList();
|
---|
636 | QUriDrag::decodeLocalFiles (dropEvent, *droppedList);
|
---|
637 | QCustomEvent *updateEvent = new QCustomEvent (1001);
|
---|
638 | updateEvent->setData (droppedList);
|
---|
639 | QApplication::postEvent (currentList, updateEvent);
|
---|
640 | dropEvent->acceptAction();
|
---|
641 | return true;
|
---|
642 | }
|
---|
643 | break;
|
---|
644 | }
|
---|
645 | case 1001: /* QCustomEvent 1001 - DnD Update Event */
|
---|
646 | {
|
---|
647 | if (aObject == currentList)
|
---|
648 | {
|
---|
649 | QCustomEvent *updateEvent =
|
---|
650 | static_cast<QCustomEvent*>(aEvent);
|
---|
651 | addDroppedImages ((QStringList*) updateEvent->data());
|
---|
652 | return true;
|
---|
653 | }
|
---|
654 | break;
|
---|
655 | }
|
---|
656 | case QEvent::FocusIn:
|
---|
657 | {
|
---|
658 | if (aObject->inherits ("QPushButton") && aObject->parent() == centralWidget())
|
---|
659 | {
|
---|
660 | ((QPushButton*)aObject)->setDefault (aObject != defaultButton);
|
---|
661 | if (defaultButton)
|
---|
662 | defaultButton->setDefault (aObject == defaultButton);
|
---|
663 | }
|
---|
664 | break;
|
---|
665 | }
|
---|
666 | case QEvent::FocusOut:
|
---|
667 | {
|
---|
668 | if (aObject->inherits ("QPushButton") && aObject->parent() == centralWidget())
|
---|
669 | {
|
---|
670 | if (defaultButton)
|
---|
671 | defaultButton->setDefault (aObject != defaultButton);
|
---|
672 | ((QPushButton*)aObject)->setDefault (aObject == defaultButton);
|
---|
673 | }
|
---|
674 | break;
|
---|
675 | }
|
---|
676 | default:
|
---|
677 | break;
|
---|
678 | }
|
---|
679 | return QMainWindow::eventFilter (aObject, aEvent);
|
---|
680 | }
|
---|
681 |
|
---|
682 |
|
---|
683 | void VBoxDiskImageManagerDlg::addDroppedImages (QStringList *aDroppedList)
|
---|
684 | {
|
---|
685 | QListView *currentList = getCurrentListView();
|
---|
686 |
|
---|
687 | DiskImageItem *item = 0;
|
---|
688 | for (QStringList::Iterator it = (*aDroppedList).begin();
|
---|
689 | it != (*aDroppedList).end(); ++it)
|
---|
690 | {
|
---|
691 | // Checking dropped media type
|
---|
692 | VBoxDefs::DiskType type = VBoxDefs::InvalidType;
|
---|
693 | if ((*it).endsWith ("iso", false))
|
---|
694 | {
|
---|
695 | if (currentList == cdsView) type = VBoxDefs::CD;
|
---|
696 | }
|
---|
697 | else if ((*it).endsWith ("img", false))
|
---|
698 | {
|
---|
699 | if (currentList == fdsView) type = VBoxDefs::FD;
|
---|
700 | }
|
---|
701 | else if ((*it).endsWith ("vdi", false))
|
---|
702 | {
|
---|
703 | if (currentList == hdsView) type = VBoxDefs::HD;
|
---|
704 | }
|
---|
705 | // If media type has been determined - attach this device
|
---|
706 | if (type) item = addImageToList (*it, type);
|
---|
707 | }
|
---|
708 | delete aDroppedList;
|
---|
709 | setCurrentItem (currentList, item);
|
---|
710 | }
|
---|
711 |
|
---|
712 |
|
---|
713 | DiskImageItem* VBoxDiskImageManagerDlg::addImageToList (QString aSource, VBoxDefs::DiskType aDiskType)
|
---|
714 | {
|
---|
715 | if (aSource.isEmpty())
|
---|
716 | return 0;
|
---|
717 |
|
---|
718 | DiskImageItem *item = 0;
|
---|
719 | QUuid uuid;
|
---|
720 | switch (aDiskType)
|
---|
721 | {
|
---|
722 | case VBoxDefs::HD:
|
---|
723 | {
|
---|
724 | CVirtualDiskImage vdi = vbox.OpenVirtualDiskImage (aSource);
|
---|
725 | if (vbox.isOk())
|
---|
726 | {
|
---|
727 | CHardDisk hardDisk = CUnknown (vdi);
|
---|
728 | vbox.RegisterHardDisk (hardDisk);
|
---|
729 | if (vbox.isOk())
|
---|
730 | {
|
---|
731 | VBoxMedia::Status status = hardDisk.GetAccessible() ?
|
---|
732 | VBoxMedia::Ok : VBoxMedia::Inaccessible;
|
---|
733 | item = createHdItem (hdsView, 0, hardDisk, status);
|
---|
734 | /* synchronize modeless dialog if present */
|
---|
735 | if (mModelessDialog && mModelessDialog != this)
|
---|
736 | mModelessDialog->createHdItem (mModelessDialog->hdsView,
|
---|
737 | 0, hardDisk, status);
|
---|
738 | }
|
---|
739 | }
|
---|
740 | break;
|
---|
741 | }
|
---|
742 | case VBoxDefs::CD:
|
---|
743 | {
|
---|
744 | CDVDImage dvdImage = vbox.OpenDVDImage (aSource, uuid);
|
---|
745 | if (vbox.isOk())
|
---|
746 | {
|
---|
747 | vbox.RegisterDVDImage (dvdImage);
|
---|
748 | if (vbox.isOk())
|
---|
749 | {
|
---|
750 | VBoxMedia::Status status = dvdImage.GetAccessible() ?
|
---|
751 | VBoxMedia::Ok : VBoxMedia::Inaccessible;
|
---|
752 | item = createCdItem (cdsView, 0, dvdImage, status);
|
---|
753 | /* synchronize modeless dialog if present */
|
---|
754 | if (mModelessDialog && mModelessDialog != this)
|
---|
755 | mModelessDialog->createCdItem (mModelessDialog->cdsView,
|
---|
756 | 0, dvdImage, status);
|
---|
757 | }
|
---|
758 | }
|
---|
759 | break;
|
---|
760 | }
|
---|
761 | case VBoxDefs::FD:
|
---|
762 | {
|
---|
763 | CFloppyImage floppyImage = vbox.OpenFloppyImage (aSource, uuid);
|
---|
764 | if (vbox.isOk())
|
---|
765 | {
|
---|
766 | vbox.RegisterFloppyImage (floppyImage);
|
---|
767 | if (vbox.isOk())
|
---|
768 | {
|
---|
769 | VBoxMedia::Status status = floppyImage.GetAccessible() ?
|
---|
770 | VBoxMedia::Ok : VBoxMedia::Inaccessible;
|
---|
771 | item = createFdItem (fdsView, 0, floppyImage, status);
|
---|
772 | /* synchronize modeless dialog if present */
|
---|
773 | if (mModelessDialog && mModelessDialog != this)
|
---|
774 | mModelessDialog->createFdItem (mModelessDialog->fdsView,
|
---|
775 | 0, floppyImage, status);
|
---|
776 | }
|
---|
777 | }
|
---|
778 | break;
|
---|
779 | }
|
---|
780 | default:
|
---|
781 | {
|
---|
782 | Assert(0);
|
---|
783 | }
|
---|
784 | }
|
---|
785 | return item;
|
---|
786 | }
|
---|
787 |
|
---|
788 |
|
---|
789 | DiskImageItem* VBoxDiskImageManagerDlg::createImageNode (QListView *aList,
|
---|
790 | DiskImageItem *aRoot,
|
---|
791 | QString aName,
|
---|
792 | QString aLabel2,
|
---|
793 | QString aLabel3,
|
---|
794 | QString aLabel4,
|
---|
795 | QString aLabel5,
|
---|
796 | QString aLabel6,
|
---|
797 | QString aLabel7,
|
---|
798 | QString aLabel8)
|
---|
799 | {
|
---|
800 | DiskImageItem *item = 0;
|
---|
801 |
|
---|
802 | if (aList)
|
---|
803 | item = new DiskImageItem (aList, aName,
|
---|
804 | aLabel2, aLabel3, aLabel4, aLabel5, aLabel6, aLabel7, aLabel8);
|
---|
805 | else if (aRoot)
|
---|
806 | item = new DiskImageItem (aRoot, aName,
|
---|
807 | aLabel2, aLabel3, aLabel4, aLabel5, aLabel6, aLabel7, aLabel8);
|
---|
808 | else
|
---|
809 | Assert(0);
|
---|
810 |
|
---|
811 | return item;
|
---|
812 | }
|
---|
813 |
|
---|
814 |
|
---|
815 | void VBoxDiskImageManagerDlg::invokePopup (QListViewItem *aItem, const QPoint & aPos, int)
|
---|
816 | {
|
---|
817 | if (aItem)
|
---|
818 | itemMenu->popup(aPos);
|
---|
819 | }
|
---|
820 |
|
---|
821 |
|
---|
822 | QString VBoxDiskImageManagerDlg::getDVDImageUsage (const QUuid &aId)
|
---|
823 | {
|
---|
824 | CVirtualBox vbox = vboxGlobal().virtualBox();
|
---|
825 |
|
---|
826 | QStringList permMachines =
|
---|
827 | QStringList::split (' ', vbox.GetDVDImageUsage (aId, CEnums::PermanentUsage));
|
---|
828 | QStringList tempMachines =
|
---|
829 | QStringList::split (' ', vbox.GetDVDImageUsage (aId, CEnums::TemporaryUsage));
|
---|
830 |
|
---|
831 | QString usage;
|
---|
832 |
|
---|
833 | for (QStringList::Iterator it = permMachines.begin();
|
---|
834 | it != permMachines.end();
|
---|
835 | ++it)
|
---|
836 | {
|
---|
837 | if (usage)
|
---|
838 | usage += ", ";
|
---|
839 | usage += vbox.GetMachine (QUuid (*it)).GetName();
|
---|
840 | }
|
---|
841 |
|
---|
842 | for (QStringList::Iterator it = tempMachines.begin();
|
---|
843 | it != tempMachines.end();
|
---|
844 | ++it)
|
---|
845 | {
|
---|
846 | /* skip IDs that are in the permanent list */
|
---|
847 | if (!permMachines.contains (*it))
|
---|
848 | {
|
---|
849 | if (usage)
|
---|
850 | usage += ", [";
|
---|
851 | else
|
---|
852 | usage += "[";
|
---|
853 | usage += vbox.GetMachine (QUuid (*it)).GetName() + "]";
|
---|
854 | }
|
---|
855 | }
|
---|
856 |
|
---|
857 | return usage;
|
---|
858 | }
|
---|
859 |
|
---|
860 | QString VBoxDiskImageManagerDlg::getFloppyImageUsage (const QUuid &aId)
|
---|
861 | {
|
---|
862 | CVirtualBox vbox = vboxGlobal().virtualBox();
|
---|
863 |
|
---|
864 | QStringList permMachines =
|
---|
865 | QStringList::split (' ', vbox.GetFloppyImageUsage (aId, CEnums::PermanentUsage));
|
---|
866 | QStringList tempMachines =
|
---|
867 | QStringList::split (' ', vbox.GetFloppyImageUsage (aId, CEnums::TemporaryUsage));
|
---|
868 |
|
---|
869 | QString usage;
|
---|
870 |
|
---|
871 | for (QStringList::Iterator it = permMachines.begin();
|
---|
872 | it != permMachines.end();
|
---|
873 | ++it)
|
---|
874 | {
|
---|
875 | if (usage)
|
---|
876 | usage += ", ";
|
---|
877 | usage += vbox.GetMachine (QUuid (*it)).GetName();
|
---|
878 | }
|
---|
879 |
|
---|
880 | for (QStringList::Iterator it = tempMachines.begin();
|
---|
881 | it != tempMachines.end();
|
---|
882 | ++it)
|
---|
883 | {
|
---|
884 | /* skip IDs that are in the permanent list */
|
---|
885 | if (!permMachines.contains (*it))
|
---|
886 | {
|
---|
887 | if (usage)
|
---|
888 | usage += ", [";
|
---|
889 | else
|
---|
890 | usage += "[";
|
---|
891 | usage += vbox.GetMachine (QUuid (*it)).GetName() + "]";
|
---|
892 | }
|
---|
893 | }
|
---|
894 |
|
---|
895 | return usage;
|
---|
896 | }
|
---|
897 |
|
---|
898 |
|
---|
899 | QString VBoxDiskImageManagerDlg::composeHdToolTip (CHardDisk &aHd,
|
---|
900 | VBoxMedia::Status aStatus)
|
---|
901 | {
|
---|
902 | CVirtualBox vbox = vboxGlobal().virtualBox();
|
---|
903 | QUuid machineId = aHd.GetMachineId();
|
---|
904 |
|
---|
905 | QString src = aHd.GetLocation();
|
---|
906 | QFileInfo fi (src);
|
---|
907 | QString location = aHd.GetStorageType() == CEnums::ISCSIHardDisk ? src :
|
---|
908 | QDir::convertSeparators (fi.absFilePath());
|
---|
909 |
|
---|
910 | QString storageType = vboxGlobal().toString (aHd.GetStorageType());
|
---|
911 | QString hardDiskType = vboxGlobal().hardDiskTypeString (aHd);
|
---|
912 |
|
---|
913 | QString usage;
|
---|
914 | if (!machineId.isNull())
|
---|
915 | usage = vbox.GetMachine (machineId).GetName();
|
---|
916 |
|
---|
917 | QString snapshotName;
|
---|
918 | if (!machineId.isNull() && !aHd.GetSnapshotId().isNull())
|
---|
919 | {
|
---|
920 | CSnapshot snapshot = vbox.GetMachine (machineId).
|
---|
921 | GetSnapshot (aHd.GetSnapshotId());
|
---|
922 | if (!snapshot.isNull())
|
---|
923 | snapshotName = snapshot.GetName();
|
---|
924 | }
|
---|
925 |
|
---|
926 | /* compose tool-tip information */
|
---|
927 | QString tip;
|
---|
928 | switch (aStatus)
|
---|
929 | {
|
---|
930 | case VBoxMedia::Unknown:
|
---|
931 | {
|
---|
932 | tip = tr ("<nobr><b>%1</b></nobr><br>"
|
---|
933 | "Checking accessibility...", "HDD")
|
---|
934 | .arg (location);
|
---|
935 | break;
|
---|
936 | }
|
---|
937 | case VBoxMedia::Ok:
|
---|
938 | {
|
---|
939 | tip = tr ("<nobr><b>%1</b></nobr><br>"
|
---|
940 | "<nobr>Disk type: %2</nobr><br>"
|
---|
941 | "<nobr>Storage type: %3</nobr>")
|
---|
942 | .arg (location)
|
---|
943 | .arg (hardDiskType)
|
---|
944 | .arg (storageType);
|
---|
945 |
|
---|
946 | if (!usage.isNull())
|
---|
947 | tip += tr ("<br><nobr>Attached to: %1</nobr>", "HDD")
|
---|
948 | .arg (usage);
|
---|
949 | if (!snapshotName.isNull())
|
---|
950 | tip += tr ("<br><nobr>Snapshot: %5</nobr>", "HDD")
|
---|
951 | .arg (snapshotName);
|
---|
952 | break;
|
---|
953 | }
|
---|
954 | case VBoxMedia::Error:
|
---|
955 | {
|
---|
956 | /// @todo (r=dmik) paass a complete VBoxMedia instance here
|
---|
957 | // to get the result of blabla.GetAccessible() call form CUnknown
|
---|
958 | tip = tr ("<nobr><b>%1</b></nobr><br>"
|
---|
959 | "Error checking media accessibility", "HDD")
|
---|
960 | .arg (location);
|
---|
961 | break;
|
---|
962 | }
|
---|
963 | case VBoxMedia::Inaccessible:
|
---|
964 | {
|
---|
965 | tip = tr ("<nobr><b>%1</b></nobr><br>%2", "HDD")
|
---|
966 | .arg (location)
|
---|
967 | .arg (VBoxGlobal::highlight (aHd.GetLastAccessError(),
|
---|
968 | true /* aToolTip */));
|
---|
969 | break;
|
---|
970 | }
|
---|
971 | default:
|
---|
972 | AssertFailed();
|
---|
973 | }
|
---|
974 | return tip;
|
---|
975 | }
|
---|
976 |
|
---|
977 | QString VBoxDiskImageManagerDlg::composeCdToolTip (CDVDImage &aCd,
|
---|
978 | VBoxMedia::Status aStatus)
|
---|
979 | {
|
---|
980 | QString src = aCd.GetFilePath();
|
---|
981 | QFileInfo fi (src);
|
---|
982 | QString location = QDir::convertSeparators (fi.absFilePath ());
|
---|
983 | QUuid uuid = aCd.GetId();
|
---|
984 | QString usage = getDVDImageUsage (uuid);
|
---|
985 |
|
---|
986 | /* compose tool-tip information */
|
---|
987 | QString tip;
|
---|
988 | switch (aStatus)
|
---|
989 | {
|
---|
990 | case VBoxMedia::Unknown:
|
---|
991 | {
|
---|
992 | tip = tr ("<nobr><b>%1</b></nobr><br>"
|
---|
993 | "Checking accessibility...", "CD/DVD/Floppy")
|
---|
994 | .arg (location);
|
---|
995 | break;
|
---|
996 | }
|
---|
997 | case VBoxMedia::Ok:
|
---|
998 | {
|
---|
999 | tip = tr ("<nobr><b>%1</b></nobr>", "CD/DVD/Floppy")
|
---|
1000 | .arg (location);
|
---|
1001 |
|
---|
1002 | if (!usage.isNull())
|
---|
1003 | tip += tr ("<br><nobr>Attached to: %1</nobr>",
|
---|
1004 | "CD/DVD/Floppy")
|
---|
1005 | .arg (usage);
|
---|
1006 | break;
|
---|
1007 | }
|
---|
1008 | case VBoxMedia::Error:
|
---|
1009 | {
|
---|
1010 | /// @todo (r=dmik) paass a complete VBoxMedia instance here
|
---|
1011 | // to get the result of blabla.GetAccessible() call form CUnknown
|
---|
1012 | tip = tr ("<nobr><b>%1</b></nobr><br>"
|
---|
1013 | "Error checking media accessibility", "CD/DVD/Floppy")
|
---|
1014 | .arg (location);
|
---|
1015 | break;
|
---|
1016 | }
|
---|
1017 | case VBoxMedia::Inaccessible:
|
---|
1018 | {
|
---|
1019 | /// @todo (r=dmik) correct this when GetLastAccessError() is
|
---|
1020 | // implemented for IDVDImage
|
---|
1021 | tip = tr ("<nobr><b>%1</b></nobr><br>%2")
|
---|
1022 | .arg (location)
|
---|
1023 | .arg (tr ("The image file is not accessible",
|
---|
1024 | "CD/DVD/Floppy"));
|
---|
1025 | break;
|
---|
1026 | }
|
---|
1027 | default:
|
---|
1028 | AssertFailed();
|
---|
1029 | }
|
---|
1030 | return tip;
|
---|
1031 | }
|
---|
1032 |
|
---|
1033 | QString VBoxDiskImageManagerDlg::composeFdToolTip (CFloppyImage &aFd,
|
---|
1034 | VBoxMedia::Status aStatus)
|
---|
1035 | {
|
---|
1036 | QString src = aFd.GetFilePath();
|
---|
1037 | QFileInfo fi (src);
|
---|
1038 | QString location = QDir::convertSeparators (fi.absFilePath ());
|
---|
1039 | QUuid uuid = aFd.GetId();
|
---|
1040 | QString usage = getFloppyImageUsage (uuid);
|
---|
1041 |
|
---|
1042 | /* compose tool-tip information */
|
---|
1043 | /* compose tool-tip information */
|
---|
1044 | QString tip;
|
---|
1045 | switch (aStatus)
|
---|
1046 | {
|
---|
1047 | case VBoxMedia::Unknown:
|
---|
1048 | {
|
---|
1049 | tip = tr ("<nobr><b>%1</b></nobr><br>"
|
---|
1050 | "Checking accessibility...", "CD/DVD/Floppy")
|
---|
1051 | .arg (location);
|
---|
1052 | break;
|
---|
1053 | }
|
---|
1054 | case VBoxMedia::Ok:
|
---|
1055 | {
|
---|
1056 | tip = tr ("<nobr><b>%1</b></nobr>", "CD/DVD/Floppy")
|
---|
1057 | .arg (location);
|
---|
1058 |
|
---|
1059 | if (!usage.isNull())
|
---|
1060 | tip += tr ("<br><nobr>Attached to: %1</nobr>",
|
---|
1061 | "CD/DVD/Floppy")
|
---|
1062 | .arg (usage);
|
---|
1063 | break;
|
---|
1064 | }
|
---|
1065 | case VBoxMedia::Error:
|
---|
1066 | {
|
---|
1067 | /// @todo (r=dmik) paass a complete VBoxMedia instance here
|
---|
1068 | // to get the result of blabla.GetAccessible() call form CUnknown
|
---|
1069 | tip = tr ("<nobr><b>%1</b></nobr><br>"
|
---|
1070 | "Error checking media accessibility", "CD/DVD/Floppy")
|
---|
1071 | .arg (location);
|
---|
1072 | break;
|
---|
1073 | }
|
---|
1074 | case VBoxMedia::Inaccessible:
|
---|
1075 | {
|
---|
1076 | /// @todo (r=dmik) correct this when GetLastAccessError() is
|
---|
1077 | // implemented for IDVDImage
|
---|
1078 | tip = tr ("<nobr><b>%1</b></nobr><br>%2")
|
---|
1079 | .arg (location)
|
---|
1080 | .arg (tr ("The image file is not accessible",
|
---|
1081 | "CD/DVD/Floppy"));
|
---|
1082 | break;
|
---|
1083 | }
|
---|
1084 | default:
|
---|
1085 | AssertFailed();
|
---|
1086 | }
|
---|
1087 | return tip;
|
---|
1088 | }
|
---|
1089 |
|
---|
1090 |
|
---|
1091 | DiskImageItem* VBoxDiskImageManagerDlg::createHdItem (QListView *aList,
|
---|
1092 | DiskImageItem *aRoot,
|
---|
1093 | CHardDisk &aHd,
|
---|
1094 | VBoxMedia::Status aStatus)
|
---|
1095 | {
|
---|
1096 | DiskImageItem *item = 0;
|
---|
1097 |
|
---|
1098 | QUuid uuid = aHd.GetId();
|
---|
1099 | QString src = aHd.GetLocation();
|
---|
1100 | QUuid machineId = aHd.GetMachineId();
|
---|
1101 |
|
---|
1102 | QString usage;
|
---|
1103 | if (!machineId.isNull())
|
---|
1104 | usage = vbox.GetMachine (machineId).GetName();
|
---|
1105 | QString storageType = vboxGlobal().toString (aHd.GetStorageType());
|
---|
1106 | QString hardDiskType = vboxGlobal().hardDiskTypeString (aHd);
|
---|
1107 | QString virtualSize = aStatus == VBoxMedia::Ok ?
|
---|
1108 | vboxGlobal().formatSize ((ULONG64)aHd.GetSize() * _1M) : QString ("--");
|
---|
1109 | QString actualSize = aStatus == VBoxMedia::Ok ?
|
---|
1110 | vboxGlobal().formatSize (aHd.GetActualSize()) : QString ("--");
|
---|
1111 | QString snapshotName;
|
---|
1112 | if (!machineId.isNull() && !aHd.GetSnapshotId().isNull())
|
---|
1113 | {
|
---|
1114 | CSnapshot snapshot = vbox.GetMachine (machineId).
|
---|
1115 | GetSnapshot (aHd.GetSnapshotId());
|
---|
1116 | if (!snapshot.isNull())
|
---|
1117 | snapshotName = QString ("%1").arg (snapshot.GetName());
|
---|
1118 | }
|
---|
1119 | QFileInfo fi (src);
|
---|
1120 |
|
---|
1121 | item = createImageNode (aList, aRoot,
|
---|
1122 | fi.fileName(),
|
---|
1123 | virtualSize,
|
---|
1124 | actualSize);
|
---|
1125 | item->setPath (aHd.GetStorageType() == CEnums::ISCSIHardDisk ? src :
|
---|
1126 | QDir::convertSeparators (fi.absFilePath()));
|
---|
1127 | item->setUsage (usage);
|
---|
1128 | item->setSnapshotName (snapshotName);
|
---|
1129 | item->setDiskType (hardDiskType);
|
---|
1130 | item->setStorageType (storageType);
|
---|
1131 | item->setVirtualSize (virtualSize);
|
---|
1132 | item->setActualSize (actualSize);
|
---|
1133 | item->setUuid (uuid);
|
---|
1134 | item->setMachineId (machineId);
|
---|
1135 | item->setToolTip (composeHdToolTip (aHd, aStatus));
|
---|
1136 | item->setStatus (aStatus);
|
---|
1137 |
|
---|
1138 | return item;
|
---|
1139 | }
|
---|
1140 |
|
---|
1141 |
|
---|
1142 | DiskImageItem* VBoxDiskImageManagerDlg::createCdItem (QListView *aList,
|
---|
1143 | DiskImageItem *aRoot,
|
---|
1144 | CDVDImage &aCd,
|
---|
1145 | VBoxMedia::Status aStatus)
|
---|
1146 | {
|
---|
1147 | DiskImageItem *item = 0;
|
---|
1148 |
|
---|
1149 | QUuid uuid = aCd.GetId();
|
---|
1150 | QString src = aCd.GetFilePath();
|
---|
1151 | QString usage = getDVDImageUsage (uuid);
|
---|
1152 |
|
---|
1153 | QString size = aStatus == VBoxMedia::Ok ?
|
---|
1154 | vboxGlobal().formatSize (aCd.GetSize()) : QString ("--");
|
---|
1155 | QFileInfo fi (src);
|
---|
1156 |
|
---|
1157 | item = createImageNode (aList, aRoot,
|
---|
1158 | fi.fileName(),
|
---|
1159 | size);
|
---|
1160 | item->setPath (QDir::convertSeparators (fi.absFilePath ()));
|
---|
1161 | item->setUsage (usage);
|
---|
1162 | item->setActualSize (size);
|
---|
1163 | item->setUuid (uuid);
|
---|
1164 | item->setToolTip (composeCdToolTip (aCd, aStatus));
|
---|
1165 | item->setStatus (aStatus);
|
---|
1166 |
|
---|
1167 | return item;
|
---|
1168 | }
|
---|
1169 |
|
---|
1170 |
|
---|
1171 | DiskImageItem* VBoxDiskImageManagerDlg::createFdItem (QListView *aList,
|
---|
1172 | DiskImageItem *aRoot,
|
---|
1173 | CFloppyImage &aFd,
|
---|
1174 | VBoxMedia::Status aStatus)
|
---|
1175 | {
|
---|
1176 | DiskImageItem *item = 0;
|
---|
1177 |
|
---|
1178 | QUuid uuid = aFd.GetId();
|
---|
1179 | QString src = aFd.GetFilePath();
|
---|
1180 | QString usage = getFloppyImageUsage (uuid);
|
---|
1181 |
|
---|
1182 | QString size = aStatus == VBoxMedia::Ok ?
|
---|
1183 | vboxGlobal().formatSize (aFd.GetSize()) : QString ("--");
|
---|
1184 | QFileInfo fi (src);
|
---|
1185 |
|
---|
1186 | item = createImageNode (aList, aRoot,
|
---|
1187 | fi.fileName(),
|
---|
1188 | size);
|
---|
1189 | item->setPath (QDir::convertSeparators (fi.absFilePath ()));
|
---|
1190 | item->setUsage (usage);
|
---|
1191 | item->setActualSize (size);
|
---|
1192 | item->setUuid (uuid);
|
---|
1193 | item->setToolTip (composeFdToolTip (aFd, aStatus));
|
---|
1194 | item->setStatus (aStatus);
|
---|
1195 |
|
---|
1196 | return item;
|
---|
1197 | }
|
---|
1198 |
|
---|
1199 |
|
---|
1200 | void VBoxDiskImageManagerDlg::createHdChildren (DiskImageItem *aRoot,
|
---|
1201 | CHardDisk &aHd,
|
---|
1202 | VBoxMedia::Status aStatus)
|
---|
1203 | {
|
---|
1204 | CHardDiskEnumerator enumerator = aHd.GetChildren().Enumerate();
|
---|
1205 | while (enumerator.HasMore())
|
---|
1206 | {
|
---|
1207 | CHardDisk subHd = enumerator.GetNext();
|
---|
1208 | DiskImageItem *subItem = createHdItem (0, aRoot, subHd, aStatus);
|
---|
1209 | createHdChildren (subItem, subHd, aStatus);
|
---|
1210 | }
|
---|
1211 | }
|
---|
1212 |
|
---|
1213 |
|
---|
1214 | DiskImageItem* VBoxDiskImageManagerDlg::searchItem (QListView *aList, QUuid aId)
|
---|
1215 | {
|
---|
1216 | DiskImageItem *item = 0, *iterator = 0;
|
---|
1217 | if (aList->firstChild() && aList->firstChild()->rtti() == 1001)
|
---|
1218 | iterator = static_cast<DiskImageItem*>(aList->firstChild());
|
---|
1219 | while (iterator)
|
---|
1220 | {
|
---|
1221 | if (iterator->getUuid() == aId)
|
---|
1222 | item = iterator;
|
---|
1223 | iterator = iterator->nextSibling();
|
---|
1224 | }
|
---|
1225 | return item;
|
---|
1226 | }
|
---|
1227 |
|
---|
1228 |
|
---|
1229 | void VBoxDiskImageManagerDlg::updateMedia (const VBoxMedia &aMedia)
|
---|
1230 | {
|
---|
1231 | /* ignore non-updated aMedia */
|
---|
1232 | if (!(type & aMedia.type))
|
---|
1233 | return;
|
---|
1234 |
|
---|
1235 | /* search for updated listview item */
|
---|
1236 | DiskImageItem *item = 0;
|
---|
1237 | switch (aMedia.type)
|
---|
1238 | {
|
---|
1239 | case VBoxDefs::HD:
|
---|
1240 | {
|
---|
1241 | CHardDisk hd = aMedia.disk;
|
---|
1242 | item = searchItem (hdsView, hd.GetId());
|
---|
1243 | delete item;
|
---|
1244 | item = createHdItem (hdsView, 0, hd, aMedia.status);
|
---|
1245 | createHdChildren (item, hd, aMedia.status);
|
---|
1246 | break;
|
---|
1247 | }
|
---|
1248 | case VBoxDefs::CD:
|
---|
1249 | {
|
---|
1250 | CDVDImage cd = aMedia.disk;
|
---|
1251 | item = searchItem (cdsView, cd.GetId());
|
---|
1252 | delete item;
|
---|
1253 | item = createCdItem (cdsView, 0, cd, aMedia.status);
|
---|
1254 | break;
|
---|
1255 | }
|
---|
1256 | case VBoxDefs::FD:
|
---|
1257 | {
|
---|
1258 | CFloppyImage fd = aMedia.disk;
|
---|
1259 | item = searchItem (fdsView, fd.GetId());
|
---|
1260 | delete item;
|
---|
1261 | item = createFdItem (fdsView, 0, fd, aMedia.status);
|
---|
1262 | break;
|
---|
1263 | }
|
---|
1264 | default:
|
---|
1265 | {
|
---|
1266 | AssertMsgFailed (("Invalid aMedia type\n"));
|
---|
1267 | break;
|
---|
1268 | }
|
---|
1269 | }
|
---|
1270 |
|
---|
1271 | if (aMedia.status == VBoxMedia::Inaccessible)
|
---|
1272 | item->setPixmap (0, pxInaccessible);
|
---|
1273 | else if (aMedia.status == VBoxMedia::Error)
|
---|
1274 | item->setPixmap (0, pxErroneous);
|
---|
1275 |
|
---|
1276 | mProgressBar->setProgress (mProgressBar->progress() + 1);
|
---|
1277 | }
|
---|
1278 |
|
---|
1279 |
|
---|
1280 | void VBoxDiskImageManagerDlg::setup (int aType, bool aDoSelect,
|
---|
1281 | const QUuid *aTargetVMId,
|
---|
1282 | const VBoxMediaList *mediaList,
|
---|
1283 | CMachine machine)
|
---|
1284 | {
|
---|
1285 | cmachine = machine;
|
---|
1286 |
|
---|
1287 | type = aType;
|
---|
1288 | twImages->setTabEnabled (twImages->page(0), type & VBoxDefs::HD);
|
---|
1289 | twImages->setTabEnabled (twImages->page(1), type & VBoxDefs::CD);
|
---|
1290 | twImages->setTabEnabled (twImages->page(2), type & VBoxDefs::FD);
|
---|
1291 |
|
---|
1292 | doSelect = aDoSelect;
|
---|
1293 | if (aTargetVMId)
|
---|
1294 | targetVMId = aTargetVMId->toString();
|
---|
1295 |
|
---|
1296 | if (doSelect)
|
---|
1297 | buttonOk->setText (tr ("&Select"));
|
---|
1298 | else
|
---|
1299 | buttonCancel->setShown (false);
|
---|
1300 |
|
---|
1301 | /* listen to "media enumeration" signals */
|
---|
1302 | connect (&vboxGlobal(), SIGNAL (mediaEnumerated (const VBoxMedia &)),
|
---|
1303 | this, SLOT (mediaEnumerated (const VBoxMedia &)));
|
---|
1304 | /* listen to "media enumeration finished" signals */
|
---|
1305 | connect (&vboxGlobal(), SIGNAL (mediaEnumerated (const VBoxMediaList &)),
|
---|
1306 | this, SLOT (mediaEnumerated (const VBoxMediaList &)));
|
---|
1307 |
|
---|
1308 | /* insert already enumerated media */
|
---|
1309 | VBoxMediaList list;
|
---|
1310 | if (mediaList)
|
---|
1311 | list = *mediaList;
|
---|
1312 | else
|
---|
1313 | list = vboxGlobal().currentMediaList();
|
---|
1314 |
|
---|
1315 | VBoxMediaList::const_iterator it;
|
---|
1316 | prepareToRefresh();
|
---|
1317 | for (it = list.begin(); it != list.end(); ++ it)
|
---|
1318 | updateMedia (*it);
|
---|
1319 |
|
---|
1320 | if (mediaList)
|
---|
1321 | {
|
---|
1322 | mediaEnumerated (*mediaList);
|
---|
1323 | }
|
---|
1324 | else
|
---|
1325 | {
|
---|
1326 | /* only start enumerating media if we haven't been supplied with a list
|
---|
1327 | * (it's ok if the enumeration has been already started, nothing will
|
---|
1328 | * happen) */
|
---|
1329 | vboxGlobal().startEnumeratingMedia();
|
---|
1330 | }
|
---|
1331 | }
|
---|
1332 |
|
---|
1333 |
|
---|
1334 | void VBoxDiskImageManagerDlg::mediaEnumerated (const VBoxMedia &aMedia)
|
---|
1335 | {
|
---|
1336 | if (!mToBeRefreshed) return;
|
---|
1337 | updateMedia (aMedia);
|
---|
1338 | processCurrentChanged();
|
---|
1339 | }
|
---|
1340 |
|
---|
1341 |
|
---|
1342 | void VBoxDiskImageManagerDlg::mediaEnumerated (const VBoxMediaList & /*aList*/)
|
---|
1343 | {
|
---|
1344 | if (!mToBeRefreshed) return;
|
---|
1345 |
|
---|
1346 | mProgressBar->setHidden (true);
|
---|
1347 | mProgressText->setHidden (true);
|
---|
1348 |
|
---|
1349 | imRefreshAction->setEnabled (true);
|
---|
1350 | unsetCursor();
|
---|
1351 |
|
---|
1352 | mToBeRefreshed = false;
|
---|
1353 | }
|
---|
1354 |
|
---|
1355 |
|
---|
1356 | void VBoxDiskImageManagerDlg::machineStateChanged (const VBoxMachineStateChangeEvent &e)
|
---|
1357 | {
|
---|
1358 | /// @todo (r=dmik) IVirtualBoxCallback::OnMachineStateChange
|
---|
1359 | // must also expose the old state! In this case we won't need to cache
|
---|
1360 | // the state value in every class in GUI that uses this signal.
|
---|
1361 |
|
---|
1362 | switch (e.state)
|
---|
1363 | {
|
---|
1364 | case CEnums::PoweredOff:
|
---|
1365 | case CEnums::Aborted:
|
---|
1366 | case CEnums::Saved:
|
---|
1367 | case CEnums::Starting:
|
---|
1368 | case CEnums::Restoring:
|
---|
1369 | {
|
---|
1370 | refreshAll();
|
---|
1371 | break;
|
---|
1372 | }
|
---|
1373 | default:
|
---|
1374 | break;
|
---|
1375 | }
|
---|
1376 | }
|
---|
1377 |
|
---|
1378 |
|
---|
1379 | void VBoxDiskImageManagerDlg::prepareToRefresh()
|
---|
1380 | {
|
---|
1381 | if (mToBeRefreshed) return;
|
---|
1382 | mToBeRefreshed = true;
|
---|
1383 |
|
---|
1384 | /* info panel clearing */
|
---|
1385 | hdsPane1->clear();
|
---|
1386 | hdsPane2->clear(), hdsPane3->clear();
|
---|
1387 | hdsPane4->clear(), hdsPane5->clear();
|
---|
1388 | cdsPane1->clear(), cdsPane2->clear();
|
---|
1389 | fdsPane1->clear(), fdsPane2->clear();
|
---|
1390 |
|
---|
1391 | /* prepare progressbar */
|
---|
1392 | if (mProgressBar)
|
---|
1393 | {
|
---|
1394 | int totalSteps = 0;
|
---|
1395 | if (type & VBoxDefs::HD)
|
---|
1396 | totalSteps += vbox.GetHardDisks().GetCount();
|
---|
1397 | if (type & VBoxDefs::CD)
|
---|
1398 | totalSteps += vbox.GetDVDImages().GetCount();
|
---|
1399 | if (type & VBoxDefs::FD)
|
---|
1400 | totalSteps += vbox.GetFloppyImages().GetCount();
|
---|
1401 | mProgressBar->setProgress (0, totalSteps);
|
---|
1402 | mProgressBar->setHidden (false);
|
---|
1403 | mProgressText->setHidden (false);
|
---|
1404 | }
|
---|
1405 |
|
---|
1406 | imRefreshAction->setEnabled (false);
|
---|
1407 | setCursor (QCursor (BusyCursor));
|
---|
1408 | }
|
---|
1409 |
|
---|
1410 |
|
---|
1411 | void VBoxDiskImageManagerDlg::refreshAll()
|
---|
1412 | {
|
---|
1413 | if (mToBeRefreshed) return;
|
---|
1414 | prepareToRefresh();
|
---|
1415 | /* lists clearing */
|
---|
1416 | hdsView->clear(), cdsView->clear(), fdsView->clear();
|
---|
1417 | /* load all lists */
|
---|
1418 | loadListViews();
|
---|
1419 | /* start enumerating media */
|
---|
1420 | vboxGlobal().startEnumeratingMedia();
|
---|
1421 | }
|
---|
1422 |
|
---|
1423 |
|
---|
1424 | bool VBoxDiskImageManagerDlg::checkImage (DiskImageItem* aItem)
|
---|
1425 | {
|
---|
1426 | QUuid itemId = aItem ? QUuid (aItem->getUuid()) : QUuid();
|
---|
1427 | if (itemId.isNull()) return false;
|
---|
1428 |
|
---|
1429 | QListView* parentList = aItem->listView();
|
---|
1430 | if (parentList == hdsView)
|
---|
1431 | {
|
---|
1432 | QUuid machineId = vbox.GetHardDisk (itemId).GetMachineId();
|
---|
1433 | if (machineId.isNull() ||
|
---|
1434 | vbox.GetMachine (machineId).GetState() != CEnums::PoweredOff &&
|
---|
1435 | vbox.GetMachine (machineId).GetState() != CEnums::Aborted)
|
---|
1436 | return false;
|
---|
1437 | }
|
---|
1438 | else if (parentList == cdsView)
|
---|
1439 | {
|
---|
1440 | QString usage = getDVDImageUsage (itemId);
|
---|
1441 | /* check if there is temporary usage: */
|
---|
1442 | QStringList tempMachines =
|
---|
1443 | QStringList::split (' ', vbox.GetDVDImageUsage (itemId,
|
---|
1444 | CEnums::TemporaryUsage));
|
---|
1445 | if (!tempMachines.isEmpty())
|
---|
1446 | return false;
|
---|
1447 | /* only permamently mounted .iso could be released */
|
---|
1448 | QStringList permMachines =
|
---|
1449 | QStringList::split (' ', vbox.GetDVDImageUsage (itemId,
|
---|
1450 | CEnums::PermanentUsage));
|
---|
1451 | for (QStringList::Iterator it = permMachines.begin();
|
---|
1452 | it != permMachines.end(); ++it)
|
---|
1453 | if (vbox.GetMachine(QUuid (*it)).GetState() != CEnums::PoweredOff &&
|
---|
1454 | vbox.GetMachine(QUuid (*it)).GetState() != CEnums::Aborted)
|
---|
1455 | return false;
|
---|
1456 | }
|
---|
1457 | else if (parentList == fdsView)
|
---|
1458 | {
|
---|
1459 | QString usage = getFloppyImageUsage(itemId);
|
---|
1460 | /* check if there is temporary usage: */
|
---|
1461 | QStringList tempMachines =
|
---|
1462 | QStringList::split (' ', vbox.GetFloppyImageUsage (itemId,
|
---|
1463 | CEnums::TemporaryUsage));
|
---|
1464 | if (!tempMachines.isEmpty())
|
---|
1465 | return false;
|
---|
1466 | /* only permamently mounted .iso could be released */
|
---|
1467 | QStringList permMachines =
|
---|
1468 | QStringList::split (' ', vbox.GetFloppyImageUsage (itemId,
|
---|
1469 | CEnums::PermanentUsage));
|
---|
1470 | for (QStringList::Iterator it = permMachines.begin();
|
---|
1471 | it != permMachines.end(); ++it)
|
---|
1472 | if (vbox.GetMachine(QUuid (*it)).GetState() != CEnums::PoweredOff &&
|
---|
1473 | vbox.GetMachine(QUuid (*it)).GetState() != CEnums::Aborted)
|
---|
1474 | return false;
|
---|
1475 | }
|
---|
1476 | else
|
---|
1477 | {
|
---|
1478 | return false;
|
---|
1479 | }
|
---|
1480 | return true;
|
---|
1481 | }
|
---|
1482 |
|
---|
1483 |
|
---|
1484 | void VBoxDiskImageManagerDlg::setCurrentItem (QListView *aListView, QListViewItem *aItem)
|
---|
1485 | {
|
---|
1486 | aListView->setFocus();
|
---|
1487 | if (aItem)
|
---|
1488 | {
|
---|
1489 | aListView->setCurrentItem (aItem);
|
---|
1490 | aListView->setSelected (aListView->currentItem(), true);
|
---|
1491 | /* it is strange repeat but it works */
|
---|
1492 | aListView->adjustColumn (1);
|
---|
1493 | aListView->adjustColumn (2);
|
---|
1494 | aListView->adjustColumn (1);
|
---|
1495 | }
|
---|
1496 | processCurrentChanged (aListView->currentItem());
|
---|
1497 | }
|
---|
1498 |
|
---|
1499 |
|
---|
1500 | void VBoxDiskImageManagerDlg::processCurrentChanged()
|
---|
1501 | {
|
---|
1502 | QListView *currentList = getCurrentListView();
|
---|
1503 | currentList->setFocus();
|
---|
1504 |
|
---|
1505 | QListViewItem *itemToSelect =
|
---|
1506 | !currentList->isSelected (currentList->currentItem()) ?
|
---|
1507 | currentList->firstChild() : currentList->currentItem();
|
---|
1508 | setCurrentItem (currentList, itemToSelect);
|
---|
1509 |
|
---|
1510 | /* tab stop setup */
|
---|
1511 | setTabOrder (hdsView, hdsPane1);
|
---|
1512 | setTabOrder (hdsPane1, hdsPane2);
|
---|
1513 | setTabOrder (hdsPane2, hdsPane3);
|
---|
1514 | setTabOrder (hdsPane3, hdsPane4);
|
---|
1515 | setTabOrder (hdsPane4, hdsPane5);
|
---|
1516 | setTabOrder (hdsPane5, buttonHelp);
|
---|
1517 |
|
---|
1518 | setTabOrder (cdsView, cdsPane1);
|
---|
1519 | setTabOrder (cdsPane1, cdsPane2);
|
---|
1520 | setTabOrder (cdsPane2, buttonHelp);
|
---|
1521 |
|
---|
1522 | setTabOrder (fdsView, fdsPane1);
|
---|
1523 | setTabOrder (fdsPane1, fdsPane2);
|
---|
1524 | setTabOrder (fdsPane2, buttonHelp);
|
---|
1525 |
|
---|
1526 | setTabOrder (buttonHelp, buttonOk);
|
---|
1527 | setTabOrder (buttonOk, twImages);
|
---|
1528 | }
|
---|
1529 |
|
---|
1530 | void VBoxDiskImageManagerDlg::processCurrentChanged (QListViewItem *aItem)
|
---|
1531 | {
|
---|
1532 | DiskImageItem *item = aItem && aItem->rtti() == 1001 ?
|
---|
1533 | static_cast<DiskImageItem*> (aItem) : 0;
|
---|
1534 |
|
---|
1535 | bool modifyEnabled = item && item->getUsage().isNull() &&
|
---|
1536 | !item->firstChild() && !item->getPath().isNull();
|
---|
1537 | bool releaseEnabled = item && !item->getUsage().isNull() &&
|
---|
1538 | checkImage (item) &&
|
---|
1539 | !item->parent() && !item->firstChild() &&
|
---|
1540 | item->getSnapshotName().isNull();
|
---|
1541 | bool newEnabled = getCurrentListView() == hdsView ? true : false;
|
---|
1542 |
|
---|
1543 | // imEditAction->setEnabled (modifyEnabled);
|
---|
1544 | imRemoveAction->setEnabled (modifyEnabled);
|
---|
1545 | imReleaseAction->setEnabled (releaseEnabled);
|
---|
1546 | imNewAction->setEnabled (newEnabled);
|
---|
1547 |
|
---|
1548 | // itemMenu->setItemVisible (itemMenu->idAt(0), modifyEnabled);
|
---|
1549 | itemMenu->setItemEnabled (itemMenu->idAt(0), modifyEnabled);
|
---|
1550 | itemMenu->setItemEnabled (itemMenu->idAt(1), releaseEnabled);
|
---|
1551 |
|
---|
1552 | if (doSelect)
|
---|
1553 | {
|
---|
1554 | bool selectEnabled = item && !item->parent() &&
|
---|
1555 | (!newEnabled ||
|
---|
1556 | (item->getUsage().isNull() ||
|
---|
1557 | item->getMachineId() == targetVMId));
|
---|
1558 |
|
---|
1559 | buttonOk->setEnabled (selectEnabled);
|
---|
1560 | }
|
---|
1561 |
|
---|
1562 | if (item)
|
---|
1563 | {
|
---|
1564 | if (getCurrentListView() == hdsView)
|
---|
1565 | {
|
---|
1566 | hdsPane1->setText (item->getInformation (item->getPath(), true, "end"));
|
---|
1567 | hdsPane2->setText (item->getInformation (item->getDiskType(), false));
|
---|
1568 | hdsPane3->setText (item->getInformation (item->getStorageType(), false));
|
---|
1569 | hdsPane4->setText (item->getInformation (item->getUsage()));
|
---|
1570 | hdsPane5->setText (item->getInformation (item->getSnapshotName()));
|
---|
1571 | }
|
---|
1572 | else if (getCurrentListView() == cdsView)
|
---|
1573 | {
|
---|
1574 | cdsPane1->setText (item->getInformation (item->getPath(), true, "end"));
|
---|
1575 | cdsPane2->setText (item->getInformation (item->getUsage()));
|
---|
1576 | }
|
---|
1577 | else if (getCurrentListView() == fdsView)
|
---|
1578 | {
|
---|
1579 | fdsPane1->setText (item->getInformation (item->getPath(), true, "end"));
|
---|
1580 | fdsPane2->setText (item->getInformation (item->getUsage()));
|
---|
1581 | }
|
---|
1582 | }
|
---|
1583 | }
|
---|
1584 |
|
---|
1585 |
|
---|
1586 | void VBoxDiskImageManagerDlg::processPressed (QListViewItem * aItem)
|
---|
1587 | {
|
---|
1588 | if (!aItem)
|
---|
1589 | {
|
---|
1590 | QListView *currentList = getCurrentListView();
|
---|
1591 | currentList->setSelected (currentList->currentItem(), true);
|
---|
1592 | }
|
---|
1593 | processCurrentChanged();
|
---|
1594 | }
|
---|
1595 |
|
---|
1596 |
|
---|
1597 | void VBoxDiskImageManagerDlg::newImage()
|
---|
1598 | {
|
---|
1599 | AssertReturnVoid (getCurrentListView() == hdsView);
|
---|
1600 |
|
---|
1601 | VBoxNewHDWzd dlg (this, "VBoxNewHDWzd");
|
---|
1602 |
|
---|
1603 | if (dlg.exec() == QDialog::Accepted)
|
---|
1604 | {
|
---|
1605 | CHardDisk hd = dlg.hardDisk();
|
---|
1606 | VBoxMedia::Status status = hd.GetAccessible() ?
|
---|
1607 | VBoxMedia::Ok : VBoxMedia::Inaccessible;
|
---|
1608 | DiskImageItem *createdItem = createHdItem (hdsView, 0, hd, status);
|
---|
1609 | setCurrentItem (hdsView, createdItem);
|
---|
1610 | /* synchronize modeless dialog if present */
|
---|
1611 | if (mModelessDialog && mModelessDialog != this)
|
---|
1612 | mModelessDialog->createHdItem (mModelessDialog->hdsView,
|
---|
1613 | 0, hd, status);
|
---|
1614 | }
|
---|
1615 | }
|
---|
1616 |
|
---|
1617 |
|
---|
1618 | void VBoxDiskImageManagerDlg::addImage()
|
---|
1619 | {
|
---|
1620 | QListView *currentList = getCurrentListView();
|
---|
1621 | DiskImageItem *item =
|
---|
1622 | currentList->currentItem() && currentList->currentItem()->rtti() == 1001 ?
|
---|
1623 | static_cast<DiskImageItem*> (currentList->currentItem()) : 0;
|
---|
1624 |
|
---|
1625 | QString dir;
|
---|
1626 | if (item && item->getStatus() == VBoxMedia::Ok)
|
---|
1627 | dir = item->getPath().stripWhiteSpace();
|
---|
1628 |
|
---|
1629 | if (!dir)
|
---|
1630 | if (currentList == hdsView)
|
---|
1631 | dir = vbox.GetSystemProperties().GetDefaultVDIFolder();
|
---|
1632 | if (!dir || !QFileInfo (dir).exists())
|
---|
1633 | dir = vbox.GetHomeFolder();
|
---|
1634 |
|
---|
1635 | QString title;
|
---|
1636 | QString filter;
|
---|
1637 | VBoxDefs::DiskType type = VBoxDefs::InvalidType;
|
---|
1638 |
|
---|
1639 | if (currentList == hdsView) {
|
---|
1640 | filter = tr( "Hard disk images (*.vdi)" );
|
---|
1641 | title = tr( "Select a hard disk image file" );
|
---|
1642 | type = VBoxDefs::HD;
|
---|
1643 | } else if (currentList == cdsView) {
|
---|
1644 | filter = tr( "CDROM images (*.iso)" );
|
---|
1645 | title = tr( "Select a DVD/CD-ROM disk image file" );
|
---|
1646 | type = VBoxDefs::CD;
|
---|
1647 | } else if (currentList == fdsView) {
|
---|
1648 | filter = tr( "Floppy images (*.img)" );
|
---|
1649 | title = tr( "Select a floppy disk image file" );
|
---|
1650 | type = VBoxDefs::FD;
|
---|
1651 | } else {
|
---|
1652 | AssertMsgFailed (("Root list should be equal to hdsView, cdsView or fdsView"));
|
---|
1653 | }
|
---|
1654 |
|
---|
1655 | QString src = QFileDialog::getOpenFileName (dir, filter,
|
---|
1656 | this, "AddDiskImageDialog",
|
---|
1657 | title);
|
---|
1658 |
|
---|
1659 | DiskImageItem *createdItem = addImageToList (src, type);
|
---|
1660 | setCurrentItem (currentList, createdItem);
|
---|
1661 |
|
---|
1662 | if (!vbox.isOk())
|
---|
1663 | {
|
---|
1664 | vboxProblem().cannotRegisterMedia (this, vbox, type, src);
|
---|
1665 | }
|
---|
1666 | }
|
---|
1667 |
|
---|
1668 |
|
---|
1669 | void VBoxDiskImageManagerDlg::removeImage()
|
---|
1670 | {
|
---|
1671 | QListView *currentList = getCurrentListView();
|
---|
1672 | DiskImageItem *item =
|
---|
1673 | currentList->currentItem() && currentList->currentItem()->rtti() == 1001 ?
|
---|
1674 | static_cast<DiskImageItem*> (currentList->currentItem()) : 0;
|
---|
1675 | AssertMsg (item, ("Current item must not be null"));
|
---|
1676 | QString removedItemName = item->getName();
|
---|
1677 |
|
---|
1678 | QString src = item->getPath().stripWhiteSpace();
|
---|
1679 | QUuid uuid = QUuid (item->getUuid());
|
---|
1680 | VBoxDefs::DiskType type = VBoxDefs::InvalidType;
|
---|
1681 |
|
---|
1682 | if (currentList == hdsView)
|
---|
1683 | {
|
---|
1684 | type = VBoxDefs::HD;
|
---|
1685 | int deleteImage;
|
---|
1686 | if (vbox.GetHardDisk (uuid).GetStorageType() == CEnums::VirtualDiskImage &&
|
---|
1687 | item->getStatus() == VBoxMedia::Ok)
|
---|
1688 | {
|
---|
1689 | deleteImage = vboxProblem().confirmHardDiskImageDeletion (this, src);
|
---|
1690 | }
|
---|
1691 | else
|
---|
1692 | {
|
---|
1693 | deleteImage = vboxProblem().confirmHardDiskUnregister (this, src);
|
---|
1694 | }
|
---|
1695 | if (deleteImage == QIMessageBox::Cancel)
|
---|
1696 | return;
|
---|
1697 | CHardDisk hd = vbox.UnregisterHardDisk (uuid);
|
---|
1698 | if (vbox.isOk() && deleteImage == QIMessageBox::Yes)
|
---|
1699 | {
|
---|
1700 | /// @todo (dmik) later, change wrappers so that converting
|
---|
1701 | // to CUnknown is not necessary for cross-assignments
|
---|
1702 | CVirtualDiskImage vdi = CUnknown (hd);
|
---|
1703 | if (vdi.isOk())
|
---|
1704 | vdi.DeleteImage();
|
---|
1705 | if (!vdi.isOk())
|
---|
1706 | vboxProblem().cannotDeleteHardDiskImage (this, vdi);
|
---|
1707 | }
|
---|
1708 | }
|
---|
1709 | else if (currentList == cdsView)
|
---|
1710 | {
|
---|
1711 | type = VBoxDefs::CD;
|
---|
1712 | vbox.UnregisterDVDImage (uuid);
|
---|
1713 | }
|
---|
1714 | else if (currentList == fdsView)
|
---|
1715 | {
|
---|
1716 | type = VBoxDefs::FD;
|
---|
1717 | vbox.UnregisterFloppyImage (uuid);
|
---|
1718 | }
|
---|
1719 |
|
---|
1720 | if (!vbox.isOk())
|
---|
1721 | {
|
---|
1722 | vboxProblem().cannotUnregisterMedia (this, vbox, type, src);
|
---|
1723 | }
|
---|
1724 | else
|
---|
1725 | {
|
---|
1726 | delete item;
|
---|
1727 | setCurrentItem (currentList, currentList->currentItem());
|
---|
1728 | /* synchronize modeless dialog if present */
|
---|
1729 | if (mModelessDialog && mModelessDialog != this)
|
---|
1730 | {
|
---|
1731 | DiskImageItem *itemToRemove = 0;
|
---|
1732 | QListView *modelessView = 0;
|
---|
1733 | if (currentList == hdsView)
|
---|
1734 | modelessView = mModelessDialog->hdsView;
|
---|
1735 | else if (currentList == cdsView)
|
---|
1736 | modelessView = mModelessDialog->cdsView;
|
---|
1737 | else if (currentList == fdsView)
|
---|
1738 | modelessView = mModelessDialog->fdsView;
|
---|
1739 | itemToRemove = static_cast<DiskImageItem*>
|
---|
1740 | (modelessView->findItem (removedItemName, 0));
|
---|
1741 | delete itemToRemove;
|
---|
1742 | if (modelessView->currentItem())
|
---|
1743 | modelessView->setSelected (modelessView->currentItem(), true);
|
---|
1744 | mModelessDialog->processCurrentChanged();
|
---|
1745 | }
|
---|
1746 | }
|
---|
1747 | }
|
---|
1748 |
|
---|
1749 |
|
---|
1750 | void VBoxDiskImageManagerDlg::releaseImage()
|
---|
1751 | {
|
---|
1752 | QListView *currentList = getCurrentListView();
|
---|
1753 | DiskImageItem *item =
|
---|
1754 | currentList->currentItem() && currentList->currentItem()->rtti() == 1001 ?
|
---|
1755 | static_cast<DiskImageItem*> (currentList->currentItem()) : 0;
|
---|
1756 | AssertMsg (item, ("Current item must not be null"));
|
---|
1757 | QString releasedItemName = item->getName();
|
---|
1758 | QString usageAfterRelease;
|
---|
1759 |
|
---|
1760 | QUuid itemId = QUuid (item->getUuid());
|
---|
1761 | AssertMsg (!itemId.isNull(), ("Current item must have uuid"));
|
---|
1762 |
|
---|
1763 | QUuid machineId;
|
---|
1764 | /* if it is a hard disk sub-item: */
|
---|
1765 | if (currentList == hdsView)
|
---|
1766 | {
|
---|
1767 | machineId = vbox.GetHardDisk (itemId).GetMachineId();
|
---|
1768 | if (vboxProblem().confirmReleaseImage (this,
|
---|
1769 | vbox.GetMachine(machineId).GetName()))
|
---|
1770 | {
|
---|
1771 | releaseDisk (machineId, itemId, VBoxDefs::HD);
|
---|
1772 |
|
---|
1773 | /* re-request current usage */
|
---|
1774 | machineId = vbox.GetHardDisk (itemId).GetMachineId();
|
---|
1775 | usageAfterRelease = machineId.isNull() ? QString::null :
|
---|
1776 | vbox.GetMachine (machineId).GetName();
|
---|
1777 | item->setUsage (usageAfterRelease);
|
---|
1778 | }
|
---|
1779 | }
|
---|
1780 | /* if it is a cd/dvd sub-item: */
|
---|
1781 | else if (currentList == cdsView)
|
---|
1782 | {
|
---|
1783 | QString usage = getDVDImageUsage (itemId);
|
---|
1784 | /* only permamently mounted .iso could be released */
|
---|
1785 | if (vboxProblem().confirmReleaseImage (this, usage))
|
---|
1786 | {
|
---|
1787 | QStringList permMachines =
|
---|
1788 | QStringList::split (' ', vbox.GetDVDImageUsage (itemId,
|
---|
1789 | CEnums::PermanentUsage));
|
---|
1790 | for (QStringList::Iterator it = permMachines.begin();
|
---|
1791 | it != permMachines.end(); ++it)
|
---|
1792 | releaseDisk (QUuid (*it), itemId, VBoxDefs::CD);
|
---|
1793 |
|
---|
1794 | /* re-request current usage */
|
---|
1795 | usageAfterRelease = getDVDImageUsage (itemId);
|
---|
1796 | item->setUsage (usageAfterRelease);
|
---|
1797 | }
|
---|
1798 | }
|
---|
1799 | /* if it is a floppy sub-item: */
|
---|
1800 | else if (currentList == fdsView)
|
---|
1801 | {
|
---|
1802 | QString usage = getFloppyImageUsage (itemId);
|
---|
1803 | /* only permamently mounted .img could be released */
|
---|
1804 | if (vboxProblem().confirmReleaseImage (this, usage))
|
---|
1805 | {
|
---|
1806 | QStringList permMachines =
|
---|
1807 | QStringList::split (' ', vbox.GetFloppyImageUsage (itemId,
|
---|
1808 | CEnums::PermanentUsage));
|
---|
1809 | for (QStringList::Iterator it = permMachines.begin();
|
---|
1810 | it != permMachines.end(); ++it)
|
---|
1811 | releaseDisk (QUuid (*it), itemId, VBoxDefs::FD);
|
---|
1812 |
|
---|
1813 | /* re-request current usage */
|
---|
1814 | usageAfterRelease = getFloppyImageUsage (itemId);
|
---|
1815 | item->setUsage (usageAfterRelease);
|
---|
1816 | }
|
---|
1817 | }
|
---|
1818 | processCurrentChanged (item);
|
---|
1819 |
|
---|
1820 | /* processing modeless dialog */
|
---|
1821 | if (mModelessDialog && mModelessDialog != this)
|
---|
1822 | {
|
---|
1823 | DiskImageItem *itemToRelease = 0;
|
---|
1824 | QListView *modelessView = 0;
|
---|
1825 | if (currentList == hdsView)
|
---|
1826 | modelessView = mModelessDialog->hdsView;
|
---|
1827 | else if (currentList == cdsView)
|
---|
1828 | modelessView = mModelessDialog->cdsView;
|
---|
1829 | else if (currentList == fdsView)
|
---|
1830 | modelessView = mModelessDialog->fdsView;
|
---|
1831 | itemToRelease = static_cast<DiskImageItem*>
|
---|
1832 | (modelessView->findItem (releasedItemName, 0));
|
---|
1833 | itemToRelease->setUsage (usageAfterRelease);
|
---|
1834 | mModelessDialog->processCurrentChanged();
|
---|
1835 | }
|
---|
1836 | }
|
---|
1837 |
|
---|
1838 |
|
---|
1839 | void VBoxDiskImageManagerDlg::releaseDisk (QUuid aMachineId,
|
---|
1840 | QUuid aItemId,
|
---|
1841 | VBoxDefs::DiskType aDiskType)
|
---|
1842 | {
|
---|
1843 | CSession session;
|
---|
1844 | CMachine machine;
|
---|
1845 | /* is this media image mapped to this VM: */
|
---|
1846 | if (!cmachine.isNull() && cmachine.GetId() == aMachineId)
|
---|
1847 | {
|
---|
1848 | machine = cmachine;
|
---|
1849 | }
|
---|
1850 | /* or some other: */
|
---|
1851 | else
|
---|
1852 | {
|
---|
1853 | session = vboxGlobal().openSession (aMachineId);
|
---|
1854 | if (session.isNull()) return;
|
---|
1855 | machine = session.GetMachine();
|
---|
1856 | }
|
---|
1857 | /* perform disk releasing: */
|
---|
1858 | switch (aDiskType)
|
---|
1859 | {
|
---|
1860 | case VBoxDefs::HD:
|
---|
1861 | {
|
---|
1862 | /* releasing hd: */
|
---|
1863 | CHardDiskAttachmentEnumerator en =
|
---|
1864 | machine.GetHardDiskAttachments().Enumerate();
|
---|
1865 | while (en.HasMore())
|
---|
1866 | {
|
---|
1867 | CHardDiskAttachment hda = en.GetNext();
|
---|
1868 | if (hda.GetHardDisk().GetId() == aItemId)
|
---|
1869 | {
|
---|
1870 | machine.DetachHardDisk (hda.GetController(),
|
---|
1871 | hda.GetDeviceNumber());
|
---|
1872 | if (!machine.isOk())
|
---|
1873 | vboxProblem().cannotDetachHardDisk (this,
|
---|
1874 | machine, hda.GetController(), hda.GetDeviceNumber());
|
---|
1875 | break;
|
---|
1876 | }
|
---|
1877 | }
|
---|
1878 | break;
|
---|
1879 | }
|
---|
1880 | case VBoxDefs::CD:
|
---|
1881 | {
|
---|
1882 | /* releasing cd: */
|
---|
1883 | machine.GetDVDDrive().Unmount();
|
---|
1884 | break;
|
---|
1885 | }
|
---|
1886 | case VBoxDefs::FD:
|
---|
1887 | {
|
---|
1888 | /* releasing fd: */
|
---|
1889 | machine.GetFloppyDrive().Unmount();
|
---|
1890 | break;
|
---|
1891 | }
|
---|
1892 | default:
|
---|
1893 | AssertFailed();
|
---|
1894 | }
|
---|
1895 | /* save all setting changes: */
|
---|
1896 | machine.SaveSettings();
|
---|
1897 | if (!machine.isOk())
|
---|
1898 | vboxProblem().cannotSaveMachineSettings (machine);
|
---|
1899 | /* if local session was opened - close this session: */
|
---|
1900 | if (!session.isNull())
|
---|
1901 | session.Close();
|
---|
1902 | }
|
---|
1903 |
|
---|
1904 |
|
---|
1905 | QUuid VBoxDiskImageManagerDlg::getSelectedUuid()
|
---|
1906 | {
|
---|
1907 | QListView *currentList = getCurrentListView();
|
---|
1908 | QUuid uuid;
|
---|
1909 |
|
---|
1910 | if ( currentList->selectedItem() &&
|
---|
1911 | currentList->selectedItem()->rtti() == 1001 )
|
---|
1912 | uuid = QUuid (static_cast<DiskImageItem *>(currentList->selectedItem())
|
---|
1913 | ->getUuid());
|
---|
1914 |
|
---|
1915 | return uuid;
|
---|
1916 | }
|
---|
1917 |
|
---|
1918 |
|
---|
1919 | QString VBoxDiskImageManagerDlg::getSelectedPath()
|
---|
1920 | {
|
---|
1921 | QListView *currentList = getCurrentListView();
|
---|
1922 | QString path;
|
---|
1923 |
|
---|
1924 | if ( currentList->selectedItem() && currentList->selectedItem()->rtti() == 1001 )
|
---|
1925 | path = static_cast<DiskImageItem*> (currentList->selectedItem())
|
---|
1926 | ->getPath().stripWhiteSpace();
|
---|
1927 |
|
---|
1928 | return path;
|
---|
1929 | }
|
---|
1930 |
|
---|
1931 |
|
---|
1932 | void VBoxDiskImageManagerDlg::processDoubleClick (QListViewItem*)
|
---|
1933 | {
|
---|
1934 | QListView *currentList = getCurrentListView();
|
---|
1935 |
|
---|
1936 | if (doSelect && currentList->selectedItem() && buttonOk->isEnabled())
|
---|
1937 | accept();
|
---|
1938 | }
|
---|