forked from qt-creator/qt-creator
Introduced a single convenient function for updating additional contexts
While before you had to call add, then remove for each context id and then call update, now you call updateAdditionalContexts with a list of contexts to remove and add. It has the update step built in. Reviewed-by: con
This commit is contained in:
@@ -1171,23 +1171,26 @@ void MainWindow::writeSettings()
|
||||
m_navigationWidget->saveSettings(m_settings);
|
||||
}
|
||||
|
||||
void MainWindow::addAdditionalContext(int context)
|
||||
void MainWindow::updateAdditionalContexts(const QList<int> &remove, const QList<int> &add)
|
||||
{
|
||||
if (context == 0)
|
||||
return;
|
||||
foreach (const int context, remove) {
|
||||
if (context == 0)
|
||||
continue;
|
||||
|
||||
if (!m_additionalContexts.contains(context))
|
||||
m_additionalContexts.prepend(context);
|
||||
}
|
||||
int index = m_additionalContexts.indexOf(context);
|
||||
if (index != -1)
|
||||
m_additionalContexts.removeAt(index);
|
||||
}
|
||||
|
||||
void MainWindow::removeAdditionalContext(int context)
|
||||
{
|
||||
if (context == 0)
|
||||
return;
|
||||
foreach (const int context, add) {
|
||||
if (context == 0)
|
||||
continue;
|
||||
|
||||
int index = m_additionalContexts.indexOf(context);
|
||||
if (index != -1)
|
||||
m_additionalContexts.removeAt(index);
|
||||
if (!m_additionalContexts.contains(context))
|
||||
m_additionalContexts.prepend(context);
|
||||
}
|
||||
|
||||
updateContext();
|
||||
}
|
||||
|
||||
bool MainWindow::hasContext(int context) const
|
||||
|
||||
Reference in New Issue
Block a user