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