Files
qt-creator/doc/examples/addressbook-sdk/part5/finddialog.cpp
Simon Hausmann eccc840cce Small cleanups
* Instantiate the FindDialog on demand only.
* When submitting a contact and there was an error, return early to
avoid adding the incomplete contact.
* In the FindDialog's findClicked slot call accept() or reject() on the
dialog, to propagate the acceptance to the caller in
AddressBook::findContact.
* Renamed FindDialog::getFindText to FindDialog::findText()

Reviewed-by: Kavindra
2009-07-21 12:05:03 +02:00

44 lines
798 B
C++

#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);
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."));
reject();
} else {
accept();
}
}
//! [findClicked]
//! [findText]
QString FindDialog::findText()
{
return m_ui->lineEdit->text();
}
//! [findText]