Skip to content

Instantly share code, notes, and snippets.

@mnogu
Created February 24, 2010 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnogu/313316 to your computer and use it in GitHub Desktop.
Save mnogu/313316 to your computer and use it in GitHub Desktop.
Subject: [PATCH 21/26] make the scope of variables narrower
---
qt4/immodule/candidatewindow.cpp | 6 +++---
qt4/immodule/qtextutil.cpp | 24 +++++++++++-------------
qt4/immodule/quiminputcontext_compose.cpp | 14 ++++++--------
3 files changed, 20 insertions(+), 24 deletions(-)
diff --git a/qt4/immodule/candidatewindow.cpp b/qt4/immodule/candidatewindow.cpp
index 70380ae..9d4b84d 100644
--- a/qt4/immodule/candidatewindow.cpp
+++ b/qt4/immodule/candidatewindow.cpp
@@ -217,15 +217,15 @@ void CandidateWindow::setPageCandidates( int page, const Q3ValueList<uim_candida
return;
// set candidates
- int i, start, pageNr;
- start = page * displayLimit;
+ int start = page * displayLimit;
+ int pageNr;
if ( displayLimit && ( nrCandidates - start ) > displayLimit )
pageNr = displayLimit;
else
pageNr = nrCandidates - start;
- for ( i = 0; i < pageNr; i++ )
+ for ( int i = 0; i < pageNr; i++ )
stores[ start + i ] = candidates[ i ];
}
#endif /* UIM_QT_USE_NEW_PAGE_HANDLING */
diff --git a/qt4/immodule/qtextutil.cpp b/qt4/immodule/qtextutil.cpp
index f306b02..484fd6e 100644
--- a/qt4/immodule/qtextutil.cpp
+++ b/qt4/immodule/qtextutil.cpp
@@ -246,7 +246,6 @@ QUimTextUtil::acquirePrimaryTextInQTextEdit( enum UTextOrigin origin,
Q3TextEdit *edit = (Q3TextEdit *)mWidget;
QString text;
- int i;
int start_para, start_index, end_para, end_index, para, index;
int n_para;
int preedit_len, preedit_cursor_pos;
@@ -274,7 +273,7 @@ QUimTextUtil::acquirePrimaryTextInQTextEdit( enum UTextOrigin origin,
end_para = para;
if ( former_req_len >= 0 ) {
- for ( i = 0; i < former_req_len; i++ )
+ for ( int i = 0; i < former_req_len; i++ )
QTextEditPositionBackward( &start_para, &start_index );
} else {
if ( former_req_len == UTextExtent_Line )
@@ -291,7 +290,7 @@ QUimTextUtil::acquirePrimaryTextInQTextEdit( enum UTextOrigin origin,
*former = strdup( edit->selectedText().utf8() );
if ( latter_req_len >= 0 ) {
- for ( i = 0; i < latter_req_len; i++ )
+ for ( int i = 0; i < latter_req_len; i++ )
QTextEditPositionForward( &end_para, &end_index );
} else {
if ( latter_req_len == UTextExtent_Line ) {
@@ -318,7 +317,7 @@ QUimTextUtil::acquirePrimaryTextInQTextEdit( enum UTextOrigin origin,
end_index = start_index;
if ( latter_req_len >= 0 ) {
- for ( i = 0; i < latter_req_len; i++ )
+ for ( int i = 0; i < latter_req_len; i++ )
QTextEditPositionForward( &end_para, &end_index );
} else {
if ( latter_req_len == UTextExtent_Line )
@@ -351,7 +350,7 @@ QUimTextUtil::acquirePrimaryTextInQTextEdit( enum UTextOrigin origin,
start_index = end_index;
if ( former_req_len >= 0 ) {
- for ( i = 0; i < former_req_len; i++ )
+ for ( int i = 0; i < former_req_len; i++ )
QTextEditPositionBackward( &start_para, &start_index );
} else {
if ( former_req_len == UTextExtent_Line )
@@ -716,7 +715,6 @@ QUimTextUtil::deletePrimaryTextInQTextEdit( enum UTextOrigin origin,
int latter_req_len )
{
Q3TextEdit *edit = (Q3TextEdit *)mWidget;
- int i;
int start_para, start_index, end_para, end_index, para, index;
int n_para;
@@ -733,7 +731,7 @@ QUimTextUtil::deletePrimaryTextInQTextEdit( enum UTextOrigin origin,
end_para = para;
if ( former_req_len >= 0 ) {
- for ( i = 0; i < former_req_len; i++ )
+ for ( int i = 0; i < former_req_len; i++ )
QTextEditPositionBackward( &start_para, &start_index );
} else {
if ( former_req_len == UTextExtent_Line ) {
@@ -747,7 +745,7 @@ QUimTextUtil::deletePrimaryTextInQTextEdit( enum UTextOrigin origin,
}
}
if ( latter_req_len >= 0 ) {
- for ( i = 0; i < latter_req_len; i++ )
+ for ( int i = 0; i < latter_req_len; i++ )
QTextEditPositionForward( &end_para, &end_index );
} else {
if ( latter_req_len == UTextExtent_Line ) {
@@ -769,7 +767,7 @@ QUimTextUtil::deletePrimaryTextInQTextEdit( enum UTextOrigin origin,
end_index = start_index;
if ( latter_req_len >= 0 ) {
- for ( i = 0; i < latter_req_len; i++ )
+ for ( int i = 0; i < latter_req_len; i++ )
QTextEditPositionForward( &end_para, &end_index );
} else {
if ( latter_req_len == UTextExtent_Line ) {
@@ -791,7 +789,7 @@ QUimTextUtil::deletePrimaryTextInQTextEdit( enum UTextOrigin origin,
start_index = end_index;
if ( former_req_len >= 0 ) {
- for ( i = 0; i < former_req_len; i++ )
+ for ( int i = 0; i < former_req_len; i++ )
QTextEditPositionBackward( &start_para, &start_index );
} else {
if ( former_req_len == UTextExtent_Line )
@@ -899,7 +897,7 @@ QUimTextUtil::deleteSelectionTextInQTextEdit( enum UTextOrigin origin,
{
Q3TextEdit *edit = (Q3TextEdit *)mWidget;
QString text;
- int len, newline, i;
+ int len, newline;
int para, index;
int sel_para_from, sel_index_from, sel_para_to, sel_index_to;
int start_para, start_index, end_para, end_index;
@@ -929,7 +927,7 @@ QUimTextUtil::deleteSelectionTextInQTextEdit( enum UTextOrigin origin,
if ( len > latter_req_len ) {
end_para = sel_para_from;
end_index = sel_index_from;
- for ( i = 0; i < latter_req_len; i++)
+ for ( int i = 0; i < latter_req_len; i++)
QTextEditPositionForward( &end_para, &end_index );
}
} else {
@@ -947,7 +945,7 @@ QUimTextUtil::deleteSelectionTextInQTextEdit( enum UTextOrigin origin,
if ( len > former_req_len ) {
start_para = sel_para_to;
start_index = sel_index_to;
- for ( i = 0; i < former_req_len; i++)
+ for ( int i = 0; i < former_req_len; i++)
QTextEditPositionBackward( &start_para, &start_index );
}
} else {
diff --git a/qt4/immodule/quiminputcontext_compose.cpp b/qt4/immodule/quiminputcontext_compose.cpp
index 028c048..1d5fa6d 100644
--- a/qt4/immodule/quiminputcontext_compose.cpp
+++ b/qt4/immodule/quiminputcontext_compose.cpp
@@ -326,7 +326,7 @@ nexttoken(FILE *fp, char **tokenbuf, int *lastch, size_t *buflen)
int c;
int token;
char *p;
- int i, j;
+ int i;
size_t len = 0;
while ((c = nextch(fp, lastch)) == ' ' || c == '\t') {
@@ -395,7 +395,7 @@ nexttoken(FILE *fp, char **tokenbuf, int *lastch, size_t *buflen)
case '7':
i = c - '0';
c = nextch(fp, lastch);
- for (j = 0; j < 2 && c >= '0' && c <= '7'; j++) {
+ for (int j = 0; j < 2 && c >= '0' && c <= '7'; j++) {
i <<= 3;
i += c - '0';
c = nextch(fp, lastch);
@@ -407,6 +407,7 @@ nexttoken(FILE *fp, char **tokenbuf, int *lastch, size_t *buflen)
case 'X':
case 'x':
i = 0;
+ int j;
for (j = 0; j < 2; j++) {
c = nextch(fp, lastch);
i <<= 4;
@@ -496,8 +497,6 @@ modmask(char *name)
const char *name;
long mask;
};
- struct _modtbl *p;
-
static struct _modtbl tbl[] = {
{ "Ctrl", ControlMask },
{ "Lock", LockMask },
@@ -507,9 +506,8 @@ modmask(char *name)
{ "Meta", Mod1Mask },
{ 0, 0 }};
- p = tbl;
mask = 0;
- for (p = tbl; p->name != 0; p++) {
+ for (struct _modtbl *p = tbl; p->name != 0; p++) {
if (strcmp(name, p->name) == 0) {
mask = p->mask;
break;
@@ -678,7 +676,7 @@ QUimInputContext::parse_compose_line(FILE *fp, char **tokenbuf, size_t *buflen)
};
struct DefBuffer buf[SEQUENCE_MAX];
- int i, n;
+ int n;
QTextCodec *codec = QTextCodec::codecForLocale();
QString qs;
@@ -819,7 +817,7 @@ QUimInputContext::parse_compose_line(FILE *fp, char **tokenbuf, size_t *buflen)
qs = codec->toUnicode(rhs_string_mb);
rhs_string_utf8 = strdup((const char *)qs.utf8());
- for (i = 0; i < n; i++) {
+ for (int i = 0; i < n; i++) {
for (p = *top; p; p = p->next) {
if (buf[i].keysym == p->keysym &&
buf[i].modifier == p->modifier &&
--
1.6.4.2
Subject: [PATCH 22/26] make edittest independent of Qt3Support
---
qt4/edittest/edittest.pro | 1 -
qt4/edittest/main.cpp | 25 +++++++++++++++++--------
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/qt4/edittest/edittest.pro b/qt4/edittest/edittest.pro
index 8795233..220d60c 100644
--- a/qt4/edittest/edittest.pro
+++ b/qt4/edittest/edittest.pro
@@ -7,7 +7,6 @@ CONFIG -= moc
DEPENDPATH += .
INCLUDEPATH += .
CONFIG += qt warn_on debug
-QT += qt3support
# Input
SOURCES += main.cpp
diff --git a/qt4/edittest/main.cpp b/qt4/edittest/main.cpp
index 38aad26..d374c57 100644
--- a/qt4/edittest/main.cpp
+++ b/qt4/edittest/main.cpp
@@ -36,22 +36,31 @@
#include <QtGui/QLineEdit>
#include <QtGui/QSplitter>
#include <QtGui/QTextEdit>
-#include <Qt3Support/Q3VBox>
+#include <QtGui/QVBoxLayout>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QSplitter page;
- Q3VBox *linev = new Q3VBox(&page);
- new QLabel("lineedit", linev);
- new QLineEdit(linev);
+ QWidget *linev = new QWidget(&page);
+ QLabel *lineLabel = new QLabel("lineedit");
+ QLineEdit *lineEdit = new QLineEdit;
- Q3VBox *textv = new Q3VBox(&page);
- new QLabel("textedit", textv);
- new QTextEdit(textv);
+ QVBoxLayout *lineLayout = new QVBoxLayout;
+ lineLayout->addWidget(lineLabel);
+ lineLayout->addWidget(lineEdit);
+ linev->setLayout(lineLayout);
+
+ QWidget *textv = new QWidget(&page);
+ QLabel *textLabel = new QLabel("textedit");
+ QTextEdit *textEdit = new QTextEdit;
+
+ QVBoxLayout *textLayout = new QVBoxLayout;
+ textLayout->addWidget(textLabel);
+ textLayout->addWidget(textEdit);
+ textv->setLayout(textLayout);
- app.setMainWidget(&page);
page.show();
return app.exec();
--
1.6.4.2
Subject: [PATCH 23/26] replace Q3ValueList with QList in uim-candwin-qt4
---
qt4/candwin/qt4.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/qt4/candwin/qt4.h b/qt4/candwin/qt4.h
index eb37391..1874da9 100644
--- a/qt4/candwin/qt4.h
+++ b/qt4/candwin/qt4.h
@@ -33,9 +33,9 @@
#ifndef UIM_QT4_CANDWIN_QT_H
#define UIM_QT4_CANDWIN_QT_H
+#include <QtCore/QList>
#include <Qt3Support/Q3ListView>
#include <Qt3Support/Q3VBox>
-#include <Qt3Support/Q3ValueList>
#include <uim/uim.h>
#include <uim/uim-helper.h>
@@ -86,7 +86,7 @@ protected:
CandidateListView *cList;
QLabel *numLabel;
- Q3ValueList<CandData> stores;
+ QList<CandData> stores;
int nrCandidates;
int candidateIndex;
--
1.6.4.2
Subject: [PATCH 24/26] replace Q3VBox with QFrame in uim-candwin-qt4
---
qt4/candwin/qt4.cpp | 14 +++++++++++---
qt4/candwin/qt4.h | 6 +++---
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/qt4/candwin/qt4.cpp b/qt4/candwin/qt4.cpp
index 934e20e..178e895 100644
--- a/qt4/candwin/qt4.cpp
+++ b/qt4/candwin/qt4.cpp
@@ -46,6 +46,7 @@
#include <QtGui/QApplication>
#include <QtGui/QDesktopWidget>
#include <QtGui/QLabel>
+#include <QtGui/QVBoxLayout>
#include <Qt3Support/Q3Header>
#include "qtgettext.h"
@@ -63,8 +64,8 @@ const Qt::WFlags candidateFlag = ( Qt::Window
);
static QSocketNotifier *notifier = 0;
-CandidateWindow::CandidateWindow( QWidget *parent, const char * name )
- : Q3VBox( parent, name, candidateFlag )
+CandidateWindow::CandidateWindow( QWidget *parent )
+ : QFrame( parent, candidateFlag )
{
setFrameStyle( Raised | NoFrame );
setFocusPolicy( Qt::NoFocus );
@@ -85,7 +86,7 @@ CandidateWindow::CandidateWindow( QWidget *parent, const char * name )
this , SLOT( slotCandidateSelected( Q3ListViewItem * ) ) );
//setup NumberLabel
- numLabel = new QLabel( this, "candidateLabel" );
+ numLabel = new QLabel;
numLabel->setFocusPolicy( Qt::NoFocus );
nrCandidates = 0;
@@ -98,6 +99,13 @@ CandidateWindow::CandidateWindow( QWidget *parent, const char * name )
notifier = new QSocketNotifier( 0, QSocketNotifier::Read );
connect( notifier, SIGNAL( activated( int ) ),
this, SLOT( slotStdinActivated( int ) ) );
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->setMargin( 0 );
+ layout->addWidget( cList );
+ layout->addWidget( numLabel );
+ setLayout( layout );
+
hide();
}
diff --git a/qt4/candwin/qt4.h b/qt4/candwin/qt4.h
index 1874da9..4a13547 100644
--- a/qt4/candwin/qt4.h
+++ b/qt4/candwin/qt4.h
@@ -34,8 +34,8 @@
#define UIM_QT4_CANDWIN_QT_H
#include <QtCore/QList>
+#include <QtGui/QFrame>
#include <Qt3Support/Q3ListView>
-#include <Qt3Support/Q3VBox>
#include <uim/uim.h>
#include <uim/uim-helper.h>
@@ -52,11 +52,11 @@ struct CandData
QString str;
};
-class CandidateWindow : public Q3VBox
+class CandidateWindow : public QFrame
{
Q_OBJECT
public:
- explicit CandidateWindow( QWidget *parent = 0, const char * name = 0 );
+ explicit CandidateWindow( QWidget *parent = 0 );
~CandidateWindow();
void activateCand( const QStringList &list );
--
1.6.4.2
Subject: [PATCH 25/26] replace Q3ListView with QTableWidget
---
qt4/candwin/qt4.cpp | 71 ++++++++++++++++++++++++++++----------------------
qt4/candwin/qt4.h | 53 +++-----------------------------------
2 files changed, 44 insertions(+), 80 deletions(-)
diff --git a/qt4/candwin/qt4.cpp b/qt4/candwin/qt4.cpp
index 178e895..ef29b5e 100644
--- a/qt4/candwin/qt4.cpp
+++ b/qt4/candwin/qt4.cpp
@@ -45,9 +45,10 @@
#include <QtCore/QTextCodec>
#include <QtGui/QApplication>
#include <QtGui/QDesktopWidget>
+#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
+#include <QtGui/QTableWidget>
#include <QtGui/QVBoxLayout>
-#include <Qt3Support/Q3Header>
#include "qtgettext.h"
@@ -71,19 +72,18 @@ CandidateWindow::CandidateWindow( QWidget *parent )
setFocusPolicy( Qt::NoFocus );
//setup CandidateList
- cList = new CandidateListView( this, "candidateListView" );
- cList->setSorting( -1 );
- cList->setSelectionMode( Q3ListView::Single );
- cList->addColumn( "1" );
- cList->setColumnWidthMode( 0, Q3ListView::Maximum );
- cList->addColumn( "2" );
- cList->setColumnWidthMode( 1, Q3ListView::Maximum );
- cList->header() ->hide();
- cList->setVScrollBarMode( Q3ScrollView::AlwaysOff );
- cList->setHScrollBarMode( Q3ScrollView::AlwaysOff );
- cList->setAllColumnsShowFocus( true );
- connect( cList, SIGNAL( clicked( Q3ListViewItem * ) ),
- this , SLOT( slotCandidateSelected( Q3ListViewItem * ) ) );
+ cList = new QTableWidget;
+ cList->setSelectionMode( QAbstractItemView::SingleSelection );
+ cList->setSelectionBehavior( QAbstractItemView::SelectRows );
+ cList->setColumnCount( 2 );
+ cList->horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents );
+ cList->horizontalHeader()->hide();
+ cList->verticalHeader()->hide();
+ cList->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
+ cList->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
+ cList->setShowGrid( false );
+ connect( cList, SIGNAL( itemClicked( QTableWidgetItem * ) ),
+ this , SLOT( slotCandidateSelected( QTableWidgetItem * ) ) );
//setup NumberLabel
numLabel = new QLabel;
@@ -125,7 +125,7 @@ void CandidateWindow::activateCand( const QStringList &list )
*/
// remove old data
- cList->clear();
+ cList->clearContents();
stores.clear();
// get charset and create codec
@@ -265,7 +265,7 @@ void CandidateWindow::setNrCandidates( const QStringList &list )
return ;
// remove old data
- cList->clear();
+ cList->clearContents();
stores.clear();
// set default value
@@ -413,9 +413,9 @@ void CandidateWindow::strParse( const QString& str )
}
}
-void CandidateWindow::slotCandidateSelected( Q3ListViewItem * item )
+void CandidateWindow::slotCandidateSelected( QTableWidgetItem * item )
{
- candidateIndex = ( pageIndex * displayLimit ) + cList->itemIndex( item );
+ candidateIndex = ( pageIndex * displayLimit ) + cList->row( item );
// write message
fprintf( stdout, "index\n" );
@@ -431,26 +431,24 @@ void CandidateWindow::adjustCandidateWindowSize()
qDebug( "adjustCandidateWindowSize()" );
#endif
int width = 0;
- int height = 0;
- Q3ListViewItem *item = cList->firstChild();
- if ( item )
- height = item->height() * ( cList->childCount() + 1 );
+ int height = cList->rowHeight(0) * ( cList->rowCount() + 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...
int maxCharIndex = 0, maxCharCount = 0;
- for ( int i = 0; i < cList->childCount(); i++ )
+ for ( int i = 0; i < cList->rowCount(); i++ )
{
- if ( maxCharCount < cList->itemAtIndex( i ) ->text( 1 ).length() )
+ if ( maxCharCount < cList->item( i, 1 )->text().length() )
{
maxCharIndex = i;
- maxCharCount = cList->itemAtIndex( i ) ->text( 1 ).length();
+ maxCharCount = cList->item( i, 1 )->text().length();
}
}
QFontMetrics fm( cList->font() );
- width = fm.width( cList->itemAtIndex( maxCharIndex ) ->text( 0 ) + " " + cList->itemAtIndex( maxCharIndex ) ->text( 1 ) );
+ width = fm.width( cList->item( maxCharIndex, 0 )->text()
+ + " " + cList->item( maxCharIndex, 1 ) ->text() );
if ( width < MIN_CAND_WIDTH )
width = MIN_CAND_WIDTH;
@@ -460,7 +458,7 @@ void CandidateWindow::adjustCandidateWindowSize()
void CandidateWindow::setPage( int page )
{
// clear items
- cList->clear();
+ cList->clearContents();
// calculate page
int newpage, lastpage;
@@ -511,13 +509,20 @@ void CandidateWindow::setPage( int page )
int ncandidates = displayLimit;
if ( newpage == lastpage )
ncandidates = nrCandidates - displayLimit * lastpage;
- for ( int i = ncandidates - 1; i >=0 ; i-- )
+ for ( int i = 0; i < ncandidates ; i++ )
{
QString headString = stores[ displayLimit * newpage + i ].label;
QString candString = stores[ displayLimit * newpage + i ].str;
// insert new item to the candidate list
- new Q3ListViewItem( cList, headString, candString );
+ QTableWidgetItem *headItem = new QTableWidgetItem;
+ headItem->setText( headString );
+ QTableWidgetItem *candItem = new QTableWidgetItem;
+ candItem->setText( candString );
+ int count = cList->rowCount();
+ cList->setRowCount( count + 1 );
+ cList->setItem( count, 0, headItem );
+ cList->setItem( count, 1, candItem );
}
// set index
@@ -557,8 +562,12 @@ void CandidateWindow::setIndex( int index )
if ( displayLimit )
pos = candidateIndex % displayLimit;
- if ( cList->itemAtIndex( pos ) && ! ( cList->itemAtIndex( pos ) ->isSelected() ) )
- cList->setSelected( cList->itemAtIndex( pos ), true );
+ if ( cList->item( pos, 0 ) && !cList->item( pos, 0 )->isSelected() )
+ {
+ cList->clearSelection();
+ cList->item( pos, 0 )->setSelected( true );
+ cList->item( pos, 1 )->setSelected( true );
+ }
}
else
{
diff --git a/qt4/candwin/qt4.h b/qt4/candwin/qt4.h
index 4a13547..90ab36a 100644
--- a/qt4/candwin/qt4.h
+++ b/qt4/candwin/qt4.h
@@ -35,7 +35,6 @@
#include <QtCore/QList>
#include <QtGui/QFrame>
-#include <Qt3Support/Q3ListView>
#include <uim/uim.h>
#include <uim/uim-helper.h>
@@ -43,8 +42,8 @@
class QLabel;
class QPoint;
class QStringList;
-
-class CandidateListView;
+class QTableWidget;
+class QTableWidgetItem;
struct CandData
{
@@ -71,7 +70,7 @@ public:
public slots:
void slotStdinActivated( int );
- void slotCandidateSelected( Q3ListViewItem* );
+ void slotCandidateSelected( QTableWidgetItem* );
protected:
void strParse( const QString& str );
@@ -83,7 +82,7 @@ protected:
void updateLabel();
protected:
- CandidateListView *cList;
+ QTableWidget *cList;
QLabel *numLabel;
QList<CandData> stores;
@@ -97,48 +96,4 @@ protected:
bool needHighlight;
};
-class CandidateListView : public Q3ListView
-{
- Q_OBJECT
-
-public:
- explicit CandidateListView( QWidget *parent, const char *name = 0, Qt::WFlags f = 0 ) : Q3ListView( parent, name, f ) {}
- ~CandidateListView() {}
-
-
- int itemIndex( const Q3ListViewItem *item ) const
- {
- if ( !item )
- return -1;
-
- if ( item == firstChild() )
- return 0;
- else
- {
- Q3ListViewItemIterator it( firstChild() );
- uint j = 0;
- for ( ; it.current() && it.current() != item; ++it, ++j ) ;
-
- if ( !it.current() )
- return -1;
- return j;
- }
- }
-
- Q3ListViewItem* itemAtIndex( int index )
- {
- if ( index < 0 )
- return 0;
-
- int j = 0;
- for ( Q3ListViewItemIterator it = firstChild(); it.current(); ++it )
- {
- if ( j == index )
- return it.current();
- j++;
- };
- return 0;
- }
-};
-
#endif /* UIM_QT4_CANDWIN_QT_H */
--
1.6.4.2
Subject: [PATCH 26/26] make uim-candwin-qt4 independent of Qt3Support
---
qt4/candwin/qt4.cpp | 34 +++++++++++++++++-----------------
qt4/candwin/uim-candwin-qt4.pro.in | 1 -
2 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/qt4/candwin/qt4.cpp b/qt4/candwin/qt4.cpp
index ef29b5e..a3852af 100644
--- a/qt4/candwin/qt4.cpp
+++ b/qt4/candwin/qt4.cpp
@@ -133,15 +133,15 @@ void CandidateWindow::activateCand( const QStringList &list )
if ( !list[ 1 ].isEmpty()
&& list[ 1 ].startsWith( QLatin1String( "charset" ) ) )
{
- const QStringList l = QStringList::split( "=", list[ 1 ] );
- codec = QTextCodec::codecForName( l[ 1 ] );
+ const QStringList l = list[ 1 ].split( '=', QString::SkipEmptyParts );
+ codec = QTextCodec::codecForName( l[ 1 ].toAscii() );
}
// get display_limit
if ( !list[ 2 ].isEmpty()
&& list[ 2 ].startsWith( QLatin1String( "display_limit" ) ) )
{
- const QStringList l = QStringList::split( "=", list[ 2 ] );
+ const QStringList l = list[ 2 ].split( '=', QString::SkipEmptyParts );
displayLimit = l[ 1 ].toInt();
}
@@ -152,13 +152,13 @@ void CandidateWindow::activateCand( const QStringList &list )
break;
// split heading_label and cand_str
- QStringList l = QStringList::split( "\t", list [ i ], true );
+ QStringList l = list [ i ].split( '\t' );
// store data
CandData d;
QString headString;
if ( codec )
- headString = codec->toUnicode( l [ 0 ] );
+ headString = codec->toUnicode( l [ 0 ].toAscii() );
else
headString = l [ 0 ];
@@ -171,7 +171,7 @@ void CandidateWindow::activateCand( const QStringList &list )
QString candString = l.join( "\t" );
if ( codec )
- d.str = codec->toUnicode( candString );
+ d.str = codec->toUnicode( candString.toAscii() );
else
d.str = candString;
@@ -297,15 +297,15 @@ void CandidateWindow::setPageCandidates( const QStringList &list )
if ( !list[ 1 ].isEmpty()
&& list[ 1 ].startsWith( QLatin1String( "charset" ) ) )
{
- const QStringList l = QStringList::split( "=", list[ 1 ] );
- codec = QTextCodec::codecForName( l[ 1 ] );
+ const QStringList l = list[ 1 ].split( '=', QString::SkipEmptyParts );
+ codec = QTextCodec::codecForName( l[ 1 ].toAscii() );
}
// get page
if ( !list[ 2 ].isEmpty()
&& list[ 2 ].startsWith( QLatin1String( "page" ) ) )
{
- const QStringList l = QStringList::split( "=", list[ 2 ] );
+ const QStringList l = list[ 2 ].split( '=', QString::SkipEmptyParts );
page = l[ 1 ].toInt();
}
@@ -317,13 +317,13 @@ void CandidateWindow::setPageCandidates( const QStringList &list )
break;
// split heading_label and cand_str
- QStringList l = QStringList::split( "\t", list [ i ], true );
+ QStringList l = list [ i ].split( '\t' );
// store data
CandData &d = stores[page * displayLimit + i - 3];
QString headString;
if ( codec )
- headString = codec->toUnicode( l [ 0 ] );
+ headString = codec->toUnicode( l [ 0 ].toAscii() );
else
headString = l [ 0 ];
@@ -336,7 +336,7 @@ void CandidateWindow::setPageCandidates( const QStringList &list )
QString candString = l.join( "\t" );
if ( codec )
- d.str = codec->toUnicode( candString );
+ d.str = codec->toUnicode( candString.toAscii() );
else
d.str = candString;
}
@@ -362,7 +362,7 @@ void CandidateWindow::slotStdinActivated( int fd )
n = read( fd, buf, 4096 - 1 );
if ( n == 0 )
{
- close( fd );
+ ::close( fd );
exit( 1 );
}
if ( n == -1 )
@@ -372,7 +372,7 @@ void CandidateWindow::slotStdinActivated( int fd )
strcat( read_buf, buf );
}
- QStringList msgList = QStringList::split( "\n\n", QString( read_buf ) );
+ QStringList msgList = QString( read_buf ).split( "\n\n", QString::SkipEmptyParts );
QStringList::Iterator it = msgList.begin();
const QStringList::Iterator end = msgList.end();
@@ -384,9 +384,9 @@ void CandidateWindow::slotStdinActivated( int fd )
void CandidateWindow::strParse( const QString& str )
{
#if defined(ENABLE_DEBUG)
- qDebug( "str = %s", ( const char* ) str.local8Bit() );
+ qDebug( "str = %s", str.toLocal8Bit().data() );
#endif
- QStringList list = QStringList::split( "\n", str );
+ QStringList list = str.split( '\n', QString::SkipEmptyParts );
QStringList::Iterator it = list.begin();
const QStringList::Iterator end = list.end();
@@ -523,6 +523,7 @@ void CandidateWindow::setPage( int page )
cList->setRowCount( count + 1 );
cList->setItem( count, 0, headItem );
cList->setItem( count, 1, candItem );
+ cList->setRowHeight( count, QFontMetrics( font() ).height() );
}
// set index
@@ -598,7 +599,6 @@ int main( int argc, char *argv[] )
QApplication a( argc, argv );
CandidateWindow b;
- a.setMainWidget( &b );
return a.exec();
}
diff --git a/qt4/candwin/uim-candwin-qt4.pro.in b/qt4/candwin/uim-candwin-qt4.pro.in
index 4ed2605..fe45a8d 100644
--- a/qt4/candwin/uim-candwin-qt4.pro.in
+++ b/qt4/candwin/uim-candwin-qt4.pro.in
@@ -1,6 +1,5 @@
TEMPLATE = app
CONFIG += @QT_CONFIG_OPTS@
-QT += qt3support
INCLUDEPATH += @top_builddir@ @top_builddir@/uim \
@top_srcdir@ @top_srcdir@/uim \
--
1.6.4.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment