5 #include "findwindow.h"
9 FindWindow::FindWindow(QWidget* parent)
10 : QGroupBox( tr("Find"), parent )
13 setWindowTitle(__VYM " - " +tr("Find Text"));
17 QVBoxLayout* mainLayout = new QVBoxLayout;
19 QHBoxLayout *row1Layout = new QHBoxLayout;
21 QLabel* label = new QLabel;
22 label->setText( tr("Text to find:"));
23 row1Layout->addWidget( label );
26 // Create LineEdit (here QComboBox)
27 QHBoxLayout *row2Layout = new QHBoxLayout;
28 findcombo = new QComboBox;
29 findcombo->setMinimumWidth(150);
30 findcombo->setEditable(true);
31 connect ( findcombo, SIGNAL( highlighted(int) ),
32 this, SLOT( findPressed() ) );
33 connect ( findcombo, SIGNAL( textChanged(const QString &) ),
34 this, SLOT( findTextChanged(const QString&) ) );
35 //findcombo->insertItem( "Normal", -1 );
37 row2Layout->addWidget(findcombo);
40 QHBoxLayout *row3Layout = new QHBoxLayout;
41 clearbutton = new QPushButton;
42 clearbutton->setText(tr("Clear"));
43 connect ( clearbutton, SIGNAL( clicked() ), this, SLOT( clearLineEdit() ) );
44 row3Layout->addWidget (clearbutton);
47 QSpacerItem *si1= new QSpacerItem (10,0,QSizePolicy::Minimum, QSizePolicy::Expanding );
48 row3Layout->addItem(si1);
51 cancelbutton = new QPushButton;
52 cancelbutton->setText(tr("Cancel"));
53 cancelbutton->setShortcut (Qt::Key_Escape);
54 connect ( cancelbutton, SIGNAL( clicked() ), this, SLOT( cancelPressed() ) );
55 row3Layout->addWidget (cancelbutton);
58 QSpacerItem *si2= new QSpacerItem (10,0,QSizePolicy::Fixed, QSizePolicy::Fixed);
59 row3Layout->addItem(si2);
62 findbutton = new QPushButton;
63 findbutton->setText (tr("Find"));
64 findbutton->setDefault (true);
65 findbutton->setShortcut (Qt::Key_Return);
66 connect ( findbutton, SIGNAL( clicked() ), this, SLOT( findPressed() ) );
68 row3Layout->addWidget(findbutton);
70 mainLayout->addLayout (row1Layout);
71 mainLayout->addLayout (row2Layout);
72 mainLayout->addLayout (row3Layout);
73 setLayout (mainLayout);
76 void FindWindow::popup()
79 findcombo->lineEdit()->selectAll();
80 findcombo->setFocus();
83 void FindWindow::cancelPressed()
88 void FindWindow::findPressed()
90 emit (findButton(findcombo->currentText() ) );
93 void FindWindow::findTextChanged(const QString&)
95 emit (somethingChanged() );
98 void FindWindow::clearLineEdit()
100 findcombo->lineEdit()->clear();