2 * This file is part of Jenirok.
4 * Jenirok is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Jenirok is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Jenirok. If not, see <http://www.gnu.org/licenses/>.
19 #include <QtCore/QDebug>
20 #include <QtGui/QHBoxLayout>
21 #include <QtGui/QVBoxLayout>
22 #include <QtGui/QLabel>
23 #include <QtGui/QDialogButtonBox>
24 #include <QMaemo5ValueButton>
25 #include "searchdialog.h"
27 SearchDialog::SearchDialog(QWidget* parent): QDialog(parent),
28 numberInput_(0), locationInput_(0), selector_(0)
30 setWindowTitle(tr("Search"));
32 QHBoxLayout* numberLayout = new QHBoxLayout;
33 QLabel* numberLabel = new QLabel(tr("Name/number"));
34 numberInput_ = new QLineEdit;
35 numberLayout->addWidget(numberLabel);
36 numberLayout->addWidget(numberInput_);
38 QHBoxLayout* locationLayout = new QHBoxLayout;
39 QLabel* locationLabel = new QLabel(tr("Location"));
40 locationInput_ = new QLineEdit;
41 locationLayout->addWidget(locationLabel);
42 locationLayout->addWidget(locationInput_);
44 selector_ = new ButtonSelector(tr("Type"), this);
45 selector_->addItem(tr("Persons"));
46 selector_->addItem(tr("Companies"));
48 QVBoxLayout* leftLayout = new QVBoxLayout;
49 leftLayout->addLayout(numberLayout);
50 leftLayout->addLayout(locationLayout);
51 leftLayout->addWidget(selector_);
53 QDialogButtonBox* buttons = new QDialogButtonBox;
54 buttons->setCenterButtons(false);
55 QPushButton* submitButton = new QPushButton(tr("Search"));
56 buttons->addButton(submitButton, QDialogButtonBox::AcceptRole);
57 connect(submitButton, SIGNAL(pressed()), this, SLOT(searchPressed()));
59 QHBoxLayout* mainLayout = new QHBoxLayout;
60 mainLayout->addLayout(leftLayout, Qt::AlignLeft);
61 mainLayout->addWidget(buttons);
63 setLayout(mainLayout);
66 void SearchDialog::searchPressed()
68 SearchDetails details;
69 details.name = numberInput_->text();
71 if(details.name.isEmpty())
73 numberInput_->setFocus();
77 details.location = locationInput_->text();
78 details.type = selector_->currentIndex();
83 void SearchDialog::setVisible(bool visible)
85 QDialog::setVisible(visible);
89 numberInput_->setFocus();