1 /***************************************************************************
2 * Copyright (C) 2010 by Ixonos Plc *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; version 2 of the License. *
8 * This program is distributed in the hope that it will be useful, *
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11 * GNU General Public License for more details. *
13 * You should have received a copy of the GNU General Public License *
14 * along with this program; if not, write to the *
15 * Free Software Foundation, Inc., *
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
17 ***************************************************************************/
18 #ifndef DOWNLOADVIEW_H
19 #define DOWNLOADVIEW_H
23 #include <QTreeWidget>
25 #include "QBittorrentSession.h"
27 class DownloadViewItem;
32 @brief A view showing all downloaded torrents
33 @author Lassi Väätämöinen <lassi.vaatamoinen@ixonos.com>
35 class DownloadView : public QTreeWidget
40 DownloadView(QWidget* parent);
44 void newItem(qtrapids::QTorrentHandle handle);
45 void updateItem(qtrapids::QTorrentHandle handle);
46 qtrapids::QTorrentHandle removeSelected();
47 void removeItem(qtrapids::QTorrentHandle handle);
48 void setRefreshInterval(int msec);
51 void on_itemClicked(QTreeWidgetItem * item, int column);
55 // Maps torrent to downloadview item.
56 // Key: SHA1 info hash of torrent. Data: View item corresponding to torrent.
57 std::map<qtrapids::QTorrentHandle, DownloadViewItem*> items_;
61 QString GetStatusString(qtrapids::QTorrentHandle::State const& status) const;
62 QColor GetStatusColor(qtrapids::QTorrentHandle::State const& status) const;
70 @class DownloadViewItem
71 @brief Represents one item row of DownloadView
73 class DownloadViewItem : public QTreeWidgetItem
77 DownloadViewItem(QTreeWidget* parent, int type) :
78 QTreeWidgetItem(parent, type = QTreeWidgetItem::UserType) {};
80 DownloadViewItem(const QStringList& strings,
81 int type = QTreeWidgetItem::UserType) :
82 QTreeWidgetItem (strings, type = Type) {};
85 /// @return An item comprising of string list, suitable for QTableView
87 static DownloadViewItem *getHeaderItem() {
88 DownloadViewItem *item
89 = new DownloadViewItem(QStringList()
92 << "Progress" << "DL speed"
93 << "UL speed" << "Seeds/Leechers"
99 /// @todo QTorrentHandle as one hidden column