Discard unused params more elegantly

By commenting out the parameter name, we get compile-time checks
Also, we can omit them for slots and Qt will not forward the parameters.

In case we had TODOs next to the code, I kept the Q_UNUSED statements
for now.
This commit is contained in:
Alexander Lohnau 2023-07-28 09:11:43 +02:00 committed by Albert Vaca Cintora
parent 46feeda0cb
commit 405f61bf85
19 changed files with 30 additions and 76 deletions

View file

@ -146,10 +146,8 @@ void CompositeUploadJob::socketDisconnected()
m_socket->close();
}
void CompositeUploadJob::socketError(QAbstractSocket::SocketError error)
void CompositeUploadJob::socketError()
{
Q_UNUSED(error);
// Do not close the socket because when android closes the socket (share is cancelled) closing the socket leads to a cyclic socketError and eventually a
// segv
setError(SocketError);
@ -158,10 +156,8 @@ void CompositeUploadJob::socketError(QAbstractSocket::SocketError error)
m_running = false;
}
void CompositeUploadJob::sslError(const QList<QSslError> &errors)
void CompositeUploadJob::sslError()
{
Q_UNUSED(errors);
m_socket->close();
setError(SslError);
emitResult();
@ -240,10 +236,8 @@ bool CompositeUploadJob::doKill()
return true;
}
void CompositeUploadJob::slotProcessedAmount(KJob *job, KJob::Unit unit, qulonglong amount)
void CompositeUploadJob::slotProcessedAmount(KJob * /*job*/, KJob::Unit unit, qulonglong amount)
{
Q_UNUSED(job);
m_currentJobSendPayloadSize = amount;
quint64 uploaded = m_totalSendPayloadSize + m_currentJobSendPayloadSize;

View file

@ -55,8 +55,8 @@ private:
private Q_SLOTS:
void newConnection();
void socketDisconnected();
void socketError(QAbstractSocket::SocketError socketError);
void sslError(const QList<QSslError> &errors);
void socketError();
void sslError();
void encrypted();
void slotProcessedAmount(KJob *job, KJob::Unit unit, qulonglong amount);
void slotResult(KJob *job) override;

View file

@ -64,10 +64,8 @@ void UploadJob::uploadNextPacket()
}
}
void UploadJob::encryptedBytesWritten(qint64 bytes)
void UploadJob::encryptedBytesWritten(qint64 /*bytes*/)
{
Q_UNUSED(bytes);
if (m_socket->encryptedBytesToWrite() == 0) {
bytesUploaded += bytesUploading;
setProcessedAmount(Bytes, bytesUploaded);

View file

@ -86,10 +86,8 @@ bool CompositeFileTransferJob::doKill()
return true;
}
void CompositeFileTransferJob::slotProcessedAmount(KJob *job, KJob::Unit unit, qulonglong amount)
void CompositeFileTransferJob::slotProcessedAmount(KJob * /*job*/, KJob::Unit unit, qulonglong amount)
{
Q_UNUSED(job);
m_currentJobSentPayloadSize = amount;
const auto totalSent = m_totalSentPayloadSize + m_currentJobSentPayloadSize;

View file

@ -28,10 +28,8 @@ void IndicatorHelper::iconPathHook()
{
}
int IndicatorHelper::daemonHook(QProcess &kdeconnectd)
int IndicatorHelper::daemonHook(QProcess & /*kdeconnectd*/)
{
Q_UNUSED(kdeconnectd);
return 0;
}

View file

@ -94,9 +94,8 @@ void DevicesModel::deviceRemoved(const QString &id)
}
}
void DevicesModel::deviceUpdated(const QString &id, bool isVisible)
void DevicesModel::deviceUpdated(const QString &id)
{
Q_UNUSED(isVisible);
int row = rowForDevice(id);
if (row < 0) {
@ -179,17 +178,10 @@ void DevicesModel::receivedDeviceList(QDBusPendingCallWatcher *watcher)
void DevicesModel::appendDevice(DeviceDbusInterface *dev)
{
m_deviceList.append(dev);
connect(dev, &OrgKdeKdeconnectDeviceInterface::nameChanged, this, &DevicesModel::nameChanged);
}
void DevicesModel::nameChanged(const QString &newName)
{
Q_UNUSED(newName);
DeviceDbusInterface *device = static_cast<DeviceDbusInterface *>(sender());
Q_ASSERT(rowForDevice(device->id()) >= 0);
deviceUpdated(device->id(), true);
connect(dev, &OrgKdeKdeconnectDeviceInterface::nameChanged, this, [this, dev]() {
Q_ASSERT(rowForDevice(dev->id()) >= 0);
deviceUpdated(dev->id());
});
}
void DevicesModel::clearDevices()

View file

@ -61,10 +61,9 @@ public:
private Q_SLOTS:
void deviceAdded(const QString &id);
void deviceRemoved(const QString &id);
void deviceUpdated(const QString &id, bool isVisible);
void deviceUpdated(const QString &id);
void refreshDeviceList();
void receivedDeviceList(QDBusPendingCallWatcher *watcher);
void nameChanged(const QString &newName);
Q_SIGNALS:
void rowsChanged();

View file

@ -31,10 +31,8 @@ FindThisDevicePlugin::FindThisDevicePlugin(QObject *parent, const QVariantList &
{
}
void FindThisDevicePlugin::receivePacket(const NetworkPacket &np)
void FindThisDevicePlugin::receivePacket(const NetworkPacket & /*np*/)
{
Q_UNUSED(np);
const QString soundFile = config()->getString(QStringLiteral("ringtone"), defaultSound());
const QUrl soundURL = QUrl::fromLocalFile(soundFile);

View file

@ -37,9 +37,7 @@ LockDevicePlugin::LockDevicePlugin(QObject *parent, const QVariantList &args)
connect(&m_propertiesInterface,
&OrgFreedesktopDBusPropertiesInterface::PropertiesChanged,
this,
[this](const QString &interface, const QVariantMap &properties, QStringList invalidatedProperties) {
Q_UNUSED(invalidatedProperties);
[this](const QString &interface, const QVariantMap &properties) {
if (interface != QLatin1String("org.freedesktop.login1.Session")) {
return;
}

View file

@ -52,17 +52,12 @@ void MMTelephonyPlugin::onModemAdded(const QString &path)
});
}
void MMTelephonyPlugin::onModemRemoved(const QString &path)
{
Q_UNUSED(path);
}
void MMTelephonyPlugin::onCallAdded(ModemManager::Call::Ptr call)
{
qCDebug(KDECONNECT_PLUGIN_MMTELEPHONY) << "Call added" << call->number();
connect(call.get(), &ModemManager::Call::stateChanged, this, [=](MMCallState newState, MMCallState oldState, MMCallStateReason reason) {
onCallStateChanged(call.get(), newState, oldState, reason);
connect(call.get(), &ModemManager::Call::stateChanged, this, [=](MMCallState newState, MMCallState oldState) {
onCallStateChanged(call.get(), newState, oldState);
});
}
@ -91,9 +86,8 @@ QString MMTelephonyPlugin::stateName(MMCallState state)
return event;
}
void MMTelephonyPlugin::onCallStateChanged(ModemManager::Call *call, MMCallState newState, MMCallState oldState, MMCallStateReason reason)
void MMTelephonyPlugin::onCallStateChanged(ModemManager::Call *call, MMCallState newState, MMCallState oldState)
{
Q_UNUSED(reason);
auto event = stateName(newState);
qCDebug(KDECONNECT_PLUGIN_MMTELEPHONY) << "Call state changed" << call->uni() << event;

View file

@ -42,8 +42,7 @@ private:
void onCallAdded(ModemManager::Call::Ptr call);
void onCallRemoved(ModemManager::Call::Ptr call);
void onModemAdded(const QString &path);
void onModemRemoved(const QString &path);
void onCallStateChanged(ModemManager::Call *call, MMCallState newState, MMCallState oldState, MMCallStateReason reason);
void onCallStateChanged(ModemManager::Call *call, MMCallState newState, MMCallState oldState);
void sendMMTelephonyPacket(ModemManager::Call *call, const QString &state);
void sendCancelMMTelephonyPacket(ModemManager::Call *call, const QString &lastState);
static QString stateName(MMCallState state);

View file

@ -119,10 +119,8 @@ void MprisControlPlugin::seeked(qlonglong position)
sendPacket(np);
}
void MprisControlPlugin::propertiesChanged(const QString &propertyInterface, const QVariantMap &properties)
void MprisControlPlugin::propertiesChanged(const QString & /*propertyInterface*/, const QVariantMap &properties)
{
Q_UNUSED(propertyInterface);
OrgFreedesktopDBusPropertiesInterface *propertiesInterface = (OrgFreedesktopDBusPropertiesInterface *)sender();
const auto end = playerList.constEnd();
const auto it = std::find_if(playerList.constBegin(), end, [propertiesInterface](const MprisPlayer &player) {

View file

@ -159,17 +159,14 @@ void MprisRemotePlayerMediaPlayer2Player::Seek(qlonglong Offset)
m_plugin->seek(Offset);
}
void MprisRemotePlayerMediaPlayer2Player::SetPosition(QDBusObjectPath TrackId, qlonglong Position)
void MprisRemotePlayerMediaPlayer2Player::SetPosition(QDBusObjectPath /*TrackId*/, qlonglong Position)
{
Q_UNUSED(TrackId)
m_plugin->setPlayer(m_parent->identity());
m_plugin->setPosition(Position / 1000);
}
void MprisRemotePlayerMediaPlayer2Player::OpenUri(QString Uri)
void MprisRemotePlayerMediaPlayer2Player::OpenUri(QString /*Uri*/)
{
Q_UNUSED(Uri)
}
void MprisRemotePlayerMediaPlayer2Player::controlsChanged()

View file

@ -241,10 +241,9 @@ void RunCommandConfig::insertRow(int i, const QString &name, const QString &comm
m_entriesModel->insertRow(i, QList<QStandardItem *>() << newName << newCommand);
}
void RunCommandConfig::onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
void RunCommandConfig::onDataChanged(const QModelIndex & /*topLeft*/, const QModelIndex &bottomRight)
{
markAsChanged();
Q_UNUSED(topLeft);
if (bottomRight.row() == m_entriesModel->rowCount() - 1) {
// TODO check both entries are still empty
insertEmptyRow();

View file

@ -73,7 +73,6 @@ void NotifyingApplicationModel::clearApplications()
QVariant NotifyingApplicationModel::data(const QModelIndex &index, int role) const
{
Q_UNUSED(role);
if (!index.isValid() || index.row() < 0 || index.row() >= m_apps.size() || index.column() > 3) {
return QVariant();
}

View file

@ -62,7 +62,7 @@ void ConversationModel::setDeviceId(const QString &deviceId)
<< "of" << this;
if (m_conversationsInterface) {
disconnect(m_conversationsInterface, SIGNAL(conversationUpdated(QDBusVariant)), this, SLOT(handleConversationUpdate(QDBusVariant)));
disconnect(m_conversationsInterface, SIGNAL(conversationLoaded(qint64, quint64)), this, SLOT(handleConversationLoaded(qint64, quint64)));
disconnect(m_conversationsInterface, SIGNAL(conversationLoaded(qint64, quint64)), this, SLOT(handleConversationLoaded(qint64)));
disconnect(m_conversationsInterface, SIGNAL(conversationCreated(QDBusVariant)), this, SLOT(handleConversationCreated(QDBusVariant)));
delete m_conversationsInterface;
}
@ -71,7 +71,7 @@ void ConversationModel::setDeviceId(const QString &deviceId)
m_conversationsInterface = new DeviceConversationsDbusInterface(deviceId, this);
connect(m_conversationsInterface, SIGNAL(conversationUpdated(QDBusVariant)), this, SLOT(handleConversationUpdate(QDBusVariant)));
connect(m_conversationsInterface, SIGNAL(conversationLoaded(qint64, quint64)), this, SLOT(handleConversationLoaded(qint64, quint64)));
connect(m_conversationsInterface, SIGNAL(conversationLoaded(qint64, quint64)), this, SLOT(handleConversationLoaded(qint64)));
connect(m_conversationsInterface, SIGNAL(conversationCreated(QDBusVariant)), this, SLOT(handleConversationCreated(QDBusVariant)));
connect(m_conversationsInterface, SIGNAL(attachmentReceived(QString, QString)), this, SIGNAL(filePathReceived(QString, QString)));
@ -205,9 +205,8 @@ void ConversationModel::handleConversationCreated(const QDBusVariant &msg)
}
}
void ConversationModel::handleConversationLoaded(qint64 threadID, quint64 numMessages)
void ConversationModel::handleConversationLoaded(qint64 threadID)
{
Q_UNUSED(numMessages)
if (threadID != m_threadId) {
return;
}

View file

@ -68,7 +68,7 @@ Q_SIGNALS:
private Q_SLOTS:
void handleConversationUpdate(const QDBusVariant &message);
void handleConversationLoaded(qint64 threadID, quint64 numMessages);
void handleConversationLoaded(qint64 threadID);
void handleConversationCreated(const QDBusVariant &message);
private:

View file

@ -26,11 +26,8 @@
#include "smsapp/gsmasciimap.h"
#include "smshelper_debug.h"
QObject *SmsHelper::singletonProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
QObject *SmsHelper::singletonProvider(QQmlEngine * /*engine*/, QJSEngine * /*scriptEngine*/)
{
Q_UNUSED(engine);
Q_UNUSED(scriptEngine);
return new SmsHelper();
}

View file

@ -11,11 +11,8 @@ ThumbnailsProvider::ThumbnailsProvider()
{
}
QImage ThumbnailsProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
QImage ThumbnailsProvider::requestImage(const QString &id, QSize * /*size*/, const QSize & /*requestedSize*/)
{
Q_UNUSED(size)
Q_UNUSED(requestedSize)
if (m_thumbnails.contains(id)) {
return m_thumbnails.value(id);
}