VirtualBox

Changeset 77432 in vbox


Ignore:
Timestamp:
Feb 22, 2019 2:52:39 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
128995
Message:

FE/Qt: bugref:9389. Split UITextTable stuff and make it global.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
6 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r77428 r77432  
    814814        src/globals/UIShortcutPool.h \
    815815        src/globals/UIThreadPool.h \
     816        src/globals/UITextTable.h \
    816817        src/globals/UIVirtualBoxEventHandler.h \
    817818        src/globals/VBoxGlobal.h \
     
    12801281        src/globals/UIProgressEventHandler.cpp \
    12811282        src/globals/UIShortcutPool.cpp \
     1283        src/globals/UITextTable.cpp \
    12821284        src/globals/UIThreadPool.cpp \
    12831285        src/globals/UIVersion.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UITextTable.cpp

    r77430 r77432  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIGraphicsTextPane class implementation.
     3 * VBox Qt GUI - UITextTable class implementation.
    44 */
    55
     
    2525
    2626/* GUI includes: */
    27 #include "UIGraphicsTextPane.h"
     27#include "UITextTable.h"
    2828#include "UIRichTextString.h"
    2929#include "VBoxGlobal.h"
     
    3131/* Other VBox includes: */
    3232#include <iprt/assert.h>
    33 
    34 
    35 /** QAccessibleObject extension used as an accessibility interface for UITextTableLine. */
    36 class UIAccessibilityInterfaceForUITextTableLine : public QAccessibleObject
    37 {
    38 public:
    39 
    40     /** Returns an accessibility interface for passed @a strClassname and @a pObject. */
    41     static QAccessibleInterface *pFactory(const QString &strClassname, QObject *pObject)
    42     {
    43         /* Creating Details-view accessibility interface: */
    44         if (pObject && strClassname == QLatin1String("UITextTableLine"))
    45             return new UIAccessibilityInterfaceForUITextTableLine(pObject);
    46 
    47         /* Null by default: */
    48         return 0;
    49     }
    50 
    51     /** Constructs an accessibility interface passing @a pObject to the base-class. */
    52     UIAccessibilityInterfaceForUITextTableLine(QObject *pObject)
    53         : QAccessibleObject(pObject)
    54     {}
    55 
    56     /** Returns the parent. */
    57     virtual QAccessibleInterface *parent() const /* override */
    58     {
    59         /* Make sure line still alive: */
    60         AssertPtrReturn(line(), 0);
    61 
    62         /* Return the parent: */
    63         return QAccessible::queryAccessibleInterface(line()->parent());
    64     }
    65 
    66     /** Returns the number of children. */
    67     virtual int childCount() const /* override */ { return 0; }
    68     /** Returns the child with the passed @a iIndex. */
    69     virtual QAccessibleInterface *child(int /* iIndex */) const /* override */ { return 0; }
    70     /** Returns the index of the passed @a pChild. */
    71     virtual int indexOfChild(const QAccessibleInterface * /* pChild */) const /* override */ { return -1; }
    72 
    73     /** Returns the rect. */
    74     virtual QRect rect() const /* override */
    75     {
    76         /* Make sure parent still alive: */
    77         AssertPtrReturn(parent(), QRect());
    78 
    79         /* Return the parent's rect for now: */
    80         /// @todo Return sub-rect.
    81         return parent()->rect();
    82     }
    83 
    84     /** Returns a text for the passed @a enmTextRole. */
    85     virtual QString text(QAccessible::Text enmTextRole) const /* override */
    86     {
    87         /* Make sure line still alive: */
    88         AssertPtrReturn(line(), QString());
    89 
    90         /* Return the description: */
    91         if (enmTextRole == QAccessible::Description)
    92             return UIGraphicsTextPane::tr("%1: %2", "'key: value', like 'Name: MyVM'").arg(line()->string1(), line()->string2());
    93 
    94         /* Null-string by default: */
    95         return QString();
    96     }
    97 
    98     /** Returns the role. */
    99     virtual QAccessible::Role role() const /* override */ { return QAccessible::StaticText; }
    100     /** Returns the state. */
    101     virtual QAccessible::State state() const /* override */ { return QAccessible::State(); }
    102 
    103 private:
    104 
    105     /** Returns corresponding text-table line. */
    106     UITextTableLine *line() const { return qobject_cast<UITextTableLine*>(object()); }
    107 };
    108 
    109 
    110 UIGraphicsTextPane::UIGraphicsTextPane(QIGraphicsWidget *pParent, QPaintDevice *pPaintDevice)
    111     : QIGraphicsWidget(pParent)
    112     , m_pPaintDevice(pPaintDevice)
    113     , m_iMargin(0)
    114     , m_iSpacing(10)
    115     , m_iMinimumTextColumnWidth(100)
    116     , m_fMinimumSizeHintInvalidated(true)
    117     , m_iMinimumTextWidth(0)
    118     , m_iMinimumTextHeight(0)
    119     , m_fAnchorCanBeHovered(true)
    120 {
    121     /* Install text-table line accessibility interface factory: */
    122     QAccessible::installFactory(UIAccessibilityInterfaceForUITextTableLine::pFactory);
    123 
    124     /* We do support hover-events: */
    125     setAcceptHoverEvents(true);
    126 }
    127 
    128 UIGraphicsTextPane::~UIGraphicsTextPane()
    129 {
    130     /* Clear text-layouts: */
    131     while (!m_leftList.isEmpty()) delete m_leftList.takeLast();
    132     while (!m_rightList.isEmpty()) delete m_rightList.takeLast();
    133 }
    134 
    135 void UIGraphicsTextPane::setText(const UITextTable &text)
    136 {
    137     /* Clear text: */
    138     m_text.clear();
    139 
    140     /* For each the line of the passed table: */
    141     foreach (const UITextTableLine &line, text)
    142     {
    143         /* Lines: */
    144         QString strLeftLine = line.string1();
    145         QString strRightLine = line.string2();
    146 
    147         /* If 2nd line is NOT empty: */
    148         if (!strRightLine.isEmpty())
    149         {
    150             /* Take both lines 'as is': */
    151             m_text << UITextTableLine(strLeftLine, strRightLine, parentWidget());
    152         }
    153         /* If 2nd line is empty: */
    154         else
    155         {
    156             /* Parse the 1st one to sub-lines: */
    157             QStringList subLines = strLeftLine.split(QRegExp("\\n"));
    158             foreach (const QString &strSubLine, subLines)
    159                 m_text << UITextTableLine(strSubLine, QString(), parentWidget());
    160         }
    161     }
    162 
    163     /* Update text-layout: */
    164     updateTextLayout(true);
    165 
    166     /* Update minimum size-hint: */
    167     updateGeometry();
    168 }
    169 
    170 void UIGraphicsTextPane::setAnchorRoleRestricted(const QString &strAnchorRole, bool fRestricted)
    171 {
    172     /* Make sure something changed: */
    173     if (   (fRestricted && m_restrictedAnchorRoles.contains(strAnchorRole))
    174         || (!fRestricted && !m_restrictedAnchorRoles.contains(strAnchorRole)))
    175         return;
    176 
    177     /* Apply new value: */
    178     if (fRestricted)
    179         m_restrictedAnchorRoles << strAnchorRole;
    180     else
    181         m_restrictedAnchorRoles.remove(strAnchorRole);
    182 
    183     /* Reset hovered anchor: */
    184     m_strHoveredAnchor.clear();
    185     updateHoverStuff();
    186 }
    187 
    188 void UIGraphicsTextPane::updateTextLayout(bool fFull /* = false */)
    189 {
    190     /* Prepare variables: */
    191     QFontMetrics fm(font(), m_pPaintDevice);
    192     int iMaximumTextWidth = (int)size().width() - 2 * m_iMargin - m_iSpacing;
    193 
    194     /* Search for the maximum column widths: */
    195     int iMaximumLeftColumnWidth = 0;
    196     int iMaximumRightColumnWidth = 0;
    197     bool fSingleColumnText = true;
    198     foreach (const UITextTableLine &line, m_text)
    199     {
    200         bool fRightColumnPresent = !line.string2().isEmpty();
    201         if (fRightColumnPresent)
    202             fSingleColumnText = false;
    203         QString strLeftLine = fRightColumnPresent ? line.string1() + ":" : line.string1();
    204         QString strRightLine = line.string2();
    205         iMaximumLeftColumnWidth = qMax(iMaximumLeftColumnWidth, fm.width(strLeftLine));
    206         iMaximumRightColumnWidth = qMax(iMaximumRightColumnWidth, fm.width(strRightLine));
    207     }
    208     iMaximumLeftColumnWidth += 1;
    209     iMaximumRightColumnWidth += 1;
    210 
    211     /* Calculate text attributes: */
    212     int iLeftColumnWidth = 0;
    213     int iRightColumnWidth = 0;
    214     /* Left column only: */
    215     if (fSingleColumnText)
    216     {
    217         /* Full update? */
    218         if (fFull)
    219         {
    220             /* Minimum width for left column: */
    221             int iMinimumLeftColumnWidth = qMin(m_iMinimumTextColumnWidth, iMaximumLeftColumnWidth);
    222             /* Minimum width for whole text: */
    223             m_iMinimumTextWidth = iMinimumLeftColumnWidth;
    224         }
    225 
    226         /* Current width for left column: */
    227         iLeftColumnWidth = qMax(m_iMinimumTextColumnWidth, iMaximumTextWidth);
    228     }
    229     /* Two columns: */
    230     else
    231     {
    232         /* Full update? */
    233         if (fFull)
    234         {
    235             /* Minimum width for left column: */
    236             int iMinimumLeftColumnWidth = iMaximumLeftColumnWidth;
    237             /* Minimum width for right column: */
    238             int iMinimumRightColumnWidth = qMin(m_iMinimumTextColumnWidth, iMaximumRightColumnWidth);
    239             /* Minimum width for whole text: */
    240             m_iMinimumTextWidth = iMinimumLeftColumnWidth + m_iSpacing + iMinimumRightColumnWidth;
    241         }
    242 
    243         /* Current width for left column: */
    244         iLeftColumnWidth = iMaximumLeftColumnWidth;
    245         /* Current width for right column: */
    246         iRightColumnWidth = iMaximumTextWidth - iLeftColumnWidth;
    247     }
    248 
    249     /* Clear old text-layouts: */
    250     while (!m_leftList.isEmpty()) delete m_leftList.takeLast();
    251     while (!m_rightList.isEmpty()) delete m_rightList.takeLast();
    252 
    253     /* Prepare new text-layouts: */
    254     int iTextX = m_iMargin;
    255     int iTextY = m_iMargin;
    256     /* Populate text-layouts: */
    257     m_iMinimumTextHeight = 0;
    258     foreach (const UITextTableLine &line, m_text)
    259     {
    260         /* Left layout: */
    261         int iLeftColumnHeight = 0;
    262         if (!line.string1().isEmpty())
    263         {
    264             bool fRightColumnPresent = !line.string2().isEmpty();
    265             m_leftList << buildTextLayout(font(), m_pPaintDevice,
    266                                           fRightColumnPresent ? line.string1() + ":" : line.string1(),
    267                                           iLeftColumnWidth, iLeftColumnHeight,
    268                                           m_strHoveredAnchor);
    269             m_leftList.last()->setPosition(QPointF(iTextX, iTextY));
    270         }
    271 
    272         /* Right layout: */
    273         int iRightColumnHeight = 0;
    274         if (!line.string2().isEmpty())
    275         {
    276             m_rightList << buildTextLayout(font(), m_pPaintDevice,
    277                                            line.string2(),
    278                                            iRightColumnWidth, iRightColumnHeight,
    279                                            m_strHoveredAnchor);
    280             m_rightList.last()->setPosition(QPointF(iTextX + iLeftColumnWidth + m_iSpacing, iTextY));
    281         }
    282 
    283         /* Maximum colum height? */
    284         int iMaximumColumnHeight = qMax(iLeftColumnHeight, iRightColumnHeight);
    285 
    286         /* Indent Y: */
    287         iTextY += iMaximumColumnHeight;
    288         /* Append summary text height: */
    289         m_iMinimumTextHeight += iMaximumColumnHeight;
    290     }
    291 }
    292 
    293 void UIGraphicsTextPane::updateGeometry()
    294 {
    295     /* Discard cached minimum size-hint: */
    296     m_fMinimumSizeHintInvalidated = true;
    297 
    298     /* Call to base-class to notify layout if any: */
    299     QIGraphicsWidget::updateGeometry();
    300 
    301     /* And notify listeners which are not layouts: */
    302     emit sigGeometryChanged();
    303 }
    304 
    305 QSizeF UIGraphicsTextPane::sizeHint(Qt::SizeHint which, const QSizeF &constraint /* = QSizeF() */) const
    306 {
    307     /* For minimum size-hint: */
    308     if (which == Qt::MinimumSize)
    309     {
    310         /* If minimum size-hint invalidated: */
    311         if (m_fMinimumSizeHintInvalidated)
    312         {
    313             /* Recache minimum size-hint: */
    314             m_minimumSizeHint = QSizeF(2 * m_iMargin + m_iMinimumTextWidth,
    315                                        2 * m_iMargin + m_iMinimumTextHeight);
    316             m_fMinimumSizeHintInvalidated = false;
    317         }
    318         /* Return cached minimum size-hint: */
    319         return m_minimumSizeHint;
    320     }
    321     /* Call to base-class for other size-hints: */
    322     return QIGraphicsWidget::sizeHint(which, constraint);
    323 }
    324 
    325 void UIGraphicsTextPane::resizeEvent(QGraphicsSceneResizeEvent*)
    326 {
    327     /* Update text-layout: */
    328     updateTextLayout();
    329 
    330     /* Update minimum size-hint: */
    331     updateGeometry();
    332 }
    333 
    334 void UIGraphicsTextPane::hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent)
    335 {
    336     /* Redirect to common handler: */
    337     handleHoverEvent(pEvent);
    338 }
    339 
    340 void UIGraphicsTextPane::hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent)
    341 {
    342     /* Redirect to common handler: */
    343     handleHoverEvent(pEvent);
    344 }
    345 
    346 void UIGraphicsTextPane::handleHoverEvent(QGraphicsSceneHoverEvent *pEvent)
    347 {
    348     /* Ignore if anchor can't be hovered: */
    349     if (!m_fAnchorCanBeHovered)
    350         return;
    351 
    352     /* Prepare variables: */
    353     QPoint mousePosition = pEvent->pos().toPoint();
    354     QString strHoveredAnchor;
    355     QString strHoveredAnchorRole;
    356 
    357     /* Search for hovered-anchor in the left list: */
    358     strHoveredAnchor = searchForHoveredAnchor(m_pPaintDevice, m_leftList, mousePosition);
    359     strHoveredAnchorRole = strHoveredAnchor.section(',', 0, 0);
    360     if (!strHoveredAnchor.isNull() && !m_restrictedAnchorRoles.contains(strHoveredAnchorRole))
    361     {
    362         m_strHoveredAnchor = strHoveredAnchor;
    363         return updateHoverStuff();
    364     }
    365 
    366     /* Then search for hovered-anchor in the right one: */
    367     strHoveredAnchor = searchForHoveredAnchor(m_pPaintDevice, m_rightList, mousePosition);
    368     strHoveredAnchorRole = strHoveredAnchor.section(',', 0, 0);
    369     if (!strHoveredAnchor.isNull() && !m_restrictedAnchorRoles.contains(strHoveredAnchorRole))
    370     {
    371         m_strHoveredAnchor = strHoveredAnchor;
    372         return updateHoverStuff();
    373     }
    374 
    375     /* Finally clear it for good: */
    376     if (!m_strHoveredAnchor.isNull())
    377     {
    378         m_strHoveredAnchor.clear();
    379         return updateHoverStuff();
    380     }
    381 }
    382 
    383 void UIGraphicsTextPane::updateHoverStuff()
    384 {
    385     /* Update mouse-cursor: */
    386     if (m_strHoveredAnchor.isNull())
    387         VBoxGlobal::unsetCursor(this);
    388     else
    389         VBoxGlobal::setCursor(this, Qt::PointingHandCursor);
    390 
    391     /* Update text-layout: */
    392     updateTextLayout();
    393 
    394     /* Update tool-tip: */
    395     setToolTip(m_strHoveredAnchor.section(',', -1));
    396 
    397     /* Update text-pane: */
    398     update();
    399 }
    400 
    401 void UIGraphicsTextPane::mousePressEvent(QGraphicsSceneMouseEvent*)
    402 {
    403     /* Make sure some anchor hovered: */
    404     if (m_strHoveredAnchor.isNull())
    405         return;
    406 
    407     /* Restrict anchor hovering: */
    408     m_fAnchorCanBeHovered = false;
    409 
    410     /* Cache clicked anchor: */
    411     QString strClickedAnchor = m_strHoveredAnchor;
    412 
    413     /* Clear hovered anchor: */
    414     m_strHoveredAnchor.clear();
    415     updateHoverStuff();
    416 
    417     /* Notify listeners about anchor clicked: */
    418     emit sigAnchorClicked(strClickedAnchor);
    419 
    420     /* Allow anchor hovering again: */
    421     m_fAnchorCanBeHovered = true;
    422 }
    423 
    424 void UIGraphicsTextPane::paint(QPainter *pPainter, const QStyleOptionGraphicsItem*, QWidget*)
    425 {
    426     /* Draw all the text-layouts: */
    427     foreach (QTextLayout *pTextLayout, m_leftList)
    428         pTextLayout->draw(pPainter, QPoint(0, 0));
    429     foreach (QTextLayout *pTextLayout, m_rightList)
    430         pTextLayout->draw(pPainter, QPoint(0, 0));
    431 }
    432 
    433 /* static  */
    434 QTextLayout* UIGraphicsTextPane::buildTextLayout(const QFont &font, QPaintDevice *pPaintDevice,
    435                                                  const QString &strText, int iWidth, int &iHeight,
    436                                                  const QString &strHoveredAnchor)
    437 {
    438     /* Prepare variables: */
    439     QFontMetrics fm(font, pPaintDevice);
    440     int iLeading = fm.leading();
    441 
    442     /* Parse incoming string with UIRichTextString capabilities: */
    443     //printf("Text: {%s}\n", strText.toUtf8().constData());
    444     UIRichTextString ms(strText);
    445     ms.setHoveredAnchor(strHoveredAnchor);
    446 
    447     /* Create layout; */
    448     QTextLayout *pTextLayout = new QTextLayout(ms.toString(), font, pPaintDevice);
    449     pTextLayout->setAdditionalFormats(ms.formatRanges());
    450 
    451     /* Configure layout: */
    452     QTextOption textOption;
    453     textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
    454     pTextLayout->setTextOption(textOption);
    455 
    456     /* Build layout: */
    457     pTextLayout->beginLayout();
    458     while (1)
    459     {
    460         QTextLine line = pTextLayout->createLine();
    461         if (!line.isValid())
    462             break;
    463 
    464         line.setLineWidth(iWidth);
    465         iHeight += iLeading;
    466         line.setPosition(QPointF(0, iHeight));
    467         iHeight += (int)line.height();
    468     }
    469     pTextLayout->endLayout();
    470 
    471     /* Return layout: */
    472     return pTextLayout;
    473 }
    474 
    475 /* static */
    476 QString UIGraphicsTextPane::searchForHoveredAnchor(QPaintDevice *pPaintDevice, const QList<QTextLayout*> &list, const QPoint &mousePosition)
    477 {
    478     /* Analyze passed text-layouts: */
    479     foreach (QTextLayout *pTextLayout, list)
    480     {
    481         /* Prepare variables: */
    482         QFontMetrics fm(pTextLayout->font(), pPaintDevice);
    483 
    484         /* Text-layout attributes: */
    485         const QPoint layoutPosition = pTextLayout->position().toPoint();
    486         const QString strLayoutText = pTextLayout->text();
    487 
    488         /* Enumerate format ranges: */
    489         foreach (const QTextLayout::FormatRange &range, pTextLayout->additionalFormats())
    490         {
    491             /* Skip unrelated formats: */
    492             if (!range.format.isAnchor())
    493                 continue;
    494 
    495             /* Parse 'anchor' format: */
    496             const int iStart = range.start;
    497             const int iLength = range.length;
    498             QRegion formatRegion;
    499             for (int iTextPosition = iStart; iTextPosition < iStart + iLength; ++iTextPosition)
    500             {
    501                 QTextLine layoutLine = pTextLayout->lineForTextPosition(iTextPosition);
    502                 QPoint linePosition = layoutLine.position().toPoint();
    503                 int iSymbolX = (int)layoutLine.cursorToX(iTextPosition);
    504                 QRect symbolRect = QRect(layoutPosition.x() + linePosition.x() + iSymbolX,
    505                                          layoutPosition.y() + linePosition.y(),
    506                                          fm.width(strLayoutText[iTextPosition]) + 1, fm.height());
    507                 formatRegion += symbolRect;
    508             }
    509 
    510             /* Is that something we looking for? */
    511             if (formatRegion.contains(mousePosition))
    512                 return range.format.anchorHref();
    513         }
    514     }
    515 
    516     /* Null string by default: */
    517     return QString();
    518 }
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UITextTable.h

    r77430 r77432  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIGraphicsTextPane class declaration.
     3 * VBox Qt GUI - UITextTable class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_widgets_graphics_UIGraphicsTextPane_h
    19 #define FEQT_INCLUDED_SRC_widgets_graphics_UIGraphicsTextPane_h
     18#ifndef FEQT_INCLUDED_SRC_widgets_graphics_UITextTable_h
     19#define FEQT_INCLUDED_SRC_widgets_graphics_UITextTable_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    3131/** QObject extension used as an
    3232  * accessible wrapper for QString pairs. */
    33 class UITextTableLine : public QObject
     33class SHARED_LIBRARY_STUFF UITextTableLine : public QObject
    3434{
    3535    Q_OBJECT;
     
    9292
    9393
    94 /** QIGraphicsWidget reimplementation to draw QTextLayout content. */
    95 class UIGraphicsTextPane : public QIGraphicsWidget
    96 {
    97     Q_OBJECT;
    98 
    99 signals:
    100 
    101     /** Notifies listeners about size-hint changes. */
    102     void sigGeometryChanged();
    103 
    104     /** Notifies listeners about anchor clicked. */
    105     void sigAnchorClicked(const QString &strAnchor);
    106 
    107 public:
    108 
    109     /** Graphics text-pane constructor. */
    110     UIGraphicsTextPane(QIGraphicsWidget *pParent, QPaintDevice *pPaintDevice);
    111     /** Graphics text-pane destructor. */
    112     ~UIGraphicsTextPane();
    113 
    114     /** Returns whether contained text is empty. */
    115     bool isEmpty() const { return m_text.isEmpty(); }
    116     /** Returns contained text. */
    117     UITextTable &text() { return m_text; }
    118     /** Defines contained text. */
    119     void setText(const UITextTable &text);
    120 
    121     /** Defines whether passed @a strAnchorRole is @a fRestricted. */
    122     void setAnchorRoleRestricted(const QString &strAnchorRole, bool fRestricted);
    123 
    124 private:
    125 
    126     /** Update text-layout. */
    127     void updateTextLayout(bool fFull = false);
    128 
    129     /** Notifies listeners about size-hint changes. */
    130     void updateGeometry();
    131     /** Returns the size-hint to constrain the content. */
    132     QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
    133 
    134     /** This event handler is delivered after the widget has been resized. */
    135     void resizeEvent(QGraphicsSceneResizeEvent *pEvent);
    136 
    137     /** This event handler called when mouse hovers widget. */
    138     void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent);
    139     /** This event handler called when mouse leaves widget. */
    140     void hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent);
    141     /** Summarize two hover-event handlers above. */
    142     void handleHoverEvent(QGraphicsSceneHoverEvent *pEvent);
    143     /** Update hover stuff. */
    144     void updateHoverStuff();
    145 
    146     /** This event handler called when mouse press widget. */
    147     void mousePressEvent(QGraphicsSceneMouseEvent *pEvent);
    148 
    149     /** Paints the contents in local coordinates. */
    150     void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget *pWidget = 0);
    151 
    152     /** Builds new text-layout. */
    153     static QTextLayout* buildTextLayout(const QFont &font, QPaintDevice *pPaintDevice,
    154                                         const QString &strText, int iWidth, int &iHeight,
    155                                         const QString &strHoveredAnchor);
    156 
    157     /** Search for hovered anchor in passed text-layout @a list. */
    158     static QString searchForHoveredAnchor(QPaintDevice *pPaintDevice, const QList<QTextLayout*> &list, const QPoint &mousePosition);
    159 
    160     /** Paint-device to scale to. */
    161     QPaintDevice *m_pPaintDevice;
    162 
    163     /** Margin. */
    164     const int m_iMargin;
    165     /** Spacing. */
    166     const int m_iSpacing;
    167     /** Minimum text-column width: */
    168     const int m_iMinimumTextColumnWidth;
    169 
    170     /** Minimum size-hint invalidation flag. */
    171     mutable bool m_fMinimumSizeHintInvalidated;
    172     /** Minimum size-hint cache. */
    173     mutable QSizeF m_minimumSizeHint;
    174     /** Minimum text-width. */
    175     int m_iMinimumTextWidth;
    176     /** Minimum text-height. */
    177     int m_iMinimumTextHeight;
    178 
    179     /** Contained text. */
    180     UITextTable m_text;
    181     /** Left text-layout list. */
    182     QList<QTextLayout*> m_leftList;
    183     /** Right text-layout list. */
    184     QList<QTextLayout*> m_rightList;
    185 
    186     /** Holds whether anchor can be hovered. */
    187     bool m_fAnchorCanBeHovered;
    188     /** Holds restricted anchor roles. */
    189     QSet<QString> m_restrictedAnchorRoles;
    190     /** Holds currently hovered anchor. */
    191     QString m_strHoveredAnchor;
    192 };
    193 
    194 #endif /* !FEQT_INCLUDED_SRC_widgets_graphics_UIGraphicsTextPane_h */
    195 
     94#endif /* !FEQT_INCLUDED_SRC_widgets_graphics_UITextTable_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElement.h

    r76581 r77432  
    2828#include "UIDetailsItem.h"
    2929#include "UIExtraDataDefs.h"
     30#include "UITextTable.h"
    3031
    3132/* Forward declarations: */
     
    3637class UIGraphicsRotatorButton;
    3738class UIGraphicsTextPane;
    38 class UITextTableLine;
    3939class CMachine;
    4040
    41 /* Typedefs: */
    42 typedef QList<UITextTableLine> UITextTable;
    4341
    4442/** UIDetailsItem extension implementing element item. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationItem.cpp

    r76606 r77432  
    7070    {
    7171        /* Lines: */
    72         const QString strLeftLine = line.first;
    73         const QString strRightLine = line.second;
     72        const QString strLeftLine = line.string1();
     73        const QString strRightLine = line.string2();
    7474
    7575        /* If 2nd line is NOT empty: */
     
    166166        /* Parse lines from text and add it to text: */
    167167        foreach (const UITextTableLine &line, m_text)
    168             item = item + QString(sSectionItemTpl2).arg(line.first, line.second);
     168            item = item + QString(sSectionItemTpl2).arg(line.string1(), line.string2());
    169169
    170170        /* Format the entire item: */
     
    188188    m_pTextDocument->setHtml(report);
    189189}
    190 
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationItem.h

    r76581 r77432  
    2828#include "QIWithRetranslateUI.h"
    2929#include "UIExtraDataDefs.h"
     30#include "UITextTable.h"
    3031
    3132/* Forward declarations: */
    3233class QStyleOptionViewItem;
    3334class QTextDocument;
    34 
    35 /* Type definitions: */
    36 typedef QPair<QString, QString> UITextTableLine;
    37 typedef QList<UITextTableLine> UITextTable;
    38 
    39 Q_DECLARE_METATYPE(UITextTable);
    4035
    4136
     
    9893
    9994#endif /* !FEQT_INCLUDED_SRC_runtime_information_UIInformationItem_h */
    100 
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsTextPane.cpp

    r76606 r77432  
    3232#include <iprt/assert.h>
    3333
    34 
    3534/** QAccessibleObject extension used as an accessibility interface for UITextTableLine. */
    3635class UIAccessibilityInterfaceForUITextTableLine : public QAccessibleObject
     
    106105    UITextTableLine *line() const { return qobject_cast<UITextTableLine*>(object()); }
    107106};
    108 
    109107
    110108UIGraphicsTextPane::UIGraphicsTextPane(QIGraphicsWidget *pParent, QPaintDevice *pPaintDevice)
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsTextPane.h

    r76581 r77432  
    2424/* GUI includes: */
    2525#include "QIGraphicsWidget.h"
     26#include "UITextTable.h"
    2627
    2728/* Forward declarations: */
    2829class QTextLayout;
    29 
    30 
    31 /** QObject extension used as an
    32   * accessible wrapper for QString pairs. */
    33 class UITextTableLine : public QObject
    34 {
    35     Q_OBJECT;
    36 
    37 public:
    38 
    39     /** Constructs text-table line passing @a pParent to the base-class.
    40       * @param  str1  Brings the 1st table string.
    41       * @param  str2  Brings the 2nd table string. */
    42     UITextTableLine(const QString &str1, const QString &str2, QObject *pParent = 0)
    43         : QObject(pParent)
    44         , m_str1(str1)
    45         , m_str2(str2)
    46     {}
    47 
    48     /** Constructs text-table line on the basis of passed @a other. */
    49     UITextTableLine(const UITextTableLine &other)
    50         : QObject(other.parent())
    51         , m_str1(other.string1())
    52         , m_str2(other.string2())
    53     {}
    54 
    55     /** Assigns @a other to this. */
    56     UITextTableLine &operator=(const UITextTableLine &other)
    57     {
    58         setParent(other.parent());
    59         set1(other.string1());
    60         set2(other.string2());
    61         return *this;
    62     }
    63 
    64     /** Compares @a other to this. */
    65     bool operator==(const UITextTableLine &other) const
    66     {
    67         return string1() == other.string1()
    68             && string2() == other.string2();
    69     }
    70 
    71     /** Defines 1st table @a strString. */
    72     void set1(const QString &strString) { m_str1 = strString; }
    73     /** Returns 1st table string. */
    74     const QString &string1() const { return m_str1; }
    75 
    76     /** Defines 2nd table @a strString. */
    77     void set2(const QString &strString) { m_str2 = strString; }
    78     /** Returns 2nd table string. */
    79     const QString &string2() const { return m_str2; }
    80 
    81 private:
    82 
    83     /** Holds the 1st table string. */
    84     QString m_str1;
    85     /** Holds the 2nd table string. */
    86     QString m_str2;
    87 };
    88 
    89 /** Defines the list of UITextTableLine instances. */
    90 typedef QList<UITextTableLine> UITextTable;
    91 Q_DECLARE_METATYPE(UITextTable);
    9230
    9331
     
    193131
    194132#endif /* !FEQT_INCLUDED_SRC_widgets_graphics_UIGraphicsTextPane_h */
    195 
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette