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

Minor optimization

parent 3a381e1a
......@@ -72,5 +72,5 @@ QString ContactGrantleeAddressObject::label() const
QString ContactGrantleeAddressObject::formattedAddress() const
{
return mAddress.formattedAddress().replace(QStringLiteral("\n"), QStringLiteral("<br>"));
return mAddress.formattedAddress().replace(QLatin1Char('\n'), QStringLiteral("<br>"));
}
......@@ -299,7 +299,8 @@ QString GrantleeContactFormatter::toHtml(HtmlForm form) const
// Emails
QStringList emails;
foreach (const QString &email, rawContact.emails()) {
const QStringList emailsList = rawContact.emails();
for (const QString &email : emailsList) {
const QString fullEmail = QString::fromLatin1(QUrl::toPercentEncoding(rawContact.fullEmail(email)));
const QString url = QStringLiteral("<a href=\"mailto:%1\">%2</a>")
......@@ -312,7 +313,8 @@ QString GrantleeContactFormatter::toHtml(HtmlForm form) const
// Phone numbers
QVariantList phoneNumbers;
int counter = 0;
foreach (const KContacts::PhoneNumber &phoneNumber, rawContact.phoneNumbers()) {
const KContacts::PhoneNumber::List lstPhone = rawContact.phoneNumbers();
for (const KContacts::PhoneNumber &phoneNumber : lstPhone) {
phoneNumbers.append(phoneNumberHash(phoneNumber, counter));
counter++;
}
......@@ -337,7 +339,8 @@ QString GrantleeContactFormatter::toHtml(HtmlForm form) const
// Homepage
QVariantList websites;
Q_FOREACH (const KContacts::ResourceLocatorUrl &resourceLocator, rawContact.extraUrlList()) {
const KContacts::ResourceLocatorUrl::List extraUrlList = rawContact.extraUrlList();
for (const KContacts::ResourceLocatorUrl &resourceLocator : extraUrlList) {
QString url = resourceLocator.url().url();
if (!url.startsWith(QStringLiteral("http://")) &&
!url.startsWith(QStringLiteral("https://"))) {
......@@ -369,7 +372,8 @@ QString GrantleeContactFormatter::toHtml(HtmlForm form) const
// Addresses
QVariantList addresses;
counter = 0;
foreach (const KContacts::Address &address, rawContact.addresses()) {
const KContacts::Address::List lstAddresses = rawContact.addresses();
for (const KContacts::Address &address : lstAddresses) {
addresses.append(addressHash(address, counter));
counter++;
}
......
......@@ -19,6 +19,7 @@
*/
#include "kaddressbookcontactselectionwidget.h"
#include <QDebug>
#include <AkonadiWidgets/CollectionComboBox>
#include <AkonadiCore/EntityTreeModel>
......@@ -80,6 +81,8 @@ Akonadi::Item::List KAddressBookContactSelectionWidget::selectedItems() const
return collectSelectedItems();
} else if (mAddressBookContactsButton->isChecked()) {
return collectAddressBookItems();
} else {
qWarning() << " It's a bug here.";
}
return Akonadi::Item::List();
......
......@@ -53,7 +53,7 @@ SendLaterDialog::SendLaterDialog(SendLater::SendLaterInfo *info, QWidget *parent
lay->setMargin(0);
w->setLayout(lay);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
mOkButton = buttonBox->button(QDialogButtonBox::Ok);
mOkButton->setObjectName(QStringLiteral("okbutton"));
mOkButton->setDefault(true);
......@@ -78,11 +78,7 @@ SendLaterDialog::SendLaterDialog(SendLater::SendLaterInfo *info, QWidget *parent
mSendLaterWidget->mDateTime->setDateTime(t);
connect(mSendLaterWidget->mRecurrence, &QCheckBox::clicked, this, &SendLaterDialog::slotRecurrenceClicked);
QStringList unitsList;
unitsList << i18n("Days");
unitsList << i18n("Weeks");
unitsList << i18n("Months");
unitsList << i18n("Years");
const QStringList unitsList = {i18n("Days"), i18n("Weeks"), i18n("Months"), i18n("Years")};
mSendLaterWidget->mRecurrenceComboBox->addItems(unitsList);
connect(mSendLaterWidget->mDateTime, &SendLaterTimeDateWidget::dateChanged, this, &SendLaterDialog::slotDateChanged);
......
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