[uim-commit] r377 - trunk/qt/quiminputcontextplugin/src

kzk@freedesktop.org kzk@freedesktop.org
Fri Jan 28 07:09:08 PST 2005


Author: kzk
Date: 2005-01-28 07:09:06 -0800 (Fri, 28 Jan 2005)
New Revision: 377

Modified:
   trunk/qt/quiminputcontextplugin/src/candidatewindow.cpp
   trunk/qt/quiminputcontextplugin/src/candidatewindow.h
Log:
* UimQt: specify default size of CandidateWindow instead
  of resizing because resizing causes flickering.

* qt/quiminputcontextplugin/src/candidatewindow.h
  - (CandidateWindow::adjustCandidateWindowSize): removed
  - (CandidateWindow::sizeHint): new function
  - (CandidateWindow::itemAtIndex): add const qualifier
  - (CandidateListView::sizeHint): new function
* qt/quiminputcontextplugin/src/candidatewindow.cpp
  - (CandidateWindow::adjustCandidateWindowSize): removed
  - (CandidateWindow::sizeHint): new function
  - (CandidateListView::sizeHint): new function



Modified: trunk/qt/quiminputcontextplugin/src/candidatewindow.cpp
===================================================================
--- trunk/qt/quiminputcontextplugin/src/candidatewindow.cpp	2005-01-28 10:39:21 UTC (rev 376)
+++ trunk/qt/quiminputcontextplugin/src/candidatewindow.cpp	2005-01-28 15:09:06 UTC (rev 377)
@@ -239,8 +239,8 @@
     if ( newindex != candidateIndex )
         setIndex( newindex );
 
-    // set candwin size
-    adjustCandidateWindowSize();
+    // size adjustment
+    adjustSize();
 }
 
 void CandidateWindow::setIndex( int totalindex )
@@ -337,38 +337,6 @@
     move( destX, destY );
 }
 
-void CandidateWindow::adjustCandidateWindowSize()
-{
-    qDebug( "adjustCandidateWindowSize()" );
-
-    int width = 0;
-    int height = 0;
-    QListViewItem *item = cList->firstChild();
-    if ( item )
-        height = item->height() * ( cList->childCount() + 1 );
-
-    // 2004-08-02 Kazuki Ohta <mover@hct.zaq.ne.jp>
-    // FIXME!:
-    //    There may be more proper way. Now width is adjusted by indeterminal 3 spaces.
-    //    Using QWidget::adjustSize() seems not to work properly...
-    unsigned int maxCharIndex = 0, maxCharCount = 0;
-    for ( int i = 0; i < cList->childCount(); i++ )
-    {
-        if ( maxCharCount < cList->itemAtIndex( i ) ->text( 1 ).length() )
-        {
-            maxCharIndex = i;
-            maxCharCount = cList->itemAtIndex( i ) ->text( 1 ).length();
-        }
-    }
-    QFontMetrics fm( cList->font() );
-    width = fm.width( cList->itemAtIndex( maxCharIndex ) ->text( 0 ) + "   " + cList->itemAtIndex( maxCharIndex ) ->text( 1 ) );
-    if ( width < MIN_CAND_WIDTH )
-        width = MIN_CAND_WIDTH;
-
-    resize( width, height );
-}
-
-
 void CandidateWindow::updateLabel()
 {
     QString indexString = QString::null;
@@ -405,3 +373,45 @@
     // move subwindow
     subWin->layoutWindow( pos().x() + e->size().width(), pos().y() );
 }
+
+
+QSize CandidateWindow::sizeHint( void ) const
+{
+    QSize cListSizeHint = cList->sizeHint();
+
+    int width = cListSizeHint.width();
+    int height = cListSizeHint.height() + numLabel->height();
+
+    return QSize( width, height );
+}
+
+QSize CandidateListView::sizeHint( void ) const
+{
+    if(childCount() == 0)
+        return QSize( MIN_CAND_WIDTH, 0 );
+    
+    int width = 0;
+    int height = 0;
+    QListViewItem *item = firstChild();
+    if ( item )
+        height = item->height() * childCount() + 3;
+    
+    // 2004-08-02 Kazuki Ohta <mover@hct.zaq.ne.jp>
+    // FIXME!:
+    //    There may be more proper way. Now width is adjusted by indeterminal 3 spaces.
+    unsigned int maxCharIndex = 0, maxCharCount = 0;
+    for ( int i = 0; i < childCount(); i++ )
+    {
+        if ( maxCharCount < itemAtIndex( i )->text( 1 ).length() )
+        {
+            maxCharIndex = i;
+            maxCharCount = itemAtIndex( i )->text( 1 ).length();
+        }
+    }
+    QFontMetrics fm( font() );
+    width = fm.width( itemAtIndex( maxCharIndex )->text( 0 ) + "   " + itemAtIndex( maxCharIndex )->text( 1 ) );
+    if ( width < MIN_CAND_WIDTH )
+        width = MIN_CAND_WIDTH;
+    
+    return QSize( width, height );
+}

Modified: trunk/qt/quiminputcontextplugin/src/candidatewindow.h
===================================================================
--- trunk/qt/quiminputcontextplugin/src/candidatewindow.h	2005-01-28 10:39:21 UTC (rev 376)
+++ trunk/qt/quiminputcontextplugin/src/candidatewindow.h	2005-01-28 15:09:06 UTC (rev 377)
@@ -39,6 +39,7 @@
 #include <qlistview.h>
 #include <qvaluelist.h>
 #include <qevent.h>
+#include <qfontmetrics.h>
 
 class QLabel;
 
@@ -71,6 +72,8 @@
 
     void setQUimInputContext( QUimInputContext* m_ic ) { ic = m_ic; }
 
+    QSize sizeHint(void) const;
+
 protected slots:
     void slotCandidateSelected( QListViewItem* );
     void slotHookSubwindow( QListViewItem* );
@@ -78,9 +81,6 @@
 protected:
     void updateLabel();
 
-    // not completed
-    void adjustCandidateWindowSize();
-
     // Moving and Resizing affects the positon of Subwindow
     virtual void moveEvent( QMoveEvent * );
     virtual void resizeEvent( QResizeEvent * );
@@ -129,7 +129,7 @@
         }
     }
 
-    QListViewItem* itemAtIndex( int index )
+    QListViewItem* itemAtIndex( int index ) const
     {
         if ( index < 0 )
             return 0;
@@ -143,6 +143,7 @@
 
         return 0;
     }
+
+    QSize sizeHint( void ) const;
 };
-
 #endif /* Not def: _CANDIDATE_WINDOW_H_ */



More information about the Uim-commit mailing list