UIMediumManager.h revision 8230e6f6671b538d39c7ef6d8484cf516a983ef4
551N/A/** @file
551N/A *
551N/A * VBox frontends: Qt4 GUI ("VirtualBox"):
551N/A * UIMediumManager class declaration
551N/A */
551N/A
551N/A/*
551N/A * Copyright (C) 2006-2009 Oracle Corporation
551N/A *
551N/A * This file is part of VirtualBox Open Source Edition (OSE), as
551N/A * available from http://www.virtualbox.org. This file is free software;
551N/A * you can redistribute it and/or modify it under the terms of the GNU
551N/A * General Public License (GPL) as published by the Free Software
551N/A * Foundation, in version 2 as it comes in the "COPYING" file of the
551N/A * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
551N/A * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
551N/A */
551N/A
551N/A#ifndef __UIMediumManager_h__
551N/A#define __UIMediumManager_h__
551N/A
551N/A/* GUI includes */
551N/A#include "UIMediumManager.gen.h"
551N/A#include "QIMainDialog.h"
551N/A#include "QIWithRetranslateUI.h"
551N/A#include "VBoxDefs.h"
551N/A#include "VBoxMediaComboBox.h"
551N/A
575N/A/* COM includes: */
551N/A#include "CMachine.h"
551N/A
551N/A/* Forward declarations: */
551N/Aclass MediaItem;
551N/Aclass VBoxProgressBar;
551N/Aclass UIToolBar;
551N/A
551N/Aclass UIMediumManager : public QIWithRetranslateUI2<QIMainDialog>,
551N/A public Ui::UIMediumManager
551N/A{
551N/A Q_OBJECT;
551N/A
551N/A enum TabIndex { HDTab = 0, CDTab, FDTab };
575N/A enum ItemAction { ItemAction_Added, ItemAction_Updated, ItemAction_Removed };
575N/A enum Action { Action_Select, Action_Edit, Action_Copy, Action_Modify, Action_Remove, Action_Release };
551N/A
551N/Apublic:
551N/A
551N/A UIMediumManager (QWidget *aParent = NULL,
551N/A Qt::WindowFlags aFlags = Qt::Dialog);
551N/A ~UIMediumManager();
551N/A
551N/A void setup (UIMediumType aType, bool aDoSelect,
551N/A bool aRefresh = true,
551N/A const CMachine &aSessionMachine = CMachine(),
551N/A const QString &aSelectId = QString::null,
551N/A bool aShowDiffs = true,
551N/A const QStringList &aUsedMediaIds = QStringList());
551N/A
551N/A static void showModeless (QWidget *aParent = NULL, bool aRefresh = true);
QString selectedId() const;
QString selectedLocation() const;
bool showDiffs() const { return mShowDiffs; };
bool inAttachMode() const { return !mSessionMachine.isNull(); };
public slots:
void refreshAll();
protected:
void retranslateUi();
virtual void closeEvent (QCloseEvent *aEvent);
virtual bool eventFilter (QObject *aObject, QEvent *aEvent);
private slots:
void mediumAdded (const UIMedium &aMedium);
void mediumUpdated (const UIMedium &aMedium);
void mediumRemoved (UIMediumType aType, const QString &aId);
void mediumEnumStarted();
void mediumEnumerated (const UIMedium &aMedium);
void mediumEnumFinished (const VBoxMediaList &aList);
void doNewMedium();
void doAddMedium();
void doCopyMedium();
void doModifyMedium();
void doRemoveMedium();
void doReleaseMedium();
bool releaseMediumFrom (const UIMedium &aMedium, const QString &aMachineId);
void processCurrentChanged (int index = -1);
void processCurrentChanged (QTreeWidgetItem *aItem, QTreeWidgetItem *aPrevItem = 0);
void processDoubleClick (QTreeWidgetItem *aItem, int aColumn);
void showContextMenu (const QPoint &aPos);
void machineStateChanged(QString strId, KMachineState state);
void makeRequestForAdjustTable();
void performTablesAdjustment();
private:
QTreeWidget* treeWidget (UIMediumType aType) const;
UIMediumType currentTreeWidgetType() const;
QTreeWidget* currentTreeWidget() const;
QTreeWidgetItem* selectedItem (const QTreeWidget *aTree) const;
MediaItem* toMediaItem (QTreeWidgetItem *aItem) const;
void setCurrentItem (QTreeWidget *aTree, QTreeWidgetItem *aItem);
void addMediumToList (const QString &aLocation, UIMediumType aType);
MediaItem* createHardDiskItem (QTreeWidget *aTree, const UIMedium &aMedium) const;
void updateTabIcons (MediaItem *aItem, ItemAction aAction);
MediaItem* searchItem (QTreeWidget *aTree, const QString &aId) const;
bool checkMediumFor (MediaItem *aItem, Action aAction);
bool checkDndUrls (const QList<QUrl> &aUrls) const;
void addDndUrls (const QList<QUrl> &aUrls);
void clearInfoPanes();
void prepareToRefresh (int aTotal = 0);
QString formatPaneText (const QString &aText, bool aCompact = true, const QString &aElipsis = "middle");
/* Private member vars */
/* Window status */
bool mDoSelect;
static UIMediumManager *mModelessDialog;
VBoxProgressBar *mProgressBar;
/* The global VirtualBox instance */
CVirtualBox mVBox;
/* Type if we are in the select modus */
int mType;
bool mShowDiffs : 1;
bool mSetupMode : 1;
/* Icon definitions */
QIcon mHardDiskIcon;
QIcon mDVDImageIcon;
QIcon mFloppyImageIcon;
/* Menu & Toolbar */
QMenu *mActionsContextMenu;
QMenu *mActionsMenu;
UIToolBar *mToolBar;
QAction *mNewAction;
QAction *mAddAction;
QAction *mCopyAction;
QAction *mModifyAction;
QAction *mRemoveAction;
QAction *mReleaseAction;
QAction *mRefreshAction;
/* Machine */
CMachine mSessionMachine;
QString mSessionMachineId;
bool mHardDisksInaccessible;
bool mDVDImagesInaccessible;
bool mFloppyImagesInaccessible;
QString mHDSelectedId;
QString mCDSelectedId;
QString mFDSelectedId;
QStringList mUsedMediaIds;
};
#endif /* __UIMediumManager_h__ */