VBoxVMSettingsHD.cpp revision e64031e20c39650a7bc902a3e1aba613b9415dee
/* $Id$ */
/** @file
*
* VBox frontends: Qt4 GUI ("VirtualBox"):
* VBoxVMSettingsHD class implementation
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* 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.
*/
/* Global Includes */
#include <QHeaderView>
#include <QItemEditorFactory>
#include <QMetaProperty>
#include <QMouseEvent>
#include <QScrollBar>
#include <QStylePainter>
#include <QTimer>
/* Local Includes */
#include "VBoxVMSettingsHD.h"
#include "VBoxGlobal.h"
#include "VBoxProblemReporter.h"
#include "QIWidgetValidator.h"
#include "VBoxToolBar.h"
#include "VBoxMediaManagerDlg.h"
#include "UINewHDWzd.h"
/* String Tags */
const char *firstAvailableId = "first available";
/* Type converters */
{
switch (aType)
{
case KDeviceType_HardDisk:
break;
case KDeviceType_DVD:
break;
case KDeviceType_Floppy:
break;
default:
AssertMsgFailed (("Incorrect medium type!\n"));
break;
}
return result;
}
{
}
/* Pixmap Storage */
{
if (!mThis)
{
}
else
{
}
return mThis;
}
{
}
{
}
/* Abstract Controller Type */
AbstractControllerType::AbstractControllerType (KStorageBus aBusType, KStorageControllerType aCtrType)
{
for (int i = 0; i < State_MAX; ++ i)
{
switch (mBusType)
{
case KStorageBus_IDE:
break;
case KStorageBus_SATA:
break;
case KStorageBus_SCSI:
break;
case KStorageBus_Floppy:
break;
case KStorageBus_SAS:
break;
default:
break;
}
}
}
{
return mBusType;
}
{
return mCtrType;
}
{
result << (KStorageControllerType) i;
return result;
}
{
}
{
}
{
return vboxGlobal().virtualBox().GetSystemProperties().GetDeviceTypesForStorageBus (mBusType).toList();
}
/* IDE Controller Type */
{
}
{
return KStorageControllerType_PIIX3;
}
{
return 3;
}
/* SATA Controller Type */
{
}
{
return KStorageControllerType_IntelAhci;
}
{
return 1;
}
/* SCSI Controller Type */
{
}
{
return KStorageControllerType_LsiLogic;
}
{
return 2;
}
/* Floppy Controller Type */
{
}
{
return KStorageControllerType_I82078;
}
{
return 1;
}
/* SAS Controller Type */
{
}
{
}
{
return 1;
}
/* Abstract Item */
{
}
{
}
{
return mParent;
}
{
return mId;
}
{
return mMachineId;
}
{
}
/* Root Item */
: AbstractItem (0)
{
}
{
while (!mControllers.isEmpty())
delete mControllers.first();
}
{
{
++ result;
}
return result;
}
{
return Type_RootItem;
}
{
return mControllers [aIndex];
}
{
for (int i = 0; i < childCount(); ++ i)
return mControllers [i];
return 0;
}
{
}
int RootItem::childCount() const
{
return mControllers.size();
}
{
return QString();
}
{
return QString();
}
{
return QPixmap();
}
{
mControllers << aItem;
}
{
}
/* Controller Item */
: AbstractItem (aParent)
, mCtrType (0)
{
/* Check for proper parent type */
/* Select default type */
switch (aBusType)
{
case KStorageBus_IDE:
break;
case KStorageBus_SATA:
break;
case KStorageBus_SCSI:
break;
case KStorageBus_Floppy:
break;
case KStorageBus_SAS:
break;
default:
break;
}
}
{
delete mCtrType;
while (!mAttachments.isEmpty())
delete mAttachments.first();
}
{
}
{
return mCtrName;
}
{
}
{
}
{
}
{
}
{
return allSlots;
}
{
for (int i = 0; i < mAttachments.size(); ++ i)
return usedSlots;
}
{
return mCtrType->deviceTypeList();
}
{
{
{
{
/* In 'don't show diffs' mode we should only show hard-disks which are:
* 1. Attached to 'current state' of this VM even if these are differencing disks.
* 2. Not attached to this VM at all only if they are not differencing disks. */
{
}
break;
}
}
}
return allMediums;
}
{
for (int i = 0; i < mAttachments.size(); ++ i)
{
}
return usedImages;
}
{
return Type_ControllerItem;
}
{
return mAttachments [aIndex];
}
{
for (int i = 0; i < childCount(); ++ i)
return mAttachments [i];
return 0;
}
{
}
int ControllerItem::childCount() const
{
return mAttachments.size();
}
{
return ctrName();
}
{
"<nobr>Bus: %2</nobr><br>"
"<nobr>Type: %3</nobr>")
}
{
}
{
mAttachments << aItem;
}
{
}
/* Attachment Item */
: AbstractItem (aParent)
, mAttIsShowDiffs (false)
, mAttIsHostDrive (false)
, mAttIsPassthrough (false)
{
/* Check for proper parent type */
/* Select default slot */
/* Try to select unique medium */
switch (mAttDeviceType)
{
case KDeviceType_HardDisk:
if (freeMediumIds.size() > 0)
setAttMediumId (freeMediumIds [0]);
break;
case KDeviceType_DVD:
case KDeviceType_Floppy:
setAttMediumId (freeMediumIds [0]);
break;
default:
break;
}
}
{
return mAttSlot;
}
{
/* Filter list from used slots */
return allSlots;
}
{
return mAttDeviceType;
}
{
}
{
return mAttMediumId;
}
{
/* Populate list of suitable medium ids */
{
allMediumIds << mediumId;
}
if (aFilter)
{
/* Filter list from used medium ids */
if (usedMediumId != mAttMediumId)
}
return allMediumIds;
}
bool AttachmentItem::attIsShowDiffs() const
{
return mAttIsShowDiffs;
}
bool AttachmentItem::attIsHostDrive() const
{
return mAttIsHostDrive;
}
bool AttachmentItem::attIsPassthrough() const
{
return mAttIsPassthrough;
}
{
}
{
}
{
/* Caching first available medium */
/* Caching passed medium */
else if (!aAttMediumId.isEmpty())
cache();
}
{
cache();
}
{
}
{
return mAttSize;
}
{
return mAttLogicalSize;
}
{
return mAttLocation;
}
{
return mAttFormat;
}
{
return mAttUsage;
}
void AttachmentItem::cache()
{
/* Cache medium information */
/* Cache additional information */
/* Fill empty attributes */
}
{
return Type_AttachmentItem;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
int AttachmentItem::childCount() const
{
return 0;
}
{
return mAttName;
}
{
return mAttTip;
}
{
if (mAttPixmap.isNull())
{
switch (mAttDeviceType)
{
case KDeviceType_HardDisk:
break;
case KDeviceType_DVD:
break;
case KDeviceType_Floppy:
break;
default:
break;
}
}
return mAttPixmap;
}
{
}
{
}
/* Storage model */
{
}
{
delete mRootItem;
}
{
}
{
return 1;
}
{
return index (0, 0);
}
{
return QModelIndex();
}
{
return QModelIndex();
if (parentOfItem)
else
return QModelIndex();
}
{
return QVariant();
switch (aRole)
{
/* Basic Attributes: */
{
}
case Qt::SizeHintRole:
{
}
case Qt::ToolTipRole:
{
{
{
switch (mToolTipType)
{
case ExpanderToolTip:
break;
case HDAdderToolTip:
break;
case CDAdderToolTip:
break;
case FDAdderToolTip:
break;
default:
break;
}
return tip;
}
}
return QString();
}
/* Advanced Attributes: */
case R_ItemId:
{
}
case R_ItemPixmap:
{
{
if (hasChildren (aIndex))
}
return QPixmap();
}
case R_ItemPixmapRect:
{
}
case R_ItemName:
{
return QString();
}
case R_ItemNamePoint:
{
}
case R_ItemType:
{
return result;
}
case R_IsController:
{
return false;
}
case R_IsAttachment:
{
return false;
}
case R_ToolTipType:
{
}
{
}
{
}
{
}
{
}
{
}
{
{
{
}
}
return false;
}
case R_CtrName:
{
return QString();
}
case R_CtrType:
{
return result;
}
case R_CtrTypes:
{
return result;
}
case R_CtrDevices:
{
return result;
}
case R_CtrBusType:
{
return result;
}
case R_AttSlot:
{
return result;
}
case R_AttSlots:
{
return result;
}
case R_AttDevice:
{
return result;
}
case R_AttMediumId:
{
return QString();
}
case R_AttIsShowDiffs:
{
return false;
}
case R_AttIsHostDrive:
{
return false;
}
case R_AttIsPassthrough:
{
return false;
}
case R_AttSize:
{
return QString();
}
case R_AttLogicalSize:
{
return QString();
}
case R_AttLocation:
{
return QString();
}
case R_AttFormat:
{
return QString();
}
case R_AttUsage:
{
return QString();
}
case R_Margin:
{
return 4;
}
case R_Spacing:
{
return 4;
}
case R_IconSize:
{
return 16;
}
case R_HDPixmapEn:
{
}
case R_CDPixmapEn:
{
}
case R_FDPixmapEn:
{
}
case R_HDPixmapAddEn:
{
}
case R_HDPixmapAddDis:
{
}
case R_CDPixmapAddEn:
{
}
case R_CDPixmapAddDis:
{
}
case R_FDPixmapAddEn:
{
}
case R_FDPixmapAddDis:
{
}
case R_HDPixmapRect:
{
}
case R_CDPixmapRect:
{
}
case R_FDPixmapRect:
{
}
default:
break;
}
return QVariant();
}
{
switch (aRole)
{
case R_ToolTipType:
{
return true;
}
case R_CtrName:
{
{
return true;
}
return false;
}
case R_CtrType:
{
{
return true;
}
return false;
}
case R_AttSlot:
{
{
return true;
}
return false;
}
case R_AttDevice:
{
{
return true;
}
return false;
}
case R_AttMediumId:
{
{
return true;
}
return false;
}
case R_AttIsShowDiffs:
{
{
return true;
}
return false;
}
case R_AttIsPassthrough:
{
{
return true;
}
return false;
}
default:
break;
}
return false;
}
QModelIndex StorageModel::addController (const QString &aCtrName, KStorageBus aBusType, KStorageControllerType aCtrType)
{
}
{
{
delete item;
}
}
QModelIndex StorageModel::addAttachment (const QUuid &aCtrId, KDeviceType aDeviceType, bool aVerbose)
{
{
}
return QModelIndex();
}
{
{
{
delete item;
}
}
}
{
}
{
}
/* Storage Delegate */
: QItemDelegate (aParent)
{
}
void StorageDelegate::paint (QPainter *aPainter, const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const
{
/* Initialize variables */
/* Draw item background */
/* Setup foregroung settings */
bool isGrayOnLoosingFocus = QApplication::style()->styleHint (QStyle::SH_ItemView_ChangeHighlightOnFocus, &aOption) != 0;
/* Draw Item Pixmap */
/* Draw compressed item name */
{
}
shortText += "...";
/* Draw Controller Additions */
{
DeviceTypeList devicesList (model->data (aIndex, StorageModel::R_CtrDevices).value <DeviceTypeList>());
for (int i = 0; i < devicesList.size(); ++ i)
{
switch (deviceType)
{
case KDeviceType_HardDisk:
{
break;
}
case KDeviceType_DVD:
{
break;
}
case KDeviceType_Floppy:
{
break;
}
default:
break;
}
}
}
}
/**
* QWidget class reimplementation.
* Used as HD Settings widget.
*/
: mValidator (0)
, mIsPolished (false)
{
/* Apply UI decorations */
/* Enumerate Mediums */
/* Initialize pixmap pool */
PixmapPool::pool (this);
/* Controller Actions */
mAddCtrAction = new QAction (this);
mAddCtrAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::ControllerAddEn),
mAddIDECtrAction = new QAction (this);
mAddIDECtrAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::IDEControllerAddEn),
mAddSATACtrAction = new QAction (this);
mAddSATACtrAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::SATAControllerAddEn),
mAddSCSICtrAction = new QAction (this);
mAddSCSICtrAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::SCSIControllerAddEn),
mAddFloppyCtrAction = new QAction (this);
mAddFloppyCtrAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::FloppyControllerAddEn),
mAddSASCtrAction = new QAction (this);
mAddSASCtrAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::SATAControllerAddEn),
mDelCtrAction = new QAction (this);
mDelCtrAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::ControllerDelEn),
/* Attachment Actions */
mAddAttAction = new QAction (this);
mAddAttAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::AttachmentAddEn),
mAddHDAttAction = new QAction (this);
mAddHDAttAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::HDAttachmentAddEn),
mAddCDAttAction = new QAction (this);
mAddCDAttAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::CDAttachmentAddEn),
mAddFDAttAction = new QAction (this);
mAddFDAttAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::FDAttachmentAddEn),
mDelAttAction = new QAction (this);
mDelAttAction->setIcon (VBoxGlobal::iconSet (PixmapPool::pool()->pixmap (PixmapPool::AttachmentDelEn),
mTwStorageTree->setMouseTracking (true);
/* Storage ToolBar */
#ifdef Q_WS_MAC
/* We need a little more space for the focus rect. */
#endif /* Q_WS_MAC */
/* Vdi Combo */
mCbVdi->setNullItemPresent (true);
/* Vmm Button */
/* Info Pane initialization */
mLbHDActualSizeValue->setFullSizeSelection (true);
mLbSizeValue->setFullSizeSelection (true);
mLbLocationValue->setFullSizeSelection (true);
mLbHDFormatValue->setFullSizeSelection (true);
mLbUsageValue->setFullSizeSelection (true);
/* Setup connections */
this, SLOT (onRowRemoved()));
this, SLOT (onCurrentItemChanged()));
/* Update actions */
/* Applying language settings */
/* Initial setup */
setMinimumWidth (500);
mSplitter->setSizes (QList<int>() << (int) (0.45 * minimumWidth()) << (int) (0.55 * minimumWidth()));
}
{
/* Set the machine id for the media-combo */
/* Load currently present controllers & attachments */
{
QModelIndex ctrIndex = mStorageModel->addController (controllerName, controller.GetBus(), controller.GetControllerType());
{
mStorageModel->setData (attIndex, QVariant::fromValue (StorageSlot (controller.GetBus(), attachment.GetPort(), attachment.GetDevice())), StorageModel::R_AttSlot);
}
}
/* Set the first controller as current if present */
}
void VBoxVMSettingsHD::putBackTo()
{
/* Remove currently present controllers & attachments */
{
}
/* Save created controllers & attachments */
{
KStorageBus ctrBusType = mStorageModel->data (ctrIndex, StorageModel::R_CtrBusType).value <KStorageBus>();
KStorageControllerType ctrType = mStorageModel->data (ctrIndex, StorageModel::R_CtrType).value <KStorageControllerType>();
int maxUsedPort = -1;
{
StorageSlot attStorageSlot = mStorageModel->data (attIndex, StorageModel::R_AttSlot).value <StorageSlot>();
KDeviceType attDeviceType = mStorageModel->data (attIndex, StorageModel::R_AttDevice).value <KDeviceType>();
mMachine.AttachDevice (ctrName, attStorageSlot.port, attStorageSlot.device, attDeviceType, attMediumId);
if (attDeviceType == KDeviceType_DVD)
}
if (ctrBusType == KStorageBus_SATA)
{
}
}
}
{
mValidator = aVal;
}
{
{
{
StorageSlot attSlot = mStorageModel->data (attIndex, StorageModel::R_AttSlot).value <StorageSlot>();
KDeviceType attDevice = mStorageModel->data (attIndex, StorageModel::R_AttDevice).value <KDeviceType>();
/* Check for emptiness */
{
}
/* Check for coincidence */
{
}
}
}
}
void VBoxVMSettingsHD::retranslateUi()
{
/* Translate uic generated strings */
"currently selected controller as parent."));
}
{
if (!mIsPolished)
{
mIsPolished = true;
/* First column indent */
#if 0
/* Second column indent minimum width */
int maxWidth = 0;
{
}
#endif
}
}
{
{
{
{
}
}
}
}
{
{
{
if (attMediumId == aMediumId)
{
}
}
}
}
void VBoxVMSettingsHD::addController()
{
}
void VBoxVMSettingsHD::addIDEController()
{
addControllerWrapper (generateUniqueName (tr ("IDE Controller")), KStorageBus_IDE, KStorageControllerType_PIIX4);
}
void VBoxVMSettingsHD::addSATAController()
{
addControllerWrapper (generateUniqueName (tr ("SATA Controller")), KStorageBus_SATA, KStorageControllerType_IntelAhci);
}
void VBoxVMSettingsHD::addSCSIController()
{
addControllerWrapper (generateUniqueName (tr ("SCSI Controller")), KStorageBus_SCSI, KStorageControllerType_LsiLogic);
}
void VBoxVMSettingsHD::addFloppyController()
{
addControllerWrapper (generateUniqueName (tr ("Floppy Controller")), KStorageBus_Floppy, KStorageControllerType_I82078);
}
void VBoxVMSettingsHD::addSASController()
{
addControllerWrapper (generateUniqueName (tr ("SAS Controller")), KStorageBus_SAS, KStorageControllerType_LsiLogicSas);
}
void VBoxVMSettingsHD::delController()
{
mStorageModel->delController (QUuid (mStorageModel->data (index, StorageModel::R_ItemId).toString()));
}
void VBoxVMSettingsHD::addAttachment()
{
DeviceTypeList deviceTypeList (mStorageModel->data (index, StorageModel::R_CtrDevices).value <DeviceTypeList>());
{
switch (deviceType)
{
case KDeviceType_HardDisk:
if (justTrigger)
if (showMenu)
break;
case KDeviceType_DVD:
if (justTrigger)
if (showMenu)
break;
case KDeviceType_Floppy:
if (justTrigger)
if (showMenu)
break;
default:
break;
}
}
if (showMenu)
}
void VBoxVMSettingsHD::addHDAttachment()
{
}
void VBoxVMSettingsHD::addCDAttachment()
{
}
void VBoxVMSettingsHD::addFDAttachment()
{
}
void VBoxVMSettingsHD::delAttachment()
{
/* Check if this would be the last DVD. If so let the user confirm this again. */
if ( device == KDeviceType_DVD
{
return;
}
return;
mStorageModel->delAttachment (QUuid (mStorageModel->data (parent, StorageModel::R_ItemId).toString()),
}
void VBoxVMSettingsHD::getInformation()
{
mIsLoadingInProgress = true;
{
/* Showing Initial Page */
mSwRightPane->setCurrentIndex (0);
}
else
{
{
case AbstractItem::Type_ControllerItem:
{
/* Getting Controller Name */
/* Getting Controller Sub type */
ControllerTypeList controllerTypeList (mStorageModel->data (index, StorageModel::R_CtrTypes).value <ControllerTypeList>());
for (int i = 0; i < controllerTypeList.size(); ++ i)
KStorageControllerType type = mStorageModel->data (index, StorageModel::R_CtrType).value <KStorageControllerType>();
/* Showing Controller Page */
break;
}
case AbstractItem::Type_AttachmentItem:
{
/* Getting Attachment Slot */
/* Getting Show Diffs state */
/* Getting Attachment Medium */
switch (device)
{
case KDeviceType_HardDisk:
break;
case KDeviceType_DVD:
break;
case KDeviceType_Floppy:
break;
default:
break;
}
/* Getting Passthrough state */
/* Passthrough is currently available only for the IDE controller DVD device */
bool isIdeCtr = mStorageModel->data (index.parent(), StorageModel::R_CtrBusType).value <KStorageBus>() == KStorageBus_IDE;
mCbPassthrough->setChecked (isHostDrive && isIdeCtr && mStorageModel->data (index, StorageModel::R_AttIsPassthrough).toBool());
/* Update optional widgets visibility */
/* Getting Other Information */
mLbHDVirtualSizeValue->setText (compressText (mStorageModel->data (index, StorageModel::R_AttLogicalSize).toString()));
mLbHDActualSizeValue->setText (compressText (mStorageModel->data (index, StorageModel::R_AttSize).toString()));
mLbSizeValue->setText (compressText (mStorageModel->data (index, StorageModel::R_AttSize).toString()));
mLbLocationValue->setText (compressText (mStorageModel->data (index, StorageModel::R_AttLocation).toString()));
mLbHDFormatValue->setText (compressText (mStorageModel->data (index, StorageModel::R_AttFormat).toString()));
mLbUsageValue->setText (compressText (mStorageModel->data (index, StorageModel::R_AttUsage).toString()));
/* Showing Attachment Page */
break;
}
default:
break;
}
}
mIsLoadingInProgress = false;
}
void VBoxVMSettingsHD::setInformation()
{
{
case AbstractItem::Type_ControllerItem:
{
/* Setting Controller Name */
/* Setting Controller Sub-Type */
mStorageModel->setData (index, QVariant::fromValue (vboxGlobal().toControllerType (mCbType->currentText())),
break;
}
case AbstractItem::Type_AttachmentItem:
{
/* Setting Attachment Slot */
mStorageModel->setData (index, QVariant::fromValue (vboxGlobal().toStorageSlot (mCbSlot->currentText())),
/* Setting Attachment Medium */
else if (sdr == mCbShowDiffs)
else if (sdr == mCbPassthrough)
{
}
break;
}
default:
break;
}
}
void VBoxVMSettingsHD::onVmmInvoked()
{
}
void VBoxVMSettingsHD::updateActionsState()
{
bool isIDEPossible = mStorageModel->data (index, StorageModel::R_IsMoreIDEControllersPossible).toBool();
bool isSATAPossible = mStorageModel->data (index, StorageModel::R_IsMoreSATAControllersPossible).toBool();
bool isSCSIPossible = mStorageModel->data (index, StorageModel::R_IsMoreSCSIControllersPossible).toBool();
bool isFloppyPossible = mStorageModel->data (index, StorageModel::R_IsMoreFloppyControllersPossible).toBool();
bool isSASPossible = mStorageModel->data (index, StorageModel::R_IsMoreSASControllersPossible).toBool();
bool isAttachmentsPossible = mStorageModel->data (index, StorageModel::R_IsMoreAttachmentsPossible).toBool();
}
{
{
case AbstractItem::Type_ControllerItem:
{
/* Select the newly created Controller Item */
break;
}
case AbstractItem::Type_AttachmentItem:
{
/* Expand parent if it is not expanded yet */
/* Check if no medium was selected for this attachment */
{
/* Ask the user for the method to select medium */
KDeviceType deviceType = mStorageModel->data (index, StorageModel::R_AttDevice).value <KDeviceType>();
}
break;
}
default:
break;
}
}
void VBoxVMSettingsHD::onRowRemoved()
{
}
void VBoxVMSettingsHD::onCurrentItemChanged()
{
}
{
{
case AbstractItem::Type_ControllerItem:
{
DeviceTypeList deviceTypeList (mStorageModel->data (index, StorageModel::R_CtrDevices).value <DeviceTypeList>());
{
switch (deviceType)
{
case KDeviceType_HardDisk:
break;
case KDeviceType_DVD:
break;
case KDeviceType_Floppy:
break;
default:
break;
}
}
break;
}
case AbstractItem::Type_AttachmentItem:
{
break;
}
default:
break;
}
}
void VBoxVMSettingsHD::onDrawItemBranches (QPainter *aPainter, const QRect &aRect, const QModelIndex &aIndex)
{
/* This pen is commonly used by different
* look and feel styles to paint tree-view branches. */
/* If we want tree-view branches to be always painted we have to use QCommonStyle::drawPrimitive()
* because QCommonStyle performs branch painting as opposed to particular inherited sub-classing styles. */
qobject_cast <QCommonStyle*> (style())->QCommonStyle::drawPrimitive (QStyle::PE_IndicatorBranch, &options, aPainter);
}
{
/* Expander tool-tip */
{
{
aEvent->setAccepted (true);
if (mStorageModel->data (index, StorageModel::R_ToolTipType).value <StorageModel::ToolTipType>() != StorageModel::ExpanderToolTip)
mStorageModel->setData (index, QVariant::fromValue (StorageModel::ExpanderToolTip), StorageModel::R_ToolTipType);
return;
}
}
/* Adder tool-tip */
{
DeviceTypeList devicesList (mStorageModel->data (index, StorageModel::R_CtrDevices).value <DeviceTypeList>());
for (int i = 0; i < devicesList.size(); ++ i)
{
switch (deviceType)
{
case KDeviceType_HardDisk:
{
break;
}
case KDeviceType_DVD:
{
break;
}
case KDeviceType_Floppy:
{
break;
}
default:
break;
}
{
aEvent->setAccepted (true);
switch (deviceType)
{
case KDeviceType_HardDisk:
{
if (mStorageModel->data (index, StorageModel::R_ToolTipType).value <StorageModel::ToolTipType>() != StorageModel::HDAdderToolTip)
mStorageModel->setData (index, QVariant::fromValue (StorageModel::HDAdderToolTip), StorageModel::R_ToolTipType);
break;
}
case KDeviceType_DVD:
{
if (mStorageModel->data (index, StorageModel::R_ToolTipType).value <StorageModel::ToolTipType>() != StorageModel::CDAdderToolTip)
mStorageModel->setData (index, QVariant::fromValue (StorageModel::CDAdderToolTip), StorageModel::R_ToolTipType);
break;
}
case KDeviceType_Floppy:
{
if (mStorageModel->data (index, StorageModel::R_ToolTipType).value <StorageModel::ToolTipType>() != StorageModel::FDAdderToolTip)
mStorageModel->setData (index, QVariant::fromValue (StorageModel::FDAdderToolTip), StorageModel::R_ToolTipType);
break;
}
default:
break;
}
return;
}
}
}
/* Default tool-tip */
if (mStorageModel->data (index, StorageModel::R_ToolTipType).value <StorageModel::ToolTipType>() != StorageModel::DefaultToolTip)
}
{
/* Expander icon */
{
{
aEvent->setAccepted (true);
return;
}
}
/* Adder icons */
{
DeviceTypeList devicesList (mStorageModel->data (index, StorageModel::R_CtrDevices).value <DeviceTypeList>());
for (int i = 0; i < devicesList.size(); ++ i)
{
switch (deviceType)
{
case KDeviceType_HardDisk:
{
break;
}
case KDeviceType_DVD:
{
break;
}
case KDeviceType_Floppy:
{
break;
}
default:
break;
}
{
aEvent->setAccepted (true);
if (mAddAttAction->isEnabled())
return;
}
}
}
}
void VBoxVMSettingsHD::addControllerWrapper (const QString &aName, KStorageBus aBus, KStorageControllerType aType)
{
switch (aBus)
{
case KStorageBus_IDE:
break;
case KStorageBus_SATA:
break;
case KStorageBus_SCSI:
break;
case KStorageBus_SAS:
break;
case KStorageBus_Floppy:
break;
default:
break;
}
}
{
mStorageModel->addAttachment (QUuid (mStorageModel->data (index, StorageModel::R_ItemId).toString()), aDevice, true);
}
{
/* Run New HD Wizard */
UINewHDWzd dlg (this);
}
{
/* Run Media Manager */
VBoxMediaManagerDlg dlg (this);
true /* do select? */,
false /* do refresh? */,
mCbShowDiffs->isChecked());
}
{
}
{
int maxNumber = 0;
{
{
bool isConverted = false;
}
}
}
{
{
{
KDeviceType attDevice = mStorageModel->data (attIndex, StorageModel::R_AttDevice).value <KDeviceType>();
++cDevices;
}
}
return cDevices;
}