From dc9ce0f3d7c5fac6ef98a723fc40f0cf2d14b6bc Mon Sep 17 00:00:00 2001
From: Emmanuel Lepage <emmanuel.lepage@savoirfairelinux.com>
Date: Wed, 2 May 2012 10:31:55 -0400
Subject: [PATCH] [ #10222 ] Fix minor itches and bugs

---
 kde/src/AccountView.cpp               | 12 +++----
 kde/src/CallView.cpp                  | 45 +++++++++------------------
 kde/src/SFLPhone.cpp                  |  4 +--
 kde/src/SFLPhoneView.cpp              | 32 +++++++++++++++++++
 kde/src/SFLPhoneView.h                |  5 +++
 kde/src/conf/ConfigAccountList.cpp    |  6 ++--
 kde/src/conf/dlgaccounts.cpp          |  4 +--
 kde/src/conf/sflphone-client-kde.kcfg |  4 +++
 kde/src/lib/Account.cpp               |  6 ++--
 kde/src/lib/AccountList.cpp           |  8 ++---
 kde/src/lib/CallModel.cpp             |  7 ++++-
 kde/src/lib/CallModel.h               | 21 +++++++------
 kde/src/lib/CallModel.hpp             | 10 +++++-
 kde/src/lib/sflphone_const.h          | 20 ++++++------
 kde/src/widgets/ContactDock.cpp       | 12 ++++++-
 kde/src/widgets/HistoryDock.cpp       | 27 +++++++++++-----
 kde/src/widgets/HistoryTreeItem.cpp   |  8 ++---
 17 files changed, 148 insertions(+), 83 deletions(-)

diff --git a/kde/src/AccountView.cpp b/kde/src/AccountView.cpp
index 167d495f93..0e20a83ffc 100644
--- a/kde/src/AccountView.cpp
+++ b/kde/src/AccountView.cpp
@@ -62,7 +62,7 @@ void AccountView::initItemWidget()
 
    if(isNew() || !enabled)
       m_pWidget->setState(AccountItemWidget::Unregistered);
-   else if(getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED || getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_READY)
+   else if(getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED || getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_READY)
       m_pWidget->setState(AccountItemWidget::Registered);
    else
       m_pWidget->setState(AccountItemWidget::NotWorking);
@@ -91,9 +91,9 @@ AccountItemWidget* AccountView::getItemWidget()
 ///Return the state color
 QColor AccountView::getStateColor()
 {
-   if(getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_UNREGISTERED)
+   if(getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_UNREGISTERED)
           return Qt::black;
-   if(getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED || getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_READY)
+   if(getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED || getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_READY)
           return Qt::darkGreen;
    return Qt::red;
 }
@@ -104,9 +104,9 @@ const QString& AccountView::getStateColorName()
    static const QString black    ( "black"     );
    static const QString darkGreen( "darkGreen" );
    static const QString red      ( "red"       );
-   if(getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_UNREGISTERED)
+   if(getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_UNREGISTERED)
           return black;
-   if(getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED || getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_READY)
+   if(getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED || getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_READY)
           return darkGreen;
    return red;
 }
@@ -158,7 +158,7 @@ void AccountView::updateState()
          kDebug() << "Changing account state to Unregistered";
          m_pWidget->setState(AccountItemWidget::Unregistered);
       }
-      else if(getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED || getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_READY) {
+      else if(getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED || getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_READY) {
          kDebug() << "Changing account state to  Registered";
          m_pWidget->setState(AccountItemWidget::Registered);
       }
diff --git a/kde/src/CallView.cpp b/kde/src/CallView.cpp
index 5c912479f3..81212cca4b 100644
--- a/kde/src/CallView.cpp
+++ b/kde/src/CallView.cpp
@@ -259,32 +259,8 @@ bool CallView::contactToCall(QTreeWidgetItem *parent, int index, const QMimeData
       Contact* contact = AkonadiBackend::getInstance()->getContactByUid(encodedContact);
       if (contact) {
          Call* call2;
-         if (contact->getPhoneNumbers().count() == 1) {
-            call2 = SFLPhone::model()->addDialingCall(contact->getFormattedName(), SFLPhone::model()->getCurrentAccountId());
-            call2->appendText(contact->getPhoneNumbers()[0]->getNumber());
-         }
-         else if (contact->getPhoneNumbers().count() > 1) {
-            bool ok = false;
-            QHash<QString,QString> map;
-            QStringList list;
-            foreach (Contact::PhoneNumber* number, contact->getPhoneNumbers()) {
-               map[number->getType()+" ("+number->getNumber()+")"] = number->getNumber();
-               list << number->getType()+" ("+number->getNumber()+")";
-            }
-            QString result = QInputDialog::getItem (this, QString("Select phone number"), QString("This contact have many phone number, please select the one you wish to call"), list, 0, false, &ok);
-            if (ok) {
-               call2 = SFLPhone::model()->addDialingCall(contact->getFormattedName(), SFLPhone::model()->getCurrentAccountId());
-               call2->appendText(map[result]);
-            }
-            else {
-               kDebug() << "Operation cancelled";
-               return false;
-            }
-         }
-         else {
-            kDebug() << "This contact have no valid phone number";
+         if (!SFLPhone::app()->view()->selectCallPhoneNumber(call2,contact))
             return false;
-         }
          if (!parent) {
             //Dropped on free space
             kDebug() << "Adding new dialing call";
@@ -382,12 +358,13 @@ Call* CallView::addCall(Call* call, Call* parent)
 ///Transfer a call
 void CallView::transfer()
 {
-   if (m_pCallPendingTransfer) {
+   if (m_pCallPendingTransfer && !m_pTransferLE->text().isEmpty()) {
       SFLPhone::model()->transfer(m_pCallPendingTransfer,m_pTransferLE->text());
-      m_pCallPendingTransfer = 0;
-      m_pTransferLE->clear();
-      m_pTransferOverlay->setVisible(false);
    }
+
+   m_pCallPendingTransfer = 0;
+   m_pTransferLE->clear();
+   m_pTransferOverlay->setVisible(false);
 }
 
 /*****************************************************************************
@@ -421,6 +398,13 @@ void CallView::hideOverlay()
    if (m_pActiveOverlay)
       m_pActiveOverlay->setVisible(false);
    m_pActiveOverlay = 0;
+
+   if (m_pCallPendingTransfer && m_pCallPendingTransfer->getState() == CALL_STATE_TRANSFER ) {
+      m_pCallPendingTransfer->actionPerformed(CALL_ACTION_TRANSFER);
+   }
+   
+   m_pCallPendingTransfer = 0;
+   m_pTransferLE->clear();
 }
 
 ///Be sure the size of the overlay stay the same
@@ -721,8 +705,9 @@ void CallViewOverlay::setVisible(bool enabled) {
       if (m_pTimer) {
          m_pTimer->stop();
          disconnect(m_pTimer);
+         delete m_pTimer;
       }
-      m_pTimer = new QTimer(this); //TODO LEAK?
+      m_pTimer = new QTimer(this);
       connect(m_pTimer, SIGNAL(timeout()), this, SLOT(changeVisibility()));
       m_step = 0;
       m_black.setAlpha(0);
diff --git a/kde/src/SFLPhone.cpp b/kde/src/SFLPhone.cpp
index 21b03330c8..ea853869ec 100755
--- a/kde/src/SFLPhone.cpp
+++ b/kde/src/SFLPhone.cpp
@@ -397,8 +397,8 @@ void SFLPhone::on_m_pView_recordCheckStateChangeAsked(bool recordCheckState)
 void SFLPhone::on_m_pView_incomingCall(const Call * call)
 {
    Contact* contact = AkonadiBackend::getInstance()->getContactByPhone(call->getPeerPhoneNumber());
-   if (contact) {
-      KNotification::event(KNotification::Notification, "New incomming call", "New call from: \n" + call->getPeerName().isEmpty() ? call->getPeerPhoneNumber() : call->getPeerName(),*contact->getPhoto());
+   if (contact && call) {
+      KNotification::event(KNotification::Notification, "New incomming call", "New call from: \n" + call->getPeerName().isEmpty() ? call->getPeerPhoneNumber() : call->getPeerName(),(contact->getPhoto())?*contact->getPhoto():NULL);
    }
    KNotification::event(KNotification::Notification, "New incomming call", "New call from: \n" + call->getPeerName().isEmpty() ? call->getPeerPhoneNumber() : call->getPeerName());
 }
diff --git a/kde/src/SFLPhoneView.cpp b/kde/src/SFLPhoneView.cpp
index dadf805c4b..b66ac42106 100755
--- a/kde/src/SFLPhoneView.cpp
+++ b/kde/src/SFLPhoneView.cpp
@@ -49,6 +49,7 @@
 #include "lib/callmanager_interface_singleton.h"
 #include "lib/instance_interface_singleton.h"
 #include "lib/sflphone_const.h"
+#include "lib/Contact.h"
 
 //ConfigurationDialog* SFLPhoneView::configDialog;
 
@@ -239,6 +240,37 @@ void SFLPhoneView::action(Call* call, call_action action)
    }
 }
 
+///Select a phone number when calling using a contact
+bool SFLPhoneView::selectCallPhoneNumber(Call* call2,Contact* contact)
+{
+   if (contact->getPhoneNumbers().count() == 1) {
+      call2 = SFLPhone::model()->addDialingCall(contact->getFormattedName(), SFLPhone::model()->getCurrentAccountId());
+      call2->appendText(contact->getPhoneNumbers()[0]->getNumber());
+   }
+   else if (contact->getPhoneNumbers().count() > 1) {
+      bool ok = false;
+      QHash<QString,QString> map;
+      QStringList list;
+      foreach (Contact::PhoneNumber* number, contact->getPhoneNumbers()) {
+         map[number->getType()+" ("+number->getNumber()+")"] = number->getNumber();
+         list << number->getType()+" ("+number->getNumber()+")";
+      }
+      QString result = QInputDialog::getItem (this, QString("Select phone number"), QString("This contact have many phone number, please select the one you wish to call"), list, 0, false, &ok);
+      if (ok) {
+         call2 = SFLPhone::model()->addDialingCall(contact->getFormattedName(), SFLPhone::model()->getCurrentAccountId());
+         call2->appendText(map[result]);
+      }
+      else {
+         kDebug() << "Operation cancelled";
+         return false;
+      }
+   }
+   else {
+      kDebug() << "This contact have no valid phone number";
+      return false;
+   }
+   return true;
+}
 
 /*****************************************************************************
  *                                                                           *
diff --git a/kde/src/SFLPhoneView.h b/kde/src/SFLPhoneView.h
index 3f444acd6a..9f63db7a23 100755
--- a/kde/src/SFLPhoneView.h
+++ b/kde/src/SFLPhoneView.h
@@ -93,6 +93,9 @@ public:
    */
    int phoneNumberTypesDisplayed();
 
+
+   bool selectCallPhoneNumber(Call* call,Contact* contact);
+
 private slots:
    /**
     *   Performs the action action on the call call, then updates window.
@@ -163,6 +166,8 @@ private slots:
    void updateDialpad        ();
 
 
+
+
 public slots:
    /**
     * Updates all the display
diff --git a/kde/src/conf/ConfigAccountList.cpp b/kde/src/conf/ConfigAccountList.cpp
index 7aaf8c3706..7f75729048 100644
--- a/kde/src/conf/ConfigAccountList.cpp
+++ b/kde/src/conf/ConfigAccountList.cpp
@@ -79,7 +79,7 @@ QVector<AccountView*> ConfigAccountList::getAccountByState(QString & state)
 {
    QVector<AccountView*> v;
    for (int i = 0; i < accounts->size(); ++i) {
-      if ((*accounts)[i]->getAccountDetail(REGISTRATION_STATUS) == state)
+      if ((*accounts)[i]->getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == state)
          v += (*accounts)[i];
    }
    return v;
@@ -167,7 +167,7 @@ QVector<AccountView*> ConfigAccountList::registeredAccounts() const
    AccountView* current;
    for (int i = 0; i < accounts->count(); ++i) {
       current = (*accounts)[i];
-      if(current->getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED) {
+      if(current->getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED) {
          kDebug() << current->getAlias() << " : " << current;
          registeredAccounts.append(current);
       }
@@ -180,7 +180,7 @@ AccountView* ConfigAccountList::firstRegisteredAccount() const
    AccountView* current;
    for (int i = 0; i < accounts->count(); ++i) {
       current = (*accounts)[i];
-      if(current->getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED)
+      if(current->getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED)
       {
          return current;
       }
diff --git a/kde/src/conf/dlgaccounts.cpp b/kde/src/conf/dlgaccounts.cpp
index de43feca96..4d1f0a5e3c 100755
--- a/kde/src/conf/dlgaccounts.cpp
+++ b/kde/src/conf/dlgaccounts.cpp
@@ -302,7 +302,7 @@ void DlgAccounts::loadAccount(QListWidgetItem * item)
    loadCredentails(account->getAccountDetail(ACCOUNT_ID));
 
    bool ok;
-   int val = account->getAccountDetail(REGISTRATION_STATUS).toInt(&ok);
+   int val = account->getAccountDetail(ACCOUNT_REGISTRATION_STATUS).toInt(&ok);
    spinbox_regExpire->setValue(ok ? val : REGISTRATION_EXPIRE_DEFAULT);
 
    foreach(CredentialData data,credentialList) {
@@ -559,7 +559,7 @@ void DlgAccounts::updateStatusLabel(AccountView* account)
    if(! account ) {
           return;
         }
-   QString status = account->getAccountDetail(REGISTRATION_STATUS);
+   QString status = account->getAccountDetail(ACCOUNT_REGISTRATION_STATUS);
    edit7_state->setText( "<FONT COLOR=\"" + account->getStateColorName() + "\">" + status + "</FONT>" );
 }
 
diff --git a/kde/src/conf/sflphone-client-kde.kcfg b/kde/src/conf/sflphone-client-kde.kcfg
index 3bc1f21fb5..6c516539cb 100755
--- a/kde/src/conf/sflphone-client-kde.kcfg
+++ b/kde/src/conf/sflphone-client-kde.kcfg
@@ -48,9 +48,13 @@
     <entry name="displayDataRange" type="Bool">
     	<label>Defines whether call history is restricted to a specific date range</label>
     </entry>
+   <entry name="historySortMode" type="Int">
+      <label>Define sorting order for history list</label>
+    </entry>
    <entry name="displayContactCallHistory" type="Bool">
         <label>Defines if the individual contact history list is visible</label>
     </entry>
+    
 
     <!-- Audio Settings -->
 
diff --git a/kde/src/lib/Account.cpp b/kde/src/lib/Account.cpp
index 6e4f05e0cc..e3b349d930 100644
--- a/kde/src/lib/Account.cpp
+++ b/kde/src/lib/Account.cpp
@@ -183,7 +183,7 @@ bool Account::isEnabled() const
 ///Is this account registered
 bool Account::isRegistered() const
 {
-   return (getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED);
+   return (getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED);
 }
 
 
@@ -232,8 +232,8 @@ void Account::updateState()
    if(! isNew()) {
       ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
       MapStringString details = configurationManager.getAccountDetails(getAccountId()).value();
-      QString status = details[REGISTRATION_STATUS];
-      setAccountDetail(REGISTRATION_STATUS, status); //Update -internal- object state
+      QString status = details[ACCOUNT_REGISTRATION_STATUS];
+      setAccountDetail(ACCOUNT_REGISTRATION_STATUS, status); //Update -internal- object state
    }
 }
 
diff --git a/kde/src/lib/AccountList.cpp b/kde/src/lib/AccountList.cpp
index 30c440de2c..9b46222014 100644
--- a/kde/src/lib/AccountList.cpp
+++ b/kde/src/lib/AccountList.cpp
@@ -143,7 +143,7 @@ QVector<Account*> AccountList::getAccountsByState(const QString& state)
 {
    QVector<Account *> v;
    for (int i = 0; i < m_pAccounts->size(); ++i) {
-      if ((*m_pAccounts)[i]->getAccountDetail(REGISTRATION_STATUS) == state)
+      if ((*m_pAccounts)[i]->getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == state)
          v += (*m_pAccounts)[i];
    }
    return v;
@@ -157,7 +157,7 @@ QVector<Account*> AccountList::registeredAccounts() const
    Account* current;
    for (int i = 0; i < m_pAccounts->count(); ++i) {
       current = (*m_pAccounts)[i];
-      if(current->getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED) {
+      if(current->getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED) {
          qDebug() << current->getAlias() << " : " << current;
          registeredAccounts.append(current);
       }
@@ -171,11 +171,11 @@ Account* AccountList::firstRegisteredAccount() const
    Account* current;
    for (int i = 0; i < m_pAccounts->count(); ++i) {
       current = (*m_pAccounts)[i];
-      if(current && current->getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED) {
+      if(current && current->getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED) {
          return current;
       }
       else {
-         qDebug() << "Account " << ((current)?current->getAccountId():"") << " is not registered (" << ((current)?current->getAccountDetail(REGISTRATION_STATUS):"") << ") State:" << ((current)?current->getAccountDetail(REGISTRATION_STATUS):"");
+         qDebug() << "Account " << ((current)?current->getAccountId():"") << " is not registered (" << ((current)?current->getAccountDetail(ACCOUNT_REGISTRATION_STATUS):"") << ") State:" << ((current)?current->getAccountDetail(ACCOUNT_REGISTRATION_STATUS):"");
       }
    }
    return NULL;
diff --git a/kde/src/lib/CallModel.cpp b/kde/src/lib/CallModel.cpp
index 66c37d1f39..79acc3b3df 100644
--- a/kde/src/lib/CallModel.cpp
+++ b/kde/src/lib/CallModel.cpp
@@ -60,7 +60,12 @@ void CallModelBase::on1_callStateChanged(const QString &callID, const QString &s
       qDebug() << "Call found" << call;
       call->stateChanged(state);
    }
-   //updateWindowCallState(); //NEED_PORT
+
+   if (call->getCurrentState() == CALL_STATE_OVER) {
+      addToHistory(call);
+      emit historyChanged();
+   }
+   
    emit callStateChanged(call);
    
 }
diff --git a/kde/src/lib/CallModel.h b/kde/src/lib/CallModel.h
index 7644138291..924264d8f9 100644
--- a/kde/src/lib/CallModel.h
+++ b/kde/src/lib/CallModel.h
@@ -54,6 +54,7 @@ public:
    virtual Call* findCallByCallId ( const QString& callId                       ) = 0;
    virtual Call* addRingingCall   ( const QString& callId                       ) = 0;
    virtual Call* addIncomingCall  ( const QString& callId                       ) = 0;
+   virtual void  addToHistory     ( Call* call                                  ) = 0;
    virtual Call* addCall          ( Call* call           , Call* parent =0      );
    virtual Call* getCall          ( const QString& callId                       ) const = 0;
 public slots:
@@ -67,15 +68,16 @@ public slots:
 private:
    static bool dbusInit;
 signals:
-   void callStateChanged        (Call* call                              );
-   void incomingCall            (Call* call                              );
-   void conferenceCreated       (Call* conf                              );
-   void conferenceChanged       (Call* conf                              );
-   void conferenceRemoved       (const QString& confId                   );
-   void aboutToRemoveConference (Call* conf                              );
-   void voiceMailNotify         (const QString& accountID , int    count );
-   void volumeChanged           (const QString& device    , double value );
-   void callAdded               (Call* call               , Call* parent );
+   void callStateChanged        ( Call* call                              );
+   void incomingCall            ( Call* call                              );
+   void conferenceCreated       ( Call* conf                              );
+   void conferenceChanged       ( Call* conf                              );
+   void conferenceRemoved       ( const QString& confId                   );
+   void aboutToRemoveConference ( Call* conf                              );
+   void voiceMailNotify         ( const QString& accountID , int    count );
+   void volumeChanged           ( const QString& device    , double value );
+   void callAdded               ( Call* call               , Call* parent );
+   void historyChanged          (                                         );
 };
 
 /**
@@ -109,6 +111,7 @@ class LIB_EXPORT CallModel : public CallModelBase {
       void           removeCall       ( Call* call                                     );
       void           attendedTransfer ( Call* toTransfer           , Call* target      );
       void           transfer         ( Call* toTransfer           , QString target    );
+      void           addToHistory     ( Call* call                                     );
       
       virtual bool selectItem(Call* item) { Q_UNUSED(item); return false;}
 
diff --git a/kde/src/lib/CallModel.hpp b/kde/src/lib/CallModel.hpp
index 8fb295df4d..2145ac8cf2 100644
--- a/kde/src/lib/CallModel.hpp
+++ b/kde/src/lib/CallModel.hpp
@@ -419,6 +419,14 @@ template<typename CallWidget, typename Index> const CallHash& CallModel<CallWidg
    return m_sHistoryCalls;
 }
 
+///Add to history
+template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::addToHistory(Call* call)
+{
+   if (call) {
+      m_sHistoryCalls[call->getStartTimeStamp()] = call;
+   }
+}
+
 /*****************************************************************************
  *                                                                           *
  *                           Account related code                            *
@@ -442,7 +450,7 @@ template<typename CallWidget, typename Index> QString CallModel<CallWidget,Index
 template<typename CallWidget, typename Index> Account* CallModel<CallWidget,Index>::getCurrentAccount()
 {
    Account* priorAccount = getAccountList()->getAccountById(m_sPriorAccountId);
-   if(priorAccount && priorAccount->getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED ) {
+   if(priorAccount && priorAccount->getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED ) {
       return priorAccount;
    }
    else {
diff --git a/kde/src/lib/sflphone_const.h b/kde/src/lib/sflphone_const.h
index 500cca98cf..14d7542262 100644
--- a/kde/src/lib/sflphone_const.h
+++ b/kde/src/lib/sflphone_const.h
@@ -173,6 +173,10 @@
 #define ACCOUNT_MAILBOX                    "Account.mailbox"
 #define ACCOUNT_USERAGENT                  "Account.useragent"
 #define ACCOUNT_REGISTRATION_EXPIRE        "Account.registrationExpire"
+#define ACCOUNT_REGISTRATION_STATUS        "Account.registrationStatus"
+#define ACCOUNT_REGISTRATION_STATE_CODE    "Account.registrationCode"
+#define ACCOUNT_REGISTRATION_STATE_DESC    "Account.registrationDescription"
+
 #define ACCOUNT_SIP_STUN_SERVER            "STUN.server"
 #define ACCOUNT_SIP_STUN_ENABLED           "STUN.enable"
 #define ACCOUNT_DTMF_TYPE                  "Account.dtmfType"
@@ -211,16 +215,6 @@
 #define TLS_NEGOTIATION_TIMEOUT_SEC        "TLS.negotiationTimeoutSec"
 #define TLS_NEGOTIATION_TIMEOUT_MSEC       "TLS.negotiationTimemoutMsec"
 
-#define LOCAL_INTERFACE                    "Account.localInterface"
-#define PUBLISHED_SAMEAS_LOCAL             "Account.publishedSameAsLocal"
-#define LOCAL_PORT                         "Account.localPort"
-#define PUBLISHED_PORT                     "Account.publishedPort"
-#define PUBLISHED_ADDRESS                  "Account.publishedAddress"
-
-#define REGISTRATION_STATUS                "Registration.Status"
-#define REGISTRATION_STATE_CODE            "Registration.code"
-#define REGISTRATION_STATE_DESCRIPTION     "Registration.description"
-
 #define SHORTCUT_PICKUP                    "pickUp"
 #define SHORTCUT_HANGUP                    "hangUp"
 #define SHORTCUT_POPUP                     "popupWindow"
@@ -236,6 +230,12 @@
 #define CONFIG_ACCOUNT_DEFAULT_REALM        "*"
 #define CONFIG_ACCOUNT_USERAGENT            "Account.useragent"
 
+#define LOCAL_INTERFACE                    "Account.localInterface"
+#define PUBLISHED_SAMEAS_LOCAL             "Account.publishedSameAsLocal"
+#define LOCAL_PORT                         "Account.localPort"
+#define PUBLISHED_PORT                     "Account.publishedPort"
+#define PUBLISHED_ADDRESS                  "Account.publishedAddress"
+
 
 /** Maybe to remove **/
 // #define ACCOUNT_EXPIRE                   "Account.expire"
diff --git a/kde/src/widgets/ContactDock.cpp b/kde/src/widgets/ContactDock.cpp
index bce78d16d8..d61ee15d97 100644
--- a/kde/src/widgets/ContactDock.cpp
+++ b/kde/src/widgets/ContactDock.cpp
@@ -43,6 +43,8 @@
 #include "ContactItemWidget.h"
 #include "SFLPhone.h"
 #include "conf/ConfigurationSkeleton.h"
+#include "CallView.h"
+#include "SFLPhoneView.h"
 
 //SFLPhone library
 #include "lib/Call.h"
@@ -293,7 +295,15 @@ void ContactDock::keyPressEvent(QKeyEvent* event) {
    int key = event->key();
    if(key == Qt::Key_Escape)
       m_pFilterLE->setText(QString());
-   else if(key == Qt::Key_Return || key == Qt::Key_Enter) {}
+   else if(key == Qt::Key_Return || key == Qt::Key_Enter) {
+      if (m_pContactView->selectedItems()[0] && m_pContactView->itemWidget(m_pContactView->selectedItems()[0],0)) {
+         QNumericTreeWidgetItem_hist* item = dynamic_cast<QNumericTreeWidgetItem_hist*>(m_pContactView->selectedItems()[0]);
+         if (item) {
+            Call* call;
+            SFLPhone::app()->view()->selectCallPhoneNumber(call,item->widget->getContact());
+         }
+      }
+   }
    else if((key == Qt::Key_Backspace) && (m_pFilterLE->text().size()))
       m_pFilterLE->setText(m_pFilterLE->text().left( m_pFilterLE->text().size()-1 ));
    else if (!event->text().isEmpty() && !(key == Qt::Key_Backspace))
diff --git a/kde/src/widgets/HistoryDock.cpp b/kde/src/widgets/HistoryDock.cpp
index 9b60cb0a65..8b2fa7ac75 100644
--- a/kde/src/widgets/HistoryDock.cpp
+++ b/kde/src/widgets/HistoryDock.cpp
@@ -147,12 +147,16 @@ HistoryDock::HistoryDock(QWidget* parent) : QDockWidget(parent)
    m_CurrentFromDate = m_pFromDW->date();
    m_CurrentToDate   = m_pToDW->date();
 
-   connect(m_pAllTimeCB,                  SIGNAL(toggled(bool)),            this, SLOT(enableDateRange(bool)       ));
-   connect(m_pFilterLE,                   SIGNAL(textChanged(QString)),     this, SLOT(filter(QString)             ));
-   connect(m_pFromDW  ,                   SIGNAL(changed(QDate)),           this, SLOT(updateLinkedFromDate(QDate) ));
-   connect(m_pToDW    ,                   SIGNAL(changed(QDate)),           this, SLOT(updateLinkedToDate(QDate)   ));
-   connect(m_pSortByCBB,                  SIGNAL(currentIndexChanged(int)), this, SLOT(reload()                    ));
-   connect(AkonadiBackend::getInstance(), SIGNAL(collectionChanged()),      this, SLOT(updateContactInfo()         ));
+   connect(m_pAllTimeCB,                   SIGNAL(toggled(bool)),            this, SLOT(enableDateRange(bool)       ));
+   connect(m_pFilterLE,                    SIGNAL(textChanged(QString)),     this, SLOT(filter(QString)             ));
+   connect(m_pFromDW  ,                    SIGNAL(changed(QDate)),           this, SLOT(updateLinkedFromDate(QDate) ));
+   connect(m_pToDW    ,                    SIGNAL(changed(QDate)),           this, SLOT(updateLinkedToDate(QDate)   ));
+   connect(m_pSortByCBB,                   SIGNAL(currentIndexChanged(int)), this, SLOT(reload()                    ));
+   connect(AkonadiBackend::getInstance(),  SIGNAL(collectionChanged()),      this, SLOT(updateContactInfo()         ));
+   connect(SFLPhone::model()            ,  SIGNAL(historyChanged()),         this, SLOT(reload()                    ));
+
+   kDebug() << "\n\n\n\nHERE" << ConfigurationSkeleton::historySortMode() << ConfigurationSkeleton::displayDataRange() << ConfigurationSkeleton::historyMax();
+   m_pSortByCBB->setCurrentIndex(ConfigurationSkeleton::historySortMode());
 }
 
 ///Destructor
@@ -194,6 +198,7 @@ void HistoryDock::updateContactInfo()
 ///Reload the history list
 void HistoryDock::reload()
 {
+   kDebug() << "IN RELOAD";
    m_pItemView->clear();
    foreach(HistoryTreeItem* hitem, m_History) {
       delete hitem;
@@ -258,6 +263,7 @@ void HistoryDock::reload()
          }
          break;
    }
+   ConfigurationSkeleton::setHistorySortMode(m_pSortByCBB->currentIndex());
    m_pItemView->sortItems(0,Qt::AscendingOrder);
 
    int maxWidth = 0;
@@ -388,7 +394,14 @@ void HistoryDock::keyPressEvent(QKeyEvent* event) {
    int key = event->key();
    if(key == Qt::Key_Escape)
       m_pFilterLE->setText(QString());
-   else if(key == Qt::Key_Return || key == Qt::Key_Enter) {}
+   else if ((key == Qt::Key_Return || key == Qt::Key_Enter) && m_pItemView->selectedItems().size() > 0) {
+      if (m_pItemView->selectedItems()[0] && m_pItemView->itemWidget(m_pItemView->selectedItems()[0],0)) {
+         QNumericTreeWidgetItem* item = dynamic_cast<QNumericTreeWidgetItem*>(m_pItemView->selectedItems()[0]);
+         if (item) {
+            SFLPhone::model()->addDialingCall(item->widget->getName(), SFLPhone::app()->model()->getCurrentAccountId())->setCallNumber(item->widget->getPhoneNumber());
+         }
+      }
+   }
    else if((key == Qt::Key_Backspace) && (m_pFilterLE->text().size()))
       m_pFilterLE->setText(m_pFilterLE->text().left( m_pFilterLE->text().size()-1 ));
    else if (!event->text().isEmpty() && !(key == Qt::Key_Backspace))
diff --git a/kde/src/widgets/HistoryTreeItem.cpp b/kde/src/widgets/HistoryTreeItem.cpp
index 01aa46307f..0cc6647a9c 100644
--- a/kde/src/widgets/HistoryTreeItem.cpp
+++ b/kde/src/widgets/HistoryTreeItem.cpp
@@ -31,7 +31,7 @@
 #include <QtGui/QMessageBox>
 #include <QtGui/QPainter>
 #include <QtGui/QColor>
-#include <QFontMetrics>
+#include <QtGui/QFontMetrics>
 #include <QtCore/QStringList>
 #include <QtCore/QFile>
 #include <Phonon/MediaObject>
@@ -85,7 +85,7 @@ HistoryTreeItem::HistoryTreeItem(QWidget *parent ,QString phone)
    m_pAddToContact = new KAction(this);
    m_pBookmark     = new KAction(this);
 
-   m_pCallAgain->setShortcut    ( Qt::CTRL + Qt::Key_Enter       );
+   m_pCallAgain->setShortcut    ( Qt::Key_Enter       );
    m_pCallAgain->setText        ( i18n("Call Again")             );
    m_pCallAgain->setIcon        ( KIcon(ICON_DIALING)            );
 
@@ -351,7 +351,7 @@ void HistoryTreeItem::showRecordPlayer()
               this, SLOT(stateChanged(Phonon::State,Phonon::State)));
       
    }
-   qDebug() << "Path:" << m_pItemCall->getRecordingPath();
+   kDebug() << "Path:" << m_pItemCall->getRecordingPath();
    m_pPlayer->setVisible(true);
    Phonon::MediaSource source(m_pItemCall->getRecordingPath());
    m_lSources.append(source);
@@ -393,7 +393,7 @@ void HistoryTreeItem::tick(qint64 time)
 ///Called on player state change
 void HistoryTreeItem::stateChanged(Phonon::State newState, Phonon::State /* oldState */)
 {
-   qDebug() << "Player state changed";
+   kDebug() << "Player state changed";
    switch (newState) {
       case Phonon::ErrorState:
             if (m_pMediaObject->errorType() == Phonon::FatalError) {
-- 
GitLab