wadseekerwadstable.h
1 //------------------------------------------------------------------------------
2 // wadseekerwadstable.h
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program 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
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; 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 __WADSEEKERWADSTABLE_H__
24 #define __WADSEEKERWADSTABLE_H__
25 
26 #include <QMap>
27 #include <QMenu>
28 #include <QTime>
29 
30 #include "gui/widgets/tablewidgetmouseaware.h"
31 
32 class SpeedCalculator;
33 
35 {
36  Q_OBJECT;
37 
38  public:
39  class ContextMenu : public QMenu
40  {
41  friend class WadseekerWadsTable;
42 
43  public:
44  QAction* actionSkipCurrentSite;
45 
46  private:
47  ContextMenu(QWidget* pParent = NULL);
48  };
49 
50  static const int IDX_NAME_COLUMN = 0;
51  static const int IDX_URL_COLUMN = 1;
52  static const int IDX_PROGRESS_COLUMN = 2;
53  static const int IDX_SPEED_COLUMN = 3;
54  static const int IDX_ETA_COLUMN = 4;
55  static const int IDX_SIZE_COLUMN = 5;
56 
57  WadseekerWadsTable(QWidget* pParent = NULL);
59 
60  void addFile(const QString& filename);
61 
62  ContextMenu* contextMenu(const QModelIndex& index, const QPoint& cursorPosition);
63 
70  qint64 expectedDataSize(int row) const;
71 
72  QString fileNameAtRow(int row) const;
73 
81  double totalDonePercentage() const;
82 
83  public slots:
84  void setFileDownloadFinished(const QString& filename);
85  void setFileFailed(const QString& filename);
86  void setFileProgress(const QString& filename, qint64 current, qint64 total);
87  void setFileSuccessful(const QString& filename);
88 
92  void setFileUrl(const QString& filename, const QUrl& url);
93 
94  protected:
95  void showEvent(QShowEvent* pEvent);
96 
97  private:
98  class PrivData
99  {
100  public:
101  bool bAlreadyShownOnce;
102 
110  QMap<QString, SpeedCalculator* > speedCalculators;
111  QTime updateClock;
112  };
113 
114  static const int UPDATE_INTERVAL_MS = 1000;
115 
116  PrivData d;
117 
118  int findFileRow(const QString& filename);
119  void updateDataInfoValues(bool bForce);
120 };
121 
122 #endif
void setFileUrl(const QString &filename, const QUrl &url)
Fired when new URL starts for specified file.
qint64 expectedDataSize(int row) const
Total size of data in bytes for specified row.
double totalDonePercentage() const
Total done percentage calculated basing on the data set by siteFileProgress().
Definition: dptr.h:31