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