ProjectExplorer: Ensure that the session model stays sorted

Fixes: QTCREATORBUG-23996
Change-Id: I96c8c1b780f5b56cb064146de3de6a4c90f9147a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2020-05-13 11:47:38 +02:00
parent 689fac8fe9
commit 2c5d6de9b4
2 changed files with 6 additions and 0 deletions

View File

@@ -192,6 +192,8 @@ void SessionModel::sort(int column, Qt::SortOrder order)
return isLess; return isLess;
}; };
Utils::sort(m_sortedSessions, cmp); Utils::sort(m_sortedSessions, cmp);
m_currentSortColumn = column;
m_currentSortOrder = order;
endResetModel(); endResetModel();
} }
@@ -237,6 +239,7 @@ void SessionModel::deleteSessions(const QStringList &sessions)
beginResetModel(); beginResetModel();
SessionManager::deleteSessions(sessions); SessionManager::deleteSessions(sessions);
m_sortedSessions = SessionManager::sessions(); m_sortedSessions = SessionManager::sessions();
sort(m_currentSortColumn, m_currentSortOrder);
endResetModel(); endResetModel();
} }
@@ -268,6 +271,7 @@ void SessionModel::runSessionNameInputDialog(SessionNameInputDialog *sessionInpu
createSession(newSession); createSession(newSession);
m_sortedSessions = SessionManager::sessions(); m_sortedSessions = SessionManager::sessions();
endResetModel(); endResetModel();
sort(m_currentSortColumn, m_currentSortOrder);
if (sessionInputDialog->isSwitchToRequested()) if (sessionInputDialog->isSwitchToRequested())
switchToSession(newSession); switchToSession(newSession);

View File

@@ -81,6 +81,8 @@ private:
void runSessionNameInputDialog(ProjectExplorer::Internal::SessionNameInputDialog *sessionInputDialog, std::function<void(const QString &)> createSession); void runSessionNameInputDialog(ProjectExplorer::Internal::SessionNameInputDialog *sessionInputDialog, std::function<void(const QString &)> createSession);
QStringList m_sortedSessions; QStringList m_sortedSessions;
int m_currentSortColumn = 0;
Qt::SortOrder m_currentSortOrder = Qt::AscendingOrder;
}; };
} // namespace Internal } // namespace Internal