File: findwindow.cpp

package info (click to toggle)
vym 1.10.0-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 5,376 kB
  • ctags: 1,926
  • sloc: cpp: 18,468; xml: 277; sh: 211; perl: 89; makefile: 26
file content (90 lines) | stat: -rw-r--r-- 2,185 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <QLineEdit>
#include <QVBoxLayout>
#include <QLabel>

#include "findwindow.h"


extern QString vymName;

FindWindow::FindWindow(QWidget* parent)
	: QGroupBox( tr("Find"), parent )

{
	setWindowTitle(vymName + " - " +tr("Find Text"));

    QVBoxLayout* mainLayout = new QVBoxLayout;
    
    QHBoxLayout *row1Layout = new QHBoxLayout;
    // Create a Label
    QLabel* label = new QLabel;
    label->setText( tr("Text to find:"));
    row1Layout->addWidget( label );


	// Create LineEdit (here QComboBox)
    QHBoxLayout *row2Layout = new QHBoxLayout;
    findcombo = new QComboBox;
	findcombo->setMinimumWidth(150);
	findcombo->setEditable(true);
	connect ( findcombo, SIGNAL( highlighted(int) ), 
		this, SLOT( findPressed() ) );
	connect ( findcombo, SIGNAL( textChanged(const QString &) ), 
		this, SLOT( findTextChanged(const QString&) ) );

	row2Layout->addWidget(findcombo);

	// Create Buttons
    QHBoxLayout *row3Layout = new QHBoxLayout;
	clearbutton = new QPushButton;
	clearbutton->setText(tr("Clear"));
	connect ( clearbutton, SIGNAL( clicked() ), this, SLOT( clearLineEdit() ) );
	row3Layout->addWidget (clearbutton);
	
	cancelbutton = new QPushButton;
	cancelbutton->setText(tr("Cancel"));
	cancelbutton->setShortcut (Qt::Key_Escape);
	connect ( cancelbutton, SIGNAL( clicked() ), this, SLOT( cancelPressed() ) );
	row3Layout->addWidget (cancelbutton);
	
	findbutton = new QPushButton;
	findbutton->setText (tr("Find"));
	findbutton->setDefault (true);
	findbutton->setShortcut (Qt::Key_Return);
	connect ( findbutton, SIGNAL( clicked() ), this, SLOT( findPressed() ) );

	row3Layout->addStretch(2);
	row3Layout->addWidget(findbutton);

	mainLayout->addLayout (row1Layout);
	mainLayout->addLayout (row2Layout);
	mainLayout->addLayout (row3Layout);
	setLayout (mainLayout);
}

void FindWindow::popup()
{
	show();
	findcombo->lineEdit()->selectAll();
	findcombo->setFocus();
}

void FindWindow::cancelPressed()
{
	hide();
}

void FindWindow::findPressed()
{
	emit (findButton(findcombo->currentText() ) );
}

void FindWindow::findTextChanged(const QString&)
{
	emit (somethingChanged() );
}

void FindWindow::clearLineEdit()
{
	findcombo->lineEdit()->clear();
}