, void>
>::type* = nullptr>
ErrorHandlerFunction normalizeErrorHandler(Func const& func)
{
diff --git a/qt/Session.cc b/qt/Session.cc
index 46f3bfbf5..4aaf041e3 100644
--- a/qt/Session.cc
+++ b/qt/Session.cc
@@ -42,7 +42,7 @@
namespace
{
-typedef Torrent::KeyList KeyList;
+using KeyList = Torrent::KeyList;
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()
{
- RpcQueue* q = new RpcQueue();
+ auto* q = new RpcQueue();
q->add([this]()
{
@@ -123,7 +123,7 @@ void Session::copyMagnetLinkToClipboard(int torrentId)
tr_variantListAddInt(tr_variantDictAddList(&args, TR_KEY_ids, 1), torrentId);
tr_variantListAddStr(tr_variantDictAddList(&args, TR_KEY_fields, 1), "magnetLink");
- RpcQueue* q = new RpcQueue();
+ auto* q = new RpcQueue();
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_name, newname.toUtf8().constData());
- RpcQueue* q = new RpcQueue();
+ auto* q = new RpcQueue();
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_name, &name, nullptr);
- QMessageBox* d = new QMessageBox(QMessageBox::Information, tr("Error Renaming Path"),
+ auto* d = new QMessageBox(QMessageBox::Information, tr("Error Renaming Path"),
tr("Unable to rename \"%1\" as \"%2\": %3.
Please correct the errors and try again.
").
arg(QString::fromUtf8(path)).arg(QString::fromUtf8(name)).arg(r.result), QMessageBox::Close,
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);
addOptionalIds(&args, ids);
- RpcQueue* q = new RpcQueue();
+ auto* q = new RpcQueue();
q->add([this, &args]()
{
@@ -596,7 +596,7 @@ void Session::sendTorrentRequest(char const* request, torrent_ids_t const& ids)
tr_variantInitDict(&args, 1);
addOptionalIds(&args, ids);
- RpcQueue* q = new RpcQueue();
+ auto* q = new RpcQueue();
q->add([this, request, &args]()
{
@@ -663,7 +663,7 @@ void Session::initTorrents(torrent_ids_t const& ids)
void Session::refreshSessionStats()
{
- RpcQueue* q = new RpcQueue();
+ auto* q = new RpcQueue();
q->add([this]()
{
@@ -680,7 +680,7 @@ void Session::refreshSessionStats()
void Session::refreshSessionInfo()
{
- RpcQueue* q = new RpcQueue();
+ auto* q = new RpcQueue();
q->add([this]()
{
@@ -697,7 +697,7 @@ void Session::refreshSessionInfo()
void Session::updateBlocklist()
{
- RpcQueue* q = new RpcQueue();
+ auto* q = new RpcQueue();
q->add([this]()
{
@@ -972,7 +972,7 @@ void Session::addTorrent(AddData const& addMe, tr_variant* args, bool trashOrigi
break;
}
- RpcQueue* q = new RpcQueue();
+ auto* q = new RpcQueue();
q->add([this, args]()
{
@@ -980,7 +980,7 @@ void Session::addTorrent(AddData const& addMe, tr_variant* args, bool trashOrigi
},
[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("%1
%2
").arg(r.result).arg(addMe.readableName()), QMessageBox::Close,
qApp->activeWindow());
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))
{
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("Unable to add \"%1\".
It is a duplicate of \"%2\" which is already added.
").
arg(addMe.readableShortName()).arg(name), QMessageBox::Close, qApp->activeWindow());
QObject::connect(d, &QMessageBox::rejected, d, &QMessageBox::deleteLater);
diff --git a/qt/StatsDialog.cc b/qt/StatsDialog.cc
index afeb6d1a5..e8ec3b33f 100644
--- a/qt/StatsDialog.cc
+++ b/qt/StatsDialog.cc
@@ -25,7 +25,7 @@ StatsDialog::StatsDialog(Session& session, QWidget* parent) :
{
ui.setupUi(this);
- ColumnResizer* cr(new ColumnResizer(this));
+ auto* cr = new ColumnResizer(this);
cr->addLayout(ui.currentSessionSectionLayout);
cr->addLayout(ui.totalSectionLayout);
cr->update();
@@ -38,9 +38,7 @@ StatsDialog::StatsDialog(Session& session, QWidget* parent) :
mySession.refreshSessionStats();
}
-StatsDialog::~StatsDialog()
-{
-}
+StatsDialog::~StatsDialog() = default;
void StatsDialog::setVisible(bool visible)
{
diff --git a/qt/TorrentDelegate.cc b/qt/TorrentDelegate.cc
index 548813cc7..4766a093d 100644
--- a/qt/TorrentDelegate.cc
+++ b/qt/TorrentDelegate.cc
@@ -57,7 +57,6 @@ public:
QRect barRect;
QRect progressRect;
-public:
ItemLayout(QString const& nameText, QString const& statusText, QString const& progressText, QIcon const& emblemIcon,
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
{
- Torrent const* tor(index.data(TorrentModel::TorrentRole).value());
+ auto const* tor(index.data(TorrentModel::TorrentRole).value());
painter->save();
painter->setClipRect(option.rect);
drawTorrent(painter, option, *tor);
diff --git a/qt/TorrentDelegateMin.cc b/qt/TorrentDelegateMin.cc
index 2f9bdeffc..48d4c4c30 100644
--- a/qt/TorrentDelegateMin.cc
+++ b/qt/TorrentDelegateMin.cc
@@ -62,7 +62,6 @@ public:
QRect statusRect;
QRect barRect;
-public:
ItemLayout(QString const& nameText, QString const& statusText, QIcon const& emblemIcon, QFont const& baseFont,
Qt::LayoutDirection direction, QPoint const& topLeft, int width);
diff --git a/qt/TorrentFilter.cc b/qt/TorrentFilter.cc
index acb54e3e3..343772bcb 100644
--- a/qt/TorrentFilter.cc
+++ b/qt/TorrentFilter.cc
@@ -27,9 +27,7 @@ TorrentFilter::TorrentFilter(Prefs const& prefs) :
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
{
int val = 0;
- Torrent const* a = sourceModel()->data(left, TorrentModel::TorrentRole).value();
- Torrent const* b = sourceModel()->data(right, TorrentModel::TorrentRole).value();
+ auto const* a = sourceModel()->data(left, TorrentModel::TorrentRole).value();
+ auto const* b = sourceModel()->data(right, TorrentModel::TorrentRole).value();
switch (myPrefs.get(Prefs::SORT_MODE).mode())
{
@@ -285,12 +283,12 @@ bool TorrentFilter::activityFilterAcceptsTorrent(Torrent const* tor, FilterMode
bool TorrentFilter::filterAcceptsRow(int sourceRow, QModelIndex const& sourceParent) const
{
QModelIndex childIndex = sourceModel()->index(sourceRow, 0, sourceParent);
- Torrent const* tor = childIndex.model()->data(childIndex, TorrentModel::TorrentRole).value();
+ auto const* tor = childIndex.model()->data(childIndex, TorrentModel::TorrentRole).value();
bool accepts = true;
if (accepts)
{
- FilterMode const m = myPrefs.get(Prefs::FILTER_MODE);
+ auto const m = myPrefs.get(Prefs::FILTER_MODE);
accepts = activityFilterAcceptsTorrent(tor, m);
}
diff --git a/qt/TorrentModel.cc b/qt/TorrentModel.cc
index 6a3ae39f7..b7f0fc79d 100644
--- a/qt/TorrentModel.cc
+++ b/qt/TorrentModel.cc
@@ -106,7 +106,7 @@ QVariant TorrentModel::data(QModelIndex const& index, int role) const
break;
case TorrentRole:
- var = qVariantFromValue(t);
+ var = QVariant::fromValue(t);
break;
default:
@@ -443,7 +443,7 @@ void TorrentModel::rowsAdd(torrents_t const& 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);
beginInsertRows(QModelIndex(), row, row);
diff --git a/qt/TorrentView.cc b/qt/TorrentView.cc
index ebb58ae36..50185d4f3 100644
--- a/qt/TorrentView.cc
+++ b/qt/TorrentView.cc
@@ -29,7 +29,7 @@ public:
}
// QWidget
- virtual QSize sizeHint() const
+ QSize sizeHint() const override
{
QStyleOptionHeader option;
option.rect = QRect(0, 0, 100, 100);
@@ -41,7 +41,7 @@ public:
protected:
// QWidget
- virtual void paintEvent(QPaintEvent* /*event*/)
+ void paintEvent(QPaintEvent* /*event*/) override
{
QStyleOptionHeader option;
option.initFrom(this);
@@ -55,7 +55,7 @@ protected:
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(parent())->headerDoubleClicked();
}
diff --git a/qt/TrackerDelegate.cc b/qt/TrackerDelegate.cc
index b36d72dbc..0b8f606b5 100644
--- a/qt/TrackerDelegate.cc
+++ b/qt/TrackerDelegate.cc
@@ -41,7 +41,6 @@ public:
QRect iconRect;
QRect textRect;
-public:
ItemLayout(QString const& text, bool suppressColors, Qt::LayoutDirection direction, QPoint const& topLeft, int width);
QSize size() const
@@ -98,13 +97,13 @@ QSize TrackerDelegate::sizeHint(QStyleOptionViewItem const& option, TrackerInfo
QSize TrackerDelegate::sizeHint(QStyleOptionViewItem const& option, QModelIndex const& index) const
{
- TrackerInfo const trackerInfo = index.data(TrackerModel::TrackerRole).value();
+ auto const trackerInfo = index.data(TrackerModel::TrackerRole).value();
return sizeHint(option, trackerInfo);
}
void TrackerDelegate::paint(QPainter* painter, QStyleOptionViewItem const& option, QModelIndex const& index) const
{
- TrackerInfo const trackerInfo = index.data(TrackerModel::TrackerRole).value();
+ auto const trackerInfo = index.data(TrackerModel::TrackerRole).value();
painter->save();
painter->setClipRect(option.rect);
drawBackground(painter, option, index);
diff --git a/qt/TrackerModel.cc b/qt/TrackerModel.cc
index 94ff7bb3e..f6d3ab042 100644
--- a/qt/TrackerModel.cc
+++ b/qt/TrackerModel.cc
@@ -42,7 +42,7 @@ QVariant TrackerModel::data(QModelIndex const& index, int role) const
break;
case TrackerRole:
- var = qVariantFromValue(trackerInfo);
+ var = QVariant::fromValue(trackerInfo);
break;
default:
diff --git a/qt/TrackerModel.h b/qt/TrackerModel.h
index 61b66d8dc..6b6b7bb9b 100644
--- a/qt/TrackerModel.h
+++ b/qt/TrackerModel.h
@@ -45,7 +45,7 @@ public:
QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const override;
private:
- typedef QVector rows_t;
+ using rows_t = QVector;
private:
rows_t myRows;
diff --git a/qt/TrackerModelFilter.cc b/qt/TrackerModelFilter.cc
index e650dd858..dc71373ce 100644
--- a/qt/TrackerModelFilter.cc
+++ b/qt/TrackerModelFilter.cc
@@ -24,6 +24,6 @@ void TrackerModelFilter::setShowBackupTrackers(bool b)
bool TrackerModelFilter::filterAcceptsRow(int sourceRow, QModelIndex const& sourceParent) const
{
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
- TrackerInfo const trackerInfo = index.data(TrackerModel::TrackerRole).value();
+ auto const trackerInfo = index.data(TrackerModel::TrackerRole).value();
return myShowBackups || !trackerInfo.st.isBackup;
}
diff --git a/qt/Utils.cc b/qt/Utils.cc
index ecd04b8a2..dd4bfeacc 100644
--- a/qt/Utils.cc
+++ b/qt/Utils.cc
@@ -112,7 +112,7 @@ QIcon fileIcon()
std::unordered_map 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.
// 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);
}
- if (!icon.isNull())
- {
- return icon;
- }
+ return icon;
#else
@@ -223,7 +220,7 @@ bool Utils::isValidUtf8(char const* s)
n = 1; // ASCII
}
else if ((*c & 0xc0) == 0x80)
- {
+ { // NOLINT(bugprone-branch-clone)
return false; // not valid
}
else if ((*c & 0xe0) == 0xc0)
diff --git a/qt/WatchDir.cc b/qt/WatchDir.cc
index 673a7f88b..62418e1b7 100644
--- a/qt/WatchDir.cc
+++ b/qt/WatchDir.cc
@@ -67,7 +67,7 @@ int WatchDir::metainfoTest(QString const& filename) const
void WatchDir::onTimeout()
{
- QTimer* t = qobject_cast(sender());
+ auto* t = qobject_cast(sender());
QString const filename = t->objectName();
if (metainfoTest(filename) == OK)
@@ -134,7 +134,7 @@ void WatchDir::watcherActivated(QString const& path)
case ERROR:
{
// 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->setSingleShot(true);
connect(t, SIGNAL(timeout()), this, SLOT(onTimeout()));