Commit 038128b7 authored by David Jarvie's avatar David Jarvie
Browse files

Code quality fixes

parent a9b7c466
Pipeline #135475 passed with stage
in 1 minute and 26 seconds
/*
* commandoptions.cpp - extract command line options
* Program: kalarm
* SPDX-FileCopyrightText: 2001-2021 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2001-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -489,7 +489,6 @@ void CommandOptions::process()
{
count = 0;
const QByteArray dateTime = mParser->value(*mOptions.at(UNTIL)).toLocal8Bit();
bool ok;
if (mParser->isSet(*mOptions.at(TIME)))
ok = KAlarm::convertTimeString(dateTime, endTime, mAlarmTime);
else
......@@ -738,8 +737,7 @@ bool CommandOptions::checkCommand(Option command, Command code, EditAlarmDlg::Ty
|| !mParser->isSet(*mOptions.at(command)))
return false;
if (mCommand != NONE
&& (allowedEditType == EditAlarmDlg::NO_TYPE
|| (allowedEditType != EditAlarmDlg::NO_TYPE && (mCommand != NEW || mEditType != allowedEditType))))
&& (allowedEditType == EditAlarmDlg::NO_TYPE || (mCommand != NEW || mEditType != allowedEditType)))
setErrorIncompatible(mCommandOpt, command);
qCDebug(KALARM_LOG).nospace() << "CommandOptions::checkCommand: " << optionName(command);
mCommand = code;
......
......@@ -60,7 +60,7 @@ DeferAlarmDlg::DeferAlarmDlg(const DateTime& initialDT, bool anyTimeOption, bool
QPushButton* deferButton = mButtonBox->addButton(i18nc("@action:button", "Cancel Deferral"), QDialogButtonBox::ActionRole);
deferButton->setWhatsThis(i18nc("@info:whatsthis", "Cancel the deferred alarm. This does not affect future recurrences."));
connect(mButtonBox, &QDialogButtonBox::clicked, this,
[this, deferButton](QAbstractButton* btn)
[this, deferButton](const QAbstractButton* btn)
{
if (btn == deferButton)
slotCancelDeferral();
......
......@@ -266,9 +266,9 @@ void EditAlarmDlg::init(const KAEvent& event)
// Controls specific to the alarm type
QGroupBox* actionBox = new QGroupBox(i18nc("@title:group", "Action"), mainPage);
topLayout->addWidget(actionBox, 1);
auto layout = new QVBoxLayout(actionBox);
auto vlayout = new QVBoxLayout(actionBox);
type_init(actionBox, layout);
type_init(actionBox, vlayout);
if (!mTemplate)
{
......
/*
* kalarmapp.cpp - the KAlarm application object
* Program: kalarm
* SPDX-FileCopyrightText: 2001-2021 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2001-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -405,8 +405,7 @@ int KAlarmApp::activateInstance(const QStringList& args, const QString& workingD
static bool firstInstance = true;
bool dontRedisplay = false;
CommandOptions::Command command = CommandOptions::NONE;
const bool processOptions = (!firstInstance || !isSessionRestored());
if (processOptions)
if (!firstInstance || !isSessionRestored())
{
options->process();
#ifndef NDEBUG
......@@ -440,10 +439,7 @@ int KAlarmApp::activateInstance(const QStringList& args, const QString& workingD
default:
break;
}
}
if (processOptions)
{
switch (command)
{
case CommandOptions::TRIGGER_EVENT:
......@@ -549,7 +545,7 @@ int KAlarmApp::activateInstance(const QStringList& args, const QString& workingD
const Preferences::SoundType type = (flags & KAEvent::BEEP) ? Preferences::Sound_Beep
: (flags & KAEvent::SPEAK) ? Preferences::Sound_Speak
: Preferences::Sound_File;
dlg->setAudio(type, options->audioFile(), options->audioVolume(), (flags & KAEvent::REPEAT_SOUND ? 0 : -1));
dlg->setAudio(type, options->audioFile(), options->audioVolume(), ((flags & KAEvent::REPEAT_SOUND) ? 0 : -1));
}
if (options->reminderMinutes())
dlg->setReminder(options->reminderMinutes(), (options->flags() & KAEvent::REMINDER_ONCE));
......
/*
* kalarmapp.h - the KAlarm application object
* Program: kalarm
* SPDX-FileCopyrightText: 2001-2021 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2001-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -210,7 +210,7 @@ private:
{
ActionQEntry(QueuedAction a, const EventId& id) : action(a), eventId(id) { }
ActionQEntry(QueuedAction a, const EventId& id, const QString& resId) : action(a), eventId(id), resourceId(resId) { }
ActionQEntry(const KAEvent& e, QueuedAction a = QueuedAction::Handle) : action(a), event(e) { }
explicit ActionQEntry(const KAEvent& e, QueuedAction a = QueuedAction::Handle) : action(a), event(e) { }
ActionQEntry() = default;
QueuedAction action;
EventId eventId;
......
......@@ -299,9 +299,9 @@ void KAMail::slotEmailSent(KJob* job)
if (!mJobs.isEmpty())
{
// Send the next queued email
auto job = mJobs.head();
connect(job, &KJob::result, instance(), &KAMail::slotEmailSent);
job->start();
auto job1 = mJobs.head();
connect(job1, &KJob::result, instance(), &KAMail::slotEmailSent);
job1->start();
}
}
......
......@@ -306,7 +306,7 @@ private:
class MainSpinBox : public SpinBox
{
public:
MainSpinBox(SpinBox2* parent)
explicit MainSpinBox(SpinBox2* parent)
: SpinBox(parent), owner(parent) { }
MainSpinBox(int minValue, int maxValue, SpinBox2* parent)
: SpinBox(minValue, maxValue, parent), owner(parent) { }
......
......@@ -146,16 +146,16 @@ QSize StackedScrollGroup::adjustSize(bool force)
}
}
mSized = true;
QSize s = mWidgets.at(0)->parentWidget()->sizeHint();
if (s.height() < mMinHeight)
s.setHeight(mMinHeight);
mWidgets.at(0)->parentWidget()->resize(s);
QSize sz = mWidgets.at(0)->parentWidget()->sizeHint();
if (sz.height() < mMinHeight)
sz.setHeight(mMinHeight);
mWidgets.at(0)->parentWidget()->resize(sz);
for (QWidget* w = mWidgets.at(0)->parentWidget(); w && w != mDialog; w = w->parentWidget())
w->setMinimumHeight(qMin(w->minimumSizeHint().height(), w->sizeHint().height()));
dlgsize.setHeight(dlgsize.height() - mHeightReduction);
s = mDialog->QDialog::minimumSizeHint();
if (s.height() > dlgsize.height())
dlgsize.setHeight(s.height());
sz = mDialog->QDialog::minimumSizeHint();
if (sz.height() > dlgsize.height())
dlgsize.setHeight(sz.height());
mDialog->setMinimumHeight(dlgsize.height());
}
mSized = true;
......
......@@ -1092,14 +1092,11 @@ void MainWindow::arrangePanel()
else
{
int minWidth = 0;
if (top)
{
top->show();
mPanelLayout->addWidget(top);
mPanelLayout->addStretch();
mPanel->show();
minWidth = top->minimumSizeHint().width();
}
top->show();
mPanelLayout->addWidget(top);
mPanelLayout->addStretch();
mPanel->show();
minWidth = top->minimumSizeHint().width();
if (bottom)
{
bottom->show();
......
......@@ -51,6 +51,9 @@ public:
static void showError(const KAEvent& event, const DateTime& alarmDateTime,
const QStringList& errmsgs, const QString& dontShowAgain = QString());
MessageDisplay(const MessageDisplay&) = delete;
MessageDisplay& operator=(const MessageDisplay&) = delete;
virtual ~MessageDisplay();
bool isValid() const { return mHelper->isValid(); }
......
......@@ -687,8 +687,8 @@ TimePrefTab::TimePrefTab(StackedScrollGroup* scrollGroup)
{
const QString name = HolidayRegion::name(regionCode);
const QString languageName = QLocale::languageToString(QLocale(HolidayRegion::languageCode(regionCode)).language());
const QString label = languageName.isEmpty() ? name : i18nc("Holiday region, region language", "%1 (%2)", name, languageName);
regionsMap.insert(label, regionCode);
const QString labelText = languageName.isEmpty() ? name : i18nc("Holiday region, region language", "%1 (%2)", name, languageName);
regionsMap.insert(labelText, regionCode);
}
mHolidays->addItem(i18nc("No holiday region", "None"), QString());
......@@ -801,8 +801,8 @@ void TimePrefTab::restore(bool, bool)
{
KADateTime::Spec timeSpec = Preferences::timeSpec();
mTimeZone->setTimeZone(timeSpec.type() == KADateTime::TimeZone ? timeSpec.timeZone() : QTimeZone());
const int i = Preferences::holidays().isValid() ? mHolidays->findData(Preferences::holidays().regionCode()) : 0;
mHolidays->setCurrentIndex(i);
const int ix = Preferences::holidays().isValid() ? mHolidays->findData(Preferences::holidays().regionCode()) : 0;
mHolidays->setCurrentIndex(ix);
mStartOfDay->setValue(Preferences::startOfDay());
mWorkStart->setValue(Preferences::workDayStart());
mWorkEnd->setValue(Preferences::workDayEnd());
......
......@@ -368,7 +368,7 @@ void FileResource::loaded(bool success, QHash<QString, KAEvent>& newEvents, cons
// This is only done when a delayed load fails.
// If the resource previously loaded successfully, leave its events (in
// mEvents) unchanged.
if (!success && !errorMessage.isEmpty())
if (!errorMessage.isEmpty())
Resources::notifyResourceMessage(this, MessageType::Error, xi18nc("@info", "Error loading calendar <resource>%1</resource>.", displayName()), errorMessage);
return;
}
......
/*
* fileresourceconfigmanager.h - config manager for resources accessed via file system
* Program: kalarm
* SPDX-FileCopyrightText: 2020 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2020-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -29,6 +29,9 @@ public:
*/
static FileResourceConfigManager* instance();
FileResourceConfigManager(const FileResourceConfigManager&) = delete;
FileResourceConfigManager& operator=(const FileResourceConfigManager&) = delete;
/** Destructor.
* Writes the 'kalarmresources' config file.
*/
......
/*
* fileresourcedatamodel.cpp - model containing file system resources and their events
* Program: kalarm
* SPDX-FileCopyrightText: 2007-2021 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2007-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -29,7 +29,7 @@ private:
public:
Type type;
Node(Resource& r) : ritem(r), type(Type::Resource) {}
explicit Node(Resource& r) : ritem(r), type(Type::Resource) {}
Node(KAEvent* e, Resource& r) : eitem(e), owner(r), type(Type::Event) {}
~Node()
{
......@@ -835,7 +835,7 @@ QModelIndex FileResourceDataModel::index(int row, int column, const QModelIndex&
if (!column)
{
const QVector<Node*>& nodes = mResourceNodes.value(Resource());
if (row >= 0 && row < nodes.count())
if (row < nodes.count())
return createIndex(row, column, nodes[row]);
}
}
......@@ -945,9 +945,9 @@ QVariant FileResourceDataModel::data(const QModelIndex& ix, int role) const
// This is an Event row
if (role == ParentResourceIdRole)
return node->parent().id();
const Resource res = node->parent();
const Resource resp = node->parent();
bool handled;
const QVariant value = eventData(role, ix.column(), *event, res, handled);
const QVariant value = eventData(role, ix.column(), *event, resp, handled);
if (handled)
return value;
}
......
......@@ -58,7 +58,7 @@ struct CollectionProperties
bool readOnly;
// Fetch the properties of a collection which has been fetched by CollectionFetchJob.
CollectionProperties(const Akonadi::Collection&);
explicit CollectionProperties(const Akonadi::Collection&);
};
const Akonadi::Collection::Rights WritableRights = Akonadi::Collection::CanChangeItem | Akonadi::Collection::CanCreateItem | Akonadi::Collection::CanDeleteItem;
......
......@@ -101,10 +101,10 @@ bool FileResourceSettings::readConfig()
mStandard = readAlarmTypes(KEY_STANDARD);
// Read storage type and validate against location.
const QString type = mConfigGroup->readEntry(KEY_TYPE, QString());
if (type == STORAGE_FILE)
const QString storageType = mConfigGroup->readEntry(KEY_TYPE, QString());
if (storageType == STORAGE_FILE)
mStorageType = File;
else if (type == STORAGE_DIR)
else if (storageType == STORAGE_DIR)
mStorageType = Directory;
else
{
......
/*
* fileresourcesettings.h - settings for calendar resource accessed via file system
* Program: kalarm
* SPDX-FileCopyrightText: 2020,2021 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2020-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -51,6 +51,9 @@ public:
CalEvent::Types enabledTypes, CalEvent::Types standardTypes,
bool readOnly);
FileResourceSettings(const FileResourceSettings&) = delete;
FileResourceSettings& operator=(const FileResourceSettings&) = delete;
~FileResourceSettings();
/** Reads the settings from the resource's config file section.
......
......@@ -721,10 +721,10 @@ QString ResourceDataModelBase::alarmTimeText(const DateTime& dateTime, char lead
const QTime t(1,30,30);
const QString nozero = locale.toString(t, timeFormat);
const QString zero = locale.toString(t, timeFullFormat);
for (int i = 0; i < nozero.size(); ++i)
if (nozero[i] != zero[i])
for (int j = 0; j < nozero.size(); ++j)
if (nozero[j] != zero[j])
{
hourOffset = i;
hourOffset = j;
break;
}
}
......
......@@ -324,7 +324,6 @@ void TrayWindow::updateIcon()
*/
QString TrayWindow::tooltipAlarmText() const
{
KAEvent event;
const QString& prefix = Preferences::tooltipTimeToPrefix();
int maxCount = Preferences::tooltipAlarmCount();
const KADateTime now = KADateTime::currentLocalDateTime();
......
/*
* undo.cpp - undo/redo facility
* Program: kalarm
* SPDX-FileCopyrightText: 2005-2020 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2005-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -77,6 +77,8 @@ class UndoMultiBase : public UndoItem
: UndoItem(t, name), mUndos(new Undo::List) {}
UndoMultiBase(Undo::Type t, Undo::List* undos, const QString& name)
: UndoItem(t, name), mUndos(undos) {}
UndoMultiBase(const UndoMultiBase&) = delete;
UndoMultiBase& operator=(const UndoMultiBase&) = delete;
~UndoMultiBase() override { delete mUndos; }
const Undo::List* undos() const { return mUndos; }
protected:
......@@ -125,6 +127,8 @@ class UndoEdit : public UndoItem
public:
UndoEdit(Undo::Type, const KAEvent& oldEvent, const QString& newEventID,
const Resource&, const QStringList& dontShowErrors, const QString& description);
UndoEdit(const UndoEdit&) = delete;
UndoEdit& operator=(const UndoEdit&) = delete;
~UndoEdit() override;
Operation operation() const override { return EDIT; }
QString defaultActionText() const override;
......@@ -150,6 +154,8 @@ class UndoDelete : public UndoItem
public:
UndoDelete(Undo::Type, const Undo::Event&, const QString& name = QString());
UndoDelete(Undo::Type, const KAEvent&, const Resource&, const QStringList& dontShowErrors, const QString& name = QString());
UndoDelete(const UndoDelete&) = delete;
UndoDelete& operator=(const UndoDelete&) = delete;
~UndoDelete() override;
Operation operation() const override { return DELETE; }
QString defaultActionText() const override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment