5 #include "findwindow.h"
9 FindWindow::FindWindow(QWidget* parent)
10 : QGroupBox( tr("Find"), parent )
13 setWindowTitle(__VYM " - " +tr("Find Text"));
15 QVBoxLayout* mainLayout = new QVBoxLayout;
17 QHBoxLayout *row1Layout = new QHBoxLayout;
19 QLabel* label = new QLabel;
20 label->setText( tr("Text to find:"));
21 row1Layout->addWidget( label );
24 // Create LineEdit (here QComboBox)
25 QHBoxLayout *row2Layout = new QHBoxLayout;
26 findcombo = new QComboBox;
27 findcombo->setMinimumWidth(150);
28 findcombo->setEditable(true);
29 connect ( findcombo, SIGNAL( highlighted(int) ),
30 this, SLOT( findPressed() ) );
31 connect ( findcombo, SIGNAL( textChanged(const QString &) ),
32 this, SLOT( findTextChanged(const QString&) ) );
34 row2Layout->addWidget(findcombo);
37 QHBoxLayout *row3Layout = new QHBoxLayout;
38 clearbutton = new QPushButton;
39 clearbutton->setText(tr("Clear"));
40 connect ( clearbutton, SIGNAL( clicked() ), this, SLOT( clearLineEdit() ) );
41 row3Layout->addWidget (clearbutton);
43 cancelbutton = new QPushButton;
44 cancelbutton->setText(tr("Cancel"));
45 cancelbutton->setShortcut (Qt::Key_Escape);
46 connect ( cancelbutton, SIGNAL( clicked() ), this, SLOT( cancelPressed() ) );
47 row3Layout->addWidget (cancelbutton);
49 findbutton = new QPushButton;
50 findbutton->setText (tr("Find"));
51 findbutton->setDefault (true);
52 findbutton->setShortcut (Qt::Key_Return);
53 connect ( findbutton, SIGNAL( clicked() ), this, SLOT( findPressed() ) );
55 row3Layout->addStretch(2);
56 row3Layout->addWidget(findbutton);
58 mainLayout->addLayout (row1Layout);
59 mainLayout->addLayout (row2Layout);
60 mainLayout->addLayout (row3Layout);
61 setLayout (mainLayout);
64 void FindWindow::popup()
67 findcombo->lineEdit()->selectAll();
68 findcombo->setFocus();
71 void FindWindow::cancelPressed()
76 void FindWindow::findPressed()
78 emit (findButton(findcombo->currentText() ) );
81 void FindWindow::findTextChanged(const QString&)
83 emit (somethingChanged() );
86 void FindWindow::clearLineEdit()
88 findcombo->lineEdit()->clear();