mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 21:14:33 +00:00
Follow project coding style. Issue #2192.
This commit is contained in:
parent
44992056cf
commit
6644791458
File diff suppressed because it is too large
Load Diff
@ -42,7 +42,8 @@ QT_END_NAMESPACE
|
|||||||
class QTorrentState
|
class QTorrentState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
Unknown = -1,
|
Unknown = -1,
|
||||||
|
|
||||||
Error,
|
Error,
|
||||||
@ -71,93 +72,94 @@ private:
|
|||||||
|
|
||||||
// A wrapper for torrent_handle in libtorrent
|
// A wrapper for torrent_handle in libtorrent
|
||||||
// to interact well with Qt types
|
// to interact well with Qt types
|
||||||
class QTorrentHandle : public libtorrent::torrent_handle {
|
class QTorrentHandle: public libtorrent::torrent_handle
|
||||||
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//
|
//
|
||||||
// Constructors
|
// Constructors
|
||||||
//
|
//
|
||||||
|
|
||||||
QTorrentHandle() {}
|
QTorrentHandle() {}
|
||||||
explicit QTorrentHandle(const libtorrent::torrent_handle& h);
|
explicit QTorrentHandle(const libtorrent::torrent_handle& h);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Getters
|
// Getters
|
||||||
//
|
//
|
||||||
QString hash() const;
|
QString hash() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
QString current_tracker() const;
|
QString current_tracker() const;
|
||||||
bool is_paused() const;
|
bool is_paused() const;
|
||||||
bool has_filtered_pieces() const;
|
bool has_filtered_pieces() const;
|
||||||
libtorrent::size_type total_size() const;
|
libtorrent::size_type total_size() const;
|
||||||
libtorrent::size_type piece_length() const;
|
libtorrent::size_type piece_length() const;
|
||||||
int num_pieces() const;
|
int num_pieces() const;
|
||||||
QString save_path() const;
|
QString save_path() const;
|
||||||
QString save_path_parsed() const;
|
QString save_path_parsed() const;
|
||||||
QStringList url_seeds() const;
|
QStringList url_seeds() const;
|
||||||
libtorrent::size_type actual_size() const;
|
libtorrent::size_type actual_size() const;
|
||||||
int num_files() const;
|
int num_files() const;
|
||||||
int queue_position() const;
|
int queue_position() const;
|
||||||
bool is_queued() const;
|
bool is_queued() const;
|
||||||
QString filename_at(unsigned int index) const;
|
QString filename_at(unsigned int index) const;
|
||||||
libtorrent::size_type filesize_at(unsigned int index) const;
|
libtorrent::size_type filesize_at(unsigned int index) const;
|
||||||
QString filepath_at(unsigned int index) const;
|
QString filepath_at(unsigned int index) const;
|
||||||
QString orig_filepath_at(unsigned int index) const;
|
QString orig_filepath_at(unsigned int index) const;
|
||||||
libtorrent::torrent_status::state_t state() const;
|
libtorrent::torrent_status::state_t state() const;
|
||||||
QString creator() const;
|
QString creator() const;
|
||||||
QString comment() const;
|
QString comment() const;
|
||||||
QStringList absolute_files_path() const;
|
QStringList absolute_files_path() const;
|
||||||
QStringList absolute_files_path_uneeded() const;
|
QStringList absolute_files_path_uneeded() const;
|
||||||
bool has_missing_files() const;
|
bool has_missing_files() const;
|
||||||
bool is_seed() const;
|
bool is_seed() const;
|
||||||
bool is_checking() const;
|
bool is_checking() const;
|
||||||
bool is_sequential_download() const;
|
bool is_sequential_download() const;
|
||||||
QString creation_date() const;
|
QString creation_date() const;
|
||||||
qlonglong creation_date_unix() const;
|
qlonglong creation_date_unix() const;
|
||||||
bool priv() const;
|
bool priv() const;
|
||||||
bool first_last_piece_first() const;
|
bool first_last_piece_first() const;
|
||||||
QString root_path() const;
|
QString root_path() const;
|
||||||
QString firstFileSavePath() const;
|
QString firstFileSavePath() const;
|
||||||
bool has_error() const;
|
bool has_error() const;
|
||||||
QString error() const;
|
QString error() const;
|
||||||
void downloading_pieces(libtorrent::bitfield& bf) const;
|
void downloading_pieces(libtorrent::bitfield& bf) const;
|
||||||
bool has_metadata() const;
|
bool has_metadata() const;
|
||||||
void file_progress(std::vector<libtorrent::size_type>& fp) const;
|
void file_progress(std::vector<libtorrent::size_type>& fp) const;
|
||||||
QTorrentState torrentState() const;
|
QTorrentState torrentState() const;
|
||||||
qulonglong eta() const;
|
qulonglong eta() const;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Setters
|
// Setters
|
||||||
//
|
//
|
||||||
void pause() const;
|
void pause() const;
|
||||||
void resume() const;
|
void resume() const;
|
||||||
void remove_url_seed(const QString& seed) const;
|
void remove_url_seed(const QString& seed) const;
|
||||||
void add_url_seed(const QString& seed) const;
|
void add_url_seed(const QString& seed) const;
|
||||||
void set_tracker_login(const QString& username, const QString& password) const;
|
void set_tracker_login(const QString& username, const QString& password) const;
|
||||||
void move_storage(const QString& path) const;
|
void move_storage(const QString& path) const;
|
||||||
void prioritize_first_last_piece(bool b) const;
|
void prioritize_first_last_piece(bool b) const;
|
||||||
void rename_file(int index, const QString& name) const;
|
void rename_file(int index, const QString& name) const;
|
||||||
bool save_torrent_file(const QString& path) const;
|
bool save_torrent_file(const QString& path) const;
|
||||||
void prioritize_files(const std::vector<int>& files) const;
|
void prioritize_files(const std::vector<int>& files) const;
|
||||||
void file_priority(int index, int priority) const;
|
void file_priority(int index, int priority) const;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Operators
|
// Operators
|
||||||
//
|
//
|
||||||
bool operator ==(const QTorrentHandle& new_h) const;
|
bool operator ==(const QTorrentHandle& new_h) const;
|
||||||
|
|
||||||
static bool is_paused(const libtorrent::torrent_status &status);
|
static bool is_paused(const libtorrent::torrent_status &status);
|
||||||
static int queue_position(const libtorrent::torrent_status &status);
|
static int queue_position(const libtorrent::torrent_status &status);
|
||||||
static bool is_queued(const libtorrent::torrent_status &status);
|
static bool is_queued(const libtorrent::torrent_status &status);
|
||||||
static bool is_seed(const libtorrent::torrent_status &status);
|
static bool is_seed(const libtorrent::torrent_status &status);
|
||||||
static bool is_checking(const libtorrent::torrent_status &status);
|
static bool is_checking(const libtorrent::torrent_status &status);
|
||||||
static bool has_error(const libtorrent::torrent_status &status);
|
static bool has_error(const libtorrent::torrent_status &status);
|
||||||
static float progress(const libtorrent::torrent_status &status);
|
static float progress(const libtorrent::torrent_status &status);
|
||||||
static QString filepath_at(const libtorrent::torrent_info &info, unsigned int index);
|
static QString filepath_at(const libtorrent::torrent_info &info, unsigned int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void prioritize_first_last_piece(int file_index, bool b) const;
|
void prioritize_first_last_piece(int file_index, bool b) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -47,77 +47,78 @@ class QSortFilterProxyModel;
|
|||||||
class QStandardItemModel;
|
class QStandardItemModel;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class TransferListWidget: public QTreeView {
|
class TransferListWidget: public QTreeView
|
||||||
Q_OBJECT
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TransferListWidget(QWidget *parent, MainWindow *main_window, QBtSession* BTSession);
|
TransferListWidget(QWidget *parent, MainWindow *main_window, QBtSession* BTSession);
|
||||||
~TransferListWidget();
|
~TransferListWidget();
|
||||||
TorrentModel* getSourceModel() const;
|
TorrentModel* getSourceModel() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setSelectionLabel(QString label);
|
void setSelectionLabel(QString label);
|
||||||
void setRefreshInterval(int t);
|
void setRefreshInterval(int t);
|
||||||
void setSelectedTorrentsLocation();
|
void setSelectedTorrentsLocation();
|
||||||
void startSelectedTorrents();
|
void startSelectedTorrents();
|
||||||
void startVisibleTorrents();
|
void startVisibleTorrents();
|
||||||
void pauseSelectedTorrents();
|
void pauseSelectedTorrents();
|
||||||
void pauseVisibleTorrents();
|
void pauseVisibleTorrents();
|
||||||
void deleteSelectedTorrents();
|
void deleteSelectedTorrents();
|
||||||
void deleteVisibleTorrents();
|
void deleteVisibleTorrents();
|
||||||
void increasePrioSelectedTorrents();
|
void increasePrioSelectedTorrents();
|
||||||
void decreasePrioSelectedTorrents();
|
void decreasePrioSelectedTorrents();
|
||||||
void topPrioSelectedTorrents();
|
void topPrioSelectedTorrents();
|
||||||
void bottomPrioSelectedTorrents();
|
void bottomPrioSelectedTorrents();
|
||||||
void copySelectedMagnetURIs() const;
|
void copySelectedMagnetURIs() const;
|
||||||
void openSelectedTorrentsFolder() const;
|
void openSelectedTorrentsFolder() const;
|
||||||
void recheckSelectedTorrents();
|
void recheckSelectedTorrents();
|
||||||
void setDlLimitSelectedTorrents();
|
void setDlLimitSelectedTorrents();
|
||||||
void setUpLimitSelectedTorrents();
|
void setUpLimitSelectedTorrents();
|
||||||
void setMaxRatioSelectedTorrents();
|
void setMaxRatioSelectedTorrents();
|
||||||
void previewSelectedTorrents();
|
void previewSelectedTorrents();
|
||||||
void hidePriorityColumn(bool hide);
|
void hidePriorityColumn(bool hide);
|
||||||
void displayDLHoSMenu(const QPoint&);
|
void displayDLHoSMenu(const QPoint&);
|
||||||
void applyNameFilter(const QString& name);
|
void applyNameFilter(const QString& name);
|
||||||
void applyStatusFilter(int f);
|
void applyStatusFilter(int f);
|
||||||
void applyLabelFilterAll();
|
void applyLabelFilterAll();
|
||||||
void applyLabelFilter(QString label);
|
void applyLabelFilter(QString label);
|
||||||
void previewFile(QString filePath);
|
void previewFile(QString filePath);
|
||||||
void removeLabelFromRows(QString label);
|
void removeLabelFromRows(QString label);
|
||||||
void renameSelectedTorrent();
|
void renameSelectedTorrent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int getRowFromHash(QString hash) const;
|
int getRowFromHash(QString hash) const;
|
||||||
QString getHashFromRow(int row) const;
|
QString getHashFromRow(int row) const;
|
||||||
QModelIndex mapToSource(const QModelIndex &index) const;
|
QModelIndex mapToSource(const QModelIndex &index) const;
|
||||||
QModelIndex mapFromSource(const QModelIndex &index) const;
|
QModelIndex mapFromSource(const QModelIndex &index) const;
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
bool loadSettings();
|
bool loadSettings();
|
||||||
QStringList getSelectedTorrentsHashes() const;
|
QStringList getSelectedTorrentsHashes() const;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void torrentDoubleClicked(const QModelIndex& index);
|
void torrentDoubleClicked(const QModelIndex& index);
|
||||||
void displayListMenu(const QPoint&);
|
void displayListMenu(const QPoint&);
|
||||||
void currentChanged(const QModelIndex& current, const QModelIndex&);
|
void currentChanged(const QModelIndex& current, const QModelIndex&);
|
||||||
void toggleSelectedTorrentsSuperSeeding() const;
|
void toggleSelectedTorrentsSuperSeeding() const;
|
||||||
void toggleSelectedTorrentsSequentialDownload() const;
|
void toggleSelectedTorrentsSequentialDownload() const;
|
||||||
void toggleSelectedFirstLastPiecePrio() const;
|
void toggleSelectedFirstLastPiecePrio() const;
|
||||||
void askNewLabelForSelection();
|
void askNewLabelForSelection();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool openUrl(const QString& _path) const;
|
bool openUrl(const QString& _path) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentTorrentChanged(const QTorrentHandle &h);
|
void currentTorrentChanged(const QTorrentHandle &h);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TransferListDelegate *listDelegate;
|
TransferListDelegate *listDelegate;
|
||||||
TorrentModel *listModel;
|
TorrentModel *listModel;
|
||||||
TransferListSortModel *nameFilterModel;
|
TransferListSortModel *nameFilterModel;
|
||||||
QBtSession* BTSession;
|
QBtSession* BTSession;
|
||||||
MainWindow *main_window;
|
MainWindow *main_window;
|
||||||
QShortcut *editHotkey;
|
QShortcut *editHotkey;
|
||||||
QShortcut *deleteHotkey;
|
QShortcut *deleteHotkey;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRANSFERLISTWIDGET_H
|
#endif // TRANSFERLISTWIDGET_H
|
||||||
|
@ -55,7 +55,7 @@ using namespace libtorrent;
|
|||||||
static QElapsedTimer cacheTimer; \
|
static QElapsedTimer cacheTimer; \
|
||||||
static bool initialized = false; \
|
static bool initialized = false; \
|
||||||
if (initialized && !cacheTimer.hasExpired(DUR)) \
|
if (initialized && !cacheTimer.hasExpired(DUR)) \
|
||||||
return json::toJson(VAR); \
|
return json::toJson(VAR); \
|
||||||
initialized = true; \
|
initialized = true; \
|
||||||
cacheTimer.start(); \
|
cacheTimer.start(); \
|
||||||
VAR = VARTYPE()
|
VAR = VARTYPE()
|
||||||
@ -65,7 +65,7 @@ using namespace libtorrent;
|
|||||||
static QString prev_hash; \
|
static QString prev_hash; \
|
||||||
static QElapsedTimer cacheTimer; \
|
static QElapsedTimer cacheTimer; \
|
||||||
if (prev_hash == HASH && !cacheTimer.hasExpired(DUR)) \
|
if (prev_hash == HASH && !cacheTimer.hasExpired(DUR)) \
|
||||||
return json::toJson(VAR); \
|
return json::toJson(VAR); \
|
||||||
prev_hash = HASH; \
|
prev_hash = HASH; \
|
||||||
cacheTimer.start(); \
|
cacheTimer.start(); \
|
||||||
VAR = VARTYPE()
|
VAR = VARTYPE()
|
||||||
@ -157,26 +157,26 @@ public:
|
|||||||
switch (type_) {
|
switch (type_) {
|
||||||
case QVariant::Int:
|
case QVariant::Int:
|
||||||
return greaterThan_ ? torrent1.toMap().value(key_).toInt() > torrent2.toMap().value(key_).toInt()
|
return greaterThan_ ? torrent1.toMap().value(key_).toInt() > torrent2.toMap().value(key_).toInt()
|
||||||
: torrent1.toMap().value(key_).toInt() < torrent2.toMap().value(key_).toInt();
|
: torrent1.toMap().value(key_).toInt() < torrent2.toMap().value(key_).toInt();
|
||||||
case QVariant::LongLong:
|
case QVariant::LongLong:
|
||||||
return greaterThan_ ? torrent1.toMap().value(key_).toLongLong() > torrent2.toMap().value(key_).toLongLong()
|
return greaterThan_ ? torrent1.toMap().value(key_).toLongLong() > torrent2.toMap().value(key_).toLongLong()
|
||||||
: torrent1.toMap().value(key_).toLongLong() < torrent2.toMap().value(key_).toLongLong();
|
: torrent1.toMap().value(key_).toLongLong() < torrent2.toMap().value(key_).toLongLong();
|
||||||
case QVariant::ULongLong:
|
case QVariant::ULongLong:
|
||||||
return greaterThan_ ? torrent1.toMap().value(key_).toULongLong() > torrent2.toMap().value(key_).toULongLong()
|
return greaterThan_ ? torrent1.toMap().value(key_).toULongLong() > torrent2.toMap().value(key_).toULongLong()
|
||||||
: torrent1.toMap().value(key_).toULongLong() < torrent2.toMap().value(key_).toULongLong();
|
: torrent1.toMap().value(key_).toULongLong() < torrent2.toMap().value(key_).toULongLong();
|
||||||
case QMetaType::Float:
|
case QMetaType::Float:
|
||||||
return greaterThan_ ? torrent1.toMap().value(key_).toFloat() > torrent2.toMap().value(key_).toFloat()
|
return greaterThan_ ? torrent1.toMap().value(key_).toFloat() > torrent2.toMap().value(key_).toFloat()
|
||||||
: torrent1.toMap().value(key_).toFloat() < torrent2.toMap().value(key_).toFloat();
|
: torrent1.toMap().value(key_).toFloat() < torrent2.toMap().value(key_).toFloat();
|
||||||
case QVariant::Double:
|
case QVariant::Double:
|
||||||
return greaterThan_ ? torrent1.toMap().value(key_).toDouble() > torrent2.toMap().value(key_).toDouble()
|
return greaterThan_ ? torrent1.toMap().value(key_).toDouble() > torrent2.toMap().value(key_).toDouble()
|
||||||
: torrent1.toMap().value(key_).toDouble() < torrent2.toMap().value(key_).toDouble();
|
: torrent1.toMap().value(key_).toDouble() < torrent2.toMap().value(key_).toDouble();
|
||||||
default:
|
default:
|
||||||
return greaterThan_ ? torrent1.toMap().value(key_).toString() > torrent2.toMap().value(key_).toString()
|
return greaterThan_ ? torrent1.toMap().value(key_).toString() > torrent2.toMap().value(key_).toString()
|
||||||
: torrent1.toMap().value(key_).toString() < torrent2.toMap().value(key_).toString();
|
: torrent1.toMap().value(key_).toString() < torrent2.toMap().value(key_).toString();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return greaterThan_ ? torrent1.toMap().value(key_) > torrent2.toMap().value(key_)
|
return greaterThan_ ? torrent1.toMap().value(key_) > torrent2.toMap().value(key_)
|
||||||
: torrent1.toMap().value(key_) < torrent2.toMap().value(key_);
|
: torrent1.toMap().value(key_) < torrent2.toMap().value(key_);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ static QVariantMap toMap(const QTorrentHandle& h)
|
|||||||
* - "state": Torrent state
|
* - "state": Torrent state
|
||||||
*/
|
*/
|
||||||
QByteArray btjson::getTorrents(QString filter, QString label,
|
QByteArray btjson::getTorrents(QString filter, QString label,
|
||||||
QString sortedColumn, bool reverse, int limit, int offset)
|
QString sortedColumn, bool reverse, int limit, int offset)
|
||||||
{
|
{
|
||||||
QVariantList torrent_list;
|
QVariantList torrent_list;
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ QByteArray btjson::getTorrents(QString filter, QString label,
|
|||||||
std::vector<torrent_handle>::const_iterator end = torrents.end();
|
std::vector<torrent_handle>::const_iterator end = torrents.end();
|
||||||
|
|
||||||
QTorrentFilter torrentFilter(filter, label);
|
QTorrentFilter torrentFilter(filter, label);
|
||||||
for( ; it != end; ++it) {
|
for(; it != end; ++it) {
|
||||||
QTorrentHandle torrent = QTorrentHandle(*it);
|
QTorrentHandle torrent = QTorrentHandle(*it);
|
||||||
|
|
||||||
if (torrentFilter.apply(torrent))
|
if (torrentFilter.apply(torrent))
|
||||||
@ -294,8 +294,9 @@ QByteArray btjson::getTrackersForTorrent(const QString& hash)
|
|||||||
tracker_dict[KEY_TRACKER_URL] = tracker_url;
|
tracker_dict[KEY_TRACKER_URL] = tracker_url;
|
||||||
const TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url));
|
const TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url));
|
||||||
QString status;
|
QString status;
|
||||||
if (it->verified)
|
if (it->verified) {
|
||||||
status = tr("Working");
|
status = tr("Working");
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if (it->updating && it->fails == 0)
|
if (it->updating && it->fails == 0)
|
||||||
status = tr("Updating...");
|
status = tr("Updating...");
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<ul class="filterList">
|
<ul class="filterList">
|
||||||
<li id="all_filter"><a href="#" onclick="setFilter('all');"><img src="images/skin/filterall.png"/>_(All)</a></li>
|
<li id="all_filter"><a href="#" onclick="setFilter('all');"><img src="images/skin/filterall.png"/>_(All)</a></li>
|
||||||
<li id="downloading_filter"><a href="#" onclick="setFilter('downloading');"><img src="images/skin/downloading.png"/>_(Downloading)</a></li>
|
<li id="downloading_filter"><a href="#" onclick="setFilter('downloading');"><img src="images/skin/downloading.png"/>_(Downloading)</a></li>
|
||||||
<li id="completed_filter"><a href="#" onclick="setFilter('completed');"><img src="images/skin/uploading.png"/>_(Completed)</a></li>
|
<li id="completed_filter"><a href="#" onclick="setFilter('completed');"><img src="images/skin/uploading.png"/>_(Completed)</a></li>
|
||||||
<li id="paused_filter"><a href="#" onclick="setFilter('paused');"><img src="images/skin/paused.png"/>_(Paused)</a></li>
|
<li id="paused_filter"><a href="#" onclick="setFilter('paused');"><img src="images/skin/paused.png"/>_(Paused)</a></li>
|
||||||
<li id="active_filter"><a href="#" onclick="setFilter('active');"><img src="images/skin/filteractive.png"/>_(Active)</a></li>
|
<li id="active_filter"><a href="#" onclick="setFilter('active');"><img src="images/skin/filteractive.png"/>_(Active)</a></li>
|
||||||
<li id="inactive_filter"><a href="#" onclick="setFilter('inactive');"><img src="images/skin/filterinactive.png"/>_(Inactive)</a></li>
|
<li id="inactive_filter"><a href="#" onclick="setFilter('inactive');"><img src="images/skin/filterinactive.png"/>_(Inactive)</a></li>
|
||||||
</ul>
|
</ul>
|
Loading…
x
Reference in New Issue
Block a user