Commit d3c3008e authored by Dominik Haumann's avatar Dominik Haumann

TabBar: More predictive tab placement when opening/closing documents

If a user explicitly opens a file, the new tab appears on the very left.
If the user closes a tab, or increases the application width, then new
tabs appear on the right (documents that were already open but no space
was in the tabbar to show them).
parent 48d22f26
......@@ -275,7 +275,7 @@ bool KateViewSpace::showView(KTextEditor::Document *document)
// if space is available, add button
if (m_tabBar->count() < m_tabBar->maxTabCount()) {
// just insert
insertTab(m_tabBar->count(), document);
insertTab(0, document);
} else {
// remove "oldest" button and replace with new one
Q_ASSERT(m_lruDocList.size() > m_tabBar->count());
......@@ -283,10 +283,10 @@ bool KateViewSpace::showView(KTextEditor::Document *document)
// we need to subtract by 1 more, as we just added ourself to the end of the lru list!
KTextEditor::Document * docToHide = m_lruDocList[m_lruDocList.size() - m_tabBar->maxTabCount() - 1];
Q_ASSERT(m_docToTabId.contains(docToHide));
const int insertIndex = removeTab(docToHide, false);
removeTab(docToHide, false);
// add new one at removed position
insertTab(insertIndex, document);
// add new one always at the beginning
insertTab(0, document);
}
}
......@@ -437,7 +437,7 @@ void KateViewSpace::registerDocument(KTextEditor::Document *doc, bool append)
// if space is available, add button
if (m_tabBar->count() < m_tabBar->maxTabCount()) {
insertTab(m_tabBar->count(), doc);
insertTab(0, doc);
updateQuickOpen();
} else if (append) {
// remove "oldest" button and replace with new one
......@@ -445,10 +445,10 @@ void KateViewSpace::registerDocument(KTextEditor::Document *doc, bool append)
KTextEditor::Document * docToHide = m_lruDocList[m_lruDocList.size() - m_tabBar->maxTabCount() - 1];
Q_ASSERT(m_docToTabId.contains(docToHide));
const int insertIndex = removeTab(docToHide, false);
removeTab(docToHide, false);
// add new one at removed position
insertTab(insertIndex, doc);
insertTab(0, doc);
}
}
......@@ -465,7 +465,7 @@ void KateViewSpace::documentDestroyed(QObject *doc)
// case: there was no view created yet, but still a button was added
if (m_docToTabId.contains(invalidDoc)) {
const int insertIndex = removeTab(invalidDoc, true);
removeTab(invalidDoc, true);
// maybe show another tab button in its stead
if (m_lruDocList.size() >= m_tabBar->maxTabCount()
&& m_tabBar->count() < m_tabBar->maxTabCount()
......@@ -474,7 +474,7 @@ void KateViewSpace::documentDestroyed(QObject *doc)
Q_ASSERT(! m_docToTabId.contains(docToShow));
// add tab that now fits into the bar
insertTab(insertIndex, docToShow);
insertTab(m_tabBar->count(), docToShow);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment