From 4d97ceb0bc0998414d4643ce5280b11ddc6e4956 Mon Sep 17 00:00:00 2001
From: Emmanuel Lepage <emmanuel.lepage@savoirfairelinux.com>
Date: Tue, 13 Dec 2011 16:49:28 -0500
Subject: [PATCH] [ #7887 ] Prevent most useless object copy

---
 src/Account.cpp      | 57 +++++++++++++++++++++++----------------
 src/Account.h        | 28 +++++++++----------
 src/AccountList.cpp  |  4 +--
 src/AccountList.h    | 16 +++++------
 src/Call.cpp         | 36 ++++++++++++-------------
 src/Call.h           | 64 ++++++++++++++++++++++----------------------
 src/CallModel.h      | 58 +++++++++++++++++++--------------------
 src/CallModel.hpp    | 14 +++++-----
 src/Contact.cpp      | 30 ++++++++++-----------
 src/Contact.h        | 38 +++++++++++++-------------
 src/ContactBackend.h |  8 +++---
 11 files changed, 182 insertions(+), 171 deletions(-)

diff --git a/src/Account.cpp b/src/Account.cpp
index 449ea381..2b7acc89 100644
--- a/src/Account.cpp
+++ b/src/Account.cpp
@@ -33,27 +33,38 @@
 #include "configurationmanager_interface_singleton.h"
 
 ///Match state name to user readable string
-const QString account_state_name(QString & s)
-{
+const QString& account_state_name(const QString& s)
+{
+   static const QString registered             = "Registered"               ;
+   static const QString notRegistered          = "Not Registered"           ;
+   static const QString trying                 = "Trying..."                ;
+   static const QString error                  = "Error"                    ;
+   static const QString authenticationFailed   = "Authentication Failed"    ;
+   static const QString networkUnreachable     = "Network unreachable"      ;
+   static const QString hostUnreachable        = "Host unreachable"         ;
+   static const QString stunConfigurationError = "Stun configuration error" ;
+   static const QString stunServerInvalid      = "Stun server invalid"      ;
+   static const QString invalid                = "Invalid"                  ;
+   
    if(s == QString(ACCOUNT_STATE_REGISTERED)       )
-      return "Registered"               ;
+      return registered             ;
    if(s == QString(ACCOUNT_STATE_UNREGISTERED)     )
-      return "Not Registered"           ;
+      return notRegistered          ;
    if(s == QString(ACCOUNT_STATE_TRYING)           )
-      return "Trying..."                ;
+      return trying                 ;
    if(s == QString(ACCOUNT_STATE_ERROR)            )
-      return "Error"                    ;
+      return error                  ;
    if(s == QString(ACCOUNT_STATE_ERROR_AUTH)       )
-      return "Authentication Failed"    ;
+      return authenticationFailed   ;
    if(s == QString(ACCOUNT_STATE_ERROR_NETWORK)    )
-      return "Network unreachable"      ;
+      return networkUnreachable     ;
    if(s == QString(ACCOUNT_STATE_ERROR_HOST)       )
-      return "Host unreachable"         ;
+      return hostUnreachable        ;
    if(s == QString(ACCOUNT_STATE_ERROR_CONF_STUN)  )
-      return "Stun configuration error" ;
+      return stunConfigurationError ;
    if(s == QString(ACCOUNT_STATE_ERROR_EXIST_STUN) )
-      return "Stun server invalid"      ;
-   return "Invalid"                     ;
+      return stunServerInvalid      ;
+   return invalid                   ;
 }
 
 ///Constructors
@@ -62,7 +73,7 @@ Account::Account():m_pAccountId(NULL),m_pAccountDetails(NULL)
 }
 
 ///Build an account from it'id
-Account* Account::buildExistingAccountFromId(QString _accountId)
+Account* Account::buildExistingAccountFromId(const QString& _accountId)
 {
    qDebug() << "Building an account from id: " << _accountId;
    ConfigurationManagerInterface& configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
@@ -79,7 +90,7 @@ Account* Account::buildExistingAccountFromId(QString _accountId)
 }
 
 ///Build an account from it's name / alias
-Account* Account::buildNewAccountFromAlias(QString alias)
+Account* Account::buildNewAccountFromAlias(const QString& alias)
 {
    qDebug() << "Building an account from alias: " << alias;
    Account* a = new Account();
@@ -108,7 +119,7 @@ bool Account::isNew() const
 }
 
 ///Get this account ID
-const QString & Account::getAccountId() const
+const QString& Account::getAccountId() const
 {
    if (isNew())
       qDebug() << "Error : getting AccountId of a new account.";
@@ -121,19 +132,19 @@ const QString & Account::getAccountId() const
 }
 
 ///Get this account details
-MapStringString& Account::getAccountDetails() const
+const MapStringString& Account::getAccountDetails() const
 {
    return *m_pAccountDetails;
 }
 
 ///Get current state
-QString Account::getStateName(QString & state)
+const QString& Account::getStateName(const QString& state) const
 {
-   return account_state_name(state);
+   return (const QString&)account_state_name(state);
 }
 
 ///Get an account detail
-QString Account::getAccountDetail(QString param) const
+const QString& Account::getAccountDetail(const QString& param) const
 {
    if (!m_pAccountDetails) {
       qDebug() << "The account list is not set";
@@ -148,7 +159,7 @@ QString Account::getAccountDetail(QString param) const
 }
 
 ///Get the alias
-QString Account::getAlias() const
+const QString& Account::getAlias() const
 {
    return getAccountDetail(ACCOUNT_ALIAS);
 }
@@ -175,19 +186,19 @@ bool Account::isRegistered() const
  ****************************************************************************/
 
 ///Set account details
-void Account::setAccountDetails(MapStringString m)
+void Account::setAccountDetails(const MapStringString& m)
 {
    *m_pAccountDetails = m;
 }
 
 ///Set a specific detail
-void Account::setAccountDetail(QString param, QString val)
+void Account::setAccountDetail(const QString& param, const QString& val)
 {
    (*m_pAccountDetails)[param] = val;
 }
 
 ///Set the account id
-void Account::setAccountId(QString id)
+void Account::setAccountId(const QString& id)
 {
    qDebug() << "accountId = " << m_pAccountId;
    if (! isNew())
diff --git a/src/Account.h b/src/Account.h
index fa0b6196..a746dae2 100644
--- a/src/Account.h
+++ b/src/Account.h
@@ -27,7 +27,7 @@ class QString;
 
 #include "typedefs.h"
 
-const QString account_state_name(QString & s);
+const QString& account_state_name(const QString& s);
 
 ///@class Account a daemon account (SIP or AIX)
 class LIB_EXPORT Account : public QObject {
@@ -36,23 +36,23 @@ class LIB_EXPORT Account : public QObject {
    public:
       ~Account();
       //Constructors
-      static Account* buildExistingAccountFromId(QString _accountId);
-      static Account* buildNewAccountFromAlias(QString alias);
+      static Account* buildExistingAccountFromId(const QString& _accountId);
+      static Account* buildNewAccountFromAlias(const QString& alias);
    
       //Getters
-      bool              isNew()                         const;
-      const QString&    getAccountId()                  const;
-      MapStringString&  getAccountDetails()             const;
-      QString           getStateName(QString & state)        ;
-      QString           getAccountDetail(QString param) const;
-      QString           getAlias()                      const;
-      bool              isEnabled()                     const;
-      bool              isRegistered()                  const;
+      bool                    isNew()                                const;
+      const QString&          getAccountId()                         const;
+      const MapStringString&  getAccountDetails()                    const;
+      const QString&          getStateName(const QString& state)     const;
+      const QString&          getAccountDetail(const QString& param) const;
+      const QString&          getAlias()                             const;
+      bool                    isEnabled()                            const;
+      bool                    isRegistered()                         const;
    
       //Setters
-      void setAccountId      (QString id                 );
-      void setAccountDetails (MapStringString m          );
-      void setAccountDetail  (QString param, QString val );
+      void setAccountId      (const QString& id                        );
+      void setAccountDetails (const MapStringString& m                 );
+      void setAccountDetail  (const QString& param, const QString& val );
    
       //Updates
       virtual void updateState();
diff --git a/src/AccountList.cpp b/src/AccountList.cpp
index dc5211b8..8a99b6b8 100644
--- a/src/AccountList.cpp
+++ b/src/AccountList.cpp
@@ -99,7 +99,7 @@ void AccountList::updateAccounts()
  ****************************************************************************/
 
 ///Get all accounts
-QVector<Account*> & AccountList::getAccounts()
+const QVector<Account*>& AccountList::getAccounts()
 {
    return *m_pAccounts;
 }
@@ -139,7 +139,7 @@ Account* AccountList::getAccountById(const QString & id) const
 }
 
 ///Get account with a specific state
-QVector<Account*> AccountList::getAccountsByState(QString & state)
+QVector<Account*> AccountList::getAccountsByState(const QString& state)
 {
    QVector<Account *> v;
    for (int i = 0; i < m_pAccounts->size(); ++i) {
diff --git a/src/AccountList.h b/src/AccountList.h
index c3f26744..68f995b0 100644
--- a/src/AccountList.h
+++ b/src/AccountList.h
@@ -40,14 +40,14 @@ public:
    ~AccountList();
    
    //Getters
-   QVector<Account*>& getAccounts            (                   );
-   QVector<Account*>  getAccountsByState     ( QString & state   );
-   QString            getOrderedList         (                   ) const;
-   Account*           getAccountById         ( const QString& id ) const;
-   Account*           getAccountAt           ( int i             );
-   const Account*     getAccountAt           ( int i             ) const;
-   int                size                   (                   ) const;
-   Account*           firstRegisteredAccount (                   ) const;
+   const QVector<Account*>& getAccounts            (                        );
+   QVector<Account*>        getAccountsByState     ( const QString& state   );
+   QString                  getOrderedList         (                        ) const;
+   Account*                 getAccountById         ( const QString& id      ) const;
+   Account*                 getAccountAt           ( int i                  );
+   const Account*           getAccountAt           ( int i                  ) const;
+   int                      size                   (                        ) const;
+   Account*                 firstRegisteredAccount (                        ) const;
    
    //Mutators
    virtual Account*  addAccount        ( QString & alias  )      ;
diff --git a/src/Call.cpp b/src/Call.cpp
index 93cbe28c..4d8b0b6d 100644
--- a/src/Call.cpp
+++ b/src/Call.cpp
@@ -312,7 +312,7 @@ daemon_call_state Call::toDaemonCallState(const QString & stateName)
 }
 
 ///Get the time (second from 1 jan 1970) when the call ended
-QString Call::getStopTimeStamp()    const
+QString Call::getStopTimeStamp()     const
 {
    if (m_pStopTime == NULL)
       return QString();
@@ -320,7 +320,7 @@ QString Call::getStopTimeStamp()    const
 }
 
 ///Get the time (second from 1 jan 1970) when the call started
-QString Call::getStartTimeStamp()   const
+QString Call::getStartTimeStamp()    const
 {
    if (m_pStartTime == NULL)
       return QString();
@@ -328,61 +328,61 @@ QString Call::getStartTimeStamp()   const
 }
 
 ///Get the number where the call have been transferred
-QString Call::getTransferNumber()    const
+const QString& Call::getTransferNumber()    const
 {
    return m_TransferNumber;
 }
 
 ///Get the call / peer number
-QString Call::getCallNumber()        const
+const QString& Call::getCallNumber()        const
 {
    return m_CallNumber;
 }
 
 ///Return the call id
-QString Call::getCallId()            const
+const QString& Call::getCallId()            const
 {
    return m_CallId;
 }
 
 ///Return the peer phone number
-QString Call::getPeerPhoneNumber()   const
+const QString& Call::getPeerPhoneNumber()   const
 {
    return m_PeerPhoneNumber;
 }
 
 ///Get the peer name
-QString Call::getPeerName()          const
+const QString& Call::getPeerName()          const
 {
    return m_PeerName;
 }
 
 ///Get the current state
-call_state Call::getCurrentState()   const
+call_state Call::getCurrentState()          const
 {
    return m_CurrentState;
 }
 
 ///Get the call recording
-bool Call::getRecording()            const
+bool Call::getRecording()                   const
 {
    return m_Recording;
 }
 
 ///Get the call account id
-QString Call::getAccountId()         const
+const QString& Call::getAccountId()         const
 {
    return m_Account;
 }
 
 ///Is this call a conference
-bool Call::isConference()            const
+bool Call::isConference()                   const
 {
    return m_isConference;
 }
 
 ///Get the conference ID
-QString Call::getConfId()            const
+const QString& Call::getConfId()            const
 {
    return m_ConfId;
 }
@@ -395,19 +395,19 @@ QString Call::getCurrentCodecName()  const
 }
 
 ///Get the state
-call_state Call::getState()          const
+call_state Call::getState()                 const
 {
    return m_CurrentState;
 }
 
 ///Get the history state
-history_state Call::getHistoryState() const
+history_state Call::getHistoryState()       const
 {
    return m_HistoryState;
 }
 
 ///Is this call over?
-bool Call::isHistory()               const
+bool Call::isHistory()                      const
 {
    return (getState() == CALL_STATE_OVER);
 }
@@ -437,7 +437,7 @@ bool Call::isSecure() const {
  ****************************************************************************/
 
 ///Set the transfer number
-void Call::setTransferNumber(QString number)
+void Call::setTransferNumber(const QString& number)
 {
    m_TransferNumber = number;
 }
@@ -449,7 +449,7 @@ void Call::setConference(bool value)
 }
 
 ///Set the call number
-void Call::setCallNumber(QString number)
+void Call::setCallNumber(const QString& number)
 {
    m_CallNumber = number;
    emit changed();
@@ -706,7 +706,7 @@ void Call::warning()
  ****************************************************************************/
 
 ///Input text on the call item
-void Call::appendText(QString str)
+void Call::appendText(const QString& str)
 {
    QString * editNumber;
    
diff --git a/src/Call.h b/src/Call.h
index 7016eab4..76f31180 100644
--- a/src/Call.h
+++ b/src/Call.h
@@ -134,23 +134,23 @@ public:
    static history_state getHistoryStateFromDaemonCallState ( QString daemonCallState, QString daemonCallType );
    
    //Getters
-   call_state    getState            () const;
-   QString       getCallId           () const;
-   QString       getPeerPhoneNumber  () const;
-   QString       getPeerName         () const;
-   call_state    getCurrentState     () const;
-   history_state getHistoryState     () const;
-   bool          getRecording        () const;
-   QString       getAccountId        () const;
-   bool          isHistory           () const;
-   QString       getStopTimeStamp    () const;
-   QString       getStartTimeStamp   () const;
-   QString       getCurrentCodecName () const;
-   bool          isSecure            () const;
-   bool          isConference        () const;
-   QString       getConfId           () const;
-   QString       getTransferNumber   () const;
-   QString       getCallNumber       () const;
+   call_state           getState            () const;
+   const QString&       getCallId           () const;
+   const QString&       getPeerPhoneNumber  () const;
+   const QString&       getPeerName         () const;
+   call_state           getCurrentState     () const;
+   history_state        getHistoryState     () const;
+   bool                 getRecording        () const;
+   const QString&       getAccountId        () const;
+   bool                 isHistory           () const;
+   QString              getStopTimeStamp    () const;
+   QString              getStartTimeStamp   () const;
+   QString              getCurrentCodecName () const;
+   bool                 isSecure            () const;
+   bool                 isConference        () const;
+   const QString&       getConfId           () const;
+   const QString&       getTransferNumber   () const;
+   const QString&       getCallNumber       () const;
 
    //Automated function
    call_state stateChanged(const QString & newState);
@@ -159,31 +159,31 @@ public:
    //Setters
    void setConference(bool value);
    void setConfId(QString value);
-   void setTransferNumber(QString number);
-   void setCallNumber(QString number);
+   void setTransferNumber(const QString& number);
+   void setCallNumber(const QString& number);
    
    //Mutotors
-   void appendText(QString str);
+   void appendText(const QString& str);
    void backspaceItemText();
    void changeCurrentState(call_state newState);
    
 private:
 
    //Attributes
-   QString                m_Account;
-   QString                m_CallId;
-   QString                m_ConfId;
+   QString                m_Account        ;
+   QString                m_CallId         ;
+   QString                m_ConfId         ;
    QString                m_PeerPhoneNumber;
-   QString                m_PeerName;
-   history_state          m_HistoryState;
-   QDateTime*             m_pStartTime;
-   QDateTime*             m_pStopTime;
-   QString                m_TransferNumber;
-   QString                m_CallNumber;
+   QString                m_PeerName       ;
+   history_state          m_HistoryState   ;
+   QDateTime*             m_pStartTime     ;
+   QDateTime*             m_pStopTime      ;
+   QString                m_TransferNumber ;
+   QString                m_CallNumber     ;
    static ContactBackend* m_pContactBackend;
-   bool                   m_isConference;
-   call_state             m_CurrentState;
-   bool                   m_Recording;
+   bool                   m_isConference   ;
+   call_state             m_CurrentState   ;
+   bool                   m_Recording      ;
    
    //Automate attributes
    /**
diff --git a/src/CallModel.h b/src/CallModel.h
index b72a8293..44f76fd3 100644
--- a/src/CallModel.h
+++ b/src/CallModel.h
@@ -51,11 +51,11 @@ public:
    virtual bool changeConference  ( const QString &confId, const QString &state ) = 0;
    virtual void removeConference  ( const QString &confId                       ) = 0;
    virtual Call* addConference    ( const QString &confID                       ) = 0;
-   virtual Call* findCallByCallId ( QString callId                              ) = 0;
+   virtual Call* findCallByCallId ( const QString& callId                       ) = 0;
    virtual Call* addRingingCall   ( const QString& callId                       ) = 0;
    virtual Call* addIncomingCall  ( const QString& callId                       ) = 0;
    virtual Call* addCall          ( Call* call           , Call* parent =0      );
-   virtual Call* getCall          ( const QString callId                        ) const = 0;
+   virtual Call* getCall          ( const QString& callId                       ) const = 0;
 public slots:
    void on1_callStateChanged   ( const QString& callID    , const QString &state   );
    void on1_incomingCall       ( const QString& accountID , const QString & callID );
@@ -127,42 +127,42 @@ class LIB_EXPORT CallModel : public CallModelBase {
       static const QStringList getHistoryCallId ();
 
       //Account related
-      static Account* getCurrentAccount  (               );
-      static QString getCurrentAccountId (               );
-      static AccountList* getAccountList (               );
-      static QString getPriorAccoundId   (               );
-      static void setPriorAccountId      ( QString value );
+      static Account* getCurrentAccount  (                     );
+      static QString getCurrentAccountId (                     );
+      static AccountList* getAccountList (                     );
+      static QString getPriorAccoundId   (                     );
+      static void setPriorAccountId      (const QString& value );
 
       //Connection related
       static bool init();
       
       //Magic dispatcher
-      Call* findCallByCallId( QString callId         );
-      CallList getCalls     (                        );
-      CallList getCalls     ( const CallWidget widget) const;
-      CallList getCalls     ( const QString callId   ) const;
-      CallList getCalls     ( const Call* call       ) const;
-      CallList getCalls     ( const Index idx        ) const;
+      Call* findCallByCallId( const QString& callId   );
+      CallList getCalls     (                         );
+      CallList getCalls     ( const CallWidget widget ) const;
+      CallList getCalls     ( const QString& callId   ) const;
+      CallList getCalls     ( const Call* call        ) const;
+      CallList getCalls     ( const Index idx         ) const;
       
-      bool isConference     ( const Call* call       ) const;
-      bool isConference     ( const QString callId   ) const;
-      bool isConference     ( const Index idx        ) const;
-      bool isConference     ( const CallWidget widget) const;
+      bool isConference     ( const Call* call        ) const;
+      bool isConference     ( const QString& callId   ) const;
+      bool isConference     ( const Index idx         ) const;
+      bool isConference     ( const CallWidget widget ) const;
       
-      Call* getCall         ( const QString callId   ) const;
-      Call* getCall         ( const Index idx        ) const;
-      Call* getCall         ( const Call* call       ) const;
-      Call* getCall         ( const CallWidget widget) const;
+      Call* getCall         ( const QString& callId   ) const;
+      Call* getCall         ( const Index idx         ) const;
+      Call* getCall         ( const Call* call        ) const;
+      Call* getCall         ( const CallWidget widget ) const;
       
-      Index getIndex        ( const Call* call       ) const;
-      Index getIndex        ( const Index idx        ) const;
-      Index getIndex        ( const CallWidget widget) const;
-      Index getIndex        ( const QString callId   ) const;
+      Index getIndex        ( const Call* call        ) const;
+      Index getIndex        ( const Index idx         ) const;
+      Index getIndex        ( const CallWidget widget ) const;
+      Index getIndex        ( const QString& callId   ) const;
       
-      CallWidget getWidget  ( const Call* call       ) const;
-      CallWidget getWidget  ( const Index idx        ) const;
-      CallWidget getWidget  ( const CallWidget widget) const;
-      CallWidget getWidget  ( const QString getWidget) const;
+      CallWidget getWidget  ( const Call* call        ) const;
+      CallWidget getWidget  ( const Index idx         ) const;
+      CallWidget getWidget  ( const CallWidget widget ) const;
+      CallWidget getWidget  ( const QString& getWidget) const;
       
       bool updateIndex      ( Call* call, Index value      );
       bool updateWidget     ( Call* call, CallWidget value );
diff --git a/src/CallModel.hpp b/src/CallModel.hpp
index b212c5e1..c138ea26 100644
--- a/src/CallModel.hpp
+++ b/src/CallModel.hpp
@@ -155,7 +155,7 @@ template<typename CallWidget, typename Index> int CallModel<CallWidget,Index>::s
 }
 
 ///Return a call corresponding to this ID or NULL
-template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::findCallByCallId(QString callId) 
+template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::findCallByCallId(const QString& callId)
 {
    return m_sActiveCalls[callId];
 }
@@ -446,7 +446,7 @@ template<typename CallWidget, typename Index> QString CallModel<CallWidget,Index
 }
 
 ///Set the previous account used
-template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::setPriorAccountId(QString value) {
+template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::setPriorAccountId(const QString& value) {
    m_sPriorAccountId = value;
 }
 
@@ -555,7 +555,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,
 }
 
 ///Is the call associated with that ID a conference                
-template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::isConference     ( const QString callId         ) const
+template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::isConference     ( const QString& callId        ) const
 { 
    if (m_sPrivateCallList_callId[callId]) {
       return m_sPrivateCallList_callId[callId]->conference;
@@ -564,7 +564,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::
 }
 
 ///Get the call associated with this ID                            
-template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::getCall         ( const QString callId         ) const
+template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::getCall         ( const QString& callId        ) const
 { 
    if (m_sPrivateCallList_callId[callId]) {
       return m_sPrivateCallList_callId[callId]->call_real;
@@ -573,7 +573,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>:
 }
 
 ///Get the calls associated with this ID                           
-template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls ( const QString callId         ) const
+template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls ( const QString& callId        ) const
 {
    QList<Call*> toReturn;
    if (m_sPrivateCallList_callId[callId] && m_sPrivateCallList_callId[callId]->conference) {
@@ -612,7 +612,7 @@ template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>:
 }
 
 ///Get the index associated with this ID                           
-template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>::getIndex        ( const QString callId         ) const
+template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>::getIndex        ( const QString& callId        ) const
 {
    if (m_sPrivateCallList_callId[callId]) {
       return m_sPrivateCallList_callId[callId]->index;
@@ -648,7 +648,7 @@ template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,In
 }
 
 ///Get the widget associated with this ID                          
-template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,Index>::getWidget  ( const QString widget         ) const
+template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,Index>::getWidget  ( const QString& widget        ) const
 {
    if (m_sPrivateCallList_widget[widget]) {
       return m_sPrivateCallList_widget[widget]->call;
diff --git a/src/Contact.cpp b/src/Contact.cpp
index fd45d1b1..557cf07a 100644
--- a/src/Contact.cpp
+++ b/src/Contact.cpp
@@ -60,19 +60,19 @@ PhoneNumbers Contact::getPhoneNumbers() const
 }
 
 ///Get the nickname
-QString Contact::getNickName() const
+const QString& Contact::getNickName() const
 {
    return m_NickName;
 }
 
 ///Get the firstname
-QString Contact::getFirstName() const
+const QString& Contact::getFirstName() const
 {
    return m_FirstName;
 }
 
 ///Get the second/family name
-QString Contact::getSecondName() const
+const QString& Contact::getSecondName() const
 {
    return m_SecondName;
 }
@@ -84,31 +84,31 @@ const QPixmap* Contact::getPhoto() const
 }
 
 ///Get the formatted name
-QString Contact::getFormattedName() const
+const QString& Contact::getFormattedName() const
 {
    return m_FormattedName;
 }
 
 ///Get the organisation
-QString Contact::getOrganization()  const
+const QString& Contact::getOrganization()  const
 {
    return m_Organization;
 }
 
 ///Get the preferred email
-QString Contact::getPreferredEmail()  const
+const QString& Contact::getPreferredEmail()  const
 {
    return m_PreferredEmail;
 }
 
 ///Get the unique identifier (used for drag and drop) 
-QString Contact::getUid() const
+const QString& Contact::getUid() const
 {
    return m_Uid;
 }
 
 ///Get the contact type
-QString Contact::getType() const
+const QString& Contact::getType() const
 {
    return m_Type;
 }
@@ -120,19 +120,19 @@ void Contact::setPhoneNumbers(PhoneNumbers numbers)
 }
 
 ///Set the nickname
-void Contact::setNickName(QString name)
+void Contact::setNickName(const QString& name)
 {
    m_NickName   = name;
 }
 
 ///Set the first name
-void Contact::setFirstName(QString name)
+void Contact::setFirstName(const QString& name)
 {
    m_FirstName  = name;
 }
 
 ///Set the family name
-void Contact::setFamilyName(QString name)
+void Contact::setFamilyName(const QString& name)
 {
    m_SecondName = name;
 }
@@ -144,25 +144,25 @@ void Contact::setPhoto(QPixmap* photo)
 }
 
 ///Set the formatted name (display name)
-void Contact::setFormattedName(QString name)
+void Contact::setFormattedName(const QString& name)
 {
    m_FormattedName = name;
 }
 
 ///Set the organisation / business
-void Contact::setOrganization(QString name)
+void Contact::setOrganization(const QString& name)
 {
    m_Organization = name;
 }
 
 ///Set the default email
-void Contact::setPreferredEmail(QString name)
+void Contact::setPreferredEmail(const QString& name)
 {
    m_PreferredEmail = name;
 }
 
 ///Set UID
-void Contact::setUid(QString id)
+void Contact::setUid(const QString& id)
 {
    m_Uid = id;
 }
\ No newline at end of file
diff --git a/src/Contact.h b/src/Contact.h
index 133b466a..87fa55c9 100644
--- a/src/Contact.h
+++ b/src/Contact.h
@@ -83,27 +83,27 @@ public:
    virtual void initItem();
    
    //Getters
-   virtual PhoneNumbers   getPhoneNumbers()    const;
-   virtual QString        getNickName()        const;
-   virtual QString        getFirstName()       const;
-   virtual QString        getSecondName()      const;
-   virtual QString        getFormattedName()   const;
-   virtual QString        getOrganization()    const;
-   virtual QString        getUid()             const;
-   virtual QString        getPreferredEmail()  const;
-   virtual const QPixmap* getPhoto()           const;
-   virtual QString        getType()            const;
+   virtual PhoneNumbers          getPhoneNumbers()    const;
+   virtual const QString&        getNickName()        const;
+   virtual const QString&        getFirstName()       const;
+   virtual const QString&        getSecondName()      const;
+   virtual const QString&        getFormattedName()   const;
+   virtual const QString&        getOrganization()    const;
+   virtual const QString&        getUid()             const;
+   virtual const QString&        getPreferredEmail()  const;
+   virtual const QPixmap*        getPhoto()           const;
+   virtual const QString&        getType()            const;
 
    //Setters
-   virtual void setPhoneNumbers   (PhoneNumbers   );
-   virtual void setFormattedName  (QString name   );
-   virtual void setNickName       (QString name   );
-   virtual void setFirstName      (QString name   );
-   virtual void setFamilyName     (QString name   );
-   virtual void setOrganization   (QString name   );
-   virtual void setPreferredEmail (QString name   );
-   virtual void setUid            (QString id     );
-   virtual void setPhoto          (QPixmap* photo );
+   virtual void setPhoneNumbers   (PhoneNumbers          );
+   virtual void setFormattedName  (const QString& name   );
+   virtual void setNickName       (const QString& name   );
+   virtual void setFirstName      (const QString& name   );
+   virtual void setFamilyName     (const QString& name   );
+   virtual void setOrganization   (const QString& name   );
+   virtual void setPreferredEmail (const QString& name   );
+   virtual void setUid            (const QString& id     );
+   virtual void setPhoto          (QPixmap* photo        );
    
 protected:
    virtual void initItemWidget();
diff --git a/src/ContactBackend.h b/src/ContactBackend.h
index 518bb728..81a0c051 100644
--- a/src/ContactBackend.h
+++ b/src/ContactBackend.h
@@ -37,10 +37,10 @@ class LIB_EXPORT ContactBackend : public QObject {
    Q_OBJECT
 public:
    ContactBackend(QObject* parent);
-   virtual Contact*    getContactByPhone ( QString phoneNumber ) = 0;
-   virtual Contact*    getContactByUid   ( QString uid         ) = 0;
-   virtual void        editContact       ( Contact* contact    ) = 0;
-   virtual void        addNewContact     ( Contact* contact    ) = 0;
+   virtual Contact*    getContactByPhone ( const QString& phoneNumber ) = 0;
+   virtual Contact*    getContactByUid   ( const QString& uid         ) = 0;
+   virtual void        editContact       ( Contact*       contact     ) = 0;
+   virtual void        addNewContact     ( Contact*       contact     ) = 0;
 protected:
    virtual ContactList update_slot       (                     ) = 0;
    QHash<QString,Contact*>        m_ContactByPhone ;
-- 
GitLab