X-Git-Url: http://git.maemo.org/git/?p=qtrapids;a=blobdiff_plain;f=src%2Fgui%2FDownloadView.h;h=2a66141968edda3c411c869bde86864876670bea;hp=80b5228a107e855d5dfbf08b866bf0f3ca112120;hb=a988ddfbc3be7773bccd4017a70fcd8ce990d8c7;hpb=45e692ff47151854cc149c514d3a53285f0f195a diff --git a/src/gui/DownloadView.h b/src/gui/DownloadView.h index 80b5228..2a66141 100644 --- a/src/gui/DownloadView.h +++ b/src/gui/DownloadView.h @@ -27,6 +27,7 @@ #include "QBittorrentSession.h" class DownloadViewItem; +class QTimer; /** @class DownloadView @@ -35,21 +36,35 @@ class DownloadViewItem; */ class DownloadView : public QTreeWidget { -Q_OBJECT - - public: - DownloadView(QWidget* parent); - - ~DownloadView(); - - void newItem(QTorrentHandle const* handle); - void updateItem(QTorrentHandle const* handle); - - private: - // Maps torrent to downloadview item. - // Key: SHA1 info hash of torrent. Data: View item corresponding to torrent. - std::map items_; - + Q_OBJECT + +public: + DownloadView(QWidget* parent); + + ~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(); + + }; @@ -57,33 +72,33 @@ Q_OBJECT @class DownloadViewItem @brief Represents one item row of DownloadView */ -class DownloadViewItem : public QTreeWidgetItem { - - public: - DownloadViewItem(QTreeWidget* parent, int type) : +class DownloadViewItem : public QTreeWidgetItem +{ + +public: + DownloadViewItem(QTreeWidget* parent, int type) : QTreeWidgetItem(parent, type = QTreeWidgetItem::UserType) {}; - - DownloadViewItem(const QStringList& strings, - int type = QTreeWidgetItem::UserType) : + + DownloadViewItem(const QStringList& strings, + int type = QTreeWidgetItem::UserType) : QTreeWidgetItem (strings, type = Type) {}; - - - /// @return An item comprising of string list, suitable for QTableView - /// header. - static DownloadViewItem *getHeaderItem() - { - DownloadViewItem *item - = new DownloadViewItem(QStringList() - << "Name" - << "Size" << "Status" - << "Progress" << "DL speed" - << "UL speed" << "Seeds/Leechers" - << "Ratio" << "ETA"); - - return item; - } - - /// @todo QTorrentHandle as one hidden column + + + /// @return An item comprising of string list, suitable for QTableView + /// header. + static DownloadViewItem *getHeaderItem() { + DownloadViewItem *item + = new DownloadViewItem(QStringList() + << "Name" + << "Size" << "Status" + << "Progress" << "DL speed" + << "UL speed" << "Seeds/Leechers" + << "Ratio" << "ETA"); + + return item; + } + + /// @todo QTorrentHandle as one hidden column }; #endif