VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceExportEditorWidget.cpp@ 100347

Last change on this file since 100347 was 98103, checked in by vboxsync, 22 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/* $Id: UIApplianceExportEditorWidget.cpp 98103 2023-01-17 14:15:46Z 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. */
38class ExportSortProxyModel : public UIApplianceSortProxyModel
39{
40public:
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_CloudProfileName;
61 }
62};
63
64
65/*********************************************************************************************************************************
66* Class UIApplianceExportEditorWidget implementation. *
67*********************************************************************************************************************************/
68
69UIApplianceExportEditorWidget::UIApplianceExportEditorWidget(QWidget *pParent /* = 0 */)
70 : UIApplianceEditorWidget(pParent)
71{
72}
73
74void UIApplianceExportEditorWidget::setAppliance(const CAppliance &comAppliance)
75{
76 /* Cleanup previous stuff: */
77 clear();
78
79 /* Call to base-class: */
80 UIApplianceEditorWidget::setAppliance(comAppliance);
81
82 /* Prepare model: */
83 QVector<CVirtualSystemDescription> vsds = m_comAppliance.GetVirtualSystemDescriptions();
84 m_pModel = new UIApplianceModel(vsds, m_pTreeViewSettings);
85 if (m_pModel)
86 {
87 m_pModel->setVsdHints(m_listVsdHints);
88
89 /* Create proxy model: */
90 ExportSortProxyModel *pProxy = new ExportSortProxyModel(m_pModel);
91 if (pProxy)
92 {
93 pProxy->setSourceModel(m_pModel);
94 pProxy->sort(ApplianceViewSection_Description, Qt::DescendingOrder);
95
96 /* Set our own model: */
97 m_pTreeViewSettings->setModel(pProxy);
98 /* Set our own delegate: */
99 UIApplianceDelegate *pDelegate = new UIApplianceDelegate(pProxy);
100 if (pDelegate)
101 m_pTreeViewSettings->setItemDelegate(pDelegate);
102
103 /* For now we hide the original column. This data is displayed as tooltip also. */
104 m_pTreeViewSettings->setColumnHidden(ApplianceViewSection_OriginalValue, true);
105 m_pTreeViewSettings->expandAll();
106 /* Set model root index and make it current: */
107 m_pTreeViewSettings->setRootIndex(pProxy->mapFromSource(m_pModel->root()));
108 m_pTreeViewSettings->setCurrentIndex(pProxy->mapFromSource(m_pModel->root()));
109 }
110 }
111
112 /* Check for warnings & if there are one display them: */
113 const QVector<QString> warnings = m_comAppliance.GetWarnings();
114 const bool fWarningsEnabled = warnings.size() > 0;
115 foreach (const QString &strText, warnings)
116 m_pTextEditWarning->append("- " + strText);
117 m_pPaneWarning->setVisible(fWarningsEnabled);
118}
119
120void UIApplianceExportEditorWidget::prepareExport()
121{
122 if (m_comAppliance.isNotNull())
123 m_pModel->putBack();
124}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette