aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Haumann <dhaumann@kde.org>2014-01-23 20:17:44 (GMT)
committerDominik Haumann <dhaumann@kde.org>2014-01-23 20:18:01 (GMT)
commit86ed12852fd2c22362792407d6566fa05ac9cdb5 (patch)
tree9c5725400654887dbe762f9efda2de4910a9745b
parent3703dfb5d184a42e999eb7942e5a6ed66b58881b (diff)
first fix attempt, still not all corner cases
-rw-r--r--kate/src/kateviewspace.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/kate/src/kateviewspace.cpp b/kate/src/kateviewspace.cpp
index 0752e73..43959df 100644
--- a/kate/src/kateviewspace.cpp
+++ b/kate/src/kateviewspace.cpp
@@ -227,7 +227,26 @@ bool KateViewSpace::showView(KTextEditor::Document *document)
stack->setCurrentWidget(kv);
kv->show();
- // raise tab in view space tab bar
+ // in case a tab does not exist, add one
+ if (! m_docToTabId.contains(document)) {
+ // if space is available, add button
+ if (m_tabBar->count() < m_tabBar->maxTabCount()) {
+ // just insert
+ insertTab(m_tabBar->count(), document);
+ } else {
+ // remove "oldest" button and replace with new one
+ Q_ASSERT(m_lruDocList.size() > m_tabBar->count());
+
+ KTextEditor::Document * docToHide = m_lruDocList[m_lruDocList.size() - m_tabBar->maxTabCount()];
+ Q_ASSERT(m_docToTabId.contains(docToHide));
+ const int insertIndex = removeTab(docToHide);
+
+ // add new one at removed position
+ insertTab(insertIndex, document);
+ }
+ }
+
+ // follow current view
Q_ASSERT(m_docToTabId.contains(document));
m_tabBar->setCurrentTab(m_docToTabId[document]);
@@ -344,7 +363,7 @@ void KateViewSpace::registerDocument(KTextEditor::Document *doc)
// remove "oldest" button and replace with new one
Q_ASSERT(m_lruDocList.size() > m_tabBar->count());
- KTextEditor::Document * docToHide = m_lruDocList[m_tabBar->count() - 1];
+ KTextEditor::Document * docToHide = m_lruDocList[m_lruDocList.size() - m_tabBar->maxTabCount()];
Q_ASSERT(m_docToTabId.contains(docToHide));
const int insertIndex = removeTab(docToHide);
@@ -361,6 +380,9 @@ void KateViewSpace::documentDestroyed(QObject *doc)
Q_ASSERT(m_lruDocList.contains(invalidDoc));
m_lruDocList.remove(m_lruDocList.indexOf(invalidDoc));
+ // disconnect entirely
+ disconnect(doc, 0, this, 0);
+
// case: there was no view created yet, but still a button was added
if (m_docToTabId.contains(invalidDoc)) {
const int insertIndex = removeTab(invalidDoc);
@@ -368,7 +390,7 @@ void KateViewSpace::documentDestroyed(QObject *doc)
if (m_lruDocList.size() >= m_tabBar->maxTabCount()
&& m_tabBar->count() < m_tabBar->maxTabCount()
) {
- KTextEditor::Document * docToShow = m_lruDocList[m_tabBar->count() - 1];
+ KTextEditor::Document * docToShow = m_lruDocList[m_lruDocList.size() - m_tabBar->count() - 1];
Q_ASSERT(! m_docToTabId.contains(docToShow));
// add tab that now fits into the bar
@@ -376,9 +398,6 @@ void KateViewSpace::documentDestroyed(QObject *doc)
}
}
- // disconnect entirely
- disconnect(doc, 0, this, 0);
-
// at this point, the doc should be completely unknown
Q_ASSERT(! m_lruDocList.contains(invalidDoc));
Q_ASSERT(! m_docToView.contains(invalidDoc));