VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeGlobal.cpp@ 103538

Last change on this file since 103538 was 98103, checked in by vboxsync, 17 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: 5.0 KB
Line 
1/* $Id: UIChooserNodeGlobal.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIChooserNodeGlobal 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/* GUI includes: */
29#include "UIChooserAbstractModel.h"
30#include "UIChooserNodeGlobal.h"
31
32/* Other VBox includes: */
33#include "iprt/assert.h"
34
35
36UIChooserNodeGlobal::UIChooserNodeGlobal(UIChooserNode *pParent,
37 int iPosition,
38 bool fFavorite,
39 const QString &)
40 : UIChooserNode(pParent, fFavorite)
41{
42 /* Add to parent: */
43 if (parentNode())
44 parentNode()->addNode(this, iPosition);
45
46 /* Apply language settings: */
47 retranslateUi();
48}
49
50UIChooserNodeGlobal::UIChooserNodeGlobal(UIChooserNode *pParent,
51 int iPosition,
52 UIChooserNodeGlobal *pCopyFrom)
53 : UIChooserNode(pParent, pCopyFrom->isFavorite())
54{
55 /* Add to parent: */
56 if (parentNode())
57 parentNode()->addNode(this, iPosition);
58
59 /* Apply language settings: */
60 retranslateUi();
61}
62
63UIChooserNodeGlobal::~UIChooserNodeGlobal()
64{
65 /* Delete item: */
66 delete item();
67
68 /* Remove from parent: */
69 if (parentNode())
70 parentNode()->removeNode(this);
71}
72
73QString UIChooserNodeGlobal::name() const
74{
75 return m_strName;
76}
77
78QString UIChooserNodeGlobal::fullName() const
79{
80 return name();
81}
82
83QString UIChooserNodeGlobal::description() const
84{
85 return m_strDescription;
86}
87
88QString UIChooserNodeGlobal::definition(bool fFull /* = false */) const
89{
90 const QString strNodePrefix = UIChooserAbstractModel::prefixToString(UIChooserNodeDataPrefixType_Global);
91 const QString strNodeOptionFavorite = UIChooserAbstractModel::optionToString(UIChooserNodeDataOptionType_GlobalFavorite);
92 const QString strNodeValueDefault = UIChooserAbstractModel::valueToString(UIChooserNodeDataValueType_GlobalDefault);
93 return fFull
94 ? QString("%1%2=%3").arg(strNodePrefix).arg(isFavorite() ? strNodeOptionFavorite : "").arg(strNodeValueDefault)
95 : QString("%1=%2").arg(strNodePrefix).arg(strNodeValueDefault);
96}
97
98bool UIChooserNodeGlobal::hasNodes(UIChooserNodeType enmType /* = UIChooserNodeType_Any */) const
99{
100 Q_UNUSED(enmType);
101 AssertFailedReturn(false);
102}
103
104QList<UIChooserNode*> UIChooserNodeGlobal::nodes(UIChooserNodeType enmType /* = UIChooserNodeType_Any */) const
105{
106 Q_UNUSED(enmType);
107 AssertFailedReturn(QList<UIChooserNode*>());
108}
109
110void UIChooserNodeGlobal::addNode(UIChooserNode *pNode, int iPosition)
111{
112 Q_UNUSED(pNode);
113 Q_UNUSED(iPosition);
114 AssertFailedReturnVoid();
115}
116
117void UIChooserNodeGlobal::removeNode(UIChooserNode *pNode)
118{
119 Q_UNUSED(pNode);
120 AssertFailedReturnVoid();
121}
122
123void UIChooserNodeGlobal::removeAllNodes(const QUuid &)
124{
125 // Nothing to remove for global-node..
126}
127
128void UIChooserNodeGlobal::updateAllNodes(const QUuid &)
129{
130 // Nothing to update for global-node..
131
132 /* Update global-item: */
133 item()->updateItem();
134}
135
136int UIChooserNodeGlobal::positionOf(UIChooserNode *pNode)
137{
138 Q_UNUSED(pNode);
139 AssertFailedReturn(0);
140}
141
142void UIChooserNodeGlobal::searchForNodes(const QString &strSearchTerm, int iSearchFlags, QList<UIChooserNode*> &matchedItems)
143{
144 /* Ignore if we are not searching for the global-node: */
145 if (!(iSearchFlags & UIChooserItemSearchFlag_Global))
146 return;
147
148 /* If the search term is empty we just add the node to the matched list: */
149 if (strSearchTerm.isEmpty())
150 matchedItems << this;
151 else
152 {
153 /* If exact name flag specified => check full node name: */
154 if (iSearchFlags & UIChooserItemSearchFlag_ExactName)
155 {
156 if (name() == strSearchTerm)
157 matchedItems << this;
158 }
159 /* Otherwise check if name contains search term: */
160 else
161 {
162 if (name().contains(strSearchTerm, Qt::CaseInsensitive))
163 matchedItems << this;
164 }
165 }
166}
167
168void UIChooserNodeGlobal::sortNodes()
169{
170 AssertFailedReturnVoid();
171}
172
173void UIChooserNodeGlobal::retranslateUi()
174{
175 /* Translate name & description: */
176 m_strName = tr("Tools");
177 m_strDescription = tr("Item");
178
179 /* Update global-item: */
180 if (item())
181 item()->updateItem();
182}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use