1.1 --- a/findwindow.cpp Wed Nov 25 15:27:22 2009 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,91 +0,0 @@
1.4 -#include <QLineEdit>
1.5 -#include <QVBoxLayout>
1.6 -#include <QLabel>
1.7 -
1.8 -#include "findwindow.h"
1.9 -
1.10 -
1.11 -extern QString vymName;
1.12 -
1.13 -FindWindow::FindWindow(QWidget* parent)
1.14 - //: QGroupBox( tr("Find"), parent )
1.15 -
1.16 -{
1.17 - //setWindowTitle(vymName + " - " +tr("Find Text"));
1.18 -
1.19 - QVBoxLayout* mainLayout = new QVBoxLayout;
1.20 -
1.21 - QHBoxLayout *row1Layout = new QHBoxLayout;
1.22 - /*
1.23 - // Create a Label
1.24 - QLabel* label = new QLabel;
1.25 - label->setText( tr("Text to find:"));
1.26 - row1Layout->addWidget( label );
1.27 - */
1.28 -
1.29 - // Create LineEdit (here QComboBox)
1.30 - QHBoxLayout *row2Layout = new QHBoxLayout;
1.31 - findcombo = new QComboBox;
1.32 - findcombo->setMinimumWidth(250);
1.33 - findcombo->setEditable(true);
1.34 - connect ( findcombo, SIGNAL( highlighted(int) ),
1.35 - this, SLOT( findPressed() ) );
1.36 - connect ( findcombo, SIGNAL( textChanged(const QString &) ),
1.37 - this, SLOT( findTextChanged(const QString&) ) );
1.38 -
1.39 - row2Layout->addWidget(findcombo);
1.40 -
1.41 - // Create Buttons
1.42 - //QHBoxLayout *row3Layout = new QHBoxLayout;
1.43 - clearbutton = new QPushButton;
1.44 - clearbutton->setText(tr("Clear"));
1.45 - connect ( clearbutton, SIGNAL( clicked() ), this, SLOT( clearLineEdit() ) );
1.46 - row2Layout->addWidget (clearbutton);
1.47 -
1.48 - cancelbutton = new QPushButton;
1.49 - cancelbutton->setText(tr("Cancel"));
1.50 - cancelbutton->setShortcut (Qt::Key_Escape);
1.51 - connect ( cancelbutton, SIGNAL( clicked() ), this, SLOT( cancelPressed() ) );
1.52 - row2Layout->addWidget (cancelbutton);
1.53 -
1.54 - findbutton = new QPushButton;
1.55 - findbutton->setText (tr("Find"));
1.56 - findbutton->setDefault (true);
1.57 - findbutton->setShortcut (Qt::Key_Return);
1.58 - connect ( findbutton, SIGNAL( clicked() ), this, SLOT( findPressed() ) );
1.59 -
1.60 - //row2Layout->addStretch(2);
1.61 - row2Layout->addWidget(findbutton);
1.62 -
1.63 - mainLayout->addLayout (row1Layout);
1.64 - mainLayout->addLayout (row2Layout);
1.65 - //mainLayout->addLayout (row3Layout);
1.66 - setLayout (mainLayout);
1.67 -}
1.68 -
1.69 -void FindWindow::popup()
1.70 -{
1.71 - show();
1.72 - findcombo->lineEdit()->selectAll();
1.73 - findcombo->setFocus();
1.74 -}
1.75 -
1.76 -void FindWindow::cancelPressed()
1.77 -{
1.78 - hide();
1.79 -}
1.80 -
1.81 -void FindWindow::findPressed()
1.82 -{
1.83 - emit (findButton(findcombo->currentText() ) );
1.84 -}
1.85 -
1.86 -void FindWindow::findTextChanged(const QString&)
1.87 -{
1.88 - emit (somethingChanged() );
1.89 -}
1.90 -
1.91 -void FindWindow::clearLineEdit()
1.92 -{
1.93 - findcombo->lineEdit()->clear();
1.94 -}
2.1 --- a/findwindow.h Wed Nov 25 15:27:22 2009 +0000
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,39 +0,0 @@
2.4 -#ifndef FINDWINDOW_H
2.5 -#define FINDWINDOW_H
2.6 -
2.7 -#include <QMainWindow>
2.8 -#include <QComboBox>
2.9 -#include <QPushButton>
2.10 -#include <QGroupBox>
2.11 -#include <QLayout>
2.12 -#include <QLabel>
2.13 -
2.14 -
2.15 -class FindWindow : public QWidget
2.16 -{
2.17 - Q_OBJECT
2.18 -
2.19 -public:
2.20 - FindWindow (QWidget* parent=0);
2.21 -
2.22 -public slots:
2.23 - void popup();
2.24 - void cancelPressed();
2.25 - void findPressed();
2.26 - void findTextChanged(const QString&);
2.27 - void clearLineEdit();
2.28 -
2.29 -signals:
2.30 - void findButton(QString); // emit to mainwindow
2.31 - void somethingChanged(); // emit to mainwindow
2.32 -
2.33 -private:
2.34 - QGroupBox *findbox;
2.35 - QComboBox *findcombo;
2.36 - QPushButton *clearbutton;
2.37 - QPushButton *findbutton;
2.38 - QPushButton *cancelbutton;
2.39 -};
2.40 -
2.41 -
2.42 -#endif