Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
0312birdzhang committed Mar 7, 2018
1 parent e6e066a commit d1588dd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
18 changes: 11 additions & 7 deletions libgooglepinyin/src/pinyindecoderservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ bool PinyinDecoderService::init()
}

initDone = im_open_decoder(sysDict.toUtf8().constData(), usrDictInfo.absoluteFilePath().toUtf8().constData());
if (!initDone)
if (!initDone){
// VIRTUALKEYBOARD_DEBUG() << "Could not initialize pinyin engine. sys_dict:" << sysDict << "usr_dict:" << usrDictInfo.absoluteFilePath();

}
return initDone;
}

Expand Down Expand Up @@ -164,18 +164,22 @@ int PinyinDecoderService::getSplStart()
return (int)im_get_spl_start_pos(spl_start);
}

QVector<int> PinyinDecoderService::spellingStartPositions()
QList<QString> PinyinDecoderService::spellingStartPositions()
{
const unsigned short *spl_start;
int len;
// There will be len + 1 elements in the buffer when len > 0.
len = (int)im_get_spl_start_pos(spl_start);

QVector<int> arr;
arr.resize(len + 2);
arr[0] = len; // element 0 is used to store the length of buffer.
QList<QString> arr;
// arr.resize(len + 2);
// arr[0] = len; // element 0 is used to store the length of buffer.
// for (int i = 0; i <= len; i++)
// arr[i + 1] = spl_start[i];

arr.append(QString::number(len)); // element 0 is used to store the length of buffer.
for (int i = 0; i <= len; i++)
arr[i + 1] = spl_start[i];
arr.append(QString::number(spl_start[i]));
return arr;
}

Expand Down
3 changes: 2 additions & 1 deletion libgooglepinyin/src/pinyindecoderservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <QObject>
#include <QVector>
#include <QVariant>


class PinyinDecoderService : public QObject
Expand All @@ -54,7 +55,7 @@ class PinyinDecoderService : public QObject
Q_INVOKABLE void resetSearch();
Q_INVOKABLE QString pinyinString(bool decoded);
int pinyinStringLength(bool decoded);
Q_INVOKABLE QVector<int> spellingStartPositions();
Q_INVOKABLE QList<QString> spellingStartPositions();
Q_INVOKABLE int getSplStart();
Q_INVOKABLE QString candidateAt(int index);
QList<QString> fetchCandidates(int index, int count, int sentFixedLen);
Expand Down
26 changes: 11 additions & 15 deletions miaomiaomiao/maliit/plugins/com/jolla/SouniaoHandler.qml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ InputHandler {
fetchMany = false
hasMore = false
pred = gpy.search(str)
pySqlStart = gpy.getSplStart()
// pySqlStart = gpy.getSplStart()
pySqlStart = gpy.spellingStartPositions()
olderSql = str
if(pred > pageSize)
{
Expand All @@ -76,7 +77,7 @@ InputHandler {
item = moreCandidates.get(index)
nSize = gpy.chooceCandidate(index+pageSize)
fixLen = gpy.fixedLength()
pred =nSize
pred = nSize
}else{
item = candidates.get(index)
nSize = gpy.chooceCandidate(index)
Expand All @@ -87,23 +88,18 @@ InputHandler {

var flag = false

// TODO
// if(fixLen == pySqlStart[0])
// {
// flag = true
// }else{
// flag = false
// }

flag = true;


if (item.text !=""){
if(fixLen == parseInt(pySqlStart[0]))
{
flag = true
}else{
flag = false
}
if (item.text != ""){

if(!flag){
var tmpPy = gpy.pinyinString(false)

var tmpSubPy = tmpPy.slice(pySqlStart[fixLen+1], tmpPy.length)
var tmpSubPy = tmpPy.slice(parseInt(pySqlStart[fixLen+1]), tmpPy.length)

MInputMethodQuick.sendCommit(item.text)
MInputMethodQuick.sendPreedit( tmpSubPy )
Expand Down

0 comments on commit d1588dd

Please sign in to comment.