VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNode.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: 2.3 KB
Line 
1/* $Id: UIChooserNode.cpp 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIChooserNode class definition.
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 "UIChooserNode.h"
30#include "UIChooserNodeGroup.h"
31#include "UIChooserNodeGlobal.h"
32#include "UIChooserNodeMachine.h"
33
34/* Other VBox includes: */
35#include "iprt/cpp/utils.h"
36
37
38UIChooserNode::UIChooserNode(UIChooserNode *pParent /* = 0 */, bool fFavorite /* = false */)
39 : QObject(pParent)
40 , m_pParent(pParent)
41 , m_fFavorite(fFavorite)
42 , m_pModel(0)
43 , m_fDisabled(false)
44{
45}
46
47UIChooserNode::~UIChooserNode()
48{
49 if (!m_pItem.isNull())
50 delete m_pItem.data();
51}
52
53UIChooserNodeGroup *UIChooserNode::toGroupNode()
54{
55 return static_cast<UIChooserNodeGroup*>(this);
56}
57
58UIChooserNodeGlobal *UIChooserNode::toGlobalNode()
59{
60 return static_cast<UIChooserNodeGlobal*>(this);
61}
62
63UIChooserNodeMachine *UIChooserNode::toMachineNode()
64{
65 return static_cast<UIChooserNodeMachine*>(this);
66}
67
68UIChooserNode *UIChooserNode::rootNode() const
69{
70 return isRoot() ? unconst(this) : parentNode()->rootNode();
71}
72
73UIChooserAbstractModel *UIChooserNode::model() const
74{
75 return m_pModel ? m_pModel : rootNode()->model();
76}
77
78int UIChooserNode::position()
79{
80 return parentNode() ? parentNode()->positionOf(this) : 0;
81}
82
83bool UIChooserNode::isDisabled() const
84{
85 return m_fDisabled;
86}
87
88void UIChooserNode::setDisabled(bool fDisabled)
89{
90 if (fDisabled == m_fDisabled)
91 return;
92 m_fDisabled = fDisabled;
93 if (m_pItem)
94 m_pItem->setDisabledEffect(m_fDisabled);
95}
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