Revision: 6481
Author: nogu.dev
Date: Sun Jun 27 02:38:55 2010
Log: * qt4/immodule/abstractcandidatewindow.cpp
  - (AbstractCandidateWindow::setCandidates): Cosmetic change.
  - (AbstractCandidateWindow::setPage): Move from CandidateWindow
    and CandidateTableWindow.
* qt4/immodule/abstractcandidatewindow.h
  - (AbstractCandidateWindow): Add updateView() and updateSize().
* qt4/immodule/candidatetablewindow.cpp
  - (CandidateTableWindow::setTable): Rename to updateSize().
  - (CandidateTableWindow::setPage): Move to AbstractCandidateWindow.
  - (CandidateTableWindow::updateView): New function.
* qt4/immodule/candidatetablewindow.h
  - Ditto.
* qt4/immodule/candidatewindow.cpp
  - (CandidateWindow::setPage): Move to AbstractCandidateWindow.
  - (CandidateWindow::updateView, CandidateWindow::updateSize):
    New function.
* qt4/immodule/candidatewindow.h
  - Ditto.
http://code.google.com/p/uim/source/detail?r=6481

Modified:
 /trunk/qt4/immodule/abstractcandidatewindow.cpp
 /trunk/qt4/immodule/abstractcandidatewindow.h
 /trunk/qt4/immodule/candidatetablewindow.cpp
 /trunk/qt4/immodule/candidatetablewindow.h
 /trunk/qt4/immodule/candidatewindow.cpp
 /trunk/qt4/immodule/candidatewindow.h

=======================================
--- /trunk/qt4/immodule/abstractcandidatewindow.cpp     Mon Jun 14 06:26:50 2010
+++ /trunk/qt4/immodule/abstractcandidatewindow.cpp     Sun Jun 27 02:38:55 2010
@@ -288,7 +288,7 @@
     displayLimit = dl;

     if (candidates.isEmpty())
-        return ;
+        return;

     // set candidates
     stores = candidates;
@@ -296,6 +296,59 @@
     // shift to default page
     setPage(0);
 }
+
+void AbstractCandidateWindow::setPage(int page)
+{
+#ifdef ENABLE_DEBUG
+    qDebug("setPage : page = %d", page);
+#endif
+
+    // calculate page
+    int lastpage = displayLimit ? nrCandidates / displayLimit : 0;
+
+    int newpage;
+    if (page < 0)
+        newpage = lastpage;
+    else if (page > lastpage)
+        newpage = 0;
+    else
+        newpage = page;
+
+    pageIndex = newpage;
+
+    // calculate index
+    int newindex;
+    if (displayLimit) {
+        newindex = (candidateIndex >= 0)
+ ? (newpage * displayLimit) + (candidateIndex % displayLimit) : -1;
+    } else {
+        newindex = candidateIndex;
+    }
+
+    if (newindex >= nrCandidates)
+        newindex = nrCandidates - 1;
+
+    // set cand items
+    //
+    // If we switch to last page, the number of items to be added
+    // is lower than displayLimit.
+    //
+    // ex. if nrCandidate == 14 and displayLimit == 10, the number of
+    //     last page's item == 4
+    int ncandidates = displayLimit;
+    if (newpage == lastpage)
+        ncandidates = nrCandidates - displayLimit * lastpage;
+
+    updateView(newpage, ncandidates);
+
+    // set index
+    if (newindex != candidateIndex)
+        setIndex(newindex);
+    else
+        updateLabel();
+
+    updateSize();
+}

 #if UIM_QT_USE_NEW_PAGE_HANDLING
 void AbstractCandidateWindow::setPageCandidates(int page,
=======================================
--- /trunk/qt4/immodule/abstractcandidatewindow.h       Mon Jun 14 06:26:50 2010
+++ /trunk/qt4/immodule/abstractcandidatewindow.h       Sun Jun 27 02:38:55 2010
@@ -70,12 +70,13 @@
     protected:
         virtual void activateCandwin(int dLimit);

-        virtual void setPage(int page) = 0;
         virtual void shiftPage(bool forward);
         virtual void setIndex(int totalindex);
 #ifdef UIM_QT_USE_NEW_PAGE_HANDLING
         virtual void setNrCandidates(int nrCands, int dLimit);
 #endif
+        virtual void updateView(int newpage, int ncandidates) = 0;
+        virtual void updateSize() = 0;
         void updateLabel();

         QUimInputContext *ic;
@@ -96,6 +97,7 @@
     private:
         void setCandidates(int displayLimit,
                 const QList<uim_candidate> &candidates);
+        void setPage(int page);
 #ifdef UIM_QT_USE_NEW_PAGE_HANDLING
         void setPageCandidates(int page,
                 const QList<uim_candidate> &candidates);
=======================================
--- /trunk/qt4/immodule/candidatetablewindow.cpp        Wed Jun 23 03:26:55 2010
+++ /trunk/qt4/immodule/candidatetablewindow.cpp        Sun Jun 27 02:38:55 2010
@@ -191,71 +191,8 @@
     }
 }

-void CandidateTableWindow::setTable()
-{
-    // hide empty blocks.
-    // pattern0 (full table)
-    //   blockLR  blockA
-    //   blockLRS blockAS (for shift key)
-    // pattern1 (minimal blocks)
-    //   blockLR
-    // pattern2 (without shift blocks)
-    //   blockLR  blockA
-    // pattern3 (without symbol blocks)
-    //   blockLR
-    //   blockLRS
-    bool hasBlockA = !isEmptyBlock(aLayout);
-    bool hasBlockAs = !isEmptyBlock(asLayout);
-    bool hasBlockLrs = !(isEmptyBlock(lsLayout) && isEmptyBlock(rsLayout));
-
-    setBlockVisible(aLayout, hasBlockA || hasBlockAs);
-    setBlockVisible(asLayout, hasBlockAs);
-    setBlockVisible(lsLayout, hasBlockLrs || hasBlockAs);
-    setBlockVisible(rsLayout, hasBlockLrs || hasBlockAs);
-}
-
-void CandidateTableWindow::setPage(int page)
-{
-#ifdef ENABLE_DEBUG
-    qDebug("setPage : page = %d", page);
-#endif
-
-    // calculate page
-    int lastpage = displayLimit ? nrCandidates / displayLimit : 0;
-
-    int newpage;
-    if (page < 0)
-        newpage = lastpage;
-    else if (page > lastpage)
-        newpage = 0;
-    else
-        newpage = page;
-
-    pageIndex = newpage;
-
-    // calculate index
-    int newindex;
-    if (displayLimit) {
-        newindex = (candidateIndex >= 0)
- ? (newpage * displayLimit) + (candidateIndex % displayLimit) : -1;
-    } else {
-        newindex = candidateIndex;
-    }
-
-    if (newindex >= nrCandidates)
-        newindex = nrCandidates - 1;
-
-    // set cand items
-    //
-    // If we switch to last page, the number of items to be added
-    // is lower than displayLimit.
-    //
-    // ex. if nrCandidate==14 and displayLimit==10, the number of
-    //     last page's item==4
-    int ncandidates = displayLimit;
-    if (newpage == lastpage)
-        ncandidates = nrCandidates - displayLimit * lastpage;
-
+void CandidateTableWindow::updateView(int newpage, int ncandidates)
+{
     int index = 0;
     int delta = 0;
     for (int i = 0; i < TABLE_NR_ROWS; i++) {
@@ -289,13 +226,29 @@
             index++;
         }
     }
-    setTable();
-
-    // set index
-    if (newindex != candidateIndex)
-        setIndex(newindex);
-    else
-        updateLabel();
+}
+
+void CandidateTableWindow::updateSize()
+{
+    // hide empty blocks.
+    // pattern0 (full table)
+    //   blockLR  blockA
+    //   blockLRS blockAS (for shift key)
+    // pattern1 (minimal blocks)
+    //   blockLR
+    // pattern2 (without shift blocks)
+    //   blockLR  blockA
+    // pattern3 (without symbol blocks)
+    //   blockLR
+    //   blockLRS
+    bool hasBlockA = !isEmptyBlock(aLayout);
+    bool hasBlockAs = !isEmptyBlock(asLayout);
+    bool hasBlockLrs = !(isEmptyBlock(lsLayout) && isEmptyBlock(rsLayout));
+
+    setBlockVisible(aLayout, hasBlockA || hasBlockAs);
+    setBlockVisible(asLayout, hasBlockAs);
+    setBlockVisible(lsLayout, hasBlockLrs || hasBlockAs);
+    setBlockVisible(rsLayout, hasBlockLrs || hasBlockAs);
 }

 void CandidateTableWindow::setIndex(int totalIndex)
=======================================
--- /trunk/qt4/immodule/candidatetablewindow.h  Wed Jun 23 03:26:55 2010
+++ /trunk/qt4/immodule/candidatetablewindow.h  Sun Jun 27 02:38:55 2010
@@ -60,8 +60,8 @@
         QGridLayout *createLayout(int row, int column,
             int rowOffset, int columnOffset);
         void setBlockVisible(QLayout *layout, bool visible);
-        void setTable();
-        void setPage(int page);
+        void updateView(int newpage, int ncandidates);
+        void updateSize();
         void setIndex(int totalIndex);

         QGridLayout *lsLayout;
=======================================
--- /trunk/qt4/immodule/candidatewindow.cpp     Mon Jun 14 06:26:50 2010
+++ /trunk/qt4/immodule/candidatewindow.cpp     Sun Jun 27 02:38:55 2010
@@ -98,65 +98,8 @@
 }
 #endif /* UIM_QT_USE_NEW_PAGE_HANDLING */

-void CandidateWindow::setPage( int page )
-{
-#ifdef ENABLE_DEBUG
-    qDebug( "setPage : page = %d", page );
-#endif
-
-    // clear items
-    cList->clearContents();
-    annotations.clear();
-
-    // calculate page
-    int newpage, lastpage;
-    if ( displayLimit )
-        lastpage = nrCandidates / displayLimit;
-    else
-        lastpage = 0;
-
-    if ( page < 0 )
-    {
-        newpage = lastpage;
-    }
-    else if ( page > lastpage )
-    {
-        newpage = 0;
-    }
-    else
-    {
-        newpage = page;
-    }
-
-    pageIndex = newpage;
-
-    // calculate index
-    int newindex;
-    if ( displayLimit )
-    {
-        if ( candidateIndex >= 0 )
- newindex = ( newpage * displayLimit ) + ( candidateIndex % displayLimit );
-        else
-            newindex = -1;
-    }
-    else
-    {
-        newindex = candidateIndex;
-    }
-
-    if ( newindex >= nrCandidates )
-        newindex = nrCandidates - 1;
-
-    // set cand items
-    //
-    // If we switch to last page, the number of items to be added
-    // is lower than displayLimit.
-    //
-    // ex. if nrCandidate==14 and displayLimit==10, the number of
-    //     last page's item==4
-    int ncandidates = displayLimit;
-    if ( newpage == lastpage )
-        ncandidates = nrCandidates - displayLimit * lastpage;
+void CandidateWindow::updateView( int newpage, int ncandidates )
+{
     cList->setRowCount( ncandidates );
     for ( int i = 0; i < ncandidates ; i++ )
     {
@@ -196,13 +139,10 @@

cList->setRowHeight( i, QFontMetrics( cList->font() ).height() + 2 );
     }
-
-    // set index
-    if ( newindex != candidateIndex )
-        setIndex( newindex );
-    else
-        updateLabel();
-
+}
+
+void CandidateWindow::updateSize()
+{
     // size adjustment
     cList->updateGeometry();
     resize(sizeHint());
=======================================
--- /trunk/qt4/immodule/candidatewindow.h       Mon Jun 14 06:26:50 2010
+++ /trunk/qt4/immodule/candidatewindow.h       Sun Jun 27 02:38:55 2010
@@ -56,7 +56,8 @@
 private:
     void activateCandwin( int dLimit );

-    void setPage( int page );
+    void updateView( int newpage, int ncandidates );
+    void updateSize();
     void shiftPage( bool forward );
     void setIndex( int totalindex );

Reply via email to