📄 qaccessiblecompat.cpp
字号:
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the plugins of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file. Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "qaccessiblecompat.h"#include "q3widgetstack.h"#include <q3listview.h>#include <q3textedit.h>#include <q3iconview.h>#include <q3listbox.h>/*!\fn Q3AccessibleScrollView::Q3AccessibleScrollView(QWidget* widget, Role role)Constructs a Q3AccessibleScrollView object for a \a widget.The \a role is propagated to the QAccessibleWidget constructor.*/Q3AccessibleScrollView::Q3AccessibleScrollView(QWidget *w, Role role): QAccessibleWidget(w, role){}/*! Returns the ID of the item at viewport position \a x, \a y.*/int Q3AccessibleScrollView::itemAt(int /*x*/, int /*y*/) const{ return 0;}/*! Returns the location in viewport coordinates of the item with ID \a item.*/QRect Q3AccessibleScrollView::itemRect(int /*item*/) const{ return QRect();}/*! Returns the number of items in the scroll view.*/int Q3AccessibleScrollView::itemCount() const{ return 0;}/*! \class QAccessibleListView qaccessiblewidget.h \brief The QAccessibleListView class implements the QAccessibleInterface for list views. \internal*/static Q3ListViewItem *findLVItem(Q3ListView* listView, int child){ int id = 1; Q3ListViewItemIterator it(listView); Q3ListViewItem *item = it.current(); while (item && id < child) { ++it; ++id; item = it.current(); } return item;}/*! \fn QAccessibleListView::QAccessibleListView(QWidget* widget) Constructs a QAccessibleListView object for a \a widget.*/QAccessibleListView::QAccessibleListView(QWidget *o) : Q3AccessibleScrollView(o, Tree){}/*! Returns the list view. */Q3ListView *QAccessibleListView::listView() const{ Q_ASSERT(widget()->inherits("Q3ListView")); return (Q3ListView*)widget();}/*! \reimp */int QAccessibleListView::itemAt(int x, int y) const{ Q3ListViewItem *item = listView()->itemAt(QPoint(x, y)); if (!item) return 0; Q3ListViewItemIterator it(listView()); int c = 1; while (it.current()) { if (it.current() == item) return c; ++c; ++it; } return 0;}/*! \reimp */QRect QAccessibleListView::itemRect(int child) const{ Q3ListViewItem *item = findLVItem(listView(), child); if (!item) return QRect(); return listView()->itemRect(item);}/*! \reimp */int QAccessibleListView::itemCount() const{ Q3ListViewItemIterator it(listView()); int c = 0; while (it.current()) { ++c; ++it; } return c;}/*! \reimp */QString QAccessibleListView::text(Text t, int child) const{ if (!child || t != Name) return Q3AccessibleScrollView::text(t, child); Q3ListViewItem *item = findLVItem(listView(), child); if (!item) return QString(); return item->text(0);}/*! \reimp */QAccessible::Role QAccessibleListView::role(int child) const{ if (!child) return Q3AccessibleScrollView::role(child); return TreeItem;}/*! \reimp */QAccessible::State QAccessibleListView::state(int child) const{ State state = Q3AccessibleScrollView::state(child); Q3ListViewItem *item; if (!child || !(item = findLVItem(listView(), child))) return state; if (item->isSelectable()) { if (listView()->selectionMode() == Q3ListView::Multi) state |= MultiSelectable; else if (listView()->selectionMode() == Q3ListView::Extended) state |= ExtSelectable; else if (listView()->selectionMode() == Q3ListView::Single) state |= Selectable; if (item->isSelected()) state |= Selected; } if (listView()->focusPolicy() != Qt::NoFocus) { state |= Focusable; if (item == listView()->currentItem()) state |= Focused; } if (item->childCount()) { if (item->isOpen()) state |= Expanded; else state |= Collapsed; } if (!listView()->itemRect(item).isValid()) state |= Invisible; if (item->rtti() == Q3CheckListItem::RTTI) { if (((Q3CheckListItem*)item)->isOn()) state|=Checked; } return state;}/* \reimpQAccessibleInterface *QAccessibleListView::focusChild(int *child) const{ Q3ListViewItem *item = listView()->currentItem(); if (!item) return 0; Q3ListViewItemIterator it(listView()); int c = 1; while (it.current()) { if (it.current() == item) { *child = c; return (QAccessibleInterface*)this; } ++c; ++it; } return 0;}*//* \reimpbool QAccessibleListView::setFocus(int child){ bool res = Q3AccessibleScrollView::setFocus(0); if (!child || !res) return res; Q3ListViewItem *item = findLVItem(listView(), child); if (!item) return false; listView()->setCurrentItem(item); return true;}*//*! \internal */bool QAccessibleListView::setSelected(int child, bool on, bool extend){ if (!child || (extend && listView()->selectionMode() != Q3ListView::Extended && listView()->selectionMode() != Q3ListView::Multi)) return false; Q3ListViewItem *item = findLVItem(listView(), child); if (!item) return false; if (!extend) { listView()->setSelected(item, on); } else { Q3ListViewItem *current = listView()->currentItem(); if (!current) return false; bool down = item->itemPos() > current->itemPos(); Q3ListViewItemIterator it(current); while (it.current()) { listView()->setSelected(it.current(), on); if (it.current() == item) break; if (down) ++it; else --it; } } return true;}/*! \internal */void QAccessibleListView::clearSelection(){ listView()->clearSelection();}/*! \internal */QVector<int> QAccessibleListView::selection() const{ QVector<int> array; uint size = 0; int id = 1; array.resize(size); Q3ListViewItemIterator it(listView()); while (it.current()) { if (it.current()->isSelected()) { ++size; array.resize(size); array[(int)size-1] = id; } ++it; ++id; } return array;}/*! \class QAccessibleIconView qaccessiblewidget.h \brief The QAccessibleIconView class implements the QAccessibleInterface for icon views. \internal*/static Q3IconViewItem *findIVItem(Q3IconView *iconView, int child){ int id = 1; Q3IconViewItem *item = iconView->firstItem(); while (item && id < child) { item = item->nextItem(); ++id; } return item;}/*! \fn QAccessibleIconView::QAccessibleIconView(QWidget* widget) Constructs a QAccessibleIconView object for a \a widget.*/QAccessibleIconView::QAccessibleIconView(QWidget *o) : Q3AccessibleScrollView(o, List){ Q_ASSERT(widget()->inherits("Q3IconView"));}/*! Returns the icon view. */Q3IconView *QAccessibleIconView::iconView() const{ return (Q3IconView*)widget();}/*! \internal */int QAccessibleIconView::itemAt(int x, int y) const{ Q3IconViewItem *item = iconView()->findItem(QPoint(x, y)); return iconView()->index(item) + 1;}/*! \internal */QRect QAccessibleIconView::itemRect(int child) const{ Q3IconViewItem *item = findIVItem(iconView(), child); if (!item) return QRect(); return item->rect();}/*! \internal */int QAccessibleIconView::itemCount() const{ return iconView()->count();}/*! \internal */QString QAccessibleIconView::text(Text t, int child) const{ if (!child || t != Name) return Q3AccessibleScrollView::text(t, child); Q3IconViewItem *item = findIVItem(iconView(), child); if (!item) return QString(); return item->text();}/*! \internal */QAccessible::Role QAccessibleIconView::role(int child) const{ if (!child) return Q3AccessibleScrollView::role(child); return ListItem;}/*! \internal */QAccessible::State QAccessibleIconView::state(int child) const{ State state = Q3AccessibleScrollView::state(child); Q3IconViewItem *item; if (!child || !(item = findIVItem(iconView(), child))) return state; if (item->isSelectable()) { if (iconView()->selectionMode() == Q3IconView::Multi) state |= MultiSelectable; else if (iconView()->selectionMode() == Q3IconView::Extended) state |= ExtSelectable; else if (iconView()->selectionMode() == Q3IconView::Single) state |= Selectable; if (item->isSelected()) state |= Selected; } if (iconView()->itemsMovable()) state |= Movable; if (iconView()->focusPolicy() != Qt::NoFocus) { state |= Focusable; if (item == iconView()->currentItem()) state |= Focused; } return state;}/* \reimpQAccessibleInterface *QAccessibleIconView::focusChild(int *child) const{ Q3IconViewItem *item = iconView()->currentItem();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -