Replaced all dynamic_casts with qobject_casts

This commit is contained in:
Uwe Kindler 2020-02-13 18:56:04 +01:00
parent 93394577d0
commit f236de3277
4 changed files with 9 additions and 9 deletions

View File

@ -263,7 +263,7 @@ struct DockAreaWidgetPrivate
*/ */
CDockWidget* dockWidgetAt(int index) CDockWidget* dockWidgetAt(int index)
{ {
return dynamic_cast<CDockWidget*>(ContentsLayout->widget(index)); return qobject_cast<CDockWidget*>(ContentsLayout->widget(index));
} }
/** /**

View File

@ -736,7 +736,7 @@ void DockContainerWidgetPrivate::appendDockAreas(const QList<CDockAreaWidget*> N
//============================================================================ //============================================================================
void DockContainerWidgetPrivate::saveChildNodesState(QXmlStreamWriter& s, QWidget* Widget) void DockContainerWidgetPrivate::saveChildNodesState(QXmlStreamWriter& s, QWidget* Widget)
{ {
QSplitter* Splitter = dynamic_cast<QSplitter*>(Widget); QSplitter* Splitter = qobject_cast<QSplitter*>(Widget);
if (Splitter) if (Splitter)
{ {
s.writeStartElement("Splitter"); s.writeStartElement("Splitter");
@ -759,7 +759,7 @@ void DockContainerWidgetPrivate::saveChildNodesState(QXmlStreamWriter& s, QWidge
} }
else else
{ {
CDockAreaWidget* DockArea = dynamic_cast<CDockAreaWidget*>(Widget); CDockAreaWidget* DockArea = qobject_cast<CDockAreaWidget*>(Widget);
if (DockArea) if (DockArea)
{ {
DockArea->saveState(s); DockArea->saveState(s);
@ -1046,7 +1046,7 @@ void DockContainerWidgetPrivate::addDockArea(CDockAreaWidget* NewDockArea, DockW
void DockContainerWidgetPrivate::dumpRecursive(int level, QWidget* widget) void DockContainerWidgetPrivate::dumpRecursive(int level, QWidget* widget)
{ {
#if defined(QT_DEBUG) #if defined(QT_DEBUG)
QSplitter* Splitter = dynamic_cast<QSplitter*>(widget); QSplitter* Splitter = qobject_cast<QSplitter*>(widget);
QByteArray buf; QByteArray buf;
buf.fill(' ', level * 4); buf.fill(' ', level * 4);
if (Splitter) if (Splitter)
@ -1069,7 +1069,7 @@ void DockContainerWidgetPrivate::dumpRecursive(int level, QWidget* widget)
} }
else else
{ {
CDockAreaWidget* DockArea = dynamic_cast<CDockAreaWidget*>(widget); CDockAreaWidget* DockArea = qobject_cast<CDockAreaWidget*>(widget);
if (!DockArea) if (!DockArea)
{ {
return; return;
@ -1285,7 +1285,7 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
} }
QWidget* widget = Splitter->widget(0); QWidget* widget = Splitter->widget(0);
QSplitter* ChildSplitter = dynamic_cast<QSplitter*>(widget); QSplitter* ChildSplitter = qobject_cast<QSplitter*>(widget);
// If the one and only content widget of the splitter is not a splitter // If the one and only content widget of the splitter is not a splitter
// then we are finished // then we are finished
if (!ChildSplitter) if (!ChildSplitter)
@ -1573,7 +1573,7 @@ bool CDockContainerWidget::restoreState(CDockingStateReader& s, bool Testing)
d->Layout->replaceWidget(d->RootSplitter, NewRootSplitter); d->Layout->replaceWidget(d->RootSplitter, NewRootSplitter);
QSplitter* OldRoot = d->RootSplitter; QSplitter* OldRoot = d->RootSplitter;
d->RootSplitter = dynamic_cast<QSplitter*>(NewRootSplitter); d->RootSplitter = qobject_cast<QSplitter*>(NewRootSplitter);
OldRoot->deleteLater(); OldRoot->deleteLater();
return true; return true;

View File

@ -411,7 +411,7 @@ CDockManager::CDockManager(QWidget *parent) :
d(new DockManagerPrivate(this)) d(new DockManagerPrivate(this))
{ {
createRootSplitter(); createRootSplitter();
QMainWindow* MainWindow = dynamic_cast<QMainWindow*>(parent); QMainWindow* MainWindow = qobject_cast<QMainWindow*>(parent);
if (MainWindow) if (MainWindow)
{ {
MainWindow->setCentralWidget(this); MainWindow->setCentralWidget(this);

View File

@ -380,7 +380,7 @@ DockWidgetArea CDockOverlay::dropAreaUnderCursor() const
return Result; return Result;
} }
CDockAreaWidget* DockArea = dynamic_cast<CDockAreaWidget*>(d->TargetWidget.data()); CDockAreaWidget* DockArea = qobject_cast<CDockAreaWidget*>(d->TargetWidget.data());
if (!DockArea) if (!DockArea)
{ {
return Result; return Result;