Verified Commit 5444f004 authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Fix clazy errors (foreach loop detaching/missing std::as_const)

parent 5f96a706
Pipeline #94874 passed with stage
in 5 minutes and 47 seconds
......@@ -506,7 +506,8 @@ QVector<qint64> CalendarManager::enabledTodoCollections()
void CalendarManager::refreshEnabledTodoCollections()
{
m_enabledTodoCollections.clear();
for (auto selectedIndex : m_calendar->checkableProxyModel()->selectionModel()->selectedIndexes()) {
const auto selectedIndexes = m_calendar->checkableProxyModel()->selectionModel()->selectedIndexes();
for (auto selectedIndex : selectedIndexes) {
auto collection = selectedIndex.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
if (collection.contentMimeTypes().contains(QStringLiteral("application/x-vnd.akonadi.calendar.todo"))) {
m_enabledTodoCollections.append(collection.id());
......@@ -708,22 +709,22 @@ bool CalendarManager::hasChildren(KCalendarCore::Incidence::Ptr incidence)
void CalendarManager::deleteAllChildren(KCalendarCore::Incidence::Ptr incidence)
{
auto allChildren = m_calendar->childIncidences(incidence->uid());
const auto allChildren = m_calendar->childIncidences(incidence->uid());
for (auto child : allChildren) {
for (const auto &child : allChildren) {
if (!m_calendar->childIncidences(child->uid()).isEmpty()) {
deleteAllChildren(child);
}
}
for (auto child : allChildren) {
for (const auto &child : allChildren) {
m_calendar->deleteIncidence(child);
}
}
void CalendarManager::deleteIncidence(KCalendarCore::Incidence::Ptr incidence, bool deleteChildren)
{
auto directChildren = m_calendar->childIncidences(incidence->uid());
const auto directChildren = m_calendar->childIncidences(incidence->uid());
if (!directChildren.isEmpty()) {
if (deleteChildren) {
......@@ -731,8 +732,9 @@ void CalendarManager::deleteIncidence(KCalendarCore::Incidence::Ptr incidence, b
deleteAllChildren(incidence);
} else {
m_changer->startAtomicOperation(i18n("Delete task and make sub-tasks independent"));
for (auto child : directChildren) {
for (auto instance : m_calendar->instances(child)) {
for (const auto &child : directChildren) {
const auto instances = m_calendar->instances(child);
for (const auto &instance : instances) {
KCalendarCore::Incidence::Ptr oldInstance(instance->clone());
instance->setRelatedTo(QString());
m_changer->modifyIncidence(m_calendar->item(instance), oldInstance);
......
......@@ -408,19 +408,19 @@ void InfiniteCalendarViewModel::setCalendar(Akonadi::ETMCalendar *calendar)
m_insertedIds.clear();
m_calendar = calendar;
for (auto model : m_monthViewModels) {
for (auto model : std::as_const(m_monthViewModels)) {
model->model()->setCalendar(calendar);
}
for (auto model : m_scheduleViewModels) {
for (auto model : std::as_const(m_scheduleViewModels)) {
model->model()->setCalendar(calendar);
}
for (auto model : m_weekViewModels) {
for (auto model : std::as_const(m_weekViewModels)) {
model->model()->setCalendar(calendar);
}
for (auto model : m_weekViewMultiDayModels) {
for (auto model : std::as_const(m_weekViewMultiDayModels)) {
model->model()->setCalendar(calendar);
}
......@@ -486,11 +486,11 @@ void InfiniteCalendarViewModel::triggerAffectedModelUpdates()
{
for (auto &model : m_models) {
if (model.modelType != TypeWeek) {
for (const auto &startDate : model.affectedStartDates) {
for (const auto &startDate : std::as_const(model.affectedStartDates)) {
model.multiDayModels->value(startDate)->model()->updateQuery();
}
} else {
for (const auto &startDate : model.affectedStartDates) {
for (const auto &startDate : std::as_const(model.affectedStartDates)) {
model.weekModels->value(startDate)->model()->updateQuery();
}
}
......@@ -545,16 +545,16 @@ QVariantMap InfiniteCalendarViewModel::filter() const
void InfiniteCalendarViewModel::setFilter(const QVariantMap &filter)
{
mFilter = filter;
for (auto model : m_monthViewModels) {
for (auto model : std::as_const(m_monthViewModels)) {
model->model()->setFilter(filter);
}
for (auto model : m_scheduleViewModels) {
for (auto model : std::as_const(m_scheduleViewModels)) {
model->model()->setFilter(filter);
}
for (auto model : m_weekViewModels) {
for (auto model : std::as_const(m_weekViewModels)) {
model->model()->setFilter(filter);
}
for (auto model : m_weekViewMultiDayModels) {
for (auto model : std::as_const(m_weekViewMultiDayModels)) {
model->model()->setFilter(filter);
}
Q_EMIT filterChanged();
......
......@@ -62,7 +62,7 @@ Q_SIGNALS:
void selectedChanged();
private:
class Private;
struct Private;
QLocale m_locale;
std::unique_ptr<Private> d;
};
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