~ubuntu-branches/ubuntu/quantal/kdepim/quantal

« back to all changes in this revision

Viewing changes to messageviewer/a11y/accessiblemailwebview.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-15 14:17:51 UTC
  • mto: This revision was merged to the branch mainline in revision 193.
  • Revision ID: package-import@ubuntu.com-20111215141751-bmhdpiwl23wd9w26
Tags: upstream-4.7.90
Import upstream version 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright 2011  José Millán Soto <fid@gpul.org>
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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/>.
 
16
 */
 
17
 
 
18
#include "accessiblemailwebview.h"
 
19
#include "messageviewer/mailwebview.h"
 
20
 
 
21
#include <QWebFrame>
 
22
 
 
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 );
 
30
#endif
 
31
 
 
32
AccessibleMailWebView::AccessibleMailWebView( MessageViewer::MailWebView* widget ):
 
33
  QAccessibleWidgetEx( widget, QAccessible::Document )
 
34
{
 
35
  m_widget = widget;
 
36
}
 
37
 
 
38
 
 
39
int AccessibleMailWebView::characterCount()
 
40
{
 
41
  return m_widget->page()->mainFrame()->toPlainText().size();
 
42
}
 
43
 
 
44
int AccessibleMailWebView::selectionCount()
 
45
{
 
46
#if QT_VERSION >= 0x40800
 
47
  return m_widget->hasSelection() ? 1 : 0;
 
48
#else
 
49
  return 0;
 
50
#endif
 
51
}
 
52
 
 
53
void AccessibleMailWebView::addSelection( int startOffset, int endOffset )
 
54
{
 
55
}
 
56
 
 
57
void AccessibleMailWebView::removeSelection( int selectionIndex )
 
58
{
 
59
#if QT_VERSION >= 0x40800
 
60
  if ( selectionIndex == 0 )
 
61
    m_widget->clearSelection();
 
62
#endif
 
63
}
 
64
 
 
65
void AccessibleMailWebView::setSelection( int selectionIndex, int startOffset, int endOffset )
 
66
{
 
67
}
 
68
 
 
69
void AccessibleMailWebView::setCursorPosition( int position )
 
70
{
 
71
}
 
72
 
 
73
QString AccessibleMailWebView::text( int startOffset, int endOffset )
 
74
{
 
75
  QString text = m_widget->page()->mainFrame()->toPlainText();
 
76
  text.truncate( endOffset );
 
77
  text.remove( 0, startOffset );
 
78
  return text;
 
79
}
 
80
 
 
81
QString AccessibleMailWebView::attributes( int offset, int* startOffset, int* endOffset )
 
82
{
 
83
  return QString();
 
84
}
 
85
 
 
86
void AccessibleMailWebView::selection( int selectionIndex, int* startOffset, int* endOffset )
 
87
{
 
88
  *startOffset = -1;
 
89
  *endOffset = -1;
 
90
}
 
91
 
 
92
QRect AccessibleMailWebView::characterRect( int offset, QAccessible2::CoordinateType coordType )
 
93
{
 
94
  return QRect();
 
95
}
 
96
 
 
97
int AccessibleMailWebView::offsetAtPoint( const QPoint& point, QAccessible2::CoordinateType coordType )
 
98
{
 
99
  return 0;
 
100
}
 
101
 
 
102
int AccessibleMailWebView::cursorPosition()
 
103
{
 
104
  return 0;
 
105
}
 
106
 
 
107
void AccessibleMailWebView::scrollToSubstring( int startIndex, int endIndex )
 
108
{
 
109
}
 
110
 
 
111
QString AccessibleMailWebView::textAfterOffset( int offset, QAccessible2::BoundaryType boundaryType, int* startOffset, int* endOffset )
 
112
{
 
113
#if QT_VERSION >= 0x40800
 
114
  return qTextAfterOffsetFromString( offset, boundaryType, startOffset, endOffset, m_widget->page()->mainFrame()->toPlainText() );
 
115
#else
 
116
  return QString();
 
117
#endif
 
118
}
 
119
 
 
120
QString AccessibleMailWebView::textBeforeOffset( int offset, QAccessible2::BoundaryType boundaryType, int* startOffset, int* endOffset )
 
121
{
 
122
#if QT_VERSION >= 0x40800
 
123
  return qTextBeforeOffsetFromString( offset, boundaryType, startOffset, endOffset, m_widget->page()->mainFrame()->toPlainText() );
 
124
#else
 
125
  return QString();
 
126
#endif
 
127
}
 
128
 
 
129
QString AccessibleMailWebView::textAtOffset( int offset, QAccessible2::BoundaryType boundaryType, int* startOffset, int* endOffset )
 
130
{
 
131
#if QT_VERSION >= 0x40800
 
132
  return qTextAtOffsetFromString( offset, boundaryType, startOffset, endOffset, m_widget->page()->mainFrame()->toPlainText() );
 
133
#else
 
134
  return QString();
 
135
#endif
 
136
}