wadseekersitestable.h
1 //------------------------------------------------------------------------------
2 // wadseekersitestable.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library 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 GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2011 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef __WADSEEKERSITESTABLE_H__
24 #define __WADSEEKERSITESTABLE_H__
25 
26 #include "gui/widgets/tablewidgetmouseaware.h"
27 
28 #include <functional>
29 
31 {
32  Q_OBJECT
33 
34 public:
35  static const int IDX_URL_COLUMN = 0;
36  static const int IDX_PROGRESS_COLUMN = 1;
37  static const int IDX_ABORT_COLUMN = 2;
38 
39  static const int PROGRESS_COLUMN_WIDTH = 85;
40 
41  WadseekerSitesTable(QWidget *pParent = nullptr);
42 
43  void addUrl(const QUrl &url);
44  void removeUrl(const QUrl &url);
45 
46 public slots:
47  void addService(const QString &service);
48  void removeService(const QString &service);
49  void setUrlProgress(const QUrl &url, qint64 current, qint64 total);
50 
51 signals:
52  void serviceAbortRequested(const QString &service);
53  void urlAbortRequested(const QUrl &url);
54 
55 protected:
56  void showEvent(QShowEvent *pEvent) override;
57 
58 private:
59  class PrivData
60  {
61  public:
62  bool bAlreadyShownOnce;
63  };
64 
65  PrivData d;
66 
67  void addSite(const QString &text, std::function<void(void)> onAbort);
68  int findRow(const QString &text);
69  int findRow(const QUrl &url);
70 
71 private slots:
72  void requestUrlAbort(const QString &urlAsString);
73 };
74 
75 #endif