basic functionality of error handling ready
[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     qDebug() << __PRETTY_FUNCTION__;
30     setWindowTitle(tr("Update Location"));
31
32     QScrollArea *scrollArea = new QScrollArea(this);
33     QGridLayout *gridLayout = new QGridLayout(this);
34     QGroupBox *groupBox = new QGroupBox(scrollArea);
35
36     m_textEdit = new QTextEdit;
37     m_locationLabel = new QLabel;
38     m_locationLabel->setWordWrap(true);
39     m_checkBox = new QCheckBox(tr("Publish on Facebook"));
40
41     QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Vertical);
42     QPushButton *sendButton = buttonBox->addButton(QDialogButtonBox::Ok);
43     QPushButton *cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel);
44     sendButton->setText(tr("Send"));
45
46     QFormLayout *form = new QFormLayout();
47     form->addRow(new QLabel(tr("Location:")), m_locationLabel);
48     form->addRow(new QLabel(tr("Message:")), m_textEdit);
49     form->addWidget(m_checkBox);
50
51     new TextEditAutoResizer(m_textEdit);
52
53     groupBox->setLayout(form);
54     scrollArea->setWidget(groupBox);
55     scrollArea->setWidgetResizable(true);
56     gridLayout->addWidget(scrollArea, 0, 0, 2, 1);
57     gridLayout->addWidget(buttonBox, 0, 1, 1, 1);
58     setLayout(gridLayout);
59
60     connect(sendButton, SIGNAL(clicked()), this, SLOT(sendUpdate()));
61     connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
62
63     scrollArea->show();    
64 }
65
66 UpdateLocationDialog::~UpdateLocationDialog()
67 {
68     qDebug() << __PRETTY_FUNCTION__;
69
70     // emit m_textEdit sisältö userInfo luokalle talteen
71 }
72
73 void UpdateLocationDialog::setAddress(const QString &address)
74 {
75     qDebug() << __PRETTY_FUNCTION__;
76     m_locationLabel->setText(address);
77 }
78
79 void UpdateLocationDialog::sendUpdate()
80 {
81     qDebug() << __PRETTY_FUNCTION__;   
82
83     // coordinates for this call will be get from somewhere, map etc...
84     emit statusUpdate(m_textEdit->toPlainText(), m_checkBox->isChecked());
85     m_textEdit->clear();
86
87     this->hide();
88     //this->close();
89 }