Skip to content

Commit

Permalink
Add overrides pt 5
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 20, 2015
1 parent cfb4b33 commit f0447db
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 65 deletions.
5 changes: 3 additions & 2 deletions src/app/nodetool/qgsmaptoolnodetool.cpp
Expand Up @@ -34,15 +34,15 @@
struct QgsExcludePointFilter : public QgsPointLocator::MatchFilter
{
QgsExcludePointFilter( const QgsPoint& exclPoint ) : mExclPoint( exclPoint ) {}
bool acceptMatch( const QgsPointLocator::Match& match ) { return match.point() != mExclPoint; }
bool acceptMatch( const QgsPointLocator::Match& match ) override { return match.point() != mExclPoint; }
QgsPoint mExclPoint;
};

//! Match filter that accepts only matches from a particular feature ID
struct QgsFeatureIdFilter : public QgsPointLocator::MatchFilter
{
QgsFeatureIdFilter( const QgsFeatureId& fid ) : mFid( fid ) {}
bool acceptMatch( const QgsPointLocator::Match& match ) { return match.featureId() == mFid; }
bool acceptMatch( const QgsPointLocator::Match& match ) override { return match.featureId() == mFid; }
QgsFeatureId mFid;
};

Expand Down Expand Up @@ -394,6 +394,7 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )

QgsVectorLayer *vlayer = mSelectedFeature->vlayer();
Q_ASSERT( vlayer );
Q_UNUSED( vlayer );

// try to find a piece of currently selected geometry
QgsFeatureIdFilter filterFid( mSelectedFeature->featureId() );
Expand Down
34 changes: 17 additions & 17 deletions src/core/qgspointlocator.cpp
Expand Up @@ -62,11 +62,11 @@ class QgsPointLocator_Stream : public IDataStream
QgsPointLocator_Stream( const QLinkedList<RTree::Data*>& dataList ) : mDataList( dataList ), mIt( mDataList ) { }
~QgsPointLocator_Stream() { }

virtual IData* getNext() { return mIt.next(); }
virtual bool hasNext() { return mIt.hasNext(); }
virtual IData* getNext() override { return mIt.next(); }
virtual bool hasNext() override { return mIt.hasNext(); }

virtual uint32_t size() { Q_ASSERT( 0 && "not available" ); return 0; }
virtual void rewind() { Q_ASSERT( 0 && "not available" ); }
virtual uint32_t size() override { Q_ASSERT( 0 && "not available" ); return 0; }
virtual void rewind() override { Q_ASSERT( 0 && "not available" ); }

private:
QLinkedList<RTree::Data*> mDataList;
Expand All @@ -84,10 +84,10 @@ class QgsPointLocator_VisitorNearestVertex : public IVisitor
QgsPointLocator_VisitorNearestVertex( QgsPointLocator* pl, QgsPointLocator::Match& m, const QgsPoint& srcPoint, QgsPointLocator::MatchFilter* filter = 0 )
: mLocator( pl ), mBest( m ), mSrcPoint( srcPoint ), mFilter( filter ) {}

void visitNode( const INode& n ) { Q_UNUSED( n ); }
void visitData( std::vector<const IData*>& v ) { Q_UNUSED( v ); }
void visitNode( const INode& n ) override { Q_UNUSED( n ); }
void visitData( std::vector<const IData*>& v ) override { Q_UNUSED( v ); }

void visitData( const IData& d )
void visitData( const IData& d ) override
{
QgsFeatureId id = d.getIdentifier();
QgsGeometry* geom = mLocator->mGeoms.value( id );
Expand Down Expand Up @@ -122,10 +122,10 @@ class QgsPointLocator_VisitorNearestEdge : public IVisitor
QgsPointLocator_VisitorNearestEdge( QgsPointLocator* pl, QgsPointLocator::Match& m, const QgsPoint& srcPoint, QgsPointLocator::MatchFilter* filter = 0 )
: mLocator( pl ), mBest( m ), mSrcPoint( srcPoint ), mFilter( filter ) {}

void visitNode( const INode& n ) { Q_UNUSED( n ); }
void visitData( std::vector<const IData*>& v ) { Q_UNUSED( v ); }
void visitNode( const INode& n ) override { Q_UNUSED( n ); }
void visitData( std::vector<const IData*>& v ) override { Q_UNUSED( v ); }

void visitData( const IData& d )
void visitData( const IData& d ) override
{
QgsFeatureId id = d.getIdentifier();
QgsGeometry* geom = mLocator->mGeoms.value( id );
Expand Down Expand Up @@ -168,10 +168,10 @@ class QgsPointLocator_VisitorArea : public IVisitor

~QgsPointLocator_VisitorArea() { delete mGeomPt; }

void visitNode( const INode& n ) { Q_UNUSED( n ); }
void visitData( std::vector<const IData*>& v ) { Q_UNUSED( v ); }
void visitNode( const INode& n ) override { Q_UNUSED( n ); }
void visitData( std::vector<const IData*>& v ) override { Q_UNUSED( v ); }

void visitData( const IData& d )
void visitData( const IData& d ) override
{
QgsFeatureId id = d.getIdentifier();
QgsGeometry* g = mLocator->mGeoms.value( id );
Expand Down Expand Up @@ -488,10 +488,10 @@ class QgsPointLocator_VisitorEdgesInRect : public IVisitor
QgsPointLocator_VisitorEdgesInRect( QgsPointLocator* pl, QgsPointLocator::MatchList& lst, const QgsRectangle& srcRect, QgsPointLocator::MatchFilter* filter = 0 )
: mLocator( pl ), mList( lst ), mSrcRect( srcRect ), mFilter( filter ) {}

void visitNode( const INode& n ) { Q_UNUSED( n ); }
void visitData( std::vector<const IData*>& v ) { Q_UNUSED( v ); }
void visitNode( const INode& n ) override { Q_UNUSED( n ); }
void visitData( std::vector<const IData*>& v ) override { Q_UNUSED( v ); }

void visitData( const IData& d )
void visitData( const IData& d ) override
{
QgsFeatureId id = d.getIdentifier();
QgsGeometry* geom = mLocator->mGeoms.value( id );
Expand Down Expand Up @@ -526,7 +526,7 @@ class QgsPointLocator_DumpTree : public SpatialIndex::IQueryStrategy

public:

void getNextEntry( const IEntry& entry, id_type& nextEntry, bool& hasNext )
void getNextEntry( const IEntry& entry, id_type& nextEntry, bool& hasNext ) override
{
const INode* n = dynamic_cast<const INode*>( &entry );
qDebug( "NODE: %ld", n->getIdentifier() );
Expand Down
20 changes: 10 additions & 10 deletions src/core/qgsvectorlayereditpassthrough.h
Expand Up @@ -24,16 +24,16 @@ class CORE_EXPORT QgsVectorLayerEditPassthrough : public QgsVectorLayerEditBuffe
Q_OBJECT
public:
QgsVectorLayerEditPassthrough( QgsVectorLayer* layer ) { L = layer; }
bool isModified() const { return false; }
bool addFeature( QgsFeature& f );
bool addFeatures( QgsFeatureList& features );
bool deleteFeature( QgsFeatureId fid );
bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom );
bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
bool addAttribute( const QgsField &field );
bool deleteAttribute( int attr );
bool commitChanges( QStringList& commitErrors );
void rollBack();
bool isModified() const override { return false; }
bool addFeature( QgsFeature& f ) override;
bool addFeatures( QgsFeatureList& features ) override;
bool deleteFeature( QgsFeatureId fid ) override;
bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom ) override;
bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() ) override;
bool addAttribute( const QgsField &field ) override;
bool deleteAttribute( int attr ) override;
bool commitChanges( QStringList& commitErrors ) override;
void rollBack() override;

};

Expand Down
52 changes: 27 additions & 25 deletions src/gui/qgsbrowsertreeview.cpp
Expand Up @@ -23,7 +23,7 @@

QgsBrowserTreeView::QgsBrowserTreeView( QWidget *parent )
: QTreeView( parent )
,mSettingsSection("browser")
, mSettingsSection( "browser" )
{
}

Expand All @@ -42,17 +42,17 @@ void QgsBrowserTreeView::setModel( QAbstractItemModel* model )

void QgsBrowserTreeView::showEvent( QShowEvent * e )
{
Q_UNUSED(e);
Q_UNUSED( e );
QgsDebugMsg( "Entered" );
if ( model() )
restoreState();
QTreeView::showEvent(e);
QTreeView::showEvent( e );
}

// closeEvent is not called when application is closed
void QgsBrowserTreeView::hideEvent( QHideEvent * e )
{
Q_UNUSED(e);
Q_UNUSED( e );
QgsDebugMsg( "Entered" );
// hideEvent() may be called (Mac) before showEvent
if ( model() )
Expand All @@ -74,7 +74,7 @@ void QgsBrowserTreeView::restoreState()
QgsDebugMsg( "Entered" );
QSettings settings;
mExpandPaths = settings.value( expandedPathsKey(), QVariant() ).toStringList();

QgsDebugMsg( "mExpandPaths = " + mExpandPaths.join( " " ) );
if ( !mExpandPaths.isEmpty() )
{
Expand All @@ -85,20 +85,22 @@ void QgsBrowserTreeView::restoreState()
if ( expandIndex.isValid() )
expandIndexSet.insert( expandIndex );
else
QgsDebugMsg( "index for path " + path + " not found");
}
{
QgsDebugMsg( "index for path " + path + " not found" );
}
}
foreach ( QModelIndex expandIndex, expandIndexSet )
{
expandTree( expandIndex );
}
}
}
}
else
{
// expand root favourites item
QModelIndex index = QgsBrowserModel::findPath( model(), "favourites:" );
expand( index );
}
}
}
}

void QgsBrowserTreeView::expandTree( const QModelIndex & index )
{
Expand All @@ -116,7 +118,7 @@ void QgsBrowserTreeView::expandTree( const QModelIndex & index )

bool QgsBrowserTreeView::treeExpanded( const QModelIndex & index )
{
if( !model() )
if ( !model() )
return false;
if ( !isExpanded( index ) )
return false;
Expand All @@ -129,7 +131,7 @@ bool QgsBrowserTreeView::treeExpanded( const QModelIndex & index )

bool QgsBrowserTreeView::hasExpandedDescendant( const QModelIndex& index ) const
{
if (!model())
if ( !model() )
return false;

for ( int i = 0 ; i < model()->rowCount( index ); i++ )
Expand All @@ -145,17 +147,17 @@ bool QgsBrowserTreeView::hasExpandedDescendant( const QModelIndex& index ) const
}

// rowsInserted signal is used to continue in state restoring
void QgsBrowserTreeView::rowsInserted ( const QModelIndex & parentIndex, int start, int end )
void QgsBrowserTreeView::rowsInserted( const QModelIndex & parentIndex, int start, int end )
{
QTreeView::rowsInserted ( parentIndex, start, end );
QTreeView::rowsInserted( parentIndex, start, end );

if ( !model() )
return;

if ( mExpandPaths.isEmpty() )
return;

QgsDebugMsgLevel( "mExpandPaths = " + mExpandPaths.join(","), 2 );
QgsDebugMsgLevel( "mExpandPaths = " + mExpandPaths.join( "," ), 2 );

QString parentPath = model()->data( parentIndex, QgsBrowserModel::PathRole ).toString();
QgsDebugMsgLevel( "parentPath = " + parentPath, 2 );
Expand All @@ -179,7 +181,7 @@ void QgsBrowserTreeView::rowsInserted ( const QModelIndex & parentIndex, int sta
QModelIndex childIndex = model()->index( i, 0, parentIndex );
QString childPath = model()->data( childIndex, QgsBrowserModel::PathRole ).toString();

if( mExpandPaths.contains(childPath) || mExpandPaths.indexOf ( QRegExp ( "^" + childPath + "/.*" ) ) != -1 )
if ( mExpandPaths.contains( childPath ) || mExpandPaths.indexOf( QRegExp( "^" + childPath + "/.*" ) ) != -1 )
{
expand( childIndex );
}
Expand All @@ -194,10 +196,10 @@ QString QgsBrowserTreeView::expandedPathsKey() const
QStringList QgsBrowserTreeView::expandedPathsList( const QModelIndex & index )
{
QStringList paths;

if ( !model() )
return paths;
return paths;

for ( int i = 0; i < model()->rowCount( index ); i++ )
{
QModelIndex childIndex = model()->index( i, 0, index );
Expand All @@ -207,12 +209,12 @@ QStringList QgsBrowserTreeView::expandedPathsList( const QModelIndex & index )
if ( !childrenPaths.isEmpty() )
{
paths.append( childrenPaths );
}
}
else
{
paths.append( model()->data( childIndex, QgsBrowserModel::PathRole ).toString() );
}
}
}
}
}
}
return paths;
}
}
10 changes: 5 additions & 5 deletions src/gui/qgsbrowsertreeview.h
Expand Up @@ -33,9 +33,9 @@ class GUI_EXPORT QgsBrowserTreeView : public QTreeView
QgsBrowserTreeView( QWidget *parent = 0 );
~QgsBrowserTreeView();

virtual void setModel( QAbstractItemModel* model );
virtual void showEvent( QShowEvent * e );
virtual void hideEvent( QHideEvent * e );
virtual void setModel( QAbstractItemModel* model ) override;
virtual void showEvent( QShowEvent * e ) override;
virtual void hideEvent( QHideEvent * e ) override;

// returns true if at least one descendat is expanded, used in refresh
bool hasExpandedDescendant( const QModelIndex& index ) const;
Expand All @@ -44,8 +44,8 @@ class GUI_EXPORT QgsBrowserTreeView : public QTreeView
void setSettingsSection( const QString & section ) { mSettingsSection = section; }

protected slots:
virtual void rowsInserted ( const QModelIndex & parentIndex, int start, int end );
virtual void rowsInserted( const QModelIndex & parentIndex, int start, int end ) override;

private:
QString mSettingsSection;
// initial expanded paths
Expand Down
4 changes: 2 additions & 2 deletions src/providers/postgres/qgspostgresprovider.h
Expand Up @@ -279,7 +279,7 @@ class QgsPostgresProvider : public QgsVectorDataProvider
/**
* Returns the transaction this data provider is included in, if any.
*/
virtual QgsTransaction* transaction() const;
virtual QgsTransaction* transaction() const override;

signals:
/**
Expand Down Expand Up @@ -482,7 +482,7 @@ class QgsPostgresProvider : public QgsVectorDataProvider

QgsPostgresTransaction* mTransaction;

void setTransaction( QgsTransaction* transaction );
void setTransaction( QgsTransaction* transaction ) override;
};


Expand Down
8 changes: 4 additions & 4 deletions src/providers/postgres/qgspostgrestransaction.h
Expand Up @@ -26,15 +26,15 @@ class QgsPostgresTransaction : public QgsTransaction
{
public:
QgsPostgresTransaction( const QString& connString );
bool executeSql( const QString& sql, QString& error );
bool executeSql( const QString& sql, QString& error ) override;
QgsPostgresConn* connection() const { return mConn; }

private:
QgsPostgresConn* mConn;

bool beginTransaction( QString& error, int statementTimeout );
bool commitTransaction( QString& error );
bool rollbackTransaction( QString& error );
bool beginTransaction( QString& error, int statementTimeout ) override;
bool commitTransaction( QString& error ) override;
bool rollbackTransaction( QString& error ) override;

};

Expand Down

0 comments on commit f0447db

Please sign in to comment.