UIMediumManager.h revision 2a3ea815abf6290c6e17e81eb350e5c19a090c64
551N/A/** @file
551N/A *
551N/A * VBox frontends: Qt4 GUI ("VirtualBox"):
551N/A * UIMediumManager class declaration
1097N/A */
551N/A
551N/A/*
919N/A * Copyright (C) 2006-2013 Oracle Corporation
919N/A *
919N/A * This file is part of VirtualBox Open Source Edition (OSE), as
919N/A * available from http://www.virtualbox.org. This file is free software;
919N/A * you can redistribute it and/or modify it under the terms of the GNU
919N/A * General Public License (GPL) as published by the Free Software
919N/A * Foundation, in version 2 as it comes in the "COPYING" file of the
919N/A * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
919N/A * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
919N/A */
919N/A
919N/A#ifndef __UIMediumManager_h__
919N/A#define __UIMediumManager_h__
919N/A
919N/A/* GUI includes: */
919N/A#include "UIMediumManager.gen.h"
919N/A#include "QIWithRetranslateUI.h"
551N/A#include "QIMainDialog.h"
551N/A#include "UIMediumDefs.h"
551N/A
551N/A/* COM includes: */
551N/A#include "COMEnums.h"
551N/A#include "CMachine.h"
970N/A#include "CVirtualBox.h"
970N/A
970N/A/* Forward declarations: */
970N/Aclass UIToolBar;
970N/Aclass UIMediumItem;
970N/Aclass UIEnumerationProgressBar;
970N/Aclass UIMedium;
970N/A
551N/A/** Functor interface allowing to check if passed UIMediumItem is suitable. */
551N/Aclass CheckIfSuitableBy
551N/A{
551N/Apublic:
551N/A /** Determines whether passed UIMediumItem is suitable. */
551N/A virtual bool isItSuitable(UIMediumItem *pItem) const = 0;
1097N/A};
1097N/A
1097N/A/* Medium Manager Dialog: */
1097N/Aclass UIMediumManager : public QIWithRetranslateUI2<QIMainDialog>, public Ui::UIMediumManager
551N/A{
551N/A Q_OBJECT;
551N/A
551N/A /* Enumerators: */
551N/A enum TabIndex { HDTab = 0, CDTab, FDTab };
551N/A enum ItemAction { ItemAction_Added, ItemAction_Updated, ItemAction_Removed };
551N/A enum Action { Action_Edit, Action_Copy, Action_Modify, Action_Remove, Action_Release };
551N/A
551N/A /* Constructor/destructor: */
551N/A UIMediumManager(QWidget *pCenterWidget, bool fRefresh = true);
551N/A ~UIMediumManager();
551N/A
970N/Apublic:
970N/A
970N/A /* Static API: Singleton stuff: */
551N/A static UIMediumManager* instance();
static void showModeless(QWidget *pCenterWidget, bool fRefresh = true);
public slots:
/* Handler: Refresh stuff: */
void refreshAll();
private slots:
/* Handlers: Medium-processing stuff: */
void sltHandleMediumCreated(const QString &strMediumID);
void sltHandleMediumDeleted(const QString &strMediumID);
/* Handlers: Medium-enumeration stuff: */
void sltHandleMediumEnumerationStart();
void sltHandleMediumEnumerated(const QString &strMediumID);
void sltHandleMediumEnumerationFinish();
/* Handlers: Medium-modification stuff: */
void sltCopyMedium();
void sltModifyMedium();
void sltRemoveMedium();
void sltReleaseMedium();
/* Handlers: Navigation stuff: */
void sltHandleCurrentTabChanged();
void sltHandleCurrentItemChanged(QTreeWidgetItem *pItem, QTreeWidgetItem *pPrevItem = 0);
void sltHandleDoubleClick();
void sltHandleContextMenuCall(const QPoint &position);
/* Handlers: Geometry stuff: */
void sltMakeRequestForTableAdjustment();
void sltPerformTablesAdjustment();
private:
/* Helpers: Prepare stuff: */
void prepare();
void prepareThis();
void prepareActions();
void prepareMenuBar();
void prepareToolBar();
void prepareContextMenu();
void prepareTabWidget();
void prepareTreeWidgets();
void prepareTreeWidgetHD();
void prepareTreeWidgetCD();
void prepareTreeWidgetFD();
void prepareInformationPanes();
void prepareButtonBox();
void prepareProgressBar();
#ifdef Q_WS_MAC
void prepareMacWindowMenu();
#endif /* Q_WS_MAC */
/* Helper: Populate stuff: */
void populateTreeWidgets();
/* 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);
/* Internal API: Tree-widget access stuff: */
QTreeWidget* treeWidget(UIMediumType type) const;
UIMediumType currentTreeWidgetType() const;
QTreeWidget* currentTreeWidget() const;
void setCurrentItem(QTreeWidget *pTree, QTreeWidgetItem *pItem);
UIMediumItem* toMediumItem(QTreeWidgetItem *pItem) const;
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);
/* 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__ */