249
249
isActive = false;
251
void CandidateWindow::setNrCandidates( const QStringList &list )
253
#if defined(ENABLE_DEBUG)
254
qDebug( "uim-candwin-qt: setNrCandidates()" );
256
if ( list[ 1 ].isEmpty() || list[ 2 ].isEmpty() )
265
nrCandidates = list[ 1 ].toInt();
266
displayLimit = list[ 2 ].toInt();
270
// setup dummy stores
271
for ( int i = 0; i < nrCandidates; i++ ) {
276
void CandidateWindow::setPageCandidates( const QStringList &list )
278
#if defined(ENABLE_DEBUG)
279
qDebug( "uim-candwin-qt: setPageCandidates()" );
282
* format: set_page_candidates\ncharset=$charset\npage=$value\nhead1\tcand1\nhead2\tcand2\nhead3\tcand3\n
287
// get charset and create codec
288
QTextCodec *codec = NULL;
289
if ( !list[ 1 ].isEmpty() && list[ 1 ].startsWith( "charset" ) )
291
const QStringList l = QStringList::split( "=", list[ 1 ] );
292
codec = QTextCodec::codecForName( l[ 1 ] );
296
if ( !list[ 2 ].isEmpty() && list[ 2 ].startsWith( "page" ) )
298
const QStringList l = QStringList::split( "=", list[ 2 ] );
299
page = l[ 1 ].toInt();
302
for ( int i = 3; !list[ i ].isNull(); i++ )
305
if ( list[ i ].isEmpty() )
308
// split heading_label and cand_str
309
QStringList l = QStringList::split( "\t", list [ i ], true );
312
CandData &d = stores[page * displayLimit + i - 3];
315
headString = codec->toUnicode( l [ 0 ] );
317
headString = l [ 0 ];
319
d.label = headString;
321
// XXX Current prime (0.4.6) may return candidate string
322
// containing "\t", and we can't handle annotation in another
325
QString candString = l.join( "\t" );
328
d.str = codec->toUnicode( candString );
333
void CandidateWindow::showPage( const QStringList &list )
335
#if defined(ENABLE_DEBUG)
336
qDebug( "uim-candwin-qt: showPage()" );
338
const int page = list[ 1 ].toInt();
341
adjustCandidateWindowSize();
251
344
void CandidateWindow::slotStdinActivated( int fd )
253
346
char buf[ 4096 ];
300
393
moveCand( list );
301
394
else if ( QString::compare( "deactivate", ( *it ) ) == 0 )
302
395
deactivateCand();
396
else if ( QString::compare( "set_nr_candidates", ( *it ) ) == 0 )
397
setNrCandidates( list );
398
else if ( QString::compare( "set_page_candidates", ( *it ) ) == 0 )
399
setPageCandidates( list );
400
else if ( QString::compare( "show_page", ( *it ) ) == 0 )