1 | /* $Id: UIApplianceExportEditorWidget.cpp 79365 2019-06-26 15:57:32Z 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 | /* Qt includes: */
|
---|
19 | #include <QTextEdit>
|
---|
20 |
|
---|
21 | /* GUI includes: */
|
---|
22 | #include "QITreeView.h"
|
---|
23 | #include "UIApplianceExportEditorWidget.h"
|
---|
24 | #include "UICommon.h"
|
---|
25 | #include "UIMessageCenter.h"
|
---|
26 |
|
---|
27 | /* COM includes: */
|
---|
28 | #include "CAppliance.h"
|
---|
29 |
|
---|
30 |
|
---|
31 | ////////////////////////////////////////////////////////////////////////////////
|
---|
32 | // ExportSortProxyModel
|
---|
33 |
|
---|
34 | class ExportSortProxyModel: public UIApplianceSortProxyModel
|
---|
35 | {
|
---|
36 | public:
|
---|
37 | ExportSortProxyModel(QObject *pParent = NULL)
|
---|
38 | : UIApplianceSortProxyModel(pParent)
|
---|
39 | {
|
---|
40 | m_aFilteredList
|
---|
41 | << KVirtualSystemDescriptionType_OS
|
---|
42 | << KVirtualSystemDescriptionType_CPU
|
---|
43 | << KVirtualSystemDescriptionType_Memory
|
---|
44 | << KVirtualSystemDescriptionType_Floppy
|
---|
45 | << KVirtualSystemDescriptionType_CDROM
|
---|
46 | << KVirtualSystemDescriptionType_USBController
|
---|
47 | << KVirtualSystemDescriptionType_SoundCard
|
---|
48 | << KVirtualSystemDescriptionType_NetworkAdapter
|
---|
49 | << KVirtualSystemDescriptionType_HardDiskControllerIDE
|
---|
50 | << KVirtualSystemDescriptionType_HardDiskControllerSATA
|
---|
51 | << KVirtualSystemDescriptionType_HardDiskControllerSCSI
|
---|
52 | << KVirtualSystemDescriptionType_HardDiskControllerSAS
|
---|
53 | << KVirtualSystemDescriptionType_CloudProfileName;
|
---|
54 | }
|
---|
55 | };
|
---|
56 |
|
---|
57 | ////////////////////////////////////////////////////////////////////////////////
|
---|
58 | // UIApplianceExportEditorWidget
|
---|
59 |
|
---|
60 | UIApplianceExportEditorWidget::UIApplianceExportEditorWidget(QWidget *pParent /* = NULL */)
|
---|
61 | : UIApplianceEditorWidget(pParent)
|
---|
62 | {
|
---|
63 | }
|
---|
64 |
|
---|
65 | CAppliance* UIApplianceExportEditorWidget::init()
|
---|
66 | {
|
---|
67 | if (m_pAppliance)
|
---|
68 | delete m_pAppliance;
|
---|
69 | CVirtualBox vbox = uiCommon().virtualBox();
|
---|
70 | /* Create a appliance object */
|
---|
71 | m_pAppliance = new CAppliance(vbox.CreateAppliance());
|
---|
72 | // bool fResult = m_pAppliance->isOk();
|
---|
73 | return m_pAppliance;
|
---|
74 | }
|
---|
75 |
|
---|
76 | void UIApplianceExportEditorWidget::populate()
|
---|
77 | {
|
---|
78 | if (m_pModel)
|
---|
79 | delete m_pModel;
|
---|
80 |
|
---|
81 | QVector<CVirtualSystemDescription> vsds = m_pAppliance->GetVirtualSystemDescriptions();
|
---|
82 |
|
---|
83 | m_pModel = new UIApplianceModel(vsds, m_pTreeViewSettings);
|
---|
84 | m_pModel->setVsdHints(m_listVsdHints);
|
---|
85 |
|
---|
86 | ExportSortProxyModel *pProxy = new ExportSortProxyModel(this);
|
---|
87 | pProxy->setSourceModel(m_pModel);
|
---|
88 | pProxy->sort(ApplianceViewSection_Description, Qt::DescendingOrder);
|
---|
89 |
|
---|
90 | UIApplianceDelegate *pDelegate = new UIApplianceDelegate(pProxy, this);
|
---|
91 |
|
---|
92 | /* Set our own model */
|
---|
93 | m_pTreeViewSettings->setModel(pProxy);
|
---|
94 | /* Set our own delegate */
|
---|
95 | m_pTreeViewSettings->setItemDelegate(pDelegate);
|
---|
96 | /* For now we hide the original column. This data is displayed as tooltip
|
---|
97 | also. */
|
---|
98 | m_pTreeViewSettings->setColumnHidden(ApplianceViewSection_OriginalValue, true);
|
---|
99 | m_pTreeViewSettings->expandAll();
|
---|
100 | /* Set model root index and make it current: */
|
---|
101 | m_pTreeViewSettings->setRootIndex(pProxy->mapFromSource(m_pModel->root()));
|
---|
102 | m_pTreeViewSettings->setCurrentIndex(pProxy->mapFromSource(m_pModel->root()));
|
---|
103 |
|
---|
104 | /* Check for warnings & if there are one display them. */
|
---|
105 | bool fWarningsEnabled = false;
|
---|
106 | QVector<QString> warnings = m_pAppliance->GetWarnings();
|
---|
107 | if (warnings.size() > 0)
|
---|
108 | {
|
---|
109 | foreach (const QString& text, warnings)
|
---|
110 | m_pTextEditWarning->append("- " + text);
|
---|
111 | fWarningsEnabled = true;
|
---|
112 | }
|
---|
113 | m_pPaneWarning->setVisible(fWarningsEnabled);
|
---|
114 | }
|
---|
115 |
|
---|
116 | void UIApplianceExportEditorWidget::prepareExport()
|
---|
117 | {
|
---|
118 | if (m_pAppliance)
|
---|
119 | m_pModel->putBack();
|
---|
120 | }
|
---|
121 |
|
---|