Fix showing call history button and timeline filter buttons from data context.

This commit is contained in:
Julien Wadel 2022-03-16 10:34:06 +01:00
parent e7612e692a
commit d840e72956
8 changed files with 29 additions and 2 deletions

View file

@ -84,4 +84,5 @@ void ChatCallModel::update(){
void ChatCallModel::deleteEvent(){
CoreManager::getInstance()->getCore()->removeCallLog(mCallLog);
emit CoreManager::getInstance()->callLogsCountChanged();
}

View file

@ -337,8 +337,11 @@ void ChatRoomModel::removeAllEntries () {
( !standardChatEnabled || !isSecure())
) {
auto callLogs = CallsListModel::getCallHistory(getParticipantAddress(), Utils::coreStringToAppString(mChatRoom->getLocalAddress()->asStringUriOnly()));
bool haveLogs = callLogs.size() > 0;
for(auto callLog : callLogs)
core->removeCallLog(callLog);
if(haveLogs)
emit CoreManager::getInstance()->callLogsCountChanged();
}
endResetModel();
emit allEntriesRemoved(mSelf.lock());

View file

@ -80,6 +80,10 @@ void CoreHandlers::onCallEncryptionChanged (
emit callEncryptionChanged(call);
}
void CoreHandlers::onCallLogUpdated(const std::shared_ptr<linphone::Core> & core, const std::shared_ptr<linphone::CallLog> & callLog){
emit callLogUpdated(callLog);
}
void CoreHandlers::onCallStateChanged (
const shared_ptr<linphone::Core> &,
const shared_ptr<linphone::Call> &call,

View file

@ -41,6 +41,7 @@ public:
signals:
void authenticationRequested (const std::shared_ptr<linphone::AuthInfo> &authInfo);
void callEncryptionChanged (const std::shared_ptr<linphone::Call> &call);
void callLogUpdated(const std::shared_ptr<linphone::CallLog> &call);
void callStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::Call::State state);
void callTransferFailed (const std::shared_ptr<linphone::Call> &call);
void callTransferSucceeded (const std::shared_ptr<linphone::Call> &call);
@ -76,6 +77,8 @@ private:
bool on,
const std::string &authenticationToken
) override;
void onCallLogUpdated(const std::shared_ptr<linphone::Core> & core, const std::shared_ptr<linphone::CallLog> & callLog) override;
void onCallStateChanged (
const std::shared_ptr<linphone::Core> &core,

View file

@ -76,6 +76,8 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) :
QObject::connect(coreHandlers, &CoreHandlers::coreStarted, this, &CoreManager::initCoreManager, Qt::QueuedConnection);
QObject::connect(coreHandlers, &CoreHandlers::coreStopped, this, &CoreManager::stopIterate, Qt::QueuedConnection);
QObject::connect(coreHandlers, &CoreHandlers::logsUploadStateChanged, this, &CoreManager::handleLogsUploadStateChanged);
QObject::connect(coreHandlers, &CoreHandlers::callLogUpdated, this, &CoreManager::callLogsCountChanged);
QTimer::singleShot(10, [this, configPath](){// Delay the creation in order to have the CoreManager instance set before
createLinphoneCore(configPath);
});
@ -354,6 +356,9 @@ QString CoreManager::getVersion () const {
int CoreManager::getEventCount () const {
return mEventCountNotifier ? mEventCountNotifier->getEventCount() : 0;
}
int CoreManager::getCallLogsCount() const{
return mCore->getCallLogs().size();
}
int CoreManager::getMissedCallCount(const QString &peerAddress, const QString &localAddress)const{
return mEventCountNotifier ? mEventCountNotifier->getMissedCallCount(peerAddress, localAddress) : 0;
}

View file

@ -56,6 +56,7 @@ class CoreManager : public QObject {
Q_PROPERTY(QString version READ getVersion CONSTANT)
Q_PROPERTY(QString downloadUrl READ getDownloadUrl CONSTANT)
Q_PROPERTY(int eventCount READ getEventCount NOTIFY eventCountChanged)
Q_PROPERTY(int callLogsCount READ getCallLogsCount NOTIFY callLogsCountChanged)
public:
bool started () const {
@ -166,6 +167,7 @@ public:
Q_INVOKABLE void sendLogs () const;
Q_INVOKABLE void cleanLogs () const;
int getCallLogsCount() const;
int getMissedCallCount(const QString &peerAddress, const QString &localAddress) const;// Get missed call count from a chat (useful for showing bubbles on Timelines)
int getMissedCallCountFromLocal(const QString &localAddress) const;// Get missed call count from a chat (useful for showing bubbles on Timelines)
@ -193,6 +195,7 @@ signals:
void logsUploaded (const QString &url);
void eventCountChanged ();
void callLogsCountChanged();
private:
CoreManager (QObject *parent, const QString &configPath);

View file

@ -133,6 +133,7 @@ bool HistoryModel::removeRows (int row, int count, const QModelIndex &parent) {
emit allEntriesRemoved();
else if (limit == mEntries.count())
emit lastEntryRemoved();
emit CoreManager::getInstance()->callLogsCountChanged();
emit focused();// Removing rows is like having focus. Don't wait asynchronous events.
return true;
}
@ -174,6 +175,7 @@ void HistoryModel::removeAllEntries () {
endResetModel();
emit allEntriesRemoved();
emit CoreManager::getInstance()->callLogsCountChanged();
emit focused();// Removing all entries is like having focus. Don't wait asynchronous events.
}

View file

@ -20,9 +20,10 @@ Rectangle {
property alias model: view.model
property string _selectedSipAddress
property bool showHistoryButton : true
property bool showHistoryButton : CoreManager.callLogsCount
property bool updateSelectionModels : true
property bool isFilterVisible: searchView.visible || showFilterView
property bool showFiltersButtons: view.count > 0 || timeline.isFilterVisible || timeline.model.filterFlags > 0
// ---------------------------------------------------------------------------
@ -62,11 +63,13 @@ Rectangle {
Layout.preferredHeight: TimelineStyle.legend.height
Layout.alignment: Qt.AlignTop
color: showHistory.containsMouse?TimelineStyle.legend.backgroundColor.hovered:TimelineStyle.legend.backgroundColor.normal
visible:view.count > 0 || timeline.isFilterVisible || timeline.model.filterFlags > 0
visible: showHistoryButton || showFiltersButtons
//visible:view.count > 0 || timeline.isFilterVisible || timeline.model.filterFlags > 0 || CoreManager.eventCount > 0
MouseArea{// no more showing history
id:showHistory
anchors.fill:parent
visible: showFiltersButtons
onClicked: {
timeline.showFilterView = !timeline.showFilterView
}
@ -78,6 +81,7 @@ Rectangle {
Layout.preferredHeight: parent.height
Layout.fillWidth: true
Layout.leftMargin: TimelineStyle.legend.leftMargin
visible: showFiltersButtons
color: TimelineStyle.legend.color
font.pointSize: TimelineStyle.legend.pointSize
//: A title for filtering mode.
@ -96,6 +100,7 @@ Rectangle {
icon: 'filter_params_custom'
iconSize: TimelineStyle.legend.iconSize
overwriteColor: TimelineStyle.legend.color
visible: showFiltersButtons
MouseArea{
anchors.fill:parent
onClicked:{
@ -107,6 +112,7 @@ Rectangle {
Layout.alignment: Qt.AlignRight
Layout.fillHeight: true
Layout.preferredWidth: TimelineStyle.legend.iconSize
visible: showFiltersButtons
onClicked:{
searchView.visible = !searchView.visible
}