Revision: 6215
Author: nogu.dev
Date: Wed Mar  3 05:55:46 2010
Log: * qt4/candwin/qt4.cpp
  - (CandidateWindow::setPage): Optimize.
* qt4/immodule/candidatewindow.cpp
  - (CandidateWindow::setPage): Ditto.
http://code.google.com/p/uim/source/detail?r=6215

Modified:
 /trunk/qt4/candwin/qt4.cpp
 /trunk/qt4/immodule/candidatewindow.cpp

=======================================
--- /trunk/qt4/candwin/qt4.cpp  Tue Mar  2 14:25:27 2010
+++ /trunk/qt4/candwin/qt4.cpp  Wed Mar  3 05:55:46 2010
@@ -471,7 +471,6 @@
 {
     // clear items
     cList->clearContents();
-    cList->setRowCount( 0 );

     // calculate page
     int newpage, lastpage;
@@ -522,6 +521,7 @@
     int ncandidates = displayLimit;
     if ( newpage == lastpage )
         ncandidates = nrCandidates - displayLimit * lastpage;
+    cList->setRowCount( ncandidates );
     for ( int i = 0; i < ncandidates ; i++ )
     {
         QString headString = stores[ displayLimit * newpage + i ].label;
@@ -534,12 +534,9 @@
         QTableWidgetItem *candItem = new QTableWidgetItem;
         candItem->setText( candString );
         candItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
-        int count = cList->rowCount();
-        cList->setRowCount( count + 1 );
-        cList->setItem( count, 0, headItem );
-        cList->setItem( count, 1, candItem );
-        cList->setRowHeight(
-            count, QFontMetrics( cList->font() ).height() + 2 );
+        cList->setItem( i, 0, headItem );
+        cList->setItem( i, 1, candItem );
+ cList->setRowHeight( i, QFontMetrics( cList->font() ).height() + 2 );
     }

     // set index
=======================================
--- /trunk/qt4/immodule/candidatewindow.cpp     Tue Mar  2 14:25:27 2010
+++ /trunk/qt4/immodule/candidatewindow.cpp     Wed Mar  3 05:55:46 2010
@@ -243,7 +243,6 @@

     // clear items
     cList->clearContents();
-    cList->setRowCount( 0 );

     // calculate page
     int newpage, lastpage;
@@ -294,6 +293,7 @@
     int ncandidates = displayLimit;
     if ( newpage == lastpage )
         ncandidates = nrCandidates - displayLimit * lastpage;
+    cList->setRowCount( ncandidates );
     for ( int i = 0; i < ncandidates ; i++ )
     {
         uim_candidate cand = stores[ displayLimit * newpage + i ];
@@ -311,12 +311,9 @@
         QTableWidgetItem *candItem = new QTableWidgetItem;
         candItem->setText( candString );
         candItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
-        int count = cList->rowCount();
-        cList->setRowCount( count + 1 );
-        cList->setItem( count, 0, headItem );
-        cList->setItem( count, 1, candItem );
-        cList->setRowHeight(
-            count, QFontMetrics( cList->font() ).height() + 2 );
+        cList->setItem( i, 0, headItem );
+        cList->setItem( i, 1, candItem );
+ cList->setRowHeight( i, QFontMetrics( cList->font() ).height() + 2 );
     }

     // set index

Reply via email to