Dooble
dooble_downloads.h
1 /*
2 ** Copyright (c) 2008 - present, Alexis Megas.
3 ** All rights reserved.
4 **
5 ** Redistribution and use in source and binary forms, with or without
6 ** modification, are permitted provided that the following conditions
7 ** are met:
8 ** 1. Redistributions of source code must retain the above copyright
9 ** notice, this list of conditions and the following disclaimer.
10 ** 2. Redistributions in binary form must reproduce the above copyright
11 ** notice, this list of conditions and the following disclaimer in the
12 ** documentation and/or other materials provided with the distribution.
13 ** 3. The name of the author may not be used to endorse or promote products
14 ** derived from Dooble without specific prior written permission.
15 **
16 ** DOOBLE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 ** DOOBLE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef dooble_downloads_h
29 #define dooble_downloads_h
30 
31 #include <QPointer>
32 #include <QSqlDatabase>
33 #include <QTimer>
34 
35 #include "dooble_main_window.h"
36 #include "ui_dooble_downloads.h"
37 
38 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
39 class QWebEngineDownloadItem;
40 #else
41 class QWebEngineDownloadRequest;
42 #endif
43 class QWebEngineProfile;
44 
46 {
47  Q_OBJECT
48 
49  public:
50  dooble_downloads(QWebEngineProfile *web_engine_profile, QWidget *parent);
51  QString download_path(void) const;
52 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
53  bool contains(QWebEngineDownloadItem *download) const;
54 #else
55  bool contains(QWebEngineDownloadRequest *download) const;
56 #endif
57  bool is_finished(void) const;
58  bool is_private(void) const;
59  int finished_size(void) const;
60  int size(void) const;
61  static void create_tables(QSqlDatabase &db);
62  void abort(void);
63  void clear(void);
64  void purge(void);
65 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
66  void record_download(QWebEngineDownloadItem *download);
67 #else
68  void record_download(QWebEngineDownloadRequest *download);
69 #endif
70  void show_normal(QWidget *parent);
71 
72  public slots:
73  void show(void);
74 
75  protected:
76  void closeEvent(QCloseEvent *event);
77  void keyPressEvent(QKeyEvent *event);
78  void resizeEvent(QResizeEvent *event);
79 
80  private:
81  QHash<QObject *, char> m_downloads;
82  QPointer<QWebEngineProfile> m_web_engine_profile;
83  QTimer m_download_path_inspection_timer;
84  QTimer m_search_timer;
85  Ui_dooble_downloads m_ui;
86  void delete_selected(void);
87  void remove_entry(qintptr oid);
88  void save_settings(void);
89 
90  private slots:
91  void slot_clear_finished_downloads(void);
92  void slot_copy_download_location(void);
93  void slot_delete_row(void);
94  void slot_download_destroyed(void);
95  void slot_download_finished(void);
96  void slot_download_path_inspection_timer_timeout(void);
97 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
98  void slot_download_requested(QWebEngineDownloadItem *download);
99 #else
100  void slot_download_requested(QWebEngineDownloadRequest *download);
101 #endif
102  void slot_find(void);
103  void slot_open_download_page(void);
104  void slot_populate(void);
105  void slot_reload(const QString &file_name, const QUrl &url);
106  void slot_search_timer_timeout(void);
107  void slot_select_path(void);
108  void slot_show_context_menu(const QPoint &point);
109 
110  signals:
111  void finished(void);
112  void open_link(const QUrl &url);
113  void populated(void);
114  void started(void);
115 };
116 
117 #endif
Definition: dooble_downloads.h:46
Definition: dooble_main_window.h:35