From 38a84336e6dbef6f2f1eb7457c5b588cc5162cca Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> Date: Fri, 8 Aug 2014 22:22:06 +0200 Subject: [PATCH] [ #52262 ] Fix the bookmark context menu --- src/abstractbookmarkmodel.cpp | 20 ++++++++++++++------ src/abstractbookmarkmodel.h | 3 ++- src/account.h | 3 --- src/callmodel.cpp | 6 +++--- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/abstractbookmarkmodel.cpp b/src/abstractbookmarkmodel.cpp index 2c951fcd..7122b066 100644 --- a/src/abstractbookmarkmodel.cpp +++ b/src/abstractbookmarkmodel.cpp @@ -281,7 +281,7 @@ QVariant AbstractBookmarkModel::commonCallInfo(NumberTreeBackend* number, int ro switch (role) { case Qt::DisplayRole: case Call::Role::Name: - cat = number->m_pNumber->primaryName(); + cat = number->m_pNumber->contact()?number->m_pNumber->contact()->formattedName():number->m_pNumber->primaryName(); break; case Qt::ToolTipRole: cat = number->m_pNumber->presenceMessage(); @@ -398,16 +398,24 @@ bool AbstractBookmarkModel::removeRows( int row, int count, const QModelIndex & } void AbstractBookmarkModel::remove(const QModelIndex& idx) +{ + PhoneNumber* nb = getNumber(idx); + if (nb) { + removeRows(idx.row(),1,idx.parent()); + removeBookmark(nb); + emit layoutAboutToBeChanged(); + emit layoutChanged(); + } +} + +PhoneNumber* AbstractBookmarkModel::getNumber(const QModelIndex& idx) { if (idx.isValid()) { if (idx.parent().isValid() && idx.parent().row() < m_lCategoryCounter.size()) { - PhoneNumber* nb = m_lCategoryCounter[idx.parent().row()]->m_lChildren[idx.row()]->m_pNumber; - removeRows(idx.row(),1,idx.parent()); - removeBookmark(nb); - emit layoutAboutToBeChanged(); - emit layoutChanged(); + return m_lCategoryCounter[idx.parent().row()]->m_lChildren[idx.row()]->m_pNumber; } } + return nullptr; } ///Callback when an item change diff --git a/src/abstractbookmarkmodel.h b/src/abstractbookmarkmodel.h index f6d73600..a10f4f74 100644 --- a/src/abstractbookmarkmodel.h +++ b/src/abstractbookmarkmodel.h @@ -65,7 +65,8 @@ public: virtual void removeBookmark(PhoneNumber* number ) = 0; //Getters - int acceptedPayloadTypes(); + int acceptedPayloadTypes(); + PhoneNumber* getNumber(const QModelIndex& idx); protected: virtual bool displayFrequentlyUsed() const; diff --git a/src/account.h b/src/account.h index e33cba98..914e4eb3 100644 --- a/src/account.h +++ b/src/account.h @@ -31,7 +31,6 @@ class QString; #include "tlsmethodmodel.h" #include "sflphone_const.h" #include "typedefs.h" -// #include "dbus/metatypes.h" class CredentialModel; class AudioCodecModel; class VideoCodecModel; @@ -40,8 +39,6 @@ class PhoneNumber ; class SecurityValidationModel; class Certificate ; -const QString& account_state_name(const QString& s); - typedef void (Account::*account_function)(); ///@enum DtmfType Different method to send the DTMF (key sound) to the peer diff --git a/src/callmodel.cpp b/src/callmodel.cpp index 3d701f3c..244770e8 100644 --- a/src/callmodel.cpp +++ b/src/callmodel.cpp @@ -379,10 +379,10 @@ void CallModel::removeCall(Call* call, bool noEmit) //NOTE Do not free the memory, it can still be used elsewhere or in modelindexes } - //TODO DEAD CODE Is this really required? - /*if (m_sPrivateCallList_callId[m_sPrivateCallList_callId.key(internal)] == internal) { + //TODO DEAD CODE Is this really required?, so far multi conference fail without + if (m_sPrivateCallList_callId[m_sPrivateCallList_callId.key(internal)] == internal) { m_sPrivateCallList_callId.remove(m_sPrivateCallList_callId.key(internal)); - }*/ + } removeInternal(internal); -- GitLab