11 #include <QMessageBox>
12 #include <QTextStream>
14 #include <QtNetwork/QNetworkReply>
20 m_mainWindow (mainWindow),
27 connect (
this, SIGNAL (
signalImportImage (QString, QImage)), &m_mainWindow, SLOT (slotFileImportImage (QString, QImage)));
35 void LoadImageFromUrl::deallocate ()
46 void LoadImageFromUrl::slotFinished ()
50 QString urlWithoutScheme = m_url.toString (QUrl::RemoveScheme);
54 if (image.loadFromData (*m_buffer)) {
64 QTextStream str (&message);
66 str << tr (
"Unable to download image from") <<
" " << urlWithoutScheme;
68 QMessageBox::critical (&m_mainWindow,
77 LOG4CPP_INFO_S ((*
mainCat)) <<
"LoadImageFromUrl::startLoadImage url=" << url.toString ().toLatin1 ().data ();
80 if (url.isLocalFile ()) {
82 QFileInfo fileInfo (url.toLocalFile ());
86 if (image.load (url.toLocalFile ())) {
96 QTextStream str (&message);
98 str << tr (
"Unable to load image from") <<
" " << url.toLocalFile ();
100 QMessageBox::critical (&m_mainWindow,
112 m_buffer =
new QByteArray;
113 QNetworkRequest request (url);
114 m_reply = m_http.get (request);
116 connect (m_reply, SIGNAL (readyRead()),
this, SLOT (slotReadData()));
117 connect (m_reply, SIGNAL (finished ()),
this, SLOT (slotFinished ()));
122 void LoadImageFromUrl::slotReadData ()
125 *m_buffer += m_reply->readAll ();
QString engaugeWindowTitle()
Text for title bars of dialogs.
LoadImageFromUrl(MainWindow &mainWindow)
Single constructor.
#define LOG4CPP_INFO_S(logger)
void signalImportImage(QString, QImage)
Send the imported image to MainWindow. This completes the asynchronous loading of the image...
log4cpp::Category * mainCat
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...