Skip to content

Commit

Permalink
use qobject_cast instead of dynamic_cast where possible
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@11790 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Oct 10, 2009
1 parent d650055 commit d316cd8
Show file tree
Hide file tree
Showing 68 changed files with 343 additions and 371 deletions.
4 changes: 3 additions & 1 deletion src/analysis/vector/qgsgeometryanalyzer.cpp
Expand Up @@ -195,6 +195,8 @@ bool QgsGeometryAnalyzer::exportGeometryInformation( QgsVectorLayer* layer,
const QString& shapefileName,
const QString& fileEncoding )
{
return false;
#if 0
QgsVectorDataProvider* provider = layer->dataProvider();
QgsAttributeList allAttrs = provider->attributeIndexes();
provider->select( allAttrs, QgsRectangle(), true );
Expand Down Expand Up @@ -223,7 +225,7 @@ bool QgsGeometryAnalyzer::exportGeometryInformation( QgsVectorLayer* layer,
writer.addFeature( outFeat );
}
return true;

#endif
}
bool QgsGeometryAnalyzer::simplifyGeometry( QgsVectorLayer* layer,
const QString shapefileName,
Expand Down
8 changes: 4 additions & 4 deletions src/app/attributetable/qgsattributetabledelegate.cpp
Expand Up @@ -28,11 +28,11 @@

QgsVectorLayer *QgsAttributeTableDelegate::layer( const QAbstractItemModel *model ) const
{
const QgsAttributeTableModel *tm = dynamic_cast<const QgsAttributeTableModel*>( model );
const QgsAttributeTableModel *tm = qobject_cast<const QgsAttributeTableModel *>( model );
if ( tm )
return tm->layer();

const QgsAttributeTableFilterModel *fm = dynamic_cast<const QgsAttributeTableFilterModel*>( model );
const QgsAttributeTableFilterModel *fm = dynamic_cast<const QgsAttributeTableFilterModel *>( model );
if ( fm )
return fm->layer();

Expand All @@ -41,11 +41,11 @@ QgsVectorLayer *QgsAttributeTableDelegate::layer( const QAbstractItemModel *mode

int QgsAttributeTableDelegate::fieldIdx( const QModelIndex &index ) const
{
const QgsAttributeTableModel *tm = dynamic_cast<const QgsAttributeTableModel*>( index.model() );
const QgsAttributeTableModel *tm = qobject_cast<const QgsAttributeTableModel *>( index.model() );
if ( tm )
return tm->fieldIdx( index.column() );

const QgsAttributeTableFilterModel *fm = dynamic_cast<const QgsAttributeTableFilterModel*>( index.model() );
const QgsAttributeTableFilterModel *fm = dynamic_cast<const QgsAttributeTableFilterModel *>( index.model() );
if ( fm )
return fm->tableModel()->fieldIdx( index.column() );

Expand Down
12 changes: 6 additions & 6 deletions src/app/composer/qgscomposer.cpp
Expand Up @@ -121,7 +121,7 @@ QgsComposer::QgsComposer( QgisApp *qgis ): QMainWindow(), mFirstPaint( true )
appMenu->addAction( QgisApp::instance()->actionOptions() );

QMenu *fileMenu = menuBar()->addMenu( tr( "File" ) );
QAction *closeAction = fileMenu->addAction( tr( "Close" ), this, SLOT( close() ), tr( "Ctrl+W" ) );
fileMenu->addAction( tr( "Close" ), this, SLOT( close() ), tr( "Ctrl+W" ) );
fileMenu->addAction( mActionExportAsImage );
fileMenu->addAction( mActionExportAsPDF );
fileMenu->addAction( mActionExportAsSVG );
Expand Down Expand Up @@ -300,7 +300,7 @@ void QgsComposer::paintEvent( QPaintEvent* event )
QMap<QgsComposerItem*, QWidget*>::iterator it = mItemWidgetMap.begin();
for ( ; it != mItemWidgetMap.constEnd(); ++it )
{
QgsComposerMap* cm = dynamic_cast<QgsComposerMap*>( it.key() );
QgsComposerMap* cm = qobject_cast<QgsComposerMap *>( it.key() );
if ( cm )
{
mFirstPaint = false;
Expand Down Expand Up @@ -1077,7 +1077,7 @@ void QgsComposer::readXML( const QDomDocument& doc )
delete( *it );
}
//delete composition widget
QgsCompositionWidget* oldCompositionWidget = dynamic_cast<QgsCompositionWidget*>( mCompositionOptionsFrame->children().at( 0 ) );
QgsCompositionWidget* oldCompositionWidget = qobject_cast<QgsCompositionWidget *>( mCompositionOptionsFrame->children().at( 0 ) );
delete oldCompositionWidget;
delete mCompositionOptionsLayout;
mCompositionOptionsLayout = 0;
Expand Down Expand Up @@ -1271,7 +1271,7 @@ bool QgsComposer::containsWMSLayer() const
for ( ; item_it != mItemWidgetMap.constEnd(); ++item_it )
{
currentItem = item_it.key();
currentMap = dynamic_cast<QgsComposerMap*>( currentItem );
currentMap = dynamic_cast<QgsComposerMap *>( currentItem );
if ( currentMap )
{
if ( currentMap->containsWMSLayer() )
Expand Down Expand Up @@ -1308,15 +1308,15 @@ void QgsComposer::cleanupAfterTemplateRead()
for ( ; itemIt != mItemWidgetMap.constEnd(); ++itemIt )
{
//update all legends completely
QgsComposerLegend* legendItem = dynamic_cast<QgsComposerLegend*>( itemIt.key() );
QgsComposerLegend* legendItem = dynamic_cast<QgsComposerLegend *>( itemIt.key() );
if ( legendItem )
{
legendItem->updateLegend();
continue;
}

//update composer map extent if it does not intersect the full extent of all layers
QgsComposerMap* mapItem = dynamic_cast<QgsComposerMap*>( itemIt.key() );
QgsComposerMap* mapItem = dynamic_cast<QgsComposerMap *>( itemIt.key() );
if ( mapItem )
{
//test if composer map extent intersects extent of all layers
Expand Down
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposeritemwidget.cpp
Expand Up @@ -77,7 +77,7 @@ void QgsComposerItemWidget::on_mBackgroundColorButton_clicked()
mItem->setBrush( QBrush( QColor( newBackgroundColor ), Qt::SolidPattern ) );
//if the item is a composer map, we need to regenerate the map image
//because it usually is cached
QgsComposerMap* cm = dynamic_cast<QgsComposerMap*>( mItem );
QgsComposerMap* cm = dynamic_cast<QgsComposerMap *>( mItem );
if ( cm )
{
cm->cache();
Expand Down
10 changes: 5 additions & 5 deletions src/app/composer/qgscomposerlegendwidget.cpp
Expand Up @@ -200,7 +200,7 @@ void QgsComposerLegendWidget::on_mBoxSpaceSpinBox_valueChanged( double d )

void QgsComposerLegendWidget::on_mMoveDownPushButton_clicked()
{
QStandardItemModel* itemModel = dynamic_cast<QStandardItemModel*>( mItemTreeView->model() );
QStandardItemModel* itemModel = qobject_cast<QStandardItemModel *>( mItemTreeView->model() );
if ( !itemModel )
{
return;
Expand Down Expand Up @@ -250,7 +250,7 @@ void QgsComposerLegendWidget::on_mMoveDownPushButton_clicked()

void QgsComposerLegendWidget::on_mMoveUpPushButton_clicked()
{
QStandardItemModel* itemModel = dynamic_cast<QStandardItemModel*>( mItemTreeView->model() );
QStandardItemModel* itemModel = qobject_cast<QStandardItemModel *>( mItemTreeView->model() );
if ( !itemModel )
{
return;
Expand Down Expand Up @@ -301,7 +301,7 @@ void QgsComposerLegendWidget::on_mMoveUpPushButton_clicked()

void QgsComposerLegendWidget::on_mRemovePushButton_clicked()
{
QStandardItemModel* itemModel = dynamic_cast<QStandardItemModel*>( mItemTreeView->model() );
QStandardItemModel* itemModel = qobject_cast<QStandardItemModel *>( mItemTreeView->model() );
if ( !itemModel )
{
return;
Expand All @@ -325,7 +325,7 @@ void QgsComposerLegendWidget::on_mRemovePushButton_clicked()

void QgsComposerLegendWidget::on_mEditPushButton_clicked()
{
QStandardItemModel* itemModel = dynamic_cast<QStandardItemModel*>( mItemTreeView->model() );
QStandardItemModel* itemModel = qobject_cast<QStandardItemModel *>( mItemTreeView->model() );
if ( !itemModel )
{
return;
Expand Down Expand Up @@ -359,7 +359,7 @@ void QgsComposerLegendWidget::on_mEditPushButton_clicked()
void QgsComposerLegendWidget::on_mUpdatePushButton_clicked()
{
//get current item
QStandardItemModel* itemModel = dynamic_cast<QStandardItemModel*>( mItemTreeView->model() );
QStandardItemModel* itemModel = qobject_cast<QStandardItemModel *>( mItemTreeView->model() );
if ( !itemModel )
{
return;
Expand Down

0 comments on commit d316cd8

Please sign in to comment.