1 /***************************************************************************
2 * Copyright (C) 2009 by Lassi Väätämöinen *
3 * lassi.vaatamoinen@ixonos.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
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. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20 #ifndef DOWNLOADVIEW_H
21 #define DOWNLOADVIEW_H
24 #include <qtrapids/info.hpp>
25 #include <qtrapids/dbus.hpp>
27 #include <QTreeWidget>
33 class DownloadViewItem;
35 typedef QHash<QString, DownloadViewItem*> DownloadItems_t;
39 @brief A view showing all downloaded torrents
40 @author Lassi Väätämöinen <lassi.vaatamoinen@ixonos.com>
42 class DownloadView : public QTreeWidget
47 DownloadView(QWidget* parent);
51 void updateItem(TorrentState const& info, ParamsMap_t other_info);
52 QString removeSelected();
55 void on_itemClicked(QTreeWidgetItem * item, int column);
58 void addItem_(TorrentState const& info, ParamsMap_t other_info);
59 void updateItem_(DownloadViewItem *item
60 , TorrentState const& info, ParamsMap_t other_info);
62 // Maps torrent to downloadview item.
63 // Key: SHA1 info hash of torrent. Data: View item corresponding to torrent.
64 DownloadItems_t items_;
67 static QString GetStatusString(TorrentStatus::Id status);
68 static QColor GetStatusColor(TorrentStatus::Id status);
73 @class DownloadViewItem
74 @brief Represents one item row of DownloadView
76 class DownloadViewItem : public QTreeWidgetItem {
79 DownloadViewItem(QTreeWidget* parent, int type) :
80 QTreeWidgetItem(parent, type = QTreeWidgetItem::UserType) {};
82 DownloadViewItem(QString hash, const QStringList& strings,
83 int type = QTreeWidgetItem::UserType) :
84 QTreeWidgetItem (strings, type = Type),
89 /// @return An item comprising of string list, suitable for QTableView
91 static DownloadViewItem *getHeaderItem()
93 DownloadViewItem *item
94 = new DownloadViewItem("", QStringList()
97 << "Progress" << "DL speed"
98 << "UL speed" << "Seeds/Leechers"
104 /// @todo QTorrentHandle as one hidden column
106 QString getHash() const
115 } // namespace qtrapids
117 #endif // DOWNLOADVIEW_H