[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-bugs-dist
Subject: [Bug 109793] open file tab-order should be restored as part of the
From: Niko Sams <niko.sams () gmail ! com>
Date: 2010-07-25 10:11:00
Message-ID: 20100725101100.7900F4A4C9 () immanuel ! kde ! org
[Download RAW message or body]
https://bugs.kde.org/show_bug.cgi?id=109793
Niko Sams <niko.sams@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #15 from Niko Sams <niko sams gmail com> 2010-07-25 12:10:19 ---
commit 165f5483f2b1e06d1202da38e82a6a1c06755e47
Author: Niko Sams <niko.sams@gmail.com>
Date: Sat Jul 24 21:09:18 2010 +0200
correctly restore tab order when loading workingset/session
- don't let Sublime::Container choose the position where new Tabs are
inserted
- instead insert it into the AreaIndex at the correct position - depending
on the "Open new
Tabs after current" setting
- "Open new Tabs after current" setting had to be moved from
Sublime::Container
to Sublime::Controller
- to load this setting Sublime::Controller::loadSettings was added
BUG: 109793
diff --git a/shell/settings/uipreferences.cpp
b/shell/settings/uipreferences.cpp
index bf55cf3..43c63d6 100644
--- a/shell/settings/uipreferences.cpp
+++ b/shell/settings/uipreferences.cpp
@@ -62,4 +62,5 @@ void UiPreferences::save()
UiController *uiController = Core::self()->uiControllerInternal();
foreach (Sublime::MainWindow *window, uiController->mainWindows())
(static_cast<KDevelop::MainWindow*>(window))->loadSettings();
+ uiController->loadSettings();
}
diff --git a/sublime/area.cpp b/sublime/area.cpp
index c75200d..21d1545 100644
--- a/sublime/area.cpp
+++ b/sublime/area.cpp
@@ -161,18 +161,19 @@ void Area::setActiveView(View* view)
d->activeView = view;
}
-void Sublime::Area::addView(View *view, AreaIndex *index)
+void Area::addView(View *view, AreaIndex *index)
{
- index->add(view);
- connect(view, SIGNAL(positionChanged(Sublime::View*, int)), this,
SLOT(positionChanged(Sublime::View*, int)));
- kDebug() << "view added in" << this;
+ addViewSilently(view, index);
emit viewAdded(index, view);
- connect(this, SIGNAL(destroyed()), view, SLOT(deleteLater()));
}
-void Sublime::Area::addViewSilently(View *view, AreaIndex *index)
+void Area::addViewSilently(View *view, AreaIndex *index)
{
- index->add(view);
+ View *after = 0;
+ if (controller()->openAfterCurrent()) {
+ after = activeView();
+ }
+ index->add(view, after);
connect(view, SIGNAL(positionChanged(Sublime::View*, int)), this,
SLOT(positionChanged(Sublime::View*, int)));
kDebug() << "view added in" << this;
connect(this, SIGNAL(destroyed()), view, SLOT(deleteLater()));
diff --git a/sublime/areaindex.cpp b/sublime/areaindex.cpp
index 48f7432..a27c375 100644
--- a/sublime/areaindex.cpp
+++ b/sublime/areaindex.cpp
@@ -103,7 +103,7 @@ void AreaIndex::add(View *view, View *after)
return;
if (after)
- d->views.insert(d->views.indexOf(after), view);
+ d->views.insert(d->views.indexOf(after)+1, view);
else
d->views.append(view);
}
diff --git a/sublime/container.cpp b/sublime/container.cpp
index 87557e1..fac423c 100644
--- a/sublime/container.cpp
+++ b/sublime/container.cpp
@@ -82,8 +82,6 @@ struct ContainerPrivate {
QLabel *fileStatus;
QLabel *statusCorner;
QPointer<QWidget> leftCornerWidget;
-
- bool openAfterCurrent;
};
class UnderlinedLabel: public QLabel {
@@ -188,8 +186,6 @@ Container::Container(QWidget *parent)
d->tabBar->setTabsClosable(true);
d->tabBar->setMovable(true);
d->tabBar->setExpanding(false);
-
- setOpenAfterCurrent(group.readEntry("TabBarOpenAfterCurrent", 1) == 1);
}
void Container::setLeftCornerWidget(QWidget* widget)
@@ -253,13 +249,13 @@ void Container::widgetActivated(int idx)
}
}
-void Container::addWidget(View *view)
+void Container::addWidget(View *view, int position)
{
QWidget *w = view->widget(this);
int idx = 0;
- if (d->openAfterCurrent)
+ if (position != -1)
{
- idx = d->stack->insertWidget(d->stack->currentIndex()+1, w);
+ idx = d->stack->insertWidget(position, w);
view->notifyPositionChanged(idx);
}
else
@@ -394,11 +390,6 @@ void Container::setTabBarHidden(bool hide)
}
}
-void Container::setOpenAfterCurrent(bool after)
-{
- d->openAfterCurrent = after;
-}
-
void Container::tabMoved(int from, int to)
{
QWidget *w = d->stack->widget(from);
diff --git a/sublime/container.h b/sublime/container.h
index 1dad7c3..6b79df7 100644
--- a/sublime/container.h
+++ b/sublime/container.h
@@ -47,7 +47,7 @@ public:
~Container();
/**Adds the widget for given @p view to the container.*/
- void addWidget(View *view);
+ void addWidget(Sublime::View* view, int position = -1);
/**Removes the widget from the container.*/
void removeWidget(QWidget *w);
/** @return true if widget is placed inside this container.*/
@@ -62,7 +62,6 @@ public:
View *viewForWidget(QWidget *w) const;
void setTabBarHidden(bool hide);
- void setOpenAfterCurrent(bool after);
/** Adds a corner widget to the left of this containers tab-bar. To remove
it again, just delete it.
* The ownership otherwise goes to the container. */
diff --git a/sublime/controller.cpp b/sublime/controller.cpp
index 2c6e95f..31765df 100644
--- a/sublime/controller.cpp
+++ b/sublime/controller.cpp
@@ -25,6 +25,7 @@
#include <QApplication>
#include <kdebug.h>
+#include <KSharedConfig>
#include "area.h"
#include "view.h"
@@ -94,6 +95,7 @@ struct ControllerPrivate {
QMap<Area*, MainWindow*> shownAreas;
QList<MainWindow*> controlledWindows;
QVector< QList<Area*> > mainWindowAreas;
+ bool openAfterCurrent;
};
@@ -108,7 +110,7 @@ Controller::Controller(QObject *parent)
void Controller::init()
{
-
+ loadSettings();
qApp->installEventFilter(this);
}
@@ -383,6 +385,17 @@ void Controller::setStatusIcon(Document * document, const
QIcon & icon)
document->setStatusIcon(icon);
}
+void Controller::loadSettings()
+{
+ KConfigGroup uiGroup = KGlobal::config()->group("UiSettings");
+ d->openAfterCurrent = (uiGroup.readEntry("TabBarOpenAfterCurrent", 1) ==
1);
+}
+
+bool Controller::openAfterCurrent() const
+{
+ return d->openAfterCurrent;
+}
+
}
#include "controller.moc"
diff --git a/sublime/controller.h b/sublime/controller.h
index e67369f..3e44beb 100644
--- a/sublime/controller.h
+++ b/sublime/controller.h
@@ -143,6 +143,9 @@ public:
void setStatusIcon(Document* document, const QIcon& icon);
+ bool openAfterCurrent() const;
+
+ void loadSettings();
public Q_SLOTS:
//@todo adymo: this should not be a part of public API
/**Area can connect to this slot to release itself from its mainwindow.*/
diff --git a/sublime/mainwindow.cpp b/sublime/mainwindow.cpp
index 7d96f73..51513a0 100644
--- a/sublime/mainwindow.cpp
+++ b/sublime/mainwindow.cpp
@@ -335,7 +335,6 @@ void MainWindow::loadSettings()
foreach (Container *container, findChildren<Container*>())
{
container->setTabBarHidden(uiGroup.readEntry("TabBarVisibility", 1) ==
0);
-
container->setOpenAfterCurrent(uiGroup.readEntry("TabBarOpenAfterCurrent", 1)
== 1);
}
cg.sync();
diff --git a/sublime/mainwindow_p.cpp b/sublime/mainwindow_p.cpp
index 8548c11..80efa90 100644
--- a/sublime/mainwindow_p.cpp
+++ b/sublime/mainwindow_p.cpp
@@ -241,6 +241,8 @@ Area::WalkerMode MainWindowPrivate::ViewCreator::operator()
(AreaIndex *index)
else
container = qobject_cast<Container*>(splitter->widget(0));
container->show();
+
+ int position = 0;
foreach (View *view, index->views())
{
QWidget *widget = view->widget(container);
@@ -249,10 +251,11 @@ Area::WalkerMode
MainWindowPrivate::ViewCreator::operator() (AreaIndex *index)
widget->installEventFilter(d);
foreach (QWidget* w, widget->findChildren<QWidget*>())
w->installEventFilter(d);
- container->addWidget(view);
+ container->addWidget(view, position);
d->viewContainers[view] = container;
d->widgetToView[widget] = view;
}
+ position++;
}
}
return Area::ContinueWalker;
--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic