QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool* tool, Qt::WFlags f ) : QDialog( tool->canvas()->topLevelWidget(), f ), mTool( tool ) { setupUi( this ); QPushButton *nb = new QPushButton( tr( "&New" ) ); buttonBox->addButton( nb, QDialogButtonBox::ActionRole ); connect( nb, SIGNAL( clicked() ), this, SLOT( restart() ) ); mMeasureArea = tool->measureArea(); mTotal = 0.; // Set one cell row where to update current distance // If measuring area, the table doesn't get shown QTreeWidgetItem* item = new QTreeWidgetItem( QStringList( QString::number( 0, 'f', 1 ) ) ); item->setTextAlignment( 0, Qt::AlignRight ); mTable->addTopLevelItem( item ); // Update whenever the canvas has refreshed. Maybe more often than needed, // but at least every time any canvas related settings changes connect( mTool->canvas(), SIGNAL( mapCanvasRefreshed() ), this, SLOT( updateSettings() ) ); updateSettings(); }
void QgsMapCanvas::rendererJobFinished() { QgsDebugMsg( QString( "CANVAS finish! %1" ).arg( !mJobCancelled ) ); mMapUpdateTimer.stop(); // TODO: would be better to show the errors in message bar Q_FOREACH ( const QgsMapRendererJob::Error& error, mJob->errors() ) { QgsMessageLog::logMessage( error.layerID + " :: " + error.message, tr( "Rendering" ) ); } if ( !mJobCancelled ) { // take labeling results before emitting renderComplete, so labeling map tools // connected to signal work with correct results delete mLabelingResults; mLabelingResults = mJob->takeLabelingResults(); QImage img = mJob->renderedImage(); // emit renderComplete to get our decorations drawn QPainter p( &img ); emit renderComplete( &p ); QSettings settings; if ( settings.value( "/Map/logCanvasRefreshEvent", false ).toBool() ) { QString logMsg = tr( "Canvas refresh: %1 ms" ).arg( mJob->renderingTime() ); QgsMessageLog::logMessage( logMsg, tr( "Rendering" ) ); } if ( mDrawRenderingStats ) { int w = img.width(), h = img.height(); QFont fnt = p.font(); fnt.setBold( true ); p.setFont( fnt ); int lh = p.fontMetrics().height() * 2; QRect r( 0, h - lh, w, lh ); p.setPen( Qt::NoPen ); p.setBrush( QColor( 0, 0, 0, 110 ) ); p.drawRect( r ); p.setPen( Qt::white ); QString msg = QString( "%1 :: %2 ms" ).arg( mUseParallelRendering ? "PARALLEL" : "SEQUENTIAL" ).arg( mJob->renderingTime() ); p.drawText( r, msg, QTextOption( Qt::AlignCenter ) ); } p.end(); mMap->setContent( img, imageRect( img, mJob->mapSettings() ) ); } // now we are in a slot called from mJob - do not delete it immediately // so the class is still valid when the execution returns to the class mJob->deleteLater(); mJob = 0; emit mapCanvasRefreshed(); }
QgsMapLayerStyleManagerWidget::QgsMapLayerStyleManagerWidget( QgsMapLayer* layer, QgsMapCanvas *canvas, QWidget *parent ) : QgsMapStylePanel( layer, canvas, parent ) { mModel = new QStandardItemModel( this ); mStyleList = new QListView( this ); mStyleList->setModel( mModel ); mStyleList->setViewMode( QListView::ListMode ); mStyleList->setResizeMode( QListView::Adjust ); QToolBar* toolbar = new QToolBar( this ); QAction* addAction = toolbar->addAction( tr( "Add" ) ); connect( addAction, SIGNAL( triggered() ), this, SLOT( addStyle() ) ); QAction* removeAction = toolbar->addAction( tr( "Remove Current" ) ); connect( removeAction, SIGNAL( triggered() ), this, SLOT( removeStyle() ) ); connect( canvas, SIGNAL( mapCanvasRefreshed() ), this, SLOT( updateCurrent() ) ); connect( mStyleList, SIGNAL( clicked( QModelIndex ) ), this, SLOT( styleClicked( QModelIndex ) ) ); setLayout( new QVBoxLayout() ); layout()->setContentsMargins( 0, 0, 0, 0 ); layout()->addWidget( toolbar ); layout()->addWidget( mStyleList ); connect( mLayer->styleManager(), SIGNAL( currentStyleChanged( QString ) ), this, SLOT( currentStyleChanged( QString ) ) ); connect( mLayer->styleManager(), SIGNAL( styleAdded( QString ) ), this, SLOT( styleAdded( QString ) ) ); connect( mLayer->styleManager(), SIGNAL( styleremoved( QString ) ), this, SLOT( styleRemoved( QString ) ) ); connect( mLayer->styleManager(), SIGNAL( styleRenamed( QString, QString ) ), this, SLOT( styleRenamed( QString, QString ) ) ); mModel->clear(); Q_FOREACH ( const QString name, mLayer->styleManager()->styles() ) { QString stylename = name; if ( stylename.isEmpty() ) stylename = "(default)"; QStandardItem* item = new QStandardItem( stylename ); mModel->appendRow( item ); } QString active = mLayer->styleManager()->currentStyle(); currentStyleChanged( active ); }