UIMediumManager.h revision cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8a
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync/** @file
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync *
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync * VBox frontends: Qt4 GUI ("VirtualBox"):
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync * UIMediumManager class declaration
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync/*
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync * Copyright (C) 2006-2013 Oracle Corporation
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync *
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync * 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
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync/* GUI includes: */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync#include "UIMediumManager.gen.h"
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync#include "QIWithRetranslateUI.h"
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync#include "QIMainDialog.h"
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync#include "UIMedium.h"
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync/* COM includes: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync#include "COMEnums.h"
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync#include "CMachine.h"
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync#include "CVirtualBox.h"
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync/* Forward declarations: */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsyncclass UIToolBar;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsyncclass UIMediumItem;
65ba0abe3ecfd47b318d49a3c37a9b48d1f6904evboxsyncclass UIEnumerationProgressBar;
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync/* Medium Manager Dialog: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsyncclass UIMediumManager : public QIWithRetranslateUI2<QIMainDialog>, public Ui::UIMediumManager
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync{
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync Q_OBJECT;
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Enumerators: */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync enum TabIndex { HDTab = 0, CDTab, FDTab };
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync enum ItemAction { ItemAction_Added, ItemAction_Updated, ItemAction_Removed };
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync enum Action { Action_Edit, Action_Copy, Action_Modify, Action_Remove, Action_Release };
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Constructor/destructor: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync UIMediumManager(QWidget *pCenterWidget, bool fRefresh = true);
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync ~UIMediumManager();
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsyncpublic:
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Static API: Singleton stuff: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync static UIMediumManager* instance();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync static void showModeless(QWidget *pCenterWidget, bool fRefresh = true);
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsyncpublic slots:
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Handler: Refresh stuff: */
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync void refreshAll();
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsyncprivate slots:
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Handlers: Medium-processing stuff: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltHandleMediumAdded(const UIMedium &medium);
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltHandleMediumUpdated(const UIMedium &medium);
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltHandleMediumRemoved(UIMediumType type, const QString &strId);
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Handlers: Medium-enumeration stuff: */
0623012e80c8f7252d781d1f51cb6836afd4d3eevboxsync void sltHandleMediumEnumerationStart();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltHandleMediumEnumerated(const UIMedium &medium);
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltHandleMediumEnumerationFinish();
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Handlers: Medium-modification stuff: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltCopyMedium();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltModifyMedium();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltRemoveMedium();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltReleaseMedium();
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Handlers: Navigation stuff: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltHandleCurrentTabChanged();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltHandleCurrentItemChanged(QTreeWidgetItem *pItem, QTreeWidgetItem *pPrevItem = 0);
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltHandleDoubleClick();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltHandleContextMenuCall(const QPoint &position);
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Handler: Machine stuff: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltHandleMachineStateChanged(QString strId, KMachineState state);
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Handlers: Geometry stuff: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltMakeRequestForTableAdjustment();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void sltPerformTablesAdjustment();
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsyncprivate:
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Helpers: Prepare stuff: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepare();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareThis();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareActions();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareMenuBar();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareToolBar();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareContextMenu();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void preapreTabWidget();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareTreeWidgets();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareTreeWidgetHD();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareTreeWidgetCD();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareTreeWidgetFD();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareInformationPanes();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareButtonBox();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareProgressBar();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync#ifdef Q_WS_MAC
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void prepareMacWindowMenu();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync#endif /* Q_WS_MAC */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Helper: Populate stuff: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void populateTreeWidgets();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Helpers: Cleanup stuff: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync#ifdef Q_WS_MAC
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void cleanupMacWindowMenu();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync#endif /* Q_WS_MAC */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void cleanup();
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Handler: Translation stuff: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void retranslateUi();
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync /* Helpers: Medium-modification stuff: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync bool releaseMediumFrom(const UIMedium &medium, const QString &strMachineId);
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync bool releaseHardDiskFrom(const UIMedium &medium, CMachine &machine);
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync bool releaseOpticalDiskFrom(const UIMedium &medium, CMachine &machine);
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync bool releaseFloppyDiskFrom(const UIMedium &medium, CMachine &machine);
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Internal API: Tree-widget access stuff: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync QTreeWidget* treeWidget(UIMediumType type) const;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync UIMediumType currentTreeWidgetType() const;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync QTreeWidget* currentTreeWidget() const;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync void setCurrentItem(QTreeWidget *pTree, QTreeWidgetItem *pItem);
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync UIMediumItem* toMediumItem(QTreeWidgetItem *pItem) const;
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync UIMediumItem* searchItem(QTreeWidget *pTree, const QString &strId) const;
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync UIMediumItem* createHardDiskItem(QTreeWidget *pTree, const UIMedium &medium) const;
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync /* Internal API: Tab-widget access stuff: */
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync void updateTabIcons(UIMediumItem *pItem, ItemAction action);
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync /* Helpers: Other stuff: */
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync bool checkMediumFor(UIMediumItem *pItem, Action action);
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync void clearInfoPanes();
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync void prepareToRefresh(int iTotal = 0);
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync /* Static helper: Formatting stuff: */
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync static QString formatPaneText(const QString &strText, bool fCompact = true, const QString &strElipsis = "middle");
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
cfeb51c88f60cb31c8862f0fa325d7d1c4d22f8avboxsync /* Static helper: Enumeration stuff: */
cf575292da27c79a7de59f7ced500686a0838b38vboxsync static bool isMediumAttachedToHiddenMachinesOnly(const UIMedium &medium);
cf575292da27c79a7de59f7ced500686a0838b38vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Variable: Singleton instance: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync static UIMediumManager *m_spInstance;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Variables: General stuff: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync CVirtualBox m_vbox;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync QWidget *m_pCenterWidget;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync bool m_fRefresh;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Variables: Tab-widget stuff: */
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync bool m_fInaccessibleHD;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync bool m_fInaccessibleCD;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync bool m_fInaccessibleFD;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync const QIcon m_iconHD;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync const QIcon m_iconCD;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync const QIcon m_iconFD;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync QString m_strSelectedIdHD;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync QString m_strSelectedIdCD;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync QString m_strSelectedIdFD;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Variables: Menu & Toolbar stuff: */
65ba0abe3ecfd47b318d49a3c37a9b48d1f6904evboxsync UIToolBar *m_pToolBar;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync QMenu *m_pContextMenu;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync QMenu *m_pMenu;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync QAction *m_pActionCopy;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync QAction *m_pActionModify;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync QAction *m_pActionRemove;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync QAction *m_pActionRelease;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync QAction *m_pActionRefresh;
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync
26ab5559e05ae622734a4047cee975670da3b0e8vboxsync /* Variable: Progress-bar stuff: */
65ba0abe3ecfd47b318d49a3c37a9b48d1f6904evboxsync UIEnumerationProgressBar *m_pProgressBar;
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync};
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync
8230e6f6671b538d39c7ef6d8484cf516a983ef4vboxsync#endif /* __UIMediumManager_h__ */