VirtualBox

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

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