insilmaril@0
|
1 |
#include <qlineedit.h>
|
insilmaril@0
|
2 |
|
insilmaril@0
|
3 |
#include "findwindow.h"
|
insilmaril@0
|
4 |
|
insilmaril@0
|
5 |
|
insilmaril@167
|
6 |
FindWindow::FindWindow(QWidget* parent, const char* name)
|
insilmaril@0
|
7 |
: QGroupBox( 0, Horizontal, "Find", parent, name )
|
insilmaril@0
|
8 |
|
insilmaril@0
|
9 |
{
|
insilmaril@0
|
10 |
setCaption ("VYM - Find Text");
|
insilmaril@0
|
11 |
//resize (180,130);
|
insilmaril@0
|
12 |
move (130,130);
|
insilmaril@0
|
13 |
|
insilmaril@0
|
14 |
setMargin( 100 );
|
insilmaril@0
|
15 |
|
insilmaril@0
|
16 |
QVBoxLayout* box = new QVBoxLayout( layout() );
|
insilmaril@0
|
17 |
|
insilmaril@0
|
18 |
QHBoxLayout *row1 = new QHBoxLayout( box );
|
insilmaril@0
|
19 |
row1->setMargin( 10 );
|
insilmaril@0
|
20 |
|
insilmaril@0
|
21 |
// Create a Label
|
insilmaril@0
|
22 |
QLabel* label = new QLabel( "Text to find: ", this);
|
insilmaril@0
|
23 |
row1->addWidget( label );
|
insilmaril@0
|
24 |
|
insilmaril@0
|
25 |
// Create LineEdit (here QComboBox)
|
insilmaril@0
|
26 |
QHBoxLayout *row2 = new QHBoxLayout( box );
|
insilmaril@0
|
27 |
row2->setMargin( 10 );
|
insilmaril@0
|
28 |
findcombo = new QComboBox( true, this );
|
insilmaril@0
|
29 |
findcombo->setMinimumWidth(150);
|
insilmaril@0
|
30 |
row2->addWidget( findcombo );
|
insilmaril@0
|
31 |
connect ( findcombo, SIGNAL( highlighted(int) ),
|
insilmaril@0
|
32 |
this, SLOT( findPressed() ) );
|
insilmaril@0
|
33 |
connect ( findcombo, SIGNAL( textChanged(const QString &) ),
|
insilmaril@0
|
34 |
this, SLOT( findTextChanged(const QString&) ) );
|
insilmaril@0
|
35 |
//findcombo->insertItem( "Normal", -1 );
|
insilmaril@0
|
36 |
|
insilmaril@0
|
37 |
// Create Buttons
|
insilmaril@0
|
38 |
QHBoxLayout *row3 = new QHBoxLayout( box );
|
insilmaril@0
|
39 |
row3->setMargin( 10 );
|
insilmaril@0
|
40 |
clearbutton = new QPushButton (tr("Clear"),this);
|
insilmaril@0
|
41 |
connect ( clearbutton, SIGNAL( clicked() ),
|
insilmaril@0
|
42 |
findcombo, SLOT( clearEdit() ) );
|
insilmaril@0
|
43 |
row3->addWidget (clearbutton);
|
insilmaril@0
|
44 |
|
insilmaril@0
|
45 |
QSpacerItem *si1= new QSpacerItem (10,0,QSizePolicy::Minimum, QSizePolicy::Expanding );
|
insilmaril@0
|
46 |
row3->addItem(si1);
|
insilmaril@0
|
47 |
|
insilmaril@0
|
48 |
cancelbutton = new QPushButton (tr("Cancel"),this);
|
insilmaril@0
|
49 |
cancelbutton->setAccel (Key_Escape);
|
insilmaril@0
|
50 |
connect ( cancelbutton, SIGNAL( clicked() ),
|
insilmaril@0
|
51 |
this, SLOT( cancelPressed() ) );
|
insilmaril@0
|
52 |
row3->addWidget (cancelbutton);
|
insilmaril@0
|
53 |
|
insilmaril@0
|
54 |
QSpacerItem *si2= new QSpacerItem (10,0,QSizePolicy::Fixed, QSizePolicy::Fixed);
|
insilmaril@0
|
55 |
row3->addItem(si2);
|
insilmaril@0
|
56 |
|
insilmaril@0
|
57 |
findbutton = new QPushButton (tr("Find"),this);
|
insilmaril@0
|
58 |
findbutton->setDefault (true);
|
insilmaril@0
|
59 |
connect ( findbutton, SIGNAL( clicked() ),
|
insilmaril@0
|
60 |
this, SLOT( findPressed() ) );
|
insilmaril@0
|
61 |
row3->add(findbutton);
|
insilmaril@0
|
62 |
|
insilmaril@0
|
63 |
findcombo->setFocus();
|
insilmaril@0
|
64 |
}
|
insilmaril@0
|
65 |
|
insilmaril@0
|
66 |
void FindWindow::popup()
|
insilmaril@0
|
67 |
{
|
insilmaril@0
|
68 |
findcombo->lineEdit()->selectAll();
|
insilmaril@0
|
69 |
show();
|
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 |
}
|