Browse Source

Performance improvement on ARM

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
5c8dd9f0fb
  1. 2
      src/misc.h
  2. 4
      src/preferences/options_imp.cpp
  3. 2
      src/preferences/options_imp.h
  4. 4
      src/preferences/preferences.h
  5. 2
      src/previewlistdelegate.h
  6. 4
      src/properties/peerlistdelegate.h
  7. 6
      src/properties/pieceavailabilitybar.h
  8. 4
      src/properties/propertieswidget.cpp
  9. 8
      src/qtlibtorrent/qtorrenthandle.cpp
  10. 6
      src/qtlibtorrent/qtorrenthandle.h
  11. 6
      src/qtlibtorrent/torrentspeedmonitor.cpp
  12. 8
      src/searchengine/engineselectdlg.cpp
  13. 2
      src/searchengine/engineselectdlg.h
  14. 2
      src/searchengine/searchengine.cpp
  15. 4
      src/searchengine/searchengine.h
  16. 4
      src/torrentfilesmodel.h
  17. 4
      src/webui/eventmanager.cpp

2
src/misc.h

@ -153,7 +153,7 @@ public: @@ -153,7 +153,7 @@ public:
// use Binary prefix standards from IEC 60027-2
// see http://en.wikipedia.org/wiki/Kilobyte
// value must be given in bytes
static QString friendlyUnit(double val);
static QString friendlyUnit(qreal val);
static bool isPreviewable(QString extension);
static QString branchPath(QString file_path, bool uses_slashes=false);
static QString fileName(QString file_path);

4
src/preferences/options_imp.cpp

@ -467,7 +467,7 @@ void options_imp::setStyle(QString style) { @@ -467,7 +467,7 @@ void options_imp::setStyle(QString style) {
void options_imp::loadOptions(){
int intValue;
float floatValue;
qreal floatValue;
QString strValue;
// General preferences
const Preferences pref;
@ -754,7 +754,7 @@ int options_imp::getDHTPort() const { @@ -754,7 +754,7 @@ int options_imp::getDHTPort() const {
}
// Return Share ratio
float options_imp::getMaxRatio() const{
qreal options_imp::getMaxRatio() const{
if(checkMaxRatio->isChecked()){
return spinMaxRatio->value();
}

2
src/preferences/options_imp.h

@ -129,7 +129,7 @@ private: @@ -129,7 +129,7 @@ private:
int getDHTPort() const;
bool isLSDEnabled() const;
int getEncryptionSetting() const;
float getMaxRatio() const;
qreal getMaxRatio() const;
// Proxy options
bool isProxyEnabled() const;
bool isProxyAuthEnabled() const;

4
src/preferences/preferences.h

@ -546,11 +546,11 @@ public: @@ -546,11 +546,11 @@ public:
setValue(QString::fromUtf8("Preferences/Bittorrent/Encryption"), val);
}
float getMaxRatio() const {
qreal getMaxRatio() const {
return value(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), -1).toDouble();
}
void setMaxRatio(float ratio) {
void setMaxRatio(qreal ratio) {
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), ratio);
}

2
src/previewlistdelegate.h

@ -59,7 +59,7 @@ class PreviewListDelegate: public QItemDelegate { @@ -59,7 +59,7 @@ class PreviewListDelegate: public QItemDelegate {
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
break;
case PreviewSelect::PROGRESS:{
float progress = index.data().toDouble()*100.;
qreal progress = index.data().toDouble()*100.;
QStyleOptionProgressBarV2 newopt;
newopt.rect = opt.rect;
newopt.text = QString(QByteArray::number(progress, 'f', 1))+QString::fromUtf8("%");

4
src/properties/peerlistdelegate.h

@ -57,14 +57,14 @@ public: @@ -57,14 +57,14 @@ public:
case DOWN_SPEED:
case UP_SPEED:{
QItemDelegate::drawBackground(painter, opt, index);
double speed = index.data().toDouble();
qreal speed = index.data().toDouble();
if (speed > 0.0)
QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (i.e. per second)"));
break;
}
case PROGRESS:{
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)+"%");
break;
}

6
src/properties/pieceavailabilitybar.h

@ -53,7 +53,7 @@ public: @@ -53,7 +53,7 @@ public:
}
void setAvailability(const std::vector<int>& avail) {
double average = 0;
qreal average = 0;
if(avail.empty()) {
// Empty bar
QPixmap pix = QPixmap(1, 1);
@ -114,10 +114,10 @@ protected: @@ -114,10 +114,10 @@ protected:
painter.drawPixmap(rect(), pixmap);
}
QColor getPieceColor(int avail, double average) {
QColor getPieceColor(int avail, qreal average) {
if(!avail) return Qt::white;
//qDebug("avail: %d/%d", avail, max_avail);
double fraction = 100.*average/avail;
qreal fraction = 100.*average/avail;
if(fraction < 100)
fraction *= 0.8;
else

4
src/properties/propertieswidget.cpp

@ -348,7 +348,7 @@ void PropertiesWidget::loadDynamicData() { @@ -348,7 +348,7 @@ void PropertiesWidget::loadDynamicData() {
// Update next announce time
reannounce_lbl->setText(h.next_announce());
// Update ratio info
const double ratio = QBtSession::instance()->getRealRatio(h.hash());
const qreal ratio = QBtSession::instance()->getRealRatio(h.hash());
if(ratio > 100.)
shareRatio->setText(QString::fromUtf8(""));
else
@ -370,7 +370,7 @@ void PropertiesWidget::loadDynamicData() { @@ -370,7 +370,7 @@ void PropertiesWidget::loadDynamicData() {
showPiecesAvailability(false);
}
// Progress
float progress = h.progress()*100.;
qreal progress = h.progress()*100.;
if(progress > 99.94 && progress < 100.)
progress = 99.9;
progress_lbl->setText(QString::number(progress, 'f', 1)+"%");

8
src/qtlibtorrent/qtorrenthandle.cpp

@ -88,12 +88,12 @@ qlonglong QTorrentHandle::next_announce_s() const { @@ -88,12 +88,12 @@ qlonglong QTorrentHandle::next_announce_s() const {
return torrent_handle::status().next_announce.total_seconds();
}
float QTorrentHandle::progress() const {
qreal QTorrentHandle::progress() const {
if(!torrent_handle::status().total_wanted)
return 0.;
if (torrent_handle::status().total_wanted_done == torrent_handle::status().total_wanted)
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.);
return progress;
}
@ -159,11 +159,11 @@ size_type QTorrentHandle::total_wanted() const { @@ -159,11 +159,11 @@ size_type QTorrentHandle::total_wanted() const {
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;
}
float QTorrentHandle::upload_payload_rate() const {
qreal QTorrentHandle::upload_payload_rate() const {
return torrent_handle::status().upload_payload_rate;
}

6
src/qtlibtorrent/qtorrenthandle.h

@ -56,7 +56,7 @@ public: @@ -56,7 +56,7 @@ public:
//
QString hash() const;
QString name() const;
float progress() const;
qreal progress() const;
libtorrent::bitfield pieces() const;
QString current_tracker() const;
bool is_paused() const;
@ -66,8 +66,8 @@ public: @@ -66,8 +66,8 @@ public:
int num_pieces() const;
libtorrent::size_type total_wanted_done() const;
libtorrent::size_type total_wanted() const;
float download_payload_rate() const;
float upload_payload_rate() const;
qreal download_payload_rate() const;
qreal upload_payload_rate() const;
int num_connections() const;
int connections_limit() const;
int num_peers() const;

6
src/qtlibtorrent/torrentspeedmonitor.cpp

@ -43,7 +43,7 @@ class SpeedSample { @@ -43,7 +43,7 @@ class SpeedSample {
public:
SpeedSample(){}
void addSample(int s);
float average() const;
qreal average() const;
void clear();
private:
@ -83,7 +83,7 @@ void SpeedSample::addSample(int s) @@ -83,7 +83,7 @@ void SpeedSample::addSample(int s)
m_speedSamples.removeFirst();
}
float SpeedSample::average() const
qreal SpeedSample::average() const
{
if(m_speedSamples.empty()) return 0;
qlonglong sum = 0;
@ -114,7 +114,7 @@ qlonglong TorrentSpeedMonitor::getETA(const QString &hash) const @@ -114,7 +114,7 @@ qlonglong TorrentSpeedMonitor::getETA(const QString &hash) const
QMutexLocker locker(&m_mutex);
QTorrentHandle h = m_session->getTorrentHandle(hash);
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;
return (h.total_wanted() - h.total_done()) / speed_average;
}

8
src/searchengine/engineselectdlg.cpp

@ -224,15 +224,15 @@ QTreeWidgetItem* engineSelectDlg::findItemWithID(QString id){ @@ -224,15 +224,15 @@ QTreeWidgetItem* engineSelectDlg::findItemWithID(QString id){
return 0;
}
bool engineSelectDlg::isUpdateNeeded(QString plugin_name, float new_version) const {
float old_version = SearchEngine::getPluginVersion(misc::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py");
bool engineSelectDlg::isUpdateNeeded(QString plugin_name, qreal new_version) const {
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);
return (new_version > old_version);
}
void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
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);
if(!isUpdateNeeded(plugin_name, new_version)) {
qDebug("Apparently update is not needed, we have a more recent version");
@ -372,7 +372,7 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) { @@ -372,7 +372,7 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) {
if(!plugin_name.endsWith(":")) continue;
plugin_name.chop(1); // remove trailing ':'
bool ok;
float version = list.last().toFloat(&ok);
qreal version = list.last().toFloat(&ok);
qDebug("read line %s: %.2f", qPrintable(plugin_name), version);
if(!ok) continue;
file_correct = true;

2
src/searchengine/engineselectdlg.h

@ -52,7 +52,7 @@ class engineSelectDlg : public QDialog, public Ui::engineSelect{ @@ -52,7 +52,7 @@ class engineSelectDlg : public QDialog, public Ui::engineSelect{
protected:
bool parseVersionsFile(QString versions_file);
bool isUpdateNeeded(QString plugin_name, float new_version) const;
bool isUpdateNeeded(QString plugin_name, qreal new_version) const;
signals:
void enginesChanged();

2
src/searchengine/searchengine.cpp

@ -188,7 +188,7 @@ SearchEngine::~SearchEngine(){ @@ -188,7 +188,7 @@ SearchEngine::~SearchEngine(){
searchProcess->waitForFinished();
foreach(QProcess *downloader, downloaders) {
// Make sure we disconnect the SIGNAL/SLOT first
// To avoid double free
// To avoid qreal free
downloader->disconnect();
downloader->kill();
downloader->waitForFinished();

4
src/searchengine/searchengine.h

@ -60,7 +60,7 @@ public: @@ -60,7 +60,7 @@ public:
~SearchEngine();
QString selectedCategory() const;
static float getPluginVersion(QString filePath) {
static qreal getPluginVersion(QString filePath) {
QFile plugin(filePath);
if(!plugin.exists()){
qDebug("%s plugin does not exist, returning 0.0", qPrintable(filePath));
@ -69,7 +69,7 @@ public: @@ -69,7 +69,7 @@ public:
if(!plugin.open(QIODevice::ReadOnly | QIODevice::Text)){
return 0.0;
}
float version = 0.0;
qreal version = 0.0;
while (!plugin.atEnd()){
QByteArray line = plugin.readLine();
if(line.startsWith("#VERSION: ")){

4
src/torrentfilesmodel.h

@ -173,7 +173,7 @@ public: @@ -173,7 +173,7 @@ public:
total_done = done;
qulonglong size = getSize();
Q_ASSERT(total_done <= size);
float progress;
qreal progress;
if(size > 0)
progress = total_done/(float)size;
else
@ -188,7 +188,7 @@ public: @@ -188,7 +188,7 @@ public:
return total_done;
}
float getProgress() const {
qreal getProgress() const {
if(getPriority() == 0)
return 0.;
qulonglong size = getSize();

4
src/webui/eventmanager.cpp

@ -355,7 +355,7 @@ QVariantMap EventManager::getPropGeneralInfo(QString hash) const { @@ -355,7 +355,7 @@ QVariantMap EventManager::getPropGeneralInfo(QString hash) const {
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()))+")");
// Update ratio info
double ratio = QBtSession::instance()->getRealRatio(h.hash());
qreal ratio = QBtSession::instance()->getRealRatio(h.hash());
if(ratio > 100.)
data["share_ratio"] = QString::fromUtf8("");
else
@ -451,7 +451,7 @@ void EventManager::modifiedTorrent(const QTorrentHandle& h) @@ -451,7 +451,7 @@ void EventManager::modifiedTorrent(const QTorrentHandle& h)
leechs += " ("+QString::number(h.num_incomplete())+")";
event["num_leechs"] = QVariant(leechs);
event["seed"] = QVariant(h.is_seed());
double ratio = QBtSession::instance()->getRealRatio(hash);
qreal ratio = QBtSession::instance()->getRealRatio(hash);
if(ratio > 100.)
event["ratio"] = QString::fromUtf8("");
else

Loading…
Cancel
Save