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
22 #include <qtrapids/info.hpp>
23 #include <qtrapids/dbus.hpp>
25 #include <QTreeWidget>
31 class DownloadViewItem;
33 typedef QHash<QString, DownloadViewItem*> DownloadItems_t;
37 @brief A view showing all downloaded torrents
38 @author Lassi Väätämöinen <lassi.vaatamoinen@ixonos.com>
40 class DownloadView : public QTreeWidget
45 DownloadView(QWidget* parent);
49 void updateItem(TorrentState const& info, ParamsMap_t other_info);
50 QString prepareRemoveSelected();
52 /// Saves current view settings via QSettings
54 /// Reads view settigns via QSettings
58 void on_itemClicked(QTreeWidgetItem * item, int column);
62 // Maps torrent to downloadview item.
63 // Key: SHA1 info hash of torrent. Data: View item corresponding to torrent.
64 DownloadItems_t items_;
65 // Used for saving view settings
70 void addItem_(TorrentState const& info, ParamsMap_t other_info);
71 void updateItem_(DownloadViewItem *item
72 , TorrentState const& info, ParamsMap_t other_info);
73 void removeItem_(DownloadViewItem *item, TorrentState const& info);
76 static QString GetStatusString(TorrentStatus::Id status);
77 static QColor GetStatusColor(TorrentStatus::Id status);
83 @class DownloadViewItem
84 @brief Represents one item row of DownloadView
86 class DownloadViewItem : public QTreeWidgetItem
90 DownloadViewItem(QTreeWidget* parent, int type) :
91 QTreeWidgetItem(parent, type = QTreeWidgetItem::UserType) {};
93 DownloadViewItem(QString hash, const QStringList& strings,
94 int type = QTreeWidgetItem::UserType) :
95 QTreeWidgetItem (strings, type = Type),
99 /// @return An item comprising of string list, suitable for QTableView
101 static DownloadViewItem *getHeaderItem() {
102 DownloadViewItem *item
103 = new DownloadViewItem("", QStringList()
105 << "Size" << "Status"
106 << "Progress" << "DL speed"
107 << "UL speed" << "Seeds/Leechers"
108 << "Ratio" << "ETA");
113 /// @todo QTorrentHandle as one hidden column
115 QString getHash() const {
123 } // namespace qtrapids
125 #endif // DOWNLOADVIEW_H