Modified mainwindow.cpp and mainwindow.h.
[situare] / src / ui / mainwindow.cpp
1 /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Henri Lampela - henri.lampela@ixonos.com
6
7     Situare is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     version 2 as published by the Free Software Foundation.
10
11     Situare is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with Situare; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19     USA.
20  */
21
22 #include <QPushButton>
23 #include <QVBoxLayout>
24
25 #include "mainwindow.h"
26 #include "mapfetcher.h"
27
28 MainWindow::MainWindow(QWidget *parent)
29     : QWidget(parent)
30 {
31     this->setWindowTitle(tr("Situare"));
32
33     connect(&mapFetcher, SIGNAL(mapImageReceived(QUrl,QPixmap)), this, SLOT(imageReceived(QUrl,QPixmap)));
34
35     QPushButton *button = new QPushButton("Fetch");
36     QLabel *label = new QLabel(this);
37     connect(button, SIGNAL(clicked()), this, SLOT(debug()));
38
39     QWidget *widget = new QWidget(this);
40     QVBoxLayout *vbox = new QVBoxLayout;
41     vbox->addWidget(button);
42     vbox->addWidget(label);
43     widget->setLayout(vbox);
44     this->setLayout(vbox);
45 }
46
47 void MainWindow::imageReceived(const QUrl &url, const QPixmap &image)
48 {
49     qDebug() << url.path();
50     QLabel *label = new QLabel();
51     label->setPixmap(image);
52     label->show();
53 }
54
55 void MainWindow::debug()
56 {
57     qDebug() << "debug()";
58     for (int j = 0; j < 10; ++j) {
59         mapFetcher.fetchMapImage(QUrl(QString("http://tile.openstreetmap.org/mapnik/13/4675/213%1.png").arg(j)));
60     }
61 }
62
63 MainWindow::~MainWindow()
64 {
65
66 }