diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.0) -set(PIM_VERSION "5.8.80") +set(PIM_VERSION "5.8.81") if (POLICY CMP0053) cmake_policy(SET CMP0053 NEW) diff --git a/messagelist/src/pane.h b/messagelist/src/pane.h --- a/messagelist/src/pane.h +++ b/messagelist/src/pane.h @@ -335,6 +335,8 @@ * If the specified folder is not open yet then behaviour * depends on the preferEmptyTab value as follows. * + * @param etmIndex the index for the collection in the EntityTreeModel (source model) + * * If preferEmptyTab is set to false then the (new) folder is loaded * in the current tab. If preferEmptyTab is set to true then the (new) folder is * loaded in the first empty tab (or a new one if there are no empty ones). @@ -347,7 +349,9 @@ * like "loading..." */ void setCurrentFolder( - const Akonadi::Collection &fld, bool preferEmptyTab = false, MessageList::Core::PreSelectionMode preSelectionMode = MessageList::Core::PreSelectLastSelected, + const Akonadi::Collection &fld, + const QModelIndex &etmIndex, + bool preferEmptyTab = false, MessageList::Core::PreSelectionMode preSelectionMode = MessageList::Core::PreSelectLastSelected, const QString &overrideLabel = QString()); void resetModelStorage(); @@ -434,8 +438,6 @@ void restoreHeaderSettings(int index); void readConfig(bool restoreSession); - Q_PRIVATE_SLOT(d, void onSelectionChanged(const QItemSelection &, const QItemSelection &)) - bool eventFilter(QObject *obj, QEvent *event) override; class Private; diff --git a/messagelist/src/pane.cpp b/messagelist/src/pane.cpp --- a/messagelist/src/pane.cpp +++ b/messagelist/src/pane.cpp @@ -68,7 +68,7 @@ { } - void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); + void setCurrentFolder(const QModelIndex &etmIndex); void onNewTabClicked(); void onCloseTabClicked(); void activateTab(); @@ -84,7 +84,6 @@ void changeQuicksearchVisibility(bool); void addActivateTabAction(int i); void slotTabCloseRequested(int index); - QItemSelection mapSelectionToSource(const QItemSelection &selection) const; QItemSelection mapSelectionFromSource(const QItemSelection &selection) const; void updateTabControls(); @@ -169,8 +168,6 @@ readConfig(restoreSession); setMovable(true); - connect(d->mSelectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - this, SLOT(onSelectionChanged(QItemSelection,QItemSelection))); connect(this, &Pane::currentChanged, this, [this]() { d->onCurrentTabChanged(); }); @@ -453,7 +450,7 @@ } } -void Pane::Private::onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) +void Pane::Private::setCurrentFolder(const QModelIndex &etmIndex) { if (mPreferEmptyTab) { q->createNewTab(); @@ -465,11 +462,12 @@ w->saveCurrentSelection(); // Deselect old before we select new - so that the messagelist can clear first. - s->select(mapSelectionToSource(deselected), QItemSelectionModel::Deselect); + s->clear(); if (s->selection().isEmpty()) { w->view()->model()->setPreSelectionMode(mPreSelectionMode); } - s->select(mapSelectionToSource(selected), QItemSelectionModel::Select); + Q_ASSERT(s->model() == etmIndex.model()); + s->select(etmIndex, QItemSelectionModel::Select); QString label; QIcon icon; @@ -499,15 +497,10 @@ q->setTabIcon(index, icon); q->setTabToolTip(index, toolTip); if (mPreferEmptyTab) { - disconnect(mSelectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - q, SLOT(onSelectionChanged(QItemSelection,QItemSelection))); - mSelectionModel->select(mapSelectionFromSource(s->selection()), QItemSelectionModel::ClearAndSelect); - - connect(mSelectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - q, SLOT(onSelectionChanged(QItemSelection,QItemSelection))); } + mPreferEmptyTab = false; } void Pane::Private::activateTab() @@ -645,14 +638,8 @@ QItemSelectionModel *s = mWidgetSelectionHash[w]; - disconnect(mSelectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - q, SLOT(onSelectionChanged(QItemSelection,QItemSelection))); - mSelectionModel->select(mapSelectionFromSource(s->selection()), QItemSelectionModel::ClearAndSelect); - - connect(mSelectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - q, SLOT(onSelectionChanged(QItemSelection,QItemSelection))); } void Pane::Private::onTabContextMenuRequest(const QPoint &pos) @@ -722,8 +709,9 @@ return {}; } -void Pane::setCurrentFolder(const Akonadi::Collection &collection, bool, Core::PreSelectionMode preSelectionMode, const QString &overrideLabel) +void Pane::setCurrentFolder(const Akonadi::Collection &collection, const QModelIndex &etmIndex, bool, Core::PreSelectionMode preSelectionMode, const QString &overrideLabel) { + d->setCurrentFolder(etmIndex); d->mPreSelectionMode = preSelectionMode; Widget *w = static_cast(currentWidget()); if (w) { @@ -790,17 +778,6 @@ return s; } -QItemSelection Pane::Private::mapSelectionToSource(const QItemSelection &selection) const -{ - QItemSelection result = selection; - - for (const QAbstractProxyModel *proxy : qAsConst(mProxyStack)) { - result = proxy->mapSelectionToSource(result); - } - - return result; -} - QItemSelection Pane::Private::mapSelectionFromSource(const QItemSelection &selection) const { QItemSelection result = selection;