mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-05 03:14:44 +00:00
Fix statsdialog.* coding style
This commit is contained in:
parent
78d6b14fe8
commit
cb678a254d
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Bittorrent Client using Qt4 and libtorrent.
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
* Copyright (C) 2013 Nick Tiskov
|
* Copyright (C) 2013 Nick Tiskov <daymansmail@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@ -24,84 +24,86 @@
|
|||||||
* modify file(s), you may extend this exception to your version of the file(s),
|
* modify file(s), you may extend this exception to your version of the file(s),
|
||||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||||
* exception statement from your version.
|
* exception statement from your version.
|
||||||
*
|
|
||||||
* Contact : daymansmail@gmail.com
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "statsdialog.h"
|
#include "statsdialog.h"
|
||||||
#include "ui_statsdialog.h"
|
|
||||||
|
|
||||||
#include "base/utils/misc.h"
|
#include "base/bittorrent/cachestatus.h"
|
||||||
#include "base/utils/string.h"
|
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
#include "base/bittorrent/sessionstatus.h"
|
#include "base/bittorrent/sessionstatus.h"
|
||||||
#include "base/bittorrent/cachestatus.h"
|
|
||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
|
#include "base/utils/misc.h"
|
||||||
|
#include "base/utils/string.h"
|
||||||
|
#include "ui_statsdialog.h"
|
||||||
|
|
||||||
StatsDialog::StatsDialog(QWidget *parent)
|
StatsDialog::StatsDialog(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, ui(new Ui::StatsDialog)
|
, m_ui(new Ui::StatsDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
connect(ui->buttonBox, SIGNAL(accepted()), SLOT(close()));
|
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &StatsDialog::close);
|
||||||
updateUI();
|
|
||||||
t = new QTimer(this);
|
|
||||||
t->setInterval(1500);
|
|
||||||
connect(t, SIGNAL(timeout()), SLOT(updateUI()));
|
|
||||||
t->start();
|
|
||||||
|
|
||||||
show();
|
update();
|
||||||
|
m_timer = new QTimer(this);
|
||||||
|
m_timer->setInterval(1500);
|
||||||
|
connect(m_timer, &QTimer::timeout, this, &StatsDialog::update);
|
||||||
|
m_timer->start();
|
||||||
|
|
||||||
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
StatsDialog::~StatsDialog() {
|
StatsDialog::~StatsDialog()
|
||||||
t->stop();
|
{
|
||||||
delete t;
|
m_timer->stop();
|
||||||
delete ui;
|
delete m_timer;
|
||||||
|
delete m_ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsDialog::updateUI() {
|
void StatsDialog::update()
|
||||||
BitTorrent::SessionStatus ss = BitTorrent::Session::instance()->status();
|
{
|
||||||
BitTorrent::CacheStatus cs = BitTorrent::Session::instance()->cacheStatus();
|
BitTorrent::SessionStatus ss = BitTorrent::Session::instance()->status();
|
||||||
|
BitTorrent::CacheStatus cs = BitTorrent::Session::instance()->cacheStatus();
|
||||||
|
|
||||||
// Alltime DL/UL
|
// Alltime DL/UL
|
||||||
quint64 atd = BitTorrent::Session::instance()->getAlltimeDL();
|
quint64 atd = BitTorrent::Session::instance()->getAlltimeDL();
|
||||||
quint64 atu = BitTorrent::Session::instance()->getAlltimeUL();
|
quint64 atu = BitTorrent::Session::instance()->getAlltimeUL();
|
||||||
ui->labelAlltimeDL->setText(Utils::Misc::friendlyUnit(atd));
|
m_ui->labelAlltimeDL->setText(Utils::Misc::friendlyUnit(atd));
|
||||||
ui->labelAlltimeUL->setText(Utils::Misc::friendlyUnit(atu));
|
m_ui->labelAlltimeUL->setText(Utils::Misc::friendlyUnit(atu));
|
||||||
// Total waste (this session)
|
// Total waste (this session)
|
||||||
ui->labelWaste->setText(Utils::Misc::friendlyUnit(ss.totalWasted()));
|
m_ui->labelWaste->setText(Utils::Misc::friendlyUnit(ss.totalWasted()));
|
||||||
// Global ratio
|
// Global ratio
|
||||||
ui->labelGlobalRatio->setText(
|
m_ui->labelGlobalRatio->setText(
|
||||||
( atd > 0 && atu > 0 ) ?
|
((atd > 0) && (atu > 0))
|
||||||
Utils::String::fromDouble((qreal)atu / (qreal)atd, 2) :
|
? Utils::String::fromDouble((qreal)atu / (qreal)atd, 2)
|
||||||
"-"
|
: "-");
|
||||||
);
|
// Cache hits
|
||||||
// Cache hits
|
qreal readRatio = cs.readRatio();
|
||||||
qreal readRatio = cs.readRatio();
|
m_ui->labelCacheHits->setText((readRatio >= 0) ? Utils::String::fromDouble(100 * readRatio, 2) : "-");
|
||||||
ui->labelCacheHits->setText((readRatio >= 0) ? Utils::String::fromDouble(100 * readRatio, 2) : "-");
|
// Buffers size
|
||||||
// Buffers size
|
m_ui->labelTotalBuf->setText(Utils::Misc::friendlyUnit(cs.totalUsedBuffers() * 16 * 1024));
|
||||||
ui->labelTotalBuf->setText(Utils::Misc::friendlyUnit(cs.totalUsedBuffers() * 16 * 1024));
|
// Disk overload (100%) equivalent
|
||||||
// Disk overload (100%) equivalent
|
// From lt manual: disk_write_queue and disk_read_queue are the number of peers currently waiting on a disk write or disk read
|
||||||
// From lt manual: disk_write_queue and disk_read_queue are the number of peers currently waiting on a disk write or disk read
|
// to complete before it receives or sends any more data on the socket. It's a metric of how disk bound you are.
|
||||||
// to complete before it receives or sends any more data on the socket. It's a metric of how disk bound you are.
|
|
||||||
|
|
||||||
// num_peers is not reliable (adds up peers, which didn't even overcome tcp handshake)
|
// num_peers is not reliable (adds up peers, which didn't even overcome tcp handshake)
|
||||||
quint32 peers = 0;
|
quint32 peers = 0;
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, BitTorrent::Session::instance()->torrents())
|
foreach (BitTorrent::TorrentHandle *const torrent, BitTorrent::Session::instance()->torrents())
|
||||||
peers += torrent->peersCount();
|
peers += torrent->peersCount();
|
||||||
|
|
||||||
ui->labelWriteStarve->setText(QString("%1%").arg(((ss.diskWriteQueue() > 0) && (peers > 0))
|
m_ui->labelWriteStarve->setText(QString("%1%")
|
||||||
? Utils::String::fromDouble((100. * ss.diskWriteQueue()) / peers, 2)
|
.arg(((ss.diskWriteQueue() > 0) && (peers > 0))
|
||||||
: "0"));
|
? Utils::String::fromDouble((100. * ss.diskWriteQueue()) / peers, 2)
|
||||||
ui->labelReadStarve->setText(QString("%1%").arg(((ss.diskReadQueue() > 0) && (peers > 0))
|
: "0"));
|
||||||
? Utils::String::fromDouble((100. * ss.diskReadQueue()) / peers, 2)
|
m_ui->labelReadStarve->setText(QString("%1%")
|
||||||
: "0"));
|
.arg(((ss.diskReadQueue() > 0) && (peers > 0))
|
||||||
// Disk queues
|
? Utils::String::fromDouble((100. * ss.diskReadQueue()) / peers, 2)
|
||||||
ui->labelQueuedJobs->setText(QString::number(cs.jobQueueLength()));
|
: "0"));
|
||||||
ui->labelJobsTime->setText(tr("%1 ms", "18 milliseconds").arg(cs.averageJobTime()));
|
// Disk queues
|
||||||
ui->labelQueuedBytes->setText(Utils::Misc::friendlyUnit(cs.queuedBytes()));
|
m_ui->labelQueuedJobs->setText(QString::number(cs.jobQueueLength()));
|
||||||
|
m_ui->labelJobsTime->setText(tr("%1 ms", "18 milliseconds").arg(cs.averageJobTime()));
|
||||||
|
m_ui->labelQueuedBytes->setText(Utils::Misc::friendlyUnit(cs.queuedBytes()));
|
||||||
|
|
||||||
// Total connected peers
|
// Total connected peers
|
||||||
ui->labelPeers->setText(QString::number(ss.peersCount()));
|
m_ui->labelPeers->setText(QString::number(ss.peersCount()));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Bittorrent Client using Qt4 and libtorrent.
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
* Copyright (C) 2013 Nick Tiskov
|
* Copyright (C) 2013 Nick Tiskov <daymansmail@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@ -24,8 +24,6 @@
|
|||||||
* modify file(s), you may extend this exception to your version of the file(s),
|
* modify file(s), you may extend this exception to your version of the file(s),
|
||||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||||
* exception statement from your version.
|
* exception statement from your version.
|
||||||
*
|
|
||||||
* Contact : daymansmail@gmail.com
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef STATSDIALOG_H
|
#ifndef STATSDIALOG_H
|
||||||
@ -34,23 +32,25 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui
|
||||||
class StatsDialog;
|
{
|
||||||
|
class StatsDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
class StatsDialog : public QDialog {
|
class StatsDialog: public QDialog
|
||||||
Q_OBJECT
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StatsDialog(QWidget *parent);
|
explicit StatsDialog(QWidget *parent);
|
||||||
~StatsDialog();
|
~StatsDialog() override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateUI();
|
void update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::StatsDialog *ui;
|
Ui::StatsDialog *m_ui;
|
||||||
QTimer* t;
|
QTimer *m_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // STATSDIALOG_H
|
#endif // STATSDIALOG_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user