~ubuntu-branches/ubuntu/maverick/uim/maverick

« back to all changes in this revision

Viewing changes to qt/immodule-candidatewindow.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Masahito Omote
  • Date: 2008-06-25 19:56:33 UTC
  • mfrom: (3.1.18 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080625195633-8jljph4rfq00l8o7
Tags: 1:1.5.1-2
* uim-tcode: provide tutcode-custom.scm, tutcode-bushudic.scm
  and tutcode-rule.scm (Closes: #482659)
* Fix FTBFS: segv during compile (Closes: #483078).
  I personally think this bug is not specific for uim but is a optimization
  problem on gcc-4.3.1. (https://bugs.freedesktop.org/show_bug.cgi?id=16477)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 
3
 
Copyright (c) 2003-2006 uim Project http://uim.freedesktop.org/
 
3
Copyright (c) 2003-2008 uim Project http://code.google.com/p/uim/
4
4
 
5
5
All rights reserved.
6
6
 
30
30
SUCH DAMAGE.
31
31
 
32
32
*/
33
 
#include "immodule-candidatewindow.h"
 
33
#include <config.h>
34
34
 
35
35
#include <qapplication.h>
36
36
#include <qlabel.h>
38
38
#include <qfontmetrics.h>
39
39
#include <qevent.h>
40
40
 
 
41
#include "uim/uim.h"
 
42
 
 
43
#include "immodule-candidatewindow.h"
41
44
#include "immodule-quiminputcontext.h"
42
45
#include "immodule-subwindow.h"
43
46
 
66
69
 
67
70
    //setup CandidateList
68
71
    cList = new CandidateListView( this, "candidateListView" );
69
 
    cList->setSorting( 0 );
 
72
    cList->setSorting( -1 );
70
73
    cList->setSelectionMode( QListView::Single );
71
74
    cList->addColumn( "0" );
72
75
    cList->setColumnWidthMode( 0, QListView::Maximum );
117
120
{
118
121
    candidateIndex = -1;
119
122
    displayLimit = dLimit;
 
123
    pageIndex = 0;
120
124
}
121
125
 
122
126
void CandidateWindow::deactivateCandwin()
180
184
 
181
185
    // calculate page
182
186
    int newpage, lastpage;
183
 
    lastpage = nrCandidates / displayLimit;
 
187
    if ( displayLimit )
 
188
        lastpage = nrCandidates / displayLimit;
 
189
    else
 
190
        lastpage = 0;
 
191
 
184
192
    if ( page < 0 )
185
193
    {
186
194
        newpage = lastpage;
223
231
    int ncandidates = displayLimit;
224
232
    if ( newpage == lastpage )
225
233
        ncandidates = nrCandidates - displayLimit * lastpage;
226
 
    for ( int i = 0; i < ncandidates; i++ )
 
234
    for ( int i = ncandidates - 1; i >= 0; i-- )
227
235
    {
228
236
        uim_candidate cand = stores[ displayLimit * newpage + i ];
229
237
        QString headString = QString::fromUtf8( ( const char * ) uim_candidate_get_heading_label( cand ) );
230
 
        if ( ( headString.toInt() < 10 && headString.toInt() + displayLimit > 10 )
231
 
                || ( headString.toInt() < 100 && headString.toInt() + displayLimit > 100 ) )
232
 
            headString.prepend( "0" );
233
238
        QString candString = QString::fromUtf8( ( const char * ) uim_candidate_get_cand_str( cand ) );
234
239
 
235
240
        // 2004-12-13 Kazuki Ohta <mover@hct.zaq.ne.jp>
244
249
    // set index
245
250
    if ( newindex != candidateIndex )
246
251
        setIndex( newindex );
 
252
    else
 
253
        updateLabel();
247
254
 
248
255
    // size adjustment
249
256
    adjustSize();
313
320
    
314
321
    if ( forward )
315
322
    {
316
 
        candidateIndex += displayLimit;
 
323
        if ( candidateIndex != -1 )
 
324
            candidateIndex += displayLimit;
317
325
        setPage( pageIndex + 1 );
318
326
    }
319
327
    else
320
328
    {
321
 
        if ( candidateIndex < displayLimit )
322
 
            candidateIndex = displayLimit * ( nrCandidates / displayLimit ) + candidateIndex;
323
 
        else
324
 
            candidateIndex -= displayLimit;
 
329
        if (candidateIndex != -1 ) {
 
330
            if ( candidateIndex < displayLimit )
 
331
                candidateIndex = displayLimit * ( nrCandidates / displayLimit ) + candidateIndex;
 
332
            else
 
333
                candidateIndex -= displayLimit;
 
334
        }
325
335
 
326
336
        setPage( pageIndex - 1 );
327
337
    }
328
338
 
329
 
    cList->setSelected( cList->itemAtIndex( candidateIndex % displayLimit ), true );
330
 
    if ( ic && ic->uimContext() )
 
339
    if ( candidateIndex != -1 ) {
 
340
        if ( displayLimit )
 
341
            cList->setSelected( cList->itemAtIndex( candidateIndex % displayLimit ), true );
 
342
        else
 
343
            cList->setSelected( cList->itemAtIndex( candidateIndex ), true );
 
344
    }
 
345
    if ( ic && ic->uimContext() && candidateIndex != -1 )
331
346
        uim_set_candidate_index( ic->uimContext(), candidateIndex );
332
347
}
333
348