mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-20 09:28:28 +00:00
update call history list when new call incoming (somehow if juste the new call log is added, it ends at the end of the list when updating the whole list) fix #LINQT-2444
This commit is contained in:
parent
88cd7299b9
commit
728a5c3f6a
4 changed files with 48 additions and 34 deletions
|
|
@ -50,7 +50,8 @@ CallHistoryCore::CallHistoryCore(const std::shared_ptr<linphone::CallLog> &callL
|
|||
mStatus = LinphoneEnums::fromLinphone(callLog->getStatus());
|
||||
mDate = QDateTime::fromMSecsSinceEpoch(callLog->getStartDate() * 1000);
|
||||
mIsOutgoing = callLog->getDir() == linphone::Call::Dir::Outgoing;
|
||||
mDuration = QString::number(callLog->getDuration());
|
||||
mDuration = callLog->getDuration();
|
||||
mDurationString = QString::number(mDuration);
|
||||
mIsConference = callLog->wasConference();
|
||||
mCallId = Utils::coreStringToAppString(callLog->getCallId());
|
||||
if (mIsConference) {
|
||||
|
|
@ -144,16 +145,17 @@ ConferenceInfoGui *CallHistoryCore::getConferenceInfoGui() const {
|
|||
return mConferenceInfo ? new ConferenceInfoGui(mConferenceInfo) : nullptr;
|
||||
}
|
||||
|
||||
QString CallHistoryCore::getDuration() const {
|
||||
int CallHistoryCore::getDuration() const {
|
||||
return mDuration;
|
||||
}
|
||||
|
||||
void CallHistoryCore::setDuration(const QString &duration) {
|
||||
QString CallHistoryCore::getDurationString() const {
|
||||
return mDurationString;
|
||||
}
|
||||
|
||||
QDateTime CallHistoryCore::getStartDate() const {
|
||||
mustBeInMainThread(log().arg(Q_FUNC_INFO));
|
||||
if (mDuration != duration) {
|
||||
mDuration = duration;
|
||||
emit durationChanged(mDuration);
|
||||
}
|
||||
return mDate;
|
||||
}
|
||||
|
||||
void CallHistoryCore::remove() {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class CallHistoryCore : public QObject, public AbstractObject {
|
|||
Q_PROPERTY(ConferenceInfoGui *conferenceInfo READ getConferenceInfoGui CONSTANT)
|
||||
Q_PROPERTY(QDateTime date MEMBER mDate CONSTANT)
|
||||
Q_PROPERTY(LinphoneEnums::CallStatus status MEMBER mStatus CONSTANT)
|
||||
Q_PROPERTY(QString duration READ getDuration WRITE setDuration NOTIFY durationChanged)
|
||||
Q_PROPERTY(int duration READ getDuration NOTIFY durationChanged)
|
||||
|
||||
public:
|
||||
static QSharedPointer<CallHistoryCore> create(const std::shared_ptr<linphone::CallLog> &callLogs);
|
||||
|
|
@ -52,8 +52,10 @@ public:
|
|||
void setSelf(QSharedPointer<CallHistoryCore> me);
|
||||
ConferenceInfoGui *getConferenceInfoGui() const;
|
||||
|
||||
QString getDuration() const;
|
||||
void setDuration(const QString &duration);
|
||||
int getDuration() const;
|
||||
QString getDurationString() const;
|
||||
|
||||
QDateTime getStartDate() const;
|
||||
|
||||
void onRemoved(const std::shared_ptr<linphone::Friend> &updatedFriend);
|
||||
|
||||
|
|
@ -68,13 +70,15 @@ public:
|
|||
QString mCallId;
|
||||
|
||||
signals:
|
||||
void durationChanged(QString duration);
|
||||
void durationChanged(int duration);
|
||||
void durationStringChanged(QString duration);
|
||||
void displayNameChanged();
|
||||
void friendUpdated(); // When a friend is created, this log is linked to it.
|
||||
void removed();
|
||||
|
||||
private:
|
||||
QString mDuration;
|
||||
int mDuration;
|
||||
QString mDurationString;
|
||||
QSharedPointer<ConferenceInfoCore> mConferenceInfo = nullptr;
|
||||
std::shared_ptr<CallHistoryModel> mCallHistoryModel;
|
||||
std::shared_ptr<FriendModel> mFriendModel;
|
||||
|
|
|
|||
|
|
@ -56,11 +56,11 @@ CallHistoryList::~CallHistoryList() {
|
|||
void CallHistoryList::setSelf(QSharedPointer<CallHistoryList> me) {
|
||||
mModelConnection = SafeConnection<CallHistoryList, CoreModel>::create(me, CoreModel::getInstance());
|
||||
|
||||
mModelConnection->makeConnectToCore(&CallHistoryList::lUpdate, [this]() {
|
||||
clearData();
|
||||
emit listAboutToBeReset();
|
||||
mModelConnection->makeConnectToCore(&CallHistoryList::lUpdate, [this](bool signalReset) {
|
||||
mustBeInMainThread(log().arg(Q_FUNC_INFO));
|
||||
if (signalReset) emit listAboutToBeReset();
|
||||
mModelConnection->invokeToModel([this]() {
|
||||
mustBeInLinphoneThread(getClassName());
|
||||
mustBeInLinphoneThread(Q_FUNC_INFO);
|
||||
// Avoid copy to lambdas
|
||||
QList<QSharedPointer<CallHistoryCore>> *callLogs = new QList<QSharedPointer<CallHistoryCore>>();
|
||||
std::list<std::shared_ptr<linphone::CallLog>> linphoneCallLogs;
|
||||
|
|
@ -73,8 +73,13 @@ void CallHistoryList::setSelf(QSharedPointer<CallHistoryList> me) {
|
|||
callLogs->push_front(model);
|
||||
}
|
||||
mModelConnection->invokeToCore([this, callLogs]() {
|
||||
mustBeInMainThread(getClassName());
|
||||
resetData<CallHistoryCore>(*callLogs);
|
||||
mustBeInMainThread(Q_FUNC_INFO);
|
||||
beginResetModel();
|
||||
mList.clear();
|
||||
for (auto &item : *callLogs) {
|
||||
mList.append(item);
|
||||
}
|
||||
endResetModel();
|
||||
delete callLogs;
|
||||
});
|
||||
});
|
||||
|
|
@ -84,21 +89,24 @@ void CallHistoryList::setSelf(QSharedPointer<CallHistoryList> me) {
|
|||
mModelConnection->makeConnectToModel(
|
||||
&CoreModel::callLogUpdated,
|
||||
[this](const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::CallLog> &callLog) {
|
||||
QSharedPointer<CallHistoryCore> *callLogs = new QSharedPointer<CallHistoryCore>[1];
|
||||
auto model = createCallHistoryCore(callLog);
|
||||
callLogs[0] = model;
|
||||
mModelConnection->invokeToCore([this, callLogs]() {
|
||||
auto oldLog = std::find_if(mList.begin(), mList.end(), [callLogs](QSharedPointer<QObject> log) {
|
||||
return (*callLogs)->mCallId == log.objectCast<CallHistoryCore>()->mCallId;
|
||||
});
|
||||
toConnect(callLogs->get());
|
||||
if (oldLog == mList.end()) { // New
|
||||
prepend(*callLogs);
|
||||
} else { // Update (status, duration, etc …)
|
||||
replace(oldLog->objectCast<CallHistoryCore>(), *callLogs);
|
||||
}
|
||||
delete[] callLogs;
|
||||
});
|
||||
if (!callLog->getLocalAddress()->weakEqual(
|
||||
CoreModel::getInstance()->getCore()->getDefaultAccount()->getParams()->getIdentityAddress())) {
|
||||
lInfo() << "call log does not refer to current account, return";
|
||||
return;
|
||||
}
|
||||
emit lUpdate(false);
|
||||
// auto callLogCore = createCallHistoryCore(callLog);
|
||||
// mModelConnection->invokeToCore([this, callLogCore]() {
|
||||
// auto oldLog = std::find_if(mList.begin(), mList.end(), [callLogCore](QSharedPointer<QObject> log) {
|
||||
// return (callLogCore)->mCallId == log.objectCast<CallHistoryCore>()->mCallId;
|
||||
// });
|
||||
// toConnect(callLogCore.get());
|
||||
// if (oldLog == mList.end()) { // New
|
||||
// prepend(callLogCore);
|
||||
// } else { // Update (status, duration, etc …)
|
||||
// replace(oldLog->objectCast<CallHistoryCore>(), callLogCore);
|
||||
// }
|
||||
// });
|
||||
});
|
||||
mModelConnection->makeConnectToCore(&CallHistoryList::lRemoveEntriesForAddress, [this](QString address) {
|
||||
mModelConnection->invokeToModel([this, address]() {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public:
|
|||
// void displayMore();
|
||||
|
||||
signals:
|
||||
void lUpdate();
|
||||
void lUpdate(bool signalReset = true);
|
||||
void lRemoveEntriesForAddress(QString address);
|
||||
void lRemoveAllEntries();
|
||||
void listAboutToBeReset();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue