Commit 9dceaa81 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Minor optimization

parent 348ebe62
......@@ -142,8 +142,9 @@ void AlarmDialog::load(const KCalCore::Alarm::Ptr &alarm)
KCalCore::Person::List addresses = alarm->mailAddresses();
QStringList add;
add.reserve(addresses.count());
const KCalCore::Person::List::ConstIterator end(addresses.constEnd());
for (KCalCore::Person::List::ConstIterator it = addresses.constBegin();
it != addresses.constEnd(); ++it) {
it != end; ++it) {
add << (*it)->fullName();
}
mUi->mEmailAddress->setText(add.join(QStringLiteral(", ")));
......
......@@ -90,8 +90,8 @@ void IncidenceAlarm::load(const KCalCore::Incidence::Ptr &incidence)
void IncidenceAlarm::save(const KCalCore::Incidence::Ptr &incidence)
{
incidence->clearAlarms();
KCalCore::Alarm::List::ConstIterator it;
for (it = mAlarms.constBegin(); it != mAlarms.constEnd(); ++it) {
const KCalCore::Alarm::List::ConstIterator end(mAlarms.constEnd());
for (KCalCore::Alarm::List::ConstIterator it = mAlarms.constBegin(); it != end; ++it) {
KCalCore::Alarm::Ptr al(new KCalCore::Alarm(*(*it)));
al->setParent(incidence.data());
// We need to make sure that both lists are the same in the end for isDirty.
......
......@@ -82,10 +82,10 @@ IncidenceDateTime::IncidenceDateTime(Ui::EventOrTodoDesktop *ui)
&IncidenceDateTime::toggleTimeZoneVisibility);
mUi->mTimeZoneLabel->setContextMenuPolicy(Qt::NoContextMenu);
QList<QLineEdit *> lineEdits;
lineEdits << mUi->mStartDateEdit->lineEdit() << mUi->mEndDateEdit->lineEdit()
<< mUi->mStartTimeEdit->lineEdit() << mUi->mEndTimeEdit->lineEdit();
foreach (QLineEdit *lineEdit, lineEdits) {
const QList<QLineEdit *> lineEdits {
mUi->mStartDateEdit->lineEdit(), mUi->mEndDateEdit->lineEdit()
,mUi->mStartTimeEdit->lineEdit(), mUi->mEndTimeEdit->lineEdit()};
for (QLineEdit *lineEdit : lineEdits) {
if (lineEdit) {
lineEdit->setClearButtonEnabled(false);
}
......
......@@ -280,7 +280,9 @@ void IncidenceDefaults::setAttachments(const QStringList &attachments,
if (d_ptr->mCleanupTemporaryFiles) {
QFile file(*it);
file.remove();
if (!file.remove()) {
qCCritical(INCIDENCEEDITOR_LOG) << "Uname to remove file " << *it;
}
}
} else {
attachment = KCalCore::Attachment::Ptr(new KCalCore::Attachment(*it, mimeType));
......
......@@ -84,9 +84,8 @@ IncidenceRecurrence::IncidenceRecurrence(IncidenceDateTime *dateTime, Ui::EventO
handleEndAfterOccurrencesChange(1);
toggleRecurrenceWidgets(RecurrenceTypeNone);
fillCombos();
QList<QLineEdit *> lineEdits;
lineEdits << mUi->mExceptionDateEdit->lineEdit() << mUi->mRecurrenceEndDate->lineEdit();
foreach (QLineEdit *lineEdit, lineEdits) {
const QList<QLineEdit *> lineEdits { mUi->mExceptionDateEdit->lineEdit(), mUi->mRecurrenceEndDate->lineEdit()};
for (QLineEdit *lineEdit : lineEdits) {
if (lineEdit) {
lineEdit->setClearButtonEnabled(false);
}
......@@ -152,9 +151,8 @@ KLocalizedString IncidenceRecurrence::subsOrdinal(const KLocalizedString &text,
"translate this as \"1\" if just the number itself "
"should be substituted (1, 22, 123).",
"0");
if (q == QLatin1String("0")) {
QString ordinal;
ordinal = numberToString(number);
if (q == QLatin1Char('0')) {
const QString ordinal = numberToString(number);
return text.subs(ordinal);
} else {
return text.subs(number);
......@@ -630,8 +628,7 @@ void IncidenceRecurrence::handleRecurrenceTypeChange(int currentIndex)
freqKey = QLatin1Char('d');
}
QString labelEvery;
labelEvery = ki18ncp("repeat >every< N years/months/...; "
const QString labelEvery = ki18ncp("repeat >every< N years/months/...; "
"dynamic context 'type': 'd' days, 'w' weeks, "
"'m' months, 'y' years",
"every", "every").
......
......@@ -51,6 +51,7 @@ void KTimeZoneComboBox::Private::fillComboBox()
// Read all system time zones
const QList<QByteArray> lstTimeZoneIds = QTimeZone::availableTimeZoneIds();
mZones.reserve(lstTimeZoneIds.count());
for (const QByteArray &id : lstTimeZoneIds) {
mZones.push_back(QString::fromLatin1(id));
}
......
......@@ -196,7 +196,7 @@ ResourceItem::Ptr ResourceManagement::selectedItem() const
void ResourceManagement::slotStartSearch(const QString &text)
{
((ResourceModel *)mUi->treeResults->model())->startSearch(text);
(static_cast<ResourceModel *>(mUi->treeResults->model()))->startSearch(text);
}
void ResourceManagement::slotShowDetails(const QModelIndex &current)
......
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