VBoxMediaManagerDlg.ui.h revision dcea3eadf1ecc8f4ac868185a05a63be42a199e4
/**
*
* VBox frontends: Qt GUI ("VirtualBox"):
* "Virtual Media Manager" dialog UI include (Qt Designer)
*/
/*
* Copyright (C) 2006-2008 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/****************************************************************************
** 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.
*****************************************************************************/
/**
* List view items for VBoxMedium objects.
*/
{
enum { TypeId = 1001 };
{ refresh(); }
{ refresh(); }
{
refresh();
}
void refreshAll();
QString hardDiskFormat() const
QString hardDiskType() const
{
mManager->inAttachMode());
}
// QListViewItem interface
{
{
return 0;
else
}
else
}
{
/* KMediaState_NotCreated is abused to mean "not checked" */
}
void refresh();
};
/**
* Refreshes the underlying medium (see VBoxMedium::refresh()) and then
* refreshes this item's columns based on the new values.
*/
void MediaItem::refreshAll()
{
refresh();
}
/**
* Refreshes the item representation according to the associated medium.
*
* Note that the underlying medium itself is not refreshed.
*/
{
/* fill in columns */
mManager->inAttachMode()));
}
/**
* Iterator for MediaItem.
*/
{
: QListViewItemIterator (aList) {}
{
}
{
}
};
/**
* COmbines QLabel with QIRichLabel.
*/
{
};
/**
* Modifies the given text string for QIRichLabel so that it optionally uses
* the <compact> syntax controlling visual text "compression" with elipsis.
*
* @param aText Original text string.
* @param aCompact @c true if "compression" should be activated.
* @param aElipsis Where to put the elipsis (see <compact> in QIRichLabel).
*
* @return Modified text string.
*/
{
if (aCompact)
else
return text;
}
////////////////////////////////////////////////////////////////////////////////
{
if (!mModelessDialog)
{
false /* aDoSelect */, aRefresh);
/* 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 */
connect (&vboxGlobal(),
(machineRegistered (const VBoxMachineRegisteredEvent &)),
connect (&vboxGlobal(),
}
mModelessDialog->show();
}
void VBoxMediaManagerDlg::init()
{
mIsPolished = false;
mInLoop = false;
mShowDiffs = true;
mFloppyImagesInaccessible = false;
/* setup tab widget icons */
/* setup media list views */
/* setup media tooltip signals */
mHardDiskView->setShowToolTips (false);
mDVDView->setShowToolTips (false);
mFloppyView->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 */
// mEditAction = new QAction (this, "mEditAction");
// connect (mEditAction, SIGNAL (activated()),
// this, SLOT (doEditMedia()));
"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"));
// mEditAction->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"));
// mEditAction->addTo (mItemMenu);
/* toolbar composing */
mToolBar->setUsesTextLabel (true);
mToolBar->setUsesBigPixmaps (true);
mToolBar->addSeparator();
// mEditAction->addTo (mToolBar);
mToolBar->addSeparator();
#ifdef Q_WS_MAC
mToolBar->setMacStyle();
#endif
/* menu bar */
// mEditAction->addTo (mToolBar);
/* 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 */
}
void VBoxMediaManagerDlg::languageChangeImp()
{
// mEditAction->setMenuText (tr ("&Edit..."));
// mEditAction->setText (tr ("Edit"));
// mEditAction->setAccel (tr ("Ctrl+E"));
// mEditAction->setStatusTip (tr ("Edit the properties of the selected medium"));
mReleaseAction->setStatusTip (tr ("Release the selected medium by detaching it from the machines"));
/* set labels for the info pane (makes sense to keep the format in sync with
* VBoxMedium::refresh()) */
mHDLocationLabel->label()->
mHDTypeLabel->label()->
mHDUsageLabel->label()->
mDVDLocationLabel->label()->
mDVDUsageLabel->label()->
mFloppyUsageLabel->label()->
if (mHardDiskView->childCount() ||
mDVDView->childCount() ||
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 (mIsPolished)
return;
mIsPolished = true;
}
{
{
break;
default:
}
}
{
}
{
mModelessDialog = 0;
}
{
{
{
case Key_Enter:
case Key_Return:
{
if (currentDefault)
break;
}
case Key_Escape:
{
reject();
break;
}
}
}
else
}
{
QPushButton *defButton = 0;
{
++it;
}
return defButton;
}
int VBoxMediaManagerDlg::exec()
{
setResult (0);
show();
mInLoop = true;
mInLoop = false;
return result();
}
{
if (mInLoop)
{
hide();
}
else
{
close();
}
}
{
return clv;
}
{
switch (aType)
{
case VBoxDefs::MediaType_HardDisk:
return mHardDiskView;
case VBoxDefs::MediaType_DVD:
return mDVDView;
case VBoxDefs::MediaType_Floppy:
return mFloppyView;
default:
break;
}
AssertFailed();
return NULL;
}
{
{
{
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 (currentList == mDVDView)
}
{
if (currentList == mFloppyView)
}
/// @todo NEWMEDIA use CSystemProperties::GetHardDIskFormats to detect
/// possible hard disk extensions
{
if (currentList == mHardDiskView)
}
/* If the medium is supported, add it */
}
}
{
switch (aType)
{
case VBoxDefs::MediaType_HardDisk:
{
{
}
break;
}
case VBoxDefs::MediaType_DVD:
{
{
}
break;
}
case VBoxDefs::MediaType_Floppy:
{
{
}
break;
}
default:
}
else
}
{
if (aItem)
}
const VBoxMedium &aMedium)
{
{
}
else
{
}
return item;
}
{
* handlers, it's a good place to reset the possibly outdated item's
* tooltip */
{
}
bool *inaccessible = NULL;
{
case VBoxDefs::MediaType_HardDisk:
break;
case VBoxDefs::MediaType_DVD:
break;
case VBoxDefs::MediaType_Floppy:
break;
default:
AssertFailed();
}
switch (aAction)
{
case ItemAction_Added:
{
/* does it change the overall state? */
if (*inaccessible ||
break; /* no */
*inaccessible = true;
break;
}
case ItemAction_Updated:
case ItemAction_Removed:
{
bool checkRest = false;
if (aAction == ItemAction_Updated)
{
/* does it change the overall state? */
break; /* no */
/* is the given item in charge? */
*inaccessible = true; /* yes */
else
checkRest = true; /* no */
}
else
checkRest = true;
if (checkRest)
{
*inaccessible = false;
/* find the first inaccessible item to be in charge */
{
{
*inaccessible = true;
break;
}
}
}
if (*inaccessible)
else
break;
}
}
}
{
while (*it)
{
return *it;
++ it;
}
return NULL;
}
/**
* Sets up the dialog.
*
* @param aType Media type to display (either one type or all).
* @param aDoSelect Whether to enable the select action (OK button).
* @param aRefresh Whether to do a media refresh.
* @param aSessionMachine Session machine object if this dialog is opened for
* a machine from its settings dialog.
* @param aSelectId Which medium to make selected? (ignored when @a
* aType is VBoxDefs::MediaType_All)
* @param aShowDiffs @c true to show differencing hard disks initially
* (ignored if @a aSessionMachine is null assuming
* @c true).
*/
bool aRefresh /* = true */,
bool aShowDiffs /*= true*/)
{
if (aSessionMachine.isNull())
{
mSessionMachineId = QUuid();
mShowDiffs = true;
}
else
{
/* suppress refresh when called from the settings UI which has just
* initiated a refresh on its own when opening the dialog */
aRefresh = false;
}
switch (aType)
{
case VBoxDefs::MediaType_All: break;
default:
}
if (mDoSelect)
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;
{
mediumAdded (*it);
}
/* emulate the finished signal to reuse the code */
if (!vboxGlobal().isMediaEnumerationStarted())
}
/* for a newly opened dialog, select the first item */
if (!mHardDiskView->selectedItem())
if (!mDVDView->selectedItem())
if (!mFloppyView->selectedItem())
}
void VBoxMediaManagerDlg::mediaEnumStarted()
{
/* reset inaccessible flags */
mFloppyImagesInaccessible = false;
/* load default tab icons */
/* insert already enumerated media */
mediumAdded (*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);
mRefreshAction->setEnabled (true);
unsetCursor();
/* adjust columns (it is strange to repeat but it works) */
}
{
/* ignore non-interesting aMedium */
return;
{
{
/* in !mShowDiffs mode, we ignore all diffs except ones that are
* directly attached to the related VM in the current state */
return;
/* Since the base hard disk of this diff has been already appended,
* we want to replace it with this diff to avoid duplicates in
* !mShowDiffs mode. */
return;
}
}
{
case VBoxDefs::MediaType_HardDisk:
{
{
mHDSelectedId = QUuid();
}
break;
}
case VBoxDefs::MediaType_DVD:
{
{
mDVDSelectedId = QUuid();
}
break;
}
case VBoxDefs::MediaType_Floppy:
{
{
mFloppySelectedId = QUuid();
}
break;
}
default:
AssertFailed();
}
/* cause to update the details box when appropriate. Note: current items on
* invisible tabs are not updated because it is always done in
* processCurrentChanged() when the user switches to an invisible tab */
}
{
/* ignore non-interesting aMedium */
return;
{
case VBoxDefs::MediaType_HardDisk:
{
break;
}
case VBoxDefs::MediaType_DVD:
{
break;
}
case VBoxDefs::MediaType_Floppy:
{
break;
}
default:
AssertFailed();
}
/* there may be unwanted items due to !mShowDiffs */
return;
/* cause to update the details box when appropriate. Note: current items on
* invisible tabs are not updated because it is always done in
* processCurrentChanged() when the user switches to an invisible tab */
}
{
/* ignore non-interesting aMedium */
return;
/* there may be unwanted items due to !mShowDiffs */
return;
}
{
/// @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;
}
}
void VBoxMediaManagerDlg::clearInfoPanes()
{
mHDTypeLabel->clear();
mHDUsageLabel->clear();
mDVDUsageLabel->clear();
}
{
/* info panel clearing */
/* prepare progressbar */
if (mProgressBar)
{
mProgressBar->setHidden (false);
mProgressText->setHidden (false);
}
mRefreshAction->setEnabled (false);
/* store the current list selections */
if (mHDSelectedId.isNull())
if (mDVDSelectedId.isNull())
if (mFloppySelectedId.isNull())
/* finally, clear all lists */
mHardDiskView->clear();
mFloppyView->clear();
}
void VBoxMediaManagerDlg::refreshAll()
{
/* start enumerating media */
}
/**
* Checks if a specific action is valid for the given medium at its current
* state.
*
* @param aItem Media item.
* @param aAction Action to check.
*
* @return @c true if the action is possible and false otherwise.
*/
{
switch (aAction)
{
case Action_Select:
{
/* In the current implementation, any known media can be attached
* (either directly, or indirectly), so always return true */
return true;
}
case Action_Edit:
{
/* edit means chagning the description and alike; any media that is
* not being read to or written from can be altered in these terms*/
{
case KMediaState_NotCreated:
case KMediaState_Inaccessible:
case KMediaState_LockedRead:
case KMediaState_LockedWrite:
return false;
default:
break;
}
return true;
}
case Action_Remove:
{
/* removable if not attacded to anything */
}
case Action_Release:
{
/* releasable if attacded but not in snapshots */
}
}
AssertFailedReturn (false);
}
{
if (!aItem)
return;
}
{
currentList->setFocus();
/* tab stop setup */
}
{
/* Ensures current item visible every time we are switching page */
// bool editEnabled = notInEnum && item &&
// checkMediumFor (item, Action_Edit);
/* New and Add are now enabled even when enumerating since it should be
* safe */
bool addEnabled = true;
// mEditAction->setEnabled (editEnabled);
if (mDoSelect)
{
}
if (item)
{
/* fill in the info pane (makes sense to keep the format in sync
* with VBoxMedium::refresh()) */
{
}
{
}
{
}
}
else
}
{
if (!aItem)
{
}
}
void VBoxMediaManagerDlg::doNewMedium()
{
{
/* select the newly created hard disk */
}
}
void VBoxMediaManagerDlg::doAddMedium()
{
currentList->currentItem() &&
if (!dir)
if (currentList == mHardDiskView)
if (currentList == mHardDiskView)
{
/// @todo NEWMEDIA use CSystemProperties::GetHardDIskFormats to detect
/// possible hard disk extensions
"Virtual Disk images (*.vdi);;"
"VMDK images (*.vmdk);;"
"All files (*)");
}
else if (currentList == mDVDView)
{
"All files (*)");
}
else if (currentList == mFloppyView)
{
"All files (*)");
}
else
{
AssertMsgFailed (("Root list should be either mHardDiskView, "
"mDVDView or mFloppyView"));
}
"AddMediaDialog", title);
}
void VBoxMediaManagerDlg::doRemoveMedium()
{
currentList->currentItem() &&
return;
switch (type)
{
case VBoxDefs::MediaType_HardDisk:
{
bool deleteStorage = false;
/// @todo NEWMEDIA use CHardDiskFormat to find out if the format
/// supports storage deletion
/* We don't want to try to delete inaccessible storage as it will
* most likely fail. Note that
* VBoxProblemReporter::confirmRemoveMedium() is aware of that and
* will give a corresponding hint. Therefore, once the code is
* changed below, the hint should be re-checked for validity. */
{
int rc = vboxProblem().
return;
}
if (deleteStorage)
{
bool success = false;
{
parentWidget());
success = true;
}
if (success)
else
progress);
/* we don't want to close the hard disk because it was
* implicitly closed and removed from the list of known media on
* storage deletion */
return;
}
break;
}
case VBoxDefs::MediaType_DVD:
{
break;
}
case VBoxDefs::MediaType_Floppy:
{
break;
}
default:
}
else
}
void VBoxMediaManagerDlg::doReleaseMedium()
{
currentList->currentItem() &&
/* get the fresh attached VM list */
item->refreshAll();
{
continue;
usage += ", ";
}
if (machineIds.size() == 0)
{
/* it may happen that the new machine list is empty (medium was already
* released by a third party); update the details and silently return.*/
return;
}
return;
{
break;
}
/* inform others about medium changes (use a copy since data owning is not
* clean there (to be fixed one day using shared_ptr)) */
}
const QUuid &aMachineId)
{
/* is this medium is attached to the VM we are setting up */
if (mSessionMachineId == aMachineId)
{
}
/* or to some other */
else
{
return false;
}
bool success = true;
{
case VBoxDefs::MediaType_HardDisk:
{
{
{
hda.GetChannel(),
{
success = false;
break;
}
}
}
break;
}
case VBoxDefs::MediaType_DVD:
{
{
success = false;
}
break;
}
case VBoxDefs::MediaType_Floppy:
{
{
success = false;
}
break;
}
default:
AssertFailedBreakStmt (success = false);
}
if (success)
{
{
success = false;
}
}
/* if a new session was opened, we must close it */
return success;
}
{
if (currentList->selectedItem() &&
return id;
}
{
if (currentList->selectedItem() &&
location().stripWhiteSpace();
return loc;
}
{
accept();
}