[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [sflphone-kde/abstractmodels] src: [ #25416 ] Make Krazy2 and Covertity happy
From:       Emmanuel Lepage Vallee <emmanuel.lepage () savoirfairelinux ! com>
Date:       2013-06-04 18:01:40
Message-ID: 20130604180140.EA0D7A605A () git ! kde ! org
[Download RAW message or body]

Git commit 85995090530c7cd36e7014eb7db39344715273b8 by Emmanuel Lepage Vallee.
Committed on 04/06/2013 at 20:01.
Pushed by lepagevalleeemmanuel into branch 'abstractmodels'.

[ #25416 ] Make Krazy2 and Covertity happy

M  +2    -1    src/accountwizard.cpp
M  +1    -0    src/conf/dlgaccessibility.cpp
M  +2    -2    src/conf/dlgdisplay.cpp
M  +21   -16   src/delegates/categorizeddelegate.cpp
M  +23   -15   src/delegates/categorizeddelegate.h
M  +17   -18   src/delegates/conferencedelegate.cpp
M  +9    -4    src/delegates/conferencedelegate.h
M  +2    -2    src/delegates/contactdelegate.cpp
M  +1    -1    src/delegates/contactdelegate.h
M  +6    -8    src/delegates/delegatedropoverlay.cpp
M  +2    -1    src/delegates/delegatedropoverlay.h
M  +1    -1    src/delegates/historydelegate.h
M  +4    -4    src/delegates/phonenumberdelegate.h
M  +2    -2    src/klib/CMakeLists.txt
M  +6    -3    src/klib/akonadibackend.cpp
M  +4    -4    src/klib/akonadibackend.h
M  +35   -10   src/klib/bookmarkmodel.cpp
M  +28   -29   src/klib/bookmarkmodel.h
A  +185  -0    src/klib/macro.cpp     [License: LGPL (v2.1+)]
C  +54   -39   src/klib/macro.h [from: src/widgets/tips/ringingtip.h - 050% \
similarity] M  +1    -149  src/klib/macromodel.cpp
M  +1    -49   src/klib/macromodel.h
M  +1    -1    src/klib/tipanimationwrapper.cpp
M  +4    -2    src/lib/CMakeLists.txt
R  +27   -16   src/lib/abstractcontactbackend.cpp [from: src/lib/contactbackend.cpp - \
076% similarity] R  +10   -9    src/lib/abstractcontactbackend.h [from: \
src/lib/contactbackend.h - 091% similarity] M  +11   -14   src/lib/accountlist.cpp
M  +1    -1    src/lib/accountlist.h
M  +26   -6    src/lib/call.cpp
M  +10   -10   src/lib/call.h
M  +13   -6    src/lib/callmodel.cpp
M  +1    -5    src/lib/callmodel.h
M  +34   -1    src/lib/contact.cpp
M  +8    -10   src/lib/contact.h
R  +51   -49   src/lib/contactproxymodel.cpp [from: src/klib/contactproxymodel.cpp - \
078% similarity] R  +16   -17   src/lib/contactproxymodel.h [from: \
src/klib/contactproxymodel.h - 084% similarity] M  +18   -5    \
src/lib/historymodel.cpp M  +2    -3    src/lib/historymodel.h
M  +0    -3    src/lib/videomodel.h
M  +67   -72   src/sflphone.cpp
M  +8    -3    src/sflphoneapplication.cpp
M  +0    -1    src/sflphoneview.cpp
M  +1    -1    src/widgets/bookmarkdock.cpp
M  +1    -1    src/widgets/bookmarkdock.h
M  +2    -1    src/widgets/callviewoverlay.cpp
M  +1    -1    src/widgets/callviewoverlaytoolbar.cpp
M  +1    -1    src/widgets/categorizedtreeview.cpp
M  +3    -4    src/widgets/categorizedtreeview.h
M  +12   -12   src/widgets/contactdock.cpp
M  +8    -4    src/widgets/contactdock.h
M  +14   -9    src/widgets/historydock.cpp
M  +1    -1    src/widgets/historydock.h
M  +1    -1    src/widgets/player.cpp
M  +1    -1    src/widgets/player.h
M  +1    -1    src/widgets/playeroverlay.h
M  +1    -1    src/widgets/tips/ringingtip.cpp
M  +2    -2    src/widgets/tips/ringingtip.h
M  +1    -1    src/widgets/ui/dockbase.ui
M  +1    -1    src/widgets/ui/player.ui
M  +1    -1    src/widgets/ui/playeroverlay.ui

http://commits.kde.org/sflphone-kde/85995090530c7cd36e7014eb7db39344715273b8

diff --git a/src/accountwizard.cpp b/src/accountwizard.cpp
index d0fe040..fcfcffa 100644
--- a/src/accountwizard.cpp
+++ b/src/accountwizard.cpp
@@ -103,6 +103,7 @@ int AccountWizard::sendRequest(const QString& host, int port, \
const QString& req  if(::connect(s, (const struct sockaddr *) &servSockAddr, \
(socklen_t) sizeof(servSockAddr)) < 0 ) {  perror(nullptr);
       ret = "connect";
+      ::close(s);
       return -1;
    }
 
@@ -128,12 +129,12 @@ int AccountWizard::sendRequest(const QString& host, int port, \
const QString& req  
    if (status != 200) {
       ret = "http error: " + status;
+      fclose(f);
 //       sprintf(ret, "http error: %ld", status);
       return -1;
    }
 
    fclose(f);
-   delete f;
    shutdown(s, 2);
    ::close(s);
    return 0;
diff --git a/src/conf/dlgaccessibility.cpp b/src/conf/dlgaccessibility.cpp
index 7207012..ff6008c 100644
--- a/src/conf/dlgaccessibility.cpp
+++ b/src/conf/dlgaccessibility.cpp
@@ -25,6 +25,7 @@
 
 //SFLPhone
 #include <klib/macromodel.h>
+#include <klib/macro.h>
 
 ///Constructor
 DlgAccessibility::DlgAccessibility(KConfigDialog* parent)
diff --git a/src/conf/dlgdisplay.cpp b/src/conf/dlgdisplay.cpp
index ef3f1f9..d8922c6 100644
--- a/src/conf/dlgdisplay.cpp
+++ b/src/conf/dlgdisplay.cpp
@@ -25,7 +25,7 @@
 
 ///Constructor
 DlgDisplay::DlgDisplay(KConfigDialog *parent)
- : QWidget(parent)
+ : QWidget(parent),m_HasChanged(false)
 {
    setupUi(this);
    kcfg_minimumRowHeight->setEnabled(ConfigurationSkeleton::limitMinimumRowHeight());
 @@ -44,7 +44,7 @@ DlgDisplay::DlgDisplay(KConfigDialog *parent)
    QMutableMapIterator<QString, QString> iter(m_lCallDetails);
    while (iter.hasNext()) {
       iter.next();
-      bool checked = \
ConfigurationSkeleton::self()->findItem(iter.value())->isEqual(true); +      const \
                bool checked = \
                ConfigurationSkeleton::self()->findItem(iter.value())->isEqual(true);
       QListWidgetItem* i = new QListWidgetItem(i18n(iter.key().toAscii()));
       i->setFlags      (Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
       i->setCheckState ((checked)?Qt::Checked:Qt::Unchecked        );
diff --git a/src/delegates/categorizeddelegate.cpp \
b/src/delegates/categorizeddelegate.cpp index c3e5e03..1e815be 100644
--- a/src/delegates/categorizeddelegate.cpp
+++ b/src/delegates/categorizeddelegate.cpp
@@ -23,18 +23,21 @@
 
 #include <QtCore/QDebug>
 
+///Construnctor
 SortedTreeDelegate::SortedTreeDelegate(QTreeView* widget)
    : QStyledItemDelegate(widget)
-   , m_tree(widget),m_LeftMargin(0),m_RightMargin(0),m_pChildDelegate(nullptr),m_pChildChildDelegate(nullptr)
 +   , m_tree(widget),m_LeftMargin(7),m_RightMargin(7),m_pChildDelegate(nullptr),m_pChildChildDelegate(nullptr)
  {
 }
 
+///Destructor
 SortedTreeDelegate::~SortedTreeDelegate()
 {
    if (m_pChildDelegate) delete m_pChildDelegate;
    if (m_pChildChildDelegate) delete m_pChildChildDelegate;
 }
 
+///Report category height
 QSize SortedTreeDelegate::sizeHint(const QStyleOptionViewItem& option, const \
QModelIndex& index) const {  //Only do it for categories and objects deeper than 1 \
level, use precalculated values for others  if (index.parent().isValid() && \
!index.parent().parent().isValid() && m_pChildDelegate) { @@ -42,27 +45,27 @@ QSize \
SortedTreeDelegate::sizeHint(const QStyleOptionViewItem& option, const QMo  }
    if (!index.parent().isValid() || index.parent().parent().isValid()) {
       QSize sh = QStyledItemDelegate::sizeHint(option, index);
-      sh.rheight() += 2 * 7/*left margin*/;
-      sh.rwidth() += 7/*left margin*/;
+      sh.rheight() += 2 * m_LeftMargin;
+      sh.rwidth() += m_LeftMargin;
       return sh;
    }
    return m_SH;
-}
+} //sizeHint
 
-QRect SortedTreeDelegate::fullCategoryRect(const QStyleOptionViewItem& option, const \
QModelIndex& index) const { +///Generate a gradient rectangle for the categories and \
the first child +QRect SortedTreeDelegate::fullCategoryRect(const \
QStyleOptionViewItem& option, const QModelIndex& index) const +{
    QModelIndex i(index),old(index);
 
    //BEGIN real sizeHint()
    //Otherwise it would be called too often (thanks to valgrind)
    ((SortedTreeDelegate*)this)->m_SH          = \
                QStyledItemDelegate::sizeHint(option, index);
-   ((SortedTreeDelegate*)this)->m_LeftMargin  = 7/*left margin*/;
-   ((SortedTreeDelegate*)this)->m_RightMargin = 7/*right margin*/;
    if (!index.parent().isValid()) {
-      ((QSize)m_SH).rheight() += 2 * 7/*left margin*/;
+      ((QSize)m_SH).rheight() += 2 * m_LeftMargin;
    } else {
-      ((QSize)m_SH).rheight() += 7/*left margin*/;
+      ((QSize)m_SH).rheight() += m_LeftMargin;
    }
-   ((QSize)m_SH).rwidth() += 7/*left margin*/;
+   ((QSize)m_SH).rwidth() += m_LeftMargin;
    //END real sizeHint()
    
    if (i.parent().isValid()) {
@@ -77,8 +80,8 @@ QRect SortedTreeDelegate::fullCategoryRect(const \
QStyleOptionViewItem& option, c  QRect r = m_tree->visualRect(i);
 
    // adapt width
-   r.setLeft(7/*left margin*/);
-   r.setWidth(m_tree->viewport()->width() - 7/*left margin*/ - 7/*right margin*/);
+   r.setLeft(m_LeftMargin);
+   r.setWidth(m_tree->viewport()->width() - m_LeftMargin - m_RightMargin);
 
    // adapt height
    if (m_tree->isExpanded(i) && m_tree->model()->rowCount(i) > 0) {
@@ -88,11 +91,12 @@ QRect SortedTreeDelegate::fullCategoryRect(const \
                QStyleOptionViewItem& option, c
       r.setHeight((r.height() + childCount * h > 100)?100:(r.height() + childCount * \
h));  }
 
-   r.setTop(r.top() + 7/*left margin*/);
+   r.setTop(r.top() + m_LeftMargin);
 
    return r;
 } //fullCategoryRect
 
+///Draw the category (and the first child)
 void SortedTreeDelegate::paint(QPainter* painter, const QStyleOptionViewItem& \
option, const QModelIndex& index) const  {
    Q_ASSERT(index.isValid());
@@ -133,8 +137,8 @@ void SortedTreeDelegate::paint(QPainter* painter, const \
QStyleOptionViewItem& op  if (index.isValid()) {
       QWidget* widget = m_tree->indexWidget(index);
       if (widget) {
-         widget->setMinimumSize((m_tree->viewport()->width() - 7/*left margin*/ - \
                7/*right margin*/)-7/*left margin*/,10);
-         widget->setMaximumSize((m_tree->viewport()->width() - 7/*left margin*/ - \
7/*right margin*/)-7/*left margin*/,99999); +         \
widget->setMinimumSize((m_tree->viewport()->width() - m_LeftMargin - \
m_RightMargin)-m_LeftMargin,10); +         \
widget->setMaximumSize((m_tree->viewport()->width() - m_LeftMargin - \
m_RightMargin)-m_LeftMargin,99999);  }
    }
    
@@ -388,13 +392,14 @@ int SortedTreeDelegate::categoryHeight(const QModelIndex \
&index, const QStyleOpt  return fontMetrics.height() + 2 + 12 /* vertical spacing */;
 } //categoryHeight
 
+///Set the delagate that are categorized
 void SortedTreeDelegate::setChildDelegate(QStyledItemDelegate* childDelegate)
 {
    m_pChildDelegate = childDelegate;
 }
 
+///Set the categorized delegate own childs
 void SortedTreeDelegate::setChildChildDelegate(QStyledItemDelegate* childDelegate)
 {
    m_pChildChildDelegate = childDelegate;
 }
-
diff --git a/src/delegates/categorizeddelegate.h \
b/src/delegates/categorizeddelegate.h index 869f615..e65bb47 100644
--- a/src/delegates/categorizeddelegate.h
+++ b/src/delegates/categorizeddelegate.h
@@ -15,34 +15,42 @@
  *   You should have received a copy of the GNU General Public License      *
  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
  ***************************************************************************/
-#ifndef SORTEDTREEDELEGATE_H
-#define SORTEDTREEDELEGATE_H
+#ifndef SORTED_TREE_DELEGATE_H
+#define SORTED_TREE_DELEGATE_H
 
 #include <QtGui/QStyledItemDelegate>
 
 class QTreeView;
 
+///SortedTreeDelegate: A categorized tree delegate
 class SortedTreeDelegate : public QStyledItemDelegate
 {
-  public:
-   SortedTreeDelegate(QTreeView* widget);
+public:
+   //Constructor
+   explicit SortedTreeDelegate(QTreeView* widget);
    virtual ~SortedTreeDelegate();
 
-   QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) \
                const;
-   QRect fullCategoryRect(const QStyleOptionViewItem& option, const QModelIndex& \
index) const; +   //Reimplemented methods
+   virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& \
index) const;  virtual void paint(QPainter* painter, const QStyleOptionViewItem& \
option, const QModelIndex& index) const; +
+   //Setters
    void setChildDelegate(QStyledItemDelegate* childDelegate);
    void setChildChildDelegate(QStyledItemDelegate* childDelegate);
 
-  private:
-    void drawCategory(const QModelIndex &index, int sortRole, const QStyleOption \
                &option, QPainter *painter) const;
-    int categoryHeight(const QModelIndex &index, const QStyleOption &option) const;
-   QTreeView* m_tree;
-   QSize m_SH;
-   int m_LeftMargin;
-   int m_RightMargin;
-   QStyledItemDelegate* m_pChildDelegate;
+private:
+   //Helpers
+   QRect fullCategoryRect(const QStyleOptionViewItem& option, const QModelIndex& \
index) const; +   void drawCategory(const QModelIndex &index, int sortRole, const \
QStyleOption &option, QPainter *painter) const; +   int categoryHeight(const \
QModelIndex &index, const QStyleOption &option) const; +
+   //Attributes
+   QTreeView* m_tree       ;
+   QSize      m_SH         ;
+   const int  m_LeftMargin ;
+   const int  m_RightMargin;
+   QStyledItemDelegate* m_pChildDelegate     ;
    QStyledItemDelegate* m_pChildChildDelegate;
 };
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/delegates/conferencedelegate.cpp \
b/src/delegates/conferencedelegate.cpp index 753658f..93ddce9 100644
--- a/src/delegates/conferencedelegate.cpp
+++ b/src/delegates/conferencedelegate.cpp
@@ -25,10 +25,10 @@
 #include <QtGui/QGraphicsEffect>
 #include <QtGui/QGraphicsOpacityEffect>
 #include <QtGui/QApplication>
-#include <QtGui/QLineEdit>
 
 //KDE
 #include <KStandardDirs>
+#include <KLineEdit>
 
 //SFLPhone
 #include "../widgets/categorizedtreeview.h"
@@ -38,7 +38,7 @@
 ///Constructor
 ConferenceDelegate::ConferenceDelegate(CategorizedTreeView* widget,QPalette pal)
       : QStyledItemDelegate(widget) , m_tree(widget) , m_Pal(pal),
-      m_LeftMargin(7),m_RightMargin(7)
+      m_LeftMargin(7),m_RightMargin(7),m_pCallDelegate(nullptr)
 {
 }
 
@@ -119,7 +119,7 @@ void ConferenceDelegate::paint(QPainter* painter, const \
QStyleOptionViewItem& op  opt.rect = fullCategoryRect(option, index);
       drawCategory(index, 0, opt, painter,&m_Pal);
 
-      //Draw the conference icon and infos
+      //Draw the conference icon and info
       static const QPixmap* pxm = nullptr;
       if (!pxm) //Static
          pxm = new QPixmap(KStandardDirs::locate("data","sflphone-client-kde/conf-small.png"));
 @@ -143,7 +143,6 @@ void ConferenceDelegate::paint(QPainter* painter, const \
QStyleOptionViewItem& op  baseColor.setAlpha(150);
       painter->setPen(baseColor);
       baseColor.setAlpha(255);
-      //painter->drawText(opt.rect.x()+opt.rect.width()-40,opt.rect.y()+font.pointSize()+8,index.data(Call::Role::Length).toString());
  static QFontMetrics* fm = nullptr;
       if (!fm) {
          fm = new QFontMetrics(painter->font());
@@ -200,11 +199,7 @@ void ConferenceDelegate::paint(QPainter* painter, const \
QStyleOptionViewItem& op  }
 } //paint
 
-void ConferenceDelegate::drawCategory(const QModelIndex&  index   ,
-                                 int                 sortRole,
-                                 const QStyleOption& option  ,
-                                 QPainter*           painter ,
-                                 const QPalette* pal) const
+void ConferenceDelegate::drawCategory(const QModelIndex& index, int sortRole, const \
QStyleOption& option, QPainter* painter, const QPalette* pal) const  {
    Q_UNUSED( sortRole )
    Q_UNUSED( index    )
@@ -419,6 +414,7 @@ int ConferenceDelegate::categoryHeight(const QModelIndex &index, \
const QStyleOpt  return fontMetrics.height() + 2 + 16 /* vertical spacing */;
 }
 
+///Draw the delegate when it is being dragged
 QPixmap ConferenceDelegate::getDragPixmap(CategorizedTreeView* parent, const \
QModelIndex& index)  {
    QStyleOptionViewItemV4 option;
@@ -454,10 +450,11 @@ QPixmap ConferenceDelegate::getDragPixmap(CategorizedTreeView* \
parent, const QMo  return pixmap;
 }
 
+///Create an editor widget
 QWidget* ConferenceDelegate::createEditor(QWidget* parent, const \
QStyleOptionViewItem& option, const QModelIndex& index ) const  {
    Q_UNUSED(option)
-   QLineEdit* ed = new QLineEdit(parent);
+   KLineEdit* ed = new KLineEdit(parent);
    ed->setStyleSheet(QString("background-color:transparent;border:0px;color:white;font-weight:bold;padding-left:%1").arg(option.rect.height()));
  ed->setAutoFillBackground(false);
    ed->setProperty("call",index.data(Call::Role::Object));
@@ -467,18 +464,20 @@ QWidget* ConferenceDelegate::createEditor(QWidget* parent, \
const QStyleOptionVie  return ed;
 }
 
-void ConferenceDelegate::setEditorData ( QWidget * editor, const QModelIndex & index \
) const +///Update line edit text when in dialing mode
+void ConferenceDelegate::setEditorData(QWidget * editor, const QModelIndex & index ) \
const  {
-   QLineEdit* ed = dynamic_cast<QLineEdit*>(editor);
+   KLineEdit* ed = dynamic_cast<KLineEdit*>(editor);
    if (ed) {
       ed->setText(index.data(Qt::EditRole).toString());
       ed->deselect();
    }
 }
 
-void ConferenceDelegate::setModelData (QWidget * editor, QAbstractItemModel * model, \
const QModelIndex & index ) const +///Update call PhoneNumber when leaving edit mode
+void ConferenceDelegate::setModelData(QWidget * editor, QAbstractItemModel * model, \
const QModelIndex & index ) const  {
-   QLineEdit* ed = qobject_cast<QLineEdit*>(editor);
+   KLineEdit* ed = qobject_cast<KLineEdit*>(editor);
    if (index.data(Call::Role::CallState) != static_cast<int>(Call::State::DIALING)) \
{  emit ((ConferenceDelegate*)(this))->closeEditor(editor,NoHint);
    }
@@ -487,12 +486,12 @@ void ConferenceDelegate::setModelData (QWidget * editor, \
QAbstractItemModel * mo  model->setData(index,ed->text(),Qt::EditRole);
 }
 
-///Intercept QLineEdit show() call, to deselect the text (as it is selected \
automagically) +///Intercept KLineEdit show() call, to deselect the text (as it is \
selected automagically)  bool ConferenceDelegate::eventFilter(QObject *obj, QEvent \
*event)  {
    Q_UNUSED(obj)
    if (event->type() == QEvent::Show) {
-      QLineEdit* ed = qobject_cast<QLineEdit*>(obj);
+      KLineEdit* ed = qobject_cast<KLineEdit*>(obj);
       if (ed)
          ed->deselect();
    }
@@ -502,7 +501,7 @@ bool ConferenceDelegate::eventFilter(QObject *obj, QEvent *event)
 ///Update the model text as soon as 
 void ConferenceDelegate::slotTextChanged(const QString& text)
 {
-   QLineEdit* ed = qobject_cast<QLineEdit*>(QObject::sender());
+   KLineEdit* ed = qobject_cast<KLineEdit*>(QObject::sender());
    if (ed) {
       ed->deselect();
       QObject* obj= qvariant_cast<Call*>(ed->property("call"));
@@ -522,4 +521,4 @@ void ConferenceDelegate::slotTextChanged(const QString& text)
    else {
       emit closeEditor(ed);
    }
-}
\ No newline at end of file
+} //slotTextChanged
diff --git a/src/delegates/conferencedelegate.h b/src/delegates/conferencedelegate.h
index 81c16c6..535f721 100644
--- a/src/delegates/conferencedelegate.h
+++ b/src/delegates/conferencedelegate.h
@@ -28,15 +28,18 @@ class ConferenceDelegate : public QStyledItemDelegate
 {
    Q_OBJECT
 public:
-   ConferenceDelegate(CategorizedTreeView* widget,QPalette pal);
-   QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) \
                const;
-   QRect fullCategoryRect(const QStyleOptionViewItem& option, const QModelIndex& \
                index) const;
-   virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const \
QModelIndex& index) const; +   explicit ConferenceDelegate(CategorizedTreeView* \
widget,QPalette pal); +
+   //Setters
    void setCallDelegate(QStyledItemDelegate* delegate) {
       m_pCallDelegate = delegate;
    }
 
    static QPixmap getDragPixmap(CategorizedTreeView* parent, const QModelIndex& \
index); +
+   //Reimplemented methods
+   virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const \
QModelIndex& index) const; +   virtual QSize sizeHint(const QStyleOptionViewItem& \
option, const QModelIndex& index) const;  virtual QWidget * createEditor(QWidget* \
parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const;  \
virtual void setEditorData ( QWidget * editor, const QModelIndex & index ) const;  \
virtual void setModelData ( QWidget * editor, QAbstractItemModel * model, const \
QModelIndex & index ) const; @@ -52,9 +55,11 @@ private:
    QPalette       m_Pal             ;
    QStyledItemDelegate* m_pCallDelegate;
 
+   //Helpers
    void drawCategory(const QModelIndex &index, int sortRole, const QStyleOption \
&option, QPainter *painter,const QPalette* pal = nullptr) const;  int \
categoryHeight(const QModelIndex &index, const QStyleOption &option,const QPalette* \
pal = nullptr) const;  void drawBoxBottom(const QModelIndex &index, int sortRole, \
const QStyleOption &option, QPainter *painter,const QPalette* pal = nullptr) const; + \
QRect fullCategoryRect(const QStyleOptionViewItem& option, const QModelIndex& index) \
const;  
 private Q_SLOTS:
    void slotTextChanged(const QString& text);
diff --git a/src/delegates/contactdelegate.cpp b/src/delegates/contactdelegate.cpp
index 6c6bb18..30a5785 100644
--- a/src/delegates/contactdelegate.cpp
+++ b/src/delegates/contactdelegate.cpp
@@ -30,7 +30,7 @@
 #include <KIcon>
 
 #include <lib/contact.h>
-#include <lib/contactbackend.h>
+#include <lib/abstractcontactbackend.h>
 #include "delegatedropoverlay.h"
 
 ContactDelegate::ContactDelegate(QObject* parent) : \
QStyledItemDelegate(parent),m_pDelegatedropoverlay(nullptr) @@ -103,7 +103,7 @@ void \
ContactDelegate::paint(QPainter* painter, const QStyleOptionViewItem& optio  }
 
    //BEGIN overlay path
-   if (index.data(ContactBackend::Role::DropState).toInt() != 0) {
+   if (index.data(AbstractContactBackend::Role::DropState).toInt() != 0) {
       if (!m_pDelegatedropoverlay) {
          ((ContactDelegate*)this)->m_pDelegatedropoverlay = new \
DelegateDropOverlay((QObject*)this);  static QMap<QString,QImage*> contactMap;
diff --git a/src/delegates/contactdelegate.h b/src/delegates/contactdelegate.h
index e333e45..d65b609 100644
--- a/src/delegates/contactdelegate.h
+++ b/src/delegates/contactdelegate.h
@@ -27,7 +27,7 @@ class DelegateDropOverlay;
 class ContactDelegate : public QStyledItemDelegate
 {
 public:
-   ContactDelegate(QObject* parent = nullptr);
+   explicit ContactDelegate(QObject* parent = nullptr);
 
    QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) \
const;  
diff --git a/src/delegates/delegatedropoverlay.cpp \
b/src/delegates/delegatedropoverlay.cpp index 35b5fb9..3db0856 100644
--- a/src/delegates/delegatedropoverlay.cpp
+++ b/src/delegates/delegatedropoverlay.cpp
@@ -27,9 +27,7 @@
 #include <QMimeData>
 #include <QtGui/QApplication>
 #include "lib/call.h"
-
-
-#include <lib/contactbackend.h>
+#include <lib/abstractcontactbackend.h>
 
 ///Constructor
 DelegateDropOverlay::DelegateDropOverlay(QObject* parent):QObject(parent),
@@ -54,7 +52,7 @@ void DelegateDropOverlay::paintEvent(QPainter* painter, const \
QStyleOptionViewIt  {
    if (!m_lpButtons)
       return;
-   int step = index.data(ContactBackend::Role::DropState).toInt();
+   int step = index.data(AbstractContactBackend::Role::DropState).toInt();
    if ((step == 1 || step == -1) && m_lActiveIndexes.indexOf(index) == -1) {
       m_lActiveIndexes << index;
       //Create tge timer
@@ -99,13 +97,13 @@ void DelegateDropOverlay::paintEvent(QPainter* painter, const \
QStyleOptionViewIt  ///Step by step animation
 void DelegateDropOverlay::changeVisibility()
 {
-   foreach(QModelIndex idx, m_lActiveIndexes) {
-      int step = idx.data(ContactBackend::Role::DropState).toInt();
+   foreach(const QModelIndex& idx, m_lActiveIndexes) {
+      int step = idx.data(AbstractContactBackend::Role::DropState).toInt();
       //Remove items from the loop if there is no animation
       if (step >= 15 || step <= -15) {
          m_lActiveIndexes.removeAll(idx);
          if (step <= -15) //Hide the overlay
-            ((QAbstractItemModel*)idx.model())->setData(idx,QVariant((int)0),ContactBackend::Role::DropState);
 +            ((QAbstractItemModel*)idx.model())->setData(idx,QVariant((int)0),AbstractContactBackend::Role::DropState);
  }
       else {
          //Update opacity
@@ -114,7 +112,7 @@ void DelegateDropOverlay::changeVisibility()
          else if (step == -1)
             setHoverState(false);
          step+=(step>0)?1:-1;
-         ((QAbstractItemModel*)idx.model())->setData(idx,QVariant((int)step),ContactBackend::Role::DropState);
 +         ((QAbstractItemModel*)idx.model())->setData(idx,QVariant((int)step),AbstractContactBackend::Role::DropState);
  }
    }
    //Stop loop if no animations are running
diff --git a/src/delegates/delegatedropoverlay.h \
b/src/delegates/delegatedropoverlay.h index 9e08188..dbbe287 100644
--- a/src/delegates/delegatedropoverlay.h
+++ b/src/delegates/delegatedropoverlay.h
@@ -54,4 +54,5 @@ private:
 private Q_SLOTS:
    void changeVisibility();
 };
-#endif
\ No newline at end of file
+
+#endif
diff --git a/src/delegates/historydelegate.h b/src/delegates/historydelegate.h
index 7fea0a8..439c54c 100644
--- a/src/delegates/historydelegate.h
+++ b/src/delegates/historydelegate.h
@@ -29,7 +29,7 @@ class HistoryDelegate : public QStyledItemDelegate
 {
    Q_OBJECT
 public:
-   HistoryDelegate(QTreeView* parent = nullptr);
+   explicit HistoryDelegate(QTreeView* parent = nullptr);
 
    QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) \
const;  
diff --git a/src/delegates/phonenumberdelegate.h \
b/src/delegates/phonenumberdelegate.h index 72af313..439d5e1 100644
--- a/src/delegates/phonenumberdelegate.h
+++ b/src/delegates/phonenumberdelegate.h
@@ -23,12 +23,12 @@
 class PhoneNumberDelegate : public QStyledItemDelegate
 {
 public:
-   PhoneNumberDelegate(QObject* parent = nullptr);
-
-   QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) \
const; +   explicit PhoneNumberDelegate(QObject* parent = nullptr);
 
+   //Reimplemented methods
+   virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& \
index) const;  virtual void paint(QPainter* painter, const QStyleOptionViewItem& \
option, const QModelIndex& index) const;  private:
 };
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/klib/CMakeLists.txt b/src/klib/CMakeLists.txt
index 078e5e4..f578e46 100644
--- a/src/klib/CMakeLists.txt
+++ b/src/klib/CMakeLists.txt
@@ -30,14 +30,13 @@ INCLUDE_DIRECTORIES ( ${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
 set( ksflphone_LIB_SRCS
    helperfunctions.cpp
    akonadibackend.cpp
-#    sortabledockcommon.cpp
    configurationskeleton.cpp
    tipmanager.cpp
    tip.cpp
    tipanimationwrapper.cpp
    macromodel.cpp
-   contactproxymodel.cpp
    bookmarkmodel.cpp
+   macro.cpp
 )
 
 KDE4_ADD_KCFG_FILES(ksflphone_LIB_SRCS kcfg_settings.kcfgc)
@@ -62,6 +61,7 @@ set( ksflphone_LIB_HDRS
   helperfunctions.h
 #   sortabledockcommon.h
   macromodel.h
+  macro.h
 )
 
 INSTALL(FILES sflphone-client-kde.kcfg DESTINATION ${KCFG_INSTALL_DIR})
diff --git a/src/klib/akonadibackend.cpp b/src/klib/akonadibackend.cpp
index 153065f..2f40a11 100644
--- a/src/klib/akonadibackend.cpp
+++ b/src/klib/akonadibackend.cpp
@@ -53,7 +53,7 @@
 AkonadiBackend*  AkonadiBackend::m_pInstance = nullptr;
 
 ///Constructor
-AkonadiBackend::AkonadiBackend(QObject* parent) : ContactBackend(parent)
+AkonadiBackend::AkonadiBackend(QObject* parent) : AbstractContactBackend(parent)
 {
    m_pSession = new Akonadi::Session( "SFLPhone::instance" );
 
@@ -79,7 +79,7 @@ AkonadiBackend::~AkonadiBackend()
  ****************************************************************************/
 
 ///Singleton
-ContactBackend* AkonadiBackend::getInstance()
+AbstractContactBackend* AkonadiBackend::getInstance()
 {
    if (m_pInstance == nullptr) {
       m_pInstance = new AkonadiBackend(0);
@@ -105,7 +105,8 @@ Contact* AkonadiBackend::getContactByPhone(const QString& \
phoneNumber,bool resol  }
    if (!a)
       a = AccountList::getInstance()->getDefaultAccount();
-   else if (number.indexOf('@') == -1 && a)
+
+   if (number.indexOf('@') == -1 && a)
       return m_ContactByPhone[number+'@'+a->getAccountHostname()];
 
    //Use default resolve account to trim hostname away from the number
@@ -137,6 +138,7 @@ Contact* AkonadiBackend::getContactByUid(const QString& uid)
    return m_ContactByUid[uid];
 }
 
+///Return contact list
 const ContactList& AkonadiBackend::getContactList() const
 {
    return m_pContacts;
@@ -149,6 +151,7 @@ const ContactList& AkonadiBackend::getContactList() const
  *                                                                           *
  ****************************************************************************/
 
+///Convert string to akonadi KABC::PhoneNumber
 KABC::PhoneNumber::Type AkonadiBackend::nameToType(const QString& name)
 {
    if      (name == "Home"   ) return KABC::PhoneNumber::Home ;
diff --git a/src/klib/akonadibackend.h b/src/klib/akonadibackend.h
index 793d3cd..c867121 100644
--- a/src/klib/akonadibackend.h
+++ b/src/klib/akonadibackend.h
@@ -20,7 +20,7 @@
 #ifndef AKONADI_BACKEND_H
 #define AKONADI_BACKEND_H
 
-#include "../lib/contactbackend.h"
+#include "../lib/abstractcontactbackend.h"
 #include "../lib/typedefs.h"
 #include <akonadi/collectionmodel.h>
 
@@ -44,16 +44,16 @@ namespace Akonadi {
 class Contact;
 
 ///AkonadiBackend: Implement a backend for Akonadi
-class LIB_EXPORT AkonadiBackend : public ContactBackend {
+class LIB_EXPORT AkonadiBackend : public AbstractContactBackend {
    Q_OBJECT
 public:
-   static   ContactBackend* getInstance();
+   static   AbstractContactBackend* getInstance();
    Contact* getContactByPhone ( const QString& phoneNumber ,bool resolveDNS = false, \
Account* a=nullptr);  Contact* getContactByUid   ( const QString& uid                 \
);  void     editContact       ( Contact*       contact , QWidget* parent = 0         \
);  void     addNewContact     ( Contact*       contact , QWidget* parent = 0         \
);  virtual void addPhoneNumber( Contact*       contact , QString  number, QString \
                type                 );
-   
+
    virtual void     editContact   ( Contact*   contact                               \
);  virtual void     addNewContact ( Contact*   contact                               \
);  virtual ~AkonadiBackend        (                                                  \
                );
diff --git a/src/klib/bookmarkmodel.cpp b/src/klib/bookmarkmodel.cpp
index 1fb26db..f5360a8 100644
--- a/src/klib/bookmarkmodel.cpp
+++ b/src/klib/bookmarkmodel.cpp
@@ -26,6 +26,7 @@
 
 BookmarkModel* BookmarkModel::m_pSelf = nullptr;
 
+//Model item/index
 class NumberTreeBackend : public HistoryTreeBackend, public QObject
 {
    friend class BookmarkModel;
@@ -38,6 +39,20 @@ class NumberTreeBackend : public HistoryTreeBackend, public \
QObject  bool m_IsMostPopular;
 };
 
+BookmarkModel::BookmarkModel(QObject* parent) : QAbstractItemModel(parent){
+      setObjectName("BookmarkModel");
+      reloadCategories();
+      m_lMimes << MIME_PLAIN_TEXT << MIME_PHONENUMBER;
+   }
+
+BookmarkModel* BookmarkModel::getInstance()
+{
+   if (!m_pSelf)
+      m_pSelf = new BookmarkModel(nullptr);
+   return m_pSelf;
+}
+
+///Reload bookmark cateogries
 void BookmarkModel::reloadCategories()
 {
    beginResetModel();
@@ -64,7 +79,7 @@ void BookmarkModel::reloadCategories()
       }
    }
 
-   foreach(QString bookmark, ConfigurationSkeleton::bookmarkList()) {
+   foreach(const QString& bookmark, ConfigurationSkeleton::bookmarkList()) {
       NumberTreeBackend* bm = new NumberTreeBackend(bookmark);
       QString val = category(bm);
       if (!m_hCategories[val]) {
@@ -82,8 +97,9 @@ void BookmarkModel::reloadCategories()
    endResetModel();
    emit layoutChanged();
    emit dataChanged(index(0,0),index(rowCount()-1,0));
-}
+} //reloadCategories
 
+//Do nothing
 bool BookmarkModel::setData( const QModelIndex& index, const QVariant &value, int \
role)  {
    Q_UNUSED(index)
@@ -92,6 +108,7 @@ bool BookmarkModel::setData( const QModelIndex& index, const \
QVariant &value, in  return false;
 }
 
+///Get bookmark model data HistoryTreeBackend::Type and Call::Role
 QVariant BookmarkModel::data( const QModelIndex& index, int role) const
 {
    if (!index.isValid())
@@ -115,8 +132,9 @@ QVariant BookmarkModel::data( const QModelIndex& index, int role) \
const  break;
    };
    return QVariant();
-}
+} //Data
 
+///Get header data
 QVariant BookmarkModel::headerData(int section, Qt::Orientation orientation, int \
role) const  {
    Q_UNUSED(section)
@@ -125,6 +143,8 @@ QVariant BookmarkModel::headerData(int section, Qt::Orientation \
orientation, int  return QVariant();
 }
 
+
+///Get the number of child of "parent"
 int BookmarkModel::rowCount( const QModelIndex& parent ) const
 {
    if (!parent.isValid() || !parent.internalPointer())
@@ -142,18 +162,20 @@ Qt::ItemFlags BookmarkModel::flags( const QModelIndex& index ) \
const  return Qt::ItemIsEnabled | Qt::ItemIsSelectable | \
(index.parent().isValid()?Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled:Qt::ItemIsEnabled);
  }
 
+///There is only 1 column
 int BookmarkModel::columnCount ( const QModelIndex& parent) const
 {
    Q_UNUSED(parent)
    return 1;
 }
 
+///Get the bookmark parent
 QModelIndex BookmarkModel::parent( const QModelIndex& index) const
 {
    if (!index.isValid() || !index.internalPointer()) {
       return QModelIndex();
    }
-   HistoryTreeBackend* modelItem = \
static_cast<HistoryTreeBackend*>(index.internalPointer()); +   const \
HistoryTreeBackend* modelItem = \
static_cast<HistoryTreeBackend*>(index.internalPointer());  if (modelItem->type3() == \
                HistoryTreeBackend::Type::BOOKMARK) {
       QString val = category(((NumberTreeBackend*)(index.internalPointer())));
       if (((NumberTreeBackend*)modelItem)->m_IsMostPopular)
@@ -163,24 +185,25 @@ QModelIndex BookmarkModel::parent( const QModelIndex& index) \
const  else BookmarkModel::index(0,0);
    }
    return QModelIndex();
-}
+} //parent
 
-QModelIndex BookmarkModel::index( int row, int column, const QModelIndex& parent) \
const +///Get the index
+QModelIndex BookmarkModel::index(int row, int column, const QModelIndex& parent) \
const  {
    if (parent.isValid())
       return createIndex(row,column,m_lCategoryCounter[parent.row()]->m_lChilds[row]);
  else {
       return createIndex(row,column,m_lCategoryCounter[row]);
    }
-   return QModelIndex();
 }
 
-
+///Get bookmarks mime types
 QStringList BookmarkModel::mimeTypes() const
 {
    return m_lMimes;
 }
 
+///Generate mime data
 QMimeData* BookmarkModel::mimeData(const QModelIndexList &indexes) const
 {
    QMimeData *mimeData = new QMimeData();
@@ -193,8 +216,9 @@ QMimeData* BookmarkModel::mimeData(const QModelIndexList \
&indexes) const  }
    }
    return mimeData;
-}
+} //mimeData
 
+///Get call info TODO use Call:: one
 QVariant BookmarkModel::commonCallInfo(NumberTreeBackend* number, int role) const
 {
    if (!number)
@@ -237,8 +261,9 @@ QVariant BookmarkModel::commonCallInfo(NumberTreeBackend* number, \
int role) cons  break;
    }
    return cat;
-}
+} //commonCallInfo
 
+///Get category
 QString BookmarkModel::category(NumberTreeBackend* number) const
 {
    QString cat = commonCallInfo(number).toString();
diff --git a/src/klib/bookmarkmodel.h b/src/klib/bookmarkmodel.h
index 4498802..9a30315 100644
--- a/src/klib/bookmarkmodel.h
+++ b/src/klib/bookmarkmodel.h
@@ -33,12 +33,10 @@ class LIB_EXPORT BookmarkModel :  public QAbstractItemModel
 {
    Q_OBJECT
 public:
-   static BookmarkModel* getInstance() {
-      if (!m_pSelf)
-         m_pSelf = new BookmarkModel(nullptr);
-      return m_pSelf;
-   }
+   //Singleton
+   static BookmarkModel* getInstance();
 
+   //Setters
    void setRole(int role);
    void setShowAll(bool showAll);
 
@@ -55,37 +53,38 @@ public:
    virtual QMimeData*    mimeData    ( const QModelIndexList &indexes                \
) const;  
 private:
-   BookmarkModel(QObject* parent) : QAbstractItemModel(parent){
-      setObjectName("BookmarkModel");
-      reloadCategories();
-      m_lMimes << MIME_PLAIN_TEXT << MIME_PHONENUMBER;
-   }
+   //Private constructor
+   explicit BookmarkModel(QObject* parent);
    virtual ~BookmarkModel() {}
+      
+   ///Top level bookmark item
    class TopLevelItem : public HistoryTreeBackend, public QObject {
-   friend class BookmarkModel;
-   public:
-      virtual QObject* getSelf() {return this;}
-   private:
-      TopLevelItem(QString name) : \
                HistoryTreeBackend(HistoryTreeBackend::TOP_LEVEL),QObject(nullptr),m_Name(name) \
                {}
-      QList<NumberTreeBackend*> m_lChilds;
-      QString m_Name;
+      friend class BookmarkModel;
+      public:
+         virtual QObject* getSelf() {return this;}
+      private:
+         explicit TopLevelItem(QString name) : \
HistoryTreeBackend(HistoryTreeBackend::TOP_LEVEL),QObject(nullptr),m_Name(name) {} +  \
QList<NumberTreeBackend*> m_lChilds; +         QString m_Name;
    };
-   ContactBackend* m_pModel;
-   QList<TopLevelItem*> m_lCategoryCounter;
-   QHash<QString,TopLevelItem*> m_hCategories;
-   const static char* m_slHistoryConstStr[25];
-   bool m_isContactDateInit;
-   QHash<Contact*, QDateTime> m_hContactByDate;
-   QStringList m_lMimes;
-   
+
+   //Attributes
+   ContactBackend*              m_pModel               ;
+   QList<TopLevelItem*>         m_lCategoryCounter     ;
+   QHash<QString,TopLevelItem*> m_hCategories          ;
+   const static char*           m_slHistoryConstStr[25];
+   bool                         m_isContactDateInit    ;
+   QHash<Contact*, QDateTime>   m_hContactByDate       ;
+   QStringList                  m_lMimes               ;
+
+   //Getters
    QModelIndex getContactIndex(Contact* ct) const;
-   
+
    //Helpers
-//    QString category(Contact* ct) const;
-//    QHash<Contact*, QDateTime> /*getContactListByTime*/() const;
    QVariant commonCallInfo(NumberTreeBackend* call, int role = Qt::DisplayRole) \
const;  QString category(NumberTreeBackend* number) const;
-   
+
+   //Singleton
    static BookmarkModel* m_pSelf;
 
 public Q_SLOTS:
diff --git a/src/klib/macro.cpp b/src/klib/macro.cpp
new file mode 100644
index 0000000..23fdbe4
--- /dev/null
+++ b/src/klib/macro.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+ *   Copyright (C) 2013 by Savoir-Faire Linux                               *
+ *   Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
+ *                                                                          *
+ *   This library is free software; you can redistribute it and/or          *
+ *   modify it under the terms of the GNU Lesser General Public             *
+ *   License as published by the Free Software Foundation; either           *
+ *   version 2.1 of the License, or (at your option) any later version.     *
+ *                                                                          *
+ *   This library is distributed in the hope that it will be useful,        *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      *
+ *   Lesser General Public License for more details.                        *
+ *                                                                          *
+ *   You should have received a copy of the GNU General Public License      *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
+ ***************************************************************************/
+#include "macro.h"
+
+//Qt
+#include <QtCore/QTimer>
+
+//KDE
+#include <KAction>
+#include <KLocale>
+
+//SFLPhone
+#include "../lib/callmanager_interface_singleton.h"
+
+Macro::Macro(QObject* parent) : \
QObject(parent),m_Position(0),m_Delay(0),m_pCat(nullptr),m_pPointer(nullptr), \
+m_Action(nullptr),m_pModel(nullptr) +{
+}
+
+Macro::Macro(const Macro* macro) : 
+QObject(0)                         , m_Position(macro->m_Position), \
m_Name(macro->m_Name)        , +m_Description(macro->m_Description), \
m_Sequence(macro->m_Sequence), m_Escaped(macro->m_Escaped)  , +m_Id(macro->m_Id)      \
, m_Delay(macro->m_Delay)      , m_Category(macro->m_Category), \
+m_Action(macro->m_Action)          , m_pCat(macro->m_pCat)        , \
m_pModel(macro->m_pModel)    , +m_pPointer(macro->m_pPointer)
+{}
+
+void Macro::execute() {
+   m_Escaped = m_Sequence;
+   while (m_Escaped.indexOf("\\n") != -1) {
+      m_Escaped = m_Escaped.replace("\\n","\n");
+   }
+   nextStep();
+}
+
+void Macro::nextStep()
+{
+   if (m_Position < m_Escaped.size()) {
+      if (!MacroModel::getInstance()->m_lListeners.size())
+         Q_NOREPLY CallManagerInterfaceSingleton::getInstance().playDTMF(QString(m_Escaped[m_Position]));
 +      else {
+         foreach(MacroListener* l,MacroModel::getInstance()->m_lListeners) {
+            l->addDTMF(QString(m_Escaped[m_Position]));
+         }
+      }
+      m_Position++;
+      QTimer::singleShot(m_Delay?m_Delay:100,this,SLOT(nextStep()));
+   }
+   else {
+      m_Position = 0;
+   }
+}
+
+//Add a new macro if the current one can be saved
+Macro* MacroModel::newMacro(const QString& id)
+{
+   m_pCurrentMacro = new Macro();
+   KAction* newAction = new KAction(this);
+   m_pCurrentMacro->m_Action = newAction;
+   m_pCurrentMacro->m_Name = i18nc("New macro","New");
+   m_pCurrentMacro->m_Category = i18nc("Other category","Other");
+   m_pCurrentMacro->m_pModel = this;
+   if (id.isEmpty()) {
+      time_t curTime;
+      ::time(&curTime);
+      m_pCurrentMacro->m_Id = QString::number(curTime);
+      while (m_hMacros[m_pCurrentMacro->m_Id]) {
+         m_pCurrentMacro->m_Id += '1';
+      }
+   }
+   m_hMacros[m_pCurrentMacro->m_Id] = m_pCurrentMacro;
+   updateTreeModel(m_pCurrentMacro);
+   connect(m_pCurrentMacro,SIGNAL(changed(Macro*)),this,SLOT(changed(Macro*)));
+   emit dataChanged(index(0,0),index(m_lCategories.size()-1,0));
+   emit layoutChanged ();
+   emit selectMacro(m_pCurrentMacro);
+   newAction->setText(m_pCurrentMacro->m_Name);
+   newAction->setIcon(KIcon("view-form-action"));
+   newAction->setObjectName("action_macro"+m_pCurrentMacro->m_Id);
+   connect(newAction, SIGNAL(triggered()), m_pCurrentMacro , SLOT(execute()) );
+   emit addAction(newAction);
+   return m_pCurrentMacro;
+}
+
+Macro* MacroModel::getCurrentMacro()
+{
+   return m_pCurrentMacro;
+}
+
+QModelIndex Macro::index()
+{
+   QModelIndex parent = \
m_pModel->index(m_pModel->m_lCategories.indexOf(m_pCat),0,QModelIndex()); +   return  \
m_pModel->index(m_pCat->m_lContent.indexOf(this),0,parent); +}
+
+void Macro::setName(QString value)
+{
+   m_Name = value;
+   emit changed(this);
+   m_Action->setText(m_Name);
+}
+
+void Macro::setDescription(QString value)
+{
+   m_Description = value;emit changed(this);
+}
+void Macro::setSequence(QString value)
+{
+   m_Sequence = value;emit changed(this);
+}
+
+void Macro::setEscaped(QString value)
+{
+   m_Escaped = value;emit changed(this);
+}
+
+void Macro::setId(QString value)
+{
+   m_Id = value;emit changed(this);
+}
+
+void Macro::setDelay(int value)
+{
+   m_Delay = value;emit changed(this);
+}
+
+void Macro::setCategory(QString value)
+{
+   m_Category = value;emit changed(this);
+}
+
+QString Macro::name()
+{
+   return m_Name;
+}
+
+QString Macro::description()
+{
+   return m_Description;
+}
+
+QString Macro::sequence()
+{
+   return m_Sequence;
+}
+
+QString Macro::escaped()
+{
+   return m_Escaped;
+}
+
+QString Macro::id()
+{
+   return m_Id;
+}
+
+int Macro::delay()
+{
+   return m_Delay;
+}
+
+QString  Macro::category()
+{
+   return m_Category;
+}
+
+KAction* Macro::action()
+{
+   return m_Action;
+}
diff --git a/src/widgets/tips/ringingtip.h b/src/klib/macro.h
similarity index 50%
copy from src/widgets/tips/ringingtip.h
copy to src/klib/macro.h
index dc72476..4fb49e5 100644
--- a/src/widgets/tips/ringingtip.h
+++ b/src/klib/macro.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- *   Copyright (C) 2012-2013 by Savoir-Faire Linux                          *
+ *   Copyright (C) 2013 by Savoir-Faire Linux                               *
  *   Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
  *                                                                          *
  *   This library is free software; you can redistribute it and/or          *
@@ -15,55 +15,70 @@
  *   You should have received a copy of the GNU General Public License      *
  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
  ***************************************************************************/
-#ifndef RIGGINGTIP_H
-#define RIGGINGTIP_H
+#ifndef MACRO_H
+#define MACRO_H
 
-//Base
-#include "../../klib/tip.h"
+#include <QtCore/QObject>
+#include <QtCore/QModelIndex>
+#include "../lib/typedefs.h"
 
 //Qt
-#include <QtGui/QWidget>
-#include <QtCore/QTimer>
+class KAction;
 
-class QSvgRenderer;
+//SFLPhone
+#include "macromodel.h"
 
-//Qt
-class QPainter;
-
-///A tip to be passed to the TipLoader
-class RingingTip : public Tip
-{
+class LIB_EXPORT Macro : public QObject {
    Q_OBJECT
+   friend class MacroModel; //Use factory method
+
+protected:
+   MacroModel::MacroCategory* m_pCat;
+
 public:
-   explicit RingingTip(QWidget* parent = nullptr);
-   virtual ~RingingTip();
+   Macro(const Macro* macro);
 
-   //It is not a notification, it doesn't need to be as visible
-   virtual float opacity() { return 0.5f; }
+   //Getters
+   QString  name();
+   QString  description();
+   QString  sequence();
+   QString  escaped();
+   QString  id();
+   int      delay();
+   QString  category();
+   KAction* action();
 
-protected:
-   virtual QRect getDecorationRect();
-   virtual void paintDecorations(QPainter& p, const QRect& textRect);
+   QModelIndex index();
 
+   //Setters
+   void setName(QString value);
+   void setDescription(QString value);
+   void setSequence(QString value);
+   void setEscaped(QString value);
+   void setId(QString value);
+   void setDelay(int value);
+   void setCategory(QString value);
+   
 private:
-   QTimer*       m_pTimer           ;
-   uchar         m_Counter          ;
-   QByteArray    m_phoneOriginalSVG ;
-   QByteArray    m_ring1OriginalSVG ;
-   QByteArray    m_ring2OriginalSVG ;
-   QByteArray    m_ring3OriginalSVG ;
-   QSvgRenderer* m_pPhoneR          ;
-   QSvgRenderer* m_pRing1R          ;
-   QSvgRenderer* m_pRing2R          ;
-   QSvgRenderer* m_pRing3R          ;
-   QPixmap*      m_pPhonePix        ;
-   QPixmap*      m_pRing1Pix        ;
-   QPixmap*      m_pRing2Pix        ;
-   QPixmap*      m_pRing3Pix        ;
-
+   explicit Macro(QObject* parent = nullptr);
+   int         m_Position;
+   QString     m_Name;
+   QString     m_Description;
+   QString     m_Sequence;
+   QString     m_Escaped;
+   QString     m_Id;
+   int         m_Delay;
+   QString     m_Category;
+   KAction*    m_Action;
+   MacroModel* m_pModel;
+   MacroModel::IndexPointer* m_pPointer;
+public Q_SLOTS:
+   void execute();
 private Q_SLOTS:
-   void startAnimation(bool visibility);
-   void timeout();
+   void nextStep();
+
+Q_SIGNALS:
+   void changed(Macro*);
 };
 
-#endif
+#endif
\ No newline at end of file
diff --git a/src/klib/macromodel.cpp b/src/klib/macromodel.cpp
index 707f997..ea87d6b 100644
--- a/src/klib/macromodel.cpp
+++ b/src/klib/macromodel.cpp
@@ -30,52 +30,11 @@
 //SFLPhone
 #include "../lib/callmanager_interface_singleton.h"
 #include "configurationskeleton.h"
+#include "macro.h"
 
 ///Init static attributes
 MacroModel*  MacroModel::m_pInstance = nullptr;
 
-Macro::Macro(QObject* parent) : \
                QObject(parent),m_Position(0),m_Delay(0),m_pCat(nullptr),m_pPointer(nullptr)
                
-{
-   
-}
-
-Macro::Macro(const Macro* macro) : 
-QObject(0)                         , m_Position(macro->m_Position), \
                m_Name(macro->m_Name)        ,
-m_Description(macro->m_Description), m_Sequence(macro->m_Sequence), \
                m_Escaped(macro->m_Escaped)  ,
-m_Id(macro->m_Id)                  , m_Delay(macro->m_Delay)      , \
                m_Category(macro->m_Category),
-m_Action(macro->m_Action) {}
-
-void Macro::execute() {
-   m_Escaped = m_Sequence;
-   while (m_Escaped.indexOf("\\n") != -1) {
-      m_Escaped = m_Escaped.replace("\\n","\n");
-   }
-   nextStep();
-}
-
-void Macro::nextStep()
-{
-   if (m_Position < m_Escaped.size()) {
-      if (!MacroModel::getInstance()->m_lListeners.size())
-         Q_NOREPLY CallManagerInterfaceSingleton::getInstance().playDTMF(QString(m_Escaped[m_Position]));
                
-      else {
-         foreach(MacroListener* l,MacroModel::getInstance()->m_lListeners) {
-            l->addDTMF(QString(m_Escaped[m_Position]));
-         }
-      }
-      m_Position++;
-      QTimer::singleShot(m_Delay?m_Delay:100,this,SLOT(nextStep()));
-   }
-   else {
-      m_Position = 0;
-   }
-}
-
-QModelIndex Macro::index()
-{
-   QModelIndex parent = \
                m_pModel->index(m_pModel->m_lCategories.indexOf(m_pCat),0,QModelIndex());
                
-   return  m_pModel->index(m_pCat->m_lContent.indexOf(this),0,parent);
-}
 
 MacroModel::MacroModel(QObject* parent) : \
QAbstractItemModel(parent),m_pCurrentMacro(nullptr),m_pCurrentMacroMemento(nullptr)  \
{ @@ -148,42 +107,6 @@ void MacroModel::updateTreeModel(Macro* newMacro)
    newMacro->m_pPointer = new IndexPointer(IndexType::MacroIndex,newMacro);
 }
 
-//Add a new macro if the current one can be saved
-Macro* MacroModel::newMacro(const QString& id)
-{
-   m_pCurrentMacro = new Macro();
-   KAction* newAction = new KAction(this);
-   m_pCurrentMacro->m_Action = newAction;
-   m_pCurrentMacro->m_Name = i18nc("New macro","New");
-   m_pCurrentMacro->m_Category = i18nc("Other category","Other");
-   m_pCurrentMacro->m_pModel = this;
-   if (id.isEmpty()) {
-      time_t curTime;
-      ::time(&curTime);
-      m_pCurrentMacro->m_Id = QString::number(curTime);
-      while (m_hMacros[m_pCurrentMacro->m_Id]) {
-         m_pCurrentMacro->m_Id += '1';
-      }
-   }
-   m_hMacros[m_pCurrentMacro->m_Id] = m_pCurrentMacro;
-   updateTreeModel(m_pCurrentMacro);
-   connect(m_pCurrentMacro,SIGNAL(changed(Macro*)),this,SLOT(changed(Macro*)));
-   emit dataChanged(index(0,0),index(m_lCategories.size()-1,0));
-   emit layoutChanged ();
-   emit selectMacro(m_pCurrentMacro);
-   newAction->setText(m_pCurrentMacro->m_Name);
-   newAction->setIcon(KIcon("view-form-action"));
-   newAction->setObjectName("action_macro"+m_pCurrentMacro->m_Id);
-   connect(newAction, SIGNAL(triggered()), m_pCurrentMacro , SLOT(execute()) );
-   emit addAction(newAction);
-   return m_pCurrentMacro;
-}
-
-Macro* MacroModel::getCurrentMacro()
-{
-   return m_pCurrentMacro;
-}
-
 //Remove the selected macro
 bool MacroModel::removeMacro(QModelIndex idx)
 {
@@ -204,40 +127,6 @@ void MacroModel::setCurrent(QModelIndex current,QModelIndex \
previous)  }
 }
 
-void Macro::setName(QString value)
-{
-   m_Name = value;emit changed(this);m_Action->setText(m_Name);
-}
-
-void Macro::setDescription(QString value)
-{
-   m_Description = value;emit changed(this);
-}
-void Macro::setSequence(QString value)
-{
-   m_Sequence = value;emit changed(this);
-}
-
-void Macro::setEscaped(QString value)
-{
-   m_Escaped = value;emit changed(this);
-}
-
-void Macro::setId(QString value)
-{
-   m_Id = value;emit changed(this);
-}
-
-void Macro::setDelay(int value)
-{
-   m_Delay = value;emit changed(this);
-}
-
-void Macro::setCategory(QString value)
-{
-   m_Category = value;emit changed(this);
-}
-
 void MacroModel::save()
 {
    QFile macros(KStandardDirs::locateLocal("appdata","")+"macros.txt");
@@ -386,40 +275,3 @@ void MacroModel::changed(Macro* macro)
       }
    }
 }
-
-QString Macro::name()
-{
-   return m_Name;
-}
-
-QString Macro::description()
-{
-   return m_Description;
-}
-
-QString Macro::sequence()
-{
-   return m_Sequence;
-}
-QString Macro::escaped()
-{
-   return m_Escaped;
-}
-QString Macro::id()
-{
-   return m_Id;
-}
-int Macro::delay()
-{
-   return m_Delay;
-}
-
-QString  Macro::category()
-{
-   return m_Category;
-}
-
-KAction* Macro::action()
-{
-   return m_Action;
-}
diff --git a/src/klib/macromodel.h b/src/klib/macromodel.h
index a7b011e..aa8adcd 100644
--- a/src/klib/macromodel.h
+++ b/src/klib/macromodel.h
@@ -33,6 +33,7 @@ class Macro;
 ///Interface to interpret DTMFs instead of using the daemon directly
 class LIB_EXPORT MacroListener {
 public:
+   explicit MacroListener() {}
    virtual void addDTMF(const QString& sequence) = 0;
    virtual ~MacroListener() {}
 };
@@ -120,53 +121,4 @@ Q_SIGNALS:
    void selectMacro(Macro* macro);
 };
 
-class LIB_EXPORT Macro : public QObject {
-   Q_OBJECT
-   friend class MacroModel; //Use factory method
-public:
-   Macro(const Macro* macro);
-   MacroModel::MacroCategory* m_pCat;
-   //Getters
-   QString  name();
-   QString  description();
-   QString  sequence();
-   QString  escaped();
-   QString  id();
-   int      delay();
-   QString  category();
-   KAction* action();
-
-   QModelIndex index();
-
-   //Setters
-   void setName(QString value);
-   void setDescription(QString value);
-   void setSequence(QString value);
-   void setEscaped(QString value);
-   void setId(QString value);
-   void setDelay(int value);
-   void setCategory(QString value);
-   
-private:
-   explicit Macro(QObject* parent = nullptr);
-   int         m_Position;
-   QString     m_Name;
-   QString     m_Description;
-   QString     m_Sequence;
-   QString     m_Escaped;
-   QString     m_Id;
-   int         m_Delay;
-   QString     m_Category;
-   KAction*    m_Action;
-   MacroModel* m_pModel;
-   MacroModel::IndexPointer* m_pPointer;
-public Q_SLOTS:
-   void execute();
-private Q_SLOTS:
-   void nextStep();
-
-Q_SIGNALS:
-   void changed(Macro*);
-};
-
 #endif
diff --git a/src/klib/tipanimationwrapper.cpp b/src/klib/tipanimationwrapper.cpp
index 8b9b5b0..12e6709 100644
--- a/src/klib/tipanimationwrapper.cpp
+++ b/src/klib/tipanimationwrapper.cpp
@@ -26,7 +26,7 @@
 #include "tipmanager.h"
 
 TipAnimationWrapper::TipAnimationWrapper(QObject* parent) : \
                QObject(parent),m_MaxStep(15),m_Step(0),m_pTimer(nullptr),m_TipSize(QSize(0,0)),
                
-m_pTip(nullptr),m_pCurrentTip(nullptr),m_CurrentAnimation(Tip::TipAnimation::None)
+m_pTip(nullptr),m_pCurrentTip(nullptr),m_CurrentAnimation(Tip::TipAnimation::None),m_FadeDirection(true)
  {
    connect(parent, SIGNAL(sizeChanged(QRect,bool)) , this , \
SLOT(sizeChanged(QRect,bool)) );  connect(parent, SIGNAL(currentTipChanged(Tip*)) , \
                this , SLOT(currentChanged(Tip*))    );
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index e97be71..6c79b22 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -32,7 +32,7 @@ set( qtsflphone_LIB_SRCS
   callmodel.cpp
   historymodel.cpp
   contact.cpp
-  contactbackend.cpp
+  abstractcontactbackend.cpp
   videocodecmodel.cpp
   videomodel.cpp
   videorenderer.cpp
@@ -45,6 +45,7 @@ set( qtsflphone_LIB_SRCS
   instance_interface_singleton.cpp
   video_interface_singleton.cpp
   sflphone_const.h
+  contactproxymodel.cpp
 )
 
 # Build dbus interfaces
@@ -126,7 +127,7 @@ set( qtsflphone_LIB_HDRS
   callmodel.h
   historymodel.h
   contact.h
-  contactbackend.h
+  abstractcontactbackend.h
   videocodecmodel.h
   videomodel.h
   videodevice.h
@@ -140,6 +141,7 @@ set( qtsflphone_LIB_HDRS
   sflphone_const.h
   instantmessagingmodel.h
   typedefs.h
+  contactproxymodel.h
 )
 
 install( FILES ${qtsflphone_LIB_HDRS}
diff --git a/src/lib/contactbackend.cpp b/src/lib/abstractcontactbackend.cpp
similarity index 76%
rename from src/lib/contactbackend.cpp
rename to src/lib/abstractcontactbackend.cpp
index c167ab9..48d7187 100644
--- a/src/lib/contactbackend.cpp
+++ b/src/lib/abstractcontactbackend.cpp
@@ -19,7 +19,7 @@
  ***********************************************************************************/
  
 //Parent
-#include "contactbackend.h"
+#include "abstractcontactbackend.h"
 
 //SFLPhone library
 #include "contact.h"
@@ -30,13 +30,13 @@
 #include <QtCore/QDebug>
 
 ///Constructor
-ContactBackend::ContactBackend(QObject* par) : \
QAbstractItemModel(par),m_UpdatesCounter(0) \
+AbstractContactBackend::AbstractContactBackend(QObject* par) : \
QAbstractItemModel(par),m_UpdatesCounter(0)  {
    connect(this,SIGNAL(collectionChanged()),this,SLOT(slotReloadModel()));
 }
 
 ///Destructor
-ContactBackend::~ContactBackend()
+AbstractContactBackend::~AbstractContactBackend()
 {
    if (Call::getContactBackend() == this)
       Call::setContactBackend(nullptr);
@@ -46,13 +46,13 @@ ContactBackend::~ContactBackend()
 }
 
 ///Update slot
-ContactList ContactBackend::update()
+ContactList AbstractContactBackend::update()
 {
    return update_slot();
 }
 
 ///Called when the new contacts are added
-void ContactBackend::slotReloadModel()
+void AbstractContactBackend::slotReloadModel()
 {
    reset();
    emit layoutChanged();
@@ -61,12 +61,23 @@ void ContactBackend::slotReloadModel()
 
 /*****************************************************************************
  *                                                                           *
+ *                                  Getters                                  *
+ *                                                                           *
+ ****************************************************************************/
+
+int AbstractContactBackend::getUpdateCount()
+{
+   return m_UpdatesCounter;
+}
+
+/*****************************************************************************
+ *                                                                           *
  *                                  Helpers                                  *
  *                                                                           *
  ****************************************************************************/
 
 ///Return the extension/user of an URI (<sip:12345@exemple.com>)
-QString ContactBackend::getUserFromPhone(QString phoneNumber)
+QString AbstractContactBackend::getUserFromPhone(QString phoneNumber)
 {
    if (phoneNumber.indexOf('@') != -1) {
       QString user = phoneNumber.split('@')[0];
@@ -76,7 +87,7 @@ QString ContactBackend::getUserFromPhone(QString phoneNumber)
 } //getUserFromPhone
 
 ///Return the domaine of an URI (<sip:12345@exemple.com>)
-QString ContactBackend::getHostNameFromPhone(QString phoneNumber)
+QString AbstractContactBackend::getHostNameFromPhone(QString phoneNumber)
 {
    if (phoneNumber.indexOf('@') != -1) {
       return phoneNumber.split('@')[1].left(phoneNumber.split('@')[1].size()-1);
@@ -92,7 +103,7 @@ QString ContactBackend::getHostNameFromPhone(QString phoneNumber)
  ****************************************************************************/
 
 
-bool ContactBackend::setData( const QModelIndex& idx, const QVariant &value, int \
role) +bool AbstractContactBackend::setData( const QModelIndex& idx, const QVariant \
&value, int role)  {
    Q_UNUSED(idx)
    Q_UNUSED(value)
@@ -100,7 +111,7 @@ bool ContactBackend::setData( const QModelIndex& idx, const \
QVariant &value, int  return false;
 }
 
-QVariant ContactBackend::data( const QModelIndex& idx, int role) const
+QVariant AbstractContactBackend::data( const QModelIndex& idx, int role) const
 {
    if (!idx.isValid())
       return QVariant();
@@ -113,7 +124,7 @@ QVariant ContactBackend::data( const QModelIndex& idx, int role) \
const  return QVariant();
 }
 
-QVariant ContactBackend::headerData(int section, Qt::Orientation orientation, int \
role) const +QVariant AbstractContactBackend::headerData(int section, Qt::Orientation \
orientation, int role) const  {
    Q_UNUSED(section)
    if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
@@ -121,7 +132,7 @@ QVariant ContactBackend::headerData(int section, Qt::Orientation \
orientation, in  return QVariant();
 }
 
-int ContactBackend::rowCount( const QModelIndex& par ) const
+int AbstractContactBackend::rowCount( const QModelIndex& par ) const
 {
    if (!par.isValid()) {
       return getContactList().size();
@@ -132,20 +143,20 @@ int ContactBackend::rowCount( const QModelIndex& par ) const
    return 0;
 }
 
-Qt::ItemFlags ContactBackend::flags( const QModelIndex& idx ) const
+Qt::ItemFlags AbstractContactBackend::flags( const QModelIndex& idx ) const
 {
    if (!idx.isValid())
       return 0;
    return Qt::ItemIsEnabled | \
((idx.parent().isValid())?Qt::ItemIsSelectable:Qt::ItemIsEnabled);  }
 
-int ContactBackend::columnCount ( const QModelIndex& par) const
+int AbstractContactBackend::columnCount ( const QModelIndex& par) const
 {
    Q_UNUSED(par)
    return 1;
 }
 
-QModelIndex ContactBackend::parent( const QModelIndex& idx) const
+QModelIndex AbstractContactBackend::parent( const QModelIndex& idx) const
 {
    if (!idx.isValid())
       return QModelIndex();
@@ -153,13 +164,13 @@ QModelIndex ContactBackend::parent( const QModelIndex& idx) \
const  if (modelItem && modelItem->type3() == ContactTreeBackend::Type::NUMBER) {
       int idx2 = getContactList().indexOf(((Contact::PhoneNumbers*)modelItem)->contact());
  if (idx2 != -1) {
-         return ContactBackend::index(idx2,0,QModelIndex());
+         return AbstractContactBackend::index(idx2,0,QModelIndex());
       }
    }
    return QModelIndex();
 }
 
-QModelIndex ContactBackend::index( int row, int column, const QModelIndex& par) \
const +QModelIndex AbstractContactBackend::index( int row, int column, const \
QModelIndex& par) const  {
    if (!par.isValid() && m_ContactByPhone.size() > row) {
       return createIndex(row,column,getContactList()[row]);
diff --git a/src/lib/contactbackend.h b/src/lib/abstractcontactbackend.h
similarity index 91%
rename from src/lib/contactbackend.h
rename to src/lib/abstractcontactbackend.h
index 6bd8afa..b03b60f 100644
--- a/src/lib/contactbackend.h
+++ b/src/lib/abstractcontactbackend.h
@@ -17,8 +17,8 @@
  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
  ***************************************************************************/
 
-#ifndef CONTACT_BACKEND_H
-#define CONTACT_BACKEND_H
+#ifndef ABSTRACTION_CONTACT_BACKEND_H
+#define ABSTRACTION_CONTACT_BACKEND_H
 
 #include <QObject>
 #include <QHash>
@@ -36,8 +36,8 @@ class Account;
 //Typedef
 typedef QList<Contact*> ContactList;
 
-///ContactBackend: Allow different way to handle contact without poluting the \
                library
-class LIB_EXPORT ContactBackend : public QAbstractItemModel {
+///AbstractContactBackend: Allow different way to handle contact without poluting \
the library +class LIB_EXPORT AbstractContactBackend : public QAbstractItemModel {
    Q_OBJECT
 public:
    enum Role {
@@ -52,8 +52,8 @@ public:
       DropState         = 300, //State for drag and drop
    };
    
-   explicit ContactBackend(QObject* parent = nullptr);
-   virtual ~ContactBackend();
+   explicit AbstractContactBackend(QObject* parent = nullptr);
+   virtual ~AbstractContactBackend();
 
    ///Get a contact using a phone number
    ///@param resolveDNS interpret the number as is (false) or parse it to extract \
the domain and number (true) @@ -80,10 +80,11 @@ public:
    virtual QModelIndex   parent      ( const QModelIndex& index                      \
) const;  virtual QModelIndex   index       ( int row, int column, const QModelIndex& \
parent=QModelIndex()) const;  virtual QVariant      headerData  ( int section, \
                Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
-   
-   int getUpdateCount() {return m_UpdatesCounter;}
+
+   int getUpdateCount();
+
 protected:
-   virtual ContactList update_slot       (                            ) = 0;
+   virtual ContactList update_slot() = 0;
 
    //Helper
    QString getUserFromPhone    (QString phoneNumber);
diff --git a/src/lib/accountlist.cpp b/src/lib/accountlist.cpp
index 56d672e..4a080cd 100644
--- a/src/lib/accountlist.cpp
+++ b/src/lib/accountlist.cpp
@@ -128,14 +128,11 @@ void AccountList::accountChanged(const QString& account,const \
QString& state, in  }
       }
       foreach (Account* acc, *m_pAccounts) {
-//          if (!dynamic_cast<Account*>(acc)) { //If an account is being created \
                while updating it may crash or remove it
-            int idx =accountIds.indexOf(acc->getAccountId());
-            if (idx == -1 && (acc->currentState() == READY || acc->currentState() == \
                REMOVED)) {
-               m_pAccounts->remove(idx);
-               emit dataChanged(index(idx - 1, 0), index(m_pAccounts->size()-1, 0));
-            }
-            acc = getAccountById(account);
-//          }
+         int idx =accountIds.indexOf(acc->getAccountId());
+         if (idx == -1 && (acc->currentState() == READY || acc->currentState() == \
REMOVED)) { +            m_pAccounts->remove(idx);
+            emit dataChanged(index(idx - 1, 0), index(m_pAccounts->size()-1, 0));
+         }
       }
    }
    if (a)
@@ -345,11 +342,11 @@ Account* AccountList::firstRegisteredAccount() const
          return current;
       else if (current && (current->getAccountRegistrationStatus() == \
ACCOUNT_STATE_READY) && m_pAccounts->count() == 1)  return current;
-      else if (current && !(current->getAccountRegistrationStatus() == \
                ACCOUNT_STATE_READY)) {
-         qDebug() << "Account " << ((current)?current->getAccountId():"") << " is \
                not registered ("
-         << ((current)?current->getAccountRegistrationStatus():"") << ") State:"
-         << ((current)?current->getAccountRegistrationStatus():"");
-      }
+//       else if (current && !(current->getAccountRegistrationStatus() == \
ACCOUNT_STATE_READY)) { +//          qDebug() << "Account " << \
((current)?current->getAccountId():"") << " is not registered (" +//          << \
((current)?current->getAccountRegistrationStatus():"") << ") State:" +//          << \
((current)?current->getAccountRegistrationStatus():""); +//       }
    }
    return nullptr;
 }
@@ -490,7 +487,7 @@ void AccountList::removeAccount( QModelIndex idx )
 }
 
 ///Set the previous account used
-void AccountList::setPriorAccount(Account* account) {
+void AccountList::setPriorAccount(const Account* account) {
    bool changed = (account && m_sPriorAccountId != account->getAccountId()) || \
(!account && !m_sPriorAccountId.isEmpty());  m_sPriorAccountId = \
account?account->getAccountId() : QString();  if (changed)
diff --git a/src/lib/accountlist.h b/src/lib/accountlist.h
index cd93279..bf36de7 100644
--- a/src/lib/accountlist.h
+++ b/src/lib/accountlist.h
@@ -61,7 +61,7 @@ public:
    Qt::ItemFlags flags    ( const QModelIndex& index                             ) \
const;  
    //Setters
-   void setPriorAccount          ( Account*                                          \
); +   void setPriorAccount          ( const Account*                                 \
);  virtual bool setData          ( const QModelIndex& index, const QVariant &value, \
int role);  void         setColorVisitor  ( AccountListColorVisitor* visitor          \
);  void         setDefaultAccount(Account* a);
diff --git a/src/lib/call.cpp b/src/lib/call.cpp
index a9de240..4efad73 100644
--- a/src/lib/call.cpp
+++ b/src/lib/call.cpp
@@ -31,7 +31,7 @@
 //SFLPhone library
 #include "callmanager_interface_singleton.h"
 #include "configurationmanager_interface_singleton.h"
-#include "contactbackend.h"
+#include "abstractcontactbackend.h"
 #include "contact.h"
 #include "account.h"
 #include "accountlist.h"
@@ -134,14 +134,34 @@ QDebug LIB_EXPORT operator<<(QDebug dbg, const Call::Action& c)
    return dbg.space();
 }
 
-ContactBackend* Call::m_pContactBackend = nullptr;
-Call*           Call::m_sSelectedCall   = nullptr;
 
-void Call::setContactBackend(ContactBackend* be)
+HistoryTreeBackend::~HistoryTreeBackend()
+{
+}
+
+char HistoryTreeBackend::dropState()
+{
+   return m_DropState;
+}
+
+void HistoryTreeBackend::setDropState(const char state)
+{
+   m_DropState = state;
+}
+
+AbstractContactBackend* Call::m_pContactBackend = nullptr;
+Call*                   Call::m_sSelectedCall   = nullptr;
+
+void Call::setContactBackend(AbstractContactBackend* be)
 {
    m_pContactBackend = be;
 }
 
+AbstractContactBackend* Call::getContactBackend ()
+{
+   return m_pContactBackend;
+}
+
 ///Constructor
 Call::Call(Call::State startState, const QString& callId, QString peerName, QString \
peerNumber, QString account)  :  HistoryTreeBackend(HistoryTreeBackend::Type::CALL), \
m_isConference(false),m_pStopTimeStamp(0),m_pStartTimeStamp(0), @@ -273,7 +293,7 @@ \
Call* Call::buildRingingCall(const QString & callId)  ///Build a call that is already \
over  Call* Call::buildHistoryCall(const QString & callId, uint startTimeStamp, uint \
stopTimeStamp, QString account, QString name, QString number, QString type)  {
-   if(name == "empty") name = "";
+   if(name == "empty") name = QString();
    Call* call            = new Call(Call::State::OVER, callId, name, number, account \
);  
    call->m_pStopTimeStamp  = stopTimeStamp ;
@@ -1238,4 +1258,4 @@ QVariant Call::getRoleData(int role) const
          break;
    };
    return QVariant();
-}
\ No newline at end of file
+}
diff --git a/src/lib/call.h b/src/lib/call.h
index e8d5f98..a3c5965 100644
--- a/src/lib/call.h
+++ b/src/lib/call.h
@@ -29,7 +29,7 @@ class QTimer;
 //SFLPhone
 #include "sflphone_const.h"
 #include "typedefs.h"
-class ContactBackend;
+class AbstractContactBackend;
 class Contact;
 class Account;
 class VideoRenderer;
@@ -60,12 +60,12 @@ public:
         TOP_LEVEL= 2,
         BOOKMARK = 3,
     };
-    HistoryTreeBackend(HistoryTreeBackend::Type _type);
-    virtual ~HistoryTreeBackend(){}
+    explicit HistoryTreeBackend(HistoryTreeBackend::Type _type);
+    virtual ~HistoryTreeBackend();
     HistoryTreeBackend::Type type3() const;
     virtual QObject* getSelf() = 0;
-    char dropState() {return m_DropState;}
-    void setDropState(const char state) {m_DropState = state;}
+    char dropState();
+    void setDropState(const char state);
 private:
     HistoryTreeBackend::Type m_Type3;
     char m_DropState;
@@ -186,8 +186,8 @@ public:
    static Call* buildRingingCall  (const QString & callId                            \
);  static Call* buildHistoryCall  (const QString & callId, uint startTimeStamp, uint \
stopTimeStamp, QString account, QString name, QString number, QString type );  static \
Call* buildExistingCall (QString callId                                               \
                );
-   static void  setContactBackend (ContactBackend* be                                \
                );
-   static ContactBackend* getContactBackend () {return m_pContactBackend;};
+   static void  setContactBackend (AbstractContactBackend* be                        \
); +   static AbstractContactBackend* getContactBackend ();
 
    //Static getters
    static history_state getHistoryStateFromType            ( QString type            \
); @@ -239,9 +239,9 @@ public:
    void backspaceItemText();
    void changeCurrentState(Call::State newState);
    void sendTextMessage(QString message);
-   
+
    virtual QObject* getSelf() {return this;}
-   
+
 private:
 
    //Attributes
@@ -256,7 +256,6 @@ private:
    uint                   m_pStopTimeStamp ;
    QString                m_TransferNumber ;
    QString                m_CallNumber     ;
-   static ContactBackend* m_pContactBackend;
    bool                   m_isConference   ;
    Call::State            m_CurrentState   ;
    bool                   m_Recording      ;
@@ -265,6 +264,7 @@ private:
    InstantMessagingModel* m_pImModel       ;
    int                    m_LastContactCheck;
    QTimer*                m_pTimer         ;
+   static AbstractContactBackend* m_pContactBackend;
    
    //State machine
    /**
diff --git a/src/lib/callmodel.cpp b/src/lib/callmodel.cpp
index 6d88c30..5ee84c1 100644
--- a/src/lib/callmodel.cpp
+++ b/src/lib/callmodel.cpp
@@ -30,7 +30,7 @@
 #include "instance_interface_singleton.h"
 #include "sflphone_const.h"
 #include "typedefs.h"
-#include "contactbackend.h"
+#include "abstractcontactbackend.h"
 #include "video_interface_singleton.h"
 #include "historymodel.h"
 
@@ -55,6 +55,13 @@ CallModel*   CallModel::m_spInstance = nullptr;
  *                                                                           *
  ****************************************************************************/
 
+///Singleton
+CallModel* CallModel::instance() {
+   if (!m_spInstance)
+      m_spInstance = new CallModel();
+   return m_spInstance;
+}
+
 ///Retrieve current and older calls from the daemon, fill history, model and enable \
drag n' drop  CallModel::CallModel() : QAbstractItemModel(nullptr)
 {
@@ -233,7 +240,7 @@ Call* CallModel::addIncomingCall(const QString& callId)
    Call* call = addCall(Call::buildIncomingCall(callId));
    //Call without account is not possible
    if (dynamic_cast<Account*>(call->getAccount())) {
-      if (call && call->getAccount()->isAutoAnswer()) {
+      if (call->getAccount()->isAutoAnswer()) {
          call->actionPerformed(Call::Action::ACCEPT);
       }
    }
@@ -362,7 +369,7 @@ Call* CallModel::addConference(const QString& confID)
       m_sPrivateCallList_callId[confID] = aNewStruct;
       m_lInternalModel << aNewStruct;
 
-      foreach(QString callId,callList) {
+      foreach(const QString& callId,callList) {
          InternalStruct* callInt = m_sPrivateCallList_callId[callId];
          if (callInt) {
             if (callInt->m_pParent && callInt->m_pParent != aNewStruct)
@@ -489,7 +496,7 @@ bool CallModel::setData( const QModelIndex& idx, const QVariant \
&value, int role  return false;
 }
 
-///Get informations relative to the index
+///Get information relative to the index
 QVariant CallModel::data( const QModelIndex& idx, int role) const
 {
    if (!idx.isValid())
@@ -647,7 +654,7 @@ bool CallModel::dropMimeData(const QMimeData* mimedata, \
Qt::DropAction action, i  return true;
             }
             //Drop a call on a conference -> add it to the conference
-            else if (targetIdx.parent().isValid() || target->isConference()) {
+            else if (target && (targetIdx.parent().isValid() || \
                target->isConference())) {
                Call* conf = \
target->isConference()?target:qvariant_cast<Call*>(targetIdx.parent().data(Call::Role::Object));
  if (conf) {
                   qDebug() << "Adding call " << call->getCallId() << "to conference" \
<< conf->getConfId(); @@ -850,4 +857,4 @@ void CallModel::slotCallChanged(Call* call)
 ///Add call slot
 void CallModel::slotAddPrivateCall(Call* call) {
    addCall(call,0);
-}
\ No newline at end of file
+}
diff --git a/src/lib/callmodel.h b/src/lib/callmodel.h
index 5958a82..3a3f7b0 100644
--- a/src/lib/callmodel.h
+++ b/src/lib/callmodel.h
@@ -74,11 +74,7 @@ class LIB_EXPORT CallModel : public QAbstractItemModel
       virtual bool          dropMimeData ( const QMimeData* data, Qt::DropAction \
action, int row, int column, const QModelIndex& parent );  
       //Singleton
-      static CallModel* instance() {
-         if (!m_spInstance)
-            m_spInstance = new CallModel();
-         return m_spInstance;
-      }
+      static CallModel* instance();
 
       Call* getCall ( const QString& callId  ) const;
       Call* getCall ( const QModelIndex& idx ) const;
diff --git a/src/lib/contact.cpp b/src/lib/contact.cpp
index 1bd4033..b7e104d 100644
--- a/src/lib/contact.cpp
+++ b/src/lib/contact.cpp
@@ -26,9 +26,42 @@
 //SFLPhone library
 #include "sflphone_const.h"
 
+
+Contact::PhoneNumber::PhoneNumber(const QString& number, const QString& type) : \
m_Number(number),m_Type(type) +{
+}
+
+Contact::PhoneNumbers::PhoneNumbers(Contact* parent) : \
QList<Contact::PhoneNumber*>(),ContactTreeBackend(ContactTreeBackend::NUMBER),m_pParent(parent)
 +{
+}
+
+Contact::PhoneNumbers::PhoneNumbers(Contact* parent, const \
QList<Contact::PhoneNumber*>& list) +: \
QList<Contact::PhoneNumber*>(list),ContactTreeBackend(ContactTreeBackend::NUMBER),m_pParent(parent)
 +{
+}
+
+Contact* Contact::PhoneNumbers::contact() const
+{
+   return m_pParent;
+}
+
 ContactTreeBackend::ContactTreeBackend(ContactTreeBackend::Type _type) : \
m_Type3(_type),m_DropState(0)  {
-   
+}
+
+ContactTreeBackend::~ContactTreeBackend()
+{
+}
+
+
+char ContactTreeBackend::dropState()
+{
+   return m_DropState;
+}
+
+void ContactTreeBackend::setDropState(const char state)
+{
+   m_DropState = state;
 }
 
 ContactTreeBackend::Type ContactTreeBackend::type3() const
diff --git a/src/lib/contact.h b/src/lib/contact.h
index 1966ca2..7b232ad 100644
--- a/src/lib/contact.h
+++ b/src/lib/contact.h
@@ -42,12 +42,12 @@ public:
         NUMBER=1,
         TOP_LEVEL=2
     };
-    ContactTreeBackend(ContactTreeBackend::Type _type);
-    virtual ~ContactTreeBackend(){}
+    explicit ContactTreeBackend(ContactTreeBackend::Type _type);
+    virtual ~ContactTreeBackend();
     ContactTreeBackend::Type type3() const;
     virtual QObject* getSelf() = 0;
-    char dropState() {return m_DropState;}
-    void setDropState(const char state) {m_DropState = state;}
+    char dropState();
+    void setDropState(const char state);
 private:
     ContactTreeBackend::Type m_Type3;
     char m_DropState;
@@ -62,8 +62,7 @@ public:
    class PhoneNumber {
    public:
       ///Constructor
-      PhoneNumber(QString number, QString type)
-      : m_Number(number),m_Type(type){}
+      PhoneNumber(const QString& number, const QString& type);
 
       //Getters
       QString& getNumber();
@@ -76,10 +75,9 @@ public:
    class  PhoneNumbers : public QList<Contact::PhoneNumber*>, public \
ContactTreeBackend {  public:
       virtual QObject* getSelf();
-      PhoneNumbers(Contact* parent) : \
QList<Contact::PhoneNumber*>(),ContactTreeBackend(ContactTreeBackend::NUMBER),m_pParent(parent) \
                {}
-      PhoneNumbers(Contact* parent, const QList<Contact::PhoneNumber*>& list) : \
                QList<Contact::PhoneNumber*>(list),
-      ContactTreeBackend(ContactTreeBackend::NUMBER),m_pParent(parent) {}
-      Contact* contact() const { return m_pParent; }
+      PhoneNumbers(Contact* parent);
+      PhoneNumbers(Contact* parent, const QList<Contact::PhoneNumber*>& list);
+      Contact* contact() const;
    private:
       Contact* m_pParent;
    };
diff --git a/src/klib/contactproxymodel.cpp b/src/lib/contactproxymodel.cpp
similarity index 78%
rename from src/klib/contactproxymodel.cpp
rename to src/lib/contactproxymodel.cpp
index 1469241..da83876 100644
--- a/src/klib/contactproxymodel.cpp
+++ b/src/lib/contactproxymodel.cpp
@@ -23,11 +23,11 @@
 
 #include <klocale.h>
 
-#include "../lib/contactbackend.h"
+#include "../lib/abstractcontactbackend.h"
 #include "../lib/callmodel.h"
 #include "../lib/historymodel.h"
 
-const char* ContactByNameProxyModel::m_slHistoryConstStr[25] = {
+const char* ContactProxyModel::m_slHistoryConstStr[25] = {
       "Today"                                                    ,//0
       "Yesterday"                                                ,//1
       QDate::currentDate().addDays(-2).toString("dddd").toAscii().constData(),//2
@@ -55,19 +55,19 @@ const char* ContactByNameProxyModel::m_slHistoryConstStr[25] = {
       "Never"                                                     //24
 };
 // 
-ContactByNameProxyModel::ContactByNameProxyModel(ContactBackend* parent,int role, \
bool showAll) : QAbstractItemModel(parent), \
+ContactProxyModel::ContactProxyModel(AbstractContactBackend* parent,int role, bool \
showAll) : QAbstractItemModel(parent),  \
m_pModel(parent),m_Role(role),m_ShowAll(showAll),m_isContactDateInit(false)  {
    m_lMimes << MIME_PLAIN_TEXT << MIME_PHONENUMBER;
    connect(m_pModel,SIGNAL(collectionChanged()),this,SLOT(reloadCategories()));
 }
 
-ContactByNameProxyModel::~ContactByNameProxyModel()
+ContactProxyModel::~ContactProxyModel()
 {
 
 }
 
-void ContactByNameProxyModel::reloadCategories()
+void ContactProxyModel::reloadCategories()
 {
    beginResetModel();
    m_hCategories.clear();
@@ -94,11 +94,11 @@ void ContactByNameProxyModel::reloadCategories()
    emit dataChanged(index(0,0),index(rowCount()-1,0));
 }
 
-bool ContactByNameProxyModel::setData( const QModelIndex& index, const QVariant \
&value, int role) +bool ContactProxyModel::setData( const QModelIndex& index, const \
QVariant &value, int role)  {
    if (index.isValid() && index.parent().isValid()) {
       ContactTreeBackend* modelItem = (ContactTreeBackend*)index.internalPointer();
-      if (role == ContactBackend::Role::DropState) {
+      if (role == AbstractContactBackend::Role::DropState) {
          modelItem->setDropState(value.toInt());
          emit dataChanged(index, index);
       }
@@ -106,7 +106,7 @@ bool ContactByNameProxyModel::setData( const QModelIndex& index, \
const QVariant  return false;
 }
 
-QVariant ContactByNameProxyModel::data( const QModelIndex& index, int role) const
+QVariant ContactProxyModel::data( const QModelIndex& index, int role) const
 {
    if (!index.isValid())
       return QVariant();
@@ -125,32 +125,32 @@ QVariant ContactByNameProxyModel::data( const QModelIndex& \
index, int role) cons  switch (role) {
          case Qt::DisplayRole:
             return QVariant(m_lCategoryCounter[index.parent().row()]->m_lChilds[index.row()]->getFormattedName());
                
-         case ContactBackend::Role::Organization:
+         case AbstractContactBackend::Role::Organization:
             return QVariant(m_lCategoryCounter[index.parent().row()]->m_lChilds[index.row()]->getOrganization());
                
-         case ContactBackend::Role::Group:
+         case AbstractContactBackend::Role::Group:
             return QVariant(m_lCategoryCounter[index.parent().row()]->m_lChilds[index.row()]->getGroup());
                
-         case ContactBackend::Role::Department:
+         case AbstractContactBackend::Role::Department:
             return QVariant(m_lCategoryCounter[index.parent().row()]->m_lChilds[index.row()]->getDepartment());
                
-         case ContactBackend::Role::PreferredEmail:
+         case AbstractContactBackend::Role::PreferredEmail:
             return QVariant(m_lCategoryCounter[index.parent().row()]->m_lChilds[index.row()]->getPreferredEmail());
                
-         case ContactBackend::Role::DropState:
+         case AbstractContactBackend::Role::DropState:
             return QVariant(modelItem->dropState());
-         case ContactBackend::Role::FormattedLastUsed: {
+         case AbstractContactBackend::Role::FormattedLastUsed: {
             if (!m_isContactDateInit)
-               ((ContactByNameProxyModel*)this)->m_hContactByDate = \
getContactListByTime(); +               ((ContactProxyModel*)this)->m_hContactByDate \
                = getContactListByTime();
             return QVariant(HistoryModel::timeToHistoryCategory(m_hContactByDate[m_lCategoryCounter[index.parent().row()]->m_lChilds[index.row()]]));
  }
-         case ContactBackend::Role::IndexedLastUsed: {
+         case AbstractContactBackend::Role::IndexedLastUsed: {
             if (!m_isContactDateInit)
-               ((ContactByNameProxyModel*)this)->m_hContactByDate = \
getContactListByTime(); +               ((ContactProxyModel*)this)->m_hContactByDate \
                = getContactListByTime();
             return QVariant(HistoryModel::timeToHistoryConst(m_hContactByDate[m_lCategoryCounter[index.parent().row()]->m_lChilds[index.row()]]));
  }
-         case ContactBackend::Role::DatedLastUsed: {
+         case AbstractContactBackend::Role::DatedLastUsed: {
             if (!m_isContactDateInit)
-               ((ContactByNameProxyModel*)this)->m_hContactByDate = \
getContactListByTime(); +               ((ContactProxyModel*)this)->m_hContactByDate \
                = getContactListByTime();
             return QVariant(QDateTime::fromTime_t( \
m_hContactByDate[m_lCategoryCounter[index.parent().row()]->m_lChilds[index.row()]])); \
                }
-         case ContactBackend::Role::Filter: {
+         case AbstractContactBackend::Role::Filter: {
             Contact* ct = \
                m_lCategoryCounter[index.parent().row()]->m_lChilds[index.row()];
             return ct->getFormattedName()+'\n'+ct->getOrganization()+'\n'+ct->getGroup()+'\n'+ct->getDepartment()+'\n'+ct->getPreferredEmail();
  }
@@ -170,7 +170,7 @@ QVariant ContactByNameProxyModel::data( const QModelIndex& index, \
int role) cons  return QVariant();
 }
 
-QVariant ContactByNameProxyModel::headerData(int section, Qt::Orientation \
orientation, int role) const +QVariant ContactProxyModel::headerData(int section, \
Qt::Orientation orientation, int role) const  {
    Q_UNUSED(section)
    if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
@@ -178,7 +178,7 @@ QVariant ContactByNameProxyModel::headerData(int section, \
Qt::Orientation orient  return QVariant();
 }
 
-bool ContactByNameProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction \
action, int row, int column, const QModelIndex &parent) +bool \
ContactProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int \
row, int column, const QModelIndex &parent)  {
    Q_UNUSED( data   )
    Q_UNUSED( row    )
@@ -189,7 +189,7 @@ bool ContactByNameProxyModel::dropMimeData(const QMimeData *data, \
Qt::DropAction  }
 
 
-int ContactByNameProxyModel::rowCount( const QModelIndex& parent ) const
+int ContactProxyModel::rowCount( const QModelIndex& parent ) const
 {
    if (!parent.isValid() || !parent.internalPointer())
       return m_lCategoryCounter.size();
@@ -202,20 +202,20 @@ int ContactByNameProxyModel::rowCount( const QModelIndex& \
parent ) const  return 0;
 }
 
-Qt::ItemFlags ContactByNameProxyModel::flags( const QModelIndex& index ) const
+Qt::ItemFlags ContactProxyModel::flags( const QModelIndex& index ) const
 {
    if (!index.isValid())
       return 0;
    return Qt::ItemIsEnabled | Qt::ItemIsSelectable | \
(index.parent().isValid()?Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled:Qt::ItemIsEnabled);
  }
 
-int ContactByNameProxyModel::columnCount ( const QModelIndex& parent) const
+int ContactProxyModel::columnCount ( const QModelIndex& parent) const
 {
    Q_UNUSED(parent)
    return 1;
 }
 
-QModelIndex ContactByNameProxyModel::parent( const QModelIndex& index) const
+QModelIndex ContactProxyModel::parent( const QModelIndex& index) const
 {
    if (!index.isValid() || !index.internalPointer()) {
       return QModelIndex();
@@ -225,16 +225,16 @@ QModelIndex ContactByNameProxyModel::parent( const QModelIndex& \
                index) const
       Contact* ct = \
(Contact*)((ContactTreeBackend*)(index.internalPointer()))->getSelf();  QString val = \
category(ct);  if (m_hCategories[val])
-         return ContactByNameProxyModel::index(m_lCategoryCounter.indexOf(m_hCategories[val]),0);
 +         return ContactProxyModel::index(m_lCategoryCounter.indexOf(m_hCategories[val]),0);
  }
    else if (modelItem && modelItem->type3() == ContactTreeBackend::Type::NUMBER) {
       Contact* ct = (Contact*)modelItem->getSelf();
       QString val = category(ct);
       if (m_hCategories[val]) {
-         return ContactByNameProxyModel::index(
+         return ContactProxyModel::index(
             (m_hCategories[val]->m_lChilds.indexOf(ct)),
             0,
-            ContactByNameProxyModel::index(m_lCategoryCounter.indexOf(m_hCategories[val]),0));
 +            ContactProxyModel::index(m_lCategoryCounter.indexOf(m_hCategories[val]),0));
  }
    }
    else if (modelItem && modelItem->type3() == ContactTreeBackend::Type::TOP_LEVEL) \
{ @@ -243,7 +243,7 @@ QModelIndex ContactByNameProxyModel::parent( const QModelIndex& \
index) const  return QModelIndex();
 }
 
-QModelIndex ContactByNameProxyModel::index( int row, int column, const QModelIndex& \
parent) const +QModelIndex ContactProxyModel::index( int row, int column, const \
QModelIndex& parent) const  {
    if (!parent.isValid()) {
       return createIndex(row,column,m_lCategoryCounter[row]);
@@ -257,12 +257,12 @@ QModelIndex ContactByNameProxyModel::index( int row, int \
column, const QModelInd  return QModelIndex();
 }
 
-QStringList ContactByNameProxyModel::mimeTypes() const
+QStringList ContactProxyModel::mimeTypes() const
 {
    return m_lMimes;
 }
 
-QMimeData* ContactByNameProxyModel::mimeData(const QModelIndexList &indexes) const
+QMimeData* ContactProxyModel::mimeData(const QModelIndexList &indexes) const
 {
    QMimeData *mimeData = new QMimeData();
    foreach (const QModelIndex &index, indexes) {
@@ -277,10 +277,12 @@ QMimeData* ContactByNameProxyModel::mimeData(const \
QModelIndexList &indexes) con  else if (index.parent().isValid()) {
             //Contact
             Contact* ct = \
                m_lCategoryCounter[index.parent().row()]->m_lChilds[index.row()];
-            if (ct && ct->getPhoneNumbers().size() == 1) {
-               mimeData->setData(MIME_PHONENUMBER , \
ct->getPhoneNumbers()[0]->getNumber().toUtf8()); +            if (ct) {
+               if (ct->getPhoneNumbers().size() == 1) {
+                  mimeData->setData(MIME_PHONENUMBER , \
ct->getPhoneNumbers()[0]->getNumber().toUtf8()); +               }
+               mimeData->setData(MIME_CONTACT , ct->getUid().toUtf8());
             }
-            mimeData->setData(MIME_CONTACT , ct->getUid().toUtf8());
             return mimeData;
          }
       }
@@ -295,36 +297,36 @@ QMimeData* ContactByNameProxyModel::mimeData(const \
                QModelIndexList &indexes) con
  ****************************************************************************/
 
 
-QString ContactByNameProxyModel::category(Contact* ct) const {
+QString ContactProxyModel::category(Contact* ct) const {
    QString cat;
    switch (m_Role) {
-      case ContactBackend::Role::Organization:
+      case AbstractContactBackend::Role::Organization:
          cat = ct->getOrganization();
          break;
-      case ContactBackend::Role::Group:
+      case AbstractContactBackend::Role::Group:
          cat = ct->getGroup();
          break;
-      case ContactBackend::Role::Department:
+      case AbstractContactBackend::Role::Department:
          cat = ct->getDepartment();
          break;
-      case ContactBackend::Role::PreferredEmail:
+      case AbstractContactBackend::Role::PreferredEmail:
          cat = ct->getPreferredEmail();
          break;
-      case ContactBackend::Role::FormattedLastUsed: {
+      case AbstractContactBackend::Role::FormattedLastUsed: {
          if (!m_isContactDateInit)
-            ((ContactByNameProxyModel*)this)->m_hContactByDate = \
getContactListByTime(); +            ((ContactProxyModel*)this)->m_hContactByDate = \
getContactListByTime();  cat = \
HistoryModel::timeToHistoryCategory(m_hContactByDate[ct]);  break;
       }
-      case ContactBackend::Role::IndexedLastUsed: {
+      case AbstractContactBackend::Role::IndexedLastUsed: {
          if (!m_isContactDateInit)
-            ((ContactByNameProxyModel*)this)->m_hContactByDate = \
getContactListByTime(); +            ((ContactProxyModel*)this)->m_hContactByDate = \
                getContactListByTime();
          cat = QString::number(HistoryModel::timeToHistoryConst(m_hContactByDate[ct]));
  break;
       }
-      case ContactBackend::Role::DatedLastUsed: {
+      case AbstractContactBackend::Role::DatedLastUsed: {
          if (!m_isContactDateInit)
-            ((ContactByNameProxyModel*)this)->m_hContactByDate = \
getContactListByTime(); +            ((ContactProxyModel*)this)->m_hContactByDate = \
getContactListByTime();  cat = \
QDateTime::fromTime_t(m_hContactByDate[ct]).toString();  break;
       }
@@ -338,7 +340,7 @@ QString ContactByNameProxyModel::category(Contact* ct) const {
 }
 
 ///Return the list of contact from history (in order, most recently used first)
-QHash<Contact*, time_t> ContactByNameProxyModel::getContactListByTime() const
+QHash<Contact*, time_t> ContactProxyModel::getContactListByTime() const
 {
    const CallMap& history= HistoryModel::getHistory();
    QHash<Contact*, time_t> toReturn;
@@ -360,7 +362,7 @@ QHash<Contact*, time_t> \
ContactByNameProxyModel::getContactListByTime() const  } //getContactListByTime
 
 
-void ContactByNameProxyModel::setRole(int role)
+void ContactProxyModel::setRole(int role)
 {
    if (role != m_Role) {
       m_Role = role;
@@ -368,7 +370,7 @@ void ContactByNameProxyModel::setRole(int role)
    }
 }
 
-void ContactByNameProxyModel::setShowAll(bool showAll)
+void ContactProxyModel::setShowAll(bool showAll)
 {
    if (showAll != m_ShowAll) {
       m_ShowAll = showAll;
diff --git a/src/klib/contactproxymodel.h b/src/lib/contactproxymodel.h
similarity index 84%
rename from src/klib/contactproxymodel.h
rename to src/lib/contactproxymodel.h
index f288f8b..7b498f9 100644
--- a/src/klib/contactproxymodel.h
+++ b/src/lib/contactproxymodel.h
@@ -15,8 +15,8 @@
  *   You should have received a copy of the GNU General Public License      *
  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
  ***************************************************************************/
-#ifndef CONTACTBYNAMEPROXYMODEL_H
-#define CONTACTBYNAMEPROXYMODEL_H
+#ifndef CONTACT_PROXY_MODEL_H
+#define CONTACT_PROXY_MODEL_H
 
 #include <QtGui/QSortFilterProxyModel>
 #include <QtCore/QHash>
@@ -25,16 +25,16 @@
 //SFLPhone
 #include "../lib/typedefs.h"
 #include "../lib/contact.h"
-class ContactBackend;
+class AbstractContactBackend;
 
-
-class LIB_EXPORT ContactByNameProxyModel :  public QAbstractItemModel
+class LIB_EXPORT ContactProxyModel :  public QAbstractItemModel
 {
    Q_OBJECT
 public:
-   friend class ContactBackend;
-   ContactByNameProxyModel(ContactBackend* parent,int role = Qt::DisplayRole, bool \
                showAll = false);
-   
+   friend class AbstractContactBackend;
+   explicit ContactProxyModel(AbstractContactBackend* parent,int role = \
Qt::DisplayRole, bool showAll = false); +
+   //Setters
    void setRole(int role);
    void setShowAll(bool showAll);
 
@@ -53,27 +53,26 @@ public:
 
 private:
    class TopLevelItem : public ContactTreeBackend,public QObject {
-   friend class ContactByNameProxyModel;
+   friend class ContactProxyModel;
    public:
       virtual QObject* getSelf() {return this;}
    private:
-      TopLevelItem(QString name) : \
                ContactTreeBackend(ContactTreeBackend::TOP_LEVEL),QObject(nullptr),m_Name(name) \
                {}
-      int counter;
-      int idx;
+      explicit TopLevelItem(QString name) : \
ContactTreeBackend(ContactTreeBackend::TOP_LEVEL),QObject(nullptr),m_Name(name) {}  \
QList<Contact*> m_lChilds;  QString m_Name;
    };
-   virtual ~ContactByNameProxyModel();
-   
+
+   virtual ~ContactProxyModel();
+
    QModelIndex getContactIndex(Contact* ct) const;
-   
+
    //Helpers
    QString category(Contact* ct) const;
    QHash<Contact*, time_t> getContactListByTime() const;
 
    //Attributes
-   QHash<Contact*, time_t>   m_hContactByDate       ;
-   ContactBackend*              m_pModel               ;
+   QHash<Contact*, time_t>      m_hContactByDate       ;
+   AbstractContactBackend*      m_pModel               ;
    QList<TopLevelItem*>         m_lCategoryCounter     ;
    QHash<QString,TopLevelItem*> m_hCategories          ;
    int                          m_Role                 ;
diff --git a/src/lib/historymodel.cpp b/src/lib/historymodel.cpp
index 0b4afe3..5592c8d 100644
--- a/src/lib/historymodel.cpp
+++ b/src/lib/historymodel.cpp
@@ -80,6 +80,10 @@ inline bool operator< (const SortableCallSource & s1, const \
SortableCallSource &  HistoryModel* HistoryModel::m_spInstance    = nullptr;
 CallMap       HistoryModel::m_sHistoryCalls          ;
 
+HistoryModel::TopLevelItem::TopLevelItem(QString name) : 
+   HistoryTreeBackend(HistoryTreeBackend::TOP_LEVEL),QObject(nullptr),m_Name(name) 
+{}
+
 
 /*****************************************************************************
  *                                                                           *
@@ -144,15 +148,17 @@ void HistoryModel::add(Call* call)
 ///Add to history
 void HistoryModel::addPriv(Call* call)
 {
-   if (call) {
-      m_sHistoryCalls[call->getStartTimeStamp()] = call;
-   }
+   if (!call)
+      return;
+
+   m_sHistoryCalls[call->getStartTimeStamp()] = call;
    if (!m_HaveContactModel && call->getContactBackend()) {
       connect(((QObject*)call->getContactBackend()),SIGNAL(collectionChanged()),this,SLOT(reloadCategories()));
  m_HaveContactModel = true;
    }
+
    emit newHistoryCall(call);
-   QString cat = category(call);
+   const QString cat = category(call);
    if (!m_hCategories[cat]) { 
       TopLevelItem* item = new TopLevelItem(cat);
       m_hCategories[cat] = item;
@@ -479,4 +485,11 @@ HistoryModel::HistoryConst \
HistoryModel::timeToHistoryConst(const time_t time)  
    //Every other senario
    return HistoryModel::HistoryConst::Very_long_time_ago;
-}
\ No newline at end of file
+}
+
+void HistoryModel::setCategoryRole(Call::Role role) 
+{
+   if (m_Role != role) {
+      m_Role = role;reloadCategories();
+   }
+}
diff --git a/src/lib/historymodel.h b/src/lib/historymodel.h
index 5027349..cd8df53 100644
--- a/src/lib/historymodel.h
+++ b/src/lib/historymodel.h
@@ -74,7 +74,7 @@ public:
 
    //Setters
    static void add(Call* call);
-   void setCategoryRole(Call::Role role) {if (m_Role != role) { m_Role = \
role;reloadCategories();}} +   void setCategoryRole(Call::Role role);
 
    //Model implementation
    virtual bool          setData     ( const QModelIndex& index, const QVariant \
&value, int role   ); @@ -105,7 +105,6 @@ private:
 
    //Helpers
    QString category(Call* call) const;
-//    QVariant commonCallInfo(Call* call, int role) const;
 
    //Static attributes
    static HistoryModel* m_spInstance;
@@ -120,7 +119,7 @@ private:
    public:
       virtual QObject* getSelf() {return this;}
    private:
-      TopLevelItem(QString name) : \
HistoryTreeBackend(HistoryTreeBackend::TOP_LEVEL),QObject(nullptr),m_Name(name) {} +  \
TopLevelItem(QString name);  CallList m_lChilds;
       QString m_Name;
    };
diff --git a/src/lib/videomodel.h b/src/lib/videomodel.h
index e453e6a..2c48f73 100644
--- a/src/lib/videomodel.h
+++ b/src/lib/videomodel.h
@@ -53,13 +53,10 @@ private:
    static VideoModel* m_spInstance;
    
    //Attributes
-   bool           m_Attached    ;
    bool           m_PreviewState;
    uint           m_BufferSize  ;
    uint           m_ShmKey      ;
    uint           m_SemKey      ;
-   int            m_SetSetId    ;
-   void*          m_pBuffer     ;
    QHash<QString,VideoRenderer*> m_lRenderers;
 
 public Q_SLOTS:
diff --git a/src/sflphone.cpp b/src/sflphone.cpp
index f0a00cc..c2d98e1 100644
--- a/src/sflphone.cpp
+++ b/src/sflphone.cpp
@@ -116,58 +116,6 @@ SFLPhone::SFLPhone(QWidget *parent)
    action_mute->setCheckable(true);
 
    m_pView = new SFLPhoneView(this);
-}
-
-///Destructor
-SFLPhone::~SFLPhone()
-{
-   if (!isHidden()) {
-      ConfigurationSkeleton::setDisplayContactDock ( m_pContactCD->isVisible()  );
-      ConfigurationSkeleton::setDisplayHistoryDock ( m_pHistoryDW->isVisible()  );
-      ConfigurationSkeleton::setDisplayBookmarkDock( m_pBookmarkDW->isVisible() );
-   }
-
-   delete action_accept                ;
-   delete action_refuse                ;
-   delete action_hold                  ;
-   delete action_transfer              ;
-   delete action_record                ;
-   delete action_mailBox               ;
-   delete action_close                 ;
-   delete action_quit                  ;
-   delete action_displayVolumeControls ;
-   delete action_displayDialpad        ;
-   delete action_displayMessageBox     ;
-   delete action_configureSflPhone     ;
-   delete action_configureShortcut     ;
-   delete action_accountCreationWizard ;
-   delete action_pastenumber           ;
-   delete action_showContactDock       ;
-   delete action_showHistoryDock       ;
-   delete action_showBookmarkDock      ;
-   delete action_editToolBar           ;
-
-   delete m_pView            ;
-   delete m_pTrayIcon        ;
-   delete m_pStatusBarWidget ;
-   delete m_pContactCD       ;
-   delete m_pCentralDW       ;
-   delete m_pHistoryDW       ;
-   delete m_pBookmarkDW      ;
-   delete m_pAccountModel    ;
-
-   delete AkonadiBackend::getInstance();
-   delete CallModel::instance();
-   //saveState();
-}
-
-///Init everything
-bool SFLPhone::initialize()
-{
-   if ( m_pInitialized ) {
-      kDebug() << "Already initialized.";
-      return false;
-   }
 
    ConfigurationSkeleton::self();
 
@@ -195,12 +143,10 @@ bool SFLPhone::initialize()
    m_pCentralDW->setContentsMargins(0,0,0,0);
    m_pView->setContentsMargins     (0,0,0,0);
 
-
-   m_pContactCD = new ContactDock(this);
-
-   m_pHistoryDW       = new HistoryDock  ( this                     );
-   m_pBookmarkDW      = new BookmarkDock ( this                     );
-   m_pStatusBarWidget = new QLabel       (                          );
+   m_pContactCD       = new ContactDock  ( this );
+   m_pHistoryDW       = new HistoryDock  ( this );
+   m_pBookmarkDW      = new BookmarkDock ( this );
+   m_pStatusBarWidget = new QLabel       ( this );
 
    //System tray
    m_pTrayIcon        = new SFLPhoneTray ( this->windowIcon(), this );
@@ -258,16 +204,14 @@ bool SFLPhone::initialize()
    connect(action_showHistoryDock, SIGNAL(toggled(bool)),m_pHistoryDW, \
SLOT(setVisible(bool)));  \
connect(action_showBookmarkDock,SIGNAL(toggled(bool)),m_pBookmarkDW,SLOT(setVisible(bool)));
  
-   #ifdef ENABLE_VIDEO
+#ifdef ENABLE_VIDEO
    connect(VideoModel::getInstance(),SIGNAL(videoCallInitiated(VideoRenderer*)),this,SLOT(displayVideoDock(VideoRenderer*)));
                
-   #endif
+#endif
 
    statusBar()->addWidget(m_pStatusBarWidget);
 
-
    m_pTrayIcon->show();
 
-
    setObjectNames();
    QMetaObject::connectSlotsByName(this);
    m_pView->loadWindow();
@@ -275,9 +219,8 @@ bool SFLPhone::initialize()
    move(QCursor::pos().x() - geometry().width()/2, QCursor::pos().y() - \
geometry().height()/2);  show();
 
-   if (AccountList::getInstance()->size() <= 1) {
+   if (AccountList::getInstance()->size() <= 1)
       (new AccountWizard())->show();
-   }
 
    m_pIconChanged = false;
    m_pInitialized = true ;
@@ -292,13 +235,11 @@ bool SFLPhone::initialize()
    m_pAccountStatus->setModel(m_pAccountModel);
    m_pAccountStatus->setMinimumSize(100,0);
    bar->addPermanentWidget(m_pAccountStatus);
-   
+
    QToolButton* m_pReloadButton = new QToolButton(this);
    m_pReloadButton->setIcon(KIcon("view-refresh"));
    bar->addPermanentWidget(m_pReloadButton);
    connect(m_pReloadButton,SIGNAL(clicked()),AccountList::getInstance(),SLOT(registerAllAccounts()));
                
-   
-
    connect(m_pAccountStatus, SIGNAL(currentIndexChanged(int)), this, \
SLOT(currentAccountIndexChanged(int)) );  connect(AccountList::getInstance(), \
SIGNAL(priorAccountChanged(Account*)),this,SLOT(currentPriorAccountChanged(Account*)));
  
@@ -315,6 +256,58 @@ bool SFLPhone::initialize()
       QTimer::singleShot(2500,this,SLOT(timeout())); //FIXME this may leave the \
                client in an unreliable state
       //exit(1); //Don't try to exit normally, it will segfault, the application is \
already in a broken state if this is reached //BUG break some slow netbooks  }
+} //SFLPhone
+
+///Destructor
+SFLPhone::~SFLPhone()
+{
+   if (!isHidden()) {
+      ConfigurationSkeleton::setDisplayContactDock ( m_pContactCD->isVisible()  );
+      ConfigurationSkeleton::setDisplayHistoryDock ( m_pHistoryDW->isVisible()  );
+      ConfigurationSkeleton::setDisplayBookmarkDock( m_pBookmarkDW->isVisible() );
+   }
+
+   delete action_accept                ;
+   delete action_refuse                ;
+   delete action_hold                  ;
+   delete action_transfer              ;
+   delete action_record                ;
+   delete action_mailBox               ;
+   delete action_close                 ;
+   delete action_quit                  ;
+   delete action_displayVolumeControls ;
+   delete action_displayDialpad        ;
+   delete action_displayMessageBox     ;
+   delete action_configureSflPhone     ;
+   delete action_configureShortcut     ;
+   delete action_accountCreationWizard ;
+   delete action_pastenumber           ;
+   delete action_showContactDock       ;
+   delete action_showHistoryDock       ;
+   delete action_showBookmarkDock      ;
+   delete action_editToolBar           ;
+
+   delete m_pView            ;
+   delete m_pTrayIcon        ;
+   delete m_pStatusBarWidget ;
+   delete m_pContactCD       ;
+   delete m_pCentralDW       ;
+   delete m_pHistoryDW       ;
+   delete m_pBookmarkDW      ;
+   delete m_pAccountModel    ;
+
+   delete AkonadiBackend::getInstance();
+   delete CallModel::instance();
+   //saveState();
+}
+
+///Init everything
+bool SFLPhone::initialize()
+{
+   if ( m_pInitialized ) {
+      kDebug() << "Already initialized.";
+      return false;
+   }
 
    return true;
 }
@@ -612,18 +605,20 @@ void SFLPhone::on_m_pView_recordCheckStateChangeAsked(bool \
recordCheckState)  ///Called when a call is coming
 void SFLPhone::on_m_pView_incomingCall(const Call* call)
 {
-   Contact* contact = \
                AkonadiBackend::getInstance()->getContactByPhone(call->getPeerPhoneNumber());
                
-   if (contact && call) {
-      KNotification::event(KNotification::Notification, i18n("New incoming call"), \
i18n("New call from:\n%1",call->getPeerName().isEmpty() ? call->getPeerPhoneNumber() \
: call->getPeerName()),((contact->getPhoto())?*contact->getPhoto():nullptr)); +   if \
(call) { +      const Contact* contact = \
AkonadiBackend::getInstance()->getContactByPhone(call->getPeerPhoneNumber()); +      \
if (contact) +         KNotification::event(KNotification::Notification, i18n("New \
incoming call"), i18n("New call from:\n%1",call->getPeerName().isEmpty() ? \
call->getPeerPhoneNumber() : \
call->getPeerName()),((contact->getPhoto())?*contact->getPhoto():nullptr)); +      \
else +         KNotification::event(KNotification::Notification, i18n("New incoming \
call"), i18n("New call from:\n%1",call->getPeerName().isEmpty() ? \
call->getPeerPhoneNumber() : call->getPeerName()));  }
-   KNotification::event(KNotification::Notification, i18n("New incoming call"), \
i18n("New call from:\n%1",call->getPeerName().isEmpty() ? call->getPeerPhoneNumber() \
: call->getPeerName()));  }
 
 ///Change current account
 void SFLPhone::currentAccountIndexChanged(int newIndex)
 {
    if (AccountList::getInstance()->size()) {
-      Account* acc = \
AccountList::getInstance()->getAccountByModelIndex(AccountList::getInstance()->index(newIndex,0));
 +      const Account* acc = \
AccountList::getInstance()->getAccountByModelIndex(AccountList::getInstance()->index(newIndex,0));
  if (acc)
          AccountList::getInstance()->setPriorAccount(acc);
    }
diff --git a/src/sflphoneapplication.cpp b/src/sflphoneapplication.cpp
index 414e2a8..3ab9ced 100644
--- a/src/sflphoneapplication.cpp
+++ b/src/sflphoneapplication.cpp
@@ -54,9 +54,14 @@ SFLPhoneApplication::SFLPhoneApplication()
   : KUniqueApplication()
 #endif
 {
-   InstanceInterface& instance = InstanceInterfaceSingleton::getInstance();
-   QDBusPendingReply<QString> reply = instance.Register(getpid(), APP_NAME);
-   reply.waitForFinished();
+   try {
+      InstanceInterface& instance = InstanceInterfaceSingleton::getInstance();
+      QDBusPendingReply<QString> reply = instance.Register(getpid(), APP_NAME);
+      reply.waitForFinished();
+   }
+   catch (...) {
+      KMessageBox::error(SFLPhone::app(),ErrorMessage::GENERIC_ERROR);
+   }
 
    // Start remaining initialisation
    initializePaths();
diff --git a/src/sflphoneview.cpp b/src/sflphoneview.cpp
index 7016bdc..88bdd08 100644
--- a/src/sflphoneview.cpp
+++ b/src/sflphoneview.cpp
@@ -42,7 +42,6 @@
 #include "accountwizard.h"
 #include "actionsetaccountfirst.h"
 #include "sflphone.h"
-#include "widgets/callviewoverlaytoolbar.h"
 #include "widgets/tips/tipcollection.h"
 #include "widgets/callviewoverlaytoolbar.h"
 #include "extendedaction.h"
diff --git a/src/widgets/bookmarkdock.cpp b/src/widgets/bookmarkdock.cpp
index d33f00d..f71aa3f 100644
--- a/src/widgets/bookmarkdock.cpp
+++ b/src/widgets/bookmarkdock.cpp
@@ -155,4 +155,4 @@ void BookmarkDock::slotDoubleClick(const QModelIndex& index)
    Call* call2 = SFLPhone::model()->addDialingCall(idx.model()->data(idx,Call::Role::Number).toString(), \
AccountList::getCurrentAccount());  call2->setCallNumber  ( \
idx.model()->data(idx,Call::Role::Number).toString() );  call2->actionPerformed( \
                Call::Action::ACCEPT   );
-}
\ No newline at end of file
+}
diff --git a/src/widgets/bookmarkdock.h b/src/widgets/bookmarkdock.h
index f04f51e..b036a58 100644
--- a/src/widgets/bookmarkdock.h
+++ b/src/widgets/bookmarkdock.h
@@ -53,7 +53,7 @@ class BookmarkSortFilterProxyModel : public QSortFilterProxyModel
 {
    Q_OBJECT
 public:
-   BookmarkSortFilterProxyModel(QObject* parent) : QSortFilterProxyModel(parent) {}
+   explicit BookmarkSortFilterProxyModel(QObject* parent) : \
QSortFilterProxyModel(parent) {}  protected:
    virtual bool filterAcceptsRow ( int source_row, const QModelIndex & source_parent \
) const  {
diff --git a/src/widgets/callviewoverlay.cpp b/src/widgets/callviewoverlay.cpp
index 61d3730..dbcde06 100644
--- a/src/widgets/callviewoverlay.cpp
+++ b/src/widgets/callviewoverlay.cpp
@@ -32,7 +32,8 @@
  ****************************************************************************/
 
 ///Constructor
-CallViewOverlay::CallViewOverlay(QWidget* parent) : \
QWidget(parent),m_pIcon(0),m_pTimer(0),m_enabled(true),m_black("black") \
+CallViewOverlay::CallViewOverlay(QWidget* parent) : \
QWidget(parent),m_pIcon(0),m_pTimer(0),m_enabled(true),m_black("black"), +m_step(0)
 {
    m_black.setAlpha(75);
 }
diff --git a/src/widgets/callviewoverlaytoolbar.cpp \
b/src/widgets/callviewoverlaytoolbar.cpp index a9887d0..effae6e 100644
--- a/src/widgets/callviewoverlaytoolbar.cpp
+++ b/src/widgets/callviewoverlaytoolbar.cpp
@@ -219,4 +219,4 @@ bool CallViewOverlayToolbar::eventFilter(QObject *obj, QEvent \
*event)  }
    // standard event processing
    return QObject::eventFilter(obj, event);
-}
\ No newline at end of file
+}
diff --git a/src/widgets/categorizedtreeview.cpp \
b/src/widgets/categorizedtreeview.cpp index 1204a0b..3c5a729 100644
--- a/src/widgets/categorizedtreeview.cpp
+++ b/src/widgets/categorizedtreeview.cpp
@@ -157,4 +157,4 @@ bool CategorizedTreeView::edit(const QModelIndex& index, \
EditTrigger trigger, QE  return true;
    }
    return QTreeView::edit(index,trigger,event);
-}
\ No newline at end of file
+}
diff --git a/src/widgets/categorizedtreeview.h b/src/widgets/categorizedtreeview.h
index 36e93fd..a77d1e3 100644
--- a/src/widgets/categorizedtreeview.h
+++ b/src/widgets/categorizedtreeview.h
@@ -41,7 +41,7 @@ class CategorizedTreeView : public QTreeView
    explicit CategorizedTreeView(QWidget *parent = nullptr);
    void setDelegate(QStyledItemDelegate* delegate);
    void setViewType(ViewType type) {m_Type = type;}
-    
+
   protected:
    virtual void contextMenuEvent ( QContextMenuEvent * e );
    virtual void dragLeaveEvent   ( QDragLeaveEvent   * e );
@@ -51,12 +51,11 @@ class CategorizedTreeView : public QTreeView
    virtual void mouseDoubleClickEvent(QMouseEvent* event);
    virtual void startDrag ( Qt::DropActions supportedActions );
    virtual bool edit(const QModelIndex& index, EditTrigger trigger, QEvent* event);
-    
+
   private:
-   QStyledItemDelegate* m_pDelegate;
    QModelIndex m_HoverIdx;
    ViewType m_Type;
-    
+
   Q_SIGNALS:
    void contextMenuRequest(QModelIndex);
    void itemDoubleClicked(QModelIndex);
diff --git a/src/widgets/contactdock.cpp b/src/widgets/contactdock.cpp
index 00b8fad..df7f9e6 100644
--- a/src/widgets/contactdock.cpp
+++ b/src/widgets/contactdock.cpp
@@ -52,6 +52,7 @@
 #include "klib/helperfunctions.h"
 #include "klib/akonadibackend.h"
 #include "klib/configurationskeleton.h"
+#include "../lib/contactproxymodel.h"
 #include "../delegates/categorizeddelegate.h"
 #include "../delegates/contactdelegate.h"
 #include "../delegates/phonenumberdelegate.h"
@@ -103,14 +104,13 @@ ContactDock::ContactDock(QWidget* parent) : \
QDockWidget(parent),m_pCallAgain(nul  delegate->setChildDelegate(new \
ContactDelegate());  delegate->setChildChildDelegate(new PhoneNumberDelegate());
    m_pView->setDelegate(delegate);
-//    m_pView->setStyle(new ContactDelegateStyle(m_pView->style()));
 
-   m_pSourceModel = new \
ContactByNameProxyModel(AkonadiBackend::getInstance(),Qt::DisplayRole,false); +   \
m_pSourceModel = new \
ContactProxyModel(AkonadiBackend::getInstance(),Qt::DisplayRole,false);  \
m_pProxyModel = new ContactSortFilterProxyModel(this);  \
m_pProxyModel->setSourceModel(m_pSourceModel);  \
m_pProxyModel->setSortRole(Qt::DisplayRole);  \
                m_pProxyModel->setSortLocaleAware(true);
-   m_pProxyModel->setFilterRole(ContactBackend::Role::Filter);
+   m_pProxyModel->setFilterRole(AbstractContactBackend::Role::Filter);
    m_pProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
    m_pProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
    m_pView->setModel(m_pProxyModel);
@@ -185,7 +185,7 @@ QString ContactDock::showNumberSelector(bool& ok)
       ok = true;
       return m_PreselectedNb;
    }
-   else if (m_pCurrentContact->getPhoneNumbers().size() == 1) {
+   else if (m_pCurrentContact&& m_pCurrentContact->getPhoneNumbers().size() == 1) {
       ok = true;
       return m_pCurrentContact->getPhoneNumbers()[0]->getNumber();
    }
@@ -481,24 +481,24 @@ void ContactDock::setCategory(int index)
          m_pProxyModel->setSortRole(Qt::DisplayRole);
          break;
       case SortingCategory::Organization:
-         m_pProxyModel->setSortRole(ContactBackend::Role::Organization);
-         m_pSourceModel->setRole(ContactBackend::Role::Organization);
+         m_pProxyModel->setSortRole(AbstractContactBackend::Role::Organization);
+         m_pSourceModel->setRole(AbstractContactBackend::Role::Organization);
          m_pSourceModel->setShowAll(true);
          break;
       case SortingCategory::RecentlyUsed:
-         m_pSourceModel->setRole(ContactBackend::Role::FormattedLastUsed);
+         m_pSourceModel->setRole(AbstractContactBackend::Role::FormattedLastUsed);
          m_pSourceModel->setShowAll(true);
-         m_pProxyModel->setSortRole(ContactBackend::Role::IndexedLastUsed);
+         m_pProxyModel->setSortRole(AbstractContactBackend::Role::IndexedLastUsed);
          break;
       case SortingCategory::Group:
-         m_pSourceModel->setRole(ContactBackend::Role::Group);
+         m_pSourceModel->setRole(AbstractContactBackend::Role::Group);
          m_pSourceModel->setShowAll(true);
-         m_pProxyModel->setSortRole(ContactBackend::Role::Group);
+         m_pProxyModel->setSortRole(AbstractContactBackend::Role::Group);
          break;
       case SortingCategory::Department:
-         m_pSourceModel->setRole(ContactBackend::Role::Department);
+         m_pSourceModel->setRole(AbstractContactBackend::Role::Department);
          m_pSourceModel->setShowAll(true);
-         m_pProxyModel->setSortRole(ContactBackend::Role::Department);
+         m_pProxyModel->setSortRole(AbstractContactBackend::Role::Department);
          break;
    };
 }
diff --git a/src/widgets/contactdock.h b/src/widgets/contactdock.h
index 98135c5..0fc9ca0 100644
--- a/src/widgets/contactdock.h
+++ b/src/widgets/contactdock.h
@@ -19,12 +19,15 @@
 #define CONTACT_DOCK_H
 
 #include "ui_dockbase.h"
-#include <QtGui/QDockWidget>
 
+//Qt
 #include <QtCore/QHash>
+#include <QtGui/QDockWidget>
+#include <QtGui/QSortFilterProxyModel>
 #include <QtGui/QTreeWidgetItem>
+
+//SFLPhone
 #include "categorizedtreeview.h"
-#include "../klib/contactproxymodel.h"
 
 //Qt
 class QSplitter;
@@ -49,12 +52,13 @@ namespace KABC {
 
 ///SFLPhone
 class Contact;
+class ContactProxyModel;
 
 class ContactSortFilterProxyModel : public QSortFilterProxyModel
 {
    Q_OBJECT
 public:
-   ContactSortFilterProxyModel(QObject* parent) : QSortFilterProxyModel(parent) {}
+   explicit ContactSortFilterProxyModel(QObject* parent) : \
QSortFilterProxyModel(parent) {}  protected:
    virtual bool filterAcceptsRow ( int source_row, const QModelIndex & source_parent \
) const  {
@@ -86,7 +90,7 @@ private:
    Contact*                     m_pCurrentContact;
    QString                      m_PreselectedNb  ;
    QSortFilterProxyModel*       m_pProxyModel    ;
-   ContactByNameProxyModel*     m_pSourceModel   ;
+   ContactProxyModel*           m_pSourceModel   ;
 
    //Actions
    KAction* m_pCallAgain   ;
diff --git a/src/widgets/historydock.cpp b/src/widgets/historydock.cpp
index 623aac0..a4db059 100644
--- a/src/widgets/historydock.cpp
+++ b/src/widgets/historydock.cpp
@@ -393,28 +393,33 @@ void HistoryDock::slotCallAgain()
 
 void HistoryDock::slotCopy()
 {
+   if (!m_pCurrentCall) {
+      kDebug() << "No call to copy";
+      return;
+   }
+
    kDebug() << "Copying contact";
    QMimeData* mimeData = new QMimeData();
-   if (m_pCurrentCall)
-      mimeData->setData(MIME_CALLID, m_pCurrentCall->getCallId().toUtf8());
+   mimeData->setData(MIME_CALLID, m_pCurrentCall->getCallId().toUtf8());
 
    mimeData->setData(MIME_PHONENUMBER, \
                m_pCurrentCall->getPeerPhoneNumber().toUtf8());
-   
-   QString numbers;
-   QString numbersHtml;
-   Contact* ct = m_pCurrentCall->getContact();
+
+   QString numbers,numbersHtml;
+   const Contact* ct = m_pCurrentCall->getContact();
+
    if (ct) {
       numbers     = ct->getFormattedName()+": \
                "+m_pCurrentCall->getPeerPhoneNumber();
       numbersHtml = "<b>"+ct->getFormattedName()+"</b><br \
/>"+HelperFunctions::escapeHtmlEntities(m_pCurrentCall->getPeerPhoneNumber());  }
-   else if (m_pCurrentCall) {
+   else {
       numbers     = m_pCurrentCall->getPeerName()+": \
                "+m_pCurrentCall->getPeerPhoneNumber();
       numbersHtml = "<b>"+m_pCurrentCall->getPeerName()+"</b><br \
/>"+HelperFunctions::escapeHtmlEntities(m_pCurrentCall->getPeerPhoneNumber());  }
+
    mimeData->setData("text/plain", numbers.toUtf8()    );
    mimeData->setData("text/html",  numbersHtml.toUtf8());
-   QClipboard* clipboard = QApplication::clipboard();
-   clipboard->setMimeData(mimeData);
+
+   QApplication::clipboard()->setMimeData(mimeData);
 }
 
 void HistoryDock::slotAaddContact()
diff --git a/src/widgets/historydock.h b/src/widgets/historydock.h
index 3ade881..8720555 100644
--- a/src/widgets/historydock.h
+++ b/src/widgets/historydock.h
@@ -116,7 +116,7 @@ class HistorySortFilterProxyModel : public QSortFilterProxyModel
 {
    Q_OBJECT
 public:
-   HistorySortFilterProxyModel(QObject* parent) : QSortFilterProxyModel(parent) {}
+   explicit HistorySortFilterProxyModel(QObject* parent) : \
QSortFilterProxyModel(parent) {}  protected:
    virtual bool filterAcceptsRow ( int source_row, const QModelIndex & source_parent \
) const  {
diff --git a/src/widgets/player.cpp b/src/widgets/player.cpp
index cb848f1..7ad22f1 100644
--- a/src/widgets/player.cpp
+++ b/src/widgets/player.cpp
@@ -58,4 +58,4 @@ void Player::slotUpdateSlider(int pos, int size)
    m_pElapsed->setText(QString("%1").arg((pos/1000)/60,2,10,QChar('0'))+':'+QString("%1").arg((pos/1000)%60,2,10,QChar('0')));
  m_pSlider->setMaximum(size);
    m_pSlider->setValue(pos);
-}
\ No newline at end of file
+}
diff --git a/src/widgets/player.h b/src/widgets/player.h
index ace9ca6..af9a25f 100644
--- a/src/widgets/player.h
+++ b/src/widgets/player.h
@@ -44,4 +44,4 @@ Q_SIGNALS:
    void sigHide(bool);
 };
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/widgets/playeroverlay.h b/src/widgets/playeroverlay.h
index 3341111..f4b752a 100644
--- a/src/widgets/playeroverlay.h
+++ b/src/widgets/playeroverlay.h
@@ -36,4 +36,4 @@ private Q_SLOTS:
    void slotDeleteRecording();
 };
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/widgets/tips/ringingtip.cpp b/src/widgets/tips/ringingtip.cpp
index de01c37..a6f0b1d 100644
--- a/src/widgets/tips/ringingtip.cpp
+++ b/src/widgets/tips/ringingtip.cpp
@@ -37,7 +37,7 @@
 RingingTip::RingingTip(QWidget* parent) : \
Tip(QString(),parent),m_pTimer(nullptr),m_Counter(0),  \
m_phoneOriginalSVG(nullptr),m_ring1OriginalSVG(nullptr),m_ring2OriginalSVG(nullptr),m_ring3OriginalSVG(nullptr),
  m_pPhoneR(nullptr),m_pRing1R(nullptr),m_pRing2R(nullptr),m_pRing3R(nullptr),m_pPhonePix(nullptr),m_pRing1Pix(nullptr),
                
-m_pRing2Pix(nullptr)
+m_pRing2Pix(nullptr),m_pRing3Pix(nullptr)
 {
    setHasBackground(false);
    setHasText(false);
diff --git a/src/widgets/tips/ringingtip.h b/src/widgets/tips/ringingtip.h
index dc72476..06f398b 100644
--- a/src/widgets/tips/ringingtip.h
+++ b/src/widgets/tips/ringingtip.h
@@ -15,8 +15,8 @@
  *   You should have received a copy of the GNU General Public License      *
  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
  ***************************************************************************/
-#ifndef RIGGINGTIP_H
-#define RIGGINGTIP_H
+#ifndef RIGGING_TIP_H
+#define RIGGING_TIP_H
 
 //Base
 #include "../../klib/tip.h"
diff --git a/src/widgets/ui/dockbase.ui b/src/widgets/ui/dockbase.ui
index b292516..1a911c5 100644
--- a/src/widgets/ui/dockbase.ui
+++ b/src/widgets/ui/dockbase.ui
@@ -11,7 +11,7 @@
    </rect>
   </property>
   <property name="windowTitle">
-   <string>Form</string>
+   <string>Dock</string>
   </property>
   <layout class="QGridLayout" name="gridLayout">
    <item row="0" column="0">
diff --git a/src/widgets/ui/player.ui b/src/widgets/ui/player.ui
index 1180174..1d3ecc4 100644
--- a/src/widgets/ui/player.ui
+++ b/src/widgets/ui/player.ui
@@ -11,7 +11,7 @@
    </rect>
   </property>
   <property name="windowTitle">
-   <string>Form</string>
+   <string>Player</string>
   </property>
   <property name="autoFillBackground">
    <bool>true</bool>
diff --git a/src/widgets/ui/playeroverlay.ui b/src/widgets/ui/playeroverlay.ui
index 1c00575..01d46b7 100644
--- a/src/widgets/ui/playeroverlay.ui
+++ b/src/widgets/ui/playeroverlay.ui
@@ -11,7 +11,7 @@
    </rect>
   </property>
   <property name="windowTitle">
-   <string>Form</string>
+   <string>PlayerOverlay</string>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
    <item>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic