patchdownloader.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef PATCHDOWNLOADER_H
  2. #define PATCHDOWNLOADER_H
  3. #include <QObject>
  4. #include <QList>
  5. #include <QString>
  6. #include <QMap>
  7. #include "models/downloader.h"
  8. class PatchDownloader : public QObject
  9. {
  10. Q_OBJECT
  11. public:
  12. static PatchDownloader& instance() {
  13. static PatchDownloader instance_;
  14. return instance_;
  15. }
  16. ~PatchDownloader();
  17. private:
  18. Q_DISABLE_COPY(PatchDownloader)
  19. PatchDownloader();
  20. void downloadDatabases(); // Starts downloading all necessary patches.
  21. static bool needDownloadDatabase(QString db_name); // Checks if database needs to be downloaded (by checksum comparing)
  22. public slots:
  23. void init();
  24. void checkForUpdates(); // Checks for updates
  25. void startPatchDownloaderChain();
  26. signals:
  27. void started();
  28. void progressChanged(Downloader::Status status);
  29. void finished();
  30. private slots:
  31. void onDownloaderProgressChanged(Downloader* context, Downloader::Status progress);
  32. void onDownloaderFinished(Downloader* context);
  33. private:
  34. bool started_ = false;
  35. const QList<QString> patches_ = {"text", "font", "image", "texture", "loadscreen", "sound", "video"};
  36. QMap<QString, Downloader*> patch_downloaders_;
  37. QMap<Downloader*, Downloader::Status> patch_downloaders_status_;
  38. };
  39. #endif // PATCHDOWNLOADER_H