Revision: 7161
Author: nogu.dev
Date: Sun Jun 26 09:09:26 2011
Log: * qt4/immodule/candidatewindow.cpp
- (CandidateWindow::CandidateWindow): Add dummy row and column
for horizontal candidate window.
- (CandidateWindow::updateView): New.
- (CandidateListView::sizeHint): New.
http://code.google.com/p/uim/source/detail?r=7161
Modified:
/trunk/qt4/immodule/candidatewindow.cpp
=======================================
--- /trunk/qt4/immodule/candidatewindow.cpp Sun Jun 26 09:07:40 2011
+++ /trunk/qt4/immodule/candidatewindow.cpp Sun Jun 26 09:09:26 2011
@@ -63,11 +63,14 @@
// the last column is dummy for adjusting size.
cList->setColumnCount( hasAnnotation ? 4 : 3 );
else
- cList->setRowCount( 1 );
- QHeaderView *header = isVertical
- ? cList->horizontalHeader() : cList->verticalHeader();
- header->setResizeMode( QHeaderView::ResizeToContents );
- header->setStretchLastSection( true );
+ cList->setRowCount( 2 );
+ cList->horizontalHeader()->setResizeMode(
QHeaderView::ResizeToContents );
+ cList->horizontalHeader()->setStretchLastSection( true );
+ if ( !isVertical ) {
+ cList->verticalHeader()
+ ->setResizeMode( QHeaderView::ResizeToContents );
+ cList->verticalHeader()->setStretchLastSection( true );
+ }
cList->horizontalHeader()->hide();
cList->verticalHeader()->hide();
cList->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
@@ -113,7 +116,8 @@
if ( isVertical )
cList->setRowCount( ncandidates );
else
- cList->setColumnCount( ncandidates );
+ // the last column is dummy for adjusting size.
+ cList->setColumnCount( ncandidates + 1 );
for ( int i = 0; i < ncandidates ; i++ )
{
uim_candidate cand = stores[ displayLimit * newpage + i ];
@@ -301,18 +305,15 @@
// frame width
int frame = style()->pixelMetric( QStyle::PM_DefaultFrameWidth ) * 2;
- const int rowNum = rowCount();
+ // the size of the dummy row should be 0.
+ const int rowNum = isVertical ? rowCount() : rowCount() - 1;
if ( rowNum == 0 ) {
return QSize( MIN_CAND_WIDTH, frame );
}
int width = frame;
// the size of the dummy column should be 0.
- int last = isVertical ? columnCount() - 1 : columnCount();
- for ( int i = 0; i < last; i++ )
+ for ( int i = 0; i < columnCount() - 1; i++ )
width += columnWidth( i );
- if ( isVertical )
- return QSize( width, rowHeight( 0 ) * rowNum + frame );
- else
- return QSize( width, QFontMetrics( font() ).height() + 2 + frame);
-}
+ return QSize( width, rowHeight( 0 ) * rowNum + frame );
+}