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