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 ff1f5f4c authored by Laurent Montel's avatar Laurent Montel 😁

Use QStringLiteral + use reserve + clean up

parent 9222472c
......@@ -683,8 +683,9 @@ Kolab::Contact fromKABC(const KContacts::Addressee &addressee)
}
std::vector<Kolab::Url> urls;
if (!addressee.url().url().isEmpty()) {
urls.push_back(Kolab::Url(toStdString(addressee.url().url().url())));
const QUrl url{addressee.url().url()};
if (!url.isEmpty()) {
urls.push_back(Kolab::Url(toStdString(url.url())));
}
const QString &blogUrl = addressee.custom(QLatin1String("KADDRESSBOOK"), QLatin1String("BlogFeed"));
if (!blogUrl.isEmpty()) {
......
......@@ -612,6 +612,7 @@ void getRecurrence(T &i, const I &e)
rrule.setByhour(defaultRR->byHours().toVector().toStdVector());
std::vector<Kolab::DayPos> daypos;
daypos.reserve(defaultRR->byDays().count());
foreach (const KCalCore::RecurrenceRule::WDayPos &dp, defaultRR->byDays()) {
daypos.push_back(fromWeekDayPos(dp));
}
......
......@@ -124,7 +124,7 @@ std::string ITipHandler::toIMip(const Event &event, ITipHandler::ITipMethod m, s
KCalCore::Event::Ptr e = Conversion::toKCalCore(event);
// e->recurrence()->addRDateTime(e->dtStart()); //FIXME The createScheduleMessage converts everything to utc without a recurrence.
KCalCore::ICalFormat format;
format.setApplication("libkolab", LIBKOLAB_LIB_VERSION_STRING);
format.setApplication(QStringLiteral("libkolab"), LIBKOLAB_LIB_VERSION_STRING);
KCalCore::iTIPMethod method = mapToKCalCore(m);
const QString &messageText = format.createScheduleMessage(e, method);
//This code is mostly from MailScheduler::performTransaction
......
......@@ -564,6 +564,7 @@ KMime::Message::Ptr KolabObjectWriter::writeDictionary(const QStringList &entrie
Kolab::Dictionary dictionary(Conversion::toStdString(lang));
std::vector <std::string> ent;
ent.reserve(entries.count());
foreach (const QString &e, entries) {
ent.push_back(Conversion::toStdString(e));
}
......
......@@ -280,6 +280,7 @@ QVariant MIMEObject::Private::readKolabV2(const KMime::Message::Ptr &msg, Kolab:
mObjectType = objectType;
Kolab::Dictionary dictionary(Conversion::toStdString(dictionaryLanguage));
std::vector<std::string> convertedEntries;
convertedEntries.reserve(entries.count());
foreach (const QString &value, entries) {
convertedEntries.push_back(Conversion::toStdString(value));
}
......
......@@ -78,6 +78,7 @@ Event XMLObject::readEvent(const std::string &s, Version version)
return Event();
}
mAttachments.clear();
mAttachments.reserve(attachments.count());
foreach (const QString &attachment, attachments) {
mAttachments.push_back(Conversion::toStdString(attachment));
}
......@@ -121,6 +122,7 @@ Todo XMLObject::readTodo(const std::string &s, Version version)
return Todo();
}
mAttachments.clear();
mAttachments.reserve(attachments.count());
foreach (const QString &attachment, attachments) {
mAttachments.push_back(Conversion::toStdString(attachment));
}
......@@ -163,6 +165,7 @@ Journal XMLObject::readJournal(const std::string &s, Version version)
return Journal();
}
mAttachments.clear();
mAttachments.reserve(attachments.count());
foreach (const QString &attachment, attachments) {
mAttachments.push_back(Conversion::toStdString(attachment));
}
......
......@@ -751,40 +751,40 @@ bool Contact::saveAttributes(QDomElement &element) const
// Save the base class elements
KolabBase::saveAttributes(element);
saveNameAttribute(element);
writeString(element, "free-busy-url", freeBusyUrl());
writeString(element, "organization", organization());
writeString(element, "web-page", webPage());
writeString(element, "im-address", imAddress());
writeString(element, "department", department());
writeString(element, "office-location", officeLocation());
writeString(element, "profession", profession());
writeString(element, "role", role());
writeString(element, "job-title", title());
writeString(element, "manager-name", managerName());
writeString(element, "assistant", assistant());
writeString(element, "nick-name", nickName());
writeString(element, "spouse-name", spouseName());
writeString(element, "birthday", dateToString(birthday()));
writeString(element, "anniversary", dateToString(anniversary()));
writeString(element, QStringLiteral("free-busy-url"), freeBusyUrl());
writeString(element, QStringLiteral("organization"), organization());
writeString(element, QStringLiteral("web-page"), webPage());
writeString(element, QStringLiteral("im-address"), imAddress());
writeString(element, QStringLiteral("department"), department());
writeString(element, QStringLiteral("office-location"), officeLocation());
writeString(element, QStringLiteral("profession"), profession());
writeString(element, QStringLiteral("role"), role());
writeString(element, QStringLiteral("job-title"), title());
writeString(element, QStringLiteral("manager-name"), managerName());
writeString(element, QStringLiteral("assistant"), assistant());
writeString(element, QStringLiteral("nick-name"), nickName());
writeString(element, QStringLiteral("spouse-name"), spouseName());
writeString(element, QStringLiteral("birthday"), dateToString(birthday()));
writeString(element, QStringLiteral("anniversary"), dateToString(anniversary()));
if (!picture().isNull()) {
writeString(element, "picture", mPictureAttachmentName);
writeString(element, QStringLiteral("picture"), mPictureAttachmentName);
}
if (!logo().isNull()) {
writeString(element, "x-logo", mLogoAttachmentName);
writeString(element, QStringLiteral("x-logo"), mLogoAttachmentName);
}
if (!sound().isNull()) {
writeString(element, "x-sound", mSoundAttachmentName);
writeString(element, QStringLiteral("x-sound"), mSoundAttachmentName);
}
writeString(element, "children", children());
writeString(element, "gender", gender());
writeString(element, "language", language());
writeString(element, QStringLiteral("children"), children());
writeString(element, QStringLiteral("gender"), gender());
writeString(element, QStringLiteral("language"), language());
savePhoneAttributes(element);
saveEmailAttributes(element);
saveAddressAttributes(element);
writeString(element, "preferred-address", preferredAddress());
writeString(element, QStringLiteral("preferred-address"), preferredAddress());
if (mHasGeo) {
writeString(element, "latitude", QString::number(latitude(), 'g', DBL_DIG));
writeString(element, "longitude", QString::number(longitude(), 'g', DBL_DIG));
writeString(element, QStringLiteral("latitude"), QString::number(latitude(), 'g', DBL_DIG));
writeString(element, QStringLiteral("longitude"), QString::number(longitude(), 'g', DBL_DIG));
}
saveCustomAttributes(element);
......@@ -865,9 +865,9 @@ static QStringList phoneTypeToString(KContacts::PhoneNumber::Type type)
QStringList types;
if (type & KContacts::PhoneNumber::Fax) {
if (type & KContacts::PhoneNumber::Home) {
types << "homefax";
types << QStringLiteral("homefax");
} else { // assume work -- if ( type & KContacts::PhoneNumber::Work )
types << "businessfax";
types << QStringLiteral("businessfax");
}
type = type & ~KContacts::PhoneNumber::Home;
type = type & ~KContacts::PhoneNumber::Work;
......@@ -875,55 +875,55 @@ static QStringList phoneTypeToString(KContacts::PhoneNumber::Type type)
// To support both "home1" and "home2", map Home+Pref to home1
if ((type &KContacts::PhoneNumber::Home) && (type & KContacts::PhoneNumber::Pref)) {
types << "home1";
types << QStringLiteral("home1");
type = type & ~KContacts::PhoneNumber::Home;
type = type & ~KContacts::PhoneNumber::Pref;
}
// To support both "business1" and "business2", map Work+Pref to business1
if ((type &KContacts::PhoneNumber::Work) && (type & KContacts::PhoneNumber::Pref)) {
types << "business1";
types << QStringLiteral("business1");
type = type & ~KContacts::PhoneNumber::Work;
type = type & ~KContacts::PhoneNumber::Pref;
}
if (type & KContacts::PhoneNumber::Home) {
types << "home2";
types << QStringLiteral("home2");
}
if (type & KContacts::PhoneNumber::Msg) { // Msg==messaging
types << "company";
types << QStringLiteral("company");
}
if (type & KContacts::PhoneNumber::Work) {
types << "business2";
types << QStringLiteral("business2");
}
if (type & KContacts::PhoneNumber::Pref) {
types << "primary";
types << QStringLiteral("primary");
}
if (type & KContacts::PhoneNumber::Voice) {
types << "callback"; // ##
types << QStringLiteral("callback"); // ##
}
if (type & KContacts::PhoneNumber::Cell) {
types << "mobile";
types << QStringLiteral("mobile");
}
if (type & KContacts::PhoneNumber::Video) {
types << "radio"; // ##
types << QStringLiteral("radio"); // ##
}
if (type & KContacts::PhoneNumber::Bbs) {
types << "ttytdd";
types << QStringLiteral("ttytdd");
}
if (type & KContacts::PhoneNumber::Modem) {
types << "telex"; // #
types << QStringLiteral("telex"); // #
}
if (type & KContacts::PhoneNumber::Car) {
types << "car";
types << QStringLiteral("car");
}
if (type & KContacts::PhoneNumber::Isdn) {
types << "isdn";
types << QStringLiteral("isdn");
}
if (type & KContacts::PhoneNumber::Pcs) {
types << "assistant"; // ## Assistant is e.g. secretary
types << QStringLiteral("assistant"); // ## Assistant is e.g. secretary
}
if (type & KContacts::PhoneNumber::Pager) {
types << "pager";
types << QStringLiteral("pager");
}
return types;
}
......@@ -1042,7 +1042,7 @@ void Contact::setFields(const KContacts::Addressee *addressee)
mFullEmail = addressee->fullEmail();
// Now the real-world addresses
QString preferredAddress = "home";
QString preferredAddress = QStringLiteral("home");
const KContacts::Address::List addresses = addressee->addresses();
for (KContacts::Address::List::ConstIterator it = addresses.constBegin(), end = addresses.constEnd(); it != end; ++it) {
Address address;
......@@ -1109,7 +1109,7 @@ void Contact::setFields(const KContacts::Addressee *addressee)
for (QStringList::ConstIterator it = customs.constBegin(), end = customs.constEnd(); it != end; ++it) {
// KContacts::Addressee doesn't offer a real way to iterate over customs, other than splitting strings ourselves
// The format is "app-name:value".
int pos = (*it).indexOf('-');
int pos = (*it).indexOf(QLatin1Char('-'));
if (pos == -1) {
continue;
}
......@@ -1118,7 +1118,7 @@ void Contact::setFields(const KContacts::Addressee *addressee)
continue;
}
QString name = (*it).mid(pos + 1);
pos = name.indexOf(':');
pos = name.indexOf(QLatin1Char(':'));
if (pos == -1) {
continue;
}
......@@ -1127,7 +1127,7 @@ void Contact::setFields(const KContacts::Addressee *addressee)
if (!knownCustoms.contains(name)) {
//qDebug() <<"app=" << app <<" name=" << name <<" value=" << value;
Custom c;
if (app != "KADDRESSBOOK") { // that's the default
if (app != QLatin1String("KADDRESSBOOK")) { // that's the default
c.app = app;
}
c.name = name;
......
......@@ -193,7 +193,7 @@ bool Incidence::loadAttendeeAttribute(QDomElement &element, Attendee &attendee)
// This sets reqResp to false, if the text is "false". Otherwise it
// sets it to true. This means the default setting is true.
attendee.requestResponse = (e.text().toLower() != QLatin1String("false"));
} else if (tagName == "invitation-sent") {
} else if (tagName == QLatin1String("invitation-sent")) {
// Like above, only this defaults to false
attendee.invitationSent = (e.text().toLower() != QLatin1String("true"));
} else if (tagName == QLatin1String("role")) {
......@@ -471,7 +471,7 @@ void Incidence::loadAlarms(const QDomElement &element)
QDomElement e = n.toElement();
QString tagName = e.tagName();
if (tagName == "alarm") {
if (tagName == QLatin1String("alarm")) {
KCalCore::Alarm::Ptr a = KCalCore::Alarm::Ptr(new KCalCore::Alarm(0));
a->setEnabled(true); // default to enabled, unless some XML attribute says otherwise.
QString type = e.attribute(QLatin1String("type"));
......@@ -865,16 +865,18 @@ void Incidence::setFields(const KCalCore::Incidence::Ptr &incidence)
mAttachments.clear();
// Attachments
KCalCore::Attachment::List attachments = incidence->attachments();
foreach (const KCalCore::Attachment::Ptr &a, attachments) {
const KCalCore::Attachment::List attachments = incidence->attachments();
mAttachments.reserve(attachments.size());
for (const KCalCore::Attachment::Ptr &a : attachments) {
mAttachments.push_back(a);
}
mAlarms.clear();
// Alarms
KCalCore::Alarm::List alarms = incidence->alarms();
foreach (const KCalCore::Alarm::Ptr &a, alarms) {
const KCalCore::Alarm::List alarms = incidence->alarms();
mAlarms.reserve(alarms.count());
for (const KCalCore::Alarm::Ptr &a : alarms) {
mAlarms.push_back(a);
}
......
......@@ -182,5 +182,5 @@ void Journal::setFields(const KCalCore::Journal::Ptr &journal)
QString Journal::productID() const
{
return QString::fromLatin1(LIBKOLAB_LIB_VERSION_STRING) + ", Kolab resource";
return QString::fromLatin1(LIBKOLAB_LIB_VERSION_STRING) + QLatin1String(", Kolab resource");
}
......@@ -103,7 +103,7 @@ void KolabBase::setFields(const KContacts::Addressee *addressee)
setCategories(addressee->categories().join(QLatin1Char(',')));
// Set creation-time and last-modification-time
const QString creationString = addressee->custom("KOLAB", "CreationDate");
const QString creationString = addressee->custom(QStringLiteral("KOLAB"), QStringLiteral("CreationDate"));
qDebug() <<"Creation time string:" << creationString;
KDateTime creationDate;
if (creationString.isEmpty()) {
......@@ -425,7 +425,7 @@ QDomDocument KolabBase::domTree()
{
QDomDocument document;
QString p = QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"");
const QString p = QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"");
document.appendChild(document.createProcessingInstruction(QStringLiteral("xml"), p));
return document;
......
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