SearchDialog::SearchDialog(QWidget* parent): QDialog(parent),
numberInput_(0), locationInput_(0), selector_(0)
{
- setWindowTitle(tr("Search"));
+ setWindowTitle(tr("Search"));
- QHBoxLayout* numberLayout = new QHBoxLayout;
- QLabel* numberLabel = new QLabel(tr("Name/number"));
- numberInput_ = new QLineEdit;
- numberLayout->addWidget(numberLabel);
- numberLayout->addWidget(numberInput_);
+ QHBoxLayout* numberLayout = new QHBoxLayout;
+ QLabel* numberLabel = new QLabel(tr("Name/number"));
+ numberInput_ = new QLineEdit;
+ numberLayout->addWidget(numberLabel);
+ numberLayout->addWidget(numberInput_);
- QHBoxLayout* locationLayout = new QHBoxLayout;
- QLabel* locationLabel = new QLabel(tr("Location"));
- locationInput_ = new QLineEdit;
- locationLayout->addWidget(locationLabel);
- locationLayout->addWidget(locationInput_);
+ QHBoxLayout* locationLayout = new QHBoxLayout;
+ QLabel* locationLabel = new QLabel(tr("Location"));
+ locationInput_ = new QLineEdit;
+ locationLayout->addWidget(locationLabel);
+ locationLayout->addWidget(locationInput_);
- selector_ = new ButtonSelector(tr("Type"), this);
- selector_->addItem(tr("Persons"));
- selector_->addItem(tr("Yellow pages"));
+ selector_ = new ButtonSelector(tr("Type"), this);
+ selector_->addItem(tr("Persons"));
+ selector_->addItem(tr("Yellow pages"));
- QVBoxLayout* leftLayout = new QVBoxLayout;
- leftLayout->addLayout(numberLayout);
- leftLayout->addLayout(locationLayout);
- leftLayout->addWidget(selector_);
+ QVBoxLayout* leftLayout = new QVBoxLayout;
+ leftLayout->addLayout(numberLayout);
+ leftLayout->addLayout(locationLayout);
+ leftLayout->addWidget(selector_);
- QDialogButtonBox* buttons = new QDialogButtonBox;
- QPushButton* submitButton = new QPushButton(tr("Search"));
- buttons->addButton(submitButton, QDialogButtonBox::AcceptRole);
- connect(submitButton, SIGNAL(pressed()), this, SLOT(searchPressed()));
+ QDialogButtonBox* buttons = new QDialogButtonBox;
+ QPushButton* submitButton = new QPushButton(tr("Search"));
+ buttons->addButton(submitButton, QDialogButtonBox::AcceptRole);
+ connect(submitButton, SIGNAL(pressed()), this, SLOT(searchPressed()));
- QHBoxLayout* mainLayout = new QHBoxLayout;
- mainLayout->addLayout(leftLayout, Qt::AlignLeft);
- mainLayout->addWidget(buttons);
+ QHBoxLayout* mainLayout = new QHBoxLayout;
+ mainLayout->addLayout(leftLayout, Qt::AlignLeft);
+ mainLayout->addWidget(buttons);
- setLayout(mainLayout);
+ setLayout(mainLayout);
}
void SearchDialog::searchPressed()
{
- SearchDetails details;
- details.name = numberInput_->text();
+ SearchDetails details;
+ details.name = numberInput_->text();
- if(details.name.isEmpty())
- {
- numberInput_->setFocus();
- return;
- }
+ if(details.name.isEmpty())
+ {
+ numberInput_->setFocus();
+ return;
+ }
- details.location = locationInput_->text();
- details.type = selector_->currentIndex();
- emit search(details);
- hide();
+ details.location = locationInput_->text();
+ details.type = selector_->currentIndex();
+ emit search(details);
+ hide();
}