mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
Check on list size before adding/prepending items in list.
Fix disabled account that still receive messages (use message-expires=0). Still need an update from SDK to take account of the new contact parameters on unREGISTER. Fix bad contact parameters after trying to overwrite them. Avoid to reload all timeline on sorting changes (incoming message, new events). Fix layout margins in chat message.
This commit is contained in:
parent
ee8a6ab970
commit
b0bfd27cbf
10 changed files with 97 additions and 43 deletions
|
|
@ -69,12 +69,14 @@ public:
|
|||
emit dataChanged(lastIndex,lastIndex );
|
||||
}
|
||||
virtual void add(QList<T> items){
|
||||
auto firstIndex = index(mList.size()-1,0);
|
||||
beginInsertRows(QModelIndex(), mList.size(), mList.size() + items.size()-1);
|
||||
mList << items;
|
||||
endInsertRows();
|
||||
auto lastIndex = index(mList.size()-1,0);
|
||||
emit dataChanged(firstIndex,lastIndex);
|
||||
if(items.size() > 0) {
|
||||
QModelIndex firstIndex = mList.size() > 0 ? index(mList.size()-1,0) : index(0,0);
|
||||
beginInsertRows(QModelIndex(), mList.size(), mList.size() + items.size()-1);
|
||||
mList << items;
|
||||
endInsertRows();
|
||||
auto lastIndex = index(mList.size()-1,0);
|
||||
emit dataChanged(firstIndex,lastIndex);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void prepend(T item){
|
||||
|
|
@ -85,11 +87,13 @@ public:
|
|||
}
|
||||
|
||||
virtual void prepend(QList<T> items){
|
||||
beginInsertRows(QModelIndex(), 0, items.size()-1);
|
||||
items << mList;
|
||||
mList = items;
|
||||
endInsertRows();
|
||||
emit dataChanged(index(0),index(items.size()-1));
|
||||
if(items.size() > 0){
|
||||
beginInsertRows(QModelIndex(), 0, items.size()-1);
|
||||
items << mList;
|
||||
mList = items;
|
||||
endInsertRows();
|
||||
emit dataChanged(index(0),index(items.size()-1));
|
||||
}
|
||||
}
|
||||
|
||||
// Remove functions
|
||||
|
|
|
|||
|
|
@ -65,13 +65,15 @@ public:
|
|||
|
||||
template <class T>
|
||||
void add(QList<QSharedPointer<T>> items){
|
||||
auto firstIndex = index(mList.size()-1,0);
|
||||
beginInsertRows(QModelIndex(), mList.size(), mList.size() + items.size() - 1);
|
||||
for(auto i : items)
|
||||
mList << i.template objectCast<QObject>();
|
||||
endInsertRows();
|
||||
auto lastIndex = index(mList.size()-1,0);
|
||||
emit dataChanged(firstIndex,lastIndex);
|
||||
if(items.size() > 0){
|
||||
QModelIndex firstIndex = mList.size() > 0 ? index(mList.size()-1,0) : index(0,0);
|
||||
beginInsertRows(QModelIndex(), mList.size(), mList.size() + items.size() - 1);
|
||||
for(auto i : items)
|
||||
mList << i.template objectCast<QObject>();
|
||||
endInsertRows();
|
||||
auto lastIndex = index(mList.size()-1,0);
|
||||
emit dataChanged(firstIndex,lastIndex);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
|
@ -81,11 +83,13 @@ public:
|
|||
|
||||
template <class T>
|
||||
void prepend(QList<QSharedPointer<T>> items){
|
||||
beginInsertRows(QModelIndex(), 0, items.size()-1);
|
||||
items << mList;
|
||||
mList = items;
|
||||
endInsertRows();
|
||||
emit dataChanged(index(0),index(items.size()-1));
|
||||
if(items.size() > 0){
|
||||
beginInsertRows(QModelIndex(), 0, items.size()-1);
|
||||
items << mList;
|
||||
mList = items;
|
||||
endInsertRows();
|
||||
emit dataChanged(index(0),index(items.size()-1));
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool remove(QObject *itemToRemove) override{
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ void AccountSettingsModel::removeAccount (const shared_ptr<linphone::Account> &a
|
|||
}
|
||||
// "message-expires" is used to keep contact for messages. Setting to 0 will remove the contact for messages too.
|
||||
// Check if a "message-expires" exists and set it to 0
|
||||
QStringList parameters = Utils::coreStringToAppString(account->getParams()->getContactParameters()).split(";");
|
||||
QStringList parameters = Utils::coreStringToAppString(account->getParams()->getContactParameters()).split(";", Qt::SkipEmptyParts);
|
||||
for(int i = 0 ; i < parameters.size() ; ++i){
|
||||
QStringList fields = parameters[i].split("=");
|
||||
if( fields.size() > 1 && fields[0].simplified() == "message-expires"){
|
||||
|
|
@ -352,13 +352,38 @@ bool AccountSettingsModel::addOrUpdateAccount(
|
|||
txt = data["videoConferenceUri"].toString();
|
||||
accountParams->setAudioVideoConferenceFactoryAddress(Utils::interpretUrl(txt));
|
||||
accountParams->setLimeServerUrl(Utils::appStringToCoreString(data["limeServerUrl"].toString()));
|
||||
|
||||
|
||||
QString contactParameters = Utils::coreStringToAppString(accountParams->getContactParameters());
|
||||
if(data.contains("contactParams"))
|
||||
accountParams->setContactParameters(Utils::appStringToCoreString(data["contactParams"].toString()));
|
||||
contactParameters = data["contactParams"].toString();
|
||||
if(data.contains("avpfInterval"))
|
||||
accountParams->setAvpfRrInterval(uint8_t(data["avpfInterval"].toInt()));
|
||||
if(data.contains("registerEnabled"))
|
||||
accountParams->enableRegister(data["registerEnabled"].toBool());
|
||||
if(data.contains("registerEnabled")){
|
||||
bool registerEnabled = data["registerEnabled"].toBool();
|
||||
|
||||
bool findMessageExpires = false;
|
||||
QStringList parameters = contactParameters.split(";", Qt::SkipEmptyParts);
|
||||
for(int i = 0 ; i < parameters.size() ; ++i){
|
||||
QStringList fields = parameters[i].split("=");
|
||||
if( fields.size() > 1 && fields[0].simplified() == "message-expires"){
|
||||
findMessageExpires = true;
|
||||
if(!registerEnabled)// replace message-expires by 0 in order to not get new incoming messages.
|
||||
parameters[i] = Constants::DefaultContactParametersOnRemove;
|
||||
else if(!accountParams->registerEnabled() && fields[1].toInt() == 0)
|
||||
parameters[i] = Constants::DefaultContactParameters;
|
||||
}
|
||||
}
|
||||
if(!findMessageExpires){
|
||||
if(!registerEnabled)// message-expires was not found we need to disable the account.
|
||||
parameters.push_back(Constants::DefaultContactParametersOnRemove);
|
||||
else if(!accountParams->registerEnabled())// Switch on
|
||||
parameters.push_back(Constants::DefaultContactParameters);
|
||||
}
|
||||
accountParams->setContactParameters(Utils::appStringToCoreString(parameters.join(";")));
|
||||
accountParams->enableRegister(registerEnabled);
|
||||
}else{
|
||||
accountParams->setContactParameters(Utils::appStringToCoreString(contactParameters));
|
||||
}
|
||||
if(data.contains("publishPresence")) {
|
||||
newPublishPresence = accountParams->publishEnabled() != data["publishPresence"].toBool();
|
||||
accountParams->enablePublish(data["publishPresence"].toBool());
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ TimelineListModel::TimelineListModel (QObject *parent) : ProxyListModel(parent)
|
|||
connect(coreHandlers, &CoreHandlers::chatRoomRead, this, &TimelineListModel::onChatRoomRead);
|
||||
connect(coreHandlers, &CoreHandlers::chatRoomStateChanged, this, &TimelineListModel::onChatRoomStateChanged);
|
||||
connect(coreHandlers, &CoreHandlers::messagesReceived, this, &TimelineListModel::update);
|
||||
connect(coreHandlers, &CoreHandlers::messagesReceived, this, &TimelineListModel::updated);
|
||||
|
||||
QObject::connect(coreHandlers, &CoreHandlers::callStateChanged, this, &TimelineListModel::onCallStateChanged);
|
||||
QObject::connect(coreHandlers, &CoreHandlers::callCreated, this, &TimelineListModel::onCallCreated);
|
||||
|
|
@ -61,7 +60,6 @@ TimelineListModel::TimelineListModel(const TimelineListModel* model){
|
|||
connect(coreHandlers, &CoreHandlers::chatRoomRead, this, &TimelineListModel::onChatRoomRead);
|
||||
connect(coreHandlers, &CoreHandlers::chatRoomStateChanged, this, &TimelineListModel::onChatRoomStateChanged);
|
||||
connect(coreHandlers, &CoreHandlers::messagesReceived, this, &TimelineListModel::update);
|
||||
connect(coreHandlers, &CoreHandlers::messagesReceived, this, &TimelineListModel::updated);
|
||||
|
||||
QObject::connect(coreHandlers, &CoreHandlers::callStateChanged, this, &TimelineListModel::onCallStateChanged);
|
||||
QObject::connect(coreHandlers, &CoreHandlers::callCreated, this, &TimelineListModel::onCallCreated);
|
||||
|
|
@ -71,7 +69,8 @@ TimelineListModel::TimelineListModel(const TimelineListModel* model){
|
|||
for(auto item : model->mList) {
|
||||
auto newItem = qobject_cast<TimelineModel*>(item)->clone();
|
||||
connect(newItem.get(), SIGNAL(selectedChanged(bool)), this, SLOT(onSelectedHasChanged(bool)));
|
||||
connect(newItem.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onChatRoomDeleted);
|
||||
connect(newItem.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onTimelineDeleted);
|
||||
connect(newItem.get(), &TimelineModel::dataChanged, this, &TimelineListModel::onTimelineDataChanged);
|
||||
mList << newItem;
|
||||
}
|
||||
}
|
||||
|
|
@ -325,7 +324,7 @@ void TimelineListModel::updateTimelines () {
|
|||
}
|
||||
}
|
||||
}
|
||||
qInfo() << "Timelines adding :" << stepsTimer.restart() << "ms.";
|
||||
qInfo() << "Timelines adding :" << stepsTimer.restart() << "ms for " << models.size() << " new timelines";
|
||||
add(models);
|
||||
qInfo() << "Timelines adding GUI :" << stepsTimer.restart() << "ms.";
|
||||
CoreManager::getInstance()->updateUnreadMessageCount();
|
||||
|
|
@ -335,8 +334,9 @@ void TimelineListModel::updateTimelines () {
|
|||
void TimelineListModel::add (QSharedPointer<TimelineModel> timeline){
|
||||
auto chatRoomModel = timeline->getChatRoomModel();
|
||||
auto chatRoom = chatRoomModel->getChatRoom();
|
||||
connect(timeline.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onChatRoomDeleted);
|
||||
connect(chatRoomModel, &ChatRoomModel::lastUpdateTimeChanged, this, &TimelineListModel::updated);
|
||||
connect(timeline.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onTimelineDeleted);
|
||||
connect(timeline.get(), &TimelineModel::dataChanged, this, &TimelineListModel::onTimelineDataChanged);
|
||||
|
||||
ProxyListModel::add(timeline);
|
||||
emit countChanged();
|
||||
}
|
||||
|
|
@ -345,11 +345,13 @@ void TimelineListModel::add (QList<QSharedPointer<TimelineModel>> timelines){
|
|||
for(auto timeline : timelines){
|
||||
auto chatRoomModel = timeline->getChatRoomModel();
|
||||
auto chatRoom = chatRoomModel->getChatRoom();
|
||||
connect(timeline.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onChatRoomDeleted);
|
||||
connect(chatRoomModel, &ChatRoomModel::lastUpdateTimeChanged, this, &TimelineListModel::updated);
|
||||
connect(timeline.get(), &TimelineModel::chatRoomDeleted, this, &TimelineListModel::onTimelineDeleted);
|
||||
connect(timeline.get(), &TimelineModel::dataChanged, this, &TimelineListModel::onTimelineDataChanged);
|
||||
}
|
||||
if(timelines.size() > 0) {
|
||||
ProxyListModel::add(timelines);
|
||||
emit countChanged();
|
||||
}
|
||||
ProxyListModel::add(timelines);
|
||||
emit countChanged();
|
||||
}
|
||||
|
||||
void TimelineListModel::removeChatRoomModel(QSharedPointer<ChatRoomModel> model){
|
||||
|
|
@ -467,6 +469,14 @@ void TimelineListModel::onCallCreated(const std::shared_ptr<linphone::Call> &cal
|
|||
}
|
||||
}
|
||||
|
||||
void TimelineListModel::onChatRoomDeleted(){
|
||||
void TimelineListModel::onTimelineDeleted(){
|
||||
remove(sender());// This will call removeRows()
|
||||
}
|
||||
|
||||
void TimelineListModel::onTimelineDataChanged(){
|
||||
int row = -1;
|
||||
get(sender(), &row);
|
||||
if(row >= 0){
|
||||
emit dataChanged(index(row),index(row));
|
||||
}
|
||||
}
|
||||
|
|
@ -67,13 +67,13 @@ public slots:
|
|||
void onChatRoomStateChanged(const std::shared_ptr<linphone::ChatRoom> &chatRoom,linphone::ChatRoom::State state);
|
||||
void onCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::Call::State state) ;
|
||||
void onCallCreated(const std::shared_ptr<linphone::Call> &call);
|
||||
void onChatRoomDeleted();
|
||||
void onTimelineDeleted();
|
||||
void onTimelineDataChanged();
|
||||
|
||||
signals:
|
||||
void countChanged();
|
||||
void selectedCountChanged(int selectedCount);
|
||||
void selectedChanged(TimelineModel * timelineModel);
|
||||
void updated();
|
||||
|
||||
private:
|
||||
virtual bool removeRows (int row, int count, const QModelIndex &parent) override;
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ TimelineModel::TimelineModel (std::shared_ptr<linphone::ChatRoom> chatRoom, cons
|
|||
QObject::connect(CoreManager::getInstance()->getAccountSettingsModel(), &AccountSettingsModel::defaultAccountChanged, this, &TimelineModel::onDefaultAccountChanged);
|
||||
QObject::connect(mChatRoomModel.get(), &ChatRoomModel::chatRoomDeleted, this, &TimelineModel::onChatRoomDeleted);
|
||||
QObject::connect(mChatRoomModel.get(), &ChatRoomModel::updatingChanged, this, &TimelineModel::updatingChanged);
|
||||
QObject::connect(mChatRoomModel.get(), &ChatRoomModel::lastUpdateTimeChanged, this, &TimelineModel::onChatRoomLastUpdateTimeChanged);
|
||||
QObject::connect(mChatRoomModel.get(), &ChatRoomModel::stateChanged, this, &TimelineModel::onChatRoomStateChanged);
|
||||
}
|
||||
if(chatRoom){
|
||||
|
|
@ -107,6 +108,7 @@ TimelineModel::TimelineModel(const TimelineModel * model){
|
|||
QObject::connect(mChatRoomModel.get(), &ChatRoomModel::chatRoomDeleted, this, &TimelineModel::onChatRoomDeleted);
|
||||
QObject::connect(mChatRoomModel.get(), &ChatRoomModel::updatingChanged, this, &TimelineModel::updatingChanged);
|
||||
QObject::connect(mChatRoomModel.get(), &ChatRoomModel::stateChanged, this, &TimelineModel::onChatRoomStateChanged);
|
||||
QObject::connect(mChatRoomModel.get(), &ChatRoomModel::lastUpdateTimeChanged, this, &TimelineModel::onChatRoomLastUpdateTimeChanged);
|
||||
}
|
||||
if(mChatRoomModel->getChatRoom()){
|
||||
mChatRoomListener = model->mChatRoomListener;
|
||||
|
|
@ -201,6 +203,10 @@ void TimelineModel::disconnectChatRoomListener(){
|
|||
}
|
||||
}
|
||||
|
||||
void TimelineModel::onChatRoomLastUpdateTimeChanged(){
|
||||
emit dataChanged();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
//------ CHAT ROOM HANDLERS
|
||||
//----------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ public slots:
|
|||
void onDefaultAccountChanged();
|
||||
void onChatRoomDeleted();
|
||||
void onChatRoomStateChanged();
|
||||
void onChatRoomLastUpdateTimeChanged();
|
||||
|
||||
signals:
|
||||
void fullPeerAddressChanged();
|
||||
|
|
@ -118,8 +119,10 @@ signals:
|
|||
void selectedChanged(bool selected);
|
||||
void conferenceLeft();
|
||||
void chatRoomDeleted();
|
||||
void dataChanged();
|
||||
void updatingChanged();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
bool mDelaySelection = false;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,6 @@ void TimelineProxyModel::setListSource(const TimelineListSource& source){
|
|||
model = source == Main ? CoreManager::getInstance()->getTimelineListModel() : CoreManager::getInstance()->getTimelineListModel()->clone();
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ Loader{// Use of Loader because of Repeater (items cannot be loaded dynamically)
|
|||
sourceComponent: Component{
|
||||
Column{
|
||||
id: mainComponent
|
||||
spacing: 0
|
||||
spacing: 5
|
||||
padding: 10
|
||||
function updateFilesBestWidth(){
|
||||
var newBestWidth = 0
|
||||
|
|
@ -164,12 +164,14 @@ Loader{// Use of Loader because of Repeater (items cannot be loaded dynamically)
|
|||
chatMessageModel: mainItem.chatMessageModel
|
||||
}
|
||||
ChatFileMessage{
|
||||
id: fileMessage
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: fitHeight
|
||||
Layout.preferredWidth: fitWidth
|
||||
Layout.maximumWidth: fitWidth
|
||||
Layout.maximumHeight: fitHeight
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
contentModel: $modelData
|
||||
onIsHoveringChanged: mainItem.isFileHoveringChanged(isHovering)
|
||||
borderWidth: mainItem.fileBorderWidth
|
||||
|
|
|
|||
|
|
@ -366,6 +366,7 @@ ApplicationWindow {
|
|||
Layout.fillWidth: true
|
||||
model: TimelineProxyModel{
|
||||
listSource: TimelineProxyModel.Main
|
||||
onListSourceChanged: console.log("listSourceChanged")
|
||||
}
|
||||
|
||||
onEntrySelected:{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue