Qt 4.8
Functions
simplewidgets.cpp File Reference
#include "simplewidgets.h"
#include <qabstractbutton.h>
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qprogressbar.h>
#include <qstatusbar.h>
#include <qradiobutton.h>
#include <qtoolbutton.h>
#include <qlabel.h>
#include <qgroupbox.h>
#include <qlcdnumber.h>
#include <qtextdocument.h>
#include <qlineedit.h>
#include <private/qlineedit_p.h>
#include <qstyle.h>
#include <qstyleoption.h>
#include <qfocusframe.h>

Go to the source code of this file.

Functions

QList< QWidget * > childWidgets (const QWidget *widget, bool includeTopLevel=false)
 
QString Q_GUI_EXPORT qt_accHotKey (const QString &text)
 
QString Q_GUI_EXPORT qt_accStripAmp (const QString &text)
 
QString Q_GUI_EXPORT qTextAfterOffsetFromString (int offset, QAccessible2::BoundaryType boundaryType, int *startOffset, int *endOffset, const QString &text)
 
QString Q_GUI_EXPORT qTextAtOffsetFromString (int offset, QAccessible2::BoundaryType boundaryType, int *startOffset, int *endOffset, const QString &text)
 
QString Q_GUI_EXPORT qTextBeforeOffsetFromString (int offset, QAccessible2::BoundaryType boundaryType, int *startOffset, int *endOffset, const QString &text)
 

Function Documentation

◆ childWidgets()

QList<QWidget*> childWidgets ( const QWidget widget,
bool  includeTopLevel = false 
)

Definition at line 80 of file qaccessiblewidgets.cpp.

Referenced by QAccessibleMainWindow::childAt(), QAccessibleMainWindow::childCount(), QAccessibleMainWindow::indexOfChild(), and QAccessibleMainWindow::navigate().

81 {
82  if (widget == 0)
83  return QList<QWidget*>();
84  QList<QObject*> list = widget->children();
85  QList<QWidget*> widgets;
86  for (int i = 0; i < list.size(); ++i) {
87  QWidget *w = qobject_cast<QWidget *>(list.at(i));
88  if (!w)
89  continue;
90  QString objectName = w->objectName();
91  if ((includeTopLevel || !w->isWindow())
92  && !qobject_cast<QFocusFrame*>(w)
93  && !qobject_cast<QMenu*>(w)
94  && objectName != QLatin1String("qt_rubberband")
95  && objectName != QLatin1String("qt_qmainwindow_extended_splitter")) {
96  widgets.append(w);
97  }
98  }
99  return widgets;
100 }
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QString objectName() const
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197

◆ qt_accHotKey()

QString Q_GUI_EXPORT qt_accHotKey ( const QString text)

Definition at line 145 of file qaccessiblewidget.cpp.

Referenced by QAccessibleButton::text(), and QAccessibleWidget::text().

146 {
147  int ampIndex = qt_accAmpIndex(text);
148  if (ampIndex != -1)
149  return (QString)QKeySequence(Qt::ALT) + text.at(ampIndex + 1);
150 
151  return QString();
152 }
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
The QString class provides a Unicode character string.
Definition: qstring.h:83
static int qt_accAmpIndex(const QString &text)
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:72

◆ qt_accStripAmp()

QString Q_GUI_EXPORT qt_accStripAmp ( const QString text)

Definition at line 135 of file qaccessiblewidget.cpp.

Referenced by QAccessibleButton::text(), QAccessibleWidget::text(), QAccessibleToolButton::text(), QAccessibleDisplay::text(), QAccessibleGroupBox::text(), and QAccessibleLineEdit::text().

136 {
137  QString newText(text);
138  int ampIndex = qt_accAmpIndex(newText);
139  if (ampIndex != -1)
140  newText.remove(ampIndex, 1);
141 
142  return newText.replace(QLatin1String("&&"), QLatin1String("&"));
143 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
static int qt_accAmpIndex(const QString &text)

◆ qTextAfterOffsetFromString()

QString Q_GUI_EXPORT qTextAfterOffsetFromString ( int  offset,
QAccessible2::BoundaryType  boundaryType,
int *  startOffset,
int *  endOffset,
const QString text 
)
Warning
This function is not part of the public interface.

Definition at line 199 of file qaccessible2.cpp.

Referenced by QAccessibleLineEdit::textAfterOffset().

201 {
203  switch (boundaryType) {
206  break;
209  break;
212  break;
213  default:
214  // in any other case return the whole line
215  *startOffset = 0;
216  *endOffset = text.length();
217  return text;
218  }
219 
220  QTextBoundaryFinder boundary(type, text);
221  boundary.setPosition(offset);
222 
223  boundary.toNextBoundary();
224  *startOffset = boundary.position();
225  boundary.toNextBoundary();
226  *endOffset = boundary.position();
227 
228  return text.mid(*startOffset, *endOffset - *startOffset);
229 }
int type
Definition: qmetatype.cpp:239
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
The QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string...
#define text
Definition: qobjectdefs.h:80

◆ qTextAtOffsetFromString()

QString Q_GUI_EXPORT qTextAtOffsetFromString ( int  offset,
QAccessible2::BoundaryType  boundaryType,
int *  startOffset,
int *  endOffset,
const QString text 
)
Warning
This function is not part of the public interface.

Definition at line 234 of file qaccessible2.cpp.

Referenced by QAccessibleLineEdit::textAtOffset().

236 {
238  switch (boundaryType) {
241  break;
244  break;
247  break;
248  default:
249  // in any other case return the whole line
250  *startOffset = 0;
251  *endOffset = text.length();
252  return text;
253  }
254 
255  QTextBoundaryFinder boundary(type, text);
256  boundary.setPosition(offset);
257 
258  if (!boundary.isAtBoundary()) {
259  boundary.toPreviousBoundary();
260  }
261  *startOffset = boundary.position();
262  boundary.toNextBoundary();
263  *endOffset = boundary.position();
264 
265  return text.mid(*startOffset, *endOffset - *startOffset);
266 }
int type
Definition: qmetatype.cpp:239
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
The QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string...
#define text
Definition: qobjectdefs.h:80

◆ qTextBeforeOffsetFromString()

QString Q_GUI_EXPORT qTextBeforeOffsetFromString ( int  offset,
QAccessible2::BoundaryType  boundaryType,
int *  startOffset,
int *  endOffset,
const QString text 
)
Warning
This function is not part of the public interface.

Definition at line 161 of file qaccessible2.cpp.

Referenced by QAccessibleLineEdit::textBeforeOffset().

163 {
165  switch (boundaryType) {
168  break;
171  break;
174  break;
175  default:
176  // in any other case return the whole line
177  *startOffset = 0;
178  *endOffset = text.length();
179  return text;
180  }
181 
182  QTextBoundaryFinder boundary(type, text);
183  boundary.setPosition(offset);
184 
185  if (!boundary.isAtBoundary()) {
186  boundary.toPreviousBoundary();
187  }
188  boundary.toPreviousBoundary();
189  *startOffset = boundary.position();
190  boundary.toNextBoundary();
191  *endOffset = boundary.position();
192 
193  return text.mid(*startOffset, *endOffset - *startOffset);
194 }
int type
Definition: qmetatype.cpp:239
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
The QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string...
#define text
Definition: qobjectdefs.h:80