File: Directory.hpp

package info (click to toggle)
wsjtx 2.6.1%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 69,664 kB
  • sloc: cpp: 86,977; f90: 42,417; python: 27,241; ansic: 12,510; fortran: 2,382; makefile: 197; sh: 134
file content (60 lines) | stat: -rwxr-xr-x 1,548 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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