~timo-jyrinki/ubuntu/trusty/maliit-framework/fix_qt52

« back to all changes in this revision

Viewing changes to src/minputmethodhost.cpp

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2013-01-31 13:26:48 UTC
  • Revision ID: package-import@ubuntu.com-20130131132648-w1u9d2279tppxcft
Tags: upstream-0.94.1
ImportĀ upstreamĀ versionĀ 0.94.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* * This file is part of Maliit framework *
 
2
 *
 
3
 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 
4
 * All rights reserved.
 
5
 *
 
6
 * Contact: maliit-discuss@lists.maliit.org
 
7
 *
 
8
 * This library is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU Lesser General Public
 
10
 * License version 2.1 as published by the Free Software Foundation
 
11
 * and appearing in the file LICENSE.LGPL included in the packaging
 
12
 * of this file.
 
13
 */
 
14
 
 
15
#include "minputmethodhost.h"
 
16
#include "minputcontextconnection.h"
 
17
#include "mimpluginmanager.h"
 
18
#include "mindicatorserviceclient.h"
 
19
#include <maliit/plugins/abstractinputmethod.h>
 
20
 
 
21
#include <QWidget>
 
22
#include <QGraphicsView>
 
23
 
 
24
#include <maliit/namespace.h>
 
25
 
 
26
MInputMethodHost::MInputMethodHost(const QSharedPointer<MInputContextConnection> &inputContextConnection,
 
27
                                   MIMPluginManager *pluginManager,
 
28
                                   MIndicatorServiceClient &indicatorService,
 
29
                                   AbstractSurfaceFactory *surfaceFactory,
 
30
                                   const QString &plugin,
 
31
                                   const QString &description)
 
32
    : MAbstractInputMethodHost(),
 
33
      connection(inputContextConnection),
 
34
      pluginManager(pluginManager),
 
35
      inputMethod(0),
 
36
      enabled(false),
 
37
      indicatorService(indicatorService),
 
38
      mSurfaceFactory(surfaceFactory),
 
39
      pluginId(plugin),
 
40
      pluginDescription(description)
 
41
{
 
42
    // nothing
 
43
}
 
44
 
 
45
 
 
46
MInputMethodHost::~MInputMethodHost()
 
47
{
 
48
    // nothing
 
49
}
 
50
 
 
51
 
 
52
void MInputMethodHost::setEnabled(bool enabled)
 
53
{
 
54
    this->enabled = enabled;
 
55
}
 
56
 
 
57
void MInputMethodHost::setInputMethod(MAbstractInputMethod *inputMethod)
 
58
{
 
59
    this->inputMethod = inputMethod;
 
60
}
 
61
 
 
62
int MInputMethodHost::contentType(bool &valid)
 
63
{
 
64
    return connection->contentType(valid);
 
65
}
 
66
 
 
67
bool MInputMethodHost::correctionEnabled(bool &valid)
 
68
{
 
69
    return connection->correctionEnabled(valid);
 
70
}
 
71
 
 
72
bool MInputMethodHost::predictionEnabled(bool &valid)
 
73
{
 
74
    return connection->predictionEnabled(valid);
 
75
}
 
76
 
 
77
bool MInputMethodHost::autoCapitalizationEnabled(bool &valid)
 
78
{
 
79
    return connection->autoCapitalizationEnabled(valid);
 
80
}
 
81
 
 
82
bool MInputMethodHost::surroundingText(QString &text, int &cursorPosition)
 
83
{
 
84
    return connection->surroundingText(text, cursorPosition);
 
85
}
 
86
 
 
87
bool MInputMethodHost::hasSelection(bool &valid)
 
88
{
 
89
    return connection->hasSelection(valid);
 
90
}
 
91
 
 
92
QString MInputMethodHost::selection(bool &valid)
 
93
{
 
94
    return connection->selection(valid);
 
95
}
 
96
 
 
97
int MInputMethodHost::preeditClickPos(bool &valid) const
 
98
{
 
99
    return connection->preeditClickPos(valid);
 
100
}
 
101
 
 
102
int MInputMethodHost::inputMethodMode(bool &valid)
 
103
{
 
104
    return connection->inputMethodMode(valid);
 
105
}
 
106
 
 
107
QRect MInputMethodHost::preeditRectangle(bool &valid)
 
108
{
 
109
    return connection->preeditRectangle(valid);
 
110
}
 
111
 
 
112
QRect MInputMethodHost::cursorRectangle(bool &valid)
 
113
{
 
114
    return connection->cursorRectangle(valid);
 
115
}
 
116
 
 
117
bool MInputMethodHost::hiddenText(bool &valid)
 
118
{
 
119
    return connection->hiddenText(valid);
 
120
}
 
121
 
 
122
void MInputMethodHost::sendPreeditString(const QString &string,
 
123
                                         const QList<Maliit::PreeditTextFormat> &preeditFormats,
 
124
                                         int replacementStart, int replacementLength,
 
125
                                         int cursorPos)
 
126
{
 
127
    if (enabled) {
 
128
        connection->sendPreeditString(string, preeditFormats, replacementStart, replacementLength, cursorPos);
 
129
    }
 
130
}
 
131
 
 
132
void MInputMethodHost::sendCommitString(const QString &string, int replaceStart,
 
133
                                        int replaceLength, int cursorPos)
 
134
{
 
135
    if (enabled) {
 
136
        connection->sendCommitString(string, replaceStart, replaceLength, cursorPos);
 
137
    }
 
138
}
 
139
 
 
140
void MInputMethodHost::sendKeyEvent(const QKeyEvent &keyEvent,
 
141
                                    Maliit::EventRequestType requestType)
 
142
{
 
143
    if (enabled) {
 
144
        connection->sendKeyEvent(keyEvent, requestType);
 
145
    }
 
146
}
 
147
 
 
148
void MInputMethodHost::notifyImInitiatedHiding()
 
149
{
 
150
    if (enabled) {
 
151
        connection->notifyImInitiatedHiding();
 
152
    }
 
153
}
 
154
 
 
155
void MInputMethodHost::invokeAction(const QString &action,
 
156
                                  const QKeySequence &sequence)
 
157
{
 
158
    if (enabled) {
 
159
        connection->invokeAction(action, sequence);
 
160
    }
 
161
}
 
162
 
 
163
void MInputMethodHost::setRedirectKeys(bool redirectEnabled)
 
164
{
 
165
    if (enabled) {
 
166
        connection->setRedirectKeys(redirectEnabled);
 
167
    }
 
168
}
 
169
 
 
170
void MInputMethodHost::setDetectableAutoRepeat(bool autoRepeatEnabled)
 
171
{
 
172
    if (enabled) {
 
173
        connection->setDetectableAutoRepeat(autoRepeatEnabled);
 
174
    }
 
175
}
 
176
 
 
177
void MInputMethodHost::setGlobalCorrectionEnabled(bool correctionEnabled)
 
178
{
 
179
    if (enabled) {
 
180
        connection->setGlobalCorrectionEnabled(correctionEnabled);
 
181
    }
 
182
}
 
183
 
 
184
void MInputMethodHost::setInputModeIndicator(Maliit::InputModeIndicator mode)
 
185
{
 
186
    if (enabled) {
 
187
        indicatorService.setInputModeIndicator(static_cast<Maliit::InputModeIndicator>(mode));
 
188
    }
 
189
}
 
190
 
 
191
void MInputMethodHost::switchPlugin(Maliit::SwitchDirection direction)
 
192
{
 
193
    if (enabled) {
 
194
        pluginManager->switchPlugin(direction, inputMethod);
 
195
    }
 
196
}
 
197
 
 
198
void MInputMethodHost::switchPlugin(const QString &pluginName)
 
199
{
 
200
    if (enabled) {
 
201
        pluginManager->switchPlugin(pluginName, inputMethod);
 
202
    }
 
203
}
 
204
 
 
205
void MInputMethodHost::setScreenRegion(const QRegion &region)
 
206
{
 
207
    if (enabled) {
 
208
        pluginManager->updateRegion(region);
 
209
    }
 
210
}
 
211
 
 
212
void MInputMethodHost::setInputMethodArea(const QRegion &)
 
213
{
 
214
    // TODO: remove function since it is handled by surfaces now
 
215
}
 
216
 
 
217
void MInputMethodHost::setSelection(int start, int length)
 
218
{
 
219
    if (enabled) {
 
220
        connection->setSelection(start, length);
 
221
    }
 
222
}
 
223
 
 
224
QList<MImPluginDescription> MInputMethodHost::pluginDescriptions(Maliit::HandlerState state) const
 
225
{
 
226
    return pluginManager->pluginDescriptions(state);
 
227
}
 
228
 
 
229
QList<MImSubViewDescription>
 
230
MInputMethodHost::surroundingSubViewDescriptions(Maliit::HandlerState state) const
 
231
{
 
232
    return pluginManager->surroundingSubViewDescriptions(state);
 
233
}
 
234
 
 
235
void MInputMethodHost::setLanguage(const QString &language)
 
236
{
 
237
    if (enabled) {
 
238
        connection->setLanguage(language);
 
239
    }
 
240
}
 
241
 
 
242
void MInputMethodHost::setOrientationAngleLocked(bool)
 
243
{
 
244
    // NOT implemented.
 
245
}
 
246
 
 
247
int MInputMethodHost::anchorPosition(bool &valid)
 
248
{
 
249
    return connection->anchorPosition(valid);
 
250
}
 
251
 
 
252
AbstractSurfaceFactory *MInputMethodHost::surfaceFactory()
 
253
{
 
254
    return mSurfaceFactory;
 
255
}
 
256
 
 
257
AbstractPluginSetting *MInputMethodHost::registerPluginSetting(const QString &key,
 
258
                                                               const QString &description,
 
259
                                                               Maliit::SettingEntryType type,
 
260
                                                               const QVariantMap &attributes)
 
261
{
 
262
    return pluginManager->registerPluginSetting(pluginId, pluginDescription, key, description, type, attributes);
 
263
}