UIMediumManager.h revision 07a690d662bd122b5e07b2c996990b4ef97f14f2
0N/A/** @file
3261N/A *
0N/A * VBox frontends: Qt4 GUI ("VirtualBox"):
0N/A * UIMediumManager class declaration
0N/A */
0N/A
2362N/A/*
0N/A * Copyright (C) 2006-2013 Oracle Corporation
2362N/A *
0N/A * This file is part of VirtualBox Open Source Edition (OSE), as
0N/A * available from http://www.virtualbox.org. This file is free software;
0N/A * you can redistribute it and/or modify it under the terms of the GNU
0N/A * General Public License (GPL) as published by the Free Software
0N/A * Foundation, in version 2 as it comes in the "COPYING" file of the
0N/A * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0N/A * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0N/A */
0N/A
0N/A#ifndef __UIMediumManager_h__
0N/A#define __UIMediumManager_h__
2362N/A
2362N/A/* GUI includes: */
2362N/A#include "UIMediumManager.gen.h"
0N/A#include "QIWithRetranslateUI.h"
0N/A#include "QIMainDialog.h"
0N/A#include "UIMediumDefs.h"
0N/A
0N/A/* COM includes: */
0N/A#include "COMEnums.h"
0N/A#include "CMachine.h"
0N/A#include "CVirtualBox.h"
0N/A
0N/A/* Forward declarations: */
0N/Aclass UIToolBar;
0N/Aclass UIMediumItem;
0N/Aclass UIEnumerationProgressBar;
0N/Aclass UIMedium;
0N/A
0N/A/** Functor interface allowing to check if passed UIMediumItem is suitable. */
0N/Aclass CheckIfSuitableBy
0N/A{
0N/Apublic:
0N/A /** Determines whether passed UIMediumItem is suitable. */
0N/A virtual bool isItSuitable(UIMediumItem *pItem) const = 0;
0N/A};
0N/A
0N/A/* Medium Manager Dialog: */
0N/Aclass UIMediumManager : public QIWithRetranslateUI2<QIMainDialog>, public Ui::UIMediumManager
0N/A{
0N/A Q_OBJECT;
0N/A
2157N/A /* Enumerators: */
0N/A enum TabIndex { HDTab = 0, CDTab, FDTab };
0N/A enum ItemAction { ItemAction_Added, ItemAction_Updated, ItemAction_Removed };
0N/A enum Action { Action_Edit, Action_Copy, Action_Modify, Action_Remove, Action_Release };
0N/A
0N/A /* Constructor/destructor: */
0N/A UIMediumManager(QWidget *pCenterWidget, bool fRefresh = true);
0N/A ~UIMediumManager();
0N/A
0N/Apublic:
0N/A
0N/A /* Static API: Singleton stuff: */
0N/A static UIMediumManager* instance();
0N/A static void showModeless(QWidget *pCenterWidget, bool fRefresh = true);
0N/A
0N/Apublic slots:
0N/A
0N/A /* Handler: Refresh stuff: */
0N/A void refreshAll();
1946N/A
0N/Aprivate slots:
0N/A
0N/A /* Handlers: Medium-processing stuff: */
0N/A void sltHandleMediumCreated(const QString &strMediumID);
4632N/A void sltHandleMediumDeleted(const QString &strMediumID);
4632N/A
4632N/A /* Handlers: Medium-enumeration stuff: */
4632N/A void sltHandleMediumEnumerationStart();
4632N/A void sltHandleMediumEnumerated(const QString &strMediumID);
4632N/A void sltHandleMediumEnumerationFinish();
4632N/A
4632N/A /* Handlers: Medium-modification stuff: */
4632N/A void sltCopyMedium();
4632N/A void sltModifyMedium();
4632N/A void sltRemoveMedium();
4632N/A void sltReleaseMedium();
4632N/A
4632N/A /* Handlers: Navigation stuff: */
4632N/A void sltHandleCurrentTabChanged();
4632N/A void sltHandleCurrentItemChanged(QTreeWidgetItem *pItem, QTreeWidgetItem *pPrevItem = 0);
4632N/A void sltHandleDoubleClick();
4632N/A void sltHandleContextMenuCall(const QPoint &position);
4632N/A
4632N/A /* Handlers: Geometry stuff: */
0N/A void sltMakeRequestForTableAdjustment();
0N/A void sltPerformTablesAdjustment();
0N/A
0N/Aprivate:
0N/A
0N/A /* Helpers: Prepare stuff: */
0N/A void prepare();
166N/A void prepareThis();
166N/A void prepareActions();
0N/A void prepareMenuBar();
0N/A void prepareToolBar();
4632N/A void prepareContextMenu();
0N/A void prepareTabWidget();
0N/A void prepareTreeWidgets();
0N/A void prepareTreeWidgetHD();
0N/A void prepareTreeWidgetCD();
0N/A void prepareTreeWidgetFD();
0N/A void prepareInformationPanes();
void prepareButtonBox();
void prepareProgressBar();
#ifdef Q_WS_MAC
void prepareMacWindowMenu();
#endif /* Q_WS_MAC */
/* Helper: Populate stuff: */
void populateTreeWidgets();
/** Update actions according currently chosen medium-item. */
void updateActions();
/* Helpers: Cleanup stuff: */
#ifdef Q_WS_MAC
void cleanupMacWindowMenu();
#endif /* Q_WS_MAC */
void cleanup();
/* Handler: Translation stuff: */
void retranslateUi();
/** Creates UIMediumItem for corresponding UIMedium. */
void createMediumItem(const UIMedium &medium);
/** Updates UIMediumItem for corresponding UIMedium. */
void updateMediumItem(const UIMedium &medium);
/* Helpers: Medium-modification stuff: */
bool releaseMediumFrom(const UIMedium &medium, const QString &strMachineId);
bool releaseHardDiskFrom(const UIMedium &medium, CMachine &machine);
bool releaseOpticalDiskFrom(const UIMedium &medium, CMachine &machine);
bool releaseFloppyDiskFrom(const UIMedium &medium, CMachine &machine);
/** Returns current medium type. */
UIMediumType currentMediumType() const;
/** Returns tree-widget for passed medium @a type. */
QTreeWidget* treeWidget(UIMediumType type) const;
/** Returns current tree-widget. */
QTreeWidget* currentTreeWidget() const;
/** Returns medium-item for passed medium @a type. */
UIMediumItem* mediumItem(UIMediumType type) const;
/** Returns current medium-item. */
UIMediumItem* currentMediumItem() const;
/** Defines <i>current-item</i> for passed @a pTree as @a pItem. */
void setCurrentItem(QTreeWidget *pTree, QTreeWidgetItem *pItem);
UIMediumItem* searchItem(QTreeWidget *pTree, const CheckIfSuitableBy &functor) const;
UIMediumItem* searchItem(QTreeWidgetItem *pParentItem, const CheckIfSuitableBy &functor) const;
UIMediumItem* createHardDiskItem(QTreeWidget *pTree, const UIMedium &medium) const;
/* Internal API: Tab-widget access stuff: */
void updateTabIcons(UIMediumItem *pItem, ItemAction action);
/* Helpers: Other stuff: */
bool checkMediumFor(UIMediumItem *pItem, Action action);
void clearInfoPanes();
void prepareToRefresh(int iTotal = 0);
/** Casts passed QTreeWidgetItem @a pItem to UIMediumItem if possible. */
static UIMediumItem* toMediumItem(QTreeWidgetItem *pItem);
/* Static helper: Formatting stuff: */
static QString formatPaneText(const QString &strText, bool fCompact = true, const QString &strElipsis = "middle");
/* Static helper: Enumeration stuff: */
static bool isMediumAttachedToHiddenMachinesOnly(const UIMedium &medium);
/* Variable: Singleton instance: */
static UIMediumManager *m_spInstance;
/* Variables: General stuff: */
CVirtualBox m_vbox;
QWidget *m_pCenterWidget;
bool m_fRefresh;
/* Variables: Tab-widget stuff: */
bool m_fInaccessibleHD;
bool m_fInaccessibleCD;
bool m_fInaccessibleFD;
const QIcon m_iconHD;
const QIcon m_iconCD;
const QIcon m_iconFD;
QString m_strSelectedIdHD;
QString m_strSelectedIdCD;
QString m_strSelectedIdFD;
/* Variables: Menu & Toolbar stuff: */
UIToolBar *m_pToolBar;
QMenu *m_pContextMenu;
QMenu *m_pMenu;
QAction *m_pActionCopy;
QAction *m_pActionModify;
QAction *m_pActionRemove;
QAction *m_pActionRelease;
QAction *m_pActionRefresh;
/* Variable: Progress-bar stuff: */
UIEnumerationProgressBar *m_pProgressBar;
};
#endif /* __UIMediumManager_h__ */