mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +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
06e562e271
commit
08f290fa8b
16 changed files with 34 additions and 31 deletions
|
@ -299,7 +299,7 @@ QAction *KActionCollection::addAction(const QString &name, QAction *action)
|
||||||
connect(action, SIGNAL(destroyed(QObject*)), SLOT(_k_actionDestroyed(QObject*)));
|
connect(action, SIGNAL(destroyed(QObject*)), SLOT(_k_actionDestroyed(QObject*)));
|
||||||
|
|
||||||
// only our private class is a friend of KAction
|
// only our private class is a friend of KAction
|
||||||
if (KAction *kaction = dynamic_cast<KAction *>(action)) {
|
if (KAction *kaction = qobject_cast<KAction *>(action)) {
|
||||||
d->setComponentForAction(kaction);
|
d->setComponentForAction(kaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
class KDEUI_EXPORT KCategorizedSortFilterProxyModel
|
class KDEUI_EXPORT KCategorizedSortFilterProxyModel
|
||||||
: public QSortFilterProxyModel
|
: public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum AdditionalRoles {
|
enum AdditionalRoles {
|
||||||
// Note: use printf "0x%08X\n" $(($RANDOM*$RANDOM))
|
// Note: use printf "0x%08X\n" $(($RANDOM*$RANDOM))
|
||||||
|
|
|
@ -518,7 +518,7 @@ void KCategorizedView::setModel(QAbstractItemModel *model)
|
||||||
disconnect(d->proxyModel, SIGNAL(layoutChanged()), this, SLOT(slotLayoutChanged()));
|
disconnect(d->proxyModel, SIGNAL(layoutChanged()), this, SLOT(slotLayoutChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
d->proxyModel = dynamic_cast<KCategorizedSortFilterProxyModel*>(model);
|
d->proxyModel = qobject_cast<KCategorizedSortFilterProxyModel*>(model);
|
||||||
|
|
||||||
if (d->proxyModel) {
|
if (d->proxyModel) {
|
||||||
connect(d->proxyModel, SIGNAL(layoutChanged()), this, SLOT(slotLayoutChanged()));
|
connect(d->proxyModel, SIGNAL(layoutChanged()), this, SLOT(slotLayoutChanged()));
|
||||||
|
|
|
@ -175,13 +175,13 @@ int KMultiTabBarButton::id() const
|
||||||
|
|
||||||
void KMultiTabBarButton::hideEvent( QHideEvent* he) {
|
void KMultiTabBarButton::hideEvent( QHideEvent* he) {
|
||||||
QPushButton::hideEvent(he);
|
QPushButton::hideEvent(he);
|
||||||
KMultiTabBar *tb=dynamic_cast<KMultiTabBar*>(parentWidget());
|
KMultiTabBar *tb=qobject_cast<KMultiTabBar*>(parentWidget());
|
||||||
if (tb) tb->updateSeparator();
|
if (tb) tb->updateSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMultiTabBarButton::showEvent( QShowEvent* he) {
|
void KMultiTabBarButton::showEvent( QShowEvent* he) {
|
||||||
QPushButton::showEvent(he);
|
QPushButton::showEvent(he);
|
||||||
KMultiTabBar *tb=dynamic_cast<KMultiTabBar*>(parentWidget());
|
KMultiTabBar *tb=qobject_cast<KMultiTabBar*>(parentWidget());
|
||||||
if (tb) tb->updateSeparator();
|
if (tb) tb->updateSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2078,7 +2078,7 @@ void KDirOperator::writeConfig(KConfigGroup& configGroup)
|
||||||
// don't save the preview when an application specific preview is in use.
|
// don't save the preview when an application specific preview is in use.
|
||||||
bool appSpecificPreview = false;
|
bool appSpecificPreview = false;
|
||||||
if (d->preview) {
|
if (d->preview) {
|
||||||
KImageFilePreview *tmp = dynamic_cast<KImageFilePreview*>(d->preview);
|
KImageFilePreview *tmp = qobject_cast<KImageFilePreview*>(d->preview);
|
||||||
appSpecificPreview = (tmp == 0);
|
appSpecificPreview = (tmp == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
|
|
||||||
class KFilePlacesViewDelegate : public QAbstractItemDelegate
|
class KFilePlacesViewDelegate : public QAbstractItemDelegate
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
KFilePlacesViewDelegate(KFilePlacesView *parent);
|
KFilePlacesViewDelegate(KFilePlacesView *parent);
|
||||||
virtual ~KFilePlacesViewDelegate();
|
virtual ~KFilePlacesViewDelegate();
|
||||||
|
@ -555,7 +556,7 @@ void KFilePlacesView::keyPressEvent(QKeyEvent *event)
|
||||||
void KFilePlacesView::contextMenuEvent(QContextMenuEvent *event)
|
void KFilePlacesView::contextMenuEvent(QContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
KFilePlacesModel *placesModel = qobject_cast<KFilePlacesModel*>(model());
|
KFilePlacesModel *placesModel = qobject_cast<KFilePlacesModel*>(model());
|
||||||
KFilePlacesViewDelegate *delegate = dynamic_cast<KFilePlacesViewDelegate*>(itemDelegate());
|
KFilePlacesViewDelegate *delegate = qobject_cast<KFilePlacesViewDelegate*>(itemDelegate());
|
||||||
|
|
||||||
if (placesModel==0) return;
|
if (placesModel==0) return;
|
||||||
|
|
||||||
|
@ -730,7 +731,7 @@ void KFilePlacesView::dragEnterEvent(QDragEnterEvent *event)
|
||||||
QListView::dragEnterEvent(event);
|
QListView::dragEnterEvent(event);
|
||||||
d->dragging = true;
|
d->dragging = true;
|
||||||
|
|
||||||
KFilePlacesViewDelegate *delegate = dynamic_cast<KFilePlacesViewDelegate*>(itemDelegate());
|
KFilePlacesViewDelegate *delegate = qobject_cast<KFilePlacesViewDelegate*>(itemDelegate());
|
||||||
delegate->setShowHoverIndication(false);
|
delegate->setShowHoverIndication(false);
|
||||||
|
|
||||||
d->dropRect = QRect();
|
d->dropRect = QRect();
|
||||||
|
@ -741,7 +742,7 @@ void KFilePlacesView::dragLeaveEvent(QDragLeaveEvent *event)
|
||||||
QListView::dragLeaveEvent(event);
|
QListView::dragLeaveEvent(event);
|
||||||
d->dragging = false;
|
d->dragging = false;
|
||||||
|
|
||||||
KFilePlacesViewDelegate *delegate = dynamic_cast<KFilePlacesViewDelegate*>(itemDelegate());
|
KFilePlacesViewDelegate *delegate = qobject_cast<KFilePlacesViewDelegate*>(itemDelegate());
|
||||||
delegate->setShowHoverIndication(true);
|
delegate->setShowHoverIndication(true);
|
||||||
|
|
||||||
setDirtyRegion(d->dropRect);
|
setDirtyRegion(d->dropRect);
|
||||||
|
@ -792,7 +793,7 @@ void KFilePlacesView::dropEvent(QDropEvent *event)
|
||||||
QListView::dropEvent(event);
|
QListView::dropEvent(event);
|
||||||
d->dragging = false;
|
d->dragging = false;
|
||||||
|
|
||||||
KFilePlacesViewDelegate *delegate = dynamic_cast<KFilePlacesViewDelegate*>(itemDelegate());
|
KFilePlacesViewDelegate *delegate = qobject_cast<KFilePlacesViewDelegate*>(itemDelegate());
|
||||||
delegate->setShowHoverIndication(true);
|
delegate->setShowHoverIndication(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -855,7 +856,7 @@ void KFilePlacesView::rowsInserted(const QModelIndex &parent, int start, int end
|
||||||
QListView::rowsInserted(parent, start, end);
|
QListView::rowsInserted(parent, start, end);
|
||||||
setUrl(d->currentUrl);
|
setUrl(d->currentUrl);
|
||||||
|
|
||||||
KFilePlacesViewDelegate *delegate = dynamic_cast<KFilePlacesViewDelegate*>(itemDelegate());
|
KFilePlacesViewDelegate *delegate = qobject_cast<KFilePlacesViewDelegate*>(itemDelegate());
|
||||||
KFilePlacesModel *placesModel = qobject_cast<KFilePlacesModel*>(model());
|
KFilePlacesModel *placesModel = qobject_cast<KFilePlacesModel*>(model());
|
||||||
|
|
||||||
for (int i=start; i<=end; ++i) {
|
for (int i=start; i<=end; ++i) {
|
||||||
|
@ -917,7 +918,7 @@ void KFilePlacesView::Private::setCurrentIndex(const QModelIndex &index)
|
||||||
|
|
||||||
void KFilePlacesView::Private::adaptItemSize()
|
void KFilePlacesView::Private::adaptItemSize()
|
||||||
{
|
{
|
||||||
KFilePlacesViewDelegate *delegate = dynamic_cast<KFilePlacesViewDelegate*>(q->itemDelegate());
|
KFilePlacesViewDelegate *delegate = qobject_cast<KFilePlacesViewDelegate*>(q->itemDelegate());
|
||||||
if (!delegate) return;
|
if (!delegate) return;
|
||||||
|
|
||||||
if (!autoResizeItems) {
|
if (!autoResizeItems) {
|
||||||
|
@ -1121,14 +1122,14 @@ void KFilePlacesView::Private::_k_adaptItemsUpdate(qreal value)
|
||||||
|
|
||||||
int size = oldSize+add;
|
int size = oldSize+add;
|
||||||
|
|
||||||
KFilePlacesViewDelegate *delegate = dynamic_cast<KFilePlacesViewDelegate*>(q->itemDelegate());
|
KFilePlacesViewDelegate *delegate = qobject_cast<KFilePlacesViewDelegate*>(q->itemDelegate());
|
||||||
delegate->setIconSize(size);
|
delegate->setIconSize(size);
|
||||||
q->scheduleDelayedItemsLayout();
|
q->scheduleDelayedItemsLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFilePlacesView::Private::_k_itemAppearUpdate(qreal value)
|
void KFilePlacesView::Private::_k_itemAppearUpdate(qreal value)
|
||||||
{
|
{
|
||||||
KFilePlacesViewDelegate *delegate = dynamic_cast<KFilePlacesViewDelegate*>(q->itemDelegate());
|
KFilePlacesViewDelegate *delegate = qobject_cast<KFilePlacesViewDelegate*>(q->itemDelegate());
|
||||||
|
|
||||||
delegate->setAppearingItemProgress(value);
|
delegate->setAppearingItemProgress(value);
|
||||||
q->scheduleDelayedItemsLayout();
|
q->scheduleDelayedItemsLayout();
|
||||||
|
@ -1136,7 +1137,7 @@ void KFilePlacesView::Private::_k_itemAppearUpdate(qreal value)
|
||||||
|
|
||||||
void KFilePlacesView::Private::_k_itemDisappearUpdate(qreal value)
|
void KFilePlacesView::Private::_k_itemDisappearUpdate(qreal value)
|
||||||
{
|
{
|
||||||
KFilePlacesViewDelegate *delegate = dynamic_cast<KFilePlacesViewDelegate*>(q->itemDelegate());
|
KFilePlacesViewDelegate *delegate = qobject_cast<KFilePlacesViewDelegate*>(q->itemDelegate());
|
||||||
|
|
||||||
delegate->setDisappearingItemProgress(value);
|
delegate->setDisappearingItemProgress(value);
|
||||||
|
|
||||||
|
@ -1193,5 +1194,6 @@ void KFilePlacesView::dataChanged(const QModelIndex &topLeft, const QModelIndex
|
||||||
d->adaptItemSize();
|
d->adaptItemSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "kfileplacesview.moc"
|
||||||
#include "moc_kfileplacesview.cpp"
|
#include "moc_kfileplacesview.cpp"
|
||||||
#include "moc_kfileplacesview_p.cpp"
|
#include "moc_kfileplacesview_p.cpp"
|
||||||
|
|
|
@ -1404,7 +1404,7 @@ void KFileWidgetPrivate::_k_urlEntered(const KUrl& url)
|
||||||
urlNavigator->setLocationUrl(url);
|
urlNavigator->setLocationUrl(url);
|
||||||
|
|
||||||
// is trigged in ctor before completion object is set
|
// is trigged in ctor before completion object is set
|
||||||
KUrlCompletion *completion = dynamic_cast<KUrlCompletion*>(locationEdit->completionObject());
|
KUrlCompletion *completion = qobject_cast<KUrlCompletion*>(locationEdit->completionObject());
|
||||||
if (completion) {
|
if (completion) {
|
||||||
completion->setDir( url.path() );
|
completion->setDir( url.path() );
|
||||||
}
|
}
|
||||||
|
@ -1882,7 +1882,7 @@ void KFileWidgetPrivate::readRecentFiles()
|
||||||
combo->setUrl(ops->url());
|
combo->setUrl(ops->url());
|
||||||
// since we delayed this moment, initialize the directory of the completion object to
|
// since we delayed this moment, initialize the directory of the completion object to
|
||||||
// our current directory (that was very probably set on the constructor)
|
// our current directory (that was very probably set on the constructor)
|
||||||
KUrlCompletion *completion = dynamic_cast<KUrlCompletion*>(locationEdit->completionObject());
|
KUrlCompletion *completion = qobject_cast<KUrlCompletion*>(locationEdit->completionObject());
|
||||||
if (completion) {
|
if (completion) {
|
||||||
completion->setDir(ops->url().url());
|
completion->setDir(ops->url().url());
|
||||||
}
|
}
|
||||||
|
|
|
@ -344,7 +344,7 @@ void KPropertiesDialog::setFileSharingPage(QWidget* page) {
|
||||||
void KPropertiesDialog::setFileNameReadOnly( bool ro )
|
void KPropertiesDialog::setFileNameReadOnly( bool ro )
|
||||||
{
|
{
|
||||||
foreach(KPropertiesDialogPlugin *it, d->m_pageList) {
|
foreach(KPropertiesDialogPlugin *it, d->m_pageList) {
|
||||||
KFilePropsPlugin* plugin = dynamic_cast<KFilePropsPlugin*>(it);
|
KFilePropsPlugin* plugin = qobject_cast<KFilePropsPlugin*>(it);
|
||||||
if ( plugin ) {
|
if ( plugin ) {
|
||||||
plugin->setFileNameReadOnly( ro );
|
plugin->setFileNameReadOnly( ro );
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1339,7 +1339,7 @@ void CopyJobPrivate::slotResultCopyingFiles( KJob * job )
|
||||||
//kDebug(7007) << files.count() << "files remaining";
|
//kDebug(7007) << files.count() << "files remaining";
|
||||||
|
|
||||||
// Merge metadata from subjob
|
// Merge metadata from subjob
|
||||||
KIO::Job* kiojob = dynamic_cast<KIO::Job*>(job);
|
KIO::Job* kiojob = qobject_cast<KIO::Job*>(job);
|
||||||
Q_ASSERT(kiojob);
|
Q_ASSERT(kiojob);
|
||||||
m_incomingMetaData += kiojob->metaData();
|
m_incomingMetaData += kiojob->metaData();
|
||||||
q->removeSubjob( job );
|
q->removeSubjob( job );
|
||||||
|
@ -1837,7 +1837,7 @@ void CopyJobPrivate::slotResultRenaming( KJob* job )
|
||||||
int err = job->error();
|
int err = job->error();
|
||||||
const QString errText = job->errorText();
|
const QString errText = job->errorText();
|
||||||
// Merge metadata from subjob
|
// Merge metadata from subjob
|
||||||
KIO::Job* kiojob = dynamic_cast<KIO::Job*>(job);
|
KIO::Job* kiojob = qobject_cast<KIO::Job*>(job);
|
||||||
Q_ASSERT(kiojob);
|
Q_ASSERT(kiojob);
|
||||||
m_incomingMetaData += kiojob->metaData();
|
m_incomingMetaData += kiojob->metaData();
|
||||||
q->removeSubjob( job );
|
q->removeSubjob( job );
|
||||||
|
|
|
@ -412,10 +412,10 @@ void DeleteJob::slotResult( KJob *job )
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DELETEJOB_STATE_DELETING_FILES:
|
case DELETEJOB_STATE_DELETING_FILES:
|
||||||
// Propagate the subjob's metadata (a SimpleJob) to the real DeleteJob
|
// Propagate the subjob's metadata (a SimpleJob) to the real DeleteJob
|
||||||
// FIXME: setMetaData() in the KIO API only allows access to outgoing metadata,
|
// FIXME: setMetaData() in the KIO API only allows access to outgoing metadata,
|
||||||
// but we need to alter the incoming one
|
// but we need to alter the incoming one
|
||||||
d->m_incomingMetaData = dynamic_cast<KIO::Job*>(job)->metaData();
|
d->m_incomingMetaData = qobject_cast<KIO::Job*>(job)->metaData();
|
||||||
|
|
||||||
if ( job->error() )
|
if ( job->error() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -95,7 +95,7 @@ bool Job::addSubjob(KJob *jobBase)
|
||||||
//kDebug(7007) << "addSubjob(" << jobBase << ") this=" << this;
|
//kDebug(7007) << "addSubjob(" << jobBase << ") this=" << this;
|
||||||
|
|
||||||
bool ok = KCompositeJob::addSubjob( jobBase );
|
bool ok = KCompositeJob::addSubjob( jobBase );
|
||||||
KIO::Job *job = dynamic_cast<KIO::Job*>( jobBase );
|
KIO::Job *job = qobject_cast<KIO::Job*>( jobBase );
|
||||||
if (ok && job) {
|
if (ok && job) {
|
||||||
// Copy metadata into subjob (e.g. window-id, user-timestamp etc.)
|
// Copy metadata into subjob (e.g. window-id, user-timestamp etc.)
|
||||||
Q_D(Job);
|
Q_D(Job);
|
||||||
|
|
|
@ -60,7 +60,7 @@ KComponentData Factory::partComponentDataFromLibrary( const QString &libraryName
|
||||||
KPluginFactory *factory = loader.factory();
|
KPluginFactory *factory = loader.factory();
|
||||||
if ( !factory )
|
if ( !factory )
|
||||||
return KComponentData();
|
return KComponentData();
|
||||||
KParts::Factory *pfactory = dynamic_cast<KParts::Factory *>( factory );
|
KParts::Factory *pfactory = qobject_cast<KParts::Factory *>( factory );
|
||||||
if ( !pfactory )
|
if ( !pfactory )
|
||||||
return KComponentData();
|
return KComponentData();
|
||||||
return pfactory->partComponentData();
|
return pfactory->partComponentData();
|
||||||
|
|
|
@ -1480,7 +1480,7 @@ FormFactor Applet::formFactor() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const PopupApplet *pa = dynamic_cast<const PopupApplet *>(this);
|
const PopupApplet *pa = qobject_cast<const PopupApplet *>(this);
|
||||||
|
|
||||||
//if the applet is in a widget that isn't a containment
|
//if the applet is in a widget that isn't a containment
|
||||||
//try to retrieve the formFactor from the parent size
|
//try to retrieve the formFactor from the parent size
|
||||||
|
|
|
@ -1394,7 +1394,7 @@ void ContainmentPrivate::clearDataForMimeJob(KIO::Job *job)
|
||||||
void ContainmentPrivate::dropJobResult(KJob *job)
|
void ContainmentPrivate::dropJobResult(KJob *job)
|
||||||
{
|
{
|
||||||
#ifndef PLASMA_NO_KIO
|
#ifndef PLASMA_NO_KIO
|
||||||
KIO::TransferJob* tjob = dynamic_cast<KIO::TransferJob*>(job);
|
KIO::TransferJob* tjob = qobject_cast<KIO::TransferJob*>(job);
|
||||||
if (!tjob) {
|
if (!tjob) {
|
||||||
kDebug() << "job is not a KIO::TransferJob, won't handle the drop...";
|
kDebug() << "job is not a KIO::TransferJob, won't handle the drop...";
|
||||||
clearDataForMimeJob(tjob);
|
clearDataForMimeJob(tjob);
|
||||||
|
@ -1413,7 +1413,7 @@ void ContainmentPrivate::mimeTypeRetrieved(KIO::Job *job, const QString &mimetyp
|
||||||
{
|
{
|
||||||
#ifndef PLASMA_NO_KIO
|
#ifndef PLASMA_NO_KIO
|
||||||
kDebug() << "Mimetype Job returns." << mimetype;
|
kDebug() << "Mimetype Job returns." << mimetype;
|
||||||
KIO::TransferJob* tjob = dynamic_cast<KIO::TransferJob*>(job);
|
KIO::TransferJob* tjob = qobject_cast<KIO::TransferJob*>(job);
|
||||||
if (!tjob) {
|
if (!tjob) {
|
||||||
kDebug() << "job should be a TransferJob, but isn't";
|
kDebug() << "job should be a TransferJob, but isn't";
|
||||||
clearDataForMimeJob(job);
|
clearDataForMimeJob(job);
|
||||||
|
|
|
@ -140,11 +140,11 @@ DataEngine* DataContainer::getDataEngine()
|
||||||
DataEngine *de = NULL;
|
DataEngine *de = NULL;
|
||||||
while (de == NULL)
|
while (de == NULL)
|
||||||
{
|
{
|
||||||
o = dynamic_cast<QObject *> (o->parent());
|
o = qobject_cast<QObject *> (o->parent());
|
||||||
if (o == NULL) {
|
if (o == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
de = dynamic_cast<DataEngine *> (o);
|
de = qobject_cast<DataEngine *> (o);
|
||||||
}
|
}
|
||||||
return de;
|
return de;
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,7 @@ void PopupApplet::setWidget(QWidget *widget)
|
||||||
|
|
||||||
QLayout *existingLayout = dialog->layout();
|
QLayout *existingLayout = dialog->layout();
|
||||||
if (existingLayout) {
|
if (existingLayout) {
|
||||||
lay = dynamic_cast<QVBoxLayout *>(existingLayout);
|
lay = qobject_cast<QVBoxLayout *>(existingLayout);
|
||||||
if (!lay) {
|
if (!lay) {
|
||||||
delete existingLayout;
|
delete existingLayout;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue