Commit 4c8ee41a authored by David Jarvie's avatar David Jarvie
Browse files

Clazy fixes

parent b1bf7b6a
Pipeline #44762 canceled with stage
......@@ -1399,8 +1399,10 @@ void EditEmailAlarmDlg::saveState(const KAEvent* event)
*/
bool EditEmailAlarmDlg::type_stateChanged() const
{
int count = mEmailAttachList->count();
QStringList emailAttach;
for (int i = 0, end = mEmailAttachList->count(); i < end; ++i)
emailAttach.reserve(count);
for (int i = 0; i < count; ++i)
emailAttach += mEmailAttachList->itemText(i);
if ((mEmailFromList && mSavedEmailFrom != mEmailFromList->currentIdentityName())
|| mSavedEmailTo != mEmailToEdit->text()
......
......@@ -819,8 +819,10 @@ QVector<KAEvent> getSortedActiveEvents(QObject* parent, AlarmListModel** model)
(*model)->setEventTypeFilter(CalEvent::ACTIVE);
(*model)->sort(AlarmListModel::TimeColumn);
}
int count = (*model)->rowCount();
QVector<KAEvent> result;
for (int i = 0, count = (*model)->rowCount(); i < count; ++i)
result.reserve(count);
for (int i = 0; i < count; ++i)
{
const KAEvent event = (*model)->event(i);
if (event.enabled() && !event.expired())
......
......@@ -349,7 +349,7 @@ void KAlarmApp::showRestoredWindows()
if (!mRestoredWindows.isEmpty())
{
// Display message windows restored at startup.
for (MessageWindow* win : mRestoredWindows)
for (MessageWindow* win : qAsConst(mRestoredWindows))
win->display();
mRestoredWindows.clear();
}
......
......@@ -687,6 +687,7 @@ QStringList extractEmailsAndNormalize(const QString& emailAddresses)
{
const QStringList splitEmails(KEmailAddress::splitAddressList(emailAddresses));
QStringList normalizedEmail;
normalizedEmail.reserve(splitEmails.count());
for (const QString& email : splitEmails)
{
normalizedEmail << KEmailAddress::extractEmailAddress(KEmailAddress::normalizeAddressesAndEncodeIdn(email));
......
......@@ -43,7 +43,7 @@ void FileResourceCreator::doCreateResource()
{
QStringList typeDescs;
for (ResourceType::StorageType t : types)
typeDescs += Resource::storageTypeString(t);
typeDescs += Resource::storageTypeString(t); //clazy:exclude=reserve-candidates There are very few types
ResourceType::StorageType type = types[0];
if (types.count() > 1)
{
......
......@@ -91,8 +91,9 @@ QModelIndexList ResourceFilterModel::match(const QModelIndex& start, int role, c
if (role < Qt::UserRole)
return QSortFilterProxyModel::match(start, role, value, hits, flags);
QModelIndexList matches; //clazy:exclude=inefficient-qlist
const QModelIndexList indexes = sourceModel()->match(mapToSource(start), role, value, hits, flags); //clazy:exclude=inefficient-qlist
QModelIndexList matches; //clazy:exclude=inefficient-qlist
matches.reserve(indexes.count());
for (const QModelIndex& ix : indexes)
{
QModelIndex proxyIndex = mapFromSource(ix);
......@@ -388,7 +389,7 @@ void ResourceCheckListModel::selectionChanged(const QItemSelection& selected, co
}
const QModelIndexList desel = deselected.indexes(); //clazy:exclude=inefficient-qlist
for (const QModelIndex& ix : desel)
mModel->resource(ix).setEnabled(mAlarmType, false);
mModel->resource(ix).setEnabled(mAlarmType, false); //clazy:exclude=writing-to-temporary
}
/******************************************************************************
......
......@@ -333,7 +333,7 @@ QString TrayWindow::tooltipAlarmText() const
// Get today's and tomorrow's alarms, sorted in time order
int i, iend;
QList<TipItem> items;
QList<TipItem> items; //clazy:exclude=inefficient-qlist QList is better than QVector for insertions
QVector<KAEvent> events = KAlarm::getSortedActiveEvents(const_cast<TrayWindow*>(this), &mAlarmsModel);
for (i = 0, iend = events.count(); i < iend; ++i)
{
......
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