VirtualBox

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

Last change on this file since 76553 was 76553, checked in by vboxsync, 5 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1/* $Id: UIApplianceExportEditorWidget.cpp 76553 2019-01-01 01:45:53Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIApplianceExportEditorWidget class implementation.
4 */
5
6/*
7 * Copyright (C) 2009-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifdef VBOX_WITH_PRECOMPILED_HEADERS
19# include <precomp.h>
20#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
21
22/* Qt includes: */
23# include <QTextEdit>
24
25/* GUI includes: */
26# include "QITreeView.h"
27# include "UIApplianceExportEditorWidget.h"
28# include "VBoxGlobal.h"
29# include "UIMessageCenter.h"
30
31/* COM includes: */
32# include "CAppliance.h"
33
34#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
35
36
37////////////////////////////////////////////////////////////////////////////////
38// ExportSortProxyModel
39
40class ExportSortProxyModel: public UIApplianceSortProxyModel
41{
42public:
43 ExportSortProxyModel(QObject *pParent = NULL)
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_HardDiskControllerSAS
59 << KVirtualSystemDescriptionType_CloudProfileName;
60 }
61};
62
63////////////////////////////////////////////////////////////////////////////////
64// UIApplianceExportEditorWidget
65
66UIApplianceExportEditorWidget::UIApplianceExportEditorWidget(QWidget *pParent /* = NULL */)
67 : UIApplianceEditorWidget(pParent)
68{
69}
70
71CAppliance* UIApplianceExportEditorWidget::init()
72{
73 if (m_pAppliance)
74 delete m_pAppliance;
75 CVirtualBox vbox = vboxGlobal().virtualBox();
76 /* Create a appliance object */
77 m_pAppliance = new CAppliance(vbox.CreateAppliance());
78// bool fResult = m_pAppliance->isOk();
79 return m_pAppliance;
80}
81
82void UIApplianceExportEditorWidget::populate()
83{
84 if (m_pModel)
85 delete m_pModel;
86
87 QVector<CVirtualSystemDescription> vsds = m_pAppliance->GetVirtualSystemDescriptions();
88
89 m_pModel = new UIApplianceModel(vsds, m_pTreeViewSettings);
90 m_pModel->setVsdHints(m_listVsdHints);
91
92 ExportSortProxyModel *pProxy = new ExportSortProxyModel(this);
93 pProxy->setSourceModel(m_pModel);
94 pProxy->sort(ApplianceViewSection_Description, Qt::DescendingOrder);
95
96 UIApplianceDelegate *pDelegate = new UIApplianceDelegate(pProxy, this);
97
98 /* Set our own model */
99 m_pTreeViewSettings->setModel(pProxy);
100 /* Set our own delegate */
101 m_pTreeViewSettings->setItemDelegate(pDelegate);
102 /* For now we hide the original column. This data is displayed as tooltip
103 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 /* Check for warnings & if there are one display them. */
111 bool fWarningsEnabled = false;
112 QVector<QString> warnings = m_pAppliance->GetWarnings();
113 if (warnings.size() > 0)
114 {
115 foreach (const QString& text, warnings)
116 m_pTextEditWarning->append("- " + text);
117 fWarningsEnabled = true;
118 }
119 m_pPaneWarning->setVisible(fWarningsEnabled);
120}
121
122void UIApplianceExportEditorWidget::prepareExport()
123{
124 if (m_pAppliance)
125 m_pModel->putBack();
126}
127
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use