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

Clean up. Minor optimization

parent 6bb7cd2c
......@@ -3,13 +3,3 @@ set (CALENDARING_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/event.cpp
${CMAKE_CURRENT_SOURCE_DIR}/datetimeutils.cpp
PARENT_SCOPE)
if(PYTHON_BINDINGS)
message("building python bindings")
add_subdirectory(python)
endif(PYTHON_BINDINGS)
if(PHP_BINDINGS)
message("building php bindings")
add_subdirectory(php)
endif(PHP_BINDINGS)
......@@ -107,7 +107,8 @@ namespace Kolab {
unsigned int stringListToCryptoMessageFormats( const QStringList & sl ) {
unsigned int result = 0;
for ( QStringList::const_iterator it = sl.begin() ; it != sl.end() ; ++it )
const QStringList::const_iterator end(sl.end());
for ( QStringList::const_iterator it = sl.begin() ; it != end ; ++it )
result |= stringToCryptoMessageFormat( *it );
return result;
}
......@@ -169,15 +170,15 @@ namespace Kolab {
SigningPreference stringToSigningPreference( const QString& str )
{
if ( str == "never" )
if ( str == QStringLiteral("never") )
return NeverSign;
if ( str == "always" )
if ( str == QStringLiteral("always") )
return AlwaysSign;
if ( str == "alwaysIfPossible" )
if ( str == QStringLiteral("alwaysIfPossible") )
return AlwaysSignIfPossible;
if ( str == "askAlways" )
if ( str == QStringLiteral("askAlways") )
return AlwaysAskForSigning;
if ( str == "askWhenPossible" )
if ( str == QStringLiteral("askWhenPossible") )
return AskSigningWheneverPossible;
return UnknownSigningPreference;
}
......@@ -813,7 +814,7 @@ Kolab::Contact fromKABC(const KContacts::Addressee &addressee)
c.setCrypto(crypto);
//FIXME the keys are most certainly worng, look at cryptopageplugin.cpp
//FIXME the keys are most certainly wrong, look at cryptopageplugin.cpp
std::vector<Kolab::Key> keys;
const std::string &pgpkey = toStdString(addressee.custom( "KADDRESSBOOK", "OPENPGPFP" ));
if (!pgpkey.empty()) {
......
......@@ -51,7 +51,7 @@ Note fromNote(const KMime::Message::Ptr &m)
std::vector<Kolab::CustomProperty> customs;
QMap<QString, QString> &customsMap = note.custom();
for (QMap <QString, QString >::const_iterator it = customsMap.constBegin(); it != customsMap.constEnd(); it ++) {
for (QMap <QString, QString >::const_iterator it = customsMap.constBegin(), end = customsMap.constEnd(); it != end; it ++) {
customs.push_back(Kolab::CustomProperty(toStdString(it.key()), toStdString(it.value())));
}
n.setCustomProperties(customs);
......@@ -77,7 +77,7 @@ KMime::Message::Ptr toNote(const Note &n)
Akonadi::NoteUtils::NoteMessageWrapper note;
note.setTitle(fromStdString(n.summary()));
note.setText(fromStdString(n.description()));
note.setFrom("kolab@kde4");
note.setFrom(QStringLiteral("kolab@kde4"));
note.setCreationDate(toDate(n.created()));
note.setUid(fromStdString(n.uid()));
note.setLastModifiedDate(toDate(n.lastModified()));
......
......@@ -3,13 +3,3 @@ set (ICALENDAR_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/icalendar.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imip.cpp
PARENT_SCOPE)
if(PYTHON_BINDINGS)
message("building python bindings")
add_subdirectory(python)
endif(PYTHON_BINDINGS)
if(PHP_BINDINGS)
message("building php bindings")
add_subdirectory(php)
endif(PHP_BINDINGS)
......@@ -322,7 +322,7 @@ Configuration XMLObject::readConfiguration(const std::string& s, Version version
return Kolab::Configuration();
}
std::vector<std::string> entries;
foreach (const QString e, dict) {
foreach (const QString &e, dict) {
entries.push_back(Conversion::toStdString(e));
}
Kolab::Dictionary dictionary(Conversion::toStdString(lang));
......
......@@ -768,7 +768,7 @@ bool Contact::loadXML( const QDomDocument& document )
{
QDomElement top = document.documentElement();
if ( top.tagName() != "contact" ) {
if ( top.tagName() != QLatin1String("contact") ) {
qWarning( "XML error: Top tag was %s instead of the expected contact",
top.tagName().toAscii().data() );
return false;
......@@ -799,7 +799,7 @@ QString Contact::saveXML() const
{
QDomDocument document = domTree();
QDomElement element = document.createElement("contact" );
element.setAttribute( "version", "1.0" );
element.setAttribute( QStringLiteral("version"), QStringLiteral("1.0") );
saveAttributes( element );
document.appendChild( element );
return document.toString();
......@@ -808,17 +808,17 @@ QString Contact::saveXML() const
static QString addressTypeToString( int /*KContacts::Address::Type*/ type )
{
if ( type & KContacts::Address::Home )
return "home";
return QLatin1String("home");
if ( type & KContacts::Address::Work )
return "business";
return "other";
return QLatin1String("business");
return QLatin1String("other");
}
static int addressTypeFromString( const QString& type )
{
if ( type == "home" )
if ( type == QLatin1String("home") )
return KContacts::Address::Home;
if ( type == "business" )
if ( type == QLatin1String("business") )
return KContacts::Address::Work;
// well, this shows "other" in the editor, which is what we want...
return KContacts::Address::Dom | KContacts::Address::Intl | KContacts::Address::Postal | KContacts::Address::Parcel;
......@@ -886,39 +886,39 @@ static QStringList phoneTypeToString( KContacts::PhoneNumber::Type type )
static KContacts::PhoneNumber::Type phoneTypeFromString( const QString& type )
{
if ( type == "homefax" )
if ( type == QLatin1String("homefax") )
return KContacts::PhoneNumber::Home | KContacts::PhoneNumber::Fax;
if ( type == "businessfax" )
if ( type == QLatin1String("businessfax") )
return KContacts::PhoneNumber::Work | KContacts::PhoneNumber::Fax;
if ( type == "business1" )
if ( type == QLatin1String("business1") )
return KContacts::PhoneNumber::Work | KContacts::PhoneNumber::Pref;
if ( type == "business2" )
if ( type == QLatin1String("business2") )
return KContacts::PhoneNumber::Work;
if ( type == "home1" )
if ( type == QLatin1String("home1") )
return KContacts::PhoneNumber::Home | KContacts::PhoneNumber::Pref;
if ( type == "home2" )
if ( type == QLatin1String("home2") )
return KContacts::PhoneNumber::Home;
if ( type == "company" )
if ( type == QLatin1String("company") )
return KContacts::PhoneNumber::Msg;
if ( type == "primary" )
if ( type == QLatin1String("primary") )
return KContacts::PhoneNumber::Pref;
if ( type == "callback" )
if ( type == QLatin1String("callback") )
return KContacts::PhoneNumber::Voice;
if ( type == "mobile" )
if ( type == QLatin1String("mobile") )
return KContacts::PhoneNumber::Cell;
if ( type == "radio" )
if ( type == QLatin1String("radio") )
return KContacts::PhoneNumber::Video;
if ( type == "ttytdd" )
if ( type == QLatin1String("ttytdd") )
return KContacts::PhoneNumber::Bbs;
if ( type == "telex" )
if ( type == QLatin1String("telex") )
return KContacts::PhoneNumber::Modem;
if ( type == "car" )
if ( type == QLatin1String("car") )
return KContacts::PhoneNumber::Car;
if ( type == "isdn" )
if ( type == QLatin1String("isdn") )
return KContacts::PhoneNumber::Isdn;
if ( type == "assistant" )
if ( type == QLatin1String("assistant") )
return KContacts::PhoneNumber::Pcs;
if ( type == "pager" )
if ( type == QLatin1String("pager") )
return KContacts::PhoneNumber::Pager;
return KContacts::PhoneNumber::Home; // whatever
}
......@@ -982,7 +982,7 @@ void Contact::setFields( const KContacts::Addressee* addressee )
// Now the real-world addresses
QString preferredAddress = "home";
const KContacts::Address::List addresses = addressee->addresses();
for ( KContacts::Address::List::ConstIterator it = addresses.constBegin() ; it != addresses.constEnd(); ++it ) {
for ( KContacts::Address::List::ConstIterator it = addresses.constBegin(), end = addresses.constEnd(); it != end; ++it ) {
Address address;
address.kdeAddressType = (*it).type();
address.type = addressTypeToString( address.kdeAddressType );
......@@ -1005,7 +1005,7 @@ void Contact::setFields( const KContacts::Addressee* addressee )
for ( KContacts::PhoneNumber::List::ConstIterator it = phones.constBegin(); it != phones.constEnd(); ++it ) {
// Create a tag per phone type set in the bitfield
QStringList types = phoneTypeToString( (*it).type() );
for( QStringList::ConstIterator typit = types.constBegin(); typit != types.constEnd(); ++typit ) {
for( QStringList::ConstIterator typit = types.constBegin(), end = types.constEnd(); typit != end; ++typit ) {
PhoneNumber phoneNumber;
phoneNumber.type = *typit;
phoneNumber.number = (*it).number();
......@@ -1138,13 +1138,13 @@ void Contact::saveTo( KContacts::Addressee* addressee )
addressee->setGeo( KContacts::Geo( mLatitude, mLongitude ) );
QStringList emailAddresses;
for ( QList<Email>::ConstIterator it = mEmails.constBegin(); it != mEmails.constEnd(); ++it ) {
for ( QList<Email>::ConstIterator it = mEmails.constBegin(), end = mEmails.constEnd(); it != end; ++it ) {
// we can't do anything with (*it).displayName
emailAddresses.append( (*it).smtpAddress );
}
addressee->setEmails( emailAddresses );
for ( QList<Address>::ConstIterator it = mAddresses.constBegin(); it != mAddresses.constEnd(); ++it ) {
for ( QList<Address>::ConstIterator it = mAddresses.constBegin(), end = mAddresses.constEnd(); it != end; ++it ) {
KContacts::Address address;
int type = (*it).kdeAddressType;
if ( type == -1 ) { // no kde-specific type available
......@@ -1162,14 +1162,14 @@ void Contact::saveTo( KContacts::Addressee* addressee )
addressee->insertAddress( address );
}
for ( QList<PhoneNumber>::ConstIterator it = mPhoneNumbers.constBegin(); it != mPhoneNumbers.constEnd(); ++it ) {
for ( QList<PhoneNumber>::ConstIterator it = mPhoneNumbers.constBegin(), end = mPhoneNumbers.constEnd(); it != end; ++it ) {
KContacts::PhoneNumber number;
number.setType( phoneTypeFromString( (*it).type ) );
number.setNumber( (*it).number );
addressee->insertPhoneNumber( number );
}
for( QList<Custom>::ConstIterator it = mCustomList.constBegin(); it != mCustomList.constEnd(); ++it ) {
for( QList<Custom>::ConstIterator it = mCustomList.constBegin(), end = mCustomList.constEnd(); it != end; ++it ) {
QString app = (*it).app.isEmpty() ? QString::fromLatin1( "KADDRESSBOOK" ) : (*it).app;
addressee->insertCustom( app, (*it).name, (*it).value );
}
......
......@@ -295,9 +295,9 @@ bool KolabBase::loadEmailAttribute( QDomElement& element, Email& email )
QDomElement e = n.toElement();
const QString tagName = e.tagName();
if ( tagName == "display-name" )
if ( tagName == QLatin1String("display-name") )
email.displayName = e.text();
else if ( tagName == "smtp-address" )
else if ( tagName == QLatin1String("smtp-address") )
email.smtpAddress = e.text();
else
// TODO: Unhandled tag - save for later storage
......
......@@ -226,5 +226,5 @@ void Note::saveTo( const KCalCore::Journal::Ptr &journal )
QString Note::productID() const
{
return QString( "KNotes %1, Kolab resource" ).arg( LIBKOLAB_LIB_VERSION_STRING );
return QStringLiteral( "KNotes %1, Kolab resource" ).arg( LIBKOLAB_LIB_VERSION_STRING );
}
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