1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/findwindow.cpp Mon Oct 06 09:18:11 2008 +0000
1.3 @@ -0,0 +1,85 @@
1.4 +#include <qlineedit.h>
1.5 +
1.6 +#include "findwindow.h"
1.7 +
1.8 +
1.9 +FindWindow::FindWindow(QWidget* parent, const char* name, WFlags f)
1.10 + : QGroupBox( 0, Horizontal, "Find", parent, name )
1.11 +
1.12 +{
1.13 + setCaption ("VYM - Find Text");
1.14 + //resize (180,130);
1.15 + move (130,130);
1.16 +
1.17 + setMargin( 100 );
1.18 +
1.19 + QVBoxLayout* box = new QVBoxLayout( layout() );
1.20 +
1.21 + QHBoxLayout *row1 = new QHBoxLayout( box );
1.22 + row1->setMargin( 10 );
1.23 +
1.24 + // Create a Label
1.25 + QLabel* label = new QLabel( "Text to find: ", this);
1.26 + row1->addWidget( label );
1.27 +
1.28 + // Create LineEdit (here QComboBox)
1.29 + QHBoxLayout *row2 = new QHBoxLayout( box );
1.30 + row2->setMargin( 10 );
1.31 + findcombo = new QComboBox( true, this );
1.32 + findcombo->setMinimumWidth(150);
1.33 + row2->addWidget( findcombo );
1.34 + connect ( findcombo, SIGNAL( highlighted(int) ),
1.35 + this, SLOT( findPressed() ) );
1.36 + connect ( findcombo, SIGNAL( textChanged(const QString &) ),
1.37 + this, SLOT( findTextChanged(const QString&) ) );
1.38 + //findcombo->insertItem( "Normal", -1 );
1.39 +
1.40 + // Create Buttons
1.41 + QHBoxLayout *row3 = new QHBoxLayout( box );
1.42 + row3->setMargin( 10 );
1.43 + clearbutton = new QPushButton (tr("Clear"),this);
1.44 + connect ( clearbutton, SIGNAL( clicked() ),
1.45 + findcombo, SLOT( clearEdit() ) );
1.46 + row3->addWidget (clearbutton);
1.47 +
1.48 + QSpacerItem *si1= new QSpacerItem (10,0,QSizePolicy::Minimum, QSizePolicy::Expanding );
1.49 + row3->addItem(si1);
1.50 +
1.51 + cancelbutton = new QPushButton (tr("Cancel"),this);
1.52 + cancelbutton->setAccel (Key_Escape);
1.53 + connect ( cancelbutton, SIGNAL( clicked() ),
1.54 + this, SLOT( cancelPressed() ) );
1.55 + row3->addWidget (cancelbutton);
1.56 +
1.57 + QSpacerItem *si2= new QSpacerItem (10,0,QSizePolicy::Fixed, QSizePolicy::Fixed);
1.58 + row3->addItem(si2);
1.59 +
1.60 + findbutton = new QPushButton (tr("Find"),this);
1.61 + findbutton->setDefault (true);
1.62 + connect ( findbutton, SIGNAL( clicked() ),
1.63 + this, SLOT( findPressed() ) );
1.64 + row3->add(findbutton);
1.65 +
1.66 + findcombo->setFocus();
1.67 +}
1.68 +
1.69 +void FindWindow::popup()
1.70 +{
1.71 + findcombo->lineEdit()->selectAll();
1.72 + show();
1.73 +}
1.74 +
1.75 +void FindWindow::cancelPressed()
1.76 +{
1.77 + hide();
1.78 +}
1.79 +
1.80 +void FindWindow::findPressed()
1.81 +{
1.82 + emit (findButton(findcombo->currentText() ) );
1.83 +}
1.84 +
1.85 +void FindWindow::findTextChanged(const QString&)
1.86 +{
1.87 + emit (somethingChanged() );
1.88 +}