VirtualBox

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

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

FE/Qt: bugref:9996: UIApplianceEditorWidget: Implementing clear functionality.

  • 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 91638 2021-10-08 12:22:29Z 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 /* Cleanup previous stuff: */
53 clear();
54
55 /* Call to base-class: */
56 UIApplianceEditorWidget::setAppliance(comAppliance);
57
58 /* Prepare model: */
59 QVector<CVirtualSystemDescription> vsds = m_comAppliance.GetVirtualSystemDescriptions();
60 m_pModel = new UIApplianceModel(vsds, m_pTreeViewSettings);
61 if (m_pModel)
62 {
63 /* Create proxy model: */
64 ImportSortProxyModel *pProxy = new ImportSortProxyModel(m_pModel);
65 if (pProxy)
66 {
67 pProxy->setSourceModel(m_pModel);
68 pProxy->sort(ApplianceViewSection_Description, Qt::DescendingOrder);
69
70 /* Set our own model: */
71 m_pTreeViewSettings->setModel(pProxy);
72 /* Set our own delegate: */
73 UIApplianceDelegate *pDelegate = new UIApplianceDelegate(pProxy);
74 if (pDelegate)
75 m_pTreeViewSettings->setItemDelegate(pDelegate);
76
77 /* For now we hide the original column. This data is displayed as tooltip also. */
78 m_pTreeViewSettings->setColumnHidden(ApplianceViewSection_OriginalValue, true);
79 m_pTreeViewSettings->expandAll();
80 /* Set model root index and make it current: */
81 m_pTreeViewSettings->setRootIndex(pProxy->mapFromSource(m_pModel->root()));
82 m_pTreeViewSettings->setCurrentIndex(pProxy->mapFromSource(m_pModel->root()));
83 }
84 }
85
86 /* Check for warnings & if there are one display them: */
87 const QVector<QString> warnings = m_comAppliance.GetWarnings();
88 const bool fWarningsEnabled = warnings.size() > 0;
89 foreach (const QString &strText, warnings)
90 m_pTextEditWarning->append("- " + strText);
91 m_pPaneWarning->setVisible(fWarningsEnabled);
92}
93
94void UIApplianceImportEditorWidget::prepareImport()
95{
96 if (m_comAppliance.isNotNull())
97 m_pModel->putBack();
98}
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