VBoxDiskImageManagerDlg.ui.h revision df30dbdfdbce7bc58d1a71d98772953017bc3269
/**
*
* VBox frontends: Qt GUI ("VirtualBox"):
* "Virtual Disk Manager" dialog UI include (Qt Designer)
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
{
enum { TypeId = 1001 };
QString getTotalUsage() const
{
}
{
return info;
}
{
{
return 0;
else
}
else
}
DiskImageItem* nextSibling() const
{
return (QListViewItem::nextSibling() &&
}
{
}
};
{
: QListViewItemIterator (aList) {}
{
}
{
}
};
{
};
{
if (!mModelessDialog)
{
"VBoxDiskImageManagerDlg",
/* listen to events that may change the media status and refresh
* the contents of the modeless dialog */
/// @todo refreshAll() may be slow, so it may be better to analyze
// event details and update only what is changed */
}
mModelessDialog->show();
}
void VBoxDiskImageManagerDlg::init()
{
polished = false;
mInLoop = false;
img =
/* setup tab widget icons */
/* setup image list views */
/* setup list-view's item tooltip */
hdsView->setShowToolTips (false);
cdsView->setShowToolTips (false);
fdsView->setShowToolTips (false);
/* status-bar currently disabled */
/// @todo we must enable it and disable our size grip hack!
/// (at least, to have action help text showh)
/* context menu composing */
// imEditAction = new QAction (this, "imEditAction");
// connect (imEditAction, SIGNAL (activated()),
// this, SLOT (editImage()));
"vdm_new_22px.png", "vdm_new_16px.png",
"vdm_new_disabled_22px.png", "vdm_new_disabled_16px.png"));
"vdm_add_22px.png", "vdm_add_16px.png",
"vdm_add_disabled_22px.png", "vdm_add_disabled_16px.png"));
// imEditAction->setIconSet (VBoxGlobal::iconSet ("guesttools_16px.png", "guesttools_disabled_16px.png"));
"vdm_remove_22px.png", "vdm_remove_16px.png",
"vdm_remove_disabled_22px.png", "vdm_remove_disabled_16px.png"));
"vdm_release_22px.png", "vdm_release_16px.png",
"vdm_release_disabled_22px.png", "vdm_release_disabled_16px.png"));
"refresh_22px.png", "refresh_16px.png",
"refresh_disabled_22px.png", "refresh_disabled_16px.png"));
// imEditAction->addTo (itemMenu);
/* toolbar composing */
toolBar->setUsesTextLabel (true);
toolBar->setUsesBigPixmaps (true);
toolBar->addSeparator();
// imEditAction->addTo (toolBar);
toolBar->addSeparator();
#ifdef Q_WS_MAC
toolBar->setMacStyle();
#endif
/* menu bar */
// imEditAction->addTo (toolBar);
/* setup size grip */
/* setup information pane */
QApplication::setGlobalMouseTracking (true);
/* setup information pane layouts */
/* create info-pane for hd list-view */
/* create info-pane for cd list-view */
/* create info-pane for fd list-view */
/* enumeration progressbar creation */
mProgressText->setHidden (true);
mProgressBar->setHidden (true);
mProgressBar->setPercentageVisible (false);
/* applying language settings */
}
{
// imEditAction->setMenuText (tr ("&Edit..."));
// imEditAction->setText (tr ("Edit"));
// imEditAction->setAccel (tr ("Ctrl+E"));
// imEditAction->setStatusTip (tr ("Edit the properties of the selected item"));
refreshAll();
}
{
/* Setup focus policy <strong> default for info pane */
/* prevent the name columns from being expanded */
if (aColumn == -1)
{
}
else
{
}
}
{
QMainWindow::showEvent (e);
/* one may think that QWidget::polish() is the right place to do things
* below, but apparently, by the time when QWidget::polish() is called,
* the widget style & layout are not fully done, at least the minimum
* size hint is not properly calculated. Since this is sometimes necessary,
* we provide our own "polish" implementation. */
if (polished)
return;
polished = true;
}
{
{
case DiskImageItem::TypeId:
break;
default:
Assert (0);
}
}
{
}
{
mModelessDialog = 0;
}
{
{
{
case Key_Enter:
case Key_Return:
{
if (currentDefault)
break;
}
case Key_Escape:
{
reject();
break;
}
}
}
else
}
{
QPushButton *defButton = 0;
{
++it;
}
return defButton;
}
int VBoxDiskImageManagerDlg::exec()
{
setResult (0);
show();
mInLoop = true;
mInLoop = false;
return result();
}
{
if (mInLoop)
{
hide();
}
else
{
close();
}
}
{
return clv;
}
{
switch (aType)
{
return hdsView;
return cdsView;
return fdsView;
default:
return 0;
}
}
{
{
{
if (aObject == currentList)
{
return true;
}
break;
}
{
if (aObject == currentList)
{
return true;
}
break;
}
case 1001: /* QCustomEvent 1001 - DnD Update Event */
{
if (aObject == currentList)
{
return true;
}
break;
}
{
{
if (defaultButton)
}
break;
}
{
{
if (defaultButton)
}
break;
}
default:
break;
}
}
{
{
case QEvent::LanguageChange:
{
break;
}
default:
break;
}
return result;
}
{
{
/* Check dropped media type */
/// @todo On OS/2 and windows (and mac?) extension checks should be case
/// insensitive, as OPPOSED to linux and the rest where case matters.
{
}
{
}
{
}
/* If media type has been determined - attach this device */
if (type)
{
}
}
}
{
return;
switch (aDiskType)
{
{
{
{
}
}
break;
}
{
{
{
}
}
break;
}
{
{
{
}
}
break;
}
default:
AssertMsgFailed (("Invalid aDiskType type\n"));
}
}
{
DiskImageItem *item = 0;
if (aRoot)
else if (aList)
else
Assert (0);
return item;
}
{
if (aItem)
}
{
++it)
{
if (usage)
usage += ", ";
}
++it)
{
/* skip IDs that are in the permanent list */
{
if (usage)
usage += ", [";
else
usage += "[";
}
}
return usage;
}
{
++it)
{
if (usage)
usage += ", ";
}
++it)
{
/* skip IDs that are in the permanent list */
{
if (usage)
usage += ", [";
else
usage += "[";
}
}
return usage;
}
{
return;
{
if (aUsage)
aUsage += ", ";
}
}
{
return;
{
if (aUsage)
aUsage += ", ";
}
}
{
if (aItem)
if (aItem)
{
}
/* compose tool-tip information */
switch (aStatus)
{
{
"Checking accessibility...", "HDD")
break;
}
{
"<nobr>Disk type: %2</nobr><br>"
"<nobr>Storage type: %3</nobr>")
.arg (hardDiskType)
.arg (storageType);
if (!snapshotName.isNull())
.arg (snapshotName);
break;
}
{
/// @todo (r=dmik) paass a complete VBoxMedia instance here
// to get the result of blabla.GetAccessible() call form CUnknown
"Error checking media accessibility", "HDD")
break;
}
case VBoxMedia::Inaccessible:
{
true /* aToolTip */));
break;
}
default:
AssertFailed();
}
return tip;
}
{
if (aItem)
else
{
/* should correlate with DiskImageItem::getTotalUsage() */
if (!snapshotUsage.isNull())
}
/* compose tool-tip information */
switch (aStatus)
{
{
break;
}
{
break;
}
{
/// @todo (r=dmik) paass a complete VBoxMedia instance here
// to get the result of blabla.GetAccessible() call form CUnknown
break;
}
case VBoxMedia::Inaccessible:
{
/// @todo (r=dmik) correct this when GetLastAccessError() is
// implemented for IDVDImage
break;
}
default:
AssertFailed();
}
return tip;
}
{
if (aItem)
else
{
/* should correlate with DiskImageItem::getTotalUsage() */
if (!snapshotUsage.isNull())
}
/* compose tool-tip information */
switch (aStatus)
{
{
break;
}
{
break;
}
{
/// @todo (r=dmik) paass a complete VBoxMedia instance here
// to get the result of blabla.GetAccessible() call form CUnknown
break;
}
case VBoxMedia::Inaccessible:
{
/// @todo (r=dmik) correct this when GetLastAccessError() is
// implemented for IDVDImage
break;
}
default:
AssertFailed();
}
return tip;
}
{
if (!aItem)
return;
{
}
}
{
if (!aItem)
return;
}
{
if (!aItem)
return;
}
{
return item;
}
{
return item;
}
{
return item;
}
{
{
}
}
{
while (*iterator)
{
return *iterator;
++iterator;
}
return 0;
}
{
while (*iterator)
{
return *iterator;
++iterator;
}
return 0;
}
bool aRefresh /* = true */,
{
if (aTargetVMId)
if (doSelect)
else
buttonCancel->setShown (false);
/* listen to "media enumeration started" signals */
/* listen to "media enumeration" signals */
/* listen to "media enumeration finished" signals */
/* listen to "media add" signals */
/* listen to "media update" signals */
/* listen to "media remove" signals */
{
}
else
{
/* insert already enumerated media */
int index = 0;
{
mediaAdded (*it);
}
/* emulate the finished signal to reuse the code */
if (!vboxGlobal().isMediaEnumerationStarted())
}
/* for a newly opened dialog, select the first item */
if (!hdsView->selectedItem())
if (!cdsView->selectedItem())
if (!fdsView->selectedItem())
}
{
/* load default tab icons */
/* load current media list */
mediaAdded (*it);
/* select the first item if the previous saved item is not found
* or no current item at all */
}
int aIndex)
{
}
{
mProgressBar->setHidden (true);
mProgressText->setHidden (true);
imRefreshAction->setEnabled (true);
unsetCursor();
/* adjust columns (it is strange to repeat but it works) */
}
{
/* ignore non-interesting aMedia */
return;
DiskImageItem *item = 0;
{
{
hdSelectedId = QUuid();
}
break;
{
cdSelectedId = QUuid();
}
break;
{
fdSelectedId = QUuid();
}
break;
default:
AssertMsgFailed (("Invalid aMedia type\n"));
}
if (!item)
return;
if (!vboxGlobal().isMediaEnumerationStarted())
}
{
/* ignore non-interesting aMedia */
return;
DiskImageItem *item = 0;
{
{
break;
}
{
break;
}
{
break;
}
default:
AssertMsgFailed (("Invalid aMedia type\n"));
}
if (!item)
return;
/* note: current items on invisible tabs are not updated because
* it is always done in processCurrentChanged() when the user switches
* to an invisible tab */
}
{
/* search the list for inaccessible media */
{
}
}
{
/// @todo (r=dmik) IVirtualBoxCallback::OnMachineStateChange
// must also expose the old state! In this case we won't need to cache
// the state value in every class in GUI that uses this signal.
switch (e.state)
{
case KMachineState_PoweredOff:
case KMachineState_Aborted:
case KMachineState_Saved:
case KMachineState_Starting:
case KMachineState_Restoring:
{
refreshAll();
break;
}
default:
break;
}
}
{
}
{
/* info panel clearing */
/* prepare progressbar */
if (mProgressBar)
{
mProgressBar->setHidden (false);
mProgressText->setHidden (false);
}
imRefreshAction->setEnabled (false);
/* store the current list selections */
if (hdSelectedId.isNull())
if (cdSelectedId.isNull())
if (fdSelectedId.isNull())
/* finally, clear all lists */
}
void VBoxDiskImageManagerDlg::refreshAll()
{
/* start enumerating media */
}
{
if (parentList == hdsView)
{
return false;
}
else if (parentList == cdsView)
{
/* check if there is temporary usage: */
if (!tempMachines.isEmpty())
return false;
/* only permamently mounted .iso could be released */
return false;
}
else if (parentList == fdsView)
{
/* check if there is temporary usage: */
if (!tempMachines.isEmpty())
return false;
/* only permamently mounted floppies could be released */
return false;
}
else
{
return false;
}
return true;
}
{
if (!aItem)
return;
}
{
currentList->setFocus();
/* tab stop setup */
}
{
bool modifyEnabled = notInEnum &&
checkImage (item) &&
bool newEnabled = notInEnum &&
getCurrentListView() == hdsView ? true : false;
bool addEnabled = notInEnum;
// imEditAction->setEnabled (modifyEnabled);
// itemMenu->setItemVisible (itemMenu->idAt(0), modifyEnabled);
if (doSelect)
{
(!newEnabled ||
}
if (item)
{
{
}
{
}
{
}
}
else
}
{
if (!aItem)
{
}
}
void VBoxDiskImageManagerDlg::newImage()
{
{
}
}
void VBoxDiskImageManagerDlg::addImage()
{
currentList->currentItem() &&
if (!dir)
if (currentList == hdsView)
if (currentList == hdsView)
{
"Virtual Disk images (*.vdi);;"
"VMDK images (*.vmdk);;"
"All files (*)");
}
else if (currentList == cdsView)
{
"All files (*)");
}
else if (currentList == fdsView)
{
"All files (*)");
}
else
{
AssertMsgFailed (("Root list should be equal to hdsView, cdsView or fdsView"));
}
"AddDiskImageDialog", title);
}
void VBoxDiskImageManagerDlg::removeImage()
{
currentList->currentItem() &&
if (currentList == hdsView)
{
bool deleteImage = false;
/// @todo When creation of VMDK is implemented, we should
/// enable image deletion for them as well (use
/// GetStorageType() to define the correct cast).
{
return;
}
else
{
/// @todo note that differencing images are always automatically
/// deleted when unregistered, but the following message box
/// doesn't mention it. I keep it as is for now because
/// implementing the portability feature will most likely change
/// this behavior (we'll update the message afterwards).
return;
}
else if (deleteImage)
{
/// @todo When creation of VMDK is implemented, we should
/// enable image deletion for them as well (use
/// GetStorageType() to define the correct cast).
vdi.DeleteImage();
}
}
else if (currentList == cdsView)
{
}
else if (currentList == fdsView)
{
}
else
}
void VBoxDiskImageManagerDlg::releaseImage()
{
currentList->currentItem() &&
/* if it is a hard disk sub-item: */
if (currentList == hdsView)
{
{
}
}
else if (currentList == cdsView)
{
{
}
}
/* if it is a floppy sub-item: */
else if (currentList == fdsView)
{
{
}
}
}
{
/* is this media image mapped to this VM: */
{
}
/* or some other: */
else
{
}
/* perform disk releasing: */
switch (aDiskType)
{
{
/* releasing hd: */
{
{
hda.GetChannel(),
break;
}
}
break;
}
{
/* releasing cd: */
break;
}
{
/* releasing fd: */
break;
}
default:
AssertMsgFailed (("Incorrect disk type."));
}
/* save all setting changes: */
/* if local session was opened - close this session: */
}
{
if (currentList->selectedItem() &&
return uuid;
}
{
if (currentList->selectedItem() &&
->getPath().stripWhiteSpace();
return path;
}
{
accept();
}