findwidget.cpp
author insilmaril
Wed, 25 Nov 2009 15:27:22 +0000
changeset 808 b163492fda17
child 810 a9295db4dcbf
permissions -rw-r--r--
First version of new FindWidget instead of extra floating dialog
     1 #include <QLineEdit>
     2 #include <QVBoxLayout>
     3 #include <QLabel>
     4 
     5 #include "findwidget.h"
     6 
     7 
     8 extern QString vymName;
     9 
    10 FindWidget::FindWidget(QWidget* parent)
    11 {
    12     QVBoxLayout* mainLayout = new QVBoxLayout;
    13     QHBoxLayout *row2Layout = new QHBoxLayout;
    14     
    15 	// Create Buttons
    16 	cancelbutton = new QPushButton;
    17 	cancelbutton->setText(tr("Cancel"));
    18 	cancelbutton->setShortcut (Qt::Key_Escape);
    19 	connect ( cancelbutton, SIGNAL( clicked() ), this, SLOT( cancelPressed() ) );
    20 	
    21 	// Create LineEdit (here QComboBox)
    22     findcombo = new QComboBox;
    23 	findcombo->setMinimumWidth(250);
    24 	findcombo->setEditable(true);
    25 	connect ( findcombo, SIGNAL( highlighted(int) ), 
    26 		this, SLOT( nextPressed() ) );
    27 	connect ( findcombo, SIGNAL( textChanged(const QString &) ), 
    28 		this, SLOT( findTextChanged(const QString&) ) );
    29 
    30 	nextbutton = new QPushButton;
    31 	nextbutton->setText (tr("Next","Find widget"));
    32 	//nextbutton->setDefault (true);
    33 	//nextbutton->setShortcut (Qt::Key_Return);
    34 	connect ( nextbutton, SIGNAL( clicked() ), this, SLOT( nextPressed() ) );
    35 
    36 	row2Layout->addWidget (cancelbutton);
    37 	row2Layout->addWidget(findcombo);
    38 	row2Layout->addWidget(nextbutton);
    39 
    40 	mainLayout->addLayout (row2Layout);
    41 
    42 	setLayout (mainLayout);
    43 }
    44 
    45 void FindWidget::popup()
    46 {
    47 	show();
    48 	findcombo->lineEdit()->selectAll();
    49 	findcombo->setFocus();
    50 }
    51 
    52 void FindWidget::cancelPressed()
    53 {
    54 	hide();
    55 }
    56 
    57 void FindWidget::nextPressed()
    58 {
    59 	emit (nextButton(findcombo->currentText() ) );
    60 }
    61 
    62 void FindWidget::findTextChanged(const QString&)
    63 {
    64 	emit (somethingChanged() );
    65 }
    66