diff --git a/src/alarm.cpp b/src/alarm.cpp --- a/src/alarm.cpp +++ b/src/alarm.cpp @@ -198,16 +198,18 @@ } switch (type) { case Display: - d->mDescription = QStringLiteral(""); + d->mDescription.clear(); break; case Procedure: - d->mFile = d->mDescription = QStringLiteral(""); + d->mFile.clear(); + d->mDescription.clear(); break; case Audio: - d->mFile = QStringLiteral(""); + d->mFile.clear(); break; case Email: - d->mMailSubject = d->mDescription = QStringLiteral(""); + d->mMailSubject.clear(); + d->mDescription.clear(); d->mMailAddresses.clear(); d->mMailAttachFiles.clear(); break; diff --git a/src/calendar.h b/src/calendar.h --- a/src/calendar.h +++ b/src/calendar.h @@ -133,7 +133,7 @@ public IncidenceBase::IncidenceObserver { Q_OBJECT - Q_PROPERTY(QString productId READ productId WRITE setProductId) + Q_PROPERTY(QString productId READ productId WRITE setProductId) //clazy:exclude=qproperty-without-notify public: diff --git a/src/compat.cpp b/src/compat.cpp --- a/src/compat.cpp +++ b/src/compat.cpp @@ -121,7 +121,7 @@ newSummary.remove(QRegExp(QStringLiteral("\n.*"))); incidence->setSummary(newSummary); if (oldDescription == newSummary) { - incidence->setDescription(QStringLiteral("")); + incidence->setDescription(QLatin1String("")); } } } diff --git a/src/customproperties.cpp b/src/customproperties.cpp --- a/src/customproperties.cpp +++ b/src/customproperties.cpp @@ -196,9 +196,9 @@ // Validate the property name and convert any null string to empty string if (checkName(it.key())) { if (d->isVolatileProperty(QLatin1String(it.key()))) { - d->mVolatileProperties[it.key()] = it.value().isNull() ? QStringLiteral("") : it.value(); + d->mVolatileProperties[it.key()] = it.value().isNull() ? QLatin1String("") : it.value(); } else { - d->mProperties[it.key()] = it.value().isNull() ? QStringLiteral("") : it.value(); + d->mProperties[it.key()] = it.value().isNull() ? QLatin1String("") : it.value(); } if (!changed) { customPropertyUpdate(); diff --git a/src/icalformat_p.cpp b/src/icalformat_p.cpp --- a/src/icalformat_p.cpp +++ b/src/icalformat_p.cpp @@ -2567,7 +2567,8 @@ icalvalue_free(v); break; } - } + } //end of ICAL_X_PROPERTY + Q_FALLTHROUGH(); default: switch (kind) { case ICAL_RDATE_PROPERTY: @@ -2770,7 +2771,7 @@ p = icalcomponent_get_first_property(calendar, ICAL_PRODID_PROPERTY); if (!p) { qCDebug(KCALCORE_LOG) << "No PRODID property found"; - d->mLoadedProductId = QStringLiteral(""); + d->mLoadedProductId.clear(); } else { d->mLoadedProductId = QString::fromUtf8(icalproperty_get_prodid(p)); diff --git a/src/occurrenceiterator.cpp b/src/occurrenceiterator.cpp --- a/src/occurrenceiterator.cpp +++ b/src/occurrenceiterator.cpp @@ -123,7 +123,7 @@ Incidence::Ptr incidence(inc), lastInc(inc); qint64 offset(0), lastOffset(0); QDateTime occurrenceStartDate; - for (auto recurrenceId : qAsConst(occurrences)) { + for (const auto &recurrenceId : qAsConst(occurrences)) { occurrenceStartDate = recurrenceId; bool resetIncidence = false; diff --git a/src/person.h b/src/person.h --- a/src/person.h +++ b/src/person.h @@ -214,14 +214,14 @@ */ KCALCORE_EXPORT QDataStream &operator>>(QDataStream &stream, KCalCore::Person::Ptr &person); -} - /** Return a hash value for a Person argument. @param key is a Person. */ KCALCORE_EXPORT uint qHash(const KCalCore::Person &key); +} + //@cond PRIVATE Q_DECLARE_TYPEINFO(KCalCore::Person::Ptr, Q_MOVABLE_TYPE); Q_DECLARE_METATYPE(KCalCore::Person::Ptr) diff --git a/src/person.cpp b/src/person.cpp --- a/src/person.cpp +++ b/src/person.cpp @@ -168,14 +168,15 @@ return d->mCount; } -uint qHash(const KCalCore::Person &key) +uint KCalCore::qHash(const KCalCore::Person &key) { return qHash(key.fullName()); } QDataStream &KCalCore::operator<<(QDataStream &stream, const KCalCore::Person::Ptr &person) { - return stream << person->d->mName + return stream + << person->d->mName << person->d->mEmail << person->d->mCount; } diff --git a/src/recurrence.cpp b/src/recurrence.cpp --- a/src/recurrence.cpp +++ b/src/recurrence.cpp @@ -1147,16 +1147,16 @@ } QDateTime kdt(startDateTime()); - for (const auto &date : d->mRDates) { + for (const auto &date : qAsConst(d->mRDates)) { kdt.setDate(date); if (kdt > nextDT) { dates << kdt; break; } } // Add the next occurrences from all RRULEs. - for (auto rule : d->mRRules) { + for (const auto &rule : qAsConst(d->mRRules)) { QDateTime dt = rule->getNextDate(nextDT); if (dt.isValid()) { dates << dt; @@ -1174,7 +1174,7 @@ if (!std::binary_search(d->mExDates.constBegin(), d->mExDates.constEnd(), nextDT.date()) && !std::binary_search(d->mExDateTimes.constBegin(), d->mExDateTimes.constEnd(), nextDT)) { bool allowed = true; - for (auto rule : d->mExRules) { + for (const auto &rule : qAsConst(d->mExRules)) { allowed = allowed && !rule->recursAt(nextDT); } if (allowed) { @@ -1217,16 +1217,16 @@ } QDateTime kdt(startDateTime()); - for (const auto &date : d->mRDates) { + for (const auto &date : qAsConst(d->mRDates)) { kdt.setDate(date); if (kdt < prevDT) { dates << kdt; break; } } // Add the previous occurrences from all RRULEs. - for (auto rule : d->mRRules) { + for (const auto &rule : qAsConst(d->mRRules)) { QDateTime dt = rule->getPreviousDate(prevDT); if (dt.isValid()) { dates << dt; @@ -1244,7 +1244,7 @@ if (!std::binary_search(d->mExDates.constBegin(), d->mExDates.constEnd(), prevDT.date()) && !std::binary_search(d->mExDateTimes.constBegin(), d->mExDateTimes.constEnd(), prevDT)) { bool allowed = true; - for (auto rule : d->mExRules) { + for (const auto &rule : qAsConst(d->mExRules)) { allowed = allowed && !rule->recursAt(prevDT); } if (allowed) { diff --git a/src/recurrencerule.cpp b/src/recurrencerule.cpp --- a/src/recurrencerule.cpp +++ b/src/recurrencerule.cpp @@ -2071,8 +2071,7 @@ if (!d->mByDays.isEmpty()) { QStringList lst; for (int i = 0, iend = d->mByDays.count(); i < iend; ++i) { - \ - lst.append((d->mByDays[i].pos() ? QString::number(d->mByDays[i].pos()) : QStringLiteral("")) + + lst.append((d->mByDays[i].pos() ? QString::number(d->mByDays[i].pos()) : QLatin1String("")) + DateHelper::dayName(d->mByDays[i].day())); } qCDebug(KCALCORE_LOG) << " ByDays: " << lst.join(QStringLiteral(", ")); diff --git a/src/vcalformat.cpp b/src/vcalformat.cpp --- a/src/vcalformat.cpp +++ b/src/vcalformat.cpp @@ -341,42 +341,46 @@ anEvent->setDtStart(QDateTime()); } - // repeat stuff + // recurrence stuff if ((vo = isAPropertyOf(vtodo, VCRRuleProp)) != nullptr) { + uint recurrenceType = Recurrence::rNone; + int recurrenceTypeAbbrLen = 0; + QString tmpStr = (QString::fromUtf8(s = fakeCString(vObjectUStringZValue(vo)))); deleteStr(s); tmpStr = tmpStr.simplified(); - tmpStr = tmpStr.toUpper(); - // first, read the type of the recurrence - int typelen = 1; - uint type = Recurrence::rNone; - if (tmpStr.left(1) == QStringLiteral("D")) { - type = Recurrence::rDaily; - } else if (tmpStr.left(1) == QStringLiteral("W")) { - type = Recurrence::rWeekly; - } else { - typelen = 2; - if (tmpStr.left(2) == QStringLiteral("MP")) { - type = Recurrence::rMonthlyPos; - } else if (tmpStr.left(2) == QStringLiteral("MD")) { - type = Recurrence::rMonthlyDay; - } else if (tmpStr.left(2) == QStringLiteral("YM")) { - type = Recurrence::rYearlyMonth; - } else if (tmpStr.left(2) == QStringLiteral("YD")) { - type = Recurrence::rYearlyDay; + const int tmpStrLen = tmpStr.length(); + if (tmpStrLen > 0) { + tmpStr = tmpStr.toUpper(); + // first, read the type of the recurrence + recurrenceTypeAbbrLen = 1; + if (tmpStr.at(0) == QLatin1String("D")) { + recurrenceType = Recurrence::rDaily; + } else if (tmpStr.at(0) == QLatin1String("W")) { + recurrenceType = Recurrence::rWeekly; + } else if (tmpStrLen > 1) { + recurrenceTypeAbbrLen = 2; + if (tmpStr.leftRef(2) == QLatin1String("MP")) { + recurrenceType = Recurrence::rMonthlyPos; + } else if (tmpStr.leftRef(2) == QLatin1String("MD")) { + recurrenceType = Recurrence::rMonthlyDay; + } else if (tmpStr.leftRef(2) == QLatin1String("YM")) { + recurrenceType = Recurrence::rYearlyMonth; + } else if (tmpStr.leftRef(2) == QLatin1String("YD")) { + recurrenceType = Recurrence::rYearlyDay; + } } } - if (type != Recurrence::rNone) { - + if (recurrenceType != Recurrence::rNone) { // Immediately after the type is the frequency int index = tmpStr.indexOf(QLatin1Char(' ')); int last = tmpStr.lastIndexOf(QLatin1Char(' ')) + 1; // find last entry - int rFreq = tmpStr.midRef(typelen, (index - 1)).toInt(); + int rFreq = tmpStr.midRef(recurrenceTypeAbbrLen, (index - 1)).toInt(); ++index; // advance to beginning of stuff after freq // Read the type-specific settings - switch (type) { + switch (recurrenceType) { case Recurrence::rDaily: anEvent->recurrence()->setDaily(rFreq); break; @@ -781,42 +785,46 @@ /////////////////////////////////////////////////////////////////////////// - // repeat stuff + // recurrence stuff if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != nullptr) { + uint recurrenceType = Recurrence::rNone; + int recurrenceTypeAbbrLen = 0; + QString tmpStr = (QString::fromUtf8(s = fakeCString(vObjectUStringZValue(vo)))); deleteStr(s); tmpStr = tmpStr.simplified(); - tmpStr = tmpStr.toUpper(); - // first, read the type of the recurrence - int typelen = 1; - uint type = Recurrence::rNone; - if (tmpStr.left(1) == QLatin1String("D")) { - type = Recurrence::rDaily; - } else if (tmpStr.left(1) == QLatin1String("W")) { - type = Recurrence::rWeekly; - } else { - typelen = 2; - if (tmpStr.left(2) == QLatin1String("MP")) { - type = Recurrence::rMonthlyPos; - } else if (tmpStr.left(2) == QLatin1String("MD")) { - type = Recurrence::rMonthlyDay; - } else if (tmpStr.left(2) == QLatin1String("YM")) { - type = Recurrence::rYearlyMonth; - } else if (tmpStr.left(2) == QLatin1String("YD")) { - type = Recurrence::rYearlyDay; + const int tmpStrLen = tmpStr.length(); + if (tmpStrLen > 0) { + tmpStr = tmpStr.toUpper(); + // first, read the type of the recurrence + recurrenceTypeAbbrLen = 1; + if (tmpStr.at(0) == QLatin1String("D")) { + recurrenceType = Recurrence::rDaily; + } else if (tmpStr.at(0) == QLatin1String("W")) { + recurrenceType = Recurrence::rWeekly; + } else if (tmpStrLen > 1){ + recurrenceTypeAbbrLen = 2; + if (tmpStr.leftRef(2) == QLatin1String("MP")) { + recurrenceType = Recurrence::rMonthlyPos; + } else if (tmpStr.leftRef(2) == QLatin1String("MD")) { + recurrenceType = Recurrence::rMonthlyDay; + } else if (tmpStr.leftRef(2) == QLatin1String("YM")) { + recurrenceType = Recurrence::rYearlyMonth; + } else if (tmpStr.leftRef(2) == QLatin1String("YD")) { + recurrenceType = Recurrence::rYearlyDay; + } } } - if (type != Recurrence::rNone) { - + if (recurrenceType != Recurrence::rNone) { // Immediately after the type is the frequency int index = tmpStr.indexOf(QLatin1Char(' ')); int last = tmpStr.lastIndexOf(QLatin1Char(' ')) + 1; // find last entry - int rFreq = tmpStr.midRef(typelen, (index - 1)).toInt(); + int rFreq = tmpStr.midRef(recurrenceTypeAbbrLen, (index - 1)).toInt(); ++index; // advance to beginning of stuff after freq // Read the type-specific settings - switch (type) { + switch (recurrenceType) { case Recurrence::rDaily: anEvent->recurrence()->setDaily(rFreq); break;