mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-06 11:54:18 +00:00
Performance improvement on ARM
This commit is contained in:
parent
dfcdb18b41
commit
5c8dd9f0fb
@ -153,7 +153,7 @@ public:
|
|||||||
// use Binary prefix standards from IEC 60027-2
|
// use Binary prefix standards from IEC 60027-2
|
||||||
// see http://en.wikipedia.org/wiki/Kilobyte
|
// see http://en.wikipedia.org/wiki/Kilobyte
|
||||||
// value must be given in bytes
|
// value must be given in bytes
|
||||||
static QString friendlyUnit(double val);
|
static QString friendlyUnit(qreal val);
|
||||||
static bool isPreviewable(QString extension);
|
static bool isPreviewable(QString extension);
|
||||||
static QString branchPath(QString file_path, bool uses_slashes=false);
|
static QString branchPath(QString file_path, bool uses_slashes=false);
|
||||||
static QString fileName(QString file_path);
|
static QString fileName(QString file_path);
|
||||||
|
@ -467,7 +467,7 @@ void options_imp::setStyle(QString style) {
|
|||||||
|
|
||||||
void options_imp::loadOptions(){
|
void options_imp::loadOptions(){
|
||||||
int intValue;
|
int intValue;
|
||||||
float floatValue;
|
qreal floatValue;
|
||||||
QString strValue;
|
QString strValue;
|
||||||
// General preferences
|
// General preferences
|
||||||
const Preferences pref;
|
const Preferences pref;
|
||||||
@ -754,7 +754,7 @@ int options_imp::getDHTPort() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return Share ratio
|
// Return Share ratio
|
||||||
float options_imp::getMaxRatio() const{
|
qreal options_imp::getMaxRatio() const{
|
||||||
if(checkMaxRatio->isChecked()){
|
if(checkMaxRatio->isChecked()){
|
||||||
return spinMaxRatio->value();
|
return spinMaxRatio->value();
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ private:
|
|||||||
int getDHTPort() const;
|
int getDHTPort() const;
|
||||||
bool isLSDEnabled() const;
|
bool isLSDEnabled() const;
|
||||||
int getEncryptionSetting() const;
|
int getEncryptionSetting() const;
|
||||||
float getMaxRatio() const;
|
qreal getMaxRatio() const;
|
||||||
// Proxy options
|
// Proxy options
|
||||||
bool isProxyEnabled() const;
|
bool isProxyEnabled() const;
|
||||||
bool isProxyAuthEnabled() const;
|
bool isProxyAuthEnabled() const;
|
||||||
|
@ -546,11 +546,11 @@ public:
|
|||||||
setValue(QString::fromUtf8("Preferences/Bittorrent/Encryption"), val);
|
setValue(QString::fromUtf8("Preferences/Bittorrent/Encryption"), val);
|
||||||
}
|
}
|
||||||
|
|
||||||
float getMaxRatio() const {
|
qreal getMaxRatio() const {
|
||||||
return value(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), -1).toDouble();
|
return value(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), -1).toDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMaxRatio(float ratio) {
|
void setMaxRatio(qreal ratio) {
|
||||||
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), ratio);
|
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ class PreviewListDelegate: public QItemDelegate {
|
|||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
|
||||||
break;
|
break;
|
||||||
case PreviewSelect::PROGRESS:{
|
case PreviewSelect::PROGRESS:{
|
||||||
float progress = index.data().toDouble()*100.;
|
qreal progress = index.data().toDouble()*100.;
|
||||||
QStyleOptionProgressBarV2 newopt;
|
QStyleOptionProgressBarV2 newopt;
|
||||||
newopt.rect = opt.rect;
|
newopt.rect = opt.rect;
|
||||||
newopt.text = QString(QByteArray::number(progress, 'f', 1))+QString::fromUtf8("%");
|
newopt.text = QString(QByteArray::number(progress, 'f', 1))+QString::fromUtf8("%");
|
||||||
|
@ -57,14 +57,14 @@ public:
|
|||||||
case DOWN_SPEED:
|
case DOWN_SPEED:
|
||||||
case UP_SPEED:{
|
case UP_SPEED:{
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
double speed = index.data().toDouble();
|
qreal speed = index.data().toDouble();
|
||||||
if (speed > 0.0)
|
if (speed > 0.0)
|
||||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (i.e. per second)"));
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (i.e. per second)"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PROGRESS:{
|
case PROGRESS:{
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
double progress = index.data().toDouble();
|
qreal progress = index.data().toDouble();
|
||||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(progress*100., 'f', 1)+"%");
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(progress*100., 'f', 1)+"%");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setAvailability(const std::vector<int>& avail) {
|
void setAvailability(const std::vector<int>& avail) {
|
||||||
double average = 0;
|
qreal average = 0;
|
||||||
if(avail.empty()) {
|
if(avail.empty()) {
|
||||||
// Empty bar
|
// Empty bar
|
||||||
QPixmap pix = QPixmap(1, 1);
|
QPixmap pix = QPixmap(1, 1);
|
||||||
@ -114,10 +114,10 @@ protected:
|
|||||||
painter.drawPixmap(rect(), pixmap);
|
painter.drawPixmap(rect(), pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor getPieceColor(int avail, double average) {
|
QColor getPieceColor(int avail, qreal average) {
|
||||||
if(!avail) return Qt::white;
|
if(!avail) return Qt::white;
|
||||||
//qDebug("avail: %d/%d", avail, max_avail);
|
//qDebug("avail: %d/%d", avail, max_avail);
|
||||||
double fraction = 100.*average/avail;
|
qreal fraction = 100.*average/avail;
|
||||||
if(fraction < 100)
|
if(fraction < 100)
|
||||||
fraction *= 0.8;
|
fraction *= 0.8;
|
||||||
else
|
else
|
||||||
|
@ -348,7 +348,7 @@ void PropertiesWidget::loadDynamicData() {
|
|||||||
// Update next announce time
|
// Update next announce time
|
||||||
reannounce_lbl->setText(h.next_announce());
|
reannounce_lbl->setText(h.next_announce());
|
||||||
// Update ratio info
|
// Update ratio info
|
||||||
const double ratio = QBtSession::instance()->getRealRatio(h.hash());
|
const qreal ratio = QBtSession::instance()->getRealRatio(h.hash());
|
||||||
if(ratio > 100.)
|
if(ratio > 100.)
|
||||||
shareRatio->setText(QString::fromUtf8("∞"));
|
shareRatio->setText(QString::fromUtf8("∞"));
|
||||||
else
|
else
|
||||||
@ -370,7 +370,7 @@ void PropertiesWidget::loadDynamicData() {
|
|||||||
showPiecesAvailability(false);
|
showPiecesAvailability(false);
|
||||||
}
|
}
|
||||||
// Progress
|
// Progress
|
||||||
float progress = h.progress()*100.;
|
qreal progress = h.progress()*100.;
|
||||||
if(progress > 99.94 && progress < 100.)
|
if(progress > 99.94 && progress < 100.)
|
||||||
progress = 99.9;
|
progress = 99.9;
|
||||||
progress_lbl->setText(QString::number(progress, 'f', 1)+"%");
|
progress_lbl->setText(QString::number(progress, 'f', 1)+"%");
|
||||||
|
@ -88,12 +88,12 @@ qlonglong QTorrentHandle::next_announce_s() const {
|
|||||||
return torrent_handle::status().next_announce.total_seconds();
|
return torrent_handle::status().next_announce.total_seconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
float QTorrentHandle::progress() const {
|
qreal QTorrentHandle::progress() const {
|
||||||
if(!torrent_handle::status().total_wanted)
|
if(!torrent_handle::status().total_wanted)
|
||||||
return 0.;
|
return 0.;
|
||||||
if (torrent_handle::status().total_wanted_done == torrent_handle::status().total_wanted)
|
if (torrent_handle::status().total_wanted_done == torrent_handle::status().total_wanted)
|
||||||
return 1.;
|
return 1.;
|
||||||
float progress = (float)torrent_handle::status().total_wanted_done/(float)torrent_handle::status().total_wanted;
|
qreal progress = (float)torrent_handle::status().total_wanted_done/(float)torrent_handle::status().total_wanted;
|
||||||
Q_ASSERT(progress >= 0. && progress <= 1.);
|
Q_ASSERT(progress >= 0. && progress <= 1.);
|
||||||
return progress;
|
return progress;
|
||||||
}
|
}
|
||||||
@ -159,11 +159,11 @@ size_type QTorrentHandle::total_wanted() const {
|
|||||||
return torrent_handle::status().total_wanted;
|
return torrent_handle::status().total_wanted;
|
||||||
}
|
}
|
||||||
|
|
||||||
float QTorrentHandle::download_payload_rate() const {
|
qreal QTorrentHandle::download_payload_rate() const {
|
||||||
return torrent_handle::status().download_payload_rate;
|
return torrent_handle::status().download_payload_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
float QTorrentHandle::upload_payload_rate() const {
|
qreal QTorrentHandle::upload_payload_rate() const {
|
||||||
return torrent_handle::status().upload_payload_rate;
|
return torrent_handle::status().upload_payload_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
//
|
//
|
||||||
QString hash() const;
|
QString hash() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
float progress() const;
|
qreal progress() const;
|
||||||
libtorrent::bitfield pieces() const;
|
libtorrent::bitfield pieces() const;
|
||||||
QString current_tracker() const;
|
QString current_tracker() const;
|
||||||
bool is_paused() const;
|
bool is_paused() const;
|
||||||
@ -66,8 +66,8 @@ public:
|
|||||||
int num_pieces() const;
|
int num_pieces() const;
|
||||||
libtorrent::size_type total_wanted_done() const;
|
libtorrent::size_type total_wanted_done() const;
|
||||||
libtorrent::size_type total_wanted() const;
|
libtorrent::size_type total_wanted() const;
|
||||||
float download_payload_rate() const;
|
qreal download_payload_rate() const;
|
||||||
float upload_payload_rate() const;
|
qreal upload_payload_rate() const;
|
||||||
int num_connections() const;
|
int num_connections() const;
|
||||||
int connections_limit() const;
|
int connections_limit() const;
|
||||||
int num_peers() const;
|
int num_peers() const;
|
||||||
|
@ -43,7 +43,7 @@ class SpeedSample {
|
|||||||
public:
|
public:
|
||||||
SpeedSample(){}
|
SpeedSample(){}
|
||||||
void addSample(int s);
|
void addSample(int s);
|
||||||
float average() const;
|
qreal average() const;
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -83,7 +83,7 @@ void SpeedSample::addSample(int s)
|
|||||||
m_speedSamples.removeFirst();
|
m_speedSamples.removeFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpeedSample::average() const
|
qreal SpeedSample::average() const
|
||||||
{
|
{
|
||||||
if(m_speedSamples.empty()) return 0;
|
if(m_speedSamples.empty()) return 0;
|
||||||
qlonglong sum = 0;
|
qlonglong sum = 0;
|
||||||
@ -114,7 +114,7 @@ qlonglong TorrentSpeedMonitor::getETA(const QString &hash) const
|
|||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
QTorrentHandle h = m_session->getTorrentHandle(hash);
|
QTorrentHandle h = m_session->getTorrentHandle(hash);
|
||||||
if(h.is_paused() || !m_samples.contains(hash)) return -1;
|
if(h.is_paused() || !m_samples.contains(hash)) return -1;
|
||||||
const float speed_average = m_samples.value(hash).average();
|
const qreal speed_average = m_samples.value(hash).average();
|
||||||
if(speed_average == 0) return -1;
|
if(speed_average == 0) return -1;
|
||||||
return (h.total_wanted() - h.total_done()) / speed_average;
|
return (h.total_wanted() - h.total_done()) / speed_average;
|
||||||
}
|
}
|
||||||
|
@ -224,15 +224,15 @@ QTreeWidgetItem* engineSelectDlg::findItemWithID(QString id){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool engineSelectDlg::isUpdateNeeded(QString plugin_name, float new_version) const {
|
bool engineSelectDlg::isUpdateNeeded(QString plugin_name, qreal new_version) const {
|
||||||
float old_version = SearchEngine::getPluginVersion(misc::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py");
|
qreal old_version = SearchEngine::getPluginVersion(misc::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py");
|
||||||
qDebug("IsUpdate needed? tobeinstalled: %.2f, alreadyinstalled: %.2f", new_version, old_version);
|
qDebug("IsUpdate needed? tobeinstalled: %.2f, alreadyinstalled: %.2f", new_version, old_version);
|
||||||
return (new_version > old_version);
|
return (new_version > old_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
|
void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
|
||||||
qDebug("Asked to install plugin at %s", qPrintable(path));
|
qDebug("Asked to install plugin at %s", qPrintable(path));
|
||||||
float new_version = SearchEngine::getPluginVersion(path);
|
qreal new_version = SearchEngine::getPluginVersion(path);
|
||||||
qDebug("Version to be installed: %.2f", new_version);
|
qDebug("Version to be installed: %.2f", new_version);
|
||||||
if(!isUpdateNeeded(plugin_name, new_version)) {
|
if(!isUpdateNeeded(plugin_name, new_version)) {
|
||||||
qDebug("Apparently update is not needed, we have a more recent version");
|
qDebug("Apparently update is not needed, we have a more recent version");
|
||||||
@ -372,7 +372,7 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) {
|
|||||||
if(!plugin_name.endsWith(":")) continue;
|
if(!plugin_name.endsWith(":")) continue;
|
||||||
plugin_name.chop(1); // remove trailing ':'
|
plugin_name.chop(1); // remove trailing ':'
|
||||||
bool ok;
|
bool ok;
|
||||||
float version = list.last().toFloat(&ok);
|
qreal version = list.last().toFloat(&ok);
|
||||||
qDebug("read line %s: %.2f", qPrintable(plugin_name), version);
|
qDebug("read line %s: %.2f", qPrintable(plugin_name), version);
|
||||||
if(!ok) continue;
|
if(!ok) continue;
|
||||||
file_correct = true;
|
file_correct = true;
|
||||||
|
@ -52,7 +52,7 @@ class engineSelectDlg : public QDialog, public Ui::engineSelect{
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool parseVersionsFile(QString versions_file);
|
bool parseVersionsFile(QString versions_file);
|
||||||
bool isUpdateNeeded(QString plugin_name, float new_version) const;
|
bool isUpdateNeeded(QString plugin_name, qreal new_version) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void enginesChanged();
|
void enginesChanged();
|
||||||
|
@ -188,7 +188,7 @@ SearchEngine::~SearchEngine(){
|
|||||||
searchProcess->waitForFinished();
|
searchProcess->waitForFinished();
|
||||||
foreach(QProcess *downloader, downloaders) {
|
foreach(QProcess *downloader, downloaders) {
|
||||||
// Make sure we disconnect the SIGNAL/SLOT first
|
// Make sure we disconnect the SIGNAL/SLOT first
|
||||||
// To avoid double free
|
// To avoid qreal free
|
||||||
downloader->disconnect();
|
downloader->disconnect();
|
||||||
downloader->kill();
|
downloader->kill();
|
||||||
downloader->waitForFinished();
|
downloader->waitForFinished();
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
~SearchEngine();
|
~SearchEngine();
|
||||||
QString selectedCategory() const;
|
QString selectedCategory() const;
|
||||||
|
|
||||||
static float getPluginVersion(QString filePath) {
|
static qreal getPluginVersion(QString filePath) {
|
||||||
QFile plugin(filePath);
|
QFile plugin(filePath);
|
||||||
if(!plugin.exists()){
|
if(!plugin.exists()){
|
||||||
qDebug("%s plugin does not exist, returning 0.0", qPrintable(filePath));
|
qDebug("%s plugin does not exist, returning 0.0", qPrintable(filePath));
|
||||||
@ -69,7 +69,7 @@ public:
|
|||||||
if(!plugin.open(QIODevice::ReadOnly | QIODevice::Text)){
|
if(!plugin.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
float version = 0.0;
|
qreal version = 0.0;
|
||||||
while (!plugin.atEnd()){
|
while (!plugin.atEnd()){
|
||||||
QByteArray line = plugin.readLine();
|
QByteArray line = plugin.readLine();
|
||||||
if(line.startsWith("#VERSION: ")){
|
if(line.startsWith("#VERSION: ")){
|
||||||
|
@ -173,7 +173,7 @@ public:
|
|||||||
total_done = done;
|
total_done = done;
|
||||||
qulonglong size = getSize();
|
qulonglong size = getSize();
|
||||||
Q_ASSERT(total_done <= size);
|
Q_ASSERT(total_done <= size);
|
||||||
float progress;
|
qreal progress;
|
||||||
if(size > 0)
|
if(size > 0)
|
||||||
progress = total_done/(float)size;
|
progress = total_done/(float)size;
|
||||||
else
|
else
|
||||||
@ -188,7 +188,7 @@ public:
|
|||||||
return total_done;
|
return total_done;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getProgress() const {
|
qreal getProgress() const {
|
||||||
if(getPriority() == 0)
|
if(getPriority() == 0)
|
||||||
return 0.;
|
return 0.;
|
||||||
qulonglong size = getSize();
|
qulonglong size = getSize();
|
||||||
|
@ -355,7 +355,7 @@ QVariantMap EventManager::getPropGeneralInfo(QString hash) const {
|
|||||||
data["time_elapsed"] = elapsed_txt;
|
data["time_elapsed"] = elapsed_txt;
|
||||||
data["nb_connections"] = QVariant(QString::number(h.num_connections())+" ("+tr("%1 max", "e.g. 10 max").arg(QString::number(h.connections_limit()))+")");
|
data["nb_connections"] = QVariant(QString::number(h.num_connections())+" ("+tr("%1 max", "e.g. 10 max").arg(QString::number(h.connections_limit()))+")");
|
||||||
// Update ratio info
|
// Update ratio info
|
||||||
double ratio = QBtSession::instance()->getRealRatio(h.hash());
|
qreal ratio = QBtSession::instance()->getRealRatio(h.hash());
|
||||||
if(ratio > 100.)
|
if(ratio > 100.)
|
||||||
data["share_ratio"] = QString::fromUtf8("∞");
|
data["share_ratio"] = QString::fromUtf8("∞");
|
||||||
else
|
else
|
||||||
@ -451,7 +451,7 @@ void EventManager::modifiedTorrent(const QTorrentHandle& h)
|
|||||||
leechs += " ("+QString::number(h.num_incomplete())+")";
|
leechs += " ("+QString::number(h.num_incomplete())+")";
|
||||||
event["num_leechs"] = QVariant(leechs);
|
event["num_leechs"] = QVariant(leechs);
|
||||||
event["seed"] = QVariant(h.is_seed());
|
event["seed"] = QVariant(h.is_seed());
|
||||||
double ratio = QBtSession::instance()->getRealRatio(hash);
|
qreal ratio = QBtSession::instance()->getRealRatio(hash);
|
||||||
if(ratio > 100.)
|
if(ratio > 100.)
|
||||||
event["ratio"] = QString::fromUtf8("∞");
|
event["ratio"] = QString::fromUtf8("∞");
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user