Coding style, use nullptr and other minor things

This commit is contained in:
thalieht
2017-09-07 03:00:04 +03:00
committed by sledgehammer999
parent 8482464ad0
commit 07130c4b26
54 changed files with 361 additions and 403 deletions

View File

@@ -27,15 +27,15 @@
*/
#include "banlistoptions.h"
#include "ui_banlistoptions.h"
#include <QMessageBox>
#include <QHostAddress>
#include <QMessageBox>
#include <QSortFilterProxyModel>
#include <QStringListModel>
#include "base/bittorrent/session.h"
#include "base/utils/net.h"
#include "ui_banlistoptions.h"
BanListOptions::BanListOptions(QWidget *parent)
: QDialog(parent)

View File

@@ -39,12 +39,12 @@ namespace Ui
class BanListOptions;
}
class BanListOptions: public QDialog
class BanListOptions : public QDialog
{
Q_OBJECT
public:
explicit BanListOptions(QWidget *parent = 0);
explicit BanListOptions(QWidget *parent = nullptr);
~BanListOptions();
private slots:

View File

@@ -30,10 +30,10 @@
#include <algorithm>
#include "base/settingsstorage.h"
#include "base/net/downloadmanager.h"
#include "guiiconprovider.h"
#include "base/settingsstorage.h"
#include "cookiesmodel.h"
#include "guiiconprovider.h"
#include "ui_cookiesdialog.h"
#define SETTINGS_KEY(name) "CookiesDialog/" name

View File

@@ -43,7 +43,7 @@ class CookiesDialog : public QDialog
Q_OBJECT
public:
explicit CookiesDialog(QWidget *parent = 0);
explicit CookiesDialog(QWidget *parent = nullptr);
~CookiesDialog();
public slots:

View File

@@ -26,9 +26,10 @@
* exception statement from your version.
*/
#include <QDateTime>
#include "cookiesmodel.h"
#include <QDateTime>
CookiesModel::CookiesModel(const QList<QNetworkCookie> &cookies, QObject *parent)
: QAbstractItemModel(parent)
, m_cookies(cookies)
@@ -43,8 +44,7 @@ QList<QNetworkCookie> CookiesModel::cookies() const
QVariant CookiesModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if ((role == Qt::DisplayRole) && (orientation == Qt::Horizontal)) {
switch (section)
{
switch (section) {
case COL_DOMAIN:
return tr("Domain");
case COL_PATH:

View File

@@ -49,7 +49,7 @@ public:
NB_COLUMNS
};
explicit CookiesModel(const QList<QNetworkCookie> &cookies, QObject *parent = 0);
explicit CookiesModel(const QList<QNetworkCookie> &cookies, QObject *parent = nullptr);
QList<QNetworkCookie> cookies() const;

View File

@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,73 +24,78 @@
* 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
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef PREVIEWLISTDELEGATE_H
#define PREVIEWLISTDELEGATE_H
#include <QApplication>
#include <QItemDelegate>
#include <QStyleOptionProgressBar>
#include <QStyleOptionViewItem>
#include <QModelIndex>
#include <QPainter>
#include <QApplication>
#ifdef Q_OS_WIN
#include <QProxyStyle>
#endif
#include <QStyleOptionProgressBar>
#include <QStyleOptionViewItem>
#include "base/utils/misc.h"
#include "base/utils/string.h"
#include "previewselectdialog.h"
#ifdef Q_OS_WIN
#include <QProxyStyle>
#endif
class PreviewListDelegate : public QItemDelegate
{
Q_OBJECT
class PreviewListDelegate: public QItemDelegate {
Q_OBJECT
public:
PreviewListDelegate(QObject *parent=0) : QItemDelegate(parent) {}
public:
PreviewListDelegate(QObject *parent = nullptr)
: QItemDelegate(parent)
{
}
~PreviewListDelegate() {}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const {
painter->save();
QStyleOptionViewItem opt = QItemDelegate::setOptions(index, option);
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
painter->save();
QStyleOptionViewItem opt = QItemDelegate::setOptions(index, option);
switch(index.column()) {
switch (index.column()) {
case PreviewSelectDialog::SIZE:
QItemDelegate::drawBackground(painter, opt, index);
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
break;
case PreviewSelectDialog::PROGRESS:{
QStyleOptionProgressBar newopt;
qreal progress = index.data().toDouble()*100.;
newopt.rect = opt.rect;
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%");
newopt.progress = static_cast<int>(progress);
newopt.maximum = 100;
newopt.minimum = 0;
newopt.state |= QStyle::State_Enabled;
newopt.textVisible = true;
QItemDelegate::drawBackground(painter, opt, index);
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
break;
case PreviewSelectDialog::PROGRESS: {
QStyleOptionProgressBar newopt;
qreal progress = index.data().toDouble() * 100.;
newopt.rect = opt.rect;
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%");
newopt.progress = static_cast<int>(progress);
newopt.maximum = 100;
newopt.minimum = 0;
newopt.state |= QStyle::State_Enabled;
newopt.textVisible = true;
#ifndef Q_OS_WIN
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
#else
// XXX: To avoid having the progress text on the right of the bar
QProxyStyle st("fusion");
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
// XXX: To avoid having the progress text on the right of the bar
QProxyStyle st("fusion");
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
#endif
break;
}
}
break;
default:
QItemDelegate::paint(painter, option, index);
}
painter->restore();
QItemDelegate::paint(painter, option, index);
}
painter->restore();
}
QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const {
// No editor here
return 0;
QWidget *createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const
{
// No editor here
return nullptr;
}
};
#endif
#endif // PREVIEWLISTDELEGATE_H

View File

@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* 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),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef PEERLISTDELEGATE_H
@@ -38,7 +36,7 @@
#include "base/utils/misc.h"
#include "base/utils/string.h"
class PeerListDelegate: public QItemDelegate
class PeerListDelegate : public QItemDelegate
{
Q_OBJECT
@@ -77,34 +75,33 @@ public:
QItemDelegate::drawBackground(painter, opt, index);
switch (index.column()) {
case PORT: {
case PORT:
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, option.rect, index.data().toString());
}
break;
case TOT_DOWN:
case TOT_UP: {
qlonglong size = index.data().toLongLong();
if (hideValues && (size <= 0))
break;
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(size));
qlonglong size = index.data().toLongLong();
if (hideValues && (size <= 0))
break;
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(size));
}
break;
case DOWN_SPEED:
case UP_SPEED: {
qreal speed = index.data().toDouble();
if (speed <= 0.0)
break;
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed, true));
qreal speed = index.data().toDouble();
if (speed <= 0.0)
break;
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed, true));
}
break;
case PROGRESS:
case RELEVANCE: {
qreal progress = index.data().toDouble();
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::String::fromDouble(progress * 100.0, 1) + "%");
qreal progress = index.data().toDouble();
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::String::fromDouble(progress * 100.0, 1) + "%");
}
break;
default:

View File

@@ -34,12 +34,12 @@
#include "peerlistdelegate.h"
class PeerListSortModel: public QSortFilterProxyModel
class PeerListSortModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
PeerListSortModel(QObject *parent = 0)
PeerListSortModel(QObject *parent = nullptr)
: QSortFilterProxyModel(parent)
{
}

View File

@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,36 +24,34 @@
* 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
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include "peerlistwidget.h"
#include <QApplication>
#include <QStandardItemModel>
#include <QSortFilterProxyModel>
#include <QSet>
#include <QClipboard>
#include <QHeaderView>
#include <QMenu>
#include <QClipboard>
#include <QMessageBox>
#include <QWheelEvent>
#include <QSet>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <QTableView>
#include <QWheelEvent>
#include "base/net/reverseresolution.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/peerinfo.h"
#include "base/preferences.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/logger.h"
#include "base/unicodestrings.h"
#include "propertieswidget.h"
#include "base/net/geoipmanager.h"
#include "peersadditiondlg.h"
#include "speedlimitdlg.h"
#include "base/net/reverseresolution.h"
#include "base/preferences.h"
#include "base/unicodestrings.h"
#include "guiiconprovider.h"
#include "peerlistdelegate.h"
#include "peerlistsortmodel.h"
#include "peersadditiondlg.h"
#include "propertieswidget.h"
#include "speedlimitdlg.h"
PeerListWidget::PeerListWidget(PropertiesWidget *parent)
: QTreeView(parent)

View File

@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,18 +24,16 @@
* 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
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef PEERLISTWIDGET_H
#define PEERLISTWIDGET_H
#include <QTreeView>
#include <QHash>
#include <QPointer>
#include <QSet>
#include <QShortcut>
#include <QTreeView>
namespace Net
{
@@ -46,11 +44,9 @@ class PeerListDelegate;
class PeerListSortModel;
class PropertiesWidget;
QT_BEGIN_NAMESPACE
class QSortFilterProxyModel;
class QStandardItem;
class QStandardItemModel;
QT_END_NAMESPACE
namespace BitTorrent
{
@@ -59,7 +55,7 @@ namespace BitTorrent
struct PeerAddress;
}
class PeerListWidget: public QTreeView
class PeerListWidget : public QTreeView
{
Q_OBJECT

View File

@@ -35,9 +35,10 @@
#include <QGraphicsView>
#include <QMap>
class QPen;
class SpeedPlotView: public QGraphicsView
class SpeedPlotView : public QGraphicsView
{
Q_OBJECT
@@ -71,7 +72,7 @@ public:
int y[NB_GRAPHS];
};
explicit SpeedPlotView(QWidget *parent = 0);
explicit SpeedPlotView(QWidget *parent = nullptr);
void setGraphEnable(GraphID id, bool enable);
void setViewableLastPoints(TimePeriod period);

View File

@@ -43,7 +43,7 @@ namespace BitTorrent
class TorrentHandle;
}
class TrackerList: public QTreeWidget
class TrackerList : public QTreeWidget
{
Q_OBJECT
Q_DISABLE_COPY(TrackerList)

View File

@@ -1,18 +1,18 @@
#include "htmlbrowser.h"
#include <QDebug>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkDiskCache>
#include <QStyle>
#include <QApplication>
#include <QDir>
#include <QDateTime>
#include <QDir>
#include <QDebug>
#include <QNetworkDiskCache>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QScrollBar>
#include <QStyle>
#include "base/profile.h"
HtmlBrowser::HtmlBrowser(QWidget* parent)
HtmlBrowser::HtmlBrowser(QWidget *parent)
: QTextBrowser(parent)
{
m_netManager = new QNetworkAccessManager(this);
@@ -31,20 +31,20 @@ HtmlBrowser::~HtmlBrowser()
QVariant HtmlBrowser::loadResource(int type, const QUrl &name)
{
if(type == QTextDocument::ImageResource) {
if (type == QTextDocument::ImageResource) {
QUrl url(name);
if(url.scheme().isEmpty())
if (url.scheme().isEmpty())
url.setScheme("http");
QIODevice *dev = m_diskCache->data(url);
if(dev != 0) {
if (dev != nullptr) {
qDebug() << "HtmlBrowser::loadResource() cache " << url.toString();
QByteArray res = dev->readAll();
delete dev;
return res;
}
if(!m_activeRequests.contains(url)) {
if (!m_activeRequests.contains(url)) {
m_activeRequests.insert(url, true);
qDebug() << "HtmlBrowser::loadResource() get " << url.toString();
QNetworkRequest req(url);
@@ -62,7 +62,7 @@ void HtmlBrowser::resourceLoaded(QNetworkReply *reply)
{
m_activeRequests.remove(reply->request().url());
if(reply->error() == QNetworkReply::NoError && reply->size() > 0) {
if ((reply->error() == QNetworkReply::NoError) && (reply->size() > 0)) {
qDebug() << "HtmlBrowser::resourceLoaded() save " << reply->request().url().toString();
}
else {
@@ -79,8 +79,8 @@ void HtmlBrowser::resourceLoaded(QNetworkReply *reply)
metaData.setLastModified(QDateTime::currentDateTime());
metaData.setExpirationDate(QDateTime::currentDateTime().addDays(1));
QIODevice *dev = m_diskCache->prepare(metaData);
if(!dev)
return;
if (!dev) return;
QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(32, 32).save(dev, "PNG");
m_diskCache->insert(dev);
}

View File

@@ -1,19 +1,19 @@
#ifndef HTMLBROWSER_H
#define HTMLBROWSER_H
#include <QTextBrowser>
#include <QHash>
#include <QTextBrowser>
class QNetworkAccessManager;
class QNetworkDiskCache;
class QNetworkReply;
class HtmlBrowser: public QTextBrowser
class HtmlBrowser : public QTextBrowser
{
Q_OBJECT
public:
explicit HtmlBrowser(QWidget* parent = 0);
explicit HtmlBrowser(QWidget* parent = nullptr);
~HtmlBrowser();
virtual QVariant loadResource(int type, const QUrl &name);

View File

@@ -39,7 +39,7 @@ namespace Ui
class confirmShutdownDlg;
}
class ShutdownConfirmDlg: public QDialog
class ShutdownConfirmDlg : public QDialog
{
Q_OBJECT

View File

@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,14 +24,12 @@
* 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
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include "speedlimitdlg.h"
#include "ui_bandwidth_limit.h"
#include "base/unicodestrings.h"
#include "ui_bandwidth_limit.h"
SpeedLimitDialog::SpeedLimitDialog(QWidget *parent)
: QDialog(parent)

View File

@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* 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),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef BANDWIDTH_ALLOCATION_H
@@ -33,16 +31,19 @@
#include <QDialog>
#include <QList>
#include "base/utils/misc.h"
#include "base/bittorrent/session.h"
#include "base/utils/misc.h"
namespace Ui
{
class bandwidth_dlg;
}
class SpeedLimitDialog : public QDialog {
class SpeedLimitDialog : public QDialog
{
Q_OBJECT
public:
explicit SpeedLimitDialog(QWidget *parent);
~SpeedLimitDialog();
@@ -58,4 +59,4 @@ private:
Ui::bandwidth_dlg *m_ui;
};
#endif
#endif // BANDWIDTH_ALLOCATION_H

View File

@@ -1,6 +1,7 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2011 Christian Kandeler, Christophe Dumez
* Copyright (C) 2011 Christian Kandeler
* Copyright (C) 2011 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,8 +25,6 @@
* 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
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include "updownratiodlg.h"
@@ -33,53 +32,52 @@
#include <QMessageBox>
#include "base/bittorrent/session.h"
#include "ui_updownratiodlg.h"
UpDownRatioDlg::UpDownRatioDlg(bool useDefault, qreal initialRatioValue,
qreal maxRatioValue, int initialTimeValue,
int maxTimeValue, QWidget *parent)
: QDialog(parent)
, ui(new Ui::UpDownRatioDlg)
, m_ui(new Ui::UpDownRatioDlg)
{
ui->setupUi(this);
m_ui->setupUi(this);
if (useDefault) {
ui->useDefaultButton->setChecked(true);
m_ui->useDefaultButton->setChecked(true);
}
else if ((initialRatioValue == -1) && (initialTimeValue == -1)) {
ui->noLimitButton->setChecked(true);
else if ((initialRatioValue == -1.) && (initialTimeValue == -1)) {
m_ui->noLimitButton->setChecked(true);
initialRatioValue = BitTorrent::Session::instance()->globalMaxRatio();
initialTimeValue = BitTorrent::Session::instance()->globalMaxSeedingMinutes();
}
else {
ui->torrentLimitButton->setChecked(true);
m_ui->torrentLimitButton->setChecked(true);
if (initialRatioValue >= 0)
ui->checkMaxRatio->setChecked(true);
m_ui->checkMaxRatio->setChecked(true);
if (initialTimeValue >= 0)
ui->checkMaxTime->setChecked(true);
m_ui->checkMaxTime->setChecked(true);
}
ui->ratioSpinBox->setMinimum(0);
ui->ratioSpinBox->setMaximum(maxRatioValue);
ui->ratioSpinBox->setValue(initialRatioValue);
m_ui->ratioSpinBox->setMinimum(0);
m_ui->ratioSpinBox->setMaximum(maxRatioValue);
m_ui->ratioSpinBox->setValue(initialRatioValue);
ui->timeSpinBox->setMinimum(0);
ui->timeSpinBox->setMaximum(maxTimeValue);
ui->timeSpinBox->setValue(initialTimeValue);
m_ui->timeSpinBox->setMinimum(0);
m_ui->timeSpinBox->setMaximum(maxTimeValue);
m_ui->timeSpinBox->setValue(initialTimeValue);
connect(ui->buttonGroup, SIGNAL(buttonClicked(int)), SLOT(handleRatioTypeChanged()));
connect(ui->checkMaxRatio, SIGNAL(toggled(bool)), this, SLOT(enableRatioSpin()));
connect(ui->checkMaxTime, SIGNAL(toggled(bool)), this, SLOT(enableTimeSpin()));
connect(m_ui->buttonGroup, SIGNAL(buttonClicked(int)), SLOT(handleRatioTypeChanged()));
connect(m_ui->checkMaxRatio, SIGNAL(toggled(bool)), this, SLOT(enableRatioSpin()));
connect(m_ui->checkMaxTime, SIGNAL(toggled(bool)), this, SLOT(enableTimeSpin()));
handleRatioTypeChanged();
}
void UpDownRatioDlg::accept()
{
if (ui->torrentLimitButton->isChecked() && !ui->checkMaxRatio->isChecked() && !ui->checkMaxTime->isChecked())
if (m_ui->torrentLimitButton->isChecked() && !m_ui->checkMaxRatio->isChecked() && !m_ui->checkMaxTime->isChecked())
QMessageBox::critical(this, tr("No share limit method selected"),
tr("Please select a limit method first"));
else
@@ -88,40 +86,40 @@ void UpDownRatioDlg::accept()
bool UpDownRatioDlg::useDefault() const
{
return ui->useDefaultButton->isChecked();
return m_ui->useDefaultButton->isChecked();
}
qreal UpDownRatioDlg::ratio() const
{
return (ui->noLimitButton->isChecked() || !ui->checkMaxRatio->isChecked()) ? -1 : ui->ratioSpinBox->value();
return (m_ui->noLimitButton->isChecked() || !m_ui->checkMaxRatio->isChecked()) ? -1. : m_ui->ratioSpinBox->value();
}
int UpDownRatioDlg::seedingTime() const
{
return (ui->noLimitButton->isChecked() || !ui->checkMaxTime->isChecked()) ? -1 : ui->timeSpinBox->value();
return (m_ui->noLimitButton->isChecked() || !m_ui->checkMaxTime->isChecked()) ? -1 : m_ui->timeSpinBox->value();
}
void UpDownRatioDlg::handleRatioTypeChanged()
{
// ui->ratioSpinBox->setEnabled(ui->torrentLimitButton->isChecked());
ui->checkMaxRatio->setEnabled(ui->torrentLimitButton->isChecked());
ui->checkMaxTime->setEnabled(ui->torrentLimitButton->isChecked());
m_ui->checkMaxRatio->setEnabled(m_ui->torrentLimitButton->isChecked());
m_ui->checkMaxTime->setEnabled(m_ui->torrentLimitButton->isChecked());
ui->ratioSpinBox->setEnabled(ui->torrentLimitButton->isChecked() && ui->checkMaxRatio->isChecked());
ui->timeSpinBox->setEnabled(ui->torrentLimitButton->isChecked() && ui->checkMaxTime->isChecked());
m_ui->ratioSpinBox->setEnabled(m_ui->torrentLimitButton->isChecked() && m_ui->checkMaxRatio->isChecked());
m_ui->timeSpinBox->setEnabled(m_ui->torrentLimitButton->isChecked() && m_ui->checkMaxTime->isChecked());
}
void UpDownRatioDlg::enableRatioSpin()
{
ui->ratioSpinBox->setEnabled(ui->checkMaxRatio->isChecked());
m_ui->ratioSpinBox->setEnabled(m_ui->checkMaxRatio->isChecked());
}
void UpDownRatioDlg::enableTimeSpin()
{
ui->timeSpinBox->setEnabled(ui->checkMaxTime->isChecked());
m_ui->timeSpinBox->setEnabled(m_ui->checkMaxTime->isChecked());
}
UpDownRatioDlg::~UpDownRatioDlg()
{
delete ui;
delete m_ui;
}

View File

@@ -1,7 +1,7 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2011 Christian Kandeler, Christophe Dumez
*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2011 Christian Kandeler
* Copyright (C) 2011 Christophe Dumez <chris@qbittorrent.org>
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -24,8 +24,6 @@
* 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
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef UPDOWNRATIODLG_H
@@ -33,20 +31,19 @@
#include <QDialog>
QT_BEGIN_NAMESPACE
namespace Ui {
namespace Ui
{
class UpDownRatioDlg;
}
QT_END_NAMESPACE
class UpDownRatioDlg : public QDialog
{
Q_OBJECT
public:
explicit UpDownRatioDlg(bool useDefault, qreal initialValue, qreal maxValue,
int initialTimeValue, int maxTimeValue,
QWidget *parent = 0);
UpDownRatioDlg(bool useDefault, qreal initialValue, qreal maxValue,
int initialTimeValue, int maxTimeValue,
QWidget *parent = nullptr);
~UpDownRatioDlg();
bool useDefault() const;
@@ -62,7 +59,7 @@ private slots:
void enableTimeSpin();
private:
Ui::UpDownRatioDlg *ui;
Ui::UpDownRatioDlg *m_ui;
};
#endif // UPDOWNRATIODLG_H