11// This file implements accessibility interface for RegistersView
22#ifndef QT_NO_ACCESSIBILITY
33#include " AccessibleRegistersView.h"
4+ #include " StringUtil.h"
45
56AccessibleRegistersViewItem::AccessibleRegistersViewItem (AccessibleRegistersView* parent, RegistersView::REGISTER_NAME id) : mParent(parent), id(id)
67{
@@ -96,7 +97,35 @@ void AccessibleRegistersViewItem::setText(QAccessible::Text t, const QString & t
9697
9798QRect AccessibleRegistersViewItem::rect () const
9899{
99- return QRect ();
100+ QRect rect;
101+ const RegistersView* parent = mParent ->m_registersView ;
102+ const auto & it = parent->mRegisterPlaces .constFind (id);
103+ if (it == parent->mRegisterPlaces .cend ())
104+ {
105+ return rect;
106+ }
107+ int top, bottom, left, right;
108+ top = it.value ().line * parent->mRowHeight + parent->yTopSpacing ;
109+ bottom = top + parent->mRowHeight ;
110+ // These registers occupy a whole line
111+ if (it.key () >= RegistersView::CAX && it.key () <= RegistersView::EFLAGS
112+ || it.key () >= RegistersView::MM0 && it.key () <= RegistersView::MM7
113+ || it.key () >= RegistersView::DR0 && it.key () <= RegistersView::DR7
114+ || it.key () >= RegistersView::K0 && it.key () <= RegistersView::K7
115+ || it.key () >= RegistersView::XMM0 && it.key () <= ArchValue (RegistersView::XMM7, RegistersView::XMM31))
116+ {
117+ const QScrollArea* upperScrollArea = (const QScrollArea*)parent->parentWidget ()->parentWidget ();
118+ left = 0 ;
119+ right = upperScrollArea->width ();
120+ }
121+ else
122+ {
123+ left = (1 + it.value ().start ) * parent->mCharWidth ;
124+ right = left + ((it.value ().labelwidth + it.value ().valuesize ) * parent->mCharWidth );
125+ }
126+ const QPoint TL = parent->mapToGlobal (QPoint (left, top));
127+ const QPoint BR = parent->mapToGlobal (QPoint (right, bottom));
128+ return QRect (TL, BR);
100129}
101130
102131bool AccessibleRegistersViewItem::isValid () const
@@ -149,7 +178,7 @@ QAccessibleInterface* AccessibleRegistersView::childAt(int x, int y) const
149178{
150179 RegistersView::REGISTER_NAME clickedReg;
151180 QPoint local = m_registersView->mapFromGlobal (QPoint (x, y));
152- if (m_registersView->identifyRegister (local.y (), local.x (), &clickedReg))
181+ if (m_registersView->identifyRegister (( local.y () - m_registersView-> yTopSpacing ) / ( double )m_registersView-> mRowHeight , local.x () / ( double )m_registersView-> mCharWidth , &clickedReg))
153182 if (clickedReg < RegistersView::UNKNOWN)
154183 return child (static_cast <int >(clickedReg));
155184 return (QAccessibleInterface*)this ;
@@ -186,4 +215,18 @@ QAccessible::State AccessibleRegistersView::state() const
186215 state.hasPopup = true ;
187216 return state;
188217}
218+
219+ QRect AccessibleRegistersView::rect () const
220+ {
221+ QRect rect;
222+ const QScrollArea* upperScrollArea = (const QScrollArea*)m_registersView->parentWidget ()->parentWidget ();
223+ int top, bottom, left, right;
224+ top = 0 ;
225+ bottom = upperScrollArea->height ();
226+ left = 0 ;
227+ right = upperScrollArea->width ();
228+ const QPoint TL = upperScrollArea->mapToGlobal (QPoint (left, top));
229+ const QPoint BR = upperScrollArea->mapToGlobal (QPoint (right, bottom));
230+ return QRect (TL, BR);
231+ }
189232#endif
0 commit comments