1 | /* $Id: UIApplianceExportEditorWidget.cpp 101472 2023-10-17 11:45:00Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIApplianceExportEditorWidget class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
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
|
---|
26 | */
|
---|
27 |
|
---|
28 | /* Qt includes: */
|
---|
29 | #include <QTextEdit>
|
---|
30 |
|
---|
31 | /* GUI includes: */
|
---|
32 | #include "QITreeView.h"
|
---|
33 | #include "UIApplianceExportEditorWidget.h"
|
---|
34 | #include "UIMessageCenter.h"
|
---|
35 |
|
---|
36 |
|
---|
37 | /** UIApplianceSortProxyModel subclass for Export Appliance wizard. */
|
---|
38 | class ExportSortProxyModel : public UIApplianceSortProxyModel
|
---|
39 | {
|
---|
40 | public:
|
---|
41 |
|
---|
42 | /** Constructs proxy model passing @a pParent to the base-class. */
|
---|
43 | ExportSortProxyModel(QObject *pParent = 0)
|
---|
44 | : UIApplianceSortProxyModel(pParent)
|
---|
45 | {
|
---|
46 | m_aFilteredList
|
---|
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
|
---|
57 | << KVirtualSystemDescriptionType_HardDiskControllerSCSI
|
---|
58 | << KVirtualSystemDescriptionType_HardDiskControllerVirtioSCSI
|
---|
59 | << KVirtualSystemDescriptionType_HardDiskControllerSAS
|
---|
60 | << KVirtualSystemDescriptionType_HardDiskControllerNVMe
|
---|
61 | << KVirtualSystemDescriptionType_CloudProfileName;
|
---|
62 | }
|
---|
63 | };
|
---|
64 |
|
---|
65 |
|
---|
66 | /*********************************************************************************************************************************
|
---|
67 | * Class UIApplianceExportEditorWidget implementation. *
|
---|
68 | *********************************************************************************************************************************/
|
---|
69 |
|
---|
70 | UIApplianceExportEditorWidget::UIApplianceExportEditorWidget(QWidget *pParent /* = 0 */)
|
---|
71 | : UIApplianceEditorWidget(pParent)
|
---|
72 | {
|
---|
73 | }
|
---|
74 |
|
---|
75 | void UIApplianceExportEditorWidget::setAppliance(const CAppliance &comAppliance)
|
---|
76 | {
|
---|
77 | /* Cleanup previous stuff: */
|
---|
78 | clear();
|
---|
79 |
|
---|
80 | /* Call to base-class: */
|
---|
81 | UIApplianceEditorWidget::setAppliance(comAppliance);
|
---|
82 |
|
---|
83 | /* Prepare model: */
|
---|
84 | QVector<CVirtualSystemDescription> vsds = m_comAppliance.GetVirtualSystemDescriptions();
|
---|
85 | m_pModel = new UIApplianceModel(vsds, m_pTreeViewSettings);
|
---|
86 | if (m_pModel)
|
---|
87 | {
|
---|
88 | m_pModel->setVsdHints(m_listVsdHints);
|
---|
89 |
|
---|
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);
|
---|
96 |
|
---|
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);
|
---|
103 |
|
---|
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 | }
|
---|
112 |
|
---|
113 | /* Check for warnings & if there are one display them: */
|
---|
114 | const QVector<QString> warnings = m_comAppliance.GetWarnings();
|
---|
115 | const bool fWarningsEnabled = warnings.size() > 0;
|
---|
116 | foreach (const QString &strText, warnings)
|
---|
117 | m_pTextEditWarning->append("- " + strText);
|
---|
118 | m_pPaneWarning->setVisible(fWarningsEnabled);
|
---|
119 | }
|
---|
120 |
|
---|
121 | void UIApplianceExportEditorWidget::prepareExport()
|
---|
122 | {
|
---|
123 | if (m_comAppliance.isNotNull())
|
---|
124 | m_pModel->putBack();
|
---|
125 | }
|
---|