1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
/***************************************************************************
* Copyright (C) 2005 by *
* Joris Guisson <joris.guisson@gmail.com> *
* Ivan Vasic <ivasic@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef _KTORRENTVIEW_H_
#define _KTORRENTVIEW_H_
#include <klistview.h>
typedef QValueList<QCString> QCStringList;
class KURL;
class KTorrentViewItem;
class KPopupMenu;
class KTorrentCore;
class KTorrentViewMenu;
class KTorrentView;
class ScanDialog;
class QString;
class FilterBar;
namespace kt
{
class TorrentInterface;
class Group;
}
using namespace bt;
class TorrentView : public KListView
{
public:
TorrentView(KTorrentView* parent);
virtual ~TorrentView();
virtual bool eventFilter(QObject* watched, QEvent* e);
private:
KTorrentView* ktview;
};
/**
* List view which shows information about torrents.
*/
class KTorrentView : public QWidget
{
Q_OBJECT
public:
enum ActionEnableFlags
{
START = 1,
STOP = 2,
START_ALL = 4,
STOP_ALL = 8,
REMOVE = 16,
SCAN = 32
};
/**
* Default constructor
*/
KTorrentView(QWidget *parent);
/**
* Destructor
*/
virtual ~KTorrentView();
/// Update the caption, so the correct number of running torrents is shown in the tab
void updateCaption();
/// Trigger an updateActions signal
void updateActions() {onSelectionChanged();}
/// Get the current group
const kt::Group* getCurrentGroup() const {return current_group;}
/// Get the current TorrentInterface object
kt::TorrentInterface* getCurrentTC();
/// Save the views settings
void saveSettings(KConfig* cfg,int idx);
/// Load the views settings
void loadSettings(KConfig* cfg,int idx);
/**
* Put the current selection in a list.
* @param sel The list to put it in
*/
void getSelection(QValueList<kt::TorrentInterface*> & sel);
/**
* Add the current selection to a group.
* @param g The group
*/
void addSelectionToGroup(kt::Group* g);
/**
* Is column visible?
*/
bool columnVisible(int index);
/**
* Setup the view columns, based upon the current group
* This will hide some columns for uploads only groups.
*/
void setupViewColumns();
QPtrList<QListViewItem> selectedItems() {return view->selectedItems();}
KListView* listView() {return view;}
/**
* Toggle the visibility of the filter bar
*/
void toggleFilterBar();
public slots:
void setCurrentGroup(kt::Group* group);
void addTorrent(kt::TorrentInterface* tc);
void removeTorrent(kt::TorrentInterface* tc);
void update();
void startDownloads();
void stopDownloads();
void startAllDownloads();
void stopAllDownloads();
void manualAnnounce();
void previewFiles();
void removeDownloads();
void removeDownloadsAndData();
void onSelectionChanged();
void queueSlot();
void checkDataIntegrity();
void removeFromGroup();
void showAddPeersWidget();
void openOutputDirectory();
void openTorXDirectory();
void setDownloadLocationSlot();
void dhtSlot();
void utPexSlot();
void speedLimits();
private slots:
void onExecuted(QListViewItem* item);
void showContextMenu(KListView* ,QListViewItem* item,const QPoint & p);
void onColumnVisibilityChange(int);
void gsmItemActived(const QString & group);
signals:
void torrentClicked(kt::TorrentInterface* tc);
void currentChanged(kt::TorrentInterface* tc);
void wantToRemove(kt::TorrentInterface* tc,bool data_to);
void wantToStop(kt::TorrentInterface* tc,bool user);
void wantToStart(kt::TorrentInterface* tc);
void viewChange(kt::TorrentInterface* tc);
/**
* Emit that actions need to be updated
* @param flags OR of ActionEnableFlags
*/
void updateActions(int flags);
void queue(kt::TorrentInterface* tc);
void needsDataCheck(kt::TorrentInterface* tc);
void updateGroupsSubMenu(KPopupMenu* gsm);
void groupsSubMenuItemActivated(KTorrentView* v,const QString & group);
private:
bool acceptDrag(QDropEvent* event) const;
int getNumRunning();
bool startDownload(kt::TorrentInterface* tc);
void stopDownload(kt::TorrentInterface* tc);
void showStartError();
virtual QDragObject* dragObject();
void setupColumns();
void insertColumn(QString label, Qt::AlignmentFlags);
void columnHide(int index);
void columnShow(int index);
private:
QMap<kt::TorrentInterface*,KTorrentViewItem*> items;
KTorrentViewMenu* menu;
KPopupMenu* m_headerMenu;
kt::Group* current_group;
Uint32 running;
Uint32 total;
TorrentView* view;
FilterBar* filter_bar;
friend class TorrentView;
};
#endif // _KTORRENTVIEW_H_
|