Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit b35283ae authored by Laurent Montel's avatar Laurent Montel 😁

Compile without foreach

parent c72951a0
......@@ -110,6 +110,10 @@ install(FILES
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
install( FILES incidenceeditor.categories incidenceeditor.renamecategories DESTINATION ${KDE_INSTALL_CONFDIR} )
if (${KF5Config_VERSION} STRGREATER "5.56.0")
add_definitions(-DQT_NO_FOREACH)
MESSAGE(STATUS "compile without foreach")
endif()
add_subdirectory(src)
if (BUILD_TESTING)
......
......@@ -32,7 +32,7 @@ using namespace IncidenceEditorNG;
void ConflictResolverTest::insertAttendees()
{
foreach (const CalendarSupport::FreeBusyItem::Ptr &item, qAsConst(attendees)) {
for (const CalendarSupport::FreeBusyItem::Ptr &item : qAsConst(attendees)) {
resolver->insertAttendee(item);
}
}
......
......@@ -52,7 +52,7 @@ bool CombinedIncidenceEditor::isDirty() const
bool CombinedIncidenceEditor::isValid() const
{
foreach (IncidenceEditor *editor, mCombinedEditors) {
for (IncidenceEditor *editor : qAsConst(mCombinedEditors)) {
if (!editor->isValid()) {
const QString reason = editor->lastErrorString();
editor->focusInvalidField();
......@@ -91,7 +91,7 @@ void CombinedIncidenceEditor::handleDirtyStatusChange(bool isDirty)
void CombinedIncidenceEditor::load(const KCalCore::Incidence::Ptr &incidence)
{
mLoadedIncidence = incidence;
foreach (IncidenceEditor *editor, mCombinedEditors) {
for (IncidenceEditor *editor : qAsConst(mCombinedEditors)) {
// load() may fire dirtyStatusChanged(), reset mDirtyEditorCount to make sure
// we don't end up with an invalid dirty count.
editor->blockSignals(true);
......@@ -117,7 +117,7 @@ void CombinedIncidenceEditor::load(const KCalCore::Incidence::Ptr &incidence)
void CombinedIncidenceEditor::load(const Akonadi::Item &item)
{
foreach (IncidenceEditor *editor, mCombinedEditors) {
for (IncidenceEditor *editor : qAsConst(mCombinedEditors)) {
// load() may fire dirtyStatusChanged(), reset mDirtyEditorCount to make sure
// we don't end up with an invalid dirty count.
editor->blockSignals(true);
......@@ -142,14 +142,14 @@ void CombinedIncidenceEditor::load(const Akonadi::Item &item)
void CombinedIncidenceEditor::save(const KCalCore::Incidence::Ptr &incidence)
{
foreach (IncidenceEditor *editor, mCombinedEditors) {
for (IncidenceEditor *editor : qAsConst(mCombinedEditors)) {
editor->save(incidence);
}
}
void CombinedIncidenceEditor::save(Akonadi::Item &item)
{
foreach (IncidenceEditor *editor, mCombinedEditors) {
for (IncidenceEditor *editor : qAsConst(mCombinedEditors)) {
editor->save(item);
}
}
......@@ -318,7 +318,7 @@ void ConflictResolver::findAllFreeSlots()
// etareti
// append the allocated array to <fbTable>
// etareti
foreach (const KCalCore::FreeBusy::Ptr &currentFB, filteredFBItems) {
for (const KCalCore::FreeBusy::Ptr &currentFB : qAsConst(filteredFBItems)) {
Q_ASSERT(currentFB); // sanity check
const KCalCore::Period::List busyPeriods = currentFB->busyPeriods();
QVector<int> fbArray(range);
......
......@@ -67,7 +67,8 @@ void IncidenceAlarm::load(const KCalCore::Incidence::Ptr &incidence)
mDateTime->load(incidence);
mAlarms.clear();
foreach (const KCalCore::Alarm::Ptr &alarm, incidence->alarms()) {
const auto lstAlarms = incidence->alarms();
for (const KCalCore::Alarm::Ptr &alarm : lstAlarms) {
mAlarms.append(KCalCore::Alarm::Ptr(new KCalCore::Alarm(*alarm.data())));
}
......@@ -118,9 +119,9 @@ bool IncidenceAlarm::isDirty() const
// if all currently enabled alarms are also in the incidence. The
// disabled alarms are not changed by our code at all, so we assume that
// they're still there.
foreach (const KCalCore::Alarm::Ptr &alarm, mAlarms) {
for (const KCalCore::Alarm::Ptr &alarm : qAsConst(mAlarms)) {
bool found = false;
foreach (const KCalCore::Alarm::Ptr &initialAlarm, initialAlarms) {
for (const KCalCore::Alarm::Ptr &initialAlarm : qAsConst(initialAlarms)) {
if (*alarm == *initialAlarm) {
found = true;
break;
......
......@@ -295,7 +295,8 @@ bool IncidenceAttendee::isDirty() const
const KCalCore::Attendee::List originalList = mLoadedIncidence->attendees();
KCalCore::Attendee::List newList;
foreach (KCalCore::Attendee::Ptr attendee, mDataModel->attendees()) {
const auto lstAttendees = mDataModel->attendees();
for (const KCalCore::Attendee::Ptr &attendee : lstAttendees) {
if (!attendee->fullName().isEmpty()) {
newList.append(attendee);
}
......@@ -309,7 +310,7 @@ bool IncidenceAttendee::isDirty() const
// Okay, again not the most efficient algorithm, but I'm assuming that in the
// bulk of the use cases, the number of attendees is not much higher than 10 or so.
foreach (const KCalCore::Attendee::Ptr &attendee, originalList) {
for (const KCalCore::Attendee::Ptr &attendee : originalList) {
bool found = false;
for (int i = 0; i < newList.count(); ++i) {
if (*(newList[i]) == *attendee) {
......@@ -998,7 +999,8 @@ void IncidenceAttendee::printDebugInfo() const
KCalCore::Attendee::List newList;
qCDebug(INCIDENCEEDITOR_LOG) << "List sizes: " << originalList.count() << newList.count();
foreach (KCalCore::Attendee::Ptr attendee, mDataModel->attendees()) {
const auto lstAttendees = mDataModel->attendees();
for (const KCalCore::Attendee::Ptr &attendee : lstAttendees) {
if (!attendee->fullName().isEmpty()) {
newList.append(attendee);
}
......@@ -1006,7 +1008,7 @@ void IncidenceAttendee::printDebugInfo() const
// Okay, again not the most efficient algorithm, but I'm assuming that in the
// bulk of the use cases, the number of attendees is not much higher than 10 or so.
foreach (const KCalCore::Attendee::Ptr &attendee, originalList) {
for (const KCalCore::Attendee::Ptr &attendee : originalList) {
bool found = false;
for (int i = 0; i < newList.count(); ++i) {
if (newList[i] == attendee) {
......
......@@ -207,7 +207,7 @@ void ResourceModel::slotLDAPCollectionData(const KLDAP::LdapResultObject::List &
// Resources in a collection add this link into ldapCollectionsMap
const auto members = result.object.attributes()[QStringLiteral("uniqueMember")];
foreach (const QByteArray &member, members) {
for (const QByteArray &member : members) {
ldapCollectionsMap.insert(QString::fromLatin1(member), item);
}
}
......
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