7 #include "LoadImageFromUrl.h" 9 #include "MainWindow.h" 11 #include <QMessageBox> 12 #include <QTextStream> 13 #include <QtNetwork/QNetworkReply> 18 m_mainWindow (mainWindow),
23 connect (
this, SIGNAL (
signalImportImage (QString, QImage)), &m_mainWindow, SLOT (slotFileImportImage (QString, QImage)));
26 LoadImageFromUrl::~LoadImageFromUrl ()
31 void LoadImageFromUrl::deallocate ()
40 void LoadImageFromUrl::slotFinished ()
44 QString urlWithoutScheme = m_url.toString (QUrl::RemoveScheme);
48 if (image.loadFromData (*m_buffer)) {
58 QTextStream str (&message);
60 str << tr (
"Unable to download image from") <<
" " << urlWithoutScheme;
62 QMessageBox::critical (&m_mainWindow,
71 LOG4CPP_INFO_S ((*mainCat)) <<
"LoadImageFromUrl::startLoadImage url=" << url.toString ().toLatin1 ().data ();
74 if (url.isLocalFile ()) {
76 QFileInfo fileInfo (url.toLocalFile ());
80 if (image.load (url.toLocalFile ())) {
90 QTextStream str (&message);
92 str << tr (
"Unable to load image from") <<
" " << url.toLocalFile ();
94 QMessageBox::critical (&m_mainWindow,
104 m_buffer =
new QByteArray;
105 QNetworkRequest request (url);
106 m_reply = m_http.get (request);
108 connect (m_reply, SIGNAL (readyRead()),
this, SLOT (slotReadData()));
109 connect (m_reply, SIGNAL (finished ()),
this, SLOT (slotFinished ()));
113 void LoadImageFromUrl::slotReadData ()
115 *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...