[13580] | 1 | /** @file
|
---|
| 2 | *
|
---|
| 3 | * VBox frontends: Qt4 GUI ("VirtualBox"):
|
---|
| 4 | * VBoxMediaManagerDlg class declaration
|
---|
| 5 | */
|
---|
| 6 |
|
---|
| 7 | /*
|
---|
[28800] | 8 | * Copyright (C) 2006-2009 Oracle Corporation
|
---|
[13580] | 9 | *
|
---|
| 10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
| 11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
| 12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
| 13 | * General Public License (GPL) as published by the Free Software
|
---|
| 14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
| 15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
| 16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
| 17 | */
|
---|
| 18 |
|
---|
| 19 | #ifndef __VBoxMediaManagerDlg_h__
|
---|
| 20 | #define __VBoxMediaManagerDlg_h__
|
---|
| 21 |
|
---|
[23953] | 22 | /* Local includes */
|
---|
[13580] | 23 | #include "VBoxMediaManagerDlg.gen.h"
|
---|
[23953] | 24 | #include "COMDefs.h"
|
---|
[13580] | 25 | #include "QIMainDialog.h"
|
---|
| 26 | #include "QIWithRetranslateUI.h"
|
---|
| 27 | #include "VBoxDefs.h"
|
---|
| 28 | #include "VBoxMediaComboBox.h"
|
---|
| 29 |
|
---|
[23953] | 30 | /* Local forwards */
|
---|
[13580] | 31 | class MediaItem;
|
---|
[23953] | 32 | class VBoxProgressBar;
|
---|
[32760] | 33 | class UIToolBar;
|
---|
[13580] | 34 |
|
---|
| 35 | class VBoxMediaManagerDlg : public QIWithRetranslateUI2<QIMainDialog>,
|
---|
| 36 | public Ui::VBoxMediaManagerDlg
|
---|
| 37 | {
|
---|
| 38 | Q_OBJECT;
|
---|
| 39 |
|
---|
| 40 | enum TabIndex { HDTab = 0, CDTab, FDTab };
|
---|
| 41 | enum ItemAction { ItemAction_Added, ItemAction_Updated, ItemAction_Removed };
|
---|
| 42 | enum Action { Action_Select, Action_Edit, Action_Remove, Action_Release };
|
---|
| 43 |
|
---|
| 44 | public:
|
---|
| 45 |
|
---|
| 46 | VBoxMediaManagerDlg (QWidget *aParent = NULL,
|
---|
| 47 | Qt::WindowFlags aFlags = Qt::Dialog);
|
---|
[22999] | 48 | ~VBoxMediaManagerDlg();
|
---|
[13580] | 49 |
|
---|
[23223] | 50 | void setup (VBoxDefs::MediumType aType, bool aDoSelect,
|
---|
[13580] | 51 | bool aRefresh = true,
|
---|
| 52 | const CMachine &aSessionMachine = CMachine(),
|
---|
[19239] | 53 | const QString &aSelectId = QString::null,
|
---|
[24147] | 54 | bool aShowDiffs = true,
|
---|
| 55 | const QStringList &aUsedMediaIds = QStringList());
|
---|
[13580] | 56 |
|
---|
| 57 | static void showModeless (QWidget *aParent = NULL, bool aRefresh = true);
|
---|
| 58 |
|
---|
[19239] | 59 | QString selectedId() const;
|
---|
[13580] | 60 | QString selectedLocation() const;
|
---|
| 61 |
|
---|
| 62 | bool showDiffs() const { return mShowDiffs; };
|
---|
| 63 | bool inAttachMode() const { return !mSessionMachine.isNull(); };
|
---|
| 64 |
|
---|
| 65 | public slots:
|
---|
| 66 |
|
---|
| 67 | void refreshAll();
|
---|
| 68 |
|
---|
| 69 | protected:
|
---|
| 70 |
|
---|
| 71 | void retranslateUi();
|
---|
| 72 | virtual void closeEvent (QCloseEvent *aEvent);
|
---|
| 73 | virtual bool eventFilter (QObject *aObject, QEvent *aEvent);
|
---|
| 74 |
|
---|
| 75 | private slots:
|
---|
| 76 |
|
---|
| 77 | void mediumAdded (const VBoxMedium &aMedium);
|
---|
| 78 | void mediumUpdated (const VBoxMedium &aMedium);
|
---|
[23223] | 79 | void mediumRemoved (VBoxDefs::MediumType aType, const QString &aId);
|
---|
[13580] | 80 |
|
---|
| 81 | void mediumEnumStarted();
|
---|
| 82 | void mediumEnumerated (const VBoxMedium &aMedium);
|
---|
| 83 | void mediumEnumFinished (const VBoxMediaList &aList);
|
---|
| 84 |
|
---|
| 85 | void doNewMedium();
|
---|
| 86 | void doAddMedium();
|
---|
| 87 | void doRemoveMedium();
|
---|
| 88 | void doReleaseMedium();
|
---|
| 89 |
|
---|
[19239] | 90 | bool releaseMediumFrom (const VBoxMedium &aMedium, const QString &aMachineId);
|
---|
[13580] | 91 |
|
---|
| 92 | void processCurrentChanged (int index = -1);
|
---|
| 93 | void processCurrentChanged (QTreeWidgetItem *aItem, QTreeWidgetItem *aPrevItem = 0);
|
---|
| 94 | void processDoubleClick (QTreeWidgetItem *aItem, int aColumn);
|
---|
| 95 | void showContextMenu (const QPoint &aPos);
|
---|
| 96 |
|
---|
[30677] | 97 | void machineStateChanged(QString strId, KMachineState state);
|
---|
[13580] | 98 |
|
---|
| 99 | void makeRequestForAdjustTable();
|
---|
| 100 | void performTablesAdjustment();
|
---|
| 101 |
|
---|
| 102 | private:
|
---|
| 103 |
|
---|
[23223] | 104 | QTreeWidget* treeWidget (VBoxDefs::MediumType aType) const;
|
---|
| 105 | VBoxDefs::MediumType currentTreeWidgetType() const;
|
---|
[13580] | 106 | QTreeWidget* currentTreeWidget() const;
|
---|
| 107 |
|
---|
| 108 | QTreeWidgetItem* selectedItem (const QTreeWidget *aTree) const;
|
---|
| 109 | MediaItem* toMediaItem (QTreeWidgetItem *aItem) const;
|
---|
| 110 |
|
---|
| 111 | void setCurrentItem (QTreeWidget *aTree, QTreeWidgetItem *aItem);
|
---|
| 112 |
|
---|
[23223] | 113 | void addMediumToList (const QString &aLocation, VBoxDefs::MediumType aType);
|
---|
[13580] | 114 |
|
---|
| 115 | MediaItem* createHardDiskItem (QTreeWidget *aTree, const VBoxMedium &aMedium) const;
|
---|
| 116 |
|
---|
| 117 | void updateTabIcons (MediaItem *aItem, ItemAction aAction);
|
---|
| 118 |
|
---|
[19239] | 119 | MediaItem* searchItem (QTreeWidget *aTree, const QString &aId) const;
|
---|
[13580] | 120 |
|
---|
| 121 | bool checkMediumFor (MediaItem *aItem, Action aAction);
|
---|
| 122 |
|
---|
| 123 | bool checkDndUrls (const QList<QUrl> &aUrls) const;
|
---|
| 124 | void addDndUrls (const QList<QUrl> &aUrls);
|
---|
| 125 |
|
---|
| 126 | void clearInfoPanes();
|
---|
| 127 | void prepareToRefresh (int aTotal = 0);
|
---|
| 128 |
|
---|
| 129 | QString formatPaneText (const QString &aText, bool aCompact = true, const QString &aElipsis = "middle");
|
---|
| 130 |
|
---|
| 131 | /* Private member vars */
|
---|
| 132 | /* Window status */
|
---|
| 133 | bool mDoSelect;
|
---|
| 134 | static VBoxMediaManagerDlg *mModelessDialog;
|
---|
| 135 | VBoxProgressBar *mProgressBar;
|
---|
| 136 |
|
---|
| 137 | /* The global VirtualBox instance */
|
---|
| 138 | CVirtualBox mVBox;
|
---|
| 139 |
|
---|
| 140 | /* Type if we are in the select modus */
|
---|
| 141 | int mType;
|
---|
| 142 |
|
---|
| 143 | bool mShowDiffs : 1;
|
---|
| 144 | bool mSetupMode : 1;
|
---|
| 145 |
|
---|
| 146 | /* Icon definitions */
|
---|
| 147 | QIcon mHardDiskIcon;
|
---|
| 148 | QIcon mDVDImageIcon;
|
---|
| 149 | QIcon mFloppyImageIcon;
|
---|
| 150 |
|
---|
| 151 | /* Menu & Toolbar */
|
---|
| 152 | QMenu *mActionsContextMenu;
|
---|
| 153 | QMenu *mActionsMenu;
|
---|
[32760] | 154 | UIToolBar *mToolBar;
|
---|
[13580] | 155 | QAction *mNewAction;
|
---|
| 156 | QAction *mAddAction;
|
---|
| 157 | QAction *mRemoveAction;
|
---|
| 158 | QAction *mReleaseAction;
|
---|
| 159 | QAction *mRefreshAction;
|
---|
| 160 |
|
---|
| 161 | /* Machine */
|
---|
| 162 | CMachine mSessionMachine;
|
---|
[19239] | 163 | QString mSessionMachineId;
|
---|
[13580] | 164 | bool mHardDisksInaccessible;
|
---|
| 165 | bool mDVDImagesInaccessible;
|
---|
| 166 | bool mFloppyImagesInaccessible;
|
---|
[19239] | 167 | QString mHDSelectedId;
|
---|
[23953] | 168 | QString mCDSelectedId;
|
---|
| 169 | QString mFDSelectedId;
|
---|
[24147] | 170 | QStringList mUsedMediaIds;
|
---|
[13580] | 171 | };
|
---|
| 172 |
|
---|
| 173 | #endif /* __VBoxMediaManagerDlg_h__ */
|
---|
| 174 |
|
---|