Browse Source

Performance improvement on ARM

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
8238c13dc0
  1. 2
      src/misc.cpp
  2. 2
      src/properties/proplistdelegate.h
  3. 14
      src/qtlibtorrent/qbtsession.cpp
  4. 10
      src/qtlibtorrent/qbtsession.h
  5. 2
      src/transferlistdelegate.h

2
src/misc.cpp

@ -518,7 +518,7 @@ QString misc::cacheLocation() {
// 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
QString misc::friendlyUnit(double val) { QString misc::friendlyUnit(qreal val) {
if(val < 0) if(val < 0)
return tr("Unknown", "Unknown (size)"); return tr("Unknown", "Unknown (size)");
int i = 0; int i = 0;

2
src/properties/proplistdelegate.h

@ -75,7 +75,7 @@ public:
break; break;
case PROGRESS:{ case PROGRESS:{
QStyleOptionProgressBarV2 newopt; QStyleOptionProgressBarV2 newopt;
float progress = index.data().toDouble()*100.; qreal progress = index.data().toDouble()*100.;
newopt.rect = opt.rect; newopt.rect = opt.rect;
// We don't want to display 100% unless // We don't want to display 100% unless
// the torrent is really complete // the torrent is really complete

14
src/qtlibtorrent/qbtsession.cpp

@ -81,7 +81,7 @@ using namespace libtorrent;
QBtSession* QBtSession::m_instance = 0; QBtSession* QBtSession::m_instance = 0;
const int MAX_TRACKER_ERRORS = 2; const int MAX_TRACKER_ERRORS = 2;
const float MAX_RATIO = 100.; const qreal MAX_RATIO = 100.;
enum VersionType { NORMAL,ALPHA,BETA,RELEASE_CANDIDATE,DEVEL }; enum VersionType { NORMAL,ALPHA,BETA,RELEASE_CANDIDATE,DEVEL };
// Main constructor // Main constructor
@ -198,7 +198,7 @@ void QBtSession::processBigRatios() {
if(!h.is_valid()) continue; if(!h.is_valid()) continue;
if(h.is_seed()) { if(h.is_seed()) {
const QString hash = h.hash(); const QString hash = h.hash();
const float ratio = getRealRatio(hash); const qreal ratio = getRealRatio(hash);
qDebug("Ratio: %f (limit: %f)", ratio, ratio_limit); qDebug("Ratio: %f (limit: %f)", ratio, ratio_limit);
if(ratio <= MAX_RATIO && ratio >= ratio_limit) { if(ratio <= MAX_RATIO && ratio >= ratio_limit) {
if(high_ratio_action == REMOVE_ACTION) { if(high_ratio_action == REMOVE_ACTION) {
@ -1395,7 +1395,7 @@ bool QBtSession::enableDHT(bool b) {
return true; return true;
} }
float QBtSession::getRealRatio(QString hash) const{ qreal QBtSession::getRealRatio(QString hash) const{
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
if(!h.is_valid()) { if(!h.is_valid()) {
return 0.; return 0.;
@ -1407,7 +1407,7 @@ float QBtSession::getRealRatio(QString hash) const{
return 0; return 0;
return 101; return 101;
} }
float ratio = (float)h.all_time_upload()/(float)h.total_done(); qreal ratio = (float)h.all_time_upload()/(float)h.total_done();
Q_ASSERT(ratio >= 0.); Q_ASSERT(ratio >= 0.);
if(ratio > 100.) if(ratio > 100.)
ratio = 100.; ratio = 100.;
@ -1731,7 +1731,7 @@ void QBtSession::setUploadRateLimit(long rate) {
// Torrents will a ratio superior to the given value will // Torrents will a ratio superior to the given value will
// be automatically deleted // be automatically deleted
void QBtSession::setMaxRatio(float ratio) { void QBtSession::setMaxRatio(qreal ratio) {
if(ratio < 0) ratio = -1.; if(ratio < 0) ratio = -1.;
if(ratio_limit == -1 && ratio != -1) { if(ratio_limit == -1 && ratio != -1) {
Q_ASSERT(!BigRatioTimer); Q_ASSERT(!BigRatioTimer);
@ -2459,14 +2459,14 @@ void QBtSession::processDownloadedFile(QString url, QString file_path) {
// Return current download rate for the BT // Return current download rate for the BT
// session. Payload means that it only take into // session. Payload means that it only take into
// account "useful" part of the rate // account "useful" part of the rate
float QBtSession::getPayloadDownloadRate() const{ qreal QBtSession::getPayloadDownloadRate() const{
return s->status().payload_download_rate; return s->status().payload_download_rate;
} }
// Return current upload rate for the BT // Return current upload rate for the BT
// session. Payload means that it only take into // session. Payload means that it only take into
// account "useful" part of the rate // account "useful" part of the rate
float QBtSession::getPayloadUploadRate() const{ qreal QBtSession::getPayloadUploadRate() const{
return s->status().payload_upload_rate; return s->status().payload_upload_rate;
} }

10
src/qtlibtorrent/qbtsession.h

@ -76,11 +76,11 @@ public:
QTorrentHandle getTorrentHandle(QString hash) const; QTorrentHandle getTorrentHandle(QString hash) const;
std::vector<libtorrent::torrent_handle> getTorrents() const; std::vector<libtorrent::torrent_handle> getTorrents() const;
bool isFilePreviewPossible(QString fileHash) const; bool isFilePreviewPossible(QString fileHash) const;
float getPayloadDownloadRate() const; qreal getPayloadDownloadRate() const;
float getPayloadUploadRate() const; qreal getPayloadUploadRate() const;
libtorrent::session_status getSessionStatus() const; libtorrent::session_status getSessionStatus() const;
int getListenPort() const; int getListenPort() const;
float getRealRatio(QString hash) const; qreal getRealRatio(QString hash) const;
QHash<QString, TrackerInfos> getTrackersInfo(QString hash) const; QHash<QString, TrackerInfos> getTrackersInfo(QString hash) const;
bool hasActiveTorrents() const; bool hasActiveTorrents() const;
bool hasDownloadingTorrents() const; bool hasDownloadingTorrents() const;
@ -129,7 +129,7 @@ public slots:
void setMaxUploadsPerTorrent(int max); void setMaxUploadsPerTorrent(int max);
void setDownloadRateLimit(long rate); void setDownloadRateLimit(long rate);
void setUploadRateLimit(long rate); void setUploadRateLimit(long rate);
void setMaxRatio(float ratio); void setMaxRatio(qreal ratio);
void setDHTPort(int dht_port); void setDHTPort(int dht_port);
void setProxySettings(const libtorrent::proxy_settings &proxySettings); void setProxySettings(const libtorrent::proxy_settings &proxySettings);
void setSessionSettings(const libtorrent::session_settings &sessionSettings); void setSessionSettings(const libtorrent::session_settings &sessionSettings);
@ -233,7 +233,7 @@ private:
// Settings // Settings
bool preAllocateAll; bool preAllocateAll;
bool addInPause; bool addInPause;
float ratio_limit; qreal ratio_limit;
int high_ratio_action; int high_ratio_action;
bool UPnPEnabled; bool UPnPEnabled;
bool LSDEnabled; bool LSDEnabled;

2
src/transferlistdelegate.h

@ -154,7 +154,7 @@ public:
case TorrentModelItem::TR_RATIO:{ case TorrentModelItem::TR_RATIO:{
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
opt.displayAlignment = Qt::AlignRight; opt.displayAlignment = Qt::AlignRight;
const double ratio = index.data().toDouble(); const qreal ratio = index.data().toDouble();
if(ratio > 100.) if(ratio > 100.)
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8("")); QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8(""));
else else

Loading…
Cancel
Save