Changeset 63770 in vbox
- Timestamp:
- Sep 8, 2016 4:18:21 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 110585
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsTextPane.cpp
r63767 r63770 21 21 22 22 /* Qt includes: */ 23 # include <QAccessibleObject> 23 24 # include <QPainter> 24 25 # include <QTextLayout> … … 31 32 # include "UIRichTextString.h" 32 33 34 /* Other VBox includes: */ 35 # include <iprt/assert.h> 36 33 37 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 38 39 40 /** QAccessibleObject extension used as an accessibility interface for UITextTableLine. */ 41 class UIAccessibilityInterfaceForUITextTableLine : public QAccessibleObject 42 { 43 public: 44 45 /** Returns an accessibility interface for passed @a strClassname and @a pObject. */ 46 static QAccessibleInterface *pFactory(const QString &strClassname, QObject *pObject) 47 { 48 /* Creating Details-view accessibility interface: */ 49 if (pObject && strClassname == QLatin1String("UITextTableLine")) 50 return new UIAccessibilityInterfaceForUITextTableLine(pObject); 51 52 /* Null by default: */ 53 return 0; 54 } 55 56 /** Constructs an accessibility interface passing @a pObject to the base-class. */ 57 UIAccessibilityInterfaceForUITextTableLine(QObject *pObject) 58 : QAccessibleObject(pObject) 59 {} 60 61 /** Returns the parent. */ 62 virtual QAccessibleInterface *parent() const /* override */ 63 { 64 /* Make sure line still alive: */ 65 AssertPtrReturn(line(), 0); 66 67 /* Return the parent: */ 68 return QAccessible::queryAccessibleInterface(line()->parent()); 69 } 70 71 /** Returns the number of children. */ 72 virtual int childCount() const /* override */ { return 0; } 73 /** Returns the child with the passed @a iIndex. */ 74 virtual QAccessibleInterface *child(int /* iIndex */) const /* override */ { return 0; } 75 /** Returns the index of the passed @a pChild. */ 76 virtual int indexOfChild(const QAccessibleInterface * /* pChild */) const /* override */ { return -1; } 77 78 /** Returns the rect. */ 79 virtual QRect rect() const /* override */ 80 { 81 /* Make sure parent still alive: */ 82 AssertPtrReturn(parent(), QRect()); 83 84 /* Return the parent's rect for now: */ 85 // TODO: Return sub-rect. 86 return parent()->rect(); 87 } 88 89 /** Returns a text for the passed @a enmTextRole. */ 90 virtual QString text(QAccessible::Text enmTextRole) const /* override */ 91 { 92 /* Make sure line still alive: */ 93 AssertPtrReturn(line(), QString()); 94 95 /* Return the description: */ 96 if (enmTextRole == QAccessible::Description) 97 return UIGraphicsTextPane::tr("%1: %2", "'key: value', like 'Name: MyVM'").arg(line()->string1(), line()->string2()); 98 99 /* Null-string by default: */ 100 return QString(); 101 } 102 103 /** Returns the role. */ 104 virtual QAccessible::Role role() const /* override */ { return QAccessible::StaticText; } 105 /** Returns the state. */ 106 virtual QAccessible::State state() const /* override */ { return QAccessible::State(); } 107 108 private: 109 110 /** Returns corresponding text-table line. */ 111 UITextTableLine *line() const { return qobject_cast<UITextTableLine*>(object()); } 112 }; 113 34 114 35 115 UIGraphicsTextPane::UIGraphicsTextPane(QIGraphicsWidget *pParent, QPaintDevice *pPaintDevice) … … 44 124 , m_fAnchorCanBeHovered(true) 45 125 { 126 /* Install text-table line accessibility interface factory: */ 127 QAccessible::installFactory(UIAccessibilityInterfaceForUITextTableLine::pFactory); 128 46 129 /* We do support hover-events: */ 47 130 setAcceptHoverEvents(true); … … 71 154 { 72 155 /* Take both lines 'as is': */ 73 m_text << UITextTableLine(strLeftLine, strRightLine, parent ());156 m_text << UITextTableLine(strLeftLine, strRightLine, parentWidget()); 74 157 } 75 158 /* If 2nd line is empty: */ … … 79 162 QStringList subLines = strLeftLine.split(QRegExp("\\n")); 80 163 foreach (const QString &strSubLine, subLines) 81 m_text << UITextTableLine(strSubLine, QString(), parent ());164 m_text << UITextTableLine(strSubLine, QString(), parentWidget()); 82 165 } 83 166 }
Note:
See TracChangeset
for help on using the changeset viewer.