X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fgui%2FDownloadView.h;h=cb300ba4c63dfbe026513cbd5cb221163481cd01;hb=d3d85653bf84dadcf6c2890cc2ddf9f629ee7619;hp=07ec860736972010b8a142135960c2ea0bc5db90;hpb=033e50732cef6dd961ac23dcd6371c873114ebe9;p=qtrapids diff --git a/src/gui/DownloadView.h b/src/gui/DownloadView.h index 07ec860..cb300ba 100644 --- a/src/gui/DownloadView.h +++ b/src/gui/DownloadView.h @@ -20,9 +20,18 @@ #ifndef DOWNLOADVIEW_H #define DOWNLOADVIEW_H +#include + #include +#include "QBittorrentSession.h" + +class DownloadViewItem; +class QTimer; + /** + @class DownloadView + @brief A view showing all downloaded torrents @author Lassi Väätämöinen */ class DownloadView : public QTreeWidget @@ -34,29 +43,44 @@ Q_OBJECT ~DownloadView(); + void newItem(qtrapids::QTorrentHandle handle); + void updateItem(qtrapids::QTorrentHandle handle); + qtrapids::QTorrentHandle removeSelected(); + void removeItem(qtrapids::QTorrentHandle handle); + void setRefreshInterval(int msec); + + private slots: + void on_itemClicked(QTreeWidgetItem * item, int column); + void on_timeout(); + private: + // Maps torrent to downloadview item. + // Key: SHA1 info hash of torrent. Data: View item corresponding to torrent. + std::map items_; + QTimer *timer_; + + // Private functions. + QString GetStatusString(qtrapids::QTorrentHandle::State const& status) const; + QColor GetStatusColor(qtrapids::QTorrentHandle::State const& status) const; + void UpdateView(); + }; /** - @class DownloadViewItem + @class DownloadViewItem @brief Represents one item row of DownloadView */ class DownloadViewItem : public QTreeWidgetItem { - public: - + public: DownloadViewItem(QTreeWidget* parent, int type) : - QTreeWidgetItem(parent, type = QTreeWidgetItem::UserType) - { - }; + QTreeWidgetItem(parent, type = QTreeWidgetItem::UserType) {}; DownloadViewItem(const QStringList& strings, - int type = QTreeWidgetItem::UserType ) : - QTreeWidgetItem (strings, type = Type) - { - }; + int type = QTreeWidgetItem::UserType) : + QTreeWidgetItem (strings, type = Type) {}; /// @return An item comprising of string list, suitable for QTableView @@ -64,11 +88,12 @@ class DownloadViewItem : public QTreeWidgetItem { static DownloadViewItem *getHeaderItem() { DownloadViewItem *item - = new DownloadViewItem(QStringList() << "Name" + = new DownloadViewItem(QStringList() + << "Name" << "Size" << "Status" << "Progress" << "DL speed" << "UL speed" << "Seeds/Leechers" - << "ratio" << "ETA"); + << "Ratio" << "ETA"); return item; }