mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-02 09:55:55 +00:00
- Removed useless mutex in GUI
- started to optimize headers includes for compilation speed
This commit is contained in:
parent
c8c53e2812
commit
0db60065c0
3
TODO
3
TODO
@ -47,6 +47,9 @@
|
|||||||
- .ico support?
|
- .ico support?
|
||||||
- display debug when fastresume data is rejected
|
- display debug when fastresume data is rejected
|
||||||
- Download/Finished lists cleanup
|
- Download/Finished lists cleanup
|
||||||
|
- Use valgrind to detect memory leaks
|
||||||
|
- optimize includes for compilation speed
|
||||||
|
- Move transfer lists refreshers to threads
|
||||||
- Wait for some bug fixes in libtorrent :
|
- Wait for some bug fixes in libtorrent :
|
||||||
- upload/download limit per torrent
|
- upload/download limit per torrent
|
||||||
- ipfilter crash
|
- ipfilter crash
|
||||||
|
@ -22,9 +22,13 @@
|
|||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "GUI.h"
|
#include "GUI.h"
|
||||||
#include "properties_imp.h"
|
#include "properties_imp.h"
|
||||||
|
#include "bittorrent.h"
|
||||||
#include "allocationDlg.h"
|
#include "allocationDlg.h"
|
||||||
|
#include "FinishedListDelegate.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession){
|
FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession){
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
@ -115,73 +119,6 @@ void FinishedTorrents::setRowColor(int row, QString color){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FinishedTorrents::sortFinishedList(int index){
|
|
||||||
static Qt::SortOrder sortOrder = Qt::AscendingOrder;
|
|
||||||
if(finishedList->header()->sortIndicatorSection() == index){
|
|
||||||
if(sortOrder == Qt::AscendingOrder){
|
|
||||||
sortOrder = Qt::DescendingOrder;
|
|
||||||
}else{
|
|
||||||
sortOrder = Qt::AscendingOrder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finishedList->header()->setSortIndicator(index, sortOrder);
|
|
||||||
switch(index){
|
|
||||||
case F_SIZE:
|
|
||||||
case F_UPSPEED:
|
|
||||||
case F_PROGRESS:
|
|
||||||
sortFinishedListFloat(index, sortOrder);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sortFinishedListString(index, sortOrder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::sortFinishedListFloat(int index, Qt::SortOrder sortOrder){
|
|
||||||
QList<QPair<int, double> > lines;
|
|
||||||
// insertion sorting
|
|
||||||
unsigned int nbRows = finishedListModel->rowCount();
|
|
||||||
for(unsigned int i=0; i<nbRows; ++i){
|
|
||||||
misc::insertSort(lines, QPair<int,double>(i, finishedListModel->data(finishedListModel->index(i, index)).toDouble()), sortOrder);
|
|
||||||
}
|
|
||||||
// Insert items in new model, in correct order
|
|
||||||
unsigned int nbRows_old = lines.size();
|
|
||||||
for(unsigned int row=0; row<nbRows_old; ++row){
|
|
||||||
finishedListModel->insertRow(finishedListModel->rowCount());
|
|
||||||
unsigned int sourceRow = lines[row].first;
|
|
||||||
unsigned int nbColumns = finishedListModel->columnCount();
|
|
||||||
for(unsigned int col=0; col<nbColumns; ++col){
|
|
||||||
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col)));
|
|
||||||
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col), Qt::DecorationRole), Qt::DecorationRole);
|
|
||||||
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col), Qt::TextColorRole), Qt::TextColorRole);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Remove old rows
|
|
||||||
finishedListModel->removeRows(0, nbRows_old);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishedTorrents::sortFinishedListString(int index, Qt::SortOrder sortOrder){
|
|
||||||
QList<QPair<int, QString> > lines;
|
|
||||||
// Insertion sorting
|
|
||||||
unsigned int nbRows = finishedListModel->rowCount();
|
|
||||||
for(unsigned int i=0; i<nbRows; ++i){
|
|
||||||
misc::insertSortString(lines, QPair<int, QString>(i, finishedListModel->data(finishedListModel->index(i, index)).toString()), sortOrder);
|
|
||||||
}
|
|
||||||
// Insert items in new model, in correct order
|
|
||||||
unsigned int nbRows_old = lines.size();
|
|
||||||
for(unsigned int row=0; row<nbRows_old; ++row){
|
|
||||||
finishedListModel->insertRow(finishedListModel->rowCount());
|
|
||||||
unsigned int sourceRow = lines[row].first;
|
|
||||||
unsigned int nbColumns = finishedListModel->columnCount();
|
|
||||||
for(unsigned int col=0; col<nbColumns; ++col){
|
|
||||||
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col)));
|
|
||||||
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col), Qt::DecorationRole), Qt::DecorationRole);
|
|
||||||
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col), Qt::TextColorRole), Qt::TextColorRole);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Remove old rows
|
|
||||||
finishedListModel->removeRows(0, nbRows_old);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load columns width in a file that were saved previously
|
// Load columns width in a file that were saved previously
|
||||||
// (finished list)
|
// (finished list)
|
||||||
bool FinishedTorrents::loadColWidthFinishedList(){
|
bool FinishedTorrents::loadColWidthFinishedList(){
|
||||||
@ -350,3 +287,74 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint& pos){
|
|||||||
// XXX: why mapToGlobal() is not enough?
|
// XXX: why mapToGlobal() is not enough?
|
||||||
myFinishedListMenu.exec(mapToGlobal(pos)+QPoint(10,55));
|
myFinishedListMenu.exec(mapToGlobal(pos)+QPoint(10,55));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sorting functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
void FinishedTorrents::sortFinishedList(int index){
|
||||||
|
static Qt::SortOrder sortOrder = Qt::AscendingOrder;
|
||||||
|
if(finishedList->header()->sortIndicatorSection() == index){
|
||||||
|
if(sortOrder == Qt::AscendingOrder){
|
||||||
|
sortOrder = Qt::DescendingOrder;
|
||||||
|
}else{
|
||||||
|
sortOrder = Qt::AscendingOrder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finishedList->header()->setSortIndicator(index, sortOrder);
|
||||||
|
switch(index){
|
||||||
|
case F_SIZE:
|
||||||
|
case F_UPSPEED:
|
||||||
|
case F_PROGRESS:
|
||||||
|
sortFinishedListFloat(index, sortOrder);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sortFinishedListString(index, sortOrder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FinishedTorrents::sortFinishedListFloat(int index, Qt::SortOrder sortOrder){
|
||||||
|
QList<QPair<int, double> > lines;
|
||||||
|
// insertion sorting
|
||||||
|
unsigned int nbRows = finishedListModel->rowCount();
|
||||||
|
for(unsigned int i=0; i<nbRows; ++i){
|
||||||
|
misc::insertSort(lines, QPair<int,double>(i, finishedListModel->data(finishedListModel->index(i, index)).toDouble()), sortOrder);
|
||||||
|
}
|
||||||
|
// Insert items in new model, in correct order
|
||||||
|
unsigned int nbRows_old = lines.size();
|
||||||
|
for(unsigned int row=0; row<nbRows_old; ++row){
|
||||||
|
finishedListModel->insertRow(finishedListModel->rowCount());
|
||||||
|
unsigned int sourceRow = lines[row].first;
|
||||||
|
unsigned int nbColumns = finishedListModel->columnCount();
|
||||||
|
for(unsigned int col=0; col<nbColumns; ++col){
|
||||||
|
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col)));
|
||||||
|
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col), Qt::DecorationRole), Qt::DecorationRole);
|
||||||
|
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col), Qt::TextColorRole), Qt::TextColorRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Remove old rows
|
||||||
|
finishedListModel->removeRows(0, nbRows_old);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FinishedTorrents::sortFinishedListString(int index, Qt::SortOrder sortOrder){
|
||||||
|
QList<QPair<int, QString> > lines;
|
||||||
|
// Insertion sorting
|
||||||
|
unsigned int nbRows = finishedListModel->rowCount();
|
||||||
|
for(unsigned int i=0; i<nbRows; ++i){
|
||||||
|
misc::insertSortString(lines, QPair<int, QString>(i, finishedListModel->data(finishedListModel->index(i, index)).toString()), sortOrder);
|
||||||
|
}
|
||||||
|
// Insert items in new model, in correct order
|
||||||
|
unsigned int nbRows_old = lines.size();
|
||||||
|
for(unsigned int row=0; row<nbRows_old; ++row){
|
||||||
|
finishedListModel->insertRow(finishedListModel->rowCount());
|
||||||
|
unsigned int sourceRow = lines[row].first;
|
||||||
|
unsigned int nbColumns = finishedListModel->columnCount();
|
||||||
|
for(unsigned int col=0; col<nbColumns; ++col){
|
||||||
|
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col)));
|
||||||
|
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col), Qt::DecorationRole), Qt::DecorationRole);
|
||||||
|
finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col), Qt::TextColorRole), Qt::TextColorRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Remove old rows
|
||||||
|
finishedListModel->removeRows(0, nbRows_old);
|
||||||
|
}
|
||||||
|
@ -23,9 +23,13 @@
|
|||||||
#define SEEDING_H
|
#define SEEDING_H
|
||||||
|
|
||||||
#include "ui_seeding.h"
|
#include "ui_seeding.h"
|
||||||
#include "bittorrent.h"
|
#include <libtorrent/torrent_handle.hpp>
|
||||||
#include "FinishedListDelegate.h"
|
|
||||||
#include <QStandardItemModel>
|
class QStandardItemModel;
|
||||||
|
class bittorrent;
|
||||||
|
class FinishedListDelegate;
|
||||||
|
|
||||||
|
using namespace libtorrent;
|
||||||
|
|
||||||
class FinishedTorrents : public QWidget, public Ui::seeding{
|
class FinishedTorrents : public QWidget, public Ui::seeding{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include <QTcpServer>
|
#include <QTcpServer>
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QMutexLocker>
|
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
|
||||||
#include <libtorrent/extensions/metadata_transfer.hpp>
|
#include <libtorrent/extensions/metadata_transfer.hpp>
|
||||||
@ -45,6 +44,7 @@
|
|||||||
#include "rss_imp.h"
|
#include "rss_imp.h"
|
||||||
#include "FinishedTorrents.h"
|
#include "FinishedTorrents.h"
|
||||||
#include "allocationDlg.h"
|
#include "allocationDlg.h"
|
||||||
|
#include "bittorrent.h"
|
||||||
|
|
||||||
/*****************************************************
|
/*****************************************************
|
||||||
* *
|
* *
|
||||||
@ -542,7 +542,6 @@ void GUI::sortProgressColumnDelayed() {
|
|||||||
void GUI::updateDlList(bool force){
|
void GUI::updateDlList(bool force){
|
||||||
char tmp[MAX_CHAR_TMP];
|
char tmp[MAX_CHAR_TMP];
|
||||||
char tmp2[MAX_CHAR_TMP];
|
char tmp2[MAX_CHAR_TMP];
|
||||||
QMutexLocker lock(&DLListAccess);
|
|
||||||
// update global informations
|
// update global informations
|
||||||
snprintf(tmp, MAX_CHAR_TMP, "%.1f", BTSession->getPayloadUploadRate()/1024.);
|
snprintf(tmp, MAX_CHAR_TMP, "%.1f", BTSession->getPayloadUploadRate()/1024.);
|
||||||
snprintf(tmp2, MAX_CHAR_TMP, "%.1f", BTSession->getPayloadDownloadRate()/1024.);
|
snprintf(tmp2, MAX_CHAR_TMP, "%.1f", BTSession->getPayloadDownloadRate()/1024.);
|
||||||
@ -726,7 +725,6 @@ void GUI::sortDownloadListString(int index, Qt::SortOrder sortOrder){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GUI::sortDownloadList(int index, Qt::SortOrder startSortOrder, bool fromLoadColWidth){
|
void GUI::sortDownloadList(int index, Qt::SortOrder startSortOrder, bool fromLoadColWidth){
|
||||||
QMutexLocker lock(&DLListAccess);
|
|
||||||
qDebug("Called sort download list");
|
qDebug("Called sort download list");
|
||||||
static Qt::SortOrder sortOrder = startSortOrder;
|
static Qt::SortOrder sortOrder = startSortOrder;
|
||||||
if(!fromLoadColWidth && downloadList->header()->sortIndicatorSection() == index){
|
if(!fromLoadColWidth && downloadList->header()->sortIndicatorSection() == index){
|
||||||
|
12
src/GUI.h
12
src/GUI.h
@ -25,23 +25,14 @@
|
|||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
#include <QMutex>
|
|
||||||
|
|
||||||
#include <libtorrent/entry.hpp>
|
|
||||||
#include <libtorrent/bencode.hpp>
|
|
||||||
#include <libtorrent/session.hpp>
|
|
||||||
#include <libtorrent/fingerprint.hpp>
|
|
||||||
#include <libtorrent/session_settings.hpp>
|
|
||||||
#include <libtorrent/identify_client.hpp>
|
|
||||||
#include <libtorrent/alert_types.hpp>
|
|
||||||
|
|
||||||
#include "ui_MainWindow.h"
|
#include "ui_MainWindow.h"
|
||||||
#include "options_imp.h"
|
#include "options_imp.h"
|
||||||
#include "about_imp.h"
|
#include "about_imp.h"
|
||||||
#include "previewSelect.h"
|
#include "previewSelect.h"
|
||||||
#include "trackerLogin.h"
|
#include "trackerLogin.h"
|
||||||
#include "bittorrent.h"
|
|
||||||
|
|
||||||
|
class bittorrent;
|
||||||
class createtorrent;
|
class createtorrent;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
class FinishedTorrents;
|
class FinishedTorrents;
|
||||||
@ -86,7 +77,6 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
|||||||
bool force_exit;
|
bool force_exit;
|
||||||
bool delayedSorting;
|
bool delayedSorting;
|
||||||
Qt::SortOrder delayedSortingOrder;
|
Qt::SortOrder delayedSortingOrder;
|
||||||
QMutex DLListAccess;
|
|
||||||
// Keyboard shortcuts
|
// Keyboard shortcuts
|
||||||
QShortcut *createShortcut;
|
QShortcut *createShortcut;
|
||||||
QShortcut *openShortcut;
|
QShortcut *openShortcut;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
#include <QMessageBox>
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
// display a right-click menu
|
// display a right-click menu
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include "ui_rss.h"
|
#include "ui_rss.h"
|
||||||
#include "rss.h"
|
#include "rss.h"
|
||||||
#include "GUI.h"
|
|
||||||
|
|
||||||
#define DESCRIPTION_CHILD 0
|
#define DESCRIPTION_CHILD 0
|
||||||
#define URL_CHILD 1
|
#define URL_CHILD 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user