1 #include "LoadImageFromUrl.h"
3 #include "MainWindow.h"
6 #include <QtNetwork/QNetworkReply>
11 m_mainWindow (mainWindow),
16 connect (
this, SIGNAL (
signalImportImage (QString, QImage)), &m_mainWindow, SLOT (slotFileImportImage (QString, QImage)));
19 LoadImageFromUrl::~LoadImageFromUrl ()
24 void LoadImageFromUrl::deallocate ()
37 void LoadImageFromUrl::slotFinished ()
41 QString urlWithoutScheme = m_url.toString (QUrl::RemoveScheme);
45 if (image.loadFromData (*m_buffer)) {
55 QTextStream str (&message);
57 str <<
"Unable to download image from " << urlWithoutScheme;
59 QMessageBox::critical (&m_mainWindow,
68 LOG4CPP_INFO_S ((*mainCat)) <<
"LoadImageFromUrl::startLoadImage url=" << url.toString ().toLatin1 ().data ();
71 if (url.isLocalFile ()) {
73 QFileInfo fileInfo (url.toLocalFile ());
77 if (image.load (url.toLocalFile ())) {
87 QTextStream str (&message);
89 str <<
"Unable to load image from " << url.toLocalFile ();
91 QMessageBox::critical (&m_mainWindow,
101 m_buffer =
new QByteArray;
102 QNetworkRequest request (url);
103 m_reply = m_http.get (request);
105 connect (m_reply, SIGNAL (readyRead()),
this, SLOT (slotReadData()));
106 connect (m_reply, SIGNAL (finished ()),
this, SLOT (slotFinished ()));
110 void LoadImageFromUrl::slotReadData ()
112 *m_buffer += m_reply->readAll ();
LoadImageFromUrl(MainWindow &mainWindow)
Single constructor.
void signalImportImage(QString, QImage)
Send the imported image to MainWindow. This completes the asynchronous loading of the image...
void startLoadImage(const QUrl &url)
Start the asynchronous loading of an image from the specified url.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...