diff -r 1f6263d403a0 -r 97f5d07bf47d findwindow.cpp --- a/findwindow.cpp Tue Sep 05 10:03:29 2006 +0000 +++ b/findwindow.cpp Tue Sep 05 11:53:54 2006 +0000 @@ -1,77 +1,83 @@ -#include -//Added by qt3to4: -#include -#include +#include +#include #include #include "findwindow.h" #include "version.h" -FindWindow::FindWindow(QWidget* parent, const char* name) - : Q3GroupBox( 0, Qt::Horizontal, "Find", parent, name ) +FindWindow::FindWindow(QWidget* parent) + : QGroupBox( tr("Find"), parent ) { - setCaption (__VYM " - " +tr("Find Text")); + setWindowTitle(__VYM " - " +tr("Find Text")); //resize (180,130); - move (130,130); + //move (130,130); - //FIXME not avail in QT4 setMargin( 100 ); + QVBoxLayout* mainLayout = new QVBoxLayout; + + QHBoxLayout *row1Layout = new QHBoxLayout; + // Create a Label + QLabel* label = new QLabel; + label->setText( tr("Text to find:")); + row1Layout->addWidget( label ); - Q3VBoxLayout* box = new Q3VBoxLayout( layout() ); - - Q3HBoxLayout *row1 = new Q3HBoxLayout( box ); - row1->setMargin( 10 ); - - // Create a Label - QLabel* label = new QLabel( "Text to find: ", this); - row1->addWidget( label ); // Create LineEdit (here QComboBox) - Q3HBoxLayout *row2 = new Q3HBoxLayout( box ); - row2->setMargin( 10 ); - findcombo = new QComboBox( true, this ); + QHBoxLayout *row2Layout = new QHBoxLayout; + findcombo = new QComboBox; findcombo->setMinimumWidth(150); - row2->addWidget( findcombo ); + findcombo->setEditable(true); connect ( findcombo, SIGNAL( highlighted(int) ), this, SLOT( findPressed() ) ); connect ( findcombo, SIGNAL( textChanged(const QString &) ), this, SLOT( findTextChanged(const QString&) ) ); //findcombo->insertItem( "Normal", -1 ); + row2Layout->addWidget(findcombo); + // Create Buttons - Q3HBoxLayout *row3 = new Q3HBoxLayout( box ); - row3->setMargin( 10 ); - clearbutton = new QPushButton (tr("Clear"),this); - connect ( clearbutton, SIGNAL( clicked() ), - findcombo, SLOT( clearEdit() ) ); - row3->addWidget (clearbutton); + QHBoxLayout *row3Layout = new QHBoxLayout; + clearbutton = new QPushButton; + clearbutton->setText(tr("Clear")); + connect ( clearbutton, SIGNAL( clicked() ), this, SLOT( clearLineEdit() ) ); + row3Layout->addWidget (clearbutton); + /* QSpacerItem *si1= new QSpacerItem (10,0,QSizePolicy::Minimum, QSizePolicy::Expanding ); - row3->addItem(si1); + row3Layout->addItem(si1); + */ - cancelbutton = new QPushButton (tr("Cancel"),this); - cancelbutton->setAccel (Qt::Key_Escape); - connect ( cancelbutton, SIGNAL( clicked() ), - this, SLOT( cancelPressed() ) ); - row3->addWidget (cancelbutton); + cancelbutton = new QPushButton; + cancelbutton->setText(tr("Cancel")); + cancelbutton->setShortcut (Qt::Key_Escape); + connect ( cancelbutton, SIGNAL( clicked() ), this, SLOT( cancelPressed() ) ); + row3Layout->addWidget (cancelbutton); +/* QSpacerItem *si2= new QSpacerItem (10,0,QSizePolicy::Fixed, QSizePolicy::Fixed); - row3->addItem(si2); + row3Layout->addItem(si2); + */ - findbutton = new QPushButton (tr("Find"),this); + findbutton = new QPushButton; + findbutton->setText (tr("Find")); findbutton->setDefault (true); - connect ( findbutton, SIGNAL( clicked() ), - this, SLOT( findPressed() ) ); - row3->add(findbutton); - - findcombo->setFocus(); + findbutton->setShortcut (Qt::Key_Return); + connect ( findbutton, SIGNAL( clicked() ), this, SLOT( findPressed() ) ); + + row3Layout->addWidget(findbutton); + + mainLayout->addLayout (row1Layout); + mainLayout->addLayout (row2Layout); + mainLayout->addLayout (row3Layout); + setLayout (mainLayout); } void FindWindow::popup() { + show(); findcombo->lineEdit()->selectAll(); - show(); + findcombo->setFocus(); } void FindWindow::cancelPressed() @@ -88,3 +94,8 @@ { emit (somethingChanged() ); } + +void FindWindow::clearLineEdit() +{ + findcombo->lineEdit()->clear(); +}