VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIQObjectStuff.cpp@ 104158

Last change on this file since 104158 was 98103, checked in by vboxsync, 23 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: 2.5 KB
Line 
1/* $Id: UIQObjectStuff.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIQObjectStuff class implementation.
4 */
5
6/*
7 * Copyright (C) 2020-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 "UIQObjectStuff.h"
30
31
32UIQObjectPropertySetter::UIQObjectPropertySetter(QObject *pObject, const QString &strPropertyName, const QVariant &value)
33 : m_strPropertyName(strPropertyName)
34 , m_value(value)
35{
36 /* Add object into list: */
37 m_objects << pObject;
38 /* Init properties: */
39 init();
40}
41
42UIQObjectPropertySetter::UIQObjectPropertySetter(const QList<QObject*> &objects, const QString &strPropertyName, const QVariant &value)
43 : m_strPropertyName(strPropertyName)
44 , m_value(value)
45{
46 /* Add objects into list: */
47 foreach (QObject *pObject, objects)
48 m_objects << pObject;
49 /* Init properties: */
50 init();
51}
52
53UIQObjectPropertySetter::~UIQObjectPropertySetter()
54{
55 /* Deinit properties: */
56 deinit();
57 /* Notify listeners that we are done: */
58 emit sigAboutToBeDestroyed();
59}
60
61void UIQObjectPropertySetter::init()
62{
63 foreach (const QPointer<QObject> &pObject, m_objects)
64 {
65 if (pObject)
66 {
67 pObject->setProperty(m_strPropertyName.toLatin1().constData(), m_value);
68 //printf("UIQObjectPropertySetter::UIQObjectPropertySetter: Property {%s} set.\n",
69 // m_strPropertyName.toLatin1().constData());
70 }
71 }
72}
73
74void UIQObjectPropertySetter::deinit()
75{
76 foreach (const QPointer<QObject> &pObject, m_objects)
77 {
78 if (pObject)
79 {
80 pObject->setProperty(m_strPropertyName.toLatin1().constData(), QVariant());
81 //printf("UIQObjectPropertySetter::~UIQObjectPropertySetter: Property {%s} cleared.\n",
82 // m_strPropertyName.toLatin1().constData());
83 }
84 }
85}
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