From 3915c7bedf4efa1ebf930b3ceb0d72c8e89c290d Mon Sep 17 00:00:00 2001 From: Jakob Leben Date: Wed, 29 Aug 2012 14:24:19 +0200 Subject: [PATCH] sc ide: MultiSplitter - reimplement findChild() to respect split order --- editors/sc-ide/widgets/multi_editor.cpp | 4 ++-- editors/sc-ide/widgets/util/multi_splitter.hpp | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/editors/sc-ide/widgets/multi_editor.cpp b/editors/sc-ide/widgets/multi_editor.cpp index 81beebc13..609bea7f4 100644 --- a/editors/sc-ide/widgets/multi_editor.cpp +++ b/editors/sc-ide/widgets/multi_editor.cpp @@ -578,7 +578,7 @@ void MultiEditor::switchSession( Session *session ) CodeEditorBox *firstBox = 0; if (mSplitter->count()) { - firstBox = mSplitter->findChild(); + firstBox = mSplitter->findChild(); if (!firstBox) { qWarning("Session seems to contain invalid editor split data!"); delete mSplitter; @@ -943,7 +943,7 @@ void MultiEditor::removeCurrentSplit() mSplitter->removeWidget(box); // switch current box to first box found: - box = mSplitter->findChild(); + box = mSplitter->findChild(); Q_ASSERT(box); setCurrentBox(box); box->setFocus( Qt::OtherFocusReason ); diff --git a/editors/sc-ide/widgets/util/multi_splitter.hpp b/editors/sc-ide/widgets/util/multi_splitter.hpp index 5aae26b41..26a2f96dc 100644 --- a/editors/sc-ide/widgets/util/multi_splitter.hpp +++ b/editors/sc-ide/widgets/util/multi_splitter.hpp @@ -88,7 +88,29 @@ public: } } + template T* findChild() + { + return MultiSplitter::findChild(this); + } + private: + template static T* findChild( QSplitter * splitter ) { + int childCount = splitter->count(); + for (int idx = 0; idx < childCount; ++idx) { + QWidget *child = splitter->widget(idx); + T* typedChild = qobject_cast(child); + if (typedChild) + return typedChild; + QSplitter *childSplitter = qobject_cast(child); + if (childSplitter) { + typedChild = findChild( childSplitter ); + if (typedChild) + return typedChild; + } + } + return 0; + } + QSplitter *parentSplitterOf( QWidget *widget ) { return qobject_cast( widget->parent() ); -- 2.11.4.GIT