diff --git a/src/bannedcontactmodel.cpp b/src/bannedcontactmodel.cpp index e5e8a1b7d56004cf9c0d8278a3c131db51ad5c7b..70aa6c0f18269f6090804b3b44af457c49c96152 100644 --- a/src/bannedcontactmodel.cpp +++ b/src/bannedcontactmodel.cpp @@ -97,6 +97,8 @@ BannedContactModel::data( const QModelIndex& index, int role ) const switch(role) { case Qt::DisplayRole: return d_ptr->m_lBanned[index.row()]->bestId(); + case static_cast<int>(ContactMethod::Role::Object): + return QVariant::fromValue(d_ptr->m_lBanned[index.row()]); } break; case Columns::COUNT__: @@ -139,3 +141,24 @@ BannedContactModel::add(ContactMethod* cm) d_ptr->m_lBanned << cm; endInsertRows(); } + +/** + * this function removes a ContactMethod from the banned list. + * @param cm, the ContactMethod to remove from the list. + */ +void +BannedContactModel::remove(ContactMethod* cm) +{ + auto rowIndex = d_ptr->m_lBanned.indexOf(cm); + + beginRemoveRows(QModelIndex(), rowIndex, rowIndex); + d_ptr->m_lBanned.removeAt(rowIndex); + endRemoveRows(); + + if (!cm->account()) { + qWarning() << "BannedContactModel, cannot remove. cm->account is nullptr"; + return; + } + + ConfigurationManager::instance().addContact(cm->account()->id(), cm->uri()); +} diff --git a/src/bannedcontactmodel.h b/src/bannedcontactmodel.h index 2c19b83374f12c802e9f3cf82d955cc8cddaee7d..c87db6e938b5c25a057b941214de525f6b704d30 100644 --- a/src/bannedcontactmodel.h +++ b/src/bannedcontactmodel.h @@ -44,6 +44,7 @@ public: // Helper void add(ContactMethod* cm); + void remove(ContactMethod* cm); private: virtual ~BannedContactModel(); diff --git a/src/qtwrapper/configurationmanager_wrap.h b/src/qtwrapper/configurationmanager_wrap.h index 35f330ef13dc872d8531d7fd8177f708a29d2290..9c4ba74d0607ce23da18b85c0201e6b73c6be5d4 100644 --- a/src/qtwrapper/configurationmanager_wrap.h +++ b/src/qtwrapper/configurationmanager_wrap.h @@ -652,6 +652,11 @@ public Q_SLOTS: // METHODS DRing::removeContact(accountId.toStdString(), uri.toStdString(), ban); } + void addContact(const QString &accountId, const QString &uri) + { + DRing::addContact(accountId.toStdString(), uri.toStdString()); + } + uint64_t sendTextMessage(const QString& accountId, const QString& to, const QMap<QString,QString>& payloads) { return DRing::sendAccountTextMessage(accountId.toStdString(), to.toStdString(), convertMap(payloads));