mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 10:22:52 +00:00
generic: cast pointers with QObject as base class via qobject_cast<T>()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
7cc37bd444
commit
73acf5040d
13 changed files with 43 additions and 42 deletions
|
@ -755,7 +755,7 @@ void TaskGroupItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
if (groupable->itemType() == TaskManager::GroupItemType) {
|
||||
//TODO: recurse through sub-groups?
|
||||
} else {
|
||||
TaskItem * item = dynamic_cast<TaskItem*>(groupable);
|
||||
TaskItem * item = qobject_cast<TaskItem*>(groupable);
|
||||
if (item && item->task()) {
|
||||
ids << item->task()->info().win();
|
||||
}
|
||||
|
|
|
@ -247,9 +247,9 @@ int TaskItemLayout::size()
|
|||
}
|
||||
|
||||
if (item->abstractItem()->itemType() == TaskManager::GroupItemType) {
|
||||
TaskGroupItem *group = static_cast<TaskGroupItem*>(item);
|
||||
TaskGroupItem *group = qobject_cast<TaskGroupItem*>(item);
|
||||
if (!group->collapsed()) {
|
||||
TaskItemLayout *layout = dynamic_cast<TaskItemLayout*>(group->tasksLayout());
|
||||
TaskItemLayout *layout = qobject_cast<TaskItemLayout*>(group->tasksLayout());
|
||||
if (!layout) {
|
||||
kDebug() << "Error group has no layout";
|
||||
continue;
|
||||
|
|
|
@ -513,7 +513,7 @@ void ToolTipManagerPrivate::toolTipHovered(bool hovered)
|
|||
|
||||
bool ToolTipManager::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
QGraphicsWidget * widget = dynamic_cast<QGraphicsWidget *>(watched);
|
||||
QGraphicsWidget * widget = qobject_cast<QGraphicsWidget *>(watched);
|
||||
if (d->state != Activated || !widget) {
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
|
|
@ -448,7 +448,7 @@ QList<QAction*> Timer::contextualActions()
|
|||
|
||||
void Timer::startTimerFromAction()
|
||||
{
|
||||
QAction *action = dynamic_cast<QAction*> (sender());
|
||||
QAction *action = qobject_cast<QAction*> (sender());
|
||||
if (!action || action->property("seconds").type() != QVariant::Int) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ GroupIconList::~GroupIconList()
|
|||
bool GroupIconList::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::GraphicsSceneResize) {
|
||||
QGraphicsWidget *widget = dynamic_cast<QGraphicsWidget *>(obj);
|
||||
QGraphicsWidget *widget = qobject_cast<QGraphicsWidget *>(obj);
|
||||
|
||||
if (widget == m_listWidget) {
|
||||
//the resize occurred with the list widget
|
||||
|
|
|
@ -628,7 +628,7 @@ KMixWindow::recreateGUI(bool saveConfig, const QString& mixerId,
|
|||
QList<GUIProfile*> activeGuiProfiles;
|
||||
for (int i = 0; i < m_wsMixers->count(); ++i)
|
||||
{
|
||||
KMixerWidget* kmw = dynamic_cast<KMixerWidget*>(m_wsMixers->widget(i));
|
||||
KMixerWidget* kmw = qobject_cast<KMixerWidget*>(m_wsMixers->widget(i));
|
||||
if (kmw)
|
||||
{
|
||||
activeGuiProfiles.append(kmw->getGuiprof());
|
||||
|
@ -981,7 +981,7 @@ KMixWindow::profileExists(QString guiProfileId)
|
|||
{
|
||||
for (int i = 0; i < m_wsMixers->count(); ++i)
|
||||
{
|
||||
KMixerWidget* kmw = dynamic_cast<KMixerWidget*>(m_wsMixers->widget(i));
|
||||
KMixerWidget* kmw = qobject_cast<KMixerWidget*>(m_wsMixers->widget(i));
|
||||
if (kmw && kmw->getGuiprof()->getId() == guiProfileId)
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -415,7 +415,7 @@ void DialogViewConfiguration::prepareControls(QAbstractItemModel* model, bool is
|
|||
// -2- Find the mdw, und update it **************************
|
||||
foreach ( QWidget *qw, _view._mdws )
|
||||
{
|
||||
MixDeviceWidget *mdw = dynamic_cast<MixDeviceWidget*>(qw);
|
||||
MixDeviceWidget *mdw = qobject_cast<MixDeviceWidget*>(qw);
|
||||
if ( !mdw ) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -862,12 +862,12 @@ MDWSlider::setColors( QColor high, QColor low, QColor back )
|
|||
{
|
||||
for( int i=0; i<m_slidersPlayback.count(); ++i ) {
|
||||
QWidget *slider = m_slidersPlayback[i];
|
||||
KSmallSlider *smallSlider = dynamic_cast<KSmallSlider*>(slider);
|
||||
KSmallSlider *smallSlider = qobject_cast<KSmallSlider*>(slider);
|
||||
if ( smallSlider ) smallSlider->setColors( high, low, back );
|
||||
}
|
||||
for( int i=0; i<m_slidersCapture.count(); ++i ) {
|
||||
QWidget *slider = m_slidersCapture[i];
|
||||
KSmallSlider *smallSlider = dynamic_cast<KSmallSlider*>(slider);
|
||||
KSmallSlider *smallSlider = qobject_cast<KSmallSlider*>(slider);
|
||||
if ( smallSlider ) smallSlider->setColors( high, low, back );
|
||||
}
|
||||
}
|
||||
|
@ -877,12 +877,12 @@ MDWSlider::setMutedColors( QColor high, QColor low, QColor back )
|
|||
{
|
||||
for( int i=0; i<m_slidersPlayback.count(); ++i ) {
|
||||
QWidget *slider = m_slidersPlayback[i];
|
||||
KSmallSlider *smallSlider = dynamic_cast<KSmallSlider*>(slider);
|
||||
KSmallSlider *smallSlider = qobject_cast<KSmallSlider*>(slider);
|
||||
if ( smallSlider ) smallSlider->setGrayColors( high, low, back );
|
||||
}
|
||||
for( int i=0; i<m_slidersCapture.count(); ++i ) {
|
||||
QWidget *slider = m_slidersCapture[i];
|
||||
KSmallSlider *smallSlider = dynamic_cast<KSmallSlider*>(slider);
|
||||
KSmallSlider *smallSlider = qobject_cast<KSmallSlider*>(slider);
|
||||
if ( smallSlider ) smallSlider->setGrayColors( high, low, back );
|
||||
}
|
||||
}
|
||||
|
@ -1043,9 +1043,9 @@ void MDWSlider::update()
|
|||
{
|
||||
QLabel *l;
|
||||
VerticalText *v;
|
||||
if ((l = dynamic_cast<QLabel*>(m_label)))
|
||||
if ((l = qobject_cast<QLabel*>(m_label)))
|
||||
l->setText(m_mixdevice->readableName());
|
||||
else if ((v = dynamic_cast<VerticalText*>(m_label)))
|
||||
else if ((v = qobject_cast<VerticalText*>(m_label)))
|
||||
v->setText(m_mixdevice->readableName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
class VerticalText : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VerticalText(QWidget * parent, const QString&, Qt::WFlags f = 0);
|
||||
~VerticalText();
|
||||
|
|
|
@ -2064,7 +2064,7 @@ void Part::slotRenameBookmark( const DocumentViewport &viewport )
|
|||
|
||||
void Part::slotRenameBookmarkFromMenu()
|
||||
{
|
||||
QAction *action = dynamic_cast<QAction *>(sender());
|
||||
QAction *action = qobject_cast<QAction *>(sender());
|
||||
Q_ASSERT( action );
|
||||
if ( action )
|
||||
{
|
||||
|
@ -2087,7 +2087,7 @@ void Part::slotAboutToShowContextMenu(KMenu * /*menu*/, QAction *action, QMenu *
|
|||
delete a;
|
||||
}
|
||||
|
||||
KBookmarkAction *ba = dynamic_cast<KBookmarkAction*>(action);
|
||||
KBookmarkAction *ba = qobject_cast<KBookmarkAction*>(action);
|
||||
if (ba != NULL)
|
||||
{
|
||||
QAction *separatorAction = contextMenu->addSeparator();
|
||||
|
@ -2908,7 +2908,7 @@ void Part::rebuildBookmarkMenu( bool unplugActions )
|
|||
QWidget *container = factory()->container("bookmarks", clients[i]);
|
||||
if (container && container->actions().contains(m_bookmarkActions.first()))
|
||||
{
|
||||
Q_ASSERT(dynamic_cast<KMenu*>(container));
|
||||
Q_ASSERT(qobject_cast<KMenu*>(container));
|
||||
disconnect(container, 0, this, 0);
|
||||
connect(container, SIGNAL(aboutToShowContextMenu(KMenu*,QAction*,QMenu*)), this, SLOT(slotAboutToShowContextMenu(KMenu*,QAction*,QMenu*)));
|
||||
containerFound = true;
|
||||
|
|
|
@ -240,8 +240,8 @@ void MainShellTest::testShell()
|
|||
QSet<QString> openUrls;
|
||||
Shell *s = findShell();
|
||||
QVERIFY(s);
|
||||
Okular::Part *part = dynamic_cast<Okular::Part*>(s->m_tabs[0].part);
|
||||
Okular::Part *part2 = dynamic_cast<Okular::Part*>(s->m_tabs[1].part);
|
||||
Okular::Part *part = qobject_cast<Okular::Part*>(s->m_tabs[0].part);
|
||||
Okular::Part *part2 = qobject_cast<Okular::Part*>(s->m_tabs[1].part);
|
||||
QCOMPARE(s->m_tabs.count(), 2);
|
||||
QCOMPARE(part->url().url(), QString("file://%1").arg(paths[0]));
|
||||
QCOMPARE(part2->url().url(), QString("file://%1").arg(paths[1]));
|
||||
|
@ -313,7 +313,7 @@ void MainShellTest::testShell()
|
|||
{
|
||||
// It is attaching to us so a second tab is there
|
||||
QCOMPARE(s->m_tabs.count(), 2);
|
||||
Okular::Part *part2 = dynamic_cast<Okular::Part*>(s->m_tabs[1].part);
|
||||
Okular::Part *part2 = qobject_cast<Okular::Part*>(s->m_tabs[1].part);
|
||||
QCOMPARE(part2->url().url(), QString("file://%1").arg(externalProcessPath));
|
||||
QCOMPARE(partDocument(part2)->currentPage(), externalProcessExpectedPage);
|
||||
}
|
||||
|
@ -353,12 +353,12 @@ void MainShellTest::testShell()
|
|||
if (unique)
|
||||
{
|
||||
QCOMPARE(s->m_tabs.count(), 1);
|
||||
part = dynamic_cast<Okular::Part*>(s->m_tabs[0].part);
|
||||
part = qobject_cast<Okular::Part*>(s->m_tabs[0].part);
|
||||
}
|
||||
else
|
||||
{
|
||||
QCOMPARE(s->m_tabs.count(), 2);
|
||||
part = dynamic_cast<Okular::Part*>(s->m_tabs[1].part);
|
||||
part = qobject_cast<Okular::Part*>(s->m_tabs[1].part);
|
||||
}
|
||||
|
||||
for (int i = 0; presentationWidget(part) == 0 && i < 20; ++i) {
|
||||
|
|
|
@ -225,7 +225,7 @@ void MiniBar::changeEvent( QEvent * event )
|
|||
{
|
||||
if ( event->type() == QEvent::ParentChange )
|
||||
{
|
||||
QToolBar *tb = dynamic_cast<QToolBar*>( parent() );
|
||||
QToolBar *tb = qobject_cast<QToolBar*>( parent() );
|
||||
if ( tb != m_oldToobarParent )
|
||||
{
|
||||
if ( m_oldToobarParent )
|
||||
|
|
|
@ -90,17 +90,17 @@ OperationStack::~OperationStack()
|
|||
*/
|
||||
bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushedOp)
|
||||
{
|
||||
NewOperation* newOp = dynamic_cast<NewOperation*>(currentOp);
|
||||
NewOperation* newOp = qobject_cast<NewOperation*>(currentOp);
|
||||
|
||||
if (newOp == NULL)
|
||||
return false;
|
||||
|
||||
DeleteOperation* pushedDeleteOp = dynamic_cast<DeleteOperation*>(pushedOp);
|
||||
ResizeOperation* pushedResizeOp = dynamic_cast<ResizeOperation*>(pushedOp);
|
||||
CopyOperation* pushedCopyOp = dynamic_cast<CopyOperation*>(pushedOp);
|
||||
SetFileSystemLabelOperation* pushedLabelOp = dynamic_cast<SetFileSystemLabelOperation*>(pushedOp);
|
||||
CreateFileSystemOperation* pushedCreateFileSystemOp = dynamic_cast<CreateFileSystemOperation*>(pushedOp);
|
||||
CheckOperation* pushedCheckOp = dynamic_cast<CheckOperation*>(pushedOp);
|
||||
DeleteOperation* pushedDeleteOp = qobject_cast<DeleteOperation*>(pushedOp);
|
||||
ResizeOperation* pushedResizeOp = qobject_cast<ResizeOperation*>(pushedOp);
|
||||
CopyOperation* pushedCopyOp = qobject_cast<CopyOperation*>(pushedOp);
|
||||
SetFileSystemLabelOperation* pushedLabelOp = qobject_cast<SetFileSystemLabelOperation*>(pushedOp);
|
||||
CreateFileSystemOperation* pushedCreateFileSystemOp = qobject_cast<CreateFileSystemOperation*>(pushedOp);
|
||||
CheckOperation* pushedCheckOp = qobject_cast<CheckOperation*>(pushedOp);
|
||||
|
||||
// -- 1 --
|
||||
if (pushedDeleteOp && &newOp->newPartition() == &pushedDeleteOp->deletedPartition() && !pushedDeleteOp->deletedPartition().roles().has(PartitionRole::Extended))
|
||||
|
@ -229,13 +229,13 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed
|
|||
*/
|
||||
bool OperationStack::mergeCopyOperation(Operation*& currentOp, Operation*& pushedOp)
|
||||
{
|
||||
CopyOperation* copyOp = dynamic_cast<CopyOperation*>(currentOp);
|
||||
CopyOperation* copyOp = qobject_cast<CopyOperation*>(currentOp);
|
||||
|
||||
if (copyOp == NULL)
|
||||
return false;
|
||||
|
||||
DeleteOperation* pushedDeleteOp = dynamic_cast<DeleteOperation*>(pushedOp);
|
||||
CopyOperation* pushedCopyOp = dynamic_cast<CopyOperation*>(pushedOp);
|
||||
DeleteOperation* pushedDeleteOp = qobject_cast<DeleteOperation*>(pushedOp);
|
||||
CopyOperation* pushedCopyOp = qobject_cast<CopyOperation*>(pushedOp);
|
||||
|
||||
// -- 1 --
|
||||
if (pushedDeleteOp && ©Op->copiedPartition() == &pushedDeleteOp->deletedPartition())
|
||||
|
@ -285,12 +285,12 @@ bool OperationStack::mergeCopyOperation(Operation*& currentOp, Operation*& pushe
|
|||
*/
|
||||
bool OperationStack::mergeRestoreOperation(Operation*& currentOp, Operation*& pushedOp)
|
||||
{
|
||||
RestoreOperation* restoreOp = dynamic_cast<RestoreOperation*>(currentOp);
|
||||
RestoreOperation* restoreOp = qobject_cast<RestoreOperation*>(currentOp);
|
||||
|
||||
if (restoreOp == NULL)
|
||||
return false;
|
||||
|
||||
DeleteOperation* pushedDeleteOp = dynamic_cast<DeleteOperation*>(pushedOp);
|
||||
DeleteOperation* pushedDeleteOp = qobject_cast<DeleteOperation*>(pushedOp);
|
||||
|
||||
if (pushedDeleteOp && &restoreOp->restorePartition() == &pushedDeleteOp->deletedPartition())
|
||||
{
|
||||
|
@ -328,12 +328,12 @@ bool OperationStack::mergeRestoreOperation(Operation*& currentOp, Operation*& pu
|
|||
*/
|
||||
bool OperationStack::mergePartFlagsOperation(Operation*& currentOp, Operation*& pushedOp)
|
||||
{
|
||||
SetPartFlagsOperation* partFlagsOp = dynamic_cast<SetPartFlagsOperation*>(currentOp);
|
||||
SetPartFlagsOperation* partFlagsOp = qobject_cast<SetPartFlagsOperation*>(currentOp);
|
||||
|
||||
if (partFlagsOp == NULL)
|
||||
return false;
|
||||
|
||||
SetPartFlagsOperation* pushedFlagsOp = dynamic_cast<SetPartFlagsOperation*>(pushedOp);
|
||||
SetPartFlagsOperation* pushedFlagsOp = qobject_cast<SetPartFlagsOperation*>(pushedOp);
|
||||
|
||||
if (pushedFlagsOp && &partFlagsOp->flagPartition() == &pushedFlagsOp->flagPartition())
|
||||
{
|
||||
|
@ -360,12 +360,12 @@ bool OperationStack::mergePartFlagsOperation(Operation*& currentOp, Operation*&
|
|||
*/
|
||||
bool OperationStack::mergePartLabelOperation(Operation*& currentOp, Operation*& pushedOp)
|
||||
{
|
||||
SetFileSystemLabelOperation* partLabelOp = dynamic_cast<SetFileSystemLabelOperation*>(currentOp);
|
||||
SetFileSystemLabelOperation* partLabelOp = qobject_cast<SetFileSystemLabelOperation*>(currentOp);
|
||||
|
||||
if (partLabelOp == NULL)
|
||||
return false;
|
||||
|
||||
SetFileSystemLabelOperation* pushedLabelOp = dynamic_cast<SetFileSystemLabelOperation*>(pushedOp);
|
||||
SetFileSystemLabelOperation* pushedLabelOp = qobject_cast<SetFileSystemLabelOperation*>(pushedOp);
|
||||
|
||||
if (pushedLabelOp && &partLabelOp->labeledPartition() == &pushedLabelOp->labeledPartition())
|
||||
{
|
||||
|
@ -392,13 +392,13 @@ bool OperationStack::mergePartLabelOperation(Operation*& currentOp, Operation*&
|
|||
*/
|
||||
bool OperationStack::mergeCreatePartitionTableOperation(Operation*& currentOp, Operation*& pushedOp)
|
||||
{
|
||||
CreatePartitionTableOperation* pushedCreatePartitionTableOp = dynamic_cast<CreatePartitionTableOperation*>(pushedOp);
|
||||
CreatePartitionTableOperation* pushedCreatePartitionTableOp = qobject_cast<CreatePartitionTableOperation*>(pushedOp);
|
||||
|
||||
if (pushedCreatePartitionTableOp && currentOp->targets(pushedCreatePartitionTableOp->targetDevice()))
|
||||
{
|
||||
Log() << i18nc("@info/plain", "Creating new partition table, discarding previous operation on device.");
|
||||
|
||||
CreatePartitionTableOperation* createPartitionTableOp = dynamic_cast<CreatePartitionTableOperation*>(currentOp);
|
||||
CreatePartitionTableOperation* createPartitionTableOp = qobject_cast<CreatePartitionTableOperation*>(currentOp);
|
||||
if (createPartitionTableOp != NULL)
|
||||
pushedCreatePartitionTableOp->setOldPartitionTable(createPartitionTableOp->oldPartitionTable());
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue