[26715] | 1 | /* $Id: UIApplianceExportEditorWidget.cpp 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
[25178] | 2 | /** @file
|
---|
[52727] | 3 | * VBox Qt GUI - UIApplianceExportEditorWidget class implementation.
|
---|
[25178] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[106061] | 7 | * Copyright (C) 2009-2024 Oracle and/or its affiliates.
|
---|
[25178] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[25178] | 26 | */
|
---|
| 27 |
|
---|
[64683] | 28 | /* Qt includes: */
|
---|
[76606] | 29 | #include <QTextEdit>
|
---|
[64683] | 30 |
|
---|
[41587] | 31 | /* GUI includes: */
|
---|
[76606] | 32 | #include "QITreeView.h"
|
---|
| 33 | #include "UIApplianceExportEditorWidget.h"
|
---|
| 34 | #include "UIMessageCenter.h"
|
---|
[25178] | 35 |
|
---|
[41587] | 36 |
|
---|
[91541] | 37 | /** UIApplianceSortProxyModel subclass for Export Appliance wizard. */
|
---|
| 38 | class ExportSortProxyModel : public UIApplianceSortProxyModel
|
---|
[25178] | 39 | {
|
---|
| 40 | public:
|
---|
[91538] | 41 |
|
---|
[91541] | 42 | /** Constructs proxy model passing @a pParent to the base-class. */
|
---|
[91538] | 43 | ExportSortProxyModel(QObject *pParent = 0)
|
---|
| 44 | : UIApplianceSortProxyModel(pParent)
|
---|
[25178] | 45 | {
|
---|
[64691] | 46 | m_aFilteredList
|
---|
[25178] | 47 | << KVirtualSystemDescriptionType_OS
|
---|
| 48 | << KVirtualSystemDescriptionType_CPU
|
---|
| 49 | << KVirtualSystemDescriptionType_Memory
|
---|
| 50 | << KVirtualSystemDescriptionType_Floppy
|
---|
| 51 | << KVirtualSystemDescriptionType_CDROM
|
---|
| 52 | << KVirtualSystemDescriptionType_USBController
|
---|
| 53 | << KVirtualSystemDescriptionType_SoundCard
|
---|
| 54 | << KVirtualSystemDescriptionType_NetworkAdapter
|
---|
| 55 | << KVirtualSystemDescriptionType_HardDiskControllerIDE
|
---|
| 56 | << KVirtualSystemDescriptionType_HardDiskControllerSATA
|
---|
[29986] | 57 | << KVirtualSystemDescriptionType_HardDiskControllerSCSI
|
---|
[96131] | 58 | << KVirtualSystemDescriptionType_HardDiskControllerVirtioSCSI
|
---|
[75971] | 59 | << KVirtualSystemDescriptionType_HardDiskControllerSAS
|
---|
[101472] | 60 | << KVirtualSystemDescriptionType_HardDiskControllerNVMe
|
---|
[76192] | 61 | << KVirtualSystemDescriptionType_CloudProfileName;
|
---|
[25178] | 62 | }
|
---|
| 63 | };
|
---|
| 64 |
|
---|
| 65 |
|
---|
[91538] | 66 | /*********************************************************************************************************************************
|
---|
| 67 | * Class UIApplianceExportEditorWidget implementation. *
|
---|
| 68 | *********************************************************************************************************************************/
|
---|
| 69 |
|
---|
| 70 | UIApplianceExportEditorWidget::UIApplianceExportEditorWidget(QWidget *pParent /* = 0 */)
|
---|
| 71 | : UIApplianceEditorWidget(pParent)
|
---|
[25178] | 72 | {
|
---|
| 73 | }
|
---|
| 74 |
|
---|
[91539] | 75 | void UIApplianceExportEditorWidget::setAppliance(const CAppliance &comAppliance)
|
---|
[25178] | 76 | {
|
---|
[91638] | 77 | /* Cleanup previous stuff: */
|
---|
| 78 | clear();
|
---|
| 79 |
|
---|
[91579] | 80 | /* Call to base-class: */
|
---|
| 81 | UIApplianceEditorWidget::setAppliance(comAppliance);
|
---|
[25178] | 82 |
|
---|
[91538] | 83 | /* Prepare model: */
|
---|
[91539] | 84 | QVector<CVirtualSystemDescription> vsds = m_comAppliance.GetVirtualSystemDescriptions();
|
---|
[64747] | 85 | m_pModel = new UIApplianceModel(vsds, m_pTreeViewSettings);
|
---|
[91538] | 86 | if (m_pModel)
|
---|
| 87 | {
|
---|
| 88 | m_pModel->setVsdHints(m_listVsdHints);
|
---|
[25178] | 89 |
|
---|
[91538] | 90 | /* Create proxy model: */
|
---|
| 91 | ExportSortProxyModel *pProxy = new ExportSortProxyModel(m_pModel);
|
---|
| 92 | if (pProxy)
|
---|
| 93 | {
|
---|
| 94 | pProxy->setSourceModel(m_pModel);
|
---|
| 95 | pProxy->sort(ApplianceViewSection_Description, Qt::DescendingOrder);
|
---|
[25178] | 96 |
|
---|
[91538] | 97 | /* Set our own model: */
|
---|
| 98 | m_pTreeViewSettings->setModel(pProxy);
|
---|
| 99 | /* Set our own delegate: */
|
---|
| 100 | UIApplianceDelegate *pDelegate = new UIApplianceDelegate(pProxy);
|
---|
| 101 | if (pDelegate)
|
---|
| 102 | m_pTreeViewSettings->setItemDelegate(pDelegate);
|
---|
[25178] | 103 |
|
---|
[91538] | 104 | /* For now we hide the original column. This data is displayed as tooltip also. */
|
---|
| 105 | m_pTreeViewSettings->setColumnHidden(ApplianceViewSection_OriginalValue, true);
|
---|
| 106 | m_pTreeViewSettings->expandAll();
|
---|
| 107 | /* Set model root index and make it current: */
|
---|
| 108 | m_pTreeViewSettings->setRootIndex(pProxy->mapFromSource(m_pModel->root()));
|
---|
| 109 | m_pTreeViewSettings->setCurrentIndex(pProxy->mapFromSource(m_pModel->root()));
|
---|
| 110 | }
|
---|
| 111 | }
|
---|
[25178] | 112 |
|
---|
[91538] | 113 | /* Check for warnings & if there are one display them: */
|
---|
[91539] | 114 | const QVector<QString> warnings = m_comAppliance.GetWarnings();
|
---|
[91538] | 115 | const bool fWarningsEnabled = warnings.size() > 0;
|
---|
| 116 | foreach (const QString &strText, warnings)
|
---|
| 117 | m_pTextEditWarning->append("- " + strText);
|
---|
[64683] | 118 | m_pPaneWarning->setVisible(fWarningsEnabled);
|
---|
[25178] | 119 | }
|
---|
| 120 |
|
---|
[38410] | 121 | void UIApplianceExportEditorWidget::prepareExport()
|
---|
[25178] | 122 | {
|
---|
[91539] | 123 | if (m_comAppliance.isNotNull())
|
---|
[38384] | 124 | m_pModel->putBack();
|
---|
[25178] | 125 | }
|
---|