summaryrefslogtreecommitdiff
path: root/doc/examples/addressbook-sdk/part5/finddialog.cpp
blob: 99ba98160215bec2a456472be5b1b6556fd2d658 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "finddialog.h"
#include "ui_finddialog.h"
#include <QMessageBox>

//! [constructor]
FindDialog::FindDialog(QWidget *parent) :
    QDialog(parent),
    m_ui(new Ui::FindDialog)
{
    m_ui->setupUi(this);
    findText = "";

    connect(m_ui->findButton, SIGNAL(clicked()), this, SLOT(findClicked()));

    setWindowTitle(tr("Find a Contact"));
}
//! [constructor]

FindDialog::~FindDialog()
{
    delete m_ui;
}

//! [findClicked]
void FindDialog::findClicked()
{
    QString text = m_ui->lineEdit->text();

    if (text.isEmpty()) {
        QMessageBox::information(this, tr("Empty Field"),
            tr("Please enter a name."));
        return;
    } else {
        findText = text;
        m_ui->lineEdit->clear();
        hide();
    }
}
//! [findClicked]

//! [getFindText]
QString FindDialog::getFindText()
{
    return findText;
}
//! [getFindText]