From 95f247d86acbf5089eca68f91623a5e5efe086b5 Mon Sep 17 00:00:00 2001 From: Christian Daniel Date: Tue, 24 Sep 2013 21:15:18 +0200 Subject: [PATCH] fix RollupWidget --- include/gui/rollupwidget.h | 4 ---- sdrbase/gui/rollupwidget.cpp | 34 +++++++++++++++++++--------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/gui/rollupwidget.h b/include/gui/rollupwidget.h index ec54d11..87e0902 100644 --- a/include/gui/rollupwidget.h +++ b/include/gui/rollupwidget.h @@ -10,11 +10,7 @@ class SDRANGELOVE_API RollupWidget : public QWidget { public: RollupWidget(QWidget* parent = NULL); - void addRollup(QWidget* rollup); - protected: - //QWidgetList m_rollups; - int arrangeRollups(); void paintEvent(QPaintEvent*); diff --git a/sdrbase/gui/rollupwidget.cpp b/sdrbase/gui/rollupwidget.cpp index 010c88c..77f1a06 100644 --- a/sdrbase/gui/rollupwidget.cpp +++ b/sdrbase/gui/rollupwidget.cpp @@ -16,23 +16,15 @@ RollupWidget::RollupWidget(QWidget* parent) : setAttribute(Qt::WA_OpaquePaintEvent, true); } -void RollupWidget::addRollup(QWidget* rollup) -{ - rollup->setParent(this); - installEventFilter(rollup); - arrangeRollups(); - repaint(); -} - int RollupWidget::arrangeRollups() { QFontMetrics fm(font()); int pos = fm.height() + 4; for(int i = 0; i < children().count(); ++i) { - pos += fm.height() + 2; QWidget* r = qobject_cast(children()[i]); if(r != NULL) { + pos += fm.height() + 2; if(!r->isHidden()) { r->move(2, pos + 3); int h = 0; @@ -112,10 +104,23 @@ void RollupWidget::paintEvent(QPaintEvent*) // Rollups int pos = fm.height() + 4; - for(int i = 0; i < children().count(); ++i) { - QWidget* r = qobject_cast(children()[i]); - if(r != NULL) - pos += paintRollup(r, pos, &p, i == children().count() - 1, frame); + + const QObjectList& c = children(); + QObjectList::ConstIterator w = c.begin(); + QObjectList::ConstIterator n = c.begin(); + + for(n = c.begin(); n != c.end(); ++n) { + if(qobject_cast(*n) != NULL) + break; + } + for(w = n; w != c.end(); w = n) { + if(n != c.end()) + ++n; + for(; n != c.end(); ++n) { + if(qobject_cast(*n) != NULL) + break; + } + pos += paintRollup(qobject_cast(*w), pos, &p, n == c.end(), frame); } } @@ -223,8 +228,7 @@ bool RollupWidget::eventFilter(QObject* object, QEvent* event) if(children().contains(object)) arrangeRollups(); } else if((event->type() == QEvent::ChildAdded) || (event->type() == QEvent::ChildRemoved)) { - if(children().contains(object)) - arrangeRollups(); + arrangeRollups(); } return QWidget::eventFilter(object, event);