VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceImportEditorWidget.cpp@ 91578

Last change on this file since 91578 was 91578, checked in by vboxsync, 3 years ago

FE/Qt: bugref:9996: UIWizardImportApp: Moving appliance related code from UIApplianceImportEditorWidget to UIWizardImportApp itself where it belongs.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1/* $Id: UIApplianceImportEditorWidget.cpp 91578 2021-10-05 17:24:33Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIApplianceImportEditorWidget class implementation.
4 */
5
6/*
7 * Copyright (C) 2009-2021 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 "UIApplianceImportEditorWidget.h"
24#include "UIMessageCenter.h"
25
26
27/** UIApplianceSortProxyModel subclass for Export Appliance wizard. */
28class ImportSortProxyModel : public UIApplianceSortProxyModel
29{
30public:
31
32 /** Constructs proxy model passing @a pParent to the base-class. */
33 ImportSortProxyModel(QObject *pParent = 0)
34 : UIApplianceSortProxyModel(pParent)
35 {
36 m_aFilteredList << KVirtualSystemDescriptionType_License;
37 }
38};
39
40
41/*********************************************************************************************************************************
42* Class UIApplianceImportEditorWidget implementation. *
43*********************************************************************************************************************************/
44
45UIApplianceImportEditorWidget::UIApplianceImportEditorWidget(QWidget *pParent /* = 0 */)
46 : UIApplianceEditorWidget(pParent)
47{
48}
49
50void UIApplianceImportEditorWidget::setAppliance(const CAppliance &comAppliance)
51{
52 /* Cache newly passed appliance: */
53 m_comAppliance = comAppliance;
54
55 /* Cleanup previous stuff: */
56 if (m_pModel)
57 delete m_pModel;
58
59 /* Prepare model: */
60 QVector<CVirtualSystemDescription> vsds = m_comAppliance.GetVirtualSystemDescriptions();
61 m_pModel = new UIApplianceModel(vsds, m_pTreeViewSettings);
62 if (m_pModel)
63 {
64 /* Create proxy model: */
65 ImportSortProxyModel *pProxy = new ImportSortProxyModel(m_pModel);
66 if (pProxy)
67 {
68 pProxy->setSourceModel(m_pModel);
69 pProxy->sort(ApplianceViewSection_Description, Qt::DescendingOrder);
70
71 /* Set our own model: */
72 m_pTreeViewSettings->setModel(pProxy);
73 /* Set our own delegate: */
74 UIApplianceDelegate *pDelegate = new UIApplianceDelegate(pProxy);
75 if (pDelegate)
76 m_pTreeViewSettings->setItemDelegate(pDelegate);
77
78 /* For now we hide the original column. This data is displayed as tooltip also. */
79 m_pTreeViewSettings->setColumnHidden(ApplianceViewSection_OriginalValue, true);
80 m_pTreeViewSettings->expandAll();
81 /* Set model root index and make it current: */
82 m_pTreeViewSettings->setRootIndex(pProxy->mapFromSource(m_pModel->root()));
83 m_pTreeViewSettings->setCurrentIndex(pProxy->mapFromSource(m_pModel->root()));
84 }
85 }
86
87 /* Check for warnings & if there are one display them: */
88 const QVector<QString> warnings = m_comAppliance.GetWarnings();
89 const bool fWarningsEnabled = warnings.size() > 0;
90 foreach (const QString &strText, warnings)
91 m_pTextEditWarning->append("- " + strText);
92 m_pPaneWarning->setVisible(fWarningsEnabled);
93}
94
95void UIApplianceImportEditorWidget::prepareImport()
96{
97 if (m_comAppliance.isNotNull())
98 m_pModel->putBack();
99}
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