2
Copyright 2011 José Millán Soto <fid@gpul.org>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Lesser General Public
6
License as published by the Free Software Foundation; either
7
version 2.1 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Lesser General Public License for more details.
14
You should have received a copy of the GNU Lesser General Public
15
License along with this library. If not, see <http://www.gnu.org/licenses/>.
18
#include "accessiblemailwebview.h"
19
#include "messageviewer/mailwebview.h"
23
#if QT_VERSION >= 0x40800
24
QString Q_GUI_EXPORT qTextAfterOffsetFromString( int offset, QAccessible2::BoundaryType boundaryType,
25
int *startOffset, int *endOffset, const QString& text );
26
QString Q_GUI_EXPORT qTextBeforeOffsetFromString( int offset, QAccessible2::BoundaryType boundaryType,
27
int *startOffset, int *endOffset, const QString& text );
28
QString Q_GUI_EXPORT qTextAtOffsetFromString( int offset, QAccessible2::BoundaryType boundaryType,
29
int *startOffset, int *endOffset, const QString& text );
32
AccessibleMailWebView::AccessibleMailWebView( MessageViewer::MailWebView* widget ):
33
QAccessibleWidgetEx( widget, QAccessible::Document )
39
int AccessibleMailWebView::characterCount()
41
return m_widget->page()->mainFrame()->toPlainText().size();
44
int AccessibleMailWebView::selectionCount()
46
#if QT_VERSION >= 0x40800
47
return m_widget->hasSelection() ? 1 : 0;
53
void AccessibleMailWebView::addSelection( int startOffset, int endOffset )
57
void AccessibleMailWebView::removeSelection( int selectionIndex )
59
#if QT_VERSION >= 0x40800
60
if ( selectionIndex == 0 )
61
m_widget->clearSelection();
65
void AccessibleMailWebView::setSelection( int selectionIndex, int startOffset, int endOffset )
69
void AccessibleMailWebView::setCursorPosition( int position )
73
QString AccessibleMailWebView::text( int startOffset, int endOffset )
75
QString text = m_widget->page()->mainFrame()->toPlainText();
76
text.truncate( endOffset );
77
text.remove( 0, startOffset );
81
QString AccessibleMailWebView::attributes( int offset, int* startOffset, int* endOffset )
86
void AccessibleMailWebView::selection( int selectionIndex, int* startOffset, int* endOffset )
92
QRect AccessibleMailWebView::characterRect( int offset, QAccessible2::CoordinateType coordType )
97
int AccessibleMailWebView::offsetAtPoint( const QPoint& point, QAccessible2::CoordinateType coordType )
102
int AccessibleMailWebView::cursorPosition()
107
void AccessibleMailWebView::scrollToSubstring( int startIndex, int endIndex )
111
QString AccessibleMailWebView::textAfterOffset( int offset, QAccessible2::BoundaryType boundaryType, int* startOffset, int* endOffset )
113
#if QT_VERSION >= 0x40800
114
return qTextAfterOffsetFromString( offset, boundaryType, startOffset, endOffset, m_widget->page()->mainFrame()->toPlainText() );
120
QString AccessibleMailWebView::textBeforeOffset( int offset, QAccessible2::BoundaryType boundaryType, int* startOffset, int* endOffset )
122
#if QT_VERSION >= 0x40800
123
return qTextBeforeOffsetFromString( offset, boundaryType, startOffset, endOffset, m_widget->page()->mainFrame()->toPlainText() );
129
QString AccessibleMailWebView::textAtOffset( int offset, QAccessible2::BoundaryType boundaryType, int* startOffset, int* endOffset )
131
#if QT_VERSION >= 0x40800
132
return qTextAtOffsetFromString( offset, boundaryType, startOffset, endOffset, m_widget->page()->mainFrame()->toPlainText() );