7 #include "LoadImageFromUrl.h" 9 #include "MainWindow.h" 11 #include <QMessageBox> 12 #include <QtNetwork/QNetworkReply> 17 m_mainWindow (mainWindow),
22 connect (
this, SIGNAL (
signalImportImage (QString, QImage)), &m_mainWindow, SLOT (slotFileImportImage (QString, QImage)));
25 LoadImageFromUrl::~LoadImageFromUrl ()
30 void LoadImageFromUrl::deallocate ()
43 void LoadImageFromUrl::slotFinished ()
47 QString urlWithoutScheme = m_url.toString (QUrl::RemoveScheme);
51 if (image.loadFromData (*m_buffer)) {
61 QTextStream str (&message);
63 str << tr (
"Unable to download image from") <<
" " << urlWithoutScheme;
65 QMessageBox::critical (&m_mainWindow,
74 LOG4CPP_INFO_S ((*mainCat)) <<
"LoadImageFromUrl::startLoadImage url=" << url.toString ().toLatin1 ().data ();
77 if (url.isLocalFile ()) {
79 QFileInfo fileInfo (url.toLocalFile ());
83 if (image.load (url.toLocalFile ())) {
93 QTextStream str (&message);
95 str << tr (
"Unable to load image from") <<
" " << url.toLocalFile ();
97 QMessageBox::critical (&m_mainWindow,
107 m_buffer =
new QByteArray;
108 QNetworkRequest request (url);
109 m_reply = m_http.get (request);
111 connect (m_reply, SIGNAL (readyRead()),
this, SLOT (slotReadData()));
112 connect (m_reply, SIGNAL (finished ()),
this, SLOT (slotFinished ()));
116 void LoadImageFromUrl::slotReadData ()
118 *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...