chore: add clang-tidy checks to Qt client (#1236)
* chore: add clang-tidy integration for Qt client
This commit is contained in:
parent
6aa559f12f
commit
d43aeb6a5c
|
@ -523,6 +523,17 @@ else()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT CMAKE_VERSION VERSION_LESS "3.7.2")
|
||||||
|
message(STATUS "Looking for clang-tidy")
|
||||||
|
find_program(CLANG_TIDY clang-tidy)
|
||||||
|
if (CLANG_TIDY STREQUAL "CLANG_TIDY-NOTFOUND")
|
||||||
|
message(STATUS "Looking for clang-tidy - not found")
|
||||||
|
else()
|
||||||
|
message(STATUS "Looking for clang-tidy - found")
|
||||||
|
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(ENABLE_TESTS)
|
if(ENABLE_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
---
|
||||||
|
Checks: "-*,\
|
||||||
|
bugprone-*,
|
||||||
|
-bugprone-branch-clone,
|
||||||
|
-bugprone-narrowing-conversions,
|
||||||
|
cert-*,
|
||||||
|
-cert-err58-cpp,
|
||||||
|
clang-analyzer-optin*,
|
||||||
|
cppcoreguidelines-*,
|
||||||
|
hicpp-*,
|
||||||
|
misc-*,
|
||||||
|
-misc-non-private-member-variables-in-classes,
|
||||||
|
modernize-*,
|
||||||
|
-modernize-avoid-c-arrays,
|
||||||
|
-modernize-loop-convert,
|
||||||
|
-modernize-pass-by-value,
|
||||||
|
-modernize-raw-string-literal,
|
||||||
|
-modernize-use-nodiscard,
|
||||||
|
-modernize-use-trailing-return-type,
|
||||||
|
readability-*,
|
||||||
|
-readability-convert-member-functions-to-static,
|
||||||
|
-readability-implicit-bool-conversion,
|
||||||
|
-readability-inconsistent-declaration-parameter-name,
|
||||||
|
-readability-isolate-declaration,
|
||||||
|
-readability-magic-numbers,
|
||||||
|
-readability-redundant-access-specifiers,
|
||||||
|
-readability-static-accessed-through-instance,
|
||||||
|
WarningsAsErrors: "*"
|
||||||
|
...
|
||||||
|
|
|
@ -19,8 +19,7 @@
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
AboutDialog::AboutDialog(QWidget* parent) :
|
AboutDialog::AboutDialog(QWidget* parent) :
|
||||||
BaseDialog(parent),
|
BaseDialog(parent)
|
||||||
myLicenseDialog()
|
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
|
|
@ -208,9 +208,6 @@ Application::Application(int& argc, char** argv) :
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AddData::FILENAME:
|
case AddData::FILENAME:
|
||||||
metainfo = QString::fromLatin1(a.toBase64());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AddData::METAINFO:
|
case AddData::METAINFO:
|
||||||
metainfo = QString::fromLatin1(a.toBase64());
|
metainfo = QString::fromLatin1(a.toBase64());
|
||||||
break;
|
break;
|
||||||
|
@ -339,7 +336,7 @@ Application::Application(int& argc, char** argv) :
|
||||||
|
|
||||||
if (!myPrefs->getBool(Prefs::USER_HAS_GIVEN_INFORMED_CONSENT))
|
if (!myPrefs->getBool(Prefs::USER_HAS_GIVEN_INFORMED_CONSENT))
|
||||||
{
|
{
|
||||||
QMessageBox* dialog = new QMessageBox(QMessageBox::Information, QString(),
|
auto* dialog = new QMessageBox(QMessageBox::Information, QString(),
|
||||||
tr("<b>Transmission is a file sharing program.</b>"), QMessageBox::Ok | QMessageBox::Cancel, myWindow);
|
tr("<b>Transmission is a file sharing program.</b>"), QMessageBox::Ok | QMessageBox::Cancel, myWindow);
|
||||||
dialog->setInformativeText(tr("When you run a torrent, its data will be made available to others by means of upload. "
|
dialog->setInformativeText(tr("When you run a torrent, its data will be made available to others by means of upload. "
|
||||||
"Any content you share is your sole responsibility."));
|
"Any content you share is your sole responsibility."));
|
||||||
|
@ -573,7 +570,7 @@ void Application::addTorrent(AddData const& addme)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto o = new OptionsDialog(*mySession, *myPrefs, addme, myWindow);
|
auto* o = new OptionsDialog(*mySession, *myPrefs, addme, myWindow);
|
||||||
o->show();
|
o->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,7 @@ int itemColumnSpan(QGridLayout* layout, QLayoutItem const* item)
|
||||||
|
|
||||||
ColumnResizer::ColumnResizer(QObject* parent) :
|
ColumnResizer::ColumnResizer(QObject* parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
myTimer(new QTimer(this)),
|
myTimer(new QTimer(this))
|
||||||
myLayouts()
|
|
||||||
{
|
{
|
||||||
myTimer->setSingleShot(true);
|
myTimer->setSingleShot(true);
|
||||||
connect(myTimer, SIGNAL(timeout()), SLOT(update()));
|
connect(myTimer, SIGNAL(timeout()), SLOT(update()));
|
||||||
|
|
|
@ -32,9 +32,7 @@ ComInteropHelper::ComInteropHelper() :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ComInteropHelper::~ComInteropHelper()
|
ComInteropHelper::~ComInteropHelper() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ComInteropHelper::isConnected() const
|
bool ComInteropHelper::isConnected() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -99,11 +99,8 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~PeerItem()
|
~PeerItem() override = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
void refresh(Peer const& p)
|
void refresh(Peer const& p)
|
||||||
{
|
{
|
||||||
if (p.address != peer.address)
|
if (p.address != peer.address)
|
||||||
|
@ -119,9 +116,9 @@ public:
|
||||||
status = s;
|
status = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool operator <(QTreeWidgetItem const& other) const
|
bool operator <(QTreeWidgetItem const& other) const override
|
||||||
{
|
{
|
||||||
PeerItem const* i = dynamic_cast<PeerItem const*>(&other);
|
auto const* i = dynamic_cast<PeerItem const*>(&other);
|
||||||
QTreeWidget* tw(treeWidget());
|
QTreeWidget* tw(treeWidget());
|
||||||
int const column = tw != nullptr ? tw->sortColumn() : 0;
|
int const column = tw != nullptr ? tw->sortColumn() : 0;
|
||||||
|
|
||||||
|
@ -516,11 +513,7 @@ void DetailsDialog::refresh()
|
||||||
ui.haveValueLabel->setText(string);
|
ui.haveValueLabel->setText(string);
|
||||||
|
|
||||||
// myAvailabilityLabel
|
// myAvailabilityLabel
|
||||||
if (torrents.empty())
|
if (torrents.empty() || sizeWhenDone == 0)
|
||||||
{
|
|
||||||
string = none;
|
|
||||||
}
|
|
||||||
else if (sizeWhenDone == 0)
|
|
||||||
{
|
{
|
||||||
string = none;
|
string = none;
|
||||||
}
|
}
|
||||||
|
@ -1189,7 +1182,7 @@ void DetailsDialog::initInfoTab()
|
||||||
int const h = QFontMetrics(ui.commentBrowser->font()).lineSpacing() * 4;
|
int const h = QFontMetrics(ui.commentBrowser->font()).lineSpacing() * 4;
|
||||||
ui.commentBrowser->setFixedHeight(h);
|
ui.commentBrowser->setFixedHeight(h);
|
||||||
|
|
||||||
ColumnResizer* cr(new ColumnResizer(this));
|
auto* cr = new ColumnResizer(this);
|
||||||
cr->addLayout(ui.activitySectionLayout);
|
cr->addLayout(ui.activitySectionLayout);
|
||||||
cr->addLayout(ui.detailsSectionLayout);
|
cr->addLayout(ui.detailsSectionLayout);
|
||||||
cr->update();
|
cr->update();
|
||||||
|
@ -1225,7 +1218,7 @@ void DetailsDialog::onSpinBoxEditingFinished()
|
||||||
{
|
{
|
||||||
QObject const* spin = sender();
|
QObject const* spin = sender();
|
||||||
tr_quark const key = spin->property(PREF_KEY).toInt();
|
tr_quark const key = spin->property(PREF_KEY).toInt();
|
||||||
QDoubleSpinBox const* d = qobject_cast<QDoubleSpinBox const*>(spin);
|
auto const* d = qobject_cast<QDoubleSpinBox const*>(spin);
|
||||||
|
|
||||||
if (d != nullptr)
|
if (d != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -1332,7 +1325,7 @@ void DetailsDialog::onEditTrackerClicked()
|
||||||
QModelIndexList selectedRows = selectionModel->selectedRows();
|
QModelIndexList selectedRows = selectionModel->selectedRows();
|
||||||
assert(selectedRows.size() == 1);
|
assert(selectedRows.size() == 1);
|
||||||
QModelIndex i = selectionModel->currentIndex();
|
QModelIndex i = selectionModel->currentIndex();
|
||||||
TrackerInfo const trackerInfo = ui.trackersView->model()->data(i, TrackerModel::TrackerRole).value<TrackerInfo>();
|
auto const trackerInfo = ui.trackersView->model()->data(i, TrackerModel::TrackerRole).value<TrackerInfo>();
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
QString const newval = QInputDialog::getText(this, tr("Edit URL "), tr("Edit tracker announce URL:"), QLineEdit::Normal,
|
QString const newval = QInputDialog::getText(this, tr("Edit URL "), tr("Edit tracker announce URL:"), QLineEdit::Normal,
|
||||||
|
@ -1366,7 +1359,7 @@ void DetailsDialog::onRemoveTrackerClicked()
|
||||||
|
|
||||||
for (QModelIndex const& i : selectedRows)
|
for (QModelIndex const& i : selectedRows)
|
||||||
{
|
{
|
||||||
TrackerInfo const inf = ui.trackersView->model()->data(i, TrackerModel::TrackerRole).value<TrackerInfo>();
|
auto const inf = ui.trackersView->model()->data(i, TrackerModel::TrackerRole).value<TrackerInfo>();
|
||||||
torrentId_to_trackerIds.insertMulti(inf.torrentId, inf.st.id);
|
torrentId_to_trackerIds.insertMulti(inf.torrentId, inf.st.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1406,7 +1399,7 @@ void DetailsDialog::initOptionsTab()
|
||||||
ui.idleCombo->addItem(tr("Seed regardless of activity"), TR_IDLELIMIT_UNLIMITED);
|
ui.idleCombo->addItem(tr("Seed regardless of activity"), TR_IDLELIMIT_UNLIMITED);
|
||||||
ui.idleCombo->addItem(tr("Stop seeding if idle for:"), TR_IDLELIMIT_SINGLE);
|
ui.idleCombo->addItem(tr("Stop seeding if idle for:"), TR_IDLELIMIT_SINGLE);
|
||||||
|
|
||||||
ColumnResizer* cr(new ColumnResizer(this));
|
auto* cr = new ColumnResizer(this);
|
||||||
cr->addLayout(ui.speedSectionLayout);
|
cr->addLayout(ui.speedSectionLayout);
|
||||||
cr->addLayout(ui.seedingLimitsSectionRatioLayout);
|
cr->addLayout(ui.seedingLimitsSectionRatioLayout);
|
||||||
cr->addLayout(ui.seedingLimitsSectionIdleLayout);
|
cr->addLayout(ui.seedingLimitsSectionIdleLayout);
|
||||||
|
@ -1510,14 +1503,14 @@ void DetailsDialog::onFilePriorityChanged(QSet<int> const& indices, int priority
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mySession.torrentSet(myIds, key, indices.toList());
|
mySession.torrentSet(myIds, key, indices.values());
|
||||||
getNewData();
|
getNewData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DetailsDialog::onFileWantedChanged(QSet<int> const& indices, bool wanted)
|
void DetailsDialog::onFileWantedChanged(QSet<int> const& indices, bool wanted)
|
||||||
{
|
{
|
||||||
tr_quark const key = wanted ? TR_KEY_files_wanted : TR_KEY_files_unwanted;
|
tr_quark const key = wanted ? TR_KEY_files_wanted : TR_KEY_files_unwanted;
|
||||||
mySession.torrentSet(myIds, key, indices.toList());
|
mySession.torrentSet(myIds, key, indices.values());
|
||||||
getNewData();
|
getNewData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include <libtransmission/transmission.h> // priorities
|
#include <libtransmission/transmission.h> // priorities
|
||||||
|
@ -27,7 +28,6 @@ protected:
|
||||||
myToken.reserve(path.size() / 2);
|
myToken.reserve(path.size() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
|
||||||
QString const& myPath;
|
QString const& myPath;
|
||||||
int mySlashIndex;
|
int mySlashIndex;
|
||||||
QString myToken;
|
QString myToken;
|
||||||
|
@ -94,8 +94,7 @@ public:
|
||||||
FileTreeModel::FileTreeModel(QObject* parent, bool isEditable) :
|
FileTreeModel::FileTreeModel(QObject* parent, bool isEditable) :
|
||||||
QAbstractItemModel(parent),
|
QAbstractItemModel(parent),
|
||||||
myIsEditable(isEditable),
|
myIsEditable(isEditable),
|
||||||
myRootItem(new FileTreeItem),
|
myRootItem(new FileTreeItem)
|
||||||
myIndexCache()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +125,7 @@ QModelIndexList FileTreeModel::getOrphanIndices(QModelIndexList const& indices)
|
||||||
{
|
{
|
||||||
QModelIndexList orphanIndices = indices;
|
QModelIndexList orphanIndices = indices;
|
||||||
|
|
||||||
qSort(orphanIndices);
|
std::sort(orphanIndices.begin(), orphanIndices.end());
|
||||||
|
|
||||||
for (QMutableListIterator<QModelIndex> it(orphanIndices); it.hasNext();)
|
for (QMutableListIterator<QModelIndex> it(orphanIndices); it.hasNext();)
|
||||||
{
|
{
|
||||||
|
@ -141,7 +140,7 @@ QModelIndexList FileTreeModel::getOrphanIndices(QModelIndexList const& indices)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qBinaryFind(orphanIndices, walk) != orphanIndices.end())
|
if (std::binary_search(orphanIndices.begin(), orphanIndices.end(), walk))
|
||||||
{
|
{
|
||||||
it.remove();
|
it.remove();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
class FileTreeItem;
|
class FileTreeItem;
|
||||||
|
|
||||||
class FileTreeModel : public QAbstractItemModel
|
class FileTreeModel final : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -283,7 +283,7 @@ void FileTreeView::onlyCheckSelectedItems()
|
||||||
QModelIndexList wantedIndices = selectedSourceRows();
|
QModelIndexList wantedIndices = selectedSourceRows();
|
||||||
myModel->setWanted(wantedIndices, true);
|
myModel->setWanted(wantedIndices, true);
|
||||||
|
|
||||||
qSort(wantedIndices);
|
std::sort(wantedIndices.begin(), wantedIndices.end());
|
||||||
|
|
||||||
QSet<QModelIndex> wantedIndicesParents;
|
QSet<QModelIndex> wantedIndicesParents;
|
||||||
|
|
||||||
|
@ -303,7 +303,7 @@ void FileTreeView::onlyCheckSelectedItems()
|
||||||
{
|
{
|
||||||
QModelIndex const parentIndex = parentsQueue.dequeue();
|
QModelIndex const parentIndex = parentsQueue.dequeue();
|
||||||
|
|
||||||
if (qBinaryFind(wantedIndices, parentIndex) != wantedIndices.end())
|
if (std::binary_search(wantedIndices.begin(), wantedIndices.end(), parentIndex))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ void FileTreeView::onlyCheckSelectedItems()
|
||||||
QModelIndex const childIndex = parentIndex.child(i, 0);
|
QModelIndex const childIndex = parentIndex.child(i, 0);
|
||||||
int const childCheckState = childIndex.data(FileTreeModel::WantedRole).toInt();
|
int const childCheckState = childIndex.data(FileTreeModel::WantedRole).toInt();
|
||||||
|
|
||||||
if (childCheckState == Qt::Unchecked || qBinaryFind(wantedIndices, childIndex) != wantedIndices.end())
|
if (childCheckState == Qt::Unchecked || std::binary_search(wantedIndices.begin(), wantedIndices.end(), childIndex))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -341,7 +341,7 @@ void FileTreeView::onlyCheckSelectedItems()
|
||||||
|
|
||||||
void FileTreeView::setSelectedItemsPriority()
|
void FileTreeView::setSelectedItemsPriority()
|
||||||
{
|
{
|
||||||
QAction* action = qobject_cast<QAction*>(sender());
|
auto* action = qobject_cast<QAction*>(sender());
|
||||||
assert(action != nullptr);
|
assert(action != nullptr);
|
||||||
myModel->setPriority(selectedSourceRows(), action->property(PRIORITY_KEY).toInt());
|
myModel->setPriority(selectedSourceRows(), action->property(PRIORITY_KEY).toInt());
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,13 +38,13 @@ enum
|
||||||
|
|
||||||
FilterBarComboBox* FilterBar::createActivityCombo()
|
FilterBarComboBox* FilterBar::createActivityCombo()
|
||||||
{
|
{
|
||||||
FilterBarComboBox* c = new FilterBarComboBox(this);
|
auto* c = new FilterBarComboBox(this);
|
||||||
FilterBarComboBoxDelegate* delegate = new FilterBarComboBoxDelegate(this, c);
|
auto* delegate = new FilterBarComboBoxDelegate(this, c);
|
||||||
c->setItemDelegate(delegate);
|
c->setItemDelegate(delegate);
|
||||||
|
|
||||||
QStandardItemModel* model = new QStandardItemModel(this);
|
auto* model = new QStandardItemModel(this);
|
||||||
|
|
||||||
QStandardItem* row = new QStandardItem(tr("All"));
|
auto* row = new QStandardItem(tr("All"));
|
||||||
row->setData(FilterMode::SHOW_ALL, ActivityRole);
|
row->setData(FilterMode::SHOW_ALL, ActivityRole);
|
||||||
model->appendRow(row);
|
model->appendRow(row);
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ void FilterBar::refreshTrackers()
|
||||||
|
|
||||||
// update the "All" row
|
// update the "All" row
|
||||||
auto const num_trackers = torrentsPerHost.size();
|
auto const num_trackers = torrentsPerHost.size();
|
||||||
auto item = myTrackerModel->item(ROW_TOTALS);
|
auto* item = myTrackerModel->item(ROW_TOTALS);
|
||||||
item->setData(int(num_trackers), FilterBarComboBox::CountRole);
|
item->setData(int(num_trackers), FilterBarComboBox::CountRole);
|
||||||
item->setData(getCountString(num_trackers), FilterBarComboBox::CountStringRole);
|
item->setData(getCountString(num_trackers), FilterBarComboBox::CountStringRole);
|
||||||
|
|
||||||
|
@ -173,11 +173,11 @@ void FilterBar::refreshTrackers()
|
||||||
|
|
||||||
FilterBarComboBox* FilterBar::createTrackerCombo(QStandardItemModel* model)
|
FilterBarComboBox* FilterBar::createTrackerCombo(QStandardItemModel* model)
|
||||||
{
|
{
|
||||||
FilterBarComboBox* c = new FilterBarComboBox(this);
|
auto* c = new FilterBarComboBox(this);
|
||||||
FilterBarComboBoxDelegate* delegate = new FilterBarComboBoxDelegate(this, c);
|
auto* delegate = new FilterBarComboBoxDelegate(this, c);
|
||||||
c->setItemDelegate(delegate);
|
c->setItemDelegate(delegate);
|
||||||
|
|
||||||
QStandardItem* row = new QStandardItem(tr("All"));
|
auto* row = new QStandardItem(tr("All"));
|
||||||
row->setData(QString(), TrackerRole);
|
row->setData(QString(), TrackerRole);
|
||||||
int const count = myTorrents.rowCount();
|
int const count = myTorrents.rowCount();
|
||||||
row->setData(count, FilterBarComboBox::CountRole);
|
row->setData(count, FilterBarComboBox::CountRole);
|
||||||
|
@ -203,7 +203,7 @@ FilterBar::FilterBar(Prefs& prefs, TorrentModel const& torrents, TorrentFilter c
|
||||||
myRecountTimer(new QTimer(this)),
|
myRecountTimer(new QTimer(this)),
|
||||||
myIsBootstrapping(true)
|
myIsBootstrapping(true)
|
||||||
{
|
{
|
||||||
QHBoxLayout* h = new QHBoxLayout(this);
|
auto* h = new QHBoxLayout(this);
|
||||||
h->setContentsMargins(3, 3, 3, 3);
|
h->setContentsMargins(3, 3, 3, 3);
|
||||||
|
|
||||||
myCountLabel = new QLabel(tr("Show:"), this);
|
myCountLabel = new QLabel(tr("Show:"), this);
|
||||||
|
@ -272,7 +272,7 @@ void FilterBar::refreshPref(int key)
|
||||||
{
|
{
|
||||||
case Prefs::FILTER_MODE:
|
case Prefs::FILTER_MODE:
|
||||||
{
|
{
|
||||||
FilterMode const m = myPrefs.get<FilterMode>(key);
|
auto const m = myPrefs.get<FilterMode>(key);
|
||||||
QAbstractItemModel* model = myActivityCombo->model();
|
QAbstractItemModel* model = myActivityCombo->model();
|
||||||
QModelIndexList indices = model->match(model->index(0, 0), ActivityRole, m.mode());
|
QModelIndexList indices = model->match(model->index(0, 0), ActivityRole, m.mode());
|
||||||
myActivityCombo->setCurrentIndex(indices.isEmpty() ? 0 : indices.first().row());
|
myActivityCombo->setCurrentIndex(indices.isEmpty() ? 0 : indices.first().row());
|
||||||
|
|
|
@ -114,7 +114,7 @@ void FilterBarComboBox::paintEvent(QPaintEvent* e)
|
||||||
QPen const pen = painter.pen();
|
QPen const pen = painter.pen();
|
||||||
painter.setPen(Utils::getFadedColor(pen.color()));
|
painter.setPen(Utils::getFadedColor(pen.color()));
|
||||||
QRect const textRect = QStyle::alignedRect(opt.direction, Qt::AlignRight | Qt::AlignVCenter,
|
QRect const textRect = QStyle::alignedRect(opt.direction, Qt::AlignRight | Qt::AlignVCenter,
|
||||||
QSize(opt.fontMetrics.width(text), rect.height()), rect);
|
QSize(opt.fontMetrics.boundingRect(text).width(), rect.height()), rect);
|
||||||
painter.drawText(textRect, Qt::AlignRight | Qt::AlignVCenter, text);
|
painter.drawText(textRect, Qt::AlignRight | Qt::AlignVCenter, text);
|
||||||
Utils::narrowRect(rect, 0, textRect.width() + hmargin, opt.direction);
|
Utils::narrowRect(rect, 0, textRect.width() + hmargin, opt.direction);
|
||||||
painter.setPen(pen);
|
painter.setPen(pen);
|
||||||
|
|
|
@ -41,7 +41,7 @@ void FilterBarComboBoxDelegate::setSeparator(QAbstractItemModel* model, QModelIn
|
||||||
{
|
{
|
||||||
model->setData(index, QString::fromLatin1("separator"), Qt::AccessibleDescriptionRole);
|
model->setData(index, QString::fromLatin1("separator"), Qt::AccessibleDescriptionRole);
|
||||||
|
|
||||||
if (QStandardItemModel* m = qobject_cast<QStandardItemModel*>(model))
|
if (auto* m = qobject_cast<QStandardItemModel*>(model))
|
||||||
{
|
{
|
||||||
if (QStandardItem* item = m->itemFromIndex(index))
|
if (QStandardItem* item = m->itemFromIndex(index))
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ void FilterBarComboBoxDelegate::paint(QPainter* painter, QStyleOptionViewItem co
|
||||||
{
|
{
|
||||||
QRect rect = option.rect;
|
QRect rect = option.rect;
|
||||||
|
|
||||||
if (QAbstractItemView const* view = qobject_cast<QAbstractItemView const*>(option.widget))
|
if (auto const* view = qobject_cast<QAbstractItemView const*>(option.widget))
|
||||||
{
|
{
|
||||||
rect.setWidth(view->viewport()->width());
|
rect.setWidth(view->viewport()->width());
|
||||||
}
|
}
|
||||||
|
@ -106,16 +106,14 @@ QSize FilterBarComboBoxDelegate::sizeHint(QStyleOptionViewItem const& option, QM
|
||||||
int const pm = myCombo->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, myCombo);
|
int const pm = myCombo->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, myCombo);
|
||||||
return QSize(pm, pm + 10);
|
return QSize(pm, pm + 10);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
QStyle* s = myCombo->style();
|
|
||||||
int const hmargin = getHSpacing(myCombo);
|
|
||||||
|
|
||||||
QSize size = QItemDelegate::sizeHint(option, index);
|
QStyle* s = myCombo->style();
|
||||||
size.setHeight(qMax(size.height(), myCombo->iconSize().height() + 6));
|
int const hmargin = getHSpacing(myCombo);
|
||||||
size.rwidth() += s->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, myCombo);
|
|
||||||
size.rwidth() += rect(option, index, FilterBarComboBox::CountStringRole).width();
|
QSize size = QItemDelegate::sizeHint(option, index);
|
||||||
size.rwidth() += hmargin * 4;
|
size.setHeight(qMax(size.height(), myCombo->iconSize().height() + 6));
|
||||||
return size;
|
size.rwidth() += s->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, myCombo);
|
||||||
}
|
size.rwidth() += rect(option, index, FilterBarComboBox::CountStringRole).width();
|
||||||
|
size.rwidth() += hmargin * 4;
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
static int const INTERVAL_MSEC = 15000;
|
int const INTERVAL_MSEC = 15000;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ void FreeSpaceLabel::onTimer()
|
||||||
tr_variantInitDict(&args, 1);
|
tr_variantInitDict(&args, 1);
|
||||||
tr_variantDictAddStr(&args, TR_KEY_path, myPath.toUtf8().constData());
|
tr_variantDictAddStr(&args, TR_KEY_path, myPath.toUtf8().constData());
|
||||||
|
|
||||||
RpcQueue* q = new RpcQueue();
|
auto* q = new RpcQueue();
|
||||||
|
|
||||||
q->add([this, &args]()
|
q->add([this, &args]()
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,7 +66,7 @@ class ListViewProxyStyle : public QProxyStyle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int styleHint(StyleHint hint, QStyleOption const* option = nullptr, QWidget const* widget = nullptr,
|
int styleHint(StyleHint hint, QStyleOption const* option = nullptr, QWidget const* widget = nullptr,
|
||||||
QStyleHintReturn* returnData = nullptr) const
|
QStyleHintReturn* returnData = nullptr) const override
|
||||||
{
|
{
|
||||||
if (hint == QStyle::SH_ItemView_ActivateItemOnSingleClick)
|
if (hint == QStyle::SH_ItemView_ActivateItemOnSingleClick)
|
||||||
{
|
{
|
||||||
|
@ -83,7 +83,7 @@ QIcon MainWindow::getStockIcon(QString const& name, int fallback)
|
||||||
|
|
||||||
if (icon.isNull() && fallback >= 0)
|
if (icon.isNull() && fallback >= 0)
|
||||||
{
|
{
|
||||||
icon = style()->standardIcon(QStyle::StandardPixmap(fallback), 0, this);
|
icon = style()->standardIcon(QStyle::StandardPixmap(fallback), nullptr, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return icon;
|
return icon;
|
||||||
|
@ -140,11 +140,6 @@ MainWindow::MainWindow(Session& session, Prefs& prefs, TorrentModel& model, bool
|
||||||
myPrefs(prefs),
|
myPrefs(prefs),
|
||||||
myModel(model),
|
myModel(model),
|
||||||
myLastFullUpdateTime(0),
|
myLastFullUpdateTime(0),
|
||||||
mySessionDialog(),
|
|
||||||
myPrefsDialog(),
|
|
||||||
myAboutDialog(),
|
|
||||||
myStatsDialog(),
|
|
||||||
myDetailsDialog(),
|
|
||||||
myFilterModel(prefs),
|
myFilterModel(prefs),
|
||||||
myTorrentDelegate(new TorrentDelegate(this)),
|
myTorrentDelegate(new TorrentDelegate(this)),
|
||||||
myTorrentDelegateMin(new TorrentDelegateMin(this)),
|
myTorrentDelegateMin(new TorrentDelegateMin(this)),
|
||||||
|
@ -156,7 +151,7 @@ MainWindow::MainWindow(Session& session, Prefs& prefs, TorrentModel& model, bool
|
||||||
{
|
{
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
QAction* sep = new QAction(this);
|
auto* sep = new QAction(this);
|
||||||
sep->setSeparator(true);
|
sep->setSeparator(true);
|
||||||
|
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
@ -271,7 +266,7 @@ MainWindow::MainWindow(Session& session, Prefs& prefs, TorrentModel& model, bool
|
||||||
qMakePair(ui.action_SortByState, static_cast<int>(SortMode::SORT_BY_STATE))
|
qMakePair(ui.action_SortByState, static_cast<int>(SortMode::SORT_BY_STATE))
|
||||||
};
|
};
|
||||||
|
|
||||||
QActionGroup* actionGroup = new QActionGroup(this);
|
auto* actionGroup = new QActionGroup(this);
|
||||||
|
|
||||||
for (auto const& mode : sortModes)
|
for (auto const& mode : sortModes)
|
||||||
{
|
{
|
||||||
|
@ -286,7 +281,7 @@ MainWindow::MainWindow(Session& session, Prefs& prefs, TorrentModel& model, bool
|
||||||
myAltSpeedAction->setCheckable(true);
|
myAltSpeedAction->setCheckable(true);
|
||||||
connect(myAltSpeedAction, SIGNAL(triggered()), this, SLOT(toggleSpeedMode()));
|
connect(myAltSpeedAction, SIGNAL(triggered()), this, SLOT(toggleSpeedMode()));
|
||||||
|
|
||||||
QMenu* menu = new QMenu(this);
|
auto* menu = new QMenu(this);
|
||||||
menu->addAction(ui.action_OpenFile);
|
menu->addAction(ui.action_OpenFile);
|
||||||
menu->addAction(ui.action_AddURL);
|
menu->addAction(ui.action_AddURL);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
@ -354,9 +349,7 @@ MainWindow::MainWindow(Session& session, Prefs& prefs, TorrentModel& model, bool
|
||||||
refreshSoon();
|
refreshSoon();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onSessionSourceChanged()
|
void MainWindow::onSessionSourceChanged()
|
||||||
{
|
{
|
||||||
|
@ -390,8 +383,8 @@ void MainWindow::initStatusBar()
|
||||||
{
|
{
|
||||||
ui.optionsButton->setMenu(createOptionsMenu());
|
ui.optionsButton->setMenu(createOptionsMenu());
|
||||||
|
|
||||||
int const minimumSpeedWidth = ui.downloadSpeedLabel->fontMetrics().width(Formatter::uploadSpeedToString(Speed::fromKBps(
|
int const minimumSpeedWidth =
|
||||||
999.99)));
|
ui.downloadSpeedLabel->fontMetrics().boundingRect(Formatter::uploadSpeedToString(Speed::fromKBps(999.99))).width();
|
||||||
ui.downloadSpeedLabel->setMinimumWidth(minimumSpeedWidth);
|
ui.downloadSpeedLabel->setMinimumWidth(minimumSpeedWidth);
|
||||||
ui.uploadSpeedLabel->setMinimumWidth(minimumSpeedWidth);
|
ui.uploadSpeedLabel->setMinimumWidth(minimumSpeedWidth);
|
||||||
|
|
||||||
|
@ -407,7 +400,7 @@ QMenu* MainWindow::createOptionsMenu()
|
||||||
int const stockSpeeds[] = { 5, 10, 20, 30, 40, 50, 75, 100, 150, 200, 250, 500, 750 };
|
int const stockSpeeds[] = { 5, 10, 20, 30, 40, 50, 75, 100, 150, 200, 250, 500, 750 };
|
||||||
int const currentValue = myPrefs.get<int>(pref);
|
int const currentValue = myPrefs.get<int>(pref);
|
||||||
|
|
||||||
QActionGroup* actionGroup = new QActionGroup(this);
|
auto* actionGroup = new QActionGroup(this);
|
||||||
|
|
||||||
offAction = menu->addAction(tr("Unlimited"));
|
offAction = menu->addAction(tr("Unlimited"));
|
||||||
offAction->setCheckable(true);
|
offAction->setCheckable(true);
|
||||||
|
@ -434,9 +427,9 @@ QMenu* MainWindow::createOptionsMenu()
|
||||||
auto const initSeedRatioSubMenu = [this](QMenu* menu, QAction*& offAction, QAction*& onAction, int pref, int enabledPref)
|
auto const initSeedRatioSubMenu = [this](QMenu* menu, QAction*& offAction, QAction*& onAction, int pref, int enabledPref)
|
||||||
{
|
{
|
||||||
double const stockRatios[] = { 0.25, 0.50, 0.75, 1, 1.5, 2, 3 };
|
double const stockRatios[] = { 0.25, 0.50, 0.75, 1, 1.5, 2, 3 };
|
||||||
double const currentValue = myPrefs.get<double>(pref);
|
auto const currentValue = myPrefs.get<double>(pref);
|
||||||
|
|
||||||
QActionGroup* actionGroup = new QActionGroup(this);
|
auto* actionGroup = new QActionGroup(this);
|
||||||
|
|
||||||
offAction = menu->addAction(tr("Seed Forever"));
|
offAction = menu->addAction(tr("Seed Forever"));
|
||||||
offAction->setCheckable(true);
|
offAction->setCheckable(true);
|
||||||
|
@ -460,7 +453,7 @@ QMenu* MainWindow::createOptionsMenu()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
QMenu* menu = new QMenu(this);
|
auto* menu = new QMenu(this);
|
||||||
|
|
||||||
initSpeedSubMenu(menu->addMenu(tr("Limit Download Speed")), myDlimitOffAction, myDlimitOnAction, Prefs::DSPEED,
|
initSpeedSubMenu(menu->addMenu(tr("Limit Download Speed")), myDlimitOffAction, myDlimitOnAction, Prefs::DSPEED,
|
||||||
Prefs::DSPEED_ENABLED);
|
Prefs::DSPEED_ENABLED);
|
||||||
|
@ -485,8 +478,8 @@ QMenu* MainWindow::createStatsModeMenu()
|
||||||
qMakePair(ui.action_SessionTransfer, SessionTransferStatsModeName)
|
qMakePair(ui.action_SessionTransfer, SessionTransferStatsModeName)
|
||||||
};
|
};
|
||||||
|
|
||||||
QActionGroup* actionGroup = new QActionGroup(this);
|
auto* actionGroup = new QActionGroup(this);
|
||||||
QMenu* menu = new QMenu(this);
|
auto* menu = new QMenu(this);
|
||||||
|
|
||||||
for (auto const& mode : statsModes)
|
for (auto const& mode : statsModes)
|
||||||
{
|
{
|
||||||
|
@ -561,7 +554,7 @@ void MainWindow::openProperties()
|
||||||
|
|
||||||
void MainWindow::setLocation()
|
void MainWindow::setLocation()
|
||||||
{
|
{
|
||||||
RelocateDialog* d = new RelocateDialog(mySession, myModel, getSelectedTorrents(), this);
|
auto* d = new RelocateDialog(mySession, myModel, getSelectedTorrents(), this);
|
||||||
d->setAttribute(Qt::WA_DeleteOnClose, true);
|
d->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
d->show();
|
d->show();
|
||||||
}
|
}
|
||||||
|
@ -947,7 +940,7 @@ torrent_ids_t MainWindow::getSelectedTorrents(bool withMetadataOnly) const
|
||||||
|
|
||||||
for (QModelIndex const& index : ui.listView->selectionModel()->selectedRows())
|
for (QModelIndex const& index : ui.listView->selectionModel()->selectedRows())
|
||||||
{
|
{
|
||||||
Torrent const* tor(index.data(TorrentModel::TorrentRole).value<Torrent const*>());
|
auto const* tor(index.data(TorrentModel::TorrentRole).value<Torrent const*>());
|
||||||
|
|
||||||
if (tor != nullptr && (!withMetadataOnly || tor->hasMetadata()))
|
if (tor != nullptr && (!withMetadataOnly || tor->hasMetadata()))
|
||||||
{
|
{
|
||||||
|
@ -1261,7 +1254,7 @@ QLatin1String const SHOW_OPTIONS_CHECKBOX_NAME("show-options-checkbox");
|
||||||
|
|
||||||
void MainWindow::newTorrent()
|
void MainWindow::newTorrent()
|
||||||
{
|
{
|
||||||
MakeDialog* dialog = new MakeDialog(mySession, this);
|
auto* dialog = new MakeDialog(mySession, this);
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
dialog->show();
|
dialog->show();
|
||||||
}
|
}
|
||||||
|
@ -1274,11 +1267,11 @@ void MainWindow::openTorrent()
|
||||||
d->setFileMode(QFileDialog::ExistingFiles);
|
d->setFileMode(QFileDialog::ExistingFiles);
|
||||||
d->setAttribute(Qt::WA_DeleteOnClose);
|
d->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
auto const l = qobject_cast<QGridLayout*>(d->layout());
|
auto* const l = qobject_cast<QGridLayout*>(d->layout());
|
||||||
|
|
||||||
if (l != nullptr)
|
if (l != nullptr)
|
||||||
{
|
{
|
||||||
QCheckBox* b = new QCheckBox(tr("Show &options dialog"));
|
auto* b = new QCheckBox(tr("Show &options dialog"));
|
||||||
b->setChecked(myPrefs.getBool(Prefs::OPTIONS_PROMPT));
|
b->setChecked(myPrefs.getBool(Prefs::OPTIONS_PROMPT));
|
||||||
b->setObjectName(SHOW_OPTIONS_CHECKBOX_NAME);
|
b->setObjectName(SHOW_OPTIONS_CHECKBOX_NAME);
|
||||||
l->addWidget(b, l->rowCount(), 0, 1, -1, Qt::AlignLeft);
|
l->addWidget(b, l->rowCount(), 0, 1, -1, Qt::AlignLeft);
|
||||||
|
@ -1310,11 +1303,11 @@ void MainWindow::addTorrents(QStringList const& filenames)
|
||||||
{
|
{
|
||||||
bool showOptions = myPrefs.getBool(Prefs::OPTIONS_PROMPT);
|
bool showOptions = myPrefs.getBool(Prefs::OPTIONS_PROMPT);
|
||||||
|
|
||||||
QFileDialog const* const fileDialog = qobject_cast<QFileDialog const*>(sender());
|
auto const* const fileDialog = qobject_cast<QFileDialog const*>(sender());
|
||||||
|
|
||||||
if (fileDialog != nullptr)
|
if (fileDialog != nullptr)
|
||||||
{
|
{
|
||||||
QCheckBox const* const b = fileDialog->findChild<QCheckBox const*>(SHOW_OPTIONS_CHECKBOX_NAME);
|
auto const* const b = fileDialog->findChild<QCheckBox const*>(SHOW_OPTIONS_CHECKBOX_NAME);
|
||||||
|
|
||||||
if (b != nullptr)
|
if (b != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -1332,7 +1325,7 @@ void MainWindow::addTorrent(AddData const& addMe, bool showOptions)
|
||||||
{
|
{
|
||||||
if (showOptions)
|
if (showOptions)
|
||||||
{
|
{
|
||||||
OptionsDialog* o = new OptionsDialog(mySession, myPrefs, addMe, this);
|
auto* o = new OptionsDialog(mySession, myPrefs, addMe, this);
|
||||||
o->show();
|
o->show();
|
||||||
qApp->alert(o);
|
qApp->alert(o);
|
||||||
}
|
}
|
||||||
|
@ -1355,7 +1348,7 @@ void MainWindow::removeTorrents(bool const deleteFiles)
|
||||||
|
|
||||||
for (QModelIndex const& index : ui.listView->selectionModel()->selectedRows())
|
for (QModelIndex const& index : ui.listView->selectionModel()->selectedRows())
|
||||||
{
|
{
|
||||||
Torrent const* tor(index.data(TorrentModel::TorrentRole).value<Torrent const*>());
|
auto const* tor(index.data(TorrentModel::TorrentRole).value<Torrent const*>());
|
||||||
ids.insert(tor->id());
|
ids.insert(tor->id());
|
||||||
|
|
||||||
if (tor->connectedPeers())
|
if (tor->connectedPeers())
|
||||||
|
@ -1429,7 +1422,7 @@ void MainWindow::removeTorrents(bool const deleteFiles)
|
||||||
msgBox.setDefaultButton(QMessageBox::Cancel);
|
msgBox.setDefaultButton(QMessageBox::Cancel);
|
||||||
msgBox.setIcon(QMessageBox::Question);
|
msgBox.setIcon(QMessageBox::Question);
|
||||||
// hack needed to keep the dialog from being too narrow
|
// hack needed to keep the dialog from being too narrow
|
||||||
auto layout = qobject_cast<QGridLayout*>(msgBox.layout());
|
auto* layout = qobject_cast<QGridLayout*>(msgBox.layout());
|
||||||
|
|
||||||
if (layout == nullptr)
|
if (layout == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -1437,7 +1430,7 @@ void MainWindow::removeTorrents(bool const deleteFiles)
|
||||||
msgBox.setLayout(layout);
|
msgBox.setLayout(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSpacerItem* spacer = new QSpacerItem(450, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
auto* spacer = new QSpacerItem(450, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||||
layout->addItem(spacer, layout->rowCount(), 0, 1, layout->columnCount());
|
layout->addItem(spacer, layout->rowCount(), 0, 1, layout->columnCount());
|
||||||
|
|
||||||
if (msgBox.exec() == QMessageBox::Ok)
|
if (msgBox.exec() == QMessageBox::Ok)
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
MakeProgressDialog(Session& session, tr_metainfo_builder& builder, QWidget* parent = nullptr);
|
MakeProgressDialog(Session& session, tr_metainfo_builder& builder, QWidget* parent = nullptr);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onButtonBoxClicked(QAbstractButton*);
|
void onButtonBoxClicked(QAbstractButton* button);
|
||||||
void onProgress();
|
void onProgress();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -181,7 +181,7 @@ void MakeDialog::makeTorrent()
|
||||||
trackers.size(), comment.isEmpty() ? nullptr : comment.toUtf8().constData(), ui.privateCheck->isChecked());
|
trackers.size(), comment.isEmpty() ? nullptr : comment.toUtf8().constData(), ui.privateCheck->isChecked());
|
||||||
|
|
||||||
// pop up the dialog
|
// pop up the dialog
|
||||||
MakeProgressDialog* dialog = new MakeProgressDialog(mySession, *myBuilder, this);
|
auto* dialog = new MakeProgressDialog(mySession, *myBuilder, this);
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
dialog->open();
|
dialog->open();
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ MakeDialog::MakeDialog(Session& session, QWidget* parent) :
|
||||||
ui.sourceFolderButton->setMode(PathButton::DirectoryMode);
|
ui.sourceFolderButton->setMode(PathButton::DirectoryMode);
|
||||||
ui.sourceFileButton->setMode(PathButton::FileMode);
|
ui.sourceFileButton->setMode(PathButton::FileMode);
|
||||||
|
|
||||||
ColumnResizer* cr(new ColumnResizer(this));
|
auto* cr = new ColumnResizer(this);
|
||||||
cr->addLayout(ui.filesSectionLayout);
|
cr->addLayout(ui.filesSectionLayout);
|
||||||
cr->addLayout(ui.propertiesSectionLayout);
|
cr->addLayout(ui.propertiesSectionLayout);
|
||||||
cr->update();
|
cr->update();
|
||||||
|
@ -258,9 +258,7 @@ MakeDialog::MakeDialog(Session& session, QWidget* parent) :
|
||||||
onSourceChanged();
|
onSourceChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeDialog::~MakeDialog()
|
MakeDialog::~MakeDialog() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
****
|
****
|
||||||
|
|
|
@ -90,7 +90,7 @@ OptionsDialog::OptionsDialog(Session& session, Prefs const& prefs, AddData const
|
||||||
|
|
||||||
if (myIsLocal)
|
if (myIsLocal)
|
||||||
{
|
{
|
||||||
myLocalDestination = downloadDir;
|
myLocalDestination.setPath(downloadDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(ui.destinationButton, SIGNAL(pathChanged(QString)), this, SLOT(onDestinationChanged()));
|
connect(ui.destinationButton, SIGNAL(pathChanged(QString)), this, SLOT(onDestinationChanged()));
|
||||||
|
@ -281,7 +281,7 @@ void OptionsDialog::onAccepted()
|
||||||
|
|
||||||
for (int i = 0, n = myWanted.size(); i < n; ++i)
|
for (int i = 0, n = myWanted.size(); i < n; ++i)
|
||||||
{
|
{
|
||||||
if (myWanted.at(i) == false)
|
if (!myWanted.at(i))
|
||||||
{
|
{
|
||||||
tr_variantListAddInt(l, i);
|
tr_variantListAddInt(l, i);
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ void OptionsDialog::onDestinationChanged()
|
||||||
{
|
{
|
||||||
if (ui.destinationStack->currentWidget() == ui.destinationButton)
|
if (ui.destinationStack->currentWidget() == ui.destinationButton)
|
||||||
{
|
{
|
||||||
myLocalDestination = ui.destinationButton->path();
|
myLocalDestination.setPath(ui.destinationButton->path());
|
||||||
ui.freeSpaceLabel->setPath(myLocalDestination.absolutePath());
|
ui.freeSpaceLabel->setPath(myLocalDestination.absolutePath());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
virtual ~OptionsDialog();
|
virtual ~OptionsDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef QMap<uint32_t, int32_t> mybins_t;
|
using mybins_t = QMap<uint32_t, int32_t>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reload();
|
void reload();
|
||||||
|
|
|
@ -106,7 +106,7 @@ void PathButton::paintEvent(QPaintEvent* /*event*/)
|
||||||
|
|
||||||
void PathButton::onClicked()
|
void PathButton::onClicked()
|
||||||
{
|
{
|
||||||
QFileDialog* dialog = new QFileDialog(window(), effectiveTitle());
|
auto* dialog = new QFileDialog(window(), effectiveTitle());
|
||||||
dialog->setFileMode(isDirMode() ? QFileDialog::Directory : QFileDialog::ExistingFile);
|
dialog->setFileMode(isDirMode() ? QFileDialog::Directory : QFileDialog::ExistingFile);
|
||||||
|
|
||||||
if (isDirMode())
|
if (isDirMode())
|
||||||
|
|
|
@ -341,7 +341,7 @@ void Prefs::initDefaults(tr_variant* d)
|
||||||
tr_variantDictAddInt(d, TR_KEY_main_window_width, 300);
|
tr_variantDictAddInt(d, TR_KEY_main_window_width, 300);
|
||||||
tr_variantDictAddInt(d, TR_KEY_main_window_x, 50);
|
tr_variantDictAddInt(d, TR_KEY_main_window_x, 50);
|
||||||
tr_variantDictAddInt(d, TR_KEY_main_window_y, 50);
|
tr_variantDictAddInt(d, TR_KEY_main_window_y, 50);
|
||||||
tr_variantDictAddInt(d, TR_KEY_remote_session_port, atoi(TR_DEFAULT_RPC_PORT_STR));
|
tr_variantDictAddInt(d, TR_KEY_remote_session_port, strtol(TR_DEFAULT_RPC_PORT_STR, nullptr, 0));
|
||||||
tr_variantDictAddStr(d, TR_KEY_download_dir, tr_getDefaultDownloadDir());
|
tr_variantDictAddStr(d, TR_KEY_download_dir, tr_getDefaultDownloadDir());
|
||||||
tr_variantDictAddStr(d, TR_KEY_filter_mode, "all");
|
tr_variantDictAddStr(d, TR_KEY_filter_mode, "all");
|
||||||
tr_variantDictAddStr(d, TR_KEY_main_window_layout_order, "menu,toolbar,filter,list,statusbar");
|
tr_variantDictAddStr(d, TR_KEY_main_window_layout_order, "menu,toolbar,filter,list,statusbar");
|
||||||
|
|
|
@ -271,7 +271,7 @@ void PrefsDialog::lineEditingFinished()
|
||||||
|
|
||||||
if (prefWidget.is<QLineEdit>())
|
if (prefWidget.is<QLineEdit>())
|
||||||
{
|
{
|
||||||
QLineEdit const* const lineEdit = prefWidget.as<QLineEdit>();
|
auto const* const lineEdit = prefWidget.as<QLineEdit>();
|
||||||
|
|
||||||
if (lineEdit->isModified())
|
if (lineEdit->isModified())
|
||||||
{
|
{
|
||||||
|
@ -363,7 +363,7 @@ void PrefsDialog::initSpeedTab()
|
||||||
mySchedWidgets << ui.altSpeedLimitStartTimeEdit << ui.altSpeedLimitToLabel << ui.altSpeedLimitEndTimeEdit <<
|
mySchedWidgets << ui.altSpeedLimitStartTimeEdit << ui.altSpeedLimitToLabel << ui.altSpeedLimitEndTimeEdit <<
|
||||||
ui.altSpeedLimitDaysLabel << ui.altSpeedLimitDaysCombo;
|
ui.altSpeedLimitDaysLabel << ui.altSpeedLimitDaysCombo;
|
||||||
|
|
||||||
ColumnResizer* cr(new ColumnResizer(this));
|
auto* cr = new ColumnResizer(this);
|
||||||
cr->addLayout(ui.speedLimitsSectionLayout);
|
cr->addLayout(ui.speedLimitsSectionLayout);
|
||||||
cr->addLayout(ui.altSpeedLimitsSectionLayout);
|
cr->addLayout(ui.altSpeedLimitsSectionLayout);
|
||||||
cr->update();
|
cr->update();
|
||||||
|
@ -418,7 +418,7 @@ void PrefsDialog::initNetworkTab()
|
||||||
linkWidgetToPref(ui.enableDhtCheck, Prefs::DHT_ENABLED);
|
linkWidgetToPref(ui.enableDhtCheck, Prefs::DHT_ENABLED);
|
||||||
linkWidgetToPref(ui.enableLpdCheck, Prefs::LPD_ENABLED);
|
linkWidgetToPref(ui.enableLpdCheck, Prefs::LPD_ENABLED);
|
||||||
|
|
||||||
ColumnResizer* cr(new ColumnResizer(this));
|
auto* cr = new ColumnResizer(this);
|
||||||
cr->addLayout(ui.incomingPeersSectionLayout);
|
cr->addLayout(ui.incomingPeersSectionLayout);
|
||||||
cr->addLayout(ui.peerLimitsSectionLayout);
|
cr->addLayout(ui.peerLimitsSectionLayout);
|
||||||
cr->update();
|
cr->update();
|
||||||
|
@ -479,7 +479,7 @@ void PrefsDialog::initPrivacyTab()
|
||||||
|
|
||||||
myBlockWidgets << ui.blocklistEdit << ui.blocklistStatusLabel << ui.updateBlocklistButton << ui.autoUpdateBlocklistCheck;
|
myBlockWidgets << ui.blocklistEdit << ui.blocklistStatusLabel << ui.updateBlocklistButton << ui.autoUpdateBlocklistCheck;
|
||||||
|
|
||||||
ColumnResizer* cr(new ColumnResizer(this));
|
auto* cr = new ColumnResizer(this);
|
||||||
cr->addLayout(ui.encryptionSectionLayout);
|
cr->addLayout(ui.encryptionSectionLayout);
|
||||||
cr->addLayout(ui.blocklistSectionLayout);
|
cr->addLayout(ui.blocklistSectionLayout);
|
||||||
cr->update();
|
cr->update();
|
||||||
|
@ -564,7 +564,7 @@ void PrefsDialog::initDownloadingTab()
|
||||||
linkWidgetToPref(ui.completionScriptButton, Prefs::SCRIPT_TORRENT_DONE_FILENAME);
|
linkWidgetToPref(ui.completionScriptButton, Prefs::SCRIPT_TORRENT_DONE_FILENAME);
|
||||||
linkWidgetToPref(ui.completionScriptEdit, Prefs::SCRIPT_TORRENT_DONE_FILENAME);
|
linkWidgetToPref(ui.completionScriptEdit, Prefs::SCRIPT_TORRENT_DONE_FILENAME);
|
||||||
|
|
||||||
ColumnResizer* cr(new ColumnResizer(this));
|
auto* cr = new ColumnResizer(this);
|
||||||
cr->addLayout(ui.addingSectionLayout);
|
cr->addLayout(ui.addingSectionLayout);
|
||||||
cr->addLayout(ui.downloadQueueSectionLayout);
|
cr->addLayout(ui.downloadQueueSectionLayout);
|
||||||
cr->addLayout(ui.incompleteSectionLayout);
|
cr->addLayout(ui.incompleteSectionLayout);
|
||||||
|
@ -639,9 +639,7 @@ PrefsDialog::PrefsDialog(Session& session, Prefs& prefs, QWidget* parent) :
|
||||||
adjustSize();
|
adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
PrefsDialog::~PrefsDialog()
|
PrefsDialog::~PrefsDialog() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrefsDialog::setPref(int key, QVariant const& v)
|
void PrefsDialog::setPref(int key, QVariant const& v)
|
||||||
{
|
{
|
||||||
|
@ -745,7 +743,7 @@ void PrefsDialog::refreshPref(int key)
|
||||||
{
|
{
|
||||||
if (key == Prefs::ENCRYPTION)
|
if (key == Prefs::ENCRYPTION)
|
||||||
{
|
{
|
||||||
QComboBox* comboBox(qobject_cast<QComboBox*>(w));
|
auto* comboBox = qobject_cast<QComboBox*>(w);
|
||||||
int const index = comboBox->findData(myPrefs.getInt(key));
|
int const index = comboBox->findData(myPrefs.getInt(key));
|
||||||
comboBox->setCurrentIndex(index);
|
comboBox->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
virtual ~PrefsDialog();
|
virtual ~PrefsDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef QMap<int, QWidget*> key2widget_t;
|
using key2widget_t = QMap<int, QWidget*>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool updateWidgetValue(QWidget* widget, int prefKey);
|
bool updateWidgetValue(QWidget* widget, int prefKey);
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
|
|
||||||
#include <event2/buffer.h>
|
|
||||||
|
|
||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
#include <libtransmission/rpcimpl.h>
|
#include <libtransmission/rpcimpl.h>
|
||||||
#include <libtransmission/utils.h> // tr_free
|
#include <libtransmission/utils.h> // tr_free
|
||||||
|
@ -206,7 +204,7 @@ void RpcClient::localSessionCallback(tr_session* s, tr_variant* response, void*
|
||||||
{
|
{
|
||||||
Q_UNUSED(s)
|
Q_UNUSED(s)
|
||||||
|
|
||||||
RpcClient* self = static_cast<RpcClient*>(vself);
|
auto* self = static_cast<RpcClient*>(vself);
|
||||||
|
|
||||||
TrVariantPtr json = createVariant();
|
TrVariantPtr json = createVariant();
|
||||||
*json = *response;
|
*json = *response;
|
||||||
|
@ -221,7 +219,7 @@ void RpcClient::networkRequestFinished(QNetworkReply* reply)
|
||||||
{
|
{
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
QFutureInterface<RpcResponse> promise = reply->property(REQUEST_FUTUREINTERFACE_PROPERTY_KEY).
|
auto promise = reply->property(REQUEST_FUTUREINTERFACE_PROPERTY_KEY).
|
||||||
value<QFutureInterface<RpcResponse>>();
|
value<QFutureInterface<RpcResponse>>();
|
||||||
|
|
||||||
#ifdef DEBUG_HTTP
|
#ifdef DEBUG_HTTP
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
class QByteArray;
|
class QByteArray;
|
||||||
class QNetworkAccessManager;
|
class QNetworkAccessManager;
|
||||||
|
|
||||||
typedef std::shared_ptr<tr_variant> TrVariantPtr;
|
using TrVariantPtr = std::shared_ptr<tr_variant>;
|
||||||
Q_DECLARE_METATYPE(TrVariantPtr)
|
Q_DECLARE_METATYPE(TrVariantPtr)
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
|
@ -45,7 +45,7 @@ struct RpcResponse
|
||||||
Q_DECLARE_METATYPE(QFutureInterface<RpcResponse>)
|
Q_DECLARE_METATYPE(QFutureInterface<RpcResponse>)
|
||||||
|
|
||||||
// The response future -- the RPC engine returns one for each request made.
|
// The response future -- the RPC engine returns one for each request made.
|
||||||
typedef QFuture<RpcResponse> RpcResponseFuture;
|
using RpcResponseFuture = QFuture<RpcResponse>;
|
||||||
|
|
||||||
class RpcClient : public QObject
|
class RpcClient : public QObject
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,10 +50,10 @@ public:
|
||||||
private:
|
private:
|
||||||
// Internally queued function. Takes the last response future, makes a
|
// Internally queued function. Takes the last response future, makes a
|
||||||
// request and returns a new response future.
|
// request and returns a new response future.
|
||||||
typedef std::function<RpcResponseFuture(RpcResponseFuture const&)> QueuedFunction;
|
using QueuedFunction = std::function<RpcResponseFuture(RpcResponseFuture const&)>;
|
||||||
|
|
||||||
// Internally stored error handler function. Takes the last response future and returns nothing.
|
// Internally stored error handler function. Takes the last response future and returns nothing.
|
||||||
typedef std::function<void (RpcResponseFuture const&)> ErrorHandlerFunction;
|
using ErrorHandlerFunction = std::function<void (RpcResponseFuture const&)>;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void stepFinished();
|
void stepFinished();
|
||||||
|
@ -65,7 +65,7 @@ private:
|
||||||
|
|
||||||
// normal closure, takes response and returns new future
|
// normal closure, takes response and returns new future
|
||||||
template<typename Func, typename std::enable_if<
|
template<typename Func, typename std::enable_if<
|
||||||
std::is_same<typename std::result_of<Func(RpcResponse const&)>::type, RpcResponseFuture>::value
|
std::is_same_v<typename std::invoke_result_t<Func, RpcResponse const&>, RpcResponseFuture>
|
||||||
>::type* = nullptr>
|
>::type* = nullptr>
|
||||||
QueuedFunction normalizeFunc(Func const& func)
|
QueuedFunction normalizeFunc(Func const& func)
|
||||||
{
|
{
|
||||||
|
@ -77,7 +77,7 @@ private:
|
||||||
|
|
||||||
// closure without argument (first step), takes nothing and returns new future
|
// closure without argument (first step), takes nothing and returns new future
|
||||||
template<typename Func, typename std::enable_if<
|
template<typename Func, typename std::enable_if<
|
||||||
std::is_same<typename std::result_of<Func()>::type, RpcResponseFuture>::value
|
std::is_same_v<typename std::invoke_result_t<Func>, RpcResponseFuture>
|
||||||
>::type* = nullptr>
|
>::type* = nullptr>
|
||||||
QueuedFunction normalizeFunc(Func const& func)
|
QueuedFunction normalizeFunc(Func const& func)
|
||||||
{
|
{
|
||||||
|
@ -89,7 +89,7 @@ private:
|
||||||
|
|
||||||
// closure without return value ("auxiliary"), takes response and returns nothing -- internally we reuse the last future
|
// closure without return value ("auxiliary"), takes response and returns nothing -- internally we reuse the last future
|
||||||
template<typename Func, typename std::enable_if<
|
template<typename Func, typename std::enable_if<
|
||||||
std::is_same<typename std::result_of<Func(RpcResponse const&)>::type, void>::value
|
std::is_same_v<typename std::invoke_result_t<Func, RpcResponse const&>, void>
|
||||||
>::type* = nullptr>
|
>::type* = nullptr>
|
||||||
QueuedFunction normalizeFunc(Func const& func)
|
QueuedFunction normalizeFunc(Func const& func)
|
||||||
{
|
{
|
||||||
|
@ -102,7 +102,7 @@ private:
|
||||||
|
|
||||||
// closure without argument and return value, takes nothing and returns nothing -- next function will also get nothing
|
// closure without argument and return value, takes nothing and returns nothing -- next function will also get nothing
|
||||||
template<typename Func, typename std::enable_if<
|
template<typename Func, typename std::enable_if<
|
||||||
std::is_same<typename std::result_of<Func()>::type, void>::value
|
std::is_same_v<typename std::invoke_result_t<Func>, void>
|
||||||
>::type* = nullptr>
|
>::type* = nullptr>
|
||||||
QueuedFunction normalizeFunc(Func const& func)
|
QueuedFunction normalizeFunc(Func const& func)
|
||||||
{
|
{
|
||||||
|
@ -115,7 +115,7 @@ private:
|
||||||
|
|
||||||
// normal error handler, takes last response
|
// normal error handler, takes last response
|
||||||
template<typename Func, typename std::enable_if<
|
template<typename Func, typename std::enable_if<
|
||||||
std::is_same<typename std::result_of<Func(RpcResponse const&)>::type, void>::value
|
std::is_same_v<typename std::invoke_result_t<Func, RpcResponse const&>, void>
|
||||||
>::type* = nullptr>
|
>::type* = nullptr>
|
||||||
ErrorHandlerFunction normalizeErrorHandler(Func const& func)
|
ErrorHandlerFunction normalizeErrorHandler(Func const& func)
|
||||||
{
|
{
|
||||||
|
@ -127,7 +127,7 @@ private:
|
||||||
|
|
||||||
// error handler without an argument, takes nothing
|
// error handler without an argument, takes nothing
|
||||||
template<typename Func, typename std::enable_if<
|
template<typename Func, typename std::enable_if<
|
||||||
std::is_same<typename std::result_of<Func()>::type, void>::value
|
std::is_same_v<typename std::invoke_result_t<Func>, void>
|
||||||
>::type* = nullptr>
|
>::type* = nullptr>
|
||||||
ErrorHandlerFunction normalizeErrorHandler(Func const& func)
|
ErrorHandlerFunction normalizeErrorHandler(Func const& func)
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
typedef Torrent::KeyList KeyList;
|
using KeyList = Torrent::KeyList;
|
||||||
|
|
||||||
void addList(tr_variant* list, KeyList const& keys)
|
void addList(tr_variant* list, KeyList const& keys)
|
||||||
{
|
{
|
||||||
|
@ -94,7 +94,7 @@ void Session::sessionSet(tr_quark const key, QVariant const& value)
|
||||||
|
|
||||||
void Session::portTest()
|
void Session::portTest()
|
||||||
{
|
{
|
||||||
RpcQueue* q = new RpcQueue();
|
auto* q = new RpcQueue();
|
||||||
|
|
||||||
q->add([this]()
|
q->add([this]()
|
||||||
{
|
{
|
||||||
|
@ -123,7 +123,7 @@ void Session::copyMagnetLinkToClipboard(int torrentId)
|
||||||
tr_variantListAddInt(tr_variantDictAddList(&args, TR_KEY_ids, 1), torrentId);
|
tr_variantListAddInt(tr_variantDictAddList(&args, TR_KEY_ids, 1), torrentId);
|
||||||
tr_variantListAddStr(tr_variantDictAddList(&args, TR_KEY_fields, 1), "magnetLink");
|
tr_variantListAddStr(tr_variantDictAddList(&args, TR_KEY_fields, 1), "magnetLink");
|
||||||
|
|
||||||
RpcQueue* q = new RpcQueue();
|
auto* q = new RpcQueue();
|
||||||
|
|
||||||
q->add([this, &args]()
|
q->add([this, &args]()
|
||||||
{
|
{
|
||||||
|
@ -516,7 +516,7 @@ void Session::torrentRenamePath(torrent_ids_t const& ids, QString const& oldpath
|
||||||
tr_variantDictAddStr(&args, TR_KEY_path, oldpath.toUtf8().constData());
|
tr_variantDictAddStr(&args, TR_KEY_path, oldpath.toUtf8().constData());
|
||||||
tr_variantDictAddStr(&args, TR_KEY_name, newname.toUtf8().constData());
|
tr_variantDictAddStr(&args, TR_KEY_name, newname.toUtf8().constData());
|
||||||
|
|
||||||
RpcQueue* q = new RpcQueue();
|
auto* q = new RpcQueue();
|
||||||
|
|
||||||
q->add([this, &args]()
|
q->add([this, &args]()
|
||||||
{
|
{
|
||||||
|
@ -529,7 +529,7 @@ void Session::torrentRenamePath(torrent_ids_t const& ids, QString const& oldpath
|
||||||
tr_variantDictFindStr(r.args.get(), TR_KEY_path, &path, nullptr);
|
tr_variantDictFindStr(r.args.get(), TR_KEY_path, &path, nullptr);
|
||||||
tr_variantDictFindStr(r.args.get(), TR_KEY_name, &name, nullptr);
|
tr_variantDictFindStr(r.args.get(), TR_KEY_name, &name, nullptr);
|
||||||
|
|
||||||
QMessageBox* d = new QMessageBox(QMessageBox::Information, tr("Error Renaming Path"),
|
auto* d = new QMessageBox(QMessageBox::Information, tr("Error Renaming Path"),
|
||||||
tr("<p><b>Unable to rename \"%1\" as \"%2\": %3.</b></p><p>Please correct the errors and try again.</p>").
|
tr("<p><b>Unable to rename \"%1\" as \"%2\": %3.</b></p><p>Please correct the errors and try again.</p>").
|
||||||
arg(QString::fromUtf8(path)).arg(QString::fromUtf8(name)).arg(r.result), QMessageBox::Close,
|
arg(QString::fromUtf8(path)).arg(QString::fromUtf8(name)).arg(r.result), QMessageBox::Close,
|
||||||
qApp->activeWindow());
|
qApp->activeWindow());
|
||||||
|
@ -553,7 +553,7 @@ void Session::refreshTorrents(torrent_ids_t const& ids, KeyList const& keys)
|
||||||
addList(tr_variantDictAddList(&args, TR_KEY_fields, 0), keys);
|
addList(tr_variantDictAddList(&args, TR_KEY_fields, 0), keys);
|
||||||
addOptionalIds(&args, ids);
|
addOptionalIds(&args, ids);
|
||||||
|
|
||||||
RpcQueue* q = new RpcQueue();
|
auto* q = new RpcQueue();
|
||||||
|
|
||||||
q->add([this, &args]()
|
q->add([this, &args]()
|
||||||
{
|
{
|
||||||
|
@ -596,7 +596,7 @@ void Session::sendTorrentRequest(char const* request, torrent_ids_t const& ids)
|
||||||
tr_variantInitDict(&args, 1);
|
tr_variantInitDict(&args, 1);
|
||||||
addOptionalIds(&args, ids);
|
addOptionalIds(&args, ids);
|
||||||
|
|
||||||
RpcQueue* q = new RpcQueue();
|
auto* q = new RpcQueue();
|
||||||
|
|
||||||
q->add([this, request, &args]()
|
q->add([this, request, &args]()
|
||||||
{
|
{
|
||||||
|
@ -663,7 +663,7 @@ void Session::initTorrents(torrent_ids_t const& ids)
|
||||||
|
|
||||||
void Session::refreshSessionStats()
|
void Session::refreshSessionStats()
|
||||||
{
|
{
|
||||||
RpcQueue* q = new RpcQueue();
|
auto* q = new RpcQueue();
|
||||||
|
|
||||||
q->add([this]()
|
q->add([this]()
|
||||||
{
|
{
|
||||||
|
@ -680,7 +680,7 @@ void Session::refreshSessionStats()
|
||||||
|
|
||||||
void Session::refreshSessionInfo()
|
void Session::refreshSessionInfo()
|
||||||
{
|
{
|
||||||
RpcQueue* q = new RpcQueue();
|
auto* q = new RpcQueue();
|
||||||
|
|
||||||
q->add([this]()
|
q->add([this]()
|
||||||
{
|
{
|
||||||
|
@ -697,7 +697,7 @@ void Session::refreshSessionInfo()
|
||||||
|
|
||||||
void Session::updateBlocklist()
|
void Session::updateBlocklist()
|
||||||
{
|
{
|
||||||
RpcQueue* q = new RpcQueue();
|
auto* q = new RpcQueue();
|
||||||
|
|
||||||
q->add([this]()
|
q->add([this]()
|
||||||
{
|
{
|
||||||
|
@ -972,7 +972,7 @@ void Session::addTorrent(AddData const& addMe, tr_variant* args, bool trashOrigi
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
RpcQueue* q = new RpcQueue();
|
auto* q = new RpcQueue();
|
||||||
|
|
||||||
q->add([this, args]()
|
q->add([this, args]()
|
||||||
{
|
{
|
||||||
|
@ -980,7 +980,7 @@ void Session::addTorrent(AddData const& addMe, tr_variant* args, bool trashOrigi
|
||||||
},
|
},
|
||||||
[addMe](RpcResponse const& r)
|
[addMe](RpcResponse const& r)
|
||||||
{
|
{
|
||||||
QMessageBox* d = new QMessageBox(QMessageBox::Warning, tr("Error Adding Torrent"),
|
auto* d = new QMessageBox(QMessageBox::Warning, tr("Error Adding Torrent"),
|
||||||
QString::fromLatin1("<p><b>%1</b></p><p>%2</p>").arg(r.result).arg(addMe.readableName()), QMessageBox::Close,
|
QString::fromLatin1("<p><b>%1</b></p><p>%2</p>").arg(r.result).arg(addMe.readableName()), QMessageBox::Close,
|
||||||
qApp->activeWindow());
|
qApp->activeWindow());
|
||||||
QObject::connect(d, &QMessageBox::rejected, d, &QMessageBox::deleteLater);
|
QObject::connect(d, &QMessageBox::rejected, d, &QMessageBox::deleteLater);
|
||||||
|
@ -1001,7 +1001,7 @@ void Session::addTorrent(AddData const& addMe, tr_variant* args, bool trashOrigi
|
||||||
if (tr_variantDictFindStr(dup, TR_KEY_name, &str, nullptr))
|
if (tr_variantDictFindStr(dup, TR_KEY_name, &str, nullptr))
|
||||||
{
|
{
|
||||||
QString const name = QString::fromUtf8(str);
|
QString const name = QString::fromUtf8(str);
|
||||||
QMessageBox* d = new QMessageBox(QMessageBox::Warning, tr("Add Torrent"),
|
auto* d = new QMessageBox(QMessageBox::Warning, tr("Add Torrent"),
|
||||||
tr("<p><b>Unable to add \"%1\".</b></p><p>It is a duplicate of \"%2\" which is already added.</p>").
|
tr("<p><b>Unable to add \"%1\".</b></p><p>It is a duplicate of \"%2\" which is already added.</p>").
|
||||||
arg(addMe.readableShortName()).arg(name), QMessageBox::Close, qApp->activeWindow());
|
arg(addMe.readableShortName()).arg(name), QMessageBox::Close, qApp->activeWindow());
|
||||||
QObject::connect(d, &QMessageBox::rejected, d, &QMessageBox::deleteLater);
|
QObject::connect(d, &QMessageBox::rejected, d, &QMessageBox::deleteLater);
|
||||||
|
|
|
@ -25,7 +25,7 @@ StatsDialog::StatsDialog(Session& session, QWidget* parent) :
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
ColumnResizer* cr(new ColumnResizer(this));
|
auto* cr = new ColumnResizer(this);
|
||||||
cr->addLayout(ui.currentSessionSectionLayout);
|
cr->addLayout(ui.currentSessionSectionLayout);
|
||||||
cr->addLayout(ui.totalSectionLayout);
|
cr->addLayout(ui.totalSectionLayout);
|
||||||
cr->update();
|
cr->update();
|
||||||
|
@ -38,9 +38,7 @@ StatsDialog::StatsDialog(Session& session, QWidget* parent) :
|
||||||
mySession.refreshSessionStats();
|
mySession.refreshSessionStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
StatsDialog::~StatsDialog()
|
StatsDialog::~StatsDialog() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatsDialog::setVisible(bool visible)
|
void StatsDialog::setVisible(bool visible)
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,7 +57,6 @@ public:
|
||||||
QRect barRect;
|
QRect barRect;
|
||||||
QRect progressRect;
|
QRect progressRect;
|
||||||
|
|
||||||
public:
|
|
||||||
ItemLayout(QString const& nameText, QString const& statusText, QString const& progressText, QIcon const& emblemIcon,
|
ItemLayout(QString const& nameText, QString const& statusText, QString const& progressText, QIcon const& emblemIcon,
|
||||||
QFont const& baseFont, Qt::LayoutDirection direction, QPoint const& topLeft, int width);
|
QFont const& baseFont, Qt::LayoutDirection direction, QPoint const& topLeft, int width);
|
||||||
|
|
||||||
|
@ -439,7 +438,7 @@ QIcon& TorrentDelegate::getWarningEmblem() const
|
||||||
|
|
||||||
void TorrentDelegate::paint(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const
|
void TorrentDelegate::paint(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const
|
||||||
{
|
{
|
||||||
Torrent const* tor(index.data(TorrentModel::TorrentRole).value<Torrent const*>());
|
auto const* tor(index.data(TorrentModel::TorrentRole).value<Torrent const*>());
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setClipRect(option.rect);
|
painter->setClipRect(option.rect);
|
||||||
drawTorrent(painter, option, *tor);
|
drawTorrent(painter, option, *tor);
|
||||||
|
|
|
@ -62,7 +62,6 @@ public:
|
||||||
QRect statusRect;
|
QRect statusRect;
|
||||||
QRect barRect;
|
QRect barRect;
|
||||||
|
|
||||||
public:
|
|
||||||
ItemLayout(QString const& nameText, QString const& statusText, QIcon const& emblemIcon, QFont const& baseFont,
|
ItemLayout(QString const& nameText, QString const& statusText, QIcon const& emblemIcon, QFont const& baseFont,
|
||||||
Qt::LayoutDirection direction, QPoint const& topLeft, int width);
|
Qt::LayoutDirection direction, QPoint const& topLeft, int width);
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,7 @@ TorrentFilter::TorrentFilter(Prefs const& prefs) :
|
||||||
refilter();
|
refilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
TorrentFilter::~TorrentFilter()
|
TorrentFilter::~TorrentFilter() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
****
|
****
|
||||||
|
@ -101,8 +99,8 @@ int compare(T const a, T const b)
|
||||||
bool TorrentFilter::lessThan(QModelIndex const& left, QModelIndex const& right) const
|
bool TorrentFilter::lessThan(QModelIndex const& left, QModelIndex const& right) const
|
||||||
{
|
{
|
||||||
int val = 0;
|
int val = 0;
|
||||||
Torrent const* a = sourceModel()->data(left, TorrentModel::TorrentRole).value<Torrent const*>();
|
auto const* a = sourceModel()->data(left, TorrentModel::TorrentRole).value<Torrent const*>();
|
||||||
Torrent const* b = sourceModel()->data(right, TorrentModel::TorrentRole).value<Torrent const*>();
|
auto const* b = sourceModel()->data(right, TorrentModel::TorrentRole).value<Torrent const*>();
|
||||||
|
|
||||||
switch (myPrefs.get<SortMode>(Prefs::SORT_MODE).mode())
|
switch (myPrefs.get<SortMode>(Prefs::SORT_MODE).mode())
|
||||||
{
|
{
|
||||||
|
@ -285,12 +283,12 @@ bool TorrentFilter::activityFilterAcceptsTorrent(Torrent const* tor, FilterMode
|
||||||
bool TorrentFilter::filterAcceptsRow(int sourceRow, QModelIndex const& sourceParent) const
|
bool TorrentFilter::filterAcceptsRow(int sourceRow, QModelIndex const& sourceParent) const
|
||||||
{
|
{
|
||||||
QModelIndex childIndex = sourceModel()->index(sourceRow, 0, sourceParent);
|
QModelIndex childIndex = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||||
Torrent const* tor = childIndex.model()->data(childIndex, TorrentModel::TorrentRole).value<Torrent const*>();
|
auto const* tor = childIndex.model()->data(childIndex, TorrentModel::TorrentRole).value<Torrent const*>();
|
||||||
bool accepts = true;
|
bool accepts = true;
|
||||||
|
|
||||||
if (accepts)
|
if (accepts)
|
||||||
{
|
{
|
||||||
FilterMode const m = myPrefs.get<FilterMode>(Prefs::FILTER_MODE);
|
auto const m = myPrefs.get<FilterMode>(Prefs::FILTER_MODE);
|
||||||
accepts = activityFilterAcceptsTorrent(tor, m);
|
accepts = activityFilterAcceptsTorrent(tor, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ QVariant TorrentModel::data(QModelIndex const& index, int role) const
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TorrentRole:
|
case TorrentRole:
|
||||||
var = qVariantFromValue(t);
|
var = QVariant::fromValue(t);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -443,7 +443,7 @@ void TorrentModel::rowsAdd(torrents_t const& torrents)
|
||||||
{
|
{
|
||||||
for (auto const& tor : torrents)
|
for (auto const& tor : torrents)
|
||||||
{
|
{
|
||||||
auto const it = std::lower_bound(myTorrents.begin(), myTorrents.end(), tor, compare);
|
auto* const it = std::lower_bound(myTorrents.begin(), myTorrents.end(), tor, compare);
|
||||||
auto const row = std::distance(myTorrents.begin(), it);
|
auto const row = std::distance(myTorrents.begin(), it);
|
||||||
|
|
||||||
beginInsertRows(QModelIndex(), row, row);
|
beginInsertRows(QModelIndex(), row, row);
|
||||||
|
|
|
@ -29,7 +29,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// QWidget
|
// QWidget
|
||||||
virtual QSize sizeHint() const
|
QSize sizeHint() const override
|
||||||
{
|
{
|
||||||
QStyleOptionHeader option;
|
QStyleOptionHeader option;
|
||||||
option.rect = QRect(0, 0, 100, 100);
|
option.rect = QRect(0, 0, 100, 100);
|
||||||
|
@ -41,7 +41,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// QWidget
|
// QWidget
|
||||||
virtual void paintEvent(QPaintEvent* /*event*/)
|
void paintEvent(QPaintEvent* /*event*/) override
|
||||||
{
|
{
|
||||||
QStyleOptionHeader option;
|
QStyleOptionHeader option;
|
||||||
option.initFrom(this);
|
option.initFrom(this);
|
||||||
|
@ -55,7 +55,7 @@ protected:
|
||||||
painter.drawItemText(option.rect, Qt::AlignCenter, option.palette, true, myText, QPalette::ButtonText);
|
painter.drawItemText(option.rect, Qt::AlignCenter, option.palette, true, myText, QPalette::ButtonText);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void mouseDoubleClickEvent(QMouseEvent* /*event*/)
|
void mouseDoubleClickEvent(QMouseEvent* /*event*/) override
|
||||||
{
|
{
|
||||||
emit static_cast<TorrentView*>(parent())->headerDoubleClicked();
|
emit static_cast<TorrentView*>(parent())->headerDoubleClicked();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,6 @@ public:
|
||||||
QRect iconRect;
|
QRect iconRect;
|
||||||
QRect textRect;
|
QRect textRect;
|
||||||
|
|
||||||
public:
|
|
||||||
ItemLayout(QString const& text, bool suppressColors, Qt::LayoutDirection direction, QPoint const& topLeft, int width);
|
ItemLayout(QString const& text, bool suppressColors, Qt::LayoutDirection direction, QPoint const& topLeft, int width);
|
||||||
|
|
||||||
QSize size() const
|
QSize size() const
|
||||||
|
@ -98,13 +97,13 @@ QSize TrackerDelegate::sizeHint(QStyleOptionViewItem const& option, TrackerInfo
|
||||||
|
|
||||||
QSize TrackerDelegate::sizeHint(QStyleOptionViewItem const& option, QModelIndex const& index) const
|
QSize TrackerDelegate::sizeHint(QStyleOptionViewItem const& option, QModelIndex const& index) const
|
||||||
{
|
{
|
||||||
TrackerInfo const trackerInfo = index.data(TrackerModel::TrackerRole).value<TrackerInfo>();
|
auto const trackerInfo = index.data(TrackerModel::TrackerRole).value<TrackerInfo>();
|
||||||
return sizeHint(option, trackerInfo);
|
return sizeHint(option, trackerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackerDelegate::paint(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const
|
void TrackerDelegate::paint(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const
|
||||||
{
|
{
|
||||||
TrackerInfo const trackerInfo = index.data(TrackerModel::TrackerRole).value<TrackerInfo>();
|
auto const trackerInfo = index.data(TrackerModel::TrackerRole).value<TrackerInfo>();
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setClipRect(option.rect);
|
painter->setClipRect(option.rect);
|
||||||
drawBackground(painter, option, index);
|
drawBackground(painter, option, index);
|
||||||
|
|
|
@ -42,7 +42,7 @@ QVariant TrackerModel::data(QModelIndex const& index, int role) const
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TrackerRole:
|
case TrackerRole:
|
||||||
var = qVariantFromValue(trackerInfo);
|
var = QVariant::fromValue(trackerInfo);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -45,7 +45,7 @@ public:
|
||||||
QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const override;
|
QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef QVector<TrackerInfo> rows_t;
|
using rows_t = QVector<TrackerInfo>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rows_t myRows;
|
rows_t myRows;
|
||||||
|
|
|
@ -24,6 +24,6 @@ void TrackerModelFilter::setShowBackupTrackers(bool b)
|
||||||
bool TrackerModelFilter::filterAcceptsRow(int sourceRow, QModelIndex const& sourceParent) const
|
bool TrackerModelFilter::filterAcceptsRow(int sourceRow, QModelIndex const& sourceParent) const
|
||||||
{
|
{
|
||||||
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||||
TrackerInfo const trackerInfo = index.data(TrackerModel::TrackerRole).value<TrackerInfo>();
|
auto const trackerInfo = index.data(TrackerModel::TrackerRole).value<TrackerInfo>();
|
||||||
return myShowBackups || !trackerInfo.st.isBackup;
|
return myShowBackups || !trackerInfo.st.isBackup;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ QIcon fileIcon()
|
||||||
|
|
||||||
std::unordered_map<QString, QIcon> iconCache;
|
std::unordered_map<QString, QIcon> iconCache;
|
||||||
|
|
||||||
QIcon const getMimeIcon(QString const& filename)
|
QIcon getMimeIcon(QString const& filename)
|
||||||
{
|
{
|
||||||
// If the suffix doesn't match a mime type, treat it as a folder.
|
// If the suffix doesn't match a mime type, treat it as a folder.
|
||||||
// This heuristic is fast and yields good results for torrent names.
|
// This heuristic is fast and yields good results for torrent names.
|
||||||
|
@ -183,10 +183,7 @@ QIcon Utils::guessMimeIcon(QString const& filename)
|
||||||
addAssociatedFileIcon(fileInfo, SHGFI_LARGEICON, icon);
|
addAssociatedFileIcon(fileInfo, SHGFI_LARGEICON, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!icon.isNull())
|
return icon;
|
||||||
{
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -223,7 +220,7 @@ bool Utils::isValidUtf8(char const* s)
|
||||||
n = 1; // ASCII
|
n = 1; // ASCII
|
||||||
}
|
}
|
||||||
else if ((*c & 0xc0) == 0x80)
|
else if ((*c & 0xc0) == 0x80)
|
||||||
{
|
{ // NOLINT(bugprone-branch-clone)
|
||||||
return false; // not valid
|
return false; // not valid
|
||||||
}
|
}
|
||||||
else if ((*c & 0xe0) == 0xc0)
|
else if ((*c & 0xe0) == 0xc0)
|
||||||
|
|
|
@ -67,7 +67,7 @@ int WatchDir::metainfoTest(QString const& filename) const
|
||||||
|
|
||||||
void WatchDir::onTimeout()
|
void WatchDir::onTimeout()
|
||||||
{
|
{
|
||||||
QTimer* t = qobject_cast<QTimer*>(sender());
|
auto* t = qobject_cast<QTimer*>(sender());
|
||||||
QString const filename = t->objectName();
|
QString const filename = t->objectName();
|
||||||
|
|
||||||
if (metainfoTest(filename) == OK)
|
if (metainfoTest(filename) == OK)
|
||||||
|
@ -134,7 +134,7 @@ void WatchDir::watcherActivated(QString const& path)
|
||||||
case ERROR:
|
case ERROR:
|
||||||
{
|
{
|
||||||
// give the .torrent a few seconds to finish downloading
|
// give the .torrent a few seconds to finish downloading
|
||||||
QTimer* t = new QTimer(this);
|
auto* t = new QTimer(this);
|
||||||
t->setObjectName(dir.absoluteFilePath(name));
|
t->setObjectName(dir.absoluteFilePath(name));
|
||||||
t->setSingleShot(true);
|
t->setSingleShot(true);
|
||||||
connect(t, SIGNAL(timeout()), this, SLOT(onTimeout()));
|
connect(t, SIGNAL(timeout()), this, SLOT(onTimeout()));
|
||||||
|
|
Loading…
Reference in New Issue