forked from qt-creator/qt-creator
Sort the session list alphabetically.
Task-Nr: 257986
This commit is contained in:
@@ -989,6 +989,11 @@ QString SessionManager::activeSession() const
|
|||||||
return m_sessionName;
|
return m_sessionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
|
||||||
|
{
|
||||||
|
return s1.toLower() < s2.toLower();
|
||||||
|
}
|
||||||
|
|
||||||
QStringList SessionManager::sessions() const
|
QStringList SessionManager::sessions() const
|
||||||
{
|
{
|
||||||
if (m_sessions.isEmpty()) {
|
if (m_sessions.isEmpty()) {
|
||||||
@@ -1001,6 +1006,7 @@ QStringList SessionManager::sessions() const
|
|||||||
m_sessions << fileInfo.completeBaseName();
|
m_sessions << fileInfo.completeBaseName();
|
||||||
}
|
}
|
||||||
m_sessions.prepend("default");
|
m_sessions.prepend("default");
|
||||||
|
qSort(m_sessions.begin(), m_sessions.end(), caseInsensitiveLessThan);
|
||||||
}
|
}
|
||||||
return m_sessions;
|
return m_sessions;
|
||||||
}
|
}
|
||||||
@@ -1021,6 +1027,7 @@ bool SessionManager::createSession(const QString &session)
|
|||||||
if (sessions().contains(session))
|
if (sessions().contains(session))
|
||||||
return false;
|
return false;
|
||||||
m_sessions.append(session);
|
m_sessions.append(session);
|
||||||
|
qSort(m_sessions.begin(), m_sessions.end(), caseInsensitiveLessThan);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1044,6 +1051,7 @@ bool SessionManager::cloneSession(const QString &original, const QString &clone)
|
|||||||
// If the file does not exist, we can still clone
|
// If the file does not exist, we can still clone
|
||||||
if (!fi.exists() || fi.copy(sessionNameToFileName(clone))) {
|
if (!fi.exists() || fi.copy(sessionNameToFileName(clone))) {
|
||||||
m_sessions.append(clone);
|
m_sessions.append(clone);
|
||||||
|
qSort(m_sessions.begin(), m_sessions.end(), caseInsensitiveLessThan);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -164,8 +164,10 @@ void SessionDialog::createNew()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_sessionManager->createSession(newSession);
|
m_sessionManager->createSession(newSession);
|
||||||
m_ui.sessionList->addItem(newSession);
|
m_ui.sessionList->clear();
|
||||||
m_ui.sessionList->setCurrentRow(m_ui.sessionList->count() - 1);
|
QStringList sessions = m_sessionManager->sessions();
|
||||||
|
m_ui.sessionList->addItems(sessions);
|
||||||
|
m_ui.sessionList->setCurrentRow(sessions.indexOf(newSession));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,8 +176,12 @@ void SessionDialog::clone()
|
|||||||
NewSessionInputDialog newSessionInputDialog(m_sessionManager->sessions());
|
NewSessionInputDialog newSessionInputDialog(m_sessionManager->sessions());
|
||||||
if (newSessionInputDialog.exec() == QDialog::Accepted) {
|
if (newSessionInputDialog.exec() == QDialog::Accepted) {
|
||||||
QString newSession = newSessionInputDialog.value();
|
QString newSession = newSessionInputDialog.value();
|
||||||
if (m_sessionManager->cloneSession(m_ui.sessionList->currentItem()->text(), newSession))
|
if (m_sessionManager->cloneSession(m_ui.sessionList->currentItem()->text(), newSession)) {
|
||||||
m_ui.sessionList->addItem(newSession);
|
m_ui.sessionList->clear();
|
||||||
|
QStringList sessions = m_sessionManager->sessions();
|
||||||
|
m_ui.sessionList->addItems(sessions);
|
||||||
|
m_ui.sessionList->setCurrentRow(sessions.indexOf(newSession));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user