Modified mainwindow.cpp and mainwindow.h.
authorJussi Laitinen <jussi.laitinen@ixonos.com>
Tue, 30 Mar 2010 10:27:54 +0000 (13:27 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 30 Mar 2010 10:27:54 +0000 (13:27 +0300)
src/main.cpp
src/ui/mainwindow.cpp
src/ui/mainwindow.h

index b5978ac..bc2ecd5 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <QtGui/QApplication>
 #include "ui/mainwindow.h"
+#include "mapfetcherqueue.h"
 
 int main(int argc, char *argv[])
 {
index bf1473b..6dc4c50 100644 (file)
     USA.
  */
 
+#include <QPushButton>
+#include <QVBoxLayout>
 
 #include "mainwindow.h"
+#include "mapfetcher.h"
 
 MainWindow::MainWindow(QWidget *parent)
-    : QMainWindow(parent)
+    : QWidget(parent)
 {
     this->setWindowTitle(tr("Situare"));
+
+    connect(&mapFetcher, SIGNAL(mapImageReceived(QUrl,QPixmap)), this, SLOT(imageReceived(QUrl,QPixmap)));
+
+    QPushButton *button = new QPushButton("Fetch");
+    QLabel *label = new QLabel(this);
+    connect(button, SIGNAL(clicked()), this, SLOT(debug()));
+
+    QWidget *widget = new QWidget(this);
+    QVBoxLayout *vbox = new QVBoxLayout;
+    vbox->addWidget(button);
+    vbox->addWidget(label);
+    widget->setLayout(vbox);
+    this->setLayout(vbox);
+}
+
+void MainWindow::imageReceived(const QUrl &url, const QPixmap &image)
+{
+    qDebug() << url.path();
+    QLabel *label = new QLabel();
+    label->setPixmap(image);
+    label->show();
+}
+
+void MainWindow::debug()
+{
+    qDebug() << "debug()";
+    for (int j = 0; j < 10; ++j) {
+        mapFetcher.fetchMapImage(QUrl(QString("http://tile.openstreetmap.org/mapnik/13/4675/213%1.png").arg(j)));
+    }
 }
 
 MainWindow::~MainWindow()
index 78c5ceb..a9eb362 100644 (file)
 #define MAINWINDOW_H
 
 #include <QtGui/QMainWindow>
+#include <QLabel>
+#include <QUrl>
+#include <QPixmap>
+#include <QWidget>
+#include "mapfetcher.h"
 
-class MainWindow : public QMainWindow
+class MainWindow : public QWidget
 {
     Q_OBJECT
 
 public:
     MainWindow(QWidget *parent = 0);
     ~MainWindow();
+
+signals:
+    void fetchImage(const QUrl &url);
+
+public slots:
+    void debug();
+    void imageReceived(const QUrl &url, const QPixmap &image);
+
+private:
+    MapFetcher mapFetcher;
 };
 
 #endif // MAINWINDOW_H