Fixed some issues
[situare] / src / ui / updatelocation / updatelocationdialog.cpp
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5       Katri Kaikkonen - katri.kaikkonen@ixonos.com
6       Henri Lampela - henri.lampela@ixonos.com
7
8    Situare is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License
10    version 2 as published by the Free Software Foundation.
11
12    Situare is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with Situare; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20    USA.
21 */
22
23 #include <QDebug>
24 #include "updatelocationdialog.h"
25
26 UpdateLocationDialog::UpdateLocationDialog(QWidget *parent)
27     : QDialog(parent)
28 {
29     setWindowTitle(tr("Update Location"));
30
31     QScrollArea *scrollArea = new QScrollArea(this);
32     QGridLayout *gridLayout = new QGridLayout(this);
33     QGroupBox *groupBox = new QGroupBox(scrollArea);
34
35     m_textEdit = new QTextEdit;
36     m_locationLabel = new QLabel;
37     m_checkBox = new QCheckBox(tr("Publish on Facebook"));
38
39     QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Vertical);
40     QPushButton *sendButton = buttonBox->addButton(QDialogButtonBox::Ok);
41     QPushButton *cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel);
42     sendButton->setText(tr("Send"));
43
44     QFormLayout *form = new QFormLayout();
45     form->addRow(new QLabel(tr("Location:")), m_locationLabel);
46     form->addRow(new QLabel(tr("Message:")), m_textEdit);
47     form->addWidget(m_checkBox);
48
49     new TextEditAutoResizer(m_textEdit);
50
51     groupBox->setLayout(form);
52     scrollArea->setWidget(groupBox);
53     scrollArea->setWidgetResizable(true);
54     gridLayout->addWidget(scrollArea, 0, 0, 2, 1);
55     gridLayout->addWidget(buttonBox, 0, 1, 1, 1);
56     setLayout(gridLayout);
57
58     connect(sendButton, SIGNAL(clicked()), this, SLOT(sendUpdate()));
59     connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
60
61     scrollArea->show();
62 }
63
64 void UpdateLocationDialog::setAddress(const QString &address)
65 {
66     qDebug() << __PRETTY_FUNCTION__;
67     m_locationLabel->setText(address);
68 }
69
70 void UpdateLocationDialog::sendUpdate()
71 {
72     qDebug() << __PRETTY_FUNCTION__;
73
74     // coordinates for this call will be get from somewhere, map etc...
75     emit statusUpdate(m_textEdit->toPlainText(), m_checkBox->isChecked());
76
77     this->close();
78 }