#include <QtGui/QApplication>
#include "ui/mainwindow.h"
+#include "mapfetcherqueue.h"
int main(int argc, char *argv[])
{
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()
#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