Commit 34047117 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port to for (... : ...) and use isEmpty when it's possible

parent a29bd732
......@@ -361,7 +361,7 @@ void HtmlExportJob::createMonthView(QTextStream *ts)
KCalCore::Event::List events = d->mCalendar->events(start, d->mCalendar->timeSpec(),
KCalCore::EventSortStartDate,
KCalCore::SortDirectionAscending);
if (events.count()) {
if (!events.isEmpty()) {
*ts << "<table>";
foreach (const KCalCore::Event::Ptr &event, events) {
Q_ASSERT(event);
......@@ -632,7 +632,7 @@ void HtmlExportJob::createTodo(QTextStream *ts, const KCalCore::Todo::Ptr &todo)
if (!todo->description().isEmpty()) {
*ts << " <p>" << breakString(cleanChars(todo->description())) << "</p>" << endl;
}
if (relations.count()) {
if (!relations.isEmpty()) {
*ts << " <div align=\"right\"><a href=\"#sub" << todo->uid()
<< "\">" << i18nc("@title:column sub-to-dos of the parent to-do",
"Sub-To-dos") << "</a></div>" << endl;
......@@ -759,7 +759,7 @@ void HtmlExportJob::formatCategories(QTextStream *ts, const KCalCore::Incidence:
void HtmlExportJob::formatAttendees(QTextStream *ts, const KCalCore::Incidence::Ptr &incidence)
{
KCalCore::Attendee::List attendees = incidence->attendees();
if (attendees.count()) {
if (!attendees.isEmpty()) {
*ts << "<em>";
const KContacts::Addressee organizer = d->mOrganizersMap.value(incidence->uid());
if (!organizer.isEmpty()) {
......
......@@ -85,7 +85,7 @@ public:
allowedTypes.insert(QStringLiteral("KDateTimeWidget"), i18n("Date & Time"));
allowedTypes.insert(QStringLiteral("KDatePicker"), i18n("Date"));
QList<QWidget *> list = wdg->findChildren<QWidget *>();
const QList<QWidget *> list = wdg->findChildren<QWidget *>();
QWidget *it;
Q_FOREACH (it, list) {
if (allowedTypes.contains(QLatin1String(it->metaObject()->className()))) {
......@@ -217,9 +217,9 @@ void KCMDesignerFields::importFile()
void KCMDesignerFields::loadUiFiles()
{
const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, uiPath(), QStandardPaths::LocateDirectory);
Q_FOREACH (const QString &dir, dirs) {
for (const QString &dir : dirs) {
const QStringList fileNames = QDir(dir).entryList(QStringList() << QStringLiteral("*.ui"));
Q_FOREACH (const QString &file, fileNames) {
for (const QString &file : fileNames) {
new PageItem(mPageView, dir + QLatin1Char('/') + file);
}
}
......
......@@ -115,8 +115,8 @@ void TodoSummaryWidget::updateView()
KCalCore::Todo::List prList;
const QDate currDate = QDate::currentDate();
KCalCore::Todo::List todos = mCalendar->todos();
Q_FOREACH (const KCalCore::Todo::Ptr &todo, todos) {
const KCalCore::Todo::List todos = mCalendar->todos();
for (const KCalCore::Todo::Ptr &todo : todos) {
if (todo->hasDueDate()) {
const int daysTo = currDate.daysTo(todo->dtDue().date());
if (daysTo >= mDaysToGo) {
......
......@@ -281,10 +281,10 @@ public:
mHolidayCombo->setWhatsThis(KOPrefs::instance()->holidaysItem()->whatsThis());
QStringList regions = KHolidays::HolidayRegion::regionCodes();
const QStringList regions = KHolidays::HolidayRegion::regionCodes();
QMap<QString, QString> regionsMap;
foreach (const QString &regionCode, regions) {
for (const QString &regionCode : regions) {
QString name = KHolidays::HolidayRegion::name(regionCode);
QLocale locale(KHolidays::HolidayRegion::languageCode(regionCode));
QString languageName = QLocale::languageToString(locale.language());
......
......@@ -140,10 +140,7 @@ Quickview::Quickview(const KPIM::Person &person, const Akonadi::Collection &col)
//create etm for mCollection
Akonadi::ChangeRecorder *monitor = new Akonadi::ChangeRecorder(this);
Akonadi::ItemFetchScope scope;
QStringList allMimeTypes;
allMimeTypes << KCalCore::Event::eventMimeType() << KCalCore::Todo::todoMimeType()
<< KCalCore::Journal::journalMimeType();
const QStringList allMimeTypes = { KCalCore::Event::eventMimeType(), KCalCore::Todo::todoMimeType(), KCalCore::Journal::journalMimeType()};
scope.fetchFullPayload(true);
scope.fetchAttribute<Akonadi::EntityDisplayAttribute>();
......@@ -153,7 +150,7 @@ Quickview::Quickview(const KPIM::Person &person, const Akonadi::Collection &col)
monitor->setItemFetchScope(scope);
monitor->setAllMonitored(true);
foreach (const QString &mimetype, allMimeTypes) {
for (const QString &mimetype : allMimeTypes) {
monitor->setMimeTypeMonitored(mimetype, true);
}
......
......@@ -433,9 +433,8 @@ QModelIndexList ReparentingModel::descendants(const QModelIndex &sourceIndex)
void ReparentingModel::removeDuplicates(const QModelIndex &sourceIndex)
{
QModelIndexList list;
list << sourceIndex << descendants(sourceIndex);
Q_FOREACH (const QModelIndex &descendant, list) {
const QModelIndexList list = QModelIndexList() << sourceIndex << descendants(sourceIndex);
for (const QModelIndex &descendant : list) {
Q_FOREACH (const Node::Ptr &proxyNode, mProxyNodes) {
if (proxyNode->isDuplicateOf(descendant)) {
//Removenode from proxy
......
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