Revision: 6277
Author: nogu.dev
Date: Wed Mar 24 15:04:35 2010
Log: * qt4/immodule/candidatewindow.cpp
  - (CandidateWindow::preparePageCandidates,
     CandidateWindow::candidateActivate,
     CandidateWindow::candidateSelect,
     CandidateWindow::candidateShiftPage):
    New functions. Move from the QUimInputContext class.
* qt4/immodule/candidatewindow.h
  - Ditto.
  - (CandidateWindow): Make nrCandidates, displayLimit, candidateIndex
    and pageIndex protected again.
   - (CandidateWindow): Add pageFilled and nrPages.
* qt4/immodule/quiminputcontext.cpp
   - (QUimInputContext::prepare_page_candidates): Remove.
   - (QUimInputContext::candidateActivate,
      QUimInputContext::candidateSelect,
      QUimInputContext::candidateShiftPage)
     Delegate to CandidateWindow.
* qt4/immodule/quiminputcontext.h
   - Remove QUimInputContext::prepare_page_candidates().
   - Remove pageFilled and nrPages.
http://code.google.com/p/uim/source/detail?r=6277

Modified:
 /trunk/qt4/immodule/candidatewindow.cpp
 /trunk/qt4/immodule/candidatewindow.h
 /trunk/qt4/immodule/quiminputcontext.cpp
 /trunk/qt4/immodule/quiminputcontext.h

=======================================
--- /trunk/qt4/immodule/candidatewindow.cpp     Wed Mar 24 15:04:21 2010
+++ /trunk/qt4/immodule/candidatewindow.cpp     Wed Mar 24 15:04:35 2010
@@ -448,6 +448,105 @@

     move( destX, destY );
 }
+
+#if UIM_QT_USE_NEW_PAGE_HANDLING
+void CandidateWindow::preparePageCandidates( int page )
+{
+    QList<uim_candidate> list;
+
+    if ( page < 0 )
+        return;
+
+    if ( pageFilled[ page ] )
+        return;
+
+    // set page candidates
+    uim_candidate cand;
+
+    int start = page * displayLimit;
+
+    int pageNr;
+    if ( displayLimit && ( nrCandidates - start ) > displayLimit )
+        pageNr = displayLimit;
+    else
+        pageNr = nrCandidates - start;
+
+    for ( int i = start; i < ( pageNr + start ); i++ )
+    {
+ cand = uim_get_candidate( ic->uimContext(), i, displayLimit ? i % displayLimit : i );
+        list.append( cand );
+    }
+    pageFilled[ page ] = true;
+    setPageCandidates( page, list );
+}
+#endif /* UIM_QT_USE_NEW_PAGE_HANDLING */
+
+void CandidateWindow::candidateActivate( int nr, int displayLimit )
+{
+    QList<uim_candidate> list;
+
+#if !UIM_QT_USE_NEW_PAGE_HANDLING
+    activateCandwin( displayLimit );
+
+    // set candidates
+    uim_candidate cand;
+    for ( int i = 0; i < nr; i++ )
+    {
+ cand = uim_get_candidate( ic->uimContext(), i, displayLimit ? i % displayLimit : i );
+        list.append( cand );
+    }
+    setCandidates( displayLimit, list );
+
+#else /* !UIM_QT_USE_NEW_PAGE_HANDLING */
+    nrPages = displayLimit ? ( nr - 1 ) / displayLimit + 1 : 1;
+    pageFilled.clear();
+    for ( int i = 0; i < nrPages; i++ )
+        pageFilled.append( false );
+
+    setNrCandidates( nr, displayLimit );
+
+    // set page candidates
+    preparePageCandidates( 0 );
+    setPage( 0 );
+#endif /* !UIM_QT_USE_NEW_PAGE_HANDLING */
+    popup();
+}
+
+void CandidateWindow::candidateSelect( int index )
+{
+#if UIM_QT_USE_NEW_PAGE_HANDLING
+    int new_page;
+
+    if ( index >= nrCandidates )
+        index = 0;
+
+    if ( index >= 0 && displayLimit )
+        new_page = index / displayLimit;
+    else
+        new_page = pageIndex;
+
+    preparePageCandidates( new_page );
+#endif /* UIM_QT_USE_NEW_PAGE_HANDLING */
+    setIndex( index );
+}
+
+void CandidateWindow::candidateShiftPage( bool forward )
+{
+#if UIM_QT_USE_NEW_PAGE_HANDLING
+    int new_page, index;
+
+    index = forward ? pageIndex + 1 : pageIndex - 1;
+    if ( index < 0 )
+        new_page = nrPages - 1;
+    else if ( index >= nrPages )
+        new_page = 0;
+    else
+        new_page = index;
+
+    preparePageCandidates( new_page );
+#endif /* UIM_QT_USE_NEW_PAGE_HANDLING */
+    shiftPage( forward );
+}

 void CandidateWindow::updateLabel()
 {
=======================================
--- /trunk/qt4/immodule/candidatewindow.h       Mon Mar  8 02:25:45 2010
+++ /trunk/qt4/immodule/candidatewindow.h       Wed Mar 24 15:04:35 2010
@@ -38,6 +38,8 @@

 #include <uim/uim.h>

+#define UIM_QT_USE_NEW_PAGE_HANDLING 1
+
 class QLabel;

 class CandidateListView;
@@ -71,18 +73,21 @@
void setPageCandidates( int page, const QList<uim_candidate> &candidates );

     void setQUimInputContext( QUimInputContext* m_ic ) { ic = m_ic; }
+
+    void candidateActivate( int nr, int displayLimit );
+    void candidateSelect( int index );
+    void candidateShiftPage( bool forward );

     QSize sizeHint() const;

-    int nrCandidates;
-    int displayLimit;
-    int candidateIndex;
-    int pageIndex;
 protected slots:
     void slotCandidateSelected( int row );
     void slotHookSubwindow();

 protected:
+#ifdef UIM_QT_USE_NEW_PAGE_HANDLING
+    void preparePageCandidates( int page );
+#endif
     void updateLabel();

     // Moving and Resizing affects the position of Subwindow
@@ -91,6 +96,11 @@

     bool eventFilter( QObject *obj, QEvent *event );

+    int nrCandidates;
+    int displayLimit;
+    int candidateIndex;
+    int pageIndex;
+
     QUimInputContext *ic;

     CandidateListView *cList;
@@ -106,6 +116,11 @@
     const bool hasAnnotation;

     QWidget *window;
+
+#ifdef UIM_QT_USE_NEW_PAGE_HANDLING
+    QList<bool> pageFilled;
+    int nrPages;
+#endif
 };


=======================================
--- /trunk/qt4/immodule/quiminputcontext.cpp    Wed Mar 24 15:04:21 2010
+++ /trunk/qt4/immodule/quiminputcontext.cpp    Wed Mar 24 15:04:35 2010
@@ -829,107 +829,21 @@

     return attrs;
 }
-
-#if UIM_QT_USE_NEW_PAGE_HANDLING
-void QUimInputContext::prepare_page_candidates( int page )
-{
-    QList<uim_candidate> list;
-
-    if ( page < 0 )
-        return;
-
-    if ( pageFilled[ page ] )
-        return;
-
-    // set page candidates
-    uim_candidate cand;
-    int pageNr, start, nrCandidates, displayLimit;
-
-    nrCandidates = cwin->nrCandidates;
-    displayLimit = cwin->displayLimit;
-    start = page * displayLimit;
-
-    if ( displayLimit && ( nrCandidates - start ) > displayLimit )
-        pageNr = displayLimit;
-    else
-        pageNr = nrCandidates - start;
-
-    for ( int i = start; i < ( pageNr + start ); i++ )
-    {
- cand = uim_get_candidate( m_uc, i, displayLimit ? i % displayLimit : i );
-        list.append( cand );
-    }
-    pageFilled[ page ] = true;
-    cwin->setPageCandidates( page, list );
-}
-#endif /* UIM_QT_USE_NEW_PAGE_HANDLING */

 void QUimInputContext::candidateActivate( int nr, int displayLimit )
 {
-    QList<uim_candidate> list;
-
-#if !UIM_QT_USE_NEW_PAGE_HANDLING
-    cwin->activateCandwin( displayLimit );
-
-    // set candidates
-    uim_candidate cand;
-    for ( int i = 0; i < nr; i++ )
-    {
- cand = uim_get_candidate( m_uc, i, displayLimit ? i % displayLimit : i );
-        list.append( cand );
-    }
-    cwin->setCandidates( displayLimit, list );
-
-#else /* !UIM_QT_USE_NEW_PAGE_HANDLING */
-    nrPages = displayLimit ? ( nr - 1 ) / displayLimit + 1 : 1;
-    pageFilled.clear();
-    for ( int i = 0; i < nrPages; i++ )
-        pageFilled.append( false );
-
-    cwin->setNrCandidates( nr, displayLimit );
-
-    // set page candidates
-    prepare_page_candidates( 0 );
-    cwin->setPage( 0 );
-#endif /* !UIM_QT_USE_NEW_PAGE_HANDLING */
-    cwin->popup();
+    cwin->candidateActivate( nr, displayLimit );
     candwinIsActive = true;
 }

 void QUimInputContext::candidateSelect( int index )
 {
-#if UIM_QT_USE_NEW_PAGE_HANDLING
-    int new_page;
-
-    if ( index >= cwin->nrCandidates )
-        index = 0;
-
-    if ( index >= 0 && cwin->displayLimit )
-        new_page = index / cwin->displayLimit;
-    else
-        new_page = cwin->pageIndex;
-
-    prepare_page_candidates( new_page );
-#endif /* UIM_QT_USE_NEW_PAGE_HANDLING */
-    cwin->setIndex( index );
+    cwin->candidateSelect( index );
 }

 void QUimInputContext::candidateShiftPage( bool forward )
 {
-#if UIM_QT_USE_NEW_PAGE_HANDLING
-    int new_page, index;
-
-    index = forward ? cwin->pageIndex + 1 : cwin->pageIndex - 1;
-    if ( index < 0 )
-        new_page = nrPages - 1;
-    else if ( index >= nrPages )
-        new_page = 0;
-    else
-        new_page = index;
-
-    prepare_page_candidates( new_page );
-#endif /* UIM_QT_USE_NEW_PAGE_HANDLING */
-    cwin->shiftPage( forward );
+    cwin->candidateShiftPage( forward );
 }


=======================================
--- /trunk/qt4/immodule/quiminputcontext.h      Wed Mar 24 15:04:11 2010
+++ /trunk/qt4/immodule/quiminputcontext.h      Wed Mar 24 15:04:35 2010
@@ -38,7 +38,6 @@
 #ifdef Q_WS_X11
 #define UIM_QT_USE_JAPANESE_KANA_KEYBOARD_HACK 1
 #endif
-#define UIM_QT_USE_NEW_PAGE_HANDLING 1

 #include <QtGui/QInputContext>

@@ -147,9 +146,6 @@
     void switch_app_global_im( const char *str );
     void switch_system_global_im( const char *str );

-#if UIM_QT_USE_NEW_PAGE_HANDLING
-    void prepare_page_candidates( int page );
-#endif
 #ifdef Q_WS_X11
     // for X11 Compose
     static DefTree *mTreeTop;
@@ -180,11 +176,6 @@

     CandidateWindow *cwin;
     static QUimHelperManager *m_HelperManager;
-
-#if UIM_QT_USE_NEW_PAGE_HANDLING
-    QList<bool> pageFilled;
-    int nrPages;
-#endif
 };

 #endif /* Not def: UIM_QT4_IMMODULE_QUIMINPUTCONTEXT_H */

To unsubscribe from this group, send email to uim-commit+unsubscribegooglegroups.com or 
reply to this email with the words "REMOVE ME" as the subject.

Reply via email to