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

Minor optimization

parent 070497c5
......@@ -187,7 +187,7 @@ void Event::delegate(const std::vector< Attendee >& delegators, const std::vecto
Attendee *Event::getAttendee(const ContactReference &ref)
{
for(std::vector <Kolab::Attendee >::iterator it = d->attendees.begin();
it != d->attendees.end(); it++) {
it != d->attendees.end(); ++it) {
if (it->contact().uid() == ref.uid() || it->contact().email() == ref.email() || it->contact().name() == ref.name()) {
return &*it;
}
......
......@@ -1049,7 +1049,7 @@ void Contact::setFields( const KContacts::Addressee* addressee )
int pos = (*it).indexOf( '-' );
if ( pos == -1 ) continue;
QString app = (*it).left( pos );
if ( app == "KOLAB" ) continue;
if ( app == QLatin1String("KOLAB") ) continue;
QString name = (*it).mid( pos + 1 );
pos = name.indexOf( ':' );
if ( pos == -1 ) continue;
......
......@@ -765,13 +765,13 @@ void Incidence::setRecurrence( KCalCore::Recurrence* recur )
}
int howMany = recur->duration();
if ( howMany > 0 ) {
mRecurrence.rangeType = "number";
mRecurrence.rangeType = QStringLiteral("number");
mRecurrence.range = QString::number( howMany );
} else if ( howMany == 0 ) {
mRecurrence.rangeType = "date";
mRecurrence.rangeType = QStringLiteral("date");
mRecurrence.range = dateToString( recur->endDate() );
} else {
mRecurrence.rangeType = "none";
mRecurrence.rangeType = QStringLiteral("none");
}
}
......@@ -833,7 +833,7 @@ void Incidence::setFields( const KCalCore::Incidence::Ptr &incidence )
// Attachments
KCalCore::Attachment::List attachments = incidence->attachments();
foreach ( KCalCore::Attachment::Ptr a, attachments ) {
foreach ( const KCalCore::Attachment::Ptr &a, attachments ) {
mAttachments.push_back( a );
}
......@@ -841,7 +841,7 @@ void Incidence::setFields( const KCalCore::Incidence::Ptr &incidence )
// Alarms
KCalCore::Alarm::List alarms = incidence->alarms();
foreach ( KCalCore::Alarm::Ptr a, alarms ) {
foreach ( const KCalCore::Alarm::Ptr &a, alarms ) {
mAlarms.push_back( a );
}
......
......@@ -101,9 +101,9 @@ bool Journal::loadAttribute( QDomElement& element )
{
QString tagName = element.tagName();
if ( tagName == "summary" )
if ( tagName == QLatin1String("summary") )
setSummary( element.text() );
else if ( tagName == "start-date" )
else if ( tagName == QLatin1String("start-date") )
setStartDate( stringToDateTime( element.text() ) );
else
// Not handled here
......@@ -118,8 +118,8 @@ bool Journal::saveAttributes( QDomElement& element ) const
// Save the base class elements
KolabBase::saveAttributes( element );
writeString( element, "summary", summary() );
writeString( element, "start-date", dateTimeToString( startDate() ) );
writeString( element, QStringLiteral("summary"), summary() );
writeString( element, QStringLiteral("start-date"), dateTimeToString( startDate() ) );
return true;
}
......@@ -129,7 +129,7 @@ bool Journal::loadXML( const QDomDocument& document )
{
QDomElement top = document.documentElement();
if ( top.tagName() != "journal" ) {
if ( top.tagName() != QLatin1String("journal") ) {
qWarning( "XML error: Top tag was %s instead of the expected Journal",
top.tagName().toAscii().data() );
return false;
......@@ -154,8 +154,8 @@ bool Journal::loadXML( const QDomDocument& document )
QString Journal::saveXML() const
{
QDomDocument document = domTree();
QDomElement element = document.createElement( "journal" );
element.setAttribute( "version", "1.0" );
QDomElement element = document.createElement( QStringLiteral("journal") );
element.setAttribute( QStringLiteral("version"), QStringLiteral("1.0") );
saveAttributes( element );
document.appendChild( element );
return document.toString();
......
......@@ -151,7 +151,7 @@ void KolabBase::saveTo( KContacts::Addressee* addressee ) const
addressee->setNote( body() );
addressee->setCategories( categories().split( ',', QString::SkipEmptyParts ) );
addressee->setRevision( lastModified().toZone( mTimeZone ).dateTime() );
addressee->insertCustom( "KOLAB", "CreationDate",
addressee->insertCustom( QStringLiteral("KOLAB"), QStringLiteral("CreationDate"),
dateTimeToString( creationDate() ) );
switch( sensitivity() ) {
......@@ -323,47 +323,47 @@ bool KolabBase::loadAttribute( QDomElement& element )
const QString tagName = element.tagName();
switch ( tagName[0].toLatin1() ) {
case 'u':
if ( tagName == "uid" ) {
if ( tagName == QLatin1String("uid") ) {
setUid( element.text() );
return true;
}
break;
case 'b':
if ( tagName == "body" ) {
if ( tagName == QLatin1String("body") ) {
setBody( element.text() );
return true;
}
break;
case 'c':
if ( tagName == "categories" ) {
if ( tagName == QLatin1String("categories") ) {
setCategories( element.text() );
return true;
}
if ( tagName == "creation-date" ) {
if ( tagName == QLatin1String("creation-date") ) {
setCreationDate( stringToDateTime( element.text() ) );
return true;
}
break;
case 'l':
if ( tagName == "last-modification-date" ) {
if ( tagName == QLatin1String("last-modification-date") ) {
setLastModified( stringToDateTime( element.text() ) );
return true;
}
break;
case 's':
if ( tagName == "sensitivity" ) {
if ( tagName == QLatin1String("sensitivity") ) {
setSensitivity( stringToSensitivity( element.text() ) );
return true;
}
break;
case 'p':
if ( tagName == "product-id" )
if ( tagName == QLatin1String("product-id") )
return true; // ignore this field
if ( tagName == "pilot-sync-id" ) {
if ( tagName == QLatin1String("pilot-sync-id") ) {
setPilotSyncId( element.text().toULong() );
return true;
}
if ( tagName == "pilot-sync-status" ) {
if ( tagName == QLatin1String("pilot-sync-status") ) {
setPilotSyncStatus( element.text().toInt() );
return true;
}
......
......@@ -108,14 +108,14 @@ bool Note::richText() const
bool Note::loadAttribute( QDomElement& element )
{
QString tagName = element.tagName();
if ( tagName == "summary" )
if ( tagName == QLatin1String("summary") )
setSummary( element.text() );
else if ( tagName == "foreground-color" )
else if ( tagName == QLatin1String("foreground-color") )
setForegroundColor( stringToColor( element.text() ) );
else if ( tagName == "background-color" )
else if ( tagName == QLatin1String("background-color") )
setBackgroundColor( stringToColor( element.text() ) );
else if ( tagName == "knotes-richtext" )
mRichText = ( element.text() == "true" );
else if ( tagName == QLatin1String("knotes-richtext") )
mRichText = ( element.text() == QLatin1String("true") );
else
return KolabBase::loadAttribute( element );
......@@ -149,7 +149,7 @@ bool Note::loadXML( const QDomDocument& document )
{
QDomElement top = document.documentElement();
if ( top.tagName() != "note" ) {
if ( top.tagName() != QLatin1String("note") ) {
qWarning( "XML error: Top tag was %s instead of the expected note",
top.tagName().toAscii().data() );
return false;
......
......@@ -199,7 +199,7 @@ KMime::Content* createAttachmentPart(const QByteArray& cid, const QByteArray& mi
Kolab::Attachment getAttachment(const std::string &id, const KMime::Message::Ptr &mimeData)
{
if (!QString::fromStdString(id).contains("cid:")) {
if (!QString::fromStdString(id).contains(QLatin1String("cid:"))) {
Error() << "not a cid reference";
return Kolab::Attachment();
}
......
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