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