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