mirror of
https://github.com/transmission/transmission
synced 2025-01-30 10:52:00 +00:00
chore: re-enable qt clang tidy warnings (#3791)
This commit is contained in:
parent
99e750229c
commit
9280bf3475
25 changed files with 159 additions and 178 deletions
|
@ -8,14 +8,10 @@ Checks: >
|
|||
-bugprone-narrowing-conversions,
|
||||
cert-*,
|
||||
-cert-err58-cpp,
|
||||
clang-analyzer-core.*,
|
||||
clang-analyzer-cplusplus.*,
|
||||
clang-analyzer-deadcode.*,
|
||||
clang-analyzer-nullability.*,
|
||||
clang-analyzer-optin.cplusplus.*,
|
||||
clang-analyzer-security.*,
|
||||
clang-analyzer-valist.*,
|
||||
clang-analyzer-*,
|
||||
cppcoreguidelines-avoid-const-or-ref-data-members,
|
||||
cppcoreguidelines-init-variables,
|
||||
cppcoreguidelines-interfaces-global-init,
|
||||
cppcoreguidelines-prefer-member-initializer,
|
||||
cppcoreguidelines-slicing,
|
||||
cppcoreguidelines-special-member-functions,
|
||||
|
|
|
@ -781,7 +781,7 @@ bool tr_sys_file_flush(tr_sys_file_t handle, tr_error** error)
|
|||
{
|
||||
TR_ASSERT(handle != TR_BAD_SYS_FILE);
|
||||
|
||||
bool const ret = (isatty(handle) ? true : (fsync(handle) != -1));
|
||||
bool const ret = (isatty(handle) != 0) || (fsync(handle) != -1);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
|
|
|
@ -6,35 +6,22 @@ Checks: >
|
|||
-bugprone-branch-clone,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-bugprone-narrowing-conversions,
|
||||
-bugprone-unchecked-optional-access,
|
||||
cert-*,
|
||||
clang-analyzer-optin*,
|
||||
-clang-diagnostic-c++98*,
|
||||
-clang-diagnostic-double-promotion,
|
||||
-clang-diagnostic-exit-time-destructors,
|
||||
-clang-diagnostic-global-constructors,
|
||||
-clang-diagnostic-shorten-64-to-32,
|
||||
-clang-diagnostic-sign-compare,
|
||||
-clang-diagnostic-sign-conversion,
|
||||
clang-analyzer-*,
|
||||
cppcoreguidelines-*,
|
||||
-cppcoreguidelines-avoid-magic-numbers,
|
||||
-cppcoreguidelines-macro-usage,
|
||||
-cppcoreguidelines-narrowing-conversions,
|
||||
-cppcoreguidelines-non-private-member-variables-in-classes,
|
||||
-cppcoreguidelines-owning-memory,
|
||||
-cppcoreguidelines-prefer-member-initializer,
|
||||
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||
-cppcoreguidelines-pro-bounds-constant-array-index,
|
||||
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
||||
-cppcoreguidelines-pro-type-const-cast,
|
||||
google-readability-*,
|
||||
-google-readability-casting,
|
||||
google-runtime-operator,
|
||||
hicpp-*,
|
||||
-hicpp-multiway-paths-covered,
|
||||
-hicpp-no-array-decay,
|
||||
-hicpp-signed-bitwise,
|
||||
-hicpp-special-member-functions,
|
||||
misc-*,
|
||||
-misc-no-recursion,
|
||||
-misc-non-private-member-variables-in-classes,
|
||||
|
@ -46,9 +33,8 @@ Checks: >
|
|||
-readability-function-cognitive-complexity,
|
||||
-readability-identifier-length,
|
||||
-readability-implicit-bool-conversion,
|
||||
-readability-inconsistent-declaration-parameter-name,
|
||||
-readability-magic-numbers,
|
||||
-readability-redundant-access-specifiers
|
||||
-readability-redundant-access-specifiers, # keep: 'private' vs 'private slots'
|
||||
|
||||
CheckOptions:
|
||||
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace
|
|||
QString getNameFromMetainfo(QByteArray const& benc)
|
||||
{
|
||||
auto metainfo = tr_torrent_metainfo{};
|
||||
if (!metainfo.parseBenc({ benc.constData(), size_t(benc.size()) }))
|
||||
if (!metainfo.parseBenc({ benc.constData(), static_cast<size_t>(benc.size()) }))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -405,16 +405,16 @@ void Application::quitLater() const
|
|||
QTimer::singleShot(0, this, SLOT(quit()));
|
||||
}
|
||||
|
||||
void Application::onTorrentsEdited(torrent_ids_t const& ids) const
|
||||
void Application::onTorrentsEdited(torrent_ids_t const& torrent_ids) const
|
||||
{
|
||||
// the backend's tr_info has changed, so reload those fields
|
||||
session_->initTorrents(ids);
|
||||
session_->initTorrents(torrent_ids);
|
||||
}
|
||||
|
||||
QStringList Application::getNames(torrent_ids_t const& ids) const
|
||||
QStringList Application::getNames(torrent_ids_t const& torrent_ids) const
|
||||
{
|
||||
QStringList names;
|
||||
for (auto const& id : ids)
|
||||
for (auto const& id : torrent_ids)
|
||||
{
|
||||
names.push_back(model_->getTorrentFromId(id)->name());
|
||||
}
|
||||
|
@ -423,23 +423,25 @@ QStringList Application::getNames(torrent_ids_t const& ids) const
|
|||
return names;
|
||||
}
|
||||
|
||||
void Application::onTorrentsAdded(torrent_ids_t const& ids) const
|
||||
void Application::onTorrentsAdded(torrent_ids_t const& torrent_ids) const
|
||||
{
|
||||
if (prefs_->getBool(Prefs::SHOW_NOTIFICATION_ON_ADD))
|
||||
if (!prefs_->getBool(Prefs::SHOW_NOTIFICATION_ON_ADD))
|
||||
{
|
||||
for (auto id : ids)
|
||||
{
|
||||
notifyTorrentAdded(model_->getTorrentFromId(id));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto id : torrent_ids)
|
||||
{
|
||||
notifyTorrentAdded(model_->getTorrentFromId(id));
|
||||
}
|
||||
}
|
||||
|
||||
void Application::onTorrentsCompleted(torrent_ids_t const& ids) const
|
||||
void Application::onTorrentsCompleted(torrent_ids_t const& torrent_ids) const
|
||||
{
|
||||
if (prefs_->getBool(Prefs::SHOW_NOTIFICATION_ON_COMPLETE))
|
||||
{
|
||||
auto const title = tr("Torrent Completed", nullptr, static_cast<int>(ids.size()));
|
||||
auto const body = getNames(ids).join(QStringLiteral("\n"));
|
||||
auto const title = tr("Torrent Completed", nullptr, static_cast<int>(std::size(torrent_ids)));
|
||||
auto const body = getNames(torrent_ids).join(QStringLiteral("\n"));
|
||||
notifyApp(title, body);
|
||||
}
|
||||
|
||||
|
@ -455,11 +457,11 @@ void Application::onTorrentsCompleted(torrent_ids_t const& ids) const
|
|||
}
|
||||
}
|
||||
|
||||
void Application::onTorrentsNeedInfo(torrent_ids_t const& ids) const
|
||||
void Application::onTorrentsNeedInfo(torrent_ids_t const& torrent_ids) const
|
||||
{
|
||||
if (!ids.empty())
|
||||
if (!torrent_ids.empty())
|
||||
{
|
||||
session_->initTorrents(ids);
|
||||
session_->initTorrents(torrent_ids);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,10 +54,10 @@ public slots:
|
|||
private slots:
|
||||
void consentGiven(int result) const;
|
||||
void onSessionSourceChanged() const;
|
||||
void onTorrentsAdded(torrent_ids_t const& torrents) const;
|
||||
void onTorrentsCompleted(torrent_ids_t const& torrents) const;
|
||||
void onTorrentsEdited(torrent_ids_t const& torrents) const;
|
||||
void onTorrentsNeedInfo(torrent_ids_t const& torrents) const;
|
||||
void onTorrentsAdded(torrent_ids_t const& torrent_ids) const;
|
||||
void onTorrentsCompleted(torrent_ids_t const& torrent_ids) const;
|
||||
void onTorrentsEdited(torrent_ids_t const& torrent_ids) const;
|
||||
void onTorrentsNeedInfo(torrent_ids_t const& torrent_ids) const;
|
||||
void refreshPref(int key) const;
|
||||
void refreshTorrents();
|
||||
void saveGeometry() const;
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
}
|
||||
|
||||
signals:
|
||||
void trackerListEdited(QString trackerList);
|
||||
void trackerListEdited(QString /*tracker_list*/);
|
||||
|
||||
private slots:
|
||||
void onButtonBoxClicked(QAbstractButton* button)
|
||||
|
@ -664,7 +664,7 @@ void DetailsDialog::refreshUI()
|
|||
}
|
||||
else
|
||||
{
|
||||
auto const seconds = int(std::difftime(now, baseline));
|
||||
auto const seconds = static_cast<int>(std::difftime(now, baseline));
|
||||
string = fmt.timeToString(seconds);
|
||||
}
|
||||
}
|
||||
|
@ -725,7 +725,7 @@ void DetailsDialog::refreshUI()
|
|||
}
|
||||
}
|
||||
|
||||
auto const seconds = int(std::difftime(now, latest));
|
||||
auto const seconds = static_cast<int>(std::difftime(now, latest));
|
||||
|
||||
if (seconds < 0)
|
||||
{
|
||||
|
@ -1037,8 +1037,8 @@ void DetailsDialog::refreshUI()
|
|||
|
||||
setIfIdle(ui_.bandwidthPriorityCombo, i);
|
||||
|
||||
setIfIdle(ui_.singleDownSpin, int(baseline.downloadLimit().getKBps()));
|
||||
setIfIdle(ui_.singleUpSpin, int(baseline.uploadLimit().getKBps()));
|
||||
setIfIdle(ui_.singleDownSpin, static_cast<int>(baseline.downloadLimit().getKBps()));
|
||||
setIfIdle(ui_.singleUpSpin, static_cast<int>(baseline.uploadLimit().getKBps()));
|
||||
setIfIdle(ui_.peerLimitSpin, baseline.peerLimit());
|
||||
}
|
||||
|
||||
|
@ -1198,7 +1198,9 @@ void DetailsDialog::refreshUI()
|
|||
|
||||
item->setText(COL_UP, peer.rate_to_peer.isZero() ? QString() : fmt.speedToString(peer.rate_to_peer));
|
||||
item->setText(COL_DOWN, peer.rate_to_client.isZero() ? QString() : fmt.speedToString(peer.rate_to_client));
|
||||
item->setText(COL_PERCENT, peer.progress > 0 ? QStringLiteral("%1%").arg(int(peer.progress * 100.0)) : QString());
|
||||
item->setText(
|
||||
COL_PERCENT,
|
||||
peer.progress > 0 ? QStringLiteral("%1%").arg(static_cast<int>(peer.progress * 100.0)) : QString());
|
||||
item->setText(COL_STATUS, code);
|
||||
item->setToolTip(COL_STATUS, code_tip);
|
||||
|
||||
|
@ -1572,9 +1574,9 @@ void DetailsDialog::onFileWantedChanged(QSet<int> const& indices, bool wanted)
|
|||
torrentSet(key, indices.values());
|
||||
}
|
||||
|
||||
void DetailsDialog::onPathEdited(QString const& oldpath, QString const& newname)
|
||||
void DetailsDialog::onPathEdited(QString const& old_path, QString const& new_name)
|
||||
{
|
||||
session_.torrentRenamePath(ids_, oldpath, newname);
|
||||
session_.torrentRenamePath(ids_, old_path, new_name);
|
||||
}
|
||||
|
||||
void DetailsDialog::onOpenRequested(QString const& path) const
|
||||
|
|
|
@ -56,7 +56,7 @@ void FileTreeDelegate::paint(QPainter* painter, QStyleOptionViewItem const& opti
|
|||
p.maximum = 100;
|
||||
p.textAlignment = Qt::AlignCenter;
|
||||
p.textVisible = true;
|
||||
p.progress = int(100.0 * index.data().toDouble());
|
||||
p.progress = static_cast<int>(100.0 * index.data().toDouble());
|
||||
p.text = QStringLiteral("%1%").arg(p.progress);
|
||||
style->drawControl(QStyle::CE_ProgressBar, &p, painter);
|
||||
}
|
||||
|
|
|
@ -337,11 +337,11 @@ int FileTreeItem::priority() const
|
|||
return i;
|
||||
}
|
||||
|
||||
void FileTreeItem::setSubtreePriority(int i, QSet<int>& ids)
|
||||
void FileTreeItem::setSubtreePriority(int priority, QSet<int>& ids)
|
||||
{
|
||||
if (priority_ != i)
|
||||
if (priority_ != priority)
|
||||
{
|
||||
priority_ = i;
|
||||
priority_ = priority;
|
||||
|
||||
if (file_index_ >= 0)
|
||||
{
|
||||
|
@ -351,7 +351,7 @@ void FileTreeItem::setSubtreePriority(int i, QSet<int>& ids)
|
|||
|
||||
for (FileTreeItem* const child : children_)
|
||||
{
|
||||
child->setSubtreePriority(i, ids);
|
||||
child->setSubtreePriority(priority, ids);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -173,13 +173,13 @@ Qt::ItemFlags FileTreeModel::flags(QModelIndex const& index) const
|
|||
return { i };
|
||||
}
|
||||
|
||||
bool FileTreeModel::setData(QModelIndex const& index, QVariant const& newname, int role)
|
||||
bool FileTreeModel::setData(QModelIndex const& index, QVariant const& value, int role)
|
||||
{
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
FileTreeItem const* item = itemFromIndex(index);
|
||||
|
||||
emit pathEdited(item->path(), newname.toString());
|
||||
emit pathEdited(item->path(), value.toString());
|
||||
}
|
||||
|
||||
return false; // don't update the view until the session confirms the change
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
int priority,
|
||||
uint64_t size,
|
||||
uint64_t have,
|
||||
bool torrent_changed);
|
||||
bool update_fields);
|
||||
|
||||
bool openFile(QModelIndex const& index);
|
||||
|
||||
|
@ -69,7 +69,7 @@ public:
|
|||
// QAbstractItemModel
|
||||
QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const override;
|
||||
Qt::ItemFlags flags(QModelIndex const& index) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
QVariant headerData(int column, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
QModelIndex index(int row, int column, QModelIndex const& parent = {}) const override;
|
||||
QModelIndex parent(QModelIndex const& child) const override;
|
||||
int rowCount(QModelIndex const& parent = {}) const override;
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
FileTreeView(QWidget* parent = nullptr, bool editable = true);
|
||||
|
||||
void clear();
|
||||
void update(FileList const& files, bool update_properties = true);
|
||||
void update(FileList const& files, bool update_fields = true);
|
||||
|
||||
void setEditable(bool editable);
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ QString getCountString(size_t n)
|
|||
}
|
||||
|
||||
Torrent::fields_t constexpr TrackerFields = {
|
||||
uint64_t(1) << Torrent::TRACKER_STATS,
|
||||
static_cast<uint64_t>(1) << Torrent::TRACKER_STATS,
|
||||
};
|
||||
|
||||
auto constexpr ActivityFields = FilterMode::TorrentFields;
|
||||
|
@ -127,7 +127,7 @@ void FilterBar::refreshTrackers()
|
|||
// update the "All" row
|
||||
auto const num_trackers = torrents_per_sitename.size();
|
||||
auto* item = tracker_model_->item(ROW_TOTALS);
|
||||
item->setData(int(num_trackers), FilterBarComboBox::CountRole);
|
||||
item->setData(static_cast<int>(num_trackers), FilterBarComboBox::CountRole);
|
||||
item->setData(getCountString(num_trackers), FilterBarComboBox::CountStringRole);
|
||||
|
||||
auto update_tracker_item = [](QStandardItem* i, auto const& it)
|
||||
|
@ -140,7 +140,7 @@ void FilterBar::refreshTrackers()
|
|||
i->setData(display_name, TRACKER_ROLE);
|
||||
i->setData(getCountString(static_cast<size_t>(count)), FilterBarComboBox::CountStringRole);
|
||||
i->setData(icon, Qt::DecorationRole);
|
||||
i->setData(int(count), FilterBarComboBox::CountRole);
|
||||
i->setData(static_cast<int>(count), FilterBarComboBox::CountRole);
|
||||
|
||||
return i;
|
||||
};
|
||||
|
@ -221,16 +221,13 @@ FilterBar::FilterBar(Prefs& prefs, TorrentModel const& torrents, TorrentFilter c
|
|||
count_label_ = new QLabel(tr("Show:"), this);
|
||||
h->addWidget(count_label_);
|
||||
|
||||
activity_combo_ = createActivityCombo();
|
||||
h->addWidget(activity_combo_);
|
||||
|
||||
tracker_model_ = new QStandardItemModel(this);
|
||||
tracker_combo_ = createTrackerCombo(tracker_model_);
|
||||
h->addWidget(tracker_combo_);
|
||||
|
||||
h->addStretch();
|
||||
|
||||
line_edit_ = new QLineEdit(this);
|
||||
line_edit_->setClearButtonEnabled(true);
|
||||
line_edit_->setPlaceholderText(tr("Search..."));
|
||||
line_edit_->setMaximumWidth(250);
|
||||
|
@ -249,7 +246,7 @@ FilterBar::FilterBar(Prefs& prefs, TorrentModel const& torrents, TorrentFilter c
|
|||
connect(&trApp->faviconCache(), &FaviconCache::pixmapReady, this, &FilterBar::recountTrackersSoon);
|
||||
|
||||
recountAllSoon();
|
||||
is_bootstrapping_ = false;
|
||||
is_bootstrapping_ = false; // NOLINT cppcoreguidelines-prefer-member-initializer
|
||||
|
||||
// initialize our state
|
||||
for (int const key : { Prefs::FILTER_MODE, Prefs::FILTER_TRACKERS })
|
||||
|
@ -354,9 +351,9 @@ void FilterBar::onActivityIndexChanged(int i)
|
|||
****
|
||||
***/
|
||||
|
||||
void FilterBar::recountSoon(Pending const& pending)
|
||||
void FilterBar::recountSoon(Pending const& fields)
|
||||
{
|
||||
pending_ |= pending;
|
||||
pending_ |= fields;
|
||||
|
||||
if (!recount_timer_.isActive())
|
||||
{
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include <bitset>
|
||||
#include <map>
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QStandardItemModel>
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
|
||||
|
@ -18,8 +20,6 @@
|
|||
#include "Typedefs.h"
|
||||
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QStandardItemModel;
|
||||
class QString;
|
||||
|
||||
class FilterBarComboBox;
|
||||
|
@ -58,12 +58,12 @@ private:
|
|||
TorrentFilter const& filter_;
|
||||
|
||||
std::map<QString, int> sitename_counts_;
|
||||
FilterBarComboBox* activity_combo_ = {};
|
||||
FilterBarComboBox* const activity_combo_ = createActivityCombo();
|
||||
FilterBarComboBox* tracker_combo_ = {};
|
||||
QLabel* count_label_ = {};
|
||||
QStandardItemModel* tracker_model_ = {};
|
||||
QStandardItemModel* const tracker_model_ = new QStandardItemModel{ this };
|
||||
QTimer recount_timer_;
|
||||
QLineEdit* line_edit_ = {};
|
||||
QLineEdit* const line_edit_ = new QLineEdit{ this };
|
||||
Pending pending_ = {};
|
||||
bool is_bootstrapping_ = {};
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
explicit FreeSpaceLabel(QWidget* parent = nullptr);
|
||||
|
||||
void setSession(Session& session);
|
||||
void setPath(QString const& folder);
|
||||
void setPath(QString const& path);
|
||||
|
||||
private slots:
|
||||
void onTimer();
|
||||
|
|
|
@ -125,7 +125,7 @@ private slots:
|
|||
private:
|
||||
QIcon addEmblem(QIcon icon, QStringList const& emblem_names) const;
|
||||
|
||||
torrent_ids_t getSelectedTorrents(bool withMetadataOnly = false) const;
|
||||
torrent_ids_t getSelectedTorrents(bool with_metadata_only = false) const;
|
||||
void updateNetworkIcon();
|
||||
|
||||
QMenu* createOptionsMenu();
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
PrefsDialog(Session&, Prefs&, QWidget* parent = nullptr);
|
||||
|
||||
private slots:
|
||||
void focusChanged(QWidget* old, QWidget* now);
|
||||
void focusChanged(QWidget* old, QWidget* cur);
|
||||
void checkBoxToggled(bool checked);
|
||||
void spinBoxEditingFinished();
|
||||
void timeEditingFinished();
|
||||
|
|
|
@ -283,23 +283,23 @@ void RpcClient::localRequestFinished(TrVariantPtr response)
|
|||
promise.reportFinished(&result);
|
||||
}
|
||||
|
||||
int64_t RpcClient::parseResponseTag(tr_variant& json) const
|
||||
int64_t RpcClient::parseResponseTag(tr_variant& response) const
|
||||
{
|
||||
auto const tag = dictFind<int>(&json, TR_KEY_tag);
|
||||
auto const tag = dictFind<int>(&response, TR_KEY_tag);
|
||||
return tag ? *tag : -1;
|
||||
}
|
||||
|
||||
RpcResponse RpcClient::parseResponseData(tr_variant& json) const
|
||||
RpcResponse RpcClient::parseResponseData(tr_variant& response) const
|
||||
{
|
||||
RpcResponse ret;
|
||||
|
||||
if (auto const result = dictFind<QString>(&json, TR_KEY_result); result)
|
||||
if (auto const result = dictFind<QString>(&response, TR_KEY_result); result)
|
||||
{
|
||||
ret.result = *result;
|
||||
ret.success = *result == QStringLiteral("success");
|
||||
}
|
||||
|
||||
if (tr_variant* args = nullptr; tr_variantDictFindDict(&json, TR_KEY_arguments, &args))
|
||||
if (tr_variant* args = nullptr; tr_variantDictFindDict(&response, TR_KEY_arguments, &args))
|
||||
{
|
||||
ret.args = createVariant();
|
||||
*ret.args = *args;
|
||||
|
|
106
qt/Session.cc
106
qt/Session.cc
|
@ -288,10 +288,6 @@ Session::Session(QString config_dir, Prefs& prefs)
|
|||
: config_dir_(std::move(config_dir))
|
||||
, prefs_(prefs)
|
||||
{
|
||||
stats_ = {};
|
||||
stats_.ratio = TR_RATIO_NA;
|
||||
cumulative_stats_ = stats_;
|
||||
|
||||
connect(&prefs_, &Prefs::changed, this, &Session::updatePref);
|
||||
connect(&rpc_, &RpcClient::httpAuthenticationRequired, this, &Session::httpAuthenticationRequired);
|
||||
connect(&rpc_, &RpcClient::dataReadProgress, this, &Session::dataReadProgress);
|
||||
|
@ -383,17 +379,17 @@ bool Session::isLocal() const
|
|||
****
|
||||
***/
|
||||
|
||||
void Session::addOptionalIds(tr_variant* args, torrent_ids_t const& ids) const
|
||||
void Session::addOptionalIds(tr_variant* args_dict, torrent_ids_t const& torrent_ids) const
|
||||
{
|
||||
auto constexpr RecentlyActiveKey = std::string_view{ "recently-active" };
|
||||
|
||||
if (&ids == &RecentlyActiveIDs)
|
||||
if (&torrent_ids == &RecentlyActiveIDs)
|
||||
{
|
||||
dictAdd(args, TR_KEY_ids, RecentlyActiveKey);
|
||||
dictAdd(args_dict, TR_KEY_ids, RecentlyActiveKey);
|
||||
}
|
||||
else if (!ids.empty())
|
||||
else if (!std::empty(torrent_ids))
|
||||
{
|
||||
dictAdd(args, TR_KEY_ids, ids);
|
||||
dictAdd(args_dict, TR_KEY_ids, torrent_ids);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,76 +406,76 @@ Session::Tag Session::torrentSetImpl(tr_variant* args)
|
|||
return tag;
|
||||
}
|
||||
|
||||
Session::Tag Session::torrentSet(torrent_ids_t const& ids, tr_quark const key, double value)
|
||||
Session::Tag Session::torrentSet(torrent_ids_t const& torrent_ids, tr_quark const key, double value)
|
||||
{
|
||||
tr_variant args;
|
||||
tr_variantInitDict(&args, 2);
|
||||
addOptionalIds(&args, ids);
|
||||
addOptionalIds(&args, torrent_ids);
|
||||
dictAdd(&args, key, value);
|
||||
return torrentSetImpl(&args);
|
||||
}
|
||||
|
||||
Session::Tag Session::torrentSet(torrent_ids_t const& ids, tr_quark const key, int value)
|
||||
Session::Tag Session::torrentSet(torrent_ids_t const& torrent_ids, tr_quark const key, int value)
|
||||
{
|
||||
tr_variant args;
|
||||
tr_variantInitDict(&args, 2);
|
||||
addOptionalIds(&args, ids);
|
||||
addOptionalIds(&args, torrent_ids);
|
||||
dictAdd(&args, key, value);
|
||||
return torrentSetImpl(&args);
|
||||
}
|
||||
|
||||
Session::Tag Session::torrentSet(torrent_ids_t const& ids, tr_quark const key, bool value)
|
||||
Session::Tag Session::torrentSet(torrent_ids_t const& torrent_ids, tr_quark const key, bool value)
|
||||
{
|
||||
tr_variant args;
|
||||
tr_variantInitDict(&args, 2);
|
||||
addOptionalIds(&args, ids);
|
||||
addOptionalIds(&args, torrent_ids);
|
||||
dictAdd(&args, key, value);
|
||||
return torrentSetImpl(&args);
|
||||
}
|
||||
|
||||
Session::Tag Session::torrentSet(torrent_ids_t const& ids, tr_quark const key, QString const& value)
|
||||
Session::Tag Session::torrentSet(torrent_ids_t const& torrent_ids, tr_quark const key, QString const& value)
|
||||
{
|
||||
tr_variant args;
|
||||
tr_variantInitDict(&args, 2);
|
||||
addOptionalIds(&args, ids);
|
||||
addOptionalIds(&args, torrent_ids);
|
||||
dictAdd(&args, key, value);
|
||||
return torrentSetImpl(&args);
|
||||
}
|
||||
|
||||
Session::Tag Session::torrentSet(torrent_ids_t const& ids, tr_quark const key, QStringList const& value)
|
||||
Session::Tag Session::torrentSet(torrent_ids_t const& torrent_ids, tr_quark const key, QStringList const& value)
|
||||
{
|
||||
tr_variant args;
|
||||
tr_variantInitDict(&args, 2);
|
||||
addOptionalIds(&args, ids);
|
||||
addOptionalIds(&args, torrent_ids);
|
||||
dictAdd(&args, key, value);
|
||||
return torrentSetImpl(&args);
|
||||
}
|
||||
|
||||
Session::Tag Session::torrentSet(torrent_ids_t const& ids, tr_quark const key, QList<int> const& value)
|
||||
Session::Tag Session::torrentSet(torrent_ids_t const& torrent_ids, tr_quark const key, QList<int> const& value)
|
||||
{
|
||||
tr_variant args;
|
||||
tr_variantInitDict(&args, 2);
|
||||
addOptionalIds(&args, ids);
|
||||
addOptionalIds(&args, torrent_ids);
|
||||
dictAdd(&args, key, value);
|
||||
return torrentSetImpl(&args);
|
||||
}
|
||||
|
||||
void Session::torrentSetLocation(torrent_ids_t const& ids, QString const& location, bool do_move)
|
||||
void Session::torrentSetLocation(torrent_ids_t const& torrent_ids, QString const& path, bool do_move)
|
||||
{
|
||||
tr_variant args;
|
||||
tr_variantInitDict(&args, 3);
|
||||
addOptionalIds(&args, ids);
|
||||
dictAdd(&args, TR_KEY_location, location);
|
||||
addOptionalIds(&args, torrent_ids);
|
||||
dictAdd(&args, TR_KEY_location, path);
|
||||
dictAdd(&args, TR_KEY_move, do_move);
|
||||
|
||||
exec(TR_KEY_torrent_set_location, &args);
|
||||
}
|
||||
|
||||
void Session::torrentRenamePath(torrent_ids_t const& ids, QString const& oldpath, QString const& newname)
|
||||
void Session::torrentRenamePath(torrent_ids_t const& torrent_ids, QString const& oldpath, QString const& newname)
|
||||
{
|
||||
tr_variant args;
|
||||
tr_variantInitDict(&args, 2);
|
||||
addOptionalIds(&args, ids);
|
||||
addOptionalIds(&args, torrent_ids);
|
||||
dictAdd(&args, TR_KEY_path, oldpath);
|
||||
dictAdd(&args, TR_KEY_name, newname);
|
||||
|
||||
|
@ -507,7 +503,7 @@ void Session::torrentRenamePath(torrent_ids_t const& ids, QString const& oldpath
|
|||
d->show();
|
||||
});
|
||||
|
||||
q->add([this, ids](RpcResponse const& /*r*/) { refreshTorrents(ids, TorrentProperties::Rename); });
|
||||
q->add([this, torrent_ids](RpcResponse const& /*r*/) { refreshTorrents(torrent_ids, TorrentProperties::Rename); });
|
||||
|
||||
q->run();
|
||||
}
|
||||
|
@ -645,7 +641,7 @@ std::vector<std::string_view> const& Session::getKeyNames(TorrentProperties prop
|
|||
return names;
|
||||
}
|
||||
|
||||
void Session::refreshTorrents(torrent_ids_t const& ids, TorrentProperties props)
|
||||
void Session::refreshTorrents(torrent_ids_t const& torrent_ids, TorrentProperties props)
|
||||
{
|
||||
auto constexpr Table = std::string_view{ "table" };
|
||||
|
||||
|
@ -653,13 +649,13 @@ void Session::refreshTorrents(torrent_ids_t const& ids, TorrentProperties props)
|
|||
tr_variantInitDict(&args, 3);
|
||||
dictAdd(&args, TR_KEY_format, Table);
|
||||
dictAdd(&args, TR_KEY_fields, getKeyNames(props));
|
||||
addOptionalIds(&args, ids);
|
||||
addOptionalIds(&args, torrent_ids);
|
||||
|
||||
auto* q = new RpcQueue();
|
||||
|
||||
q->add([this, &args]() { return exec(TR_KEY_torrent_get, &args); });
|
||||
|
||||
bool const all_torrents = ids.empty();
|
||||
bool const all_torrents = std::empty(torrent_ids);
|
||||
|
||||
q->add(
|
||||
[this, all_torrents](RpcResponse const& r)
|
||||
|
@ -690,17 +686,17 @@ void Session::refreshExtraStats(torrent_ids_t const& ids)
|
|||
refreshTorrents(ids, TorrentProperties::DetailStat);
|
||||
}
|
||||
|
||||
void Session::sendTorrentRequest(std::string_view request, torrent_ids_t const& ids)
|
||||
void Session::sendTorrentRequest(std::string_view request, torrent_ids_t const& torrent_ids)
|
||||
{
|
||||
tr_variant args;
|
||||
tr_variantInitDict(&args, 1);
|
||||
addOptionalIds(&args, ids);
|
||||
addOptionalIds(&args, torrent_ids);
|
||||
|
||||
auto* q = new RpcQueue();
|
||||
|
||||
q->add([this, request, &args]() { return exec(request, &args); });
|
||||
|
||||
q->add([this, ids]() { refreshTorrents(ids, TorrentProperties::MainStats); });
|
||||
q->add([this, torrent_ids]() { refreshTorrents(torrent_ids, TorrentProperties::MainStats); });
|
||||
|
||||
q->run();
|
||||
}
|
||||
|
@ -812,29 +808,29 @@ RpcResponseFuture Session::exec(std::string_view method, tr_variant* args)
|
|||
return rpc_.exec(method, args);
|
||||
}
|
||||
|
||||
void Session::updateStats(tr_variant* d, tr_session_stats* stats)
|
||||
void Session::updateStats(tr_variant* args_dict, tr_session_stats* stats)
|
||||
{
|
||||
if (auto const value = dictFind<uint64_t>(d, TR_KEY_uploadedBytes); value)
|
||||
if (auto const value = dictFind<uint64_t>(args_dict, TR_KEY_uploadedBytes); value)
|
||||
{
|
||||
stats->uploadedBytes = *value;
|
||||
}
|
||||
|
||||
if (auto const value = dictFind<uint64_t>(d, TR_KEY_downloadedBytes); value)
|
||||
if (auto const value = dictFind<uint64_t>(args_dict, TR_KEY_downloadedBytes); value)
|
||||
{
|
||||
stats->downloadedBytes = *value;
|
||||
}
|
||||
|
||||
if (auto const value = dictFind<uint64_t>(d, TR_KEY_filesAdded); value)
|
||||
if (auto const value = dictFind<uint64_t>(args_dict, TR_KEY_filesAdded); value)
|
||||
{
|
||||
stats->filesAdded = *value;
|
||||
}
|
||||
|
||||
if (auto const value = dictFind<uint64_t>(d, TR_KEY_sessionCount); value)
|
||||
if (auto const value = dictFind<uint64_t>(args_dict, TR_KEY_sessionCount); value)
|
||||
{
|
||||
stats->sessionCount = *value;
|
||||
}
|
||||
|
||||
if (auto const value = dictFind<uint64_t>(d, TR_KEY_secondsActive); value)
|
||||
if (auto const value = dictFind<uint64_t>(args_dict, TR_KEY_secondsActive); value)
|
||||
{
|
||||
stats->secondsActive = *value;
|
||||
}
|
||||
|
@ -857,13 +853,13 @@ void Session::updateStats(tr_variant* dict)
|
|||
emit statsUpdated();
|
||||
}
|
||||
|
||||
void Session::updateInfo(tr_variant* d)
|
||||
void Session::updateInfo(tr_variant* args_dict)
|
||||
{
|
||||
disconnect(&prefs_, &Prefs::changed, this, &Session::updatePref);
|
||||
|
||||
for (int i = Prefs::FIRST_CORE_PREF; i <= Prefs::LAST_CORE_PREF; ++i)
|
||||
{
|
||||
tr_variant const* b(tr_variantDictFind(d, prefs_.getKey(i)));
|
||||
tr_variant const* b(tr_variantDictFind(args_dict, prefs_.getKey(i)));
|
||||
|
||||
if (b == nullptr)
|
||||
{
|
||||
|
@ -932,12 +928,12 @@ void Session::updateInfo(tr_variant* d)
|
|||
}
|
||||
}
|
||||
|
||||
if (auto const b = dictFind<bool>(d, TR_KEY_seedRatioLimited); b)
|
||||
if (auto const b = dictFind<bool>(args_dict, TR_KEY_seedRatioLimited); b)
|
||||
{
|
||||
prefs_.set(Prefs::RATIO_ENABLED, *b);
|
||||
}
|
||||
|
||||
if (auto const x = dictFind<double>(d, TR_KEY_seedRatioLimit); x)
|
||||
if (auto const x = dictFind<double>(args_dict, TR_KEY_seedRatioLimit); x)
|
||||
{
|
||||
prefs_.set(Prefs::RATIO, *x);
|
||||
}
|
||||
|
@ -954,17 +950,17 @@ void Session::updateInfo(tr_variant* d)
|
|||
prefs_.set(Prefs::RPC_WHITELIST, QString::fromUtf8(tr_sessionGetRPCWhitelist(session_)));
|
||||
}
|
||||
|
||||
if (auto const size = dictFind<int>(d, TR_KEY_blocklist_size); size && *size != blocklistSize())
|
||||
if (auto const size = dictFind<int>(args_dict, TR_KEY_blocklist_size); size && *size != blocklistSize())
|
||||
{
|
||||
setBlocklistSize(*size);
|
||||
}
|
||||
|
||||
if (auto const str = dictFind<QString>(d, TR_KEY_version); str)
|
||||
if (auto const str = dictFind<QString>(args_dict, TR_KEY_version); str)
|
||||
{
|
||||
session_version_ = *str;
|
||||
}
|
||||
|
||||
if (auto const str = dictFind<QString>(d, TR_KEY_session_id); str)
|
||||
if (auto const str = dictFind<QString>(args_dict, TR_KEY_session_id); str)
|
||||
{
|
||||
session_id_ = *str;
|
||||
is_definitely_local_session_ = tr_session_id::isLocal(session_id_.toUtf8().constData());
|
||||
|
@ -986,30 +982,30 @@ void Session::setBlocklistSize(int64_t i)
|
|||
emit blocklistUpdated(i);
|
||||
}
|
||||
|
||||
void Session::addTorrent(AddData add_me, tr_variant* args, bool trash_original)
|
||||
void Session::addTorrent(AddData add_me, tr_variant* args_dict, bool trash_original)
|
||||
{
|
||||
assert(tr_variantDictFind(args, TR_KEY_filename) == nullptr);
|
||||
assert(tr_variantDictFind(args, TR_KEY_metainfo) == nullptr);
|
||||
assert(tr_variantDictFind(args_dict, TR_KEY_filename) == nullptr);
|
||||
assert(tr_variantDictFind(args_dict, TR_KEY_metainfo) == nullptr);
|
||||
|
||||
if (tr_variantDictFind(args, TR_KEY_paused) == nullptr)
|
||||
if (tr_variantDictFind(args_dict, TR_KEY_paused) == nullptr)
|
||||
{
|
||||
dictAdd(args, TR_KEY_paused, !prefs_.getBool(Prefs::START));
|
||||
dictAdd(args_dict, TR_KEY_paused, !prefs_.getBool(Prefs::START));
|
||||
}
|
||||
|
||||
switch (add_me.type)
|
||||
{
|
||||
case AddData::MAGNET:
|
||||
dictAdd(args, TR_KEY_filename, add_me.magnet);
|
||||
dictAdd(args_dict, TR_KEY_filename, add_me.magnet);
|
||||
break;
|
||||
|
||||
case AddData::URL:
|
||||
dictAdd(args, TR_KEY_filename, add_me.url.toString());
|
||||
dictAdd(args_dict, TR_KEY_filename, add_me.url.toString());
|
||||
break;
|
||||
|
||||
case AddData::FILENAME:
|
||||
[[fallthrough]];
|
||||
case AddData::METAINFO:
|
||||
dictAdd(args, TR_KEY_metainfo, add_me.toBase64());
|
||||
dictAdd(args_dict, TR_KEY_metainfo, add_me.toBase64());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1020,7 +1016,7 @@ void Session::addTorrent(AddData add_me, tr_variant* args, bool trash_original)
|
|||
auto* q = new RpcQueue();
|
||||
|
||||
q->add(
|
||||
[this, args]() { return exec("torrent-add", args); },
|
||||
[this, args_dict]() { return exec("torrent-add", args_dict); },
|
||||
[add_me](RpcResponse const& r)
|
||||
{
|
||||
auto* d = new QMessageBox(
|
||||
|
|
44
qt/Session.h
44
qt/Session.h
|
@ -84,27 +84,27 @@ public:
|
|||
RpcResponseFuture exec(std::string_view method, tr_variant* args);
|
||||
|
||||
using Tag = RpcQueue::Tag;
|
||||
Tag torrentSet(torrent_ids_t const& ids, tr_quark const key, bool val);
|
||||
Tag torrentSet(torrent_ids_t const& ids, tr_quark const key, int val);
|
||||
Tag torrentSet(torrent_ids_t const& ids, tr_quark const key, double val);
|
||||
Tag torrentSet(torrent_ids_t const& ids, tr_quark const key, QString const& val);
|
||||
Tag torrentSet(torrent_ids_t const& ids, tr_quark const key, QList<int> const& val);
|
||||
Tag torrentSet(torrent_ids_t const& ids, tr_quark const key, QStringList const& val);
|
||||
Tag torrentSet(torrent_ids_t const& torrent_ids, tr_quark const key, bool val);
|
||||
Tag torrentSet(torrent_ids_t const& torrent_ids, tr_quark const key, int val);
|
||||
Tag torrentSet(torrent_ids_t const& torrent_ids, tr_quark const key, double val);
|
||||
Tag torrentSet(torrent_ids_t const& torrent_ids, tr_quark const key, QString const& val);
|
||||
Tag torrentSet(torrent_ids_t const& torrent_ids, tr_quark const key, QList<int> const& val);
|
||||
Tag torrentSet(torrent_ids_t const& torrent_ids, tr_quark const key, QStringList const& val);
|
||||
|
||||
void torrentSetLocation(torrent_ids_t const& ids, QString const& path, bool do_move);
|
||||
void torrentRenamePath(torrent_ids_t const& ids, QString const& oldpath, QString const& newname);
|
||||
void addTorrent(AddData addme, tr_variant* top, bool trash_original);
|
||||
void torrentSetLocation(torrent_ids_t const& torrent_ids, QString const& path, bool do_move);
|
||||
void torrentRenamePath(torrent_ids_t const& torrent_ids, QString const& oldpath, QString const& newname);
|
||||
void addTorrent(AddData add_me, tr_variant* args_dict, bool trash_original);
|
||||
void initTorrents(torrent_ids_t const& ids = {});
|
||||
void pauseTorrents(torrent_ids_t const& torrentIds = {});
|
||||
void startTorrents(torrent_ids_t const& torrentIds = {});
|
||||
void startTorrentsNow(torrent_ids_t const& torrentIds = {});
|
||||
void pauseTorrents(torrent_ids_t const& torrent_ids = {});
|
||||
void startTorrents(torrent_ids_t const& torrent_ids = {});
|
||||
void startTorrentsNow(torrent_ids_t const& torrent_ids = {});
|
||||
void refreshDetailInfo(torrent_ids_t const& torrent_ids);
|
||||
void refreshActiveTorrents();
|
||||
void refreshAllTorrents();
|
||||
void addNewlyCreatedTorrent(QString const& filename, QString const& local_path);
|
||||
void verifyTorrents(torrent_ids_t const& torrent_ids);
|
||||
void reannounceTorrents(torrent_ids_t const& torrent_ids);
|
||||
void refreshExtraStats(torrent_ids_t const& ids);
|
||||
void refreshExtraStats(torrent_ids_t const& torrent_ids);
|
||||
|
||||
enum class TorrentProperties
|
||||
{
|
||||
|
@ -117,7 +117,7 @@ public:
|
|||
};
|
||||
|
||||
public slots:
|
||||
void addTorrent(AddData addme);
|
||||
void addTorrent(AddData add_me);
|
||||
void launchWebInterface() const;
|
||||
void queueMoveBottom(torrent_ids_t const& torrentIds = {});
|
||||
void queueMoveDown(torrent_ids_t const& torrentIds = {});
|
||||
|
@ -148,19 +148,19 @@ private slots:
|
|||
private:
|
||||
void start();
|
||||
|
||||
void updateStats(tr_variant* args);
|
||||
void updateInfo(tr_variant* args);
|
||||
void updateStats(tr_variant* args_dict);
|
||||
void updateInfo(tr_variant* args_dict);
|
||||
|
||||
Tag torrentSetImpl(tr_variant* args);
|
||||
void sessionSet(tr_quark const key, QVariant const& variant);
|
||||
void sessionSet(tr_quark const key, QVariant const& value);
|
||||
void pumpRequests();
|
||||
void sendTorrentRequest(std::string_view request, torrent_ids_t const& torrent_ids);
|
||||
void refreshTorrents(torrent_ids_t const& ids, TorrentProperties props);
|
||||
std::vector<std::string_view> const& getKeyNames(TorrentProperties props);
|
||||
|
||||
static void updateStats(tr_variant* d, tr_session_stats* stats);
|
||||
static void updateStats(tr_variant* args_dict, tr_session_stats* stats);
|
||||
|
||||
void addOptionalIds(tr_variant* args, torrent_ids_t const& ids) const;
|
||||
void addOptionalIds(tr_variant* args_dict, torrent_ids_t const& torrent_ids) const;
|
||||
|
||||
QString const config_dir_;
|
||||
Prefs& prefs_;
|
||||
|
@ -170,8 +170,8 @@ private:
|
|||
int64_t blocklist_size_ = -1;
|
||||
tr_session* session_ = {};
|
||||
QStringList idle_json_;
|
||||
tr_session_stats stats_ = {};
|
||||
tr_session_stats cumulative_stats_ = {};
|
||||
tr_session_stats stats_ = EmptyStats;
|
||||
tr_session_stats cumulative_stats_ = EmptyStats;
|
||||
QString session_version_;
|
||||
QString session_id_;
|
||||
bool is_definitely_local_session_ = true;
|
||||
|
@ -180,4 +180,6 @@ private:
|
|||
|
||||
std::map<QString, QString> duplicates_;
|
||||
QTimer duplicates_timer_;
|
||||
|
||||
static auto constexpr EmptyStats = tr_session_stats{ TR_RATIO_NA, 0, 0, 0, 0, 0 };
|
||||
};
|
||||
|
|
|
@ -55,11 +55,11 @@ SqueezeLabel::SqueezeLabel(QWidget* parent)
|
|||
{
|
||||
}
|
||||
|
||||
void SqueezeLabel::paintEvent(QPaintEvent* paintEvent)
|
||||
void SqueezeLabel::paintEvent(QPaintEvent* paint_event)
|
||||
{
|
||||
if (hasFocus() && (textInteractionFlags() & (Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse)) != 0)
|
||||
{
|
||||
return QLabel::paintEvent(paintEvent);
|
||||
return QLabel::paintEvent(paint_event);
|
||||
}
|
||||
|
||||
QPainter painter(this);
|
||||
|
|
|
@ -398,7 +398,7 @@ QString TorrentDelegate::statusString(Torrent const& tor)
|
|||
|
||||
QSize TorrentDelegate::sizeHint(QStyleOptionViewItem const& option, Torrent const& tor) const
|
||||
{
|
||||
auto const m = QSize(margin(*QApplication::style()));
|
||||
auto const m = margin(*QApplication::style());
|
||||
auto const layout = ItemLayout(
|
||||
tor.name(),
|
||||
progressString(tor),
|
||||
|
|
|
@ -108,7 +108,7 @@ ItemLayout::ItemLayout(
|
|||
int const icon_size = style->pixelMetric(QStyle::PM_SmallIconSize);
|
||||
|
||||
auto const name_fm = QFontMetrics(name_font);
|
||||
auto const name_size = QSize(name_fm.size(0, name_text_));
|
||||
auto const name_size = name_fm.size(0, name_text_);
|
||||
|
||||
status_font.setPointSize(static_cast<int>(status_font.pointSize() * 0.85));
|
||||
QFontMetrics const status_fm(status_font);
|
||||
|
@ -148,8 +148,8 @@ ItemLayout::ItemLayout(
|
|||
|
||||
QSize TorrentDelegateMin::sizeHint(QStyleOptionViewItem const& option, Torrent const& tor) const
|
||||
{
|
||||
auto const is_magnet = bool(!tor.hasMetadata());
|
||||
auto const m = QSize(margin(*QApplication::style()));
|
||||
auto const is_magnet = !tor.hasMetadata();
|
||||
auto const m = margin(*QApplication::style());
|
||||
auto const layout = ItemLayout(
|
||||
is_magnet ? progressString(tor) : tor.name(),
|
||||
shortStatusString(tor),
|
||||
|
|
|
@ -118,14 +118,14 @@ QVariant TorrentModel::data(QModelIndex const& index, int role) const
|
|||
****
|
||||
***/
|
||||
|
||||
void TorrentModel::removeTorrents(tr_variant* list)
|
||||
void TorrentModel::removeTorrents(tr_variant* torrent_list)
|
||||
{
|
||||
torrents_t torrents;
|
||||
torrents.reserve(tr_variantListSize(list));
|
||||
auto torrents = torrents_t{};
|
||||
torrents.reserve(tr_variantListSize(torrent_list));
|
||||
|
||||
int i = 0;
|
||||
tr_variant const* child = nullptr;
|
||||
while ((child = tr_variantListChild(list, i++)) != nullptr)
|
||||
while ((child = tr_variantListChild(torrent_list, i++)) != nullptr)
|
||||
{
|
||||
if (auto const id = getValue<int>(child); id)
|
||||
{
|
||||
|
@ -142,7 +142,7 @@ void TorrentModel::removeTorrents(tr_variant* list)
|
|||
}
|
||||
}
|
||||
|
||||
void TorrentModel::updateTorrents(tr_variant* torrents, bool is_complete_list)
|
||||
void TorrentModel::updateTorrents(tr_variant* torrent_list, bool is_complete_list)
|
||||
{
|
||||
auto const old = is_complete_list ? torrents_ : torrents_t{};
|
||||
auto added = torrent_ids_t{};
|
||||
|
@ -163,7 +163,7 @@ void TorrentModel::updateTorrents(tr_variant* torrents, bool is_complete_list)
|
|||
};
|
||||
|
||||
// build a list of the property keys
|
||||
tr_variant* const first_child = tr_variantListChild(torrents, 0);
|
||||
tr_variant* const first_child = tr_variantListChild(torrent_list, 0);
|
||||
bool const table = tr_variantIsList(first_child);
|
||||
std::vector<tr_quark> keys;
|
||||
if (table)
|
||||
|
@ -202,9 +202,9 @@ void TorrentModel::updateTorrents(tr_variant* torrents, bool is_complete_list)
|
|||
std::vector<tr_variant*> values;
|
||||
values.reserve(keys.size());
|
||||
size_t tor_index = table ? 1 : 0;
|
||||
processed.reserve(tr_variantListSize(torrents));
|
||||
processed.reserve(tr_variantListSize(torrent_list));
|
||||
tr_variant* v = nullptr;
|
||||
while ((v = tr_variantListChild(torrents, tor_index++)))
|
||||
while ((v = tr_variantListChild(torrent_list, tor_index++)))
|
||||
{
|
||||
// Build an array of values
|
||||
values.clear();
|
||||
|
|
|
@ -31,10 +31,10 @@ bool change(double& setme, double const& value)
|
|||
return changed;
|
||||
}
|
||||
|
||||
bool change(Speed& setme, tr_variant const* variant)
|
||||
bool change(Speed& setme, tr_variant const* value)
|
||||
{
|
||||
auto const value = getValue<int>(variant);
|
||||
return value && change(setme, Speed::fromBps(*value));
|
||||
auto const bytes_per_second = getValue<int>(value);
|
||||
return bytes_per_second && change(setme, Speed::fromBps(*bytes_per_second));
|
||||
}
|
||||
|
||||
bool change(TorrentHash& setme, tr_variant const* value)
|
||||
|
|
Loading…
Reference in a new issue