diff --git a/qt/AddData.cc b/qt/AddData.cc index 4b0a0221a..5bb9174e1 100644 --- a/qt/AddData.cc +++ b/qt/AddData.cc @@ -98,7 +98,7 @@ QString AddData::readableName() const case METAINFO: { tr_info inf; - tr_ctor* ctor = tr_ctorNew(NULL); + tr_ctor* ctor = tr_ctorNew(nullptr); tr_ctorSetMetainfo(ctor, reinterpret_cast(metainfo.constData()), metainfo.size()); diff --git a/qt/Application.cc b/qt/Application.cc index 968bfc4c8..66c353c89 100644 --- a/qt/Application.cc +++ b/qt/Application.cc @@ -47,13 +47,13 @@ QLatin1String const MY_READABLE_NAME("transmission-qt"); tr_option const opts[] = { { 'g', "config-dir", "Where to look for configuration files", "g", 1, "" }, - { 'm', "minimized", "Start minimized in system tray", "m", 0, NULL }, + { 'm', "minimized", "Start minimized in system tray", "m", 0, nullptr }, { 'p', "port", "Port to use when connecting to an existing session", "p", 1, "" }, { 'r', "remote", "Connect to an existing session at the specified hostname", "r", 1, "" }, { 'u', "username", "Username to use when connecting to an existing session", "u", 1, "" }, - { 'v', "version", "Show version number and exit", "v", 0, NULL }, + { 'v', "version", "Show version number and exit", "v", 0, nullptr }, { 'w', "password", "Password to use when connecting to an existing session", "w", 1, "" }, - { 0, NULL, NULL, NULL, 0, NULL } + { 0, nullptr, nullptr, nullptr, 0, nullptr } }; char const* getUsage() @@ -575,7 +575,7 @@ void Application::refreshTorrents() // usually we just poll the torrents that have shown recent activity, // but we also periodically ask for updates on the others to ensure // nothing's falling through the cracks. - time_t const now = time(NULL); + time_t const now = time(nullptr); if (myLastFullUpdateTime + 60 >= now) { diff --git a/qt/ComInteropHelper.cc b/qt/ComInteropHelper.cc index a6b36ab8c..36fb70944 100644 --- a/qt/ComInteropHelper.cc +++ b/qt/ComInteropHelper.cc @@ -49,10 +49,10 @@ QVariant ComInteropHelper::addMetainfo(QString const& metainfo) void ComInteropHelper::initialize() { qAxOutProcServer = true; - ::GetModuleFileNameW(0, qAxModuleFilename, MAX_PATH); - qAxInstance = ::GetModuleHandleW(NULL); + ::GetModuleFileNameW(nullptr, qAxModuleFilename, MAX_PATH); + qAxInstance = ::GetModuleHandleW(nullptr); - ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); qAxInit(); } diff --git a/qt/DetailsDialog.cc b/qt/DetailsDialog.cc index 15a605566..7753ab900 100644 --- a/qt/DetailsDialog.cc +++ b/qt/DetailsDialog.cc @@ -200,7 +200,7 @@ QIcon DetailsDialog::getStockIcon(QString const& freedesktop_name, int fallback) if (icon.isNull()) { - icon = style()->standardIcon(QStyle::StandardPixmap(fallback), 0, this); + icon = style()->standardIcon(QStyle::StandardPixmap(fallback), nullptr, this); } return icon; @@ -1067,9 +1067,9 @@ void DetailsDialog::refresh() for (Peer const& peer : peers) { QString const key = idStr + QLatin1Char(':') + peer.address; - PeerItem* item = static_cast(myPeers.value(key, 0)); + PeerItem* item = static_cast(myPeers.value(key, nullptr)); - if (item == 0) // new peer has connected + if (item == nullptr) // new peer has connected { static QIcon const myEncryptionIcon(QLatin1String(":/icons/encrypted.png")); static QIcon const myEmptyIcon; @@ -1173,7 +1173,7 @@ void DetailsDialog::refresh() { if (!peers2.contains(key)) // old peer has disconnected { - QTreeWidgetItem* item = myPeers.value(key, 0); + QTreeWidgetItem* item = myPeers.value(key, nullptr); ui.peersView->takeTopLevelItem(ui.peersView->indexOfTopLevelItem(item)); delete item; } @@ -1273,7 +1273,7 @@ void DetailsDialog::onIdleModeChanged(int index) void DetailsDialog::onIdleLimitChanged() { //: Spin box suffix, "Stop seeding if idle for: [ 5 minutes ]" (includes leading space after the number, if needed) - QString const unitsSuffix = tr(" minute(s)", 0, ui.idleSpin->value()); + QString const unitsSuffix = tr(" minute(s)", nullptr, ui.idleSpin->value()); if (ui.idleSpin->suffix() != unitsSuffix) { @@ -1557,7 +1557,7 @@ void DetailsDialog::onOpenRequested(QString const& path) { Torrent const* const tor = myModel.getTorrentFromId(id); - if (tor == NULL) + if (tor == nullptr) { continue; } diff --git a/qt/FileTreeItem.cc b/qt/FileTreeItem.cc index e99811b74..5fe530de3 100644 --- a/qt/FileTreeItem.cc +++ b/qt/FileTreeItem.cc @@ -37,7 +37,7 @@ FileTreeItem::~FileTreeItem() { assert(myChildren.isEmpty()); - if (myParent != 0) + if (myParent != nullptr) { int const pos = row(); assert((pos >= 0) && "couldn't find child in parent's lookup"); @@ -57,7 +57,7 @@ void FileTreeItem::appendChild(FileTreeItem* child) FileTreeItem* FileTreeItem::child(QString const& filename) { - FileTreeItem* item(0); + FileTreeItem* item(nullptr); int const row = getMyChildRows().value(filename, -1); @@ -401,7 +401,7 @@ QString FileTreeItem::path() const QString itemPath; FileTreeItem const* item = this; - while (item != NULL && !item->name().isEmpty()) + while (item != nullptr && !item->name().isEmpty()) { if (itemPath.isEmpty()) { diff --git a/qt/FileTreeModel.cc b/qt/FileTreeModel.cc index f65292a9e..0d156c348 100644 --- a/qt/FileTreeModel.cc +++ b/qt/FileTreeModel.cc @@ -318,7 +318,7 @@ void FileTreeModel::clearSubtree(QModelIndex const& top) FileTreeItem* const item = itemFromIndex(top); - if (item == 0) + if (item == nullptr) { return; } @@ -342,7 +342,7 @@ void FileTreeModel::clear() FileTreeItem* FileTreeModel::findItemForFileIndex(int fileIndex) const { - return myIndexCache.value(fileIndex, 0); + return myIndexCache.value(fileIndex, nullptr); } void FileTreeModel::addFile(int fileIndex, QString const& filename, bool wanted, int priority, uint64_t totalSize, diff --git a/qt/FilterBarComboBox.cc b/qt/FilterBarComboBox.cc index 1d520aaaa..7aac7e3c8 100644 --- a/qt/FilterBarComboBox.cc +++ b/qt/FilterBarComboBox.cc @@ -19,7 +19,7 @@ namespace int getHSpacing(QWidget const* w) { - return qMax(3, w->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing, 0, w)); + return qMax(3, w->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing, nullptr, w)); } } // namespace diff --git a/qt/FilterBarComboBoxDelegate.cc b/qt/FilterBarComboBoxDelegate.cc index 403abc131..cd779259f 100644 --- a/qt/FilterBarComboBoxDelegate.cc +++ b/qt/FilterBarComboBoxDelegate.cc @@ -21,7 +21,7 @@ namespace int getHSpacing(QWidget const* w) { - return qMax(3, w->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing, 0, w)); + return qMax(3, w->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing, nullptr, w)); } } // namespace @@ -103,7 +103,7 @@ QSize FilterBarComboBoxDelegate::sizeHint(QStyleOptionViewItem const& option, QM { if (isSeparator(index)) { - int const pm = myCombo->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, myCombo); + int const pm = myCombo->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, myCombo); return QSize(pm, pm + 10); } else @@ -113,7 +113,7 @@ QSize FilterBarComboBoxDelegate::sizeHint(QStyleOptionViewItem const& option, QM QSize size = QItemDelegate::sizeHint(option, index); size.setHeight(qMax(size.height(), myCombo->iconSize().height() + 6)); - size.rwidth() += s->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, myCombo); + size.rwidth() += s->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, myCombo); size.rwidth() += rect(option, index, FilterBarComboBox::CountStringRole).width(); size.rwidth() += hmargin * 4; return size; diff --git a/qt/Formatter.cc b/qt/Formatter.cc index 7a9418974..de1e74cb6 100644 --- a/qt/Formatter.cc +++ b/qt/Formatter.cc @@ -158,10 +158,10 @@ QString Formatter::timeToString(int seconds) minutes = (seconds % 3600) / 60; seconds %= 60; - d = tr("%Ln day(s)", 0, days); - h = tr("%Ln hour(s)", 0, hours); - m = tr("%Ln minute(s)", 0, minutes); - s = tr("%Ln second(s)", 0, seconds); + d = tr("%Ln day(s)", nullptr, days); + h = tr("%Ln hour(s)", nullptr, hours); + m = tr("%Ln minute(s)", nullptr, minutes); + s = tr("%Ln second(s)", nullptr, seconds); if (days) { diff --git a/qt/FreeSpaceLabel.cc b/qt/FreeSpaceLabel.cc index 6b3db5fca..630c1448d 100644 --- a/qt/FreeSpaceLabel.cc +++ b/qt/FreeSpaceLabel.cc @@ -93,7 +93,7 @@ void FreeSpaceLabel::onTimer() // update the tooltip size_t len = 0; - char const* path = 0; + char const* path = nullptr; tr_variantDictFindStr(r.args.get(), TR_KEY_path, &path, &len); str = QString::fromUtf8(path, len); setToolTip(QDir::toNativeSeparators(str)); diff --git a/qt/MainWindow.cc b/qt/MainWindow.cc index 240b2cd72..09bca55d2 100644 --- a/qt/MainWindow.cc +++ b/qt/MainWindow.cc @@ -65,8 +65,8 @@ QLatin1String const SessionTransferStatsModeName("session-transfer"); class ListViewProxyStyle : public QProxyStyle { public: - int styleHint(StyleHint hint, QStyleOption const* option = 0, QWidget const* widget = 0, - QStyleHintReturn* returnData = 0) const + int styleHint(StyleHint hint, QStyleOption const* option = nullptr, QWidget const* widget = nullptr, + QStyleHintReturn* returnData = nullptr) const { if (hint == QStyle::SH_ItemView_ActivateItemOnSingleClick) { @@ -788,7 +788,7 @@ void MainWindow::refreshTorrentViewHeader() } else { - ui.listView->setHeaderText(tr("Showing %L1 of %Ln torrent(s)", 0, totalCount).arg(visibleCount)); + ui.listView->setHeaderText(tr("Showing %L1 of %Ln torrent(s)", nullptr, totalCount).arg(visibleCount)); } } @@ -1277,11 +1277,11 @@ void MainWindow::addTorrents(QStringList const& filenames) QFileDialog const* const fileDialog = qobject_cast(sender()); - if (fileDialog != NULL) + if (fileDialog != nullptr) { QCheckBox const* const b = fileDialog->findChild(SHOW_OPTIONS_CHECKBOX_NAME); - if (b != NULL) + if (b != nullptr) { showOptions = b->isChecked(); } @@ -1342,12 +1342,12 @@ void MainWindow::removeTorrents(bool const deleteFiles) if (!deleteFiles) { - primary_text = (count == 1) ? tr("Remove torrent?") : tr("Remove %Ln torrent(s)?", 0, count); + primary_text = (count == 1) ? tr("Remove torrent?") : tr("Remove %Ln torrent(s)?", nullptr, count); } else { primary_text = (count == 1) ? tr("Delete this torrent's downloaded files?") : - tr("Delete these %Ln torrent(s)' downloaded files?", 0, count); + tr("Delete these %Ln torrent(s)' downloaded files?", nullptr, count); } if (!incomplete && !connected) @@ -1417,7 +1417,7 @@ void MainWindow::removeTorrents(bool const deleteFiles) void MainWindow::updateNetworkIcon() { - time_t const now = time(NULL); + time_t const now = time(nullptr); int const period = 3; time_t const secondsSinceLastSend = now - myLastSendTime; time_t const secondsSinceLastRead = now - myLastReadTime; diff --git a/qt/MakeDialog.cc b/qt/MakeDialog.cc index d9cc63170..c673df717 100644 --- a/qt/MakeDialog.cc +++ b/qt/MakeDialog.cc @@ -177,8 +177,8 @@ void MakeDialog::makeTorrent() } // start making the torrent - tr_makeMetaInfo(myBuilder.get(), target.toUtf8().constData(), trackers.isEmpty() ? NULL : trackers.data(), trackers.size(), - comment.isEmpty() ? NULL : comment.toUtf8().constData(), ui.privateCheck->isChecked()); + tr_makeMetaInfo(myBuilder.get(), target.toUtf8().constData(), trackers.isEmpty() ? nullptr : trackers.data(), + trackers.size(), comment.isEmpty() ? nullptr : comment.toUtf8().constData(), ui.privateCheck->isChecked()); // pop up the dialog MakeProgressDialog* dialog = new MakeProgressDialog(mySession, *myBuilder, this); @@ -218,8 +218,8 @@ void MakeDialog::onSourceChanged() } else { - QString files = tr("%Ln File(s)", 0, myBuilder->fileCount); - QString pieces = tr("%Ln Piece(s)", 0, myBuilder->pieceCount); + QString files = tr("%Ln File(s)", nullptr, myBuilder->fileCount); + QString pieces = tr("%Ln Piece(s)", nullptr, myBuilder->pieceCount); text = tr("%1 in %2; %3 @ %4").arg(Formatter::sizeToString(myBuilder->totalSize)).arg(files).arg(pieces). arg(Formatter::sizeToString(myBuilder->pieceSize)); } diff --git a/qt/OptionsDialog.cc b/qt/OptionsDialog.cc index eee2aa87d..1f6ac7e63 100644 --- a/qt/OptionsDialog.cc +++ b/qt/OptionsDialog.cc @@ -149,7 +149,7 @@ void OptionsDialog::reload() clearInfo(); clearVerify(); - tr_ctor* ctor = tr_ctorNew(0); + tr_ctor* ctor = tr_ctorNew(nullptr); switch (myAdd.type) { diff --git a/qt/Prefs.cc b/qt/Prefs.cc index 5ef6fd189..1442c5368 100644 --- a/qt/Prefs.cc +++ b/qt/Prefs.cc @@ -146,7 +146,7 @@ Prefs::Prefs(QString const& configDir) : tr_variant top; tr_variantInitDict(&top, 0); initDefaults(&top); - tr_sessionLoadSettings(&top, myConfigDir.toUtf8().constData(), NULL); + tr_sessionLoadSettings(&top, myConfigDir.toUtf8().constData(), nullptr); for (int i = 0; i < PREFS_COUNT; ++i) { @@ -168,7 +168,7 @@ Prefs::Prefs(QString const& configDir) : break; case CustomVariantType::SortModeType: - if (tr_variantGetStr(b, &str, NULL)) + if (tr_variantGetStr(b, &str, nullptr)) { myValues[i] = QVariant::fromValue(SortMode(QString::fromUtf8(str))); } @@ -176,7 +176,7 @@ Prefs::Prefs(QString const& configDir) : break; case CustomVariantType::FilterModeType: - if (tr_variantGetStr(b, &str, NULL)) + if (tr_variantGetStr(b, &str, nullptr)) { myValues[i] = QVariant::fromValue(FilterMode(QString::fromUtf8(str))); } @@ -293,7 +293,7 @@ Prefs::~Prefs() tr_variant file_settings; QFile const file(QDir(myConfigDir).absoluteFilePath(QLatin1String("settings.json"))); - if (!tr_variantFromFile(&file_settings, TR_VARIANT_FMT_JSON, file.fileName().toUtf8().constData(), NULL)) + if (!tr_variantFromFile(&file_settings, TR_VARIANT_FMT_JSON, file.fileName().toUtf8().constData(), nullptr)) { tr_variantInitDict(&file_settings, PREFS_COUNT); } diff --git a/qt/Prefs.h b/qt/Prefs.h index 8587977df..1b553c441 100644 --- a/qt/Prefs.h +++ b/qt/Prefs.h @@ -144,7 +144,7 @@ public: char const* keyStr(int i) const { - return tr_quark_get_string(myItems[i].key, NULL); + return tr_quark_get_string(myItems[i].key, nullptr); } tr_quark getKey(int i) const diff --git a/qt/PrefsDialog.cc b/qt/PrefsDialog.cc index f36af7b29..ca0722339 100644 --- a/qt/PrefsDialog.cc +++ b/qt/PrefsDialog.cc @@ -435,7 +435,7 @@ void PrefsDialog::onBlocklistDialogDestroyed(QObject* o) { Q_UNUSED(o); - myBlocklistDialog = 0; + myBlocklistDialog = nullptr; } void PrefsDialog::onUpdateBlocklistCancelled() @@ -446,7 +446,7 @@ void PrefsDialog::onUpdateBlocklistCancelled() void PrefsDialog::onBlocklistUpdated(int n) { - myBlocklistDialog->setText(tr("Update succeeded!

Blocklist now has %Ln rule(s).", 0, n)); + myBlocklistDialog->setText(tr("Update succeeded!

Blocklist now has %Ln rule(s).", nullptr, n)); myBlocklistDialog->setTextFormat(Qt::RichText); } @@ -497,7 +497,7 @@ void PrefsDialog::initPrivacyTab() void PrefsDialog::onIdleLimitChanged() { //: Spin box suffix, "Stop seeding if idle for: [ 5 minutes ]" (includes leading space after the number, if needed) - QString const unitsSuffix = tr(" minute(s)", 0, ui.idleLimitSpin->value()); + QString const unitsSuffix = tr(" minute(s)", nullptr, ui.idleLimitSpin->value()); if (ui.idleLimitSpin->suffix() != unitsSuffix) { @@ -520,7 +520,7 @@ void PrefsDialog::initSeedingTab() void PrefsDialog::onQueueStalledMinutesChanged() { //: Spin box suffix, "Download is inactive if data sharing stopped: [ 5 minutes ago ]" (includes leading space after the number, if needed) - QString const unitsSuffix = tr(" minute(s) ago", 0, ui.queueStalledMinutesSpin->value()); + QString const unitsSuffix = tr(" minute(s) ago", nullptr, ui.queueStalledMinutesSpin->value()); if (ui.queueStalledMinutesSpin->suffix() != unitsSuffix) { @@ -669,7 +669,7 @@ void PrefsDialog::sessionUpdated() void PrefsDialog::updateBlocklistLabel() { int const n = mySession.blocklistSize(); - ui.blocklistStatusLabel->setText(tr("Blocklist contains %Ln rule(s)", 0, n)); + ui.blocklistStatusLabel->setText(tr("Blocklist contains %Ln rule(s)", nullptr, n)); } void PrefsDialog::refreshPref(int key) diff --git a/qt/RpcClient.cc b/qt/RpcClient.cc index 6443559b3..704ad562a 100644 --- a/qt/RpcClient.cc +++ b/qt/RpcClient.cc @@ -79,7 +79,7 @@ void RpcClient::start(QUrl const& url) bool RpcClient::isLocal() const { - if (mySession != 0) + if (mySession != nullptr) { return true; } @@ -189,7 +189,7 @@ RpcResponseFuture RpcClient::sendRequest(TrVariantPtr json) QNetworkAccessManager* RpcClient::networkAccessManager() { - if (myNAM == 0) + if (myNAM == nullptr) { myNAM = new QNetworkAccessManager(); diff --git a/qt/Session.cc b/qt/Session.cc index 830bbe902..3fada6631 100644 --- a/qt/Session.cc +++ b/qt/Session.cc @@ -151,7 +151,7 @@ void Session::copyMagnetLinkToClipboard(int torrentId) char const* str; if (tr_variantDictFindList(r.args.get(), TR_KEY_torrents, &torrents) && - (child = tr_variantListChild(torrents, 0)) && tr_variantDictFindStr(child, TR_KEY_magnetLink, &str, NULL)) + (child = tr_variantListChild(torrents, 0)) && tr_variantDictFindStr(child, TR_KEY_magnetLink, &str, nullptr)) { qApp->clipboard()->setText(QString::fromUtf8(str)); } @@ -310,7 +310,7 @@ Session::Session(QString const& configDir, Prefs& prefs) : myConfigDir(configDir), myPrefs(prefs), myBlocklistSize(-1), - mySession(0), + mySession(nullptr), myIsDefinitelyLocalSession(true) { myStats.ratio = TR_RATIO_NA; @@ -345,7 +345,7 @@ void Session::stop() if (mySession) { tr_sessionClose(mySession); - mySession = 0; + mySession = nullptr; } } @@ -395,7 +395,7 @@ void Session::start() bool Session::isServer() const { - return mySession != 0; + return mySession != nullptr; } bool Session::isLocal() const @@ -808,7 +808,7 @@ void Session::updateInfo(tr_variant* d) { char const* val; - if (tr_variantGetStr(b, &val, NULL)) + if (tr_variantGetStr(b, &val, nullptr)) { if (qstrcmp(val, "required") == 0) { @@ -871,7 +871,7 @@ void Session::updateInfo(tr_variant* d) { char const* val; - if (tr_variantGetStr(b, &val, NULL)) + if (tr_variantGetStr(b, &val, nullptr)) { myPrefs.set(i, QString::fromUtf8(val)); } @@ -898,7 +898,7 @@ void Session::updateInfo(tr_variant* d) } /* Use the C API to get settings that, for security reasons, aren't supported by RPC */ - if (mySession != 0) + if (mySession != nullptr) { myPrefs.set(Prefs::RPC_ENABLED, tr_sessionIsRPCEnabled(mySession)); myPrefs.set(Prefs::RPC_AUTH_REQUIRED, tr_sessionIsRPCPasswordEnabled(mySession)); @@ -914,12 +914,12 @@ void Session::updateInfo(tr_variant* d) setBlocklistSize(i); } - if (tr_variantDictFindStr(d, TR_KEY_version, &str, NULL) && (mySessionVersion != QString::fromUtf8(str))) + if (tr_variantDictFindStr(d, TR_KEY_version, &str, nullptr) && (mySessionVersion != QString::fromUtf8(str))) { mySessionVersion = QString::fromUtf8(str); } - if (tr_variantDictFindStr(d, TR_KEY_session_id, &str, NULL)) + if (tr_variantDictFindStr(d, TR_KEY_session_id, &str, nullptr)) { QString const sessionId = QString::fromUtf8(str); @@ -1001,7 +1001,7 @@ void Session::addTorrent(AddData const& addMe, tr_variant* args, bool trashOrigi char const* str; if (tr_variantDictFindDict(r.args.get(), TR_KEY_torrent_duplicate, &dup) && - tr_variantDictFindStr(dup, TR_KEY_name, &str, NULL)) + tr_variantDictFindStr(dup, TR_KEY_name, &str, nullptr)) { QString const name = QString::fromUtf8(str); QMessageBox* d = new QMessageBox(QMessageBox::Warning, tr("Add Torrent"), diff --git a/qt/StatsDialog.cc b/qt/StatsDialog.cc index 083879b37..afeb6d1a5 100644 --- a/qt/StatsDialog.cc +++ b/qt/StatsDialog.cc @@ -69,5 +69,5 @@ void StatsDialog::updateStats() ui.totalRatioValueLabel->setText(Formatter::ratioToString(total.ratio)); ui.totalDurationValueLabel->setText(Formatter::timeToString(total.secondsActive)); - ui.startCountLabel->setText(tr("Started %Ln time(s)", 0, total.sessionCount)); + ui.startCountLabel->setText(tr("Started %Ln time(s)", nullptr, total.sessionCount)); } diff --git a/qt/Torrent.cc b/qt/Torrent.cc index 1b10d1b70..eba089594 100644 --- a/qt/Torrent.cc +++ b/qt/Torrent.cc @@ -576,7 +576,7 @@ void Torrent::update(tr_variant* d) { char const* val; - if (tr_variantGetStr(child, &val, NULL)) + if (tr_variantGetStr(child, &val, nullptr)) { changed |= setString(property_index, val); } @@ -626,7 +626,7 @@ void Torrent::update(tr_variant* d) break; default: - std::cerr << __FILE__ << ':' << __LINE__ << "unhandled type: " << tr_quark_get_string(key, NULL) << std::endl; + std::cerr << __FILE__ << ':' << __LINE__ << "unhandled type: " << tr_quark_get_string(key, nullptr) << std::endl; assert(0 && "unhandled type"); } } diff --git a/qt/TorrentDelegate.cc b/qt/TorrentDelegate.cc index f9b6a9430..525a5e61e 100644 --- a/qt/TorrentDelegate.cc +++ b/qt/TorrentDelegate.cc @@ -328,7 +328,7 @@ QString TorrentDelegate::statusString(Torrent const& tor) case TR_STATUS_DOWNLOAD: if (!tor.hasMetadata()) { - str = tr("Downloading metadata from %Ln peer(s) (%1% done)", 0, tor.peersWeAreDownloadingFrom()). + str = tr("Downloading metadata from %Ln peer(s) (%1% done)", nullptr, tor.peersWeAreDownloadingFrom()). arg(Formatter::percentToString(100.0 * tor.metadataPercentDone())); } else @@ -338,12 +338,12 @@ QString TorrentDelegate::statusString(Torrent const& tor) if (tor.connectedPeersAndWebseeds() == 0) { //: First part of phrase "Downloading from ... peer(s) and ... web seed(s)" - str = tr("Downloading from %Ln peer(s)", 0, tor.peersWeAreDownloadingFrom()); + str = tr("Downloading from %Ln peer(s)", nullptr, tor.peersWeAreDownloadingFrom()); } else { //: First part of phrase "Downloading from ... of ... connected peer(s) and ... web seed(s)" - str = tr("Downloading from %1 of %Ln connected peer(s)", 0, tor.connectedPeersAndWebseeds()). + str = tr("Downloading from %1 of %Ln connected peer(s)", nullptr, tor.connectedPeersAndWebseeds()). arg(tor.peersWeAreDownloadingFrom()); } @@ -352,7 +352,7 @@ QString TorrentDelegate::statusString(Torrent const& tor) //: Second (optional) part of phrase "Downloading from ... of ... connected peer(s) and ... web // seed(s)"; //: notice that leading space (before "and") is included here - str += tr(" and %Ln web seed(s)", 0, tor.webseedsWeAreDownloadingFrom()); + str += tr(" and %Ln web seed(s)", nullptr, tor.webseedsWeAreDownloadingFrom()); } } @@ -361,11 +361,11 @@ QString TorrentDelegate::statusString(Torrent const& tor) case TR_STATUS_SEED: if (tor.connectedPeers() == 0) { - str = tr("Seeding to %Ln peer(s)", 0, tor.peersWeAreUploadingTo()); + str = tr("Seeding to %Ln peer(s)", nullptr, tor.peersWeAreUploadingTo()); } else { - str = tr("Seeding to %1 of %Ln connected peer(s)", 0, tor.connectedPeers()).arg(tor.peersWeAreUploadingTo()); + str = tr("Seeding to %1 of %Ln connected peer(s)", nullptr, tor.connectedPeers()).arg(tor.peersWeAreUploadingTo()); } break; diff --git a/qt/TorrentModel.cc b/qt/TorrentModel.cc index 3bb02dcec..a34419bd3 100644 --- a/qt/TorrentModel.cc +++ b/qt/TorrentModel.cc @@ -60,9 +60,9 @@ QVariant TorrentModel::data(QModelIndex const& index, int role) const { QVariant var; - Torrent const* t = myTorrents.value(index.row(), 0); + Torrent const* t = myTorrents.value(index.row(), nullptr); - if (t != 0) + if (t != nullptr) { switch (role) { @@ -214,7 +214,7 @@ void TorrentModel::updateTorrents(tr_variant* torrents, bool isCompleteList) Torrent* tor = getTorrentFromId(id); - if (tor == 0) + if (tor == nullptr) { tor = new Torrent(myPrefs, id); tor->update(child); diff --git a/qt/TrackerDelegate.cc b/qt/TrackerDelegate.cc index f7bac3283..cc27b73df 100644 --- a/qt/TrackerDelegate.cc +++ b/qt/TrackerDelegate.cc @@ -181,7 +181,7 @@ QString TrackerDelegate::getText(TrackerInfo const& inf) const { QString key; QString str; - time_t const now(time(0)); + time_t const now(time(nullptr)); QString const err_markup_begin = QLatin1String(""); QString const err_markup_end = QLatin1String(""); QString const timeout_markup_begin = QLatin1String(""); @@ -191,9 +191,9 @@ QString TrackerDelegate::getText(TrackerInfo const& inf) const // hostname str += inf.st.isBackup ? QLatin1String("") : QLatin1String(""); - char* host = NULL; + char* host = nullptr; int port = 0; - tr_urlParse(inf.st.announce.toUtf8().constData(), TR_BAD_SIZE, NULL, &host, &port, NULL); + tr_urlParse(inf.st.announce.toUtf8().constData(), TR_BAD_SIZE, nullptr, &host, &port, nullptr); str += QString::fromLatin1("%1:%2").arg(QString::fromUtf8(host)).arg(port); tr_free(host); @@ -215,7 +215,7 @@ QString TrackerDelegate::getText(TrackerInfo const& inf) const if (inf.st.lastAnnounceSucceeded) { //: %1 and %2 are replaced with HTML markup, %3 is duration - str += tr("Got a list of%1 %Ln peer(s)%2 %3 ago", 0, inf.st.lastAnnouncePeerCount).arg(success_markup_begin). + str += tr("Got a list of%1 %Ln peer(s)%2 %3 ago", nullptr, inf.st.lastAnnouncePeerCount).arg(success_markup_begin). arg(success_markup_end).arg(tstr); } else if (inf.st.lastAnnounceTimedOut) @@ -276,12 +276,12 @@ QString TrackerDelegate::getText(TrackerInfo const& inf) const { //: First part of phrase "Tracker had ... seeder(s) and ... leecher(s) ... ago"; //: %1 and %2 are replaced with HTML markup - str += tr("Tracker had%1 %Ln seeder(s)%2", 0, inf.st.seederCount).arg(success_markup_begin). + str += tr("Tracker had%1 %Ln seeder(s)%2", nullptr, inf.st.seederCount).arg(success_markup_begin). arg(success_markup_end); //: Second part of phrase "Tracker had ... seeder(s) and ... leecher(s) ... ago"; //: %1 and %2 are replaced with HTML markup, %3 is duration; //: notice that leading space (before "and") is included here - str += tr(" and%1 %Ln leecher(s)%2 %3 ago", 0, inf.st.leecherCount).arg(success_markup_begin). + str += tr(" and%1 %Ln leecher(s)%2 %3 ago", nullptr, inf.st.leecherCount).arg(success_markup_begin). arg(success_markup_end).arg(tstr); } else diff --git a/qt/TrackerModel.cc b/qt/TrackerModel.cc index 22b4fab2e..23997bdb9 100644 --- a/qt/TrackerModel.cc +++ b/qt/TrackerModel.cc @@ -89,7 +89,7 @@ void TrackerModel::refresh(TorrentModel const& torrentModel, QSet const& id { Torrent const* tor = torrentModel.getTorrentFromId(id); - if (tor != 0) + if (tor != nullptr) { TrackerStatsList const trackerList = tor->trackerStats(); diff --git a/qt/Utils.cc b/qt/Utils.cc index d8e05eaab..3ba753217 100644 --- a/qt/Utils.cc +++ b/qt/Utils.cc @@ -61,7 +61,7 @@ void addAssociatedFileIcon(QFileInfo const& fileInfo, UINT iconSize, QIcon& icon if (::SHGetFileInfoW(reinterpret_cast(filename.utf16()), FILE_ATTRIBUTE_NORMAL, &shellFileInfo, sizeof(shellFileInfo), SHGFI_ICON | iconSize | SHGFI_USEFILEATTRIBUTES) != 0) { - if (shellFileInfo.hIcon != NULL) + if (shellFileInfo.hIcon != nullptr) { pixmap = QtWin::fromHICON(shellFileInfo.hIcon); ::DestroyIcon(shellFileInfo.hIcon); diff --git a/qt/WatchDir.cc b/qt/WatchDir.cc index 78426cd83..ba91accec 100644 --- a/qt/WatchDir.cc +++ b/qt/WatchDir.cc @@ -24,7 +24,7 @@ WatchDir::WatchDir(TorrentModel const& model) : myModel(model), - myWatcher(0) + myWatcher(nullptr) { } @@ -40,7 +40,7 @@ int WatchDir::metainfoTest(QString const& filename) const { int ret; tr_info inf; - tr_ctor* ctor = tr_ctorNew(0); + tr_ctor* ctor = tr_ctorNew(nullptr); // parse tr_ctorSetMetainfoFromFile(ctor, filename.toUtf8().constData()); @@ -90,7 +90,7 @@ void WatchDir::setPath(QString const& path, bool isEnabled) if (myWatcher) { delete myWatcher; - myWatcher = 0; + myWatcher = nullptr; } // maybe create a new watcher