UIMediumManager.h revision daa8487f5bc0d5c44dc3be2cbe3d34cc211a845f
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync/** @file
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync * VBox Qt GUI - UIMediumManager class declaration.
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync/*
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync * Copyright (C) 2006-2014 Oracle Corporation
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync *
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync * available from http://www.virtualbox.org. This file is free software;
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync * you can redistribute it and/or modify it under the terms of the GNU
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync * General Public License (GPL) as published by the Free Software
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync#ifndef ___UIMediumManager_h___
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync#define ___UIMediumManager_h___
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync/* GUI includes: */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync#include "UIMediumManager.gen.h"
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync#include "QIWithRetranslateUI.h"
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync#include "QIMainDialog.h"
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync#include "UIMediumDefs.h"
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync/* Forward declarations: */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsyncclass UIMedium;
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsyncclass UIMediumItem;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsyncclass UIToolBar;
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsyncclass UIEnumerationProgressBar;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync/** Functor interface allowing to check if passed UIMediumItem is suitable. */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsyncclass CheckIfSuitableBy
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync{
26ab5559e05ae622734a4047cee975670da3b0e8vboxsyncpublic:
65ba0abe3ecfd47b318d49a3c37a9b48d1f6904evboxsync /** Determines whether passed @a pItem is suitable. */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync virtual bool isItSuitable(UIMediumItem *pItem) const = 0;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync};
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync/** Medium Manager dialog. */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsyncclass UIMediumManager : public QIWithRetranslateUI2<QIMainDialog>, public Ui::UIMediumManager
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync{
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync Q_OBJECT;
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync /** Tab index enumerator. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync enum TabIndex { TabIndex_HD = 0, TabIndex_CD, TabIndex_FD };
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Item action enumerator. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync enum Action { Action_Add, Action_Edit, Action_Copy, Action_Modify, Action_Remove, Action_Release };
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync /** Constructor for UIMediumManager dialog. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync UIMediumManager(QWidget *pCenterWidget, bool fRefresh = true);
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync /** Destructor for UIMediumManager dialog. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync ~UIMediumManager();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsyncpublic:
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync /** Returns UIMediumManager singleton instance. */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync static UIMediumManager* instance();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Shows UIMediumManager singleton instance, creates new if necessary. */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync static void showModeless(QWidget *pCenterWidget, bool fRefresh = true);
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsyncprivate slots:
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Handles VBoxGlobal::sigMediumCreated signal. */
b4e89d495c2988c10068923397d31fd27112b9ebvboxsync void sltHandleMediumCreated(const QString &strMediumID);
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Handles VBoxGlobal::sigMediumDeleted signal. */
b4e89d495c2988c10068923397d31fd27112b9ebvboxsync void sltHandleMediumDeleted(const QString &strMediumID);
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Handles VBoxGlobal::sigMediumEnumerationStarted signal. */
0623012e80c8f7252d781d1f51cb6836afd4d3eevboxsync void sltHandleMediumEnumerationStart();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Handles VBoxGlobal::sigMediumEnumerated signal. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltHandleMediumEnumerated(const QString &strMediumID);
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync /** Handles VBoxGlobal::sigMediumEnumerationFinished signal. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltHandleMediumEnumerationFinish();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Handles UIMediumManager::m_pActionCopy action triggering. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltCopyMedium();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Handles UIMediumManager::m_pActionModify action triggering. */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync void sltModifyMedium();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Handles UIMediumManager::m_pActionRemove action triggering. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltRemoveMedium();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Handles UIMediumManager::m_pActionRelease action triggering. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltReleaseMedium();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Handles UIMediumManager::m_pActionRefresh action triggering. */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync void sltRefreshAll();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Handles tab change case. */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync void sltHandleCurrentTabChanged();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Handles item change case. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltHandleCurrentItemChanged();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Handles item double-click case. */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync void sltHandleDoubleClick();
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync /** Handles item context-menu-call case. */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync void sltHandleContextMenuCall(const QPoint &position);
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Adjusts tree-widgets according content. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltPerformTablesAdjustment();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsyncprivate:
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** General prepare wrapper. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepare();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Prepare dialog. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareThis();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Prepare actions. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareActions();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Prepare menu-bar. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareMenuBar();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Prepare tool-bar. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareToolBar();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Prepare context-menu. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareContextMenu();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Prepare tab-widget. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareTabWidget();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Prepare tree-widgets. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareTreeWidgets();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Prepare hard-drive tree-widget. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareTreeWidgetHD();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Prepare optical-disk tree-widget. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareTreeWidgetCD();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Prepare floppy-disk tree-widget. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareTreeWidgetFD();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Prepare information-panes. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareInformationPanes();
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync /** Prepare button-box. */
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync void prepareButtonBox();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Prepare progress-bar. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareProgressBar();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync#ifdef Q_WS_MAC
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Mac OS X: Prepare <i>Window</i> menu. */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync void prepareMacWindowMenu();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync#endif /* Q_WS_MAC */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Repopulates tree-widgets content. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void repopulateTreeWidgets();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync /** Updates details according latest changes in current item of passed @a type. */
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync void refetchCurrentMediumItem(UIMediumType type);
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync /** Updates details according latest changes in current item of chosen type. */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync void refetchCurrentChosenMediumItem();
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync /** Updates details according latest changes in all current items. */
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync void refetchCurrentMediumItems();
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync /** Update actions according currently chosen item. */
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync void updateActions();
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync /** Update action icons according currently chosen tab. */
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync void updateActionIcons();
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync /** Update tab icons according last @a action happened with @a pItem. */
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync void updateTabIcons(UIMediumItem *pItem, Action action);
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync /** Update information pane of passed medium @a type. */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync void updateInformationPanes(UIMediumType type = UIMediumType_Invalid);
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync /** Update information pane for hard-drive tab. */
cf575292da27c79a7de59f7ced500686a0838b38vboxsync void updateInformationPanesHD();
cf575292da27c79a7de59f7ced500686a0838b38vboxsync /** Update information pane for optical-disk tab. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void updateInformationPanesCD();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Update information pane for floppy-disk tab. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void updateInformationPanesFD();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync#ifdef Q_WS_MAC
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Mac OS X: Cleanup <i>Window</i> menu. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void cleanupMacWindowMenu();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync#endif /* Q_WS_MAC */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** General cleanup wrapper. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void cleanup();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Translates dialog content. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void retranslateUi();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Creates UIMediumItem for corresponding @a medium. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync UIMediumItem* createMediumItem(const UIMedium &medium);
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Creates UIMediumItemHD for corresponding @a medium. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync UIMediumItem* createHardDiskItem(const UIMedium &medium);
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Updates UIMediumItem for corresponding @a medium. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void updateMediumItem(const UIMedium &medium);
65ba0abe3ecfd47b318d49a3c37a9b48d1f6904evboxsync /** Deletes UIMediumItem for corresponding @a strMediumID. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void deleteMediumItem(const QString &strMediumID);
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Determines medium type for passed @a pTreeWidget. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync UIMediumType mediumType(QTreeWidget *pTreeWidget) const;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Returns current medium type. */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync UIMediumType currentMediumType() const;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /** Returns tree-widget for passed medium @a type. */
65ba0abe3ecfd47b318d49a3c37a9b48d1f6904evboxsync QTreeWidget* treeWidget(UIMediumType type) const;
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync /** Returns current tree-widget. */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync QTreeWidget* currentTreeWidget() const;
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
/** Returns item for passed medium @a type. */
UIMediumItem* mediumItem(UIMediumType type) const;
/** Returns current item. */
UIMediumItem* currentMediumItem() const;
/** Defines current item for passed @a pTreeWidget as @a pItem. */
void setCurrentItem(QTreeWidget *pTreeWidget, QTreeWidgetItem *pItem);
/** Performs search for the @a pTree child which corresponds to the @a condition but not @a pException. */
static UIMediumItem* searchItem(QTreeWidget *pTree, const CheckIfSuitableBy &condition, CheckIfSuitableBy *pException = 0);
/** Performs search for the @a pParentItem child which corresponds to the @a condition but not @a pException. */
static UIMediumItem* searchItem(QTreeWidgetItem *pParentItem, const CheckIfSuitableBy &condition, CheckIfSuitableBy *pException = 0);
/** Checks if @a action can be used for @a pItem. */
static bool checkMediumFor(UIMediumItem *pItem, Action action);
/** Casts passed QTreeWidgetItem @a pItem to UIMediumItem if possible. */
static UIMediumItem* toMediumItem(QTreeWidgetItem *pItem);
/** Format information-pane content. */
static QString formatPaneText(const QString &strText, bool fCompact = true, const QString &strElipsis = "middle");
/** Determines if passed @a medium attached to hidden machines only. */
static bool isMediumAttachedToHiddenMachinesOnly(const UIMedium &medium);
/** UIMediumManager singleton instance. */
static UIMediumManager *m_spInstance;
/** @name General variables.
* @{ */
/** Widget to center UIMediumManager according. */
QWidget *m_pPseudoParentWidget;
/** Holds whether UIMediumManager should be refreshed on invoke. */
bool m_fRefresh;
/** Holds whether UIMediumManager should preserve current item change. */
bool m_fPreventChangeCurrentItem;
/** @} */
/** @name Tab-widget variables.
* @{ */
/** Holds whether hard-drive tab-widget have inaccessible item. */
bool m_fInaccessibleHD;
/** Holds whether optical-disk tab-widget have inaccessible item. */
bool m_fInaccessibleCD;
/** Holds whether floppy-disk tab-widget have inaccessible item. */
bool m_fInaccessibleFD;
/** Holds cached hard-drive tab-widget icon. */
const QIcon m_iconHD;
/** Holds cached optical-disk tab-widget icon. */
const QIcon m_iconCD;
/** Holds cached floppy-disk tab-widget icon. */
const QIcon m_iconFD;
/** Holds current hard-drive tree-view item ID. */
QString m_strCurrentIdHD;
/** Holds current optical-disk tree-view item ID. */
QString m_strCurrentIdCD;
/** Holds current floppy-disk tree-view item ID. */
QString m_strCurrentIdFD;
/** @} */
/** @name Tool-bar and menu variables.
* @{ */
/** Tool-bar widget. */
UIToolBar *m_pToolBar;
/** Context menu object. */
QMenu *m_pContextMenu;
/** Menu-bar menu object. */
QMenu *m_pMenu;
/** Action to <i>copy</i> current item. */
QAction *m_pActionCopy;
/** Action to <i>modify</i> current item. */
QAction *m_pActionModify;
/** Action to <i>remove</i> current item. */
QAction *m_pActionRemove;
/** Action to <i>release</i> current item. */
QAction *m_pActionRelease;
/** Action to <i>refresh</i> current item. */
QAction *m_pActionRefresh;
/** @} */
/** @name Progress-bar variables.
* @{ */
/** Progress-bar widget. */
UIEnumerationProgressBar *m_pProgressBar;
/** @} */
};
#endif /* !___UIMediumManager_h___ */