findwindow.cpp
author insilmaril
Thu Sep 14 11:38:17 2006 +0000 (2006-09-14)
changeset 384 73bfe41502d9
parent 370 97f5d07bf47d
child 403 7c3ee77f4449
permissions -rw-r--r--
1.8.57 - more changes in history window, Note Editor is QT4 now
     1 #include <QLineEdit>
     2 #include <QVBoxLayout>
     3 #include <QLabel>
     4 
     5 #include "findwindow.h"
     6 #include "version.h"
     7 
     8 
     9 FindWindow::FindWindow(QWidget* parent)
    10 	: QGroupBox( tr("Find"), parent )
    11 
    12 {
    13 	setWindowTitle(__VYM " - " +tr("Find Text"));
    14 
    15     QVBoxLayout* mainLayout = new QVBoxLayout;
    16     
    17     QHBoxLayout *row1Layout = new QHBoxLayout;
    18     // Create a Label
    19     QLabel* label = new QLabel;
    20     label->setText( tr("Text to find:"));
    21     row1Layout->addWidget( label );
    22 
    23 
    24 	// Create LineEdit (here QComboBox)
    25     QHBoxLayout *row2Layout = new QHBoxLayout;
    26     findcombo = new QComboBox;
    27 	findcombo->setMinimumWidth(150);
    28 	findcombo->setEditable(true);
    29 	connect ( findcombo, SIGNAL( highlighted(int) ), 
    30 		this, SLOT( findPressed() ) );
    31 	connect ( findcombo, SIGNAL( textChanged(const QString &) ), 
    32 		this, SLOT( findTextChanged(const QString&) ) );
    33 
    34 	row2Layout->addWidget(findcombo);
    35 
    36 	// Create Buttons
    37     QHBoxLayout *row3Layout = new QHBoxLayout;
    38 	clearbutton = new QPushButton;
    39 	clearbutton->setText(tr("Clear"));
    40 	connect ( clearbutton, SIGNAL( clicked() ), this, SLOT( clearLineEdit() ) );
    41 	row3Layout->addWidget (clearbutton);
    42 	
    43 	cancelbutton = new QPushButton;
    44 	cancelbutton->setText(tr("Cancel"));
    45 	cancelbutton->setShortcut (Qt::Key_Escape);
    46 	connect ( cancelbutton, SIGNAL( clicked() ), this, SLOT( cancelPressed() ) );
    47 	row3Layout->addWidget (cancelbutton);
    48 	
    49 	findbutton = new QPushButton;
    50 	findbutton->setText (tr("Find"));
    51 	findbutton->setDefault (true);
    52 	findbutton->setShortcut (Qt::Key_Return);
    53 	connect ( findbutton, SIGNAL( clicked() ), this, SLOT( findPressed() ) );
    54 
    55 	row3Layout->addStretch(2);
    56 	row3Layout->addWidget(findbutton);
    57 
    58 	mainLayout->addLayout (row1Layout);
    59 	mainLayout->addLayout (row2Layout);
    60 	mainLayout->addLayout (row3Layout);
    61 	setLayout (mainLayout);
    62 }
    63 
    64 void FindWindow::popup()
    65 {
    66 	show();
    67 	findcombo->lineEdit()->selectAll();
    68 	findcombo->setFocus();
    69 }
    70 
    71 void FindWindow::cancelPressed()
    72 {
    73 	hide();
    74 }
    75 
    76 void FindWindow::findPressed()
    77 {
    78 	emit (findButton(findcombo->currentText() ) );
    79 }
    80 
    81 void FindWindow::findTextChanged(const QString&)
    82 {
    83 	emit (somethingChanged() );
    84 }
    85 
    86 void FindWindow::clearLineEdit()
    87 {
    88 	findcombo->lineEdit()->clear();
    89 }