diff --git a/linphone-app/src/components/timeline/TimelineListModel.cpp b/linphone-app/src/components/timeline/TimelineListModel.cpp index be4366522..23ad03a05 100644 --- a/linphone-app/src/components/timeline/TimelineListModel.cpp +++ b/linphone-app/src/components/timeline/TimelineListModel.cpp @@ -120,7 +120,7 @@ bool TimelineListModel::removeRows (int row, int count, const QModelIndex &paren for(auto timeline : oldTimelines) if(timeline->mSelected) timeline->setSelected(false); - + emit countChanged(); return true; } @@ -137,7 +137,7 @@ std::shared_ptr TimelineListModel::getTimeline(std::shared_ptr
  • model = TimelineModel::create(chatRoom); //std::shared_ptr model = std::make_shared(chatRoom); - connect(model.get(), SIGNAL(selectedChanged(bool)), this, SLOT(selectedHasChanged(bool))); + connect(model.get(), SIGNAL(selectedChanged(bool)), this, SLOT(onSelectedHasChanged(bool))); connect(model->getChatRoomModel(), &ChatRoomModel::allEntriesRemoved, this, &TimelineListModel::removeChatRoomModel); add(model); //connect(model.get(), SIGNAL(conferenceLeft()), this, SLOT(selectedHasChanged(bool))); @@ -179,7 +179,7 @@ std::shared_ptr TimelineListModel::getChatRoomModel(std::shared_p if(create){ std::shared_ptr model = TimelineModel::create(chatRoom); if(model){ - connect(model.get(), SIGNAL(selectedChanged(bool)), this, SLOT(selectedHasChanged(bool))); + connect(model.get(), SIGNAL(selectedChanged(bool)), this, SLOT(onSelectedHasChanged(bool))); connect(model->getChatRoomModel(), &ChatRoomModel::allEntriesRemoved, this, &TimelineListModel::removeChatRoomModel); //connect(model.get(), SIGNAL(conferenceLeft()), this, SLOT(selectedHasChanged(bool))); @@ -199,6 +199,9 @@ std::shared_ptr TimelineListModel::getChatRoomModel(ChatRoomModel return nullptr; } +int TimelineListModel::getCount() const{ + return mTimelines.size(); +} //------------------------------------------------------------------------------------------------- @@ -210,7 +213,7 @@ void TimelineListModel::setSelectedCount(int selectedCount){ } } -void TimelineListModel::selectedHasChanged(bool selected){ +void TimelineListModel::onSelectedHasChanged(bool selected){ if(selected) { if(mSelectedCount >= 1){// We have more selection than wanted : count select first and unselect after : the final signal will be send only on limit setSelectedCount(mSelectedCount+1);// It will not send a change signal @@ -219,6 +222,7 @@ void TimelineListModel::selectedHasChanged(bool selected){ (*it)->setSelected(false); }else setSelectedCount(mSelectedCount+1); + emit selectedChanged(qobject_cast(sender())); } else setSelectedCount(mSelectedCount-1); } @@ -266,7 +270,7 @@ void TimelineListModel::updateTimelines () { std::shared_ptr model = TimelineModel::create(dbChatRoom); if( model){ - connect(model.get(), SIGNAL(selectedChanged(bool)), this, SLOT(selectedHasChanged(bool))); + connect(model.get(), SIGNAL(selectedChanged(bool)), this, SLOT(onSelectedHasChanged(bool))); connect(model->getChatRoomModel(), &ChatRoomModel::allEntriesRemoved, this, &TimelineListModel::removeChatRoomModel); add(model); } @@ -281,6 +285,7 @@ void TimelineListModel::add (std::shared_ptr timeline){ mTimelines << timeline; endInsertRows(); resetInternalData(); + emit countChanged(); } void TimelineListModel::remove (TimelineModel* model) { @@ -311,7 +316,7 @@ void TimelineListModel::onChatRoomStateChanged(const std::shared_ptr model = TimelineModel::create(chatRoom); if(model){ - connect(model.get(), SIGNAL(selectedChanged(bool)), this, SLOT(selectedHasChanged(bool))); + connect(model.get(), SIGNAL(selectedChanged(bool)), this, SLOT(onSelectedHasChanged(bool))); connect(model->getChatRoomModel(), &ChatRoomModel::allEntriesRemoved, this, &TimelineListModel::removeChatRoomModel); add(model); } diff --git a/linphone-app/src/components/timeline/TimelineListModel.hpp b/linphone-app/src/components/timeline/TimelineListModel.hpp index ebbcdfc5f..0069d63fe 100644 --- a/linphone-app/src/components/timeline/TimelineListModel.hpp +++ b/linphone-app/src/components/timeline/TimelineListModel.hpp @@ -32,6 +32,7 @@ class TimelineListModel : public QAbstractListModel { public: Q_PROPERTY(int selectedCount MEMBER mSelectedCount WRITE setSelectedCount NOTIFY selectedCountChanged) + Q_PROPERTY(int count READ getCount NOTIFY countChanged) TimelineListModel (QObject *parent = Q_NULLPTR); @@ -42,6 +43,7 @@ public: Q_INVOKABLE QVariantList getLastChatRooms(const int& maxCount) const; std::shared_ptr getChatRoomModel(std::shared_ptr chatRoom, const bool &create); std::shared_ptr getChatRoomModel(ChatRoomModel * chatRoom); + int getCount() const; int rowCount (const QModelIndex &index = QModelIndex()) const override; @@ -58,14 +60,16 @@ public: public slots: void update(); void removeChatRoomModel(std::shared_ptr model); - void selectedHasChanged(bool selected); + void onSelectedHasChanged(bool selected); void onChatRoomStateChanged(const std::shared_ptr &chatRoom,linphone::ChatRoom::State state); //void onConferenceLeft(); signals: + void countChanged(); void selectedCountChanged(int selectedCount); + void selectedChanged(TimelineModel * timelineModel); void updated(); private: diff --git a/linphone-app/src/components/timeline/TimelineProxyModel.cpp b/linphone-app/src/components/timeline/TimelineProxyModel.cpp index d161717f8..bdae545fb 100644 --- a/linphone-app/src/components/timeline/TimelineProxyModel.cpp +++ b/linphone-app/src/components/timeline/TimelineProxyModel.cpp @@ -42,6 +42,8 @@ TimelineProxyModel::TimelineProxyModel (QObject *parent) : QSortFilterProxyModel connect(model, SIGNAL(selectedCountChanged(int)), this, SIGNAL(selectedCountChanged(int))); connect(model, &TimelineListModel::updated, this, &TimelineProxyModel::invalidate); + connect(model, &TimelineListModel::selectedChanged, this, &TimelineProxyModel::selectedChanged); + connect(model, &TimelineListModel::countChanged, this, &TimelineProxyModel::countChanged); setSourceModel(model); @@ -59,27 +61,11 @@ TimelineProxyModel::TimelineProxyModel (QObject *parent) : QSortFilterProxyModel } // ----------------------------------------------------------------------------- -/* -void TimelineProxyModel::setCurrentChatRoomModel(ChatRoomModel *data){ - mCurrentChatRoomModel = CoreManager::getInstance()->getChatRoomModel(data); - emit currentChatRoomModelChanged(mCurrentChatRoomModel); - if(mCurrentChatRoomModel) - emit currentTimelineChanged(dynamic_cast(sourceModel())->getTimeline(mCurrentChatRoomModel->getChatRoom(), false).get()); - else - emit currentTimelineChanged(nullptr); + +int TimelineProxyModel::getCount() const{ + return dynamic_cast(sourceModel())->getCount(); } -ChatRoomModel *TimelineProxyModel::getCurrentChatRoomModel()const{ - return mCurrentChatRoomModel.get(); -} - -void TimelineProxyModel::updateCurrentSelection(){ - auto currentAddress = CoreManager::getInstance()->getAccountSettingsModel()->getUsedSipAddress(); - if(mCurrentChatRoomModel && !mCurrentChatRoomModel->getChatRoom()->getMe()->getAddress()->weakEqual(currentAddress) ){ - setCurrentChatRoomModel(nullptr); - } -} -*/ void TimelineProxyModel::unselectAll(){ dynamic_cast(sourceModel())->selectAll(false); } diff --git a/linphone-app/src/components/timeline/TimelineProxyModel.hpp b/linphone-app/src/components/timeline/TimelineProxyModel.hpp index 4240257c9..4bced99f6 100644 --- a/linphone-app/src/components/timeline/TimelineProxyModel.hpp +++ b/linphone-app/src/components/timeline/TimelineProxyModel.hpp @@ -29,9 +29,9 @@ class TimelineModel; class TimelineProxyModel : public QSortFilterProxyModel { - Q_OBJECT - - + Q_OBJECT + + public: enum TimelineFilter { SimpleChatRoom=1, @@ -44,44 +44,41 @@ public: }; Q_ENUM(TimelineFilter) - TimelineProxyModel (QObject *parent = Q_NULLPTR); - - Q_PROPERTY(int filterFlags MEMBER mFilterFlags WRITE setFilterFlags NOTIFY filterFlagsChanged) - Q_PROPERTY(QString filterText MEMBER mFilterText WRITE setFilterText NOTIFY filterTextChanged) - - //Q_PROPERTY(ChatRoomModel *currentChatRoomModel WRITE setCurrentChatRoomModel READ getCurrentChatRoomModel NOTIFY currentChatRoomModelChanged) - - //void updateCurrentSelection(); - - //Q_INVOKABLE void setCurrentChatRoomModel(ChatRoomModel *data); - //ChatRoomModel *getCurrentChatRoomModel() const; - Q_INVOKABLE void unselectAll(); - Q_INVOKABLE void setFilterFlags(const int& filterFlags); - Q_INVOKABLE void setFilterText(const QString& text); - //Q_INVOKABLE TimelineModel * getTimeline(); - + TimelineProxyModel (QObject *parent = Q_NULLPTR); + + Q_PROPERTY(int filterFlags MEMBER mFilterFlags WRITE setFilterFlags NOTIFY filterFlagsChanged) + Q_PROPERTY(QString filterText MEMBER mFilterText WRITE setFilterText NOTIFY filterTextChanged) + Q_PROPERTY(int count READ getCount NOTIFY countChanged) + + int getCount() const; + + Q_INVOKABLE void unselectAll(); + Q_INVOKABLE void setFilterFlags(const int& filterFlags); + Q_INVOKABLE void setFilterText(const QString& text); + //Q_INVOKABLE TimelineModel * getTimeline(); + signals: - void selectedCountChanged(int selectedCount); - void filterFlagsChanged(); - void filterTextChanged(); -// void currentChatRoomModelChanged(std::shared_ptr currentChatRoomModel); -// void currentTimelineChanged(TimelineModel * currentTimeline); - + void countChanged(); + void selectedCountChanged(int selectedCount); + void selectedChanged(TimelineModel * timelineModel); + void filterFlagsChanged(); + void filterTextChanged(); + protected: - - bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override; - bool lessThan (const QModelIndex &left, const QModelIndex &right) const override; - - QString getLocalAddress () const; - QString getCleanedLocalAddress () const; - void handleLocalAddressChanged (const QString &localAddress); - + + bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override; + bool lessThan (const QModelIndex &left, const QModelIndex &right) const override; + + QString getLocalAddress () const; + QString getCleanedLocalAddress () const; + void handleLocalAddressChanged (const QString &localAddress); + private: int mFilterFlags = 0; QString mFilterText; - //std::shared_ptr mCurrentChatRoomModel; - + //std::shared_ptr mCurrentChatRoomModel; + }; #endif // TIMELINE_PROXY_MODEL_H_ diff --git a/linphone-app/ui/modules/Common/View/ScrollableListView.qml b/linphone-app/ui/modules/Common/View/ScrollableListView.qml index 77ce55b00..c70bf1e9b 100644 --- a/linphone-app/ui/modules/Common/View/ScrollableListView.qml +++ b/linphone-app/ui/modules/Common/View/ScrollableListView.qml @@ -1,4 +1,4 @@ -import QtQuick 2.7 +import QtQuick 2.12 //synchronousDrag import QtQuick.Controls 2.2 import Common 1.0 @@ -23,7 +23,8 @@ ListView { clip: true contentWidth: width - (vScrollBar.visible?vScrollBar.width:0) spacing: 0 - + synchronousDrag:true + maximumFlickVelocity:-1 // --------------------------------------------------------------------------- // TODO: Find a solution at this bug => diff --git a/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml b/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml index 359c40a99..cc11e9e58 100644 --- a/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml +++ b/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml @@ -23,16 +23,6 @@ Rectangle { //signal entrySelected (string entry) signal entrySelected (TimelineModel entry) - // --------------------------------------------------------------------------- - /* - function setSelectedEntry (peerAddress, localAddress) { - Logic.setSelectedEntry(peerAddress, localAddress) - } - - function resetSelectedEntry () { - Logic.resetSelectedEntry() - } -*/ // --------------------------------------------------------------------------- color: TimelineStyle.color @@ -49,9 +39,10 @@ Rectangle { onSelectedCountChanged:{ if(selectedCount<=0) { view.currentIndex = -1 - timeline.entrySelected('',false) + timeline.entrySelected('') } } + onSelectedChanged : if(timelineModel) timeline.entrySelected(timelineModel) // onCurrentTimelineChanged:entrySelected(currentTimeline) } /* @@ -71,6 +62,7 @@ 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 MouseArea{// no more showing history id:showHistory @@ -278,17 +270,19 @@ Rectangle { anchors.fill: parent onClicked: { //timeline.model.unselectAll() - if(modelData.selected) + if(modelData.selected)// Update selection timeline.entrySelected(modelData) modelData.selected = true view.currentIndex = index; } } + Connections{ target:modelData onSelectedChanged:{ - if(selected) - timeline.entrySelected(modelData) + if(selected) { + view.currentIndex = index; + } } } } diff --git a/linphone-app/ui/views/App/Main/MainWindow.qml b/linphone-app/ui/views/App/Main/MainWindow.qml index 57737b939..a4f988f1b 100644 --- a/linphone-app/ui/views/App/Main/MainWindow.qml +++ b/linphone-app/ui/views/App/Main/MainWindow.qml @@ -264,9 +264,9 @@ ApplicationWindow { visible: SettingsModel.contactsEnabled onSelected: { - timeline.model.unselectAll() - setView('Contacts') - } + timeline.model.unselectAll() + setView('Contacts') + } Icon{ anchors.right:parent.right anchors.verticalCenter: parent.verticalCenter @@ -285,7 +285,7 @@ ApplicationWindow { iconSize: 32 name: 'MES CONFERENCES' - onSelected: setView('HistoryView') + onSelected: window.setView('HistoryView') } } @@ -297,14 +297,18 @@ ApplicationWindow { Layout.fillWidth: true model: TimelineProxyModel{} - onEntrySelected:{ (entry?setView('Conversation', { - chatRoomModel:entry.chatRoomModel - - }): - //setView('HistoryView', {})) - setView('Home', {})) - menu.resetSelectedEntry() - } + onEntrySelected:{ + if( entry ) { + window.setView('Conversation', { + chatRoomModel:entry.chatRoomModel + + }) + }else{ + + window.setView('Home', {}) + } + menu.resetSelectedEntry() + } } } @@ -318,6 +322,7 @@ ApplicationWindow { Layout.fillWidth: true source: 'Home.qml' + Component.onCompleted: if (AccountSettingsModel.accounts.length < 2) source= 'Assistant.qml' // default proxy = 1. Do not use this set diretly in source because of bindings that will override next setSource } } }