1 | /* $Id: UIDetails.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIDetails class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-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 <QVBoxLayout>
|
---|
30 |
|
---|
31 | /* GUI includes: */
|
---|
32 | #include "UICommon.h"
|
---|
33 | #include "UIDetails.h"
|
---|
34 | #include "UIDetailsModel.h"
|
---|
35 | #include "UIDetailsView.h"
|
---|
36 | #include "UIExtraDataManager.h"
|
---|
37 |
|
---|
38 |
|
---|
39 | UIDetails::UIDetails(QWidget *pParent /* = 0 */)
|
---|
40 | : QWidget(pParent)
|
---|
41 | , m_pMainLayout(0)
|
---|
42 | , m_pDetailsModel(0)
|
---|
43 | , m_pDetailsView(0)
|
---|
44 | {
|
---|
45 | prepare();
|
---|
46 | }
|
---|
47 |
|
---|
48 | void UIDetails::setItems(const QList<UIVirtualMachineItem*> &items)
|
---|
49 | {
|
---|
50 | /* Propagate to details-model: */
|
---|
51 | m_pDetailsModel->setItems(items);
|
---|
52 | }
|
---|
53 |
|
---|
54 | void UIDetails::prepare()
|
---|
55 | {
|
---|
56 | /* Prepare everything: */
|
---|
57 | prepareContents();
|
---|
58 | prepareConnections();
|
---|
59 |
|
---|
60 | /* Configure context-sensitive help: */
|
---|
61 | uiCommon().setHelpKeyword(this, "vm-details-tool");
|
---|
62 |
|
---|
63 | /* Init model finally: */
|
---|
64 | initModel();
|
---|
65 | }
|
---|
66 |
|
---|
67 | void UIDetails::prepareContents()
|
---|
68 | {
|
---|
69 | /* Prepare main-layout: */
|
---|
70 | m_pMainLayout = new QVBoxLayout(this);
|
---|
71 | if (m_pMainLayout)
|
---|
72 | {
|
---|
73 | m_pMainLayout->setContentsMargins(0, 0, 0, 0);
|
---|
74 | m_pMainLayout->setSpacing(0);
|
---|
75 |
|
---|
76 | /* Prepare model: */
|
---|
77 | prepareModel();
|
---|
78 | }
|
---|
79 | }
|
---|
80 |
|
---|
81 | void UIDetails::prepareModel()
|
---|
82 | {
|
---|
83 | /* Prepare model: */
|
---|
84 | m_pDetailsModel = new UIDetailsModel(this);
|
---|
85 | if (m_pDetailsModel)
|
---|
86 | prepareView();
|
---|
87 | }
|
---|
88 |
|
---|
89 | void UIDetails::prepareView()
|
---|
90 | {
|
---|
91 | AssertPtrReturnVoid(m_pDetailsModel);
|
---|
92 | AssertPtrReturnVoid(m_pMainLayout);
|
---|
93 |
|
---|
94 | /* Prepare view: */
|
---|
95 | m_pDetailsView = new UIDetailsView(this);
|
---|
96 | if (m_pDetailsView)
|
---|
97 | {
|
---|
98 | m_pDetailsView->setScene(m_pDetailsModel->scene());
|
---|
99 | m_pDetailsView->show();
|
---|
100 | setFocusProxy(m_pDetailsView);
|
---|
101 |
|
---|
102 | /* Add into layout: */
|
---|
103 | m_pMainLayout->addWidget(m_pDetailsView);
|
---|
104 | }
|
---|
105 | }
|
---|
106 |
|
---|
107 | void UIDetails::prepareConnections()
|
---|
108 | {
|
---|
109 | /* Extra-data events connections: */
|
---|
110 | connect(gEDataManager, &UIExtraDataManager::sigDetailsCategoriesChange,
|
---|
111 | m_pDetailsModel, &UIDetailsModel::sltHandleExtraDataCategoriesChange);
|
---|
112 | connect(gEDataManager, &UIExtraDataManager::sigDetailsOptionsChange,
|
---|
113 | m_pDetailsModel, &UIDetailsModel::sltHandleExtraDataOptionsChange);
|
---|
114 |
|
---|
115 | /* Model connections: */
|
---|
116 | connect(m_pDetailsModel, &UIDetailsModel::sigRootItemMinimumWidthHintChanged,
|
---|
117 | m_pDetailsView, &UIDetailsView::sltMinimumWidthHintChanged);
|
---|
118 | connect(m_pDetailsModel, &UIDetailsModel::sigLinkClicked,
|
---|
119 | this, &UIDetails::sigLinkClicked);
|
---|
120 | connect(this, &UIDetails::sigToggleStarted,
|
---|
121 | m_pDetailsModel, &UIDetailsModel::sltHandleToggleStarted);
|
---|
122 | connect(this, &UIDetails::sigToggleFinished,
|
---|
123 | m_pDetailsModel, &UIDetailsModel::sltHandleToggleFinished);
|
---|
124 |
|
---|
125 | /* View connections: */
|
---|
126 | connect(m_pDetailsView, &UIDetailsView::sigResized,
|
---|
127 | m_pDetailsModel, &UIDetailsModel::sltHandleViewResize);
|
---|
128 | }
|
---|
129 |
|
---|
130 | void UIDetails::initModel()
|
---|
131 | {
|
---|
132 | m_pDetailsModel->init();
|
---|
133 | }
|
---|