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
|
/***************************************************************************
* TorrentsWindow.h
*
* Sat Jan 27 14:19:23 2007
* Copyright 2007 Fernando TarĂn Morales
* icemanf@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 3 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 _TORRENTSWINDOW_H
#define _TORRENTSWINDOW_H
#include <gtkmm.h>
#include "libtorrent/session.hpp"
#include "MenuBar.h"
#include "Utils.h"
#include "Lince/Torrent.h"
class TorrentsTab;
class MainWindow;
class MenuBar;
enum TorrentsWindowType { DOWNLOADING_TORRENTS, DOWNLOADED_TORRENTS };
class TorrentsWindow: public Gtk::ScrolledWindow
{
private:
Utils::TorrentModelColumns torrentsColumns;
TorrentsWindowType torrentsWindowType;
MenuBar * menuBar;
TorrentsTab * torrentsTab;
bool isCtrlKeyPressed;
// Rows
Gtk::TreeView torrentsTreeView;
Glib::RefPtr<Gtk::ListStore> refTreeModel;
Glib::RefPtr<Gtk::TreeSelection> refTreeSelection;
Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup;
// Show columns_autosize
Glib::RefPtr<Gtk::ToggleAction> showID;
Glib::RefPtr<Gtk::ToggleAction> showHealth;
Glib::RefPtr<Gtk::ToggleAction> showName;
Glib::RefPtr<Gtk::ToggleAction> showSize;
Glib::RefPtr<Gtk::ToggleAction> showRest;
Glib::RefPtr<Gtk::ToggleAction> showDownloaded;
Glib::RefPtr<Gtk::ToggleAction> showUploaded;
Glib::RefPtr<Gtk::ToggleAction> showRatio;
Glib::RefPtr<Gtk::ToggleAction> showPercentage;
Glib::RefPtr<Gtk::ToggleAction> showSeeders;
Glib::RefPtr<Gtk::ToggleAction> showDownloaders;
Glib::RefPtr<Gtk::ToggleAction> showStatus;
Glib::RefPtr<Gtk::ToggleAction> showDSpeed;
Glib::RefPtr<Gtk::ToggleAction> showUSpeed;
Glib::RefPtr<Gtk::ToggleAction> showETA;
// Row Menu
Glib::RefPtr<Gtk::UIManager> rm_refUIManager;
Gtk::Menu* rm_pMenuPopup;
// Menu
Glib::RefPtr<Gtk::UIManager> nsm_refUIManager;
Gtk::Menu* nsm_pMenuPopup;
// Health images
enum Health { GOOD, BAD, FIREWALLED, NOTRACKER };
Glib::RefPtr<Gdk::Pixbuf> goodHealth, noTrackerHealth;
Glib::RefPtr<Gdk::Pixbuf> badHealth, firewalledHealth;
// Signal to remove torrents when supr key is pressed
sigc::signal<void> sig_to_remove_torrents;
void setMenuSensitivity();
void updateRow(Lince::Torrent *, Gtk::TreeModel::Row&);
void mouse_button_press_event(GdkEventButton* event);
void key_press_event(GdkEventKey* event);
void key_release_event(GdkEventKey* event);
bool focus_in_event(GdkEventFocus*);
void hideColumn(int);
public:
TorrentsWindow(MainWindow*, MenuBar*, TorrentsTab*, TorrentsWindowType);
~TorrentsWindow();
int torrentsSelected(void);
bool getSelectedTorrent(int &);
bool getSelectedTorrents(std::vector<int>&);
int getSelectedRow(void);
void setSelectedRow(int position);
void removeGivenRow(int tId);
void addRow(Lince::Torrent *t);
void updateRows(void);
void unselectRows(void);
void clearRows(void) { refTreeModel->clear(); };
bool isSorted();
void autoSizeColums(void) { torrentsTreeView.columns_autosize(); };
};
#endif /* _TORRENTSWINDOW_H */
|