findwindow.cpp
author insilmaril
Tue Sep 05 10:03:29 2006 +0000 (2006-09-05)
changeset 367 b1e3a4d88f13
parent 180 60e2297bab39
child 370 97f5d07bf47d
permissions -rw-r--r--
Moved qt4-port branch to head
insilmaril@0
     1
#include <qlineedit.h>
insilmaril@364
     2
//Added by qt3to4:
insilmaril@364
     3
#include <Q3HBoxLayout>
insilmaril@364
     4
#include <Q3VBoxLayout>
insilmaril@364
     5
#include <QLabel>
insilmaril@0
     6
insilmaril@0
     7
#include "findwindow.h"
insilmaril@180
     8
#include "version.h"
insilmaril@0
     9
insilmaril@0
    10
insilmaril@167
    11
FindWindow::FindWindow(QWidget* parent, const char* name) 
insilmaril@364
    12
	: Q3GroupBox( 0, Qt::Horizontal, "Find", parent, name )
insilmaril@0
    13
insilmaril@0
    14
{
insilmaril@180
    15
	setCaption (__VYM " - " +tr("Find Text"));
insilmaril@0
    16
	//resize (180,130);
insilmaril@0
    17
	move (130,130);
insilmaril@0
    18
insilmaril@364
    19
	//FIXME not avail in QT4 setMargin( 100 );
insilmaril@0
    20
insilmaril@364
    21
    Q3VBoxLayout* box = new Q3VBoxLayout( layout() );
insilmaril@0
    22
    
insilmaril@364
    23
    Q3HBoxLayout *row1 = new Q3HBoxLayout( box );
insilmaril@0
    24
    row1->setMargin( 10 );
insilmaril@0
    25
insilmaril@0
    26
    // Create a Label
insilmaril@0
    27
    QLabel* label = new QLabel( "Text to find: ", this);
insilmaril@0
    28
    row1->addWidget( label );
insilmaril@0
    29
insilmaril@0
    30
	// Create LineEdit (here QComboBox)
insilmaril@364
    31
    Q3HBoxLayout *row2 = new Q3HBoxLayout( box );
insilmaril@0
    32
    row2->setMargin( 10 );
insilmaril@0
    33
    findcombo = new QComboBox( true, this );
insilmaril@0
    34
	findcombo->setMinimumWidth(150);
insilmaril@0
    35
    row2->addWidget( findcombo );
insilmaril@0
    36
	connect ( findcombo, SIGNAL( highlighted(int) ), 
insilmaril@0
    37
		this, SLOT( findPressed() ) );
insilmaril@0
    38
	connect ( findcombo, SIGNAL( textChanged(const QString &) ), 
insilmaril@0
    39
		this, SLOT( findTextChanged(const QString&) ) );
insilmaril@0
    40
    //findcombo->insertItem( "Normal", -1 );
insilmaril@0
    41
insilmaril@0
    42
	// Create Buttons
insilmaril@364
    43
    Q3HBoxLayout *row3 = new Q3HBoxLayout( box );
insilmaril@0
    44
    row3->setMargin( 10 );
insilmaril@0
    45
	clearbutton = new QPushButton (tr("Clear"),this);
insilmaril@0
    46
	connect ( clearbutton, SIGNAL( clicked() ), 
insilmaril@0
    47
		findcombo, SLOT( clearEdit() ) );
insilmaril@0
    48
	row3->addWidget (clearbutton);
insilmaril@0
    49
	
insilmaril@0
    50
	QSpacerItem *si1= new QSpacerItem (10,0,QSizePolicy::Minimum, QSizePolicy::Expanding );
insilmaril@0
    51
	row3->addItem(si1);
insilmaril@0
    52
	
insilmaril@0
    53
	cancelbutton = new QPushButton (tr("Cancel"),this);
insilmaril@364
    54
	cancelbutton->setAccel (Qt::Key_Escape);
insilmaril@0
    55
	connect ( cancelbutton, SIGNAL( clicked() ), 
insilmaril@0
    56
		this, SLOT( cancelPressed() ) );
insilmaril@0
    57
	row3->addWidget (cancelbutton);
insilmaril@0
    58
insilmaril@0
    59
	QSpacerItem *si2= new QSpacerItem (10,0,QSizePolicy::Fixed, QSizePolicy::Fixed);
insilmaril@0
    60
	row3->addItem(si2);
insilmaril@0
    61
	
insilmaril@0
    62
	findbutton = new QPushButton (tr("Find"),this);
insilmaril@0
    63
	findbutton->setDefault (true);
insilmaril@0
    64
	connect ( findbutton, SIGNAL( clicked() ), 
insilmaril@0
    65
		this, SLOT( findPressed() ) );
insilmaril@0
    66
	row3->add(findbutton);
insilmaril@0
    67
	
insilmaril@0
    68
	findcombo->setFocus();
insilmaril@0
    69
}
insilmaril@0
    70
insilmaril@0
    71
void FindWindow::popup()
insilmaril@0
    72
{
insilmaril@0
    73
	findcombo->lineEdit()->selectAll();
insilmaril@0
    74
	show();
insilmaril@0
    75
}
insilmaril@0
    76
insilmaril@0
    77
void FindWindow::cancelPressed()
insilmaril@0
    78
{
insilmaril@0
    79
	hide();
insilmaril@0
    80
}
insilmaril@0
    81
insilmaril@0
    82
void FindWindow::findPressed()
insilmaril@0
    83
{
insilmaril@0
    84
	emit (findButton(findcombo->currentText() ) );
insilmaril@0
    85
}
insilmaril@0
    86
insilmaril@0
    87
void FindWindow::findTextChanged(const QString&)
insilmaril@0
    88
{
insilmaril@0
    89
	emit (somethingChanged() );
insilmaril@0
    90
}