X-Git-Url: http://git.maemo.org/git/?p=qtrapids;a=blobdiff_plain;f=src%2Fgui%2FDownloadView.h;h=2a66141968edda3c411c869bde86864876670bea;hp=07ec860736972010b8a142135960c2ea0bc5db90;hb=1ff0a23bdb48e5c21a26df217de38b02359b3150;hpb=033e50732cef6dd961ac23dcd6371c873114ebe9 diff --git a/src/gui/DownloadView.h b/src/gui/DownloadView.h index 07ec860..2a66141 100644 --- a/src/gui/DownloadView.h +++ b/src/gui/DownloadView.h @@ -20,21 +20,50 @@ #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 { -Q_OBJECT - - public: - DownloadView(QWidget* parent); + 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_; - ~DownloadView(); + // Private functions. + QString GetStatusString(qtrapids::QTorrentHandle::State const& status) const; + QColor GetStatusColor(qtrapids::QTorrentHandle::State const& status) const; + void UpdateView(); - private: }; @@ -43,37 +72,33 @@ Q_OBJECT @class DownloadViewItem @brief Represents one item row of DownloadView */ -class DownloadViewItem : public QTreeWidgetItem { - - public: - - DownloadViewItem(QTreeWidget* parent, int type) : - QTreeWidgetItem(parent, 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 +class DownloadViewItem : public QTreeWidgetItem +{ + +public: + DownloadViewItem(QTreeWidget* parent, int type) : + QTreeWidgetItem(parent, 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 }; #endif