findwindow.cpp
author insilmaril
Wed, 02 May 2007 15:31:17 +0000
changeset 480 4e2c9394c7da
parent 403 7c3ee77f4449
child 807 f9f7922989d8
permissions -rw-r--r--
Mainly documentation fixes
     1 #include <QLineEdit>
     2 #include <QVBoxLayout>
     3 #include <QLabel>
     4 
     5 #include "findwindow.h"
     6 
     7 
     8 extern QString vymName;
     9 
    10 FindWindow::FindWindow(QWidget* parent)
    11 	: QGroupBox( tr("Find"), parent )
    12 
    13 {
    14 	setWindowTitle(vymName + " - " +tr("Find Text"));
    15 
    16     QVBoxLayout* mainLayout = new QVBoxLayout;
    17     
    18     QHBoxLayout *row1Layout = new QHBoxLayout;
    19     // Create a Label
    20     QLabel* label = new QLabel;
    21     label->setText( tr("Text to find:"));
    22     row1Layout->addWidget( label );
    23 
    24 
    25 	// Create LineEdit (here QComboBox)
    26     QHBoxLayout *row2Layout = new QHBoxLayout;
    27     findcombo = new QComboBox;
    28 	findcombo->setMinimumWidth(150);
    29 	findcombo->setEditable(true);
    30 	connect ( findcombo, SIGNAL( highlighted(int) ), 
    31 		this, SLOT( findPressed() ) );
    32 	connect ( findcombo, SIGNAL( textChanged(const QString &) ), 
    33 		this, SLOT( findTextChanged(const QString&) ) );
    34 
    35 	row2Layout->addWidget(findcombo);
    36 
    37 	// Create Buttons
    38     QHBoxLayout *row3Layout = new QHBoxLayout;
    39 	clearbutton = new QPushButton;
    40 	clearbutton->setText(tr("Clear"));
    41 	connect ( clearbutton, SIGNAL( clicked() ), this, SLOT( clearLineEdit() ) );
    42 	row3Layout->addWidget (clearbutton);
    43 	
    44 	cancelbutton = new QPushButton;
    45 	cancelbutton->setText(tr("Cancel"));
    46 	cancelbutton->setShortcut (Qt::Key_Escape);
    47 	connect ( cancelbutton, SIGNAL( clicked() ), this, SLOT( cancelPressed() ) );
    48 	row3Layout->addWidget (cancelbutton);
    49 	
    50 	findbutton = new QPushButton;
    51 	findbutton->setText (tr("Find"));
    52 	findbutton->setDefault (true);
    53 	findbutton->setShortcut (Qt::Key_Return);
    54 	connect ( findbutton, SIGNAL( clicked() ), this, SLOT( findPressed() ) );
    55 
    56 	row3Layout->addStretch(2);
    57 	row3Layout->addWidget(findbutton);
    58 
    59 	mainLayout->addLayout (row1Layout);
    60 	mainLayout->addLayout (row2Layout);
    61 	mainLayout->addLayout (row3Layout);
    62 	setLayout (mainLayout);
    63 }
    64 
    65 void FindWindow::popup()
    66 {
    67 	show();
    68 	findcombo->lineEdit()->selectAll();
    69 	findcombo->setFocus();
    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 }
    86 
    87 void FindWindow::clearLineEdit()
    88 {
    89 	findcombo->lineEdit()->clear();
    90 }