insilmaril@370
|
1 |
#include <QLineEdit>
|
insilmaril@370
|
2 |
#include <QVBoxLayout>
|
insilmaril@364
|
3 |
#include <QLabel>
|
insilmaril@0
|
4 |
|
insilmaril@0
|
5 |
#include "findwindow.h"
|
insilmaril@0
|
6 |
|
insilmaril@0
|
7 |
|
insilmaril@403
|
8 |
extern QString vymName;
|
insilmaril@403
|
9 |
|
insilmaril@370
|
10 |
FindWindow::FindWindow(QWidget* parent)
|
insilmaril@370
|
11 |
: QGroupBox( tr("Find"), parent )
|
insilmaril@0
|
12 |
|
insilmaril@0
|
13 |
{
|
insilmaril@403
|
14 |
setWindowTitle(vymName + " - " +tr("Find Text"));
|
insilmaril@0
|
15 |
|
insilmaril@370
|
16 |
QVBoxLayout* mainLayout = new QVBoxLayout;
|
insilmaril@370
|
17 |
|
insilmaril@370
|
18 |
QHBoxLayout *row1Layout = new QHBoxLayout;
|
insilmaril@370
|
19 |
// Create a Label
|
insilmaril@370
|
20 |
QLabel* label = new QLabel;
|
insilmaril@370
|
21 |
label->setText( tr("Text to find:"));
|
insilmaril@370
|
22 |
row1Layout->addWidget( label );
|
insilmaril@0
|
23 |
|
insilmaril@0
|
24 |
|
insilmaril@0
|
25 |
// Create LineEdit (here QComboBox)
|
insilmaril@370
|
26 |
QHBoxLayout *row2Layout = new QHBoxLayout;
|
insilmaril@370
|
27 |
findcombo = new QComboBox;
|
insilmaril@0
|
28 |
findcombo->setMinimumWidth(150);
|
insilmaril@370
|
29 |
findcombo->setEditable(true);
|
insilmaril@0
|
30 |
connect ( findcombo, SIGNAL( highlighted(int) ),
|
insilmaril@0
|
31 |
this, SLOT( findPressed() ) );
|
insilmaril@0
|
32 |
connect ( findcombo, SIGNAL( textChanged(const QString &) ),
|
insilmaril@0
|
33 |
this, SLOT( findTextChanged(const QString&) ) );
|
insilmaril@0
|
34 |
|
insilmaril@370
|
35 |
row2Layout->addWidget(findcombo);
|
insilmaril@370
|
36 |
|
insilmaril@0
|
37 |
// Create Buttons
|
insilmaril@370
|
38 |
QHBoxLayout *row3Layout = new QHBoxLayout;
|
insilmaril@370
|
39 |
clearbutton = new QPushButton;
|
insilmaril@370
|
40 |
clearbutton->setText(tr("Clear"));
|
insilmaril@370
|
41 |
connect ( clearbutton, SIGNAL( clicked() ), this, SLOT( clearLineEdit() ) );
|
insilmaril@370
|
42 |
row3Layout->addWidget (clearbutton);
|
insilmaril@0
|
43 |
|
insilmaril@370
|
44 |
cancelbutton = new QPushButton;
|
insilmaril@370
|
45 |
cancelbutton->setText(tr("Cancel"));
|
insilmaril@370
|
46 |
cancelbutton->setShortcut (Qt::Key_Escape);
|
insilmaril@370
|
47 |
connect ( cancelbutton, SIGNAL( clicked() ), this, SLOT( cancelPressed() ) );
|
insilmaril@370
|
48 |
row3Layout->addWidget (cancelbutton);
|
insilmaril@0
|
49 |
|
insilmaril@370
|
50 |
findbutton = new QPushButton;
|
insilmaril@370
|
51 |
findbutton->setText (tr("Find"));
|
insilmaril@0
|
52 |
findbutton->setDefault (true);
|
insilmaril@370
|
53 |
findbutton->setShortcut (Qt::Key_Return);
|
insilmaril@370
|
54 |
connect ( findbutton, SIGNAL( clicked() ), this, SLOT( findPressed() ) );
|
insilmaril@370
|
55 |
|
insilmaril@375
|
56 |
row3Layout->addStretch(2);
|
insilmaril@370
|
57 |
row3Layout->addWidget(findbutton);
|
insilmaril@370
|
58 |
|
insilmaril@370
|
59 |
mainLayout->addLayout (row1Layout);
|
insilmaril@370
|
60 |
mainLayout->addLayout (row2Layout);
|
insilmaril@370
|
61 |
mainLayout->addLayout (row3Layout);
|
insilmaril@370
|
62 |
setLayout (mainLayout);
|
insilmaril@0
|
63 |
}
|
insilmaril@0
|
64 |
|
insilmaril@0
|
65 |
void FindWindow::popup()
|
insilmaril@0
|
66 |
{
|
insilmaril@370
|
67 |
show();
|
insilmaril@0
|
68 |
findcombo->lineEdit()->selectAll();
|
insilmaril@370
|
69 |
findcombo->setFocus();
|
insilmaril@0
|
70 |
}
|
insilmaril@0
|
71 |
|
insilmaril@0
|
72 |
void FindWindow::cancelPressed()
|
insilmaril@0
|
73 |
{
|
insilmaril@0
|
74 |
hide();
|
insilmaril@0
|
75 |
}
|
insilmaril@0
|
76 |
|
insilmaril@0
|
77 |
void FindWindow::findPressed()
|
insilmaril@0
|
78 |
{
|
insilmaril@0
|
79 |
emit (findButton(findcombo->currentText() ) );
|
insilmaril@0
|
80 |
}
|
insilmaril@0
|
81 |
|
insilmaril@0
|
82 |
void FindWindow::findTextChanged(const QString&)
|
insilmaril@0
|
83 |
{
|
insilmaril@0
|
84 |
emit (somethingChanged() );
|
insilmaril@0
|
85 |
}
|
insilmaril@370
|
86 |
|
insilmaril@370
|
87 |
void FindWindow::clearLineEdit()
|
insilmaril@370
|
88 |
{
|
insilmaril@370
|
89 |
findcombo->lineEdit()->clear();
|
insilmaril@370
|
90 |
}
|