VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UITextTable.cpp

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
  • Property svn:mergeinfo set to (toggle deleted branches)
    /branches/VBox-3.0/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp58652,​70973
    /branches/VBox-3.2/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp66309,​66318
    /branches/VBox-4.0/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp70873
    /branches/VBox-4.1/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp74233
    /branches/VBox-4.2/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp91503-91504,​91506-91508,​91510,​91514-91515,​91521
    /branches/VBox-4.3/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp91223
    /branches/VBox-4.3/trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp91223
    /branches/dsen/gui/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp79076-79078,​79089,​79109-79110,​79112-79113,​79127-79130,​79134,​79141,​79151,​79155,​79157-79159,​79193,​79197
    /branches/dsen/gui2/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp79562-79569,​79572-79573,​79578,​79581-79582,​79590-79591,​79598-79599,​79602-79603,​79605-79606,​79632,​79635,​79637,​79644
    /branches/dsen/gui3/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp79645-79692
    /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp79225,​79271
File size: 5.1 KB
Line 
1/* $Id: UITextTable.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UITextTable 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 <QAccessibleObject>
30#include <QRegularExpression>
31
32/* GUI includes: */
33#include "UITextTable.h"
34
35/* Other VBox includes: */
36#include "iprt/assert.h"
37
38
39/** QAccessibleObject extension used as an accessibility interface for UITextTableLine. */
40class UIAccessibilityInterfaceForUITextTableLine : public QAccessibleObject
41{
42public:
43
44 /** Returns an accessibility interface for passed @a strClassname and @a pObject. */
45 static QAccessibleInterface *pFactory(const QString &strClassname, QObject *pObject)
46 {
47 /* Creating UITextTableLine accessibility interface: */
48 if (pObject && strClassname == QLatin1String("UITextTableLine"))
49 return new UIAccessibilityInterfaceForUITextTableLine(pObject);
50
51 /* Null by default: */
52 return 0;
53 }
54
55 /** Constructs an accessibility interface passing @a pObject to the base-class. */
56 UIAccessibilityInterfaceForUITextTableLine(QObject *pObject)
57 : QAccessibleObject(pObject)
58 {}
59
60 /** Returns the parent. */
61 virtual QAccessibleInterface *parent() const RT_OVERRIDE
62 {
63 /* Make sure item still alive: */
64 AssertPtrReturn(line(), 0);
65
66 /* Always return parent object: */
67 return QAccessible::queryAccessibleInterface(line()->parent());
68 }
69
70 /** Returns the number of children. */
71 virtual int childCount() const RT_OVERRIDE { return 0; }
72 /** Returns the child with the passed @a iIndex. */
73 virtual QAccessibleInterface *child(int iIndex) const RT_OVERRIDE { Q_UNUSED(iIndex); return 0; }
74 /** Returns the index of the passed @a pChild. */
75 virtual int indexOfChild(const QAccessibleInterface *pChild) const RT_OVERRIDE { Q_UNUSED(pChild); return -1; }
76
77 /** Returns a text for the passed @a enmTextRole. */
78 virtual QString text(QAccessible::Text enmTextRole) const RT_OVERRIDE
79 {
80 /* Make sure line still alive: */
81 AssertPtrReturn(line(), QString());
82
83 /* Return the description: */
84 if (enmTextRole == QAccessible::Description)
85 {
86 const QString str1 = line()->string1();
87 QString str2 = line()->string2();
88 if (!str2.isEmpty())
89 str2.remove(QRegularExpression("<a[^>]*>|</a>"));
90 return str2.isEmpty() ? str1 : QString("%1: %2").arg(str1, str2);
91 }
92
93 /* Null-string by default: */
94 return QString();
95 }
96
97 /** Returns the role. */
98 virtual QAccessible::Role role() const RT_OVERRIDE
99 {
100 /* Return the role: */
101 return QAccessible::ListItem;
102 }
103
104 /** Returns the state. */
105 virtual QAccessible::State state() const RT_OVERRIDE
106 {
107 /* Return the state: */
108 return QAccessible::State();
109 }
110
111private:
112
113 /** Returns corresponding UITextTableLine. */
114 UITextTableLine *line() const { return qobject_cast<UITextTableLine*>(object()); }
115};
116
117
118/*********************************************************************************************************************************
119* Class UITextTableLine implementation. *
120*********************************************************************************************************************************/
121
122UITextTableLine::UITextTableLine(const QString &str1, const QString &str2, QObject *pParent /* = 0 */)
123 : QObject(pParent)
124 , m_str1(str1)
125 , m_str2(str2)
126{
127 /* Install UITextTableLine accessibility interface factory: */
128 QAccessible::installFactory(UIAccessibilityInterfaceForUITextTableLine::pFactory);
129}
130
131UITextTableLine::UITextTableLine(const UITextTableLine &other)
132 : QObject(other.parent())
133 , m_str1(other.string1())
134 , m_str2(other.string2())
135{
136 /* Install UITextTableLine accessibility interface factory: */
137 QAccessible::installFactory(UIAccessibilityInterfaceForUITextTableLine::pFactory);
138}
139
140UITextTableLine &UITextTableLine::operator=(const UITextTableLine &other)
141{
142 setParent(other.parent());
143 set1(other.string1());
144 set2(other.string2());
145 return *this;
146}
147
148bool UITextTableLine::operator==(const UITextTableLine &other) const
149{
150 return string1() == other.string1()
151 && string2() == other.string2();
152}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use