bool QgsAbstractFeatureIterator::nextFeature( QgsFeature& f ) { bool dataOk = false; switch ( mRequest.filterType() ) { case QgsFeatureRequest::FilterExpression: dataOk = nextFeatureFilterExpression( f ); break; case QgsFeatureRequest::FilterFids: dataOk = nextFeatureFilterFids( f ); break; default: dataOk = fetchFeature( f ); break; } // simplify the geometry using the simplifier configured if ( dataOk && mLocalSimplification ) { QgsGeometry* geometry = f.geometry(); if ( geometry ) simplify( f ); } return dataOk; }
bool QgsOgrFeatureIterator::nextFeatureFilterExpression( QgsFeature& f ) { if ( !mExpressionCompiled ) return QgsAbstractFeatureIterator::nextFeatureFilterExpression( f ); else return fetchFeature( f ); }
bool QgsAbstractFeatureIterator::nextFeatureFilterFids( QgsFeature& f ) { while ( fetchFeature( f ) ) { if ( mRequest.filterFids().contains( f.id() ) ) return true; } return false; }
bool QgsAbstractFeatureIterator::nextFeatureFilterExpression( QgsFeature& f ) { while ( fetchFeature( f ) ) { if ( mRequest.filterExpression()->evaluate( f ).toBool() ) return true; } return false; }
bool QgsAbstractFeatureIterator::nextFeature( QgsFeature& f ) { bool dataOk = false; if ( mRequest.limit() >= 0 && mFetchedCount >= mRequest.limit() ) { return false; } if ( mUseCachedFeatures ) { if ( mFeatureIterator != mCachedFeatures.constEnd() ) { f = mFeatureIterator->mFeature; ++mFeatureIterator; dataOk = true; } else { dataOk = false; // even the zombie dies at this point... mZombie = false; } } else { switch ( mRequest.filterType() ) { case QgsFeatureRequest::FilterExpression: dataOk = nextFeatureFilterExpression( f ); break; case QgsFeatureRequest::FilterFids: dataOk = nextFeatureFilterFids( f ); break; default: dataOk = fetchFeature( f ); break; } } // simplify the geometry using the simplifier configured if ( dataOk && mLocalSimplification ) { if ( f.constGeometry() ) simplify( f ); } if ( dataOk ) mFetchedCount++; return dataOk; }
void QgsMapTip::showMapTip( QgsMapLayer *thepLayer, QgsPoint & theMapPosition, QPoint & thePixelPosition, QgsMapCanvas *thepMapCanvas ) { // Do the search using the active layer and the preferred label // field for the layer. The label field must be defined in the layer configuration // file/database. The code required to do this is similar to identify, except // we only want the first qualifying feature and we will only display the // field defined as the label field in the layer configuration file/database. // // TODO: Define the label (display) field for each map layer in the map configuration file/database // Show the maptip on the canvas QString myTipText = fetchFeature( thepLayer, theMapPosition, thepMapCanvas ); mMapTipVisible = !myTipText.isEmpty(); if ( mMapTipVisible ) { QToolTip::showText( thepMapCanvas->mapToGlobal( thePixelPosition ), myTipText, thepMapCanvas ); // store the point so we can use it to clear the maptip later mLastPosition = thePixelPosition; } }
void QgsMapTip::showMapTip( QgsMapLayer *pLayer, QgsPoint & mapPosition, QPoint & thePixelPosition, QgsMapCanvas *pMapCanvas ) { // Do the search using the active layer and the preferred label field for the // layer. The label field must be defined in the layer configuration // file/database. The code required to do this is similar to identify, except // we only want the first qualifying feature and we will only display the // field defined as the label field in the layer configuration file/database // Show the maptip on the canvas QString tipText, lastTipText, tipHtml, bodyStyle, containerStyle, backgroundColor, borderColor; delete mWidget; mWidget = new QWidget( pMapCanvas ); mWebView = new QgsWebView( mWidget ); #if WITH_QTWEBKIT mWebView->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );//Handle link clicks by yourself mWebView->setContextMenuPolicy( Qt::NoContextMenu ); //No context menu is allowed if you don't need it connect( mWebView, SIGNAL( linkClicked( QUrl ) ), this, SLOT( onLinkClicked( QUrl ) ) ); #endif mWebView->page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled, true ); mWebView->page()->settings()->setAttribute( QWebSettings::JavascriptEnabled, true ); QHBoxLayout* layout = new QHBoxLayout; layout->addWidget( mWebView ); mWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); mWidget->setLayout( layout ); //assure the map tip is never larger than half the map canvas const int MAX_WIDTH = pMapCanvas->geometry().width() / 2; const int MAX_HEIGHT = pMapCanvas->geometry().height() / 2; mWidget->setMaximumSize( MAX_WIDTH, MAX_HEIGHT ); // start with 0 size, // the content will automatically make it grow up to MaximumSize mWidget->resize( 0, 0 ); backgroundColor = mWidget->palette().base().color().name(); borderColor = mWidget->palette().shadow().color().name(); mWidget->setStyleSheet( QString( ".QWidget{" "border: 1px solid %1;" "background-color: %2;}" ).arg( borderColor, backgroundColor ) ); tipText = fetchFeature( pLayer, mapPosition, pMapCanvas ); mMapTipVisible = !tipText.isEmpty(); if ( !mMapTipVisible ) { clear(); return; } if ( tipText == lastTipText ) { return; } bodyStyle = QString( "background-color: %1;" "margin: 0;" ).arg( backgroundColor ); containerStyle = QString( "display: inline-block;" "margin: 0px" ); tipHtml = QString( "<html>" "<body style='%1'>" "<div id='QgsWebViewContainer' style='%2'>%3</div>" "</body>" "</html>" ).arg( bodyStyle, containerStyle, tipText ); mWidget->move( thePixelPosition.x(), thePixelPosition.y() ); mWebView->setHtml( tipHtml ); lastTipText = tipText; mWidget->show(); #if WITH_QTWEBKIT int scrollbarWidth = mWebView->page()->mainFrame()->scrollBarGeometry( Qt::Vertical ).width(); int scrollbarHeight = mWebView->page()->mainFrame()->scrollBarGeometry( Qt::Horizontal ).height(); if ( scrollbarWidth > 0 || scrollbarHeight > 0 ) { // Get the content size QWebElement container = mWebView->page()->mainFrame()->findFirstElement( QStringLiteral( "#QgsWebViewContainer" ) ); int width = container.geometry().width() + 5 + scrollbarWidth; int height = container.geometry().height() + 5 + scrollbarHeight; mWidget->resize( width, height ); } #endif }