diff options
| author | hibby <d@vehibberd.com> | 2018-02-16 15:17:14 +0000 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2018-02-16 15:17:14 +0000 |
| commit | 37f727ac0746fd85504aa46c1f023c09b3eff33a (patch) | |
| tree | c8a7ce04545040a8f161ba279528730bd9a3e6ab /SampleDownloader/Directory.hpp | |
| parent | d63dd8d081a6fcd0715cd13f26df59fb831769d2 (diff) | |
New upstream version 1.8.0+repackupstream/1.8.0+repack
Diffstat (limited to 'SampleDownloader/Directory.hpp')
| -rw-r--r-- | SampleDownloader/Directory.hpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/SampleDownloader/Directory.hpp b/SampleDownloader/Directory.hpp new file mode 100644 index 00000000..1ffae0d8 --- /dev/null +++ b/SampleDownloader/Directory.hpp @@ -0,0 +1,60 @@ +#ifndef SAMPLE_DOWNLOADER_DIRECTORY_HPP__ +#define SAMPLE_DOWNLOADER_DIRECTORY_HPP__ + +#include <QObject> +#include <QString> +#include <QTreeWidget> +#include <QIcon> +#include <QSize> +#include <QDir> +#include <QUrl> + +#include "DirectoryDelegate.hpp" +#include "RemoteFile.hpp" + +class Configuration; +class QNetworkAccessManager; +class QTreeWidgetItem; +class QNetworkReply; +class QAuthenticator; +class QJsonArray; + +class Directory final + : public QTreeWidget + , protected RemoteFile::ListenerInterface +{ + Q_OBJECT + +public: + explicit Directory (Configuration const * configuration + , QNetworkAccessManager * network_manager + , QWidget * parent = nullptr); + + QSize sizeHint () const override {return {400, 500};} + + bool url_root (QUrl); + bool refresh (bool http_only); + void abort (); + void update (QTreeWidgetItem * item); + +protected: + void error (QString const& title, QString const& message) override; + bool redirect_request (QUrl const&) override {return true;} // allow + void download_finished (bool success) override; + +private: + Q_SLOT void authentication (QNetworkReply *, QAuthenticator *); + void parse_entries (QJsonArray const& entries, QDir const& dir, QTreeWidgetItem * parent); + + Configuration const * configuration_; + QNetworkAccessManager * network_manager_; + bool http_only_; + QDir root_dir_; + QUrl url_root_; + RemoteFile contents_; + DirectoryDelegate item_delegate_; + QIcon dir_icon_; + QIcon file_icon_; +}; + +#endif |
