VirtualBox

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

Last change on this file since 100347 was 98103, checked in by vboxsync, 21 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: 3.8 KB
Line 
1/* $Id: UIApplianceImportEditorWidget.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIApplianceImportEditorWidget 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 "UIApplianceImportEditorWidget.h"
34#include "UIMessageCenter.h"
35
36
37/** UIApplianceSortProxyModel subclass for Export Appliance wizard. */
38class ImportSortProxyModel : public UIApplianceSortProxyModel
39{
40public:
41
42 /** Constructs proxy model passing @a pParent to the base-class. */
43 ImportSortProxyModel(QObject *pParent = 0)
44 : UIApplianceSortProxyModel(pParent)
45 {
46 m_aFilteredList << KVirtualSystemDescriptionType_License;
47 }
48};
49
50
51/*********************************************************************************************************************************
52* Class UIApplianceImportEditorWidget implementation. *
53*********************************************************************************************************************************/
54
55UIApplianceImportEditorWidget::UIApplianceImportEditorWidget(QWidget *pParent /* = 0 */)
56 : UIApplianceEditorWidget(pParent)
57{
58}
59
60void UIApplianceImportEditorWidget::setAppliance(const CAppliance &comAppliance)
61{
62 /* Cleanup previous stuff: */
63 clear();
64
65 /* Call to base-class: */
66 UIApplianceEditorWidget::setAppliance(comAppliance);
67
68 /* Prepare model: */
69 QVector<CVirtualSystemDescription> vsds = m_comAppliance.GetVirtualSystemDescriptions();
70 m_pModel = new UIApplianceModel(vsds, m_pTreeViewSettings);
71 if (m_pModel)
72 {
73 /* Create proxy model: */
74 ImportSortProxyModel *pProxy = new ImportSortProxyModel(m_pModel);
75 if (pProxy)
76 {
77 pProxy->setSourceModel(m_pModel);
78 pProxy->sort(ApplianceViewSection_Description, Qt::DescendingOrder);
79
80 /* Set our own model: */
81 m_pTreeViewSettings->setModel(pProxy);
82 /* Set our own delegate: */
83 UIApplianceDelegate *pDelegate = new UIApplianceDelegate(pProxy);
84 if (pDelegate)
85 m_pTreeViewSettings->setItemDelegate(pDelegate);
86
87 /* For now we hide the original column. This data is displayed as tooltip also. */
88 m_pTreeViewSettings->setColumnHidden(ApplianceViewSection_OriginalValue, true);
89 m_pTreeViewSettings->expandAll();
90 /* Set model root index and make it current: */
91 m_pTreeViewSettings->setRootIndex(pProxy->mapFromSource(m_pModel->root()));
92 m_pTreeViewSettings->setCurrentIndex(pProxy->mapFromSource(m_pModel->root()));
93 }
94 }
95
96 /* Check for warnings & if there are one display them: */
97 const QVector<QString> warnings = m_comAppliance.GetWarnings();
98 const bool fWarningsEnabled = warnings.size() > 0;
99 foreach (const QString &strText, warnings)
100 m_pTextEditWarning->append("- " + strText);
101 m_pPaneWarning->setVisible(fWarningsEnabled);
102}
103
104void UIApplianceImportEditorWidget::prepareImport()
105{
106 if (m_comAppliance.isNotNull())
107 m_pModel->putBack();
108}
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