1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/findwidget.cpp Wed Nov 25 15:27:22 2009 +0000
1.3 @@ -0,0 +1,66 @@
1.4 +#include <QLineEdit>
1.5 +#include <QVBoxLayout>
1.6 +#include <QLabel>
1.7 +
1.8 +#include "findwidget.h"
1.9 +
1.10 +
1.11 +extern QString vymName;
1.12 +
1.13 +FindWidget::FindWidget(QWidget* parent)
1.14 +{
1.15 + QVBoxLayout* mainLayout = new QVBoxLayout;
1.16 + QHBoxLayout *row2Layout = new QHBoxLayout;
1.17 +
1.18 + // Create Buttons
1.19 + cancelbutton = new QPushButton;
1.20 + cancelbutton->setText(tr("Cancel"));
1.21 + cancelbutton->setShortcut (Qt::Key_Escape);
1.22 + connect ( cancelbutton, SIGNAL( clicked() ), this, SLOT( cancelPressed() ) );
1.23 +
1.24 + // Create LineEdit (here QComboBox)
1.25 + findcombo = new QComboBox;
1.26 + findcombo->setMinimumWidth(250);
1.27 + findcombo->setEditable(true);
1.28 + connect ( findcombo, SIGNAL( highlighted(int) ),
1.29 + this, SLOT( nextPressed() ) );
1.30 + connect ( findcombo, SIGNAL( textChanged(const QString &) ),
1.31 + this, SLOT( findTextChanged(const QString&) ) );
1.32 +
1.33 + nextbutton = new QPushButton;
1.34 + nextbutton->setText (tr("Next","Find widget"));
1.35 + //nextbutton->setDefault (true);
1.36 + //nextbutton->setShortcut (Qt::Key_Return);
1.37 + connect ( nextbutton, SIGNAL( clicked() ), this, SLOT( nextPressed() ) );
1.38 +
1.39 + row2Layout->addWidget (cancelbutton);
1.40 + row2Layout->addWidget(findcombo);
1.41 + row2Layout->addWidget(nextbutton);
1.42 +
1.43 + mainLayout->addLayout (row2Layout);
1.44 +
1.45 + setLayout (mainLayout);
1.46 +}
1.47 +
1.48 +void FindWidget::popup()
1.49 +{
1.50 + show();
1.51 + findcombo->lineEdit()->selectAll();
1.52 + findcombo->setFocus();
1.53 +}
1.54 +
1.55 +void FindWidget::cancelPressed()
1.56 +{
1.57 + hide();
1.58 +}
1.59 +
1.60 +void FindWidget::nextPressed()
1.61 +{
1.62 + emit (nextButton(findcombo->currentText() ) );
1.63 +}
1.64 +
1.65 +void FindWidget::findTextChanged(const QString&)
1.66 +{
1.67 + emit (somethingChanged() );
1.68 +}
1.69 +