multipageloader.hh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright 2010 wkhtmltopdf authors
  2. //
  3. // This file is part of wkhtmltopdf.
  4. //
  5. // wkhtmltopdf is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU Lesser General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // wkhtmltopdf is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Lesser General Public License
  16. // along with wkhtmltopdf. If not, see <http://www.gnu.org/licenses/>.
  17. #ifndef __MULTIPAGELOADER_HH__
  18. #define __MULTIPAGELOADER_HH__
  19. #include <QFile>
  20. #include <QObject>
  21. #include <QUrl>
  22. #if QT_VERSION >= 0x050000
  23. #include <QtWebKitWidgets>
  24. #else
  25. #include <QWebPage>
  26. #endif
  27. #include <wkhtmltox/loadsettings.hh>
  28. #include <wkhtmltox/dllbegin.inc>
  29. namespace wkhtmltopdf {
  30. class DLL_LOCAL MyQWebPage;
  31. class DLL_LOCAL LoaderObject {
  32. public:
  33. QWebPage & page;
  34. bool skip;
  35. LoaderObject(QWebPage & page);
  36. };
  37. class DLL_LOCAL MultiPageLoaderPrivate;
  38. class DLL_LOCAL MultiPageLoader: public QObject {
  39. Q_OBJECT
  40. public:
  41. MultiPageLoader(settings::LoadGlobal & s, bool mainLoader = false);
  42. ~MultiPageLoader();
  43. LoaderObject * addResource(const QString & url, const settings::LoadPage & settings, const QString * data=NULL);
  44. LoaderObject * addResource(const QUrl & url, const settings::LoadPage & settings);
  45. static QUrl guessUrlFromString(const QString &string);
  46. int httpErrorCode();
  47. static bool copyFile(QFile & src, QFile & dst);
  48. public slots:
  49. void load();
  50. void clearResources();
  51. void cancel();
  52. signals:
  53. void loadFinished(bool ok);
  54. void loadProgress(int progress);
  55. void loadStarted();
  56. void warning(QString text);
  57. void error(QString text);
  58. private:
  59. MultiPageLoaderPrivate * d;
  60. friend class MultiPageLoaderPrivate;
  61. friend class MyQWebPage;
  62. friend class ResourceObject;
  63. };
  64. }
  65. #include <wkhtmltox/dllend.inc>
  66. #endif //__MULTIPAGELOADER_HH__