void QgsGraduatedSymbolRendererWidget::disconnectUpdateHandlers() { disconnect( spinGraduatedClasses, SIGNAL( valueChanged( int ) ), this, SLOT( classifyGraduated() ) ); disconnect( cboGraduatedMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( classifyGraduated() ) ); disconnect( btnColorRamp, &QgsColorRampButton::colorRampChanged, this, &QgsGraduatedSymbolRendererWidget::reapplyColorRamp ); disconnect( spinPrecision, SIGNAL( valueChanged( int ) ), this, SLOT( labelFormatChanged() ) ); disconnect( cbxTrimTrailingZeroes, SIGNAL( toggled( bool ) ), this, SLOT( labelFormatChanged() ) ); disconnect( txtLegendFormat, SIGNAL( textChanged( QString ) ), this, SLOT( labelFormatChanged() ) ); disconnect( minSizeSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( reapplySizes() ) ); disconnect( maxSizeSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( reapplySizes() ) ); disconnect( mModel, SIGNAL( rowsMoved() ), this, SLOT( rowsMoved() ) ); disconnect( mModel, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ), this, SLOT( modelDataChanged() ) ); }
int QAbstractItemModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: dataChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break; case 1: headerDataChanged((*reinterpret_cast< Qt::Orientation(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 2: layoutChanged(); break; case 3: layoutAboutToBeChanged(); break; case 4: rowsAboutToBeInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 5: rowsInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 6: rowsAboutToBeRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 7: rowsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 8: columnsAboutToBeInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 9: columnsInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 10: columnsAboutToBeRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 11: columnsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 12: modelAboutToBeReset(); break; case 13: modelReset(); break; case 14: rowsAboutToBeMoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QModelIndex(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break; case 15: rowsMoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QModelIndex(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break; case 16: columnsAboutToBeMoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QModelIndex(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break; case 17: columnsMoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QModelIndex(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break; case 18: { bool _r = submit(); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 19: revert(); break; default: ; } _id -= 20; } return _id; }
void QgsGraduatedSymbolRendererV2Widget::connectUpdateHandlers() { connect( spinGraduatedClasses, SIGNAL( valueChanged( int ) ), this, SLOT( classifyGraduated() ) ); connect( cboGraduatedMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( classifyGraduated() ) ); connect( cboGraduatedColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( reapplyColorRamp() ) ); connect( cboGraduatedColorRamp, SIGNAL( sourceRampEdited() ), this, SLOT( reapplyColorRamp() ) ); connect( mButtonEditRamp, SIGNAL( clicked() ), cboGraduatedColorRamp, SLOT( editSourceRamp() ) ); connect( cbxInvertedColorRamp, SIGNAL( toggled( bool ) ), this, SLOT( reapplyColorRamp() ) ); connect( spinPrecision, SIGNAL( valueChanged( int ) ), this, SLOT( labelFormatChanged() ) ); connect( cbxTrimTrailingZeroes, SIGNAL( toggled( bool ) ), this, SLOT( labelFormatChanged() ) ); connect( txtLegendFormat, SIGNAL( textChanged( QString ) ), this, SLOT( labelFormatChanged() ) ); connect( minSizeSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( reapplySizes() ) ); connect( maxSizeSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( reapplySizes() ) ); connect( mModel, SIGNAL( rowsMoved() ), this, SLOT( rowsMoved() ) ); connect( mModel, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ), this, SLOT( modelDataChanged() ) ); }
void QgsGraduatedSymbolRendererModel::sort( int column, Qt::SortOrder order ) { if ( column == 0 ) { return; } if ( column == 1 ) { mRenderer->sortByValue( order ); } else if ( column == 2 ) { mRenderer->sortByLabel( order ); } emit rowsMoved(); emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->ranges().size(), 0 ) ); }
bool QgsCategorizedSymbolRendererV2Model::dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) { Q_UNUSED( row ); Q_UNUSED( column ); if ( action != Qt::MoveAction ) return true; if ( !data->hasFormat( mMimeFormat ) ) return false; QByteArray encodedData = data->data( mMimeFormat ); QDataStream stream( &encodedData, QIODevice::ReadOnly ); QVector<int> rows; while ( !stream.atEnd() ) { int r; stream >> r; rows.append( r ); } int to = parent.row(); // to is -1 if dragged outside items, i.e. below any item, // then move to the last position if ( to == -1 ) to = mRenderer->categories().size(); // out of rang ok, will be decreased for ( int i = rows.size() - 1; i >= 0; i-- ) { QgsDebugMsg( QString( "move %1 to %2" ).arg( rows[i] ).arg( to ) ); int t = to; // moveCategory first removes and then inserts if ( rows[i] < to ) t--; mRenderer->moveCategory( rows[i], t ); // current moved under another, shift its index up for ( int j = 0; j < i; j++ ) { if ( to < rows[j] && rows[i] > rows[j] ) rows[j] += 1; } // removed under 'to' so the target shifted down if ( rows[i] < to ) to--; } emit dataChanged( createIndex( 0, 0, 0 ), createIndex( mRenderer->categories().size(), 0 ) ); emit rowsMoved(); return false; }
int QtTableModelInterface::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: cellsChanged((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< int(*)>(_a[4])),(*reinterpret_cast< const QList<QByteArray>(*)>(_a[5]))); break; case 1: rowsInserted((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 2: rowsRemoved((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 3: rowsMoved((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 4: columnsInserted((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 5: columnsRemoved((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 6: columnsMoved((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; default: ; } _id -= 7; } return _id; }
QgsCategorizedSymbolRendererV2Widget::QgsCategorizedSymbolRendererV2Widget( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer ) : QgsRendererV2Widget( layer, style ) , mRenderer( 0 ) , mModel( 0 ) { // try to recognize the previous renderer // (null renderer means "no previous renderer") if ( renderer ) { mRenderer = QgsCategorizedSymbolRendererV2::convertFromRenderer( renderer ); } if ( !mRenderer ) { mRenderer = new QgsCategorizedSymbolRendererV2( "", QgsCategoryList() ); } QString attrName = mRenderer->classAttribute(); mOldClassificationAttribute = attrName; // setup user interface setupUi( this ); mExpressionWidget->setLayer( mLayer ); cboCategorizedColorRamp->populate( mStyle ); int randomIndex = cboCategorizedColorRamp->findText( tr( "Random colors" ) ); if ( randomIndex != -1 ) { cboCategorizedColorRamp->setCurrentIndex( randomIndex ); } // set project default color ramp QString defaultColorRamp = QgsProject::instance()->readEntry( "DefaultStyles", "/ColorRamp", "" ); if ( defaultColorRamp != "" ) { int index = cboCategorizedColorRamp->findText( defaultColorRamp, Qt::MatchCaseSensitive ); if ( index >= 0 ) cboCategorizedColorRamp->setCurrentIndex( index ); } mCategorizedSymbol = QgsSymbolV2::defaultSymbol( mLayer->geometryType() ); mModel = new QgsCategorizedSymbolRendererV2Model( this ); mModel->setRenderer( mRenderer ); // update GUI from renderer updateUiFromRenderer(); viewCategories->setModel( mModel ); viewCategories->resizeColumnToContents( 0 ); viewCategories->resizeColumnToContents( 1 ); viewCategories->resizeColumnToContents( 2 ); viewCategories->setStyle( new QgsCategorizedSymbolRendererV2ViewStyle( viewCategories->style() ) ); connect( mModel, SIGNAL( rowsMoved() ), this, SLOT( rowsMoved() ) ); connect( mExpressionWidget, SIGNAL( fieldChanged( QString ) ), this, SLOT( categoryColumnChanged( QString ) ) ); connect( viewCategories, SIGNAL( doubleClicked( const QModelIndex & ) ), this, SLOT( categoriesDoubleClicked( const QModelIndex & ) ) ); connect( viewCategories, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( contextMenuViewCategories( const QPoint& ) ) ); connect( btnChangeCategorizedSymbol, SIGNAL( clicked() ), this, SLOT( changeCategorizedSymbol() ) ); connect( btnAddCategories, SIGNAL( clicked() ), this, SLOT( addCategories() ) ); connect( btnDeleteCategories, SIGNAL( clicked() ), this, SLOT( deleteCategories() ) ); connect( btnDeleteAllCategories, SIGNAL( clicked() ), this, SLOT( deleteAllCategories() ) ); connect( btnAddCategory, SIGNAL( clicked() ), this, SLOT( addCategory() ) ); connect( cbxInvertedColorRamp, SIGNAL( toggled( bool ) ), this, SLOT( applyColorRamp() ) ); connect( cboCategorizedColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) ); // menus for data-defined rotation/size QMenu* advMenu = new QMenu; advMenu->addAction( tr( "Symbol levels..." ), this, SLOT( showSymbolLevels() ) ); mDataDefinedMenus = new QgsRendererV2DataDefinedMenus( advMenu, mLayer, mRenderer->rotationField(), mRenderer->sizeScaleField(), mRenderer->scaleMethod() ); connect( mDataDefinedMenus, SIGNAL( rotationFieldChanged( QString ) ), this, SLOT( rotationFieldChanged( QString ) ) ); connect( mDataDefinedMenus, SIGNAL( sizeScaleFieldChanged( QString ) ), this, SLOT( sizeScaleFieldChanged( QString ) ) ); connect( mDataDefinedMenus, SIGNAL( scaleMethodChanged( QgsSymbolV2::ScaleMethod ) ), this, SLOT( scaleMethodChanged( QgsSymbolV2::ScaleMethod ) ) ); btnAdvanced->setMenu( advMenu ); }
QgsGraduatedSymbolRendererV2Widget::QgsGraduatedSymbolRendererV2Widget( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer ) : QgsRendererV2Widget( layer, style ) , mRenderer( 0 ) , mModel( 0 ) { // try to recognize the previous renderer // (null renderer means "no previous renderer") if ( !renderer || renderer->type() != "graduatedSymbol" ) { // we're not going to use it - so let's delete the renderer delete renderer; mRenderer = new QgsGraduatedSymbolRendererV2( "", QgsRangeList() ); } else { mRenderer = static_cast<QgsGraduatedSymbolRendererV2*>( renderer ); } // setup user interface setupUi( this ); mExpressionWidget->setFilters( QgsFieldProxyModel::Numeric | QgsFieldProxyModel::Date ); mExpressionWidget->setLayer( mLayer ); cboGraduatedColorRamp->populate( mStyle ); // set project default color ramp QString defaultColorRamp = QgsProject::instance()->readEntry( "DefaultStyles", "/ColorRamp", "" ); if ( defaultColorRamp != "" ) { int index = cboGraduatedColorRamp->findText( defaultColorRamp, Qt::MatchCaseSensitive ); if ( index >= 0 ) cboGraduatedColorRamp->setCurrentIndex( index ); } mModel = new QgsGraduatedSymbolRendererV2Model( this ); mModel->setRenderer( mRenderer ); viewGraduated->setModel( mModel ); viewGraduated->resizeColumnToContents( 0 ); viewGraduated->resizeColumnToContents( 1 ); viewGraduated->resizeColumnToContents( 2 ); viewGraduated->setStyle( new QgsGraduatedSymbolRendererV2ViewStyle( viewGraduated->style() ) ); mGraduatedSymbol = QgsSymbolV2::defaultSymbol( mLayer->geometryType() ); connect( mExpressionWidget, SIGNAL( fieldChanged( QString ) ), this, SLOT( graduatedColumnChanged( QString ) ) ); connect( viewGraduated, SIGNAL( doubleClicked( const QModelIndex & ) ), this, SLOT( rangesDoubleClicked( const QModelIndex & ) ) ); connect( viewGraduated, SIGNAL( clicked( const QModelIndex & ) ), this, SLOT( rangesClicked( const QModelIndex & ) ) ); connect( viewGraduated, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( contextMenuViewCategories( const QPoint& ) ) ); connect( mModel, SIGNAL( rowsMoved() ), this, SLOT( rowsMoved() ) ); connect( btnGraduatedClassify, SIGNAL( clicked() ), this, SLOT( classifyGraduated() ) ); connect( btnChangeGraduatedSymbol, SIGNAL( clicked() ), this, SLOT( changeGraduatedSymbol() ) ); connect( btnGraduatedDelete, SIGNAL( clicked() ), this, SLOT( deleteClasses() ) ); connect( btnDeleteAllClasses, SIGNAL( clicked() ), this, SLOT( deleteAllClasses() ) ); connect( btnGraduatedAdd, SIGNAL( clicked() ), this, SLOT( addClass() ) ); // initialize from previously set renderer updateUiFromRenderer(); connect( spinGraduatedClasses, SIGNAL( valueChanged( int ) ) , this, SLOT( classifyGraduated() ) ); connect( cboGraduatedMode, SIGNAL( currentIndexChanged( int ) ) , this, SLOT( classifyGraduated() ) ); connect( cboGraduatedColorRamp, SIGNAL( currentIndexChanged( int ) ) , this, SLOT( reapplyColorRamp() ) ); // menus for data-defined rotation/size QMenu* advMenu = new QMenu; advMenu->addAction( tr( "Symbol levels..." ), this, SLOT( showSymbolLevels() ) ); mDataDefinedMenus = new QgsRendererV2DataDefinedMenus( advMenu, mLayer, mRenderer->rotationField(), mRenderer->sizeScaleField(), mRenderer->scaleMethod() ); connect( mDataDefinedMenus, SIGNAL( rotationFieldChanged( QString ) ), this, SLOT( rotationFieldChanged( QString ) ) ); connect( mDataDefinedMenus, SIGNAL( sizeScaleFieldChanged( QString ) ), this, SLOT( sizeScaleFieldChanged( QString ) ) ); connect( mDataDefinedMenus, SIGNAL( scaleMethodChanged( QgsSymbolV2::ScaleMethod ) ), this, SLOT( scaleMethodChanged( QgsSymbolV2::ScaleMethod ) ) ); btnAdvanced->setMenu( advMenu ); }
QgsCategorizedSymbolRendererWidget::QgsCategorizedSymbolRendererWidget( QgsVectorLayer* layer, QgsStyle* style, QgsFeatureRenderer* renderer ) : QgsRendererWidget( layer, style ) , mRenderer( nullptr ) , mModel( nullptr ) { // try to recognize the previous renderer // (null renderer means "no previous renderer") if ( renderer ) { mRenderer = QgsCategorizedSymbolRenderer::convertFromRenderer( renderer ); } if ( !mRenderer ) { mRenderer = new QgsCategorizedSymbolRenderer( QLatin1String( "" ), QgsCategoryList() ); } QString attrName = mRenderer->classAttribute(); mOldClassificationAttribute = attrName; // setup user interface setupUi( this ); mExpressionWidget->setLayer( mLayer ); cboCategorizedColorRamp->populate( mStyle ); int randomIndex = cboCategorizedColorRamp->findText( tr( "Random colors" ) ); if ( randomIndex != -1 ) { cboCategorizedColorRamp->setCurrentIndex( randomIndex ); mButtonEditRamp->setEnabled( false ); } // set project default color ramp QString defaultColorRamp = QgsProject::instance()->readEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/ColorRamp" ), QLatin1String( "" ) ); if ( defaultColorRamp != QLatin1String( "" ) ) { int index = cboCategorizedColorRamp->findText( defaultColorRamp, Qt::MatchCaseSensitive ); if ( index >= 0 ) cboCategorizedColorRamp->setCurrentIndex( index ); } mCategorizedSymbol = QgsSymbol::defaultSymbol( mLayer->geometryType() ); mModel = new QgsCategorizedSymbolRendererModel( this ); mModel->setRenderer( mRenderer ); // update GUI from renderer updateUiFromRenderer(); viewCategories->setModel( mModel ); viewCategories->resizeColumnToContents( 0 ); viewCategories->resizeColumnToContents( 1 ); viewCategories->resizeColumnToContents( 2 ); viewCategories->setStyle( new QgsCategorizedSymbolRendererViewStyle( viewCategories->style() ) ); connect( mModel, SIGNAL( rowsMoved() ), this, SLOT( rowsMoved() ) ); connect( mModel, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ), this, SIGNAL( widgetChanged() ) ); connect( mExpressionWidget, SIGNAL( fieldChanged( QString ) ), this, SLOT( categoryColumnChanged( QString ) ) ); connect( viewCategories, SIGNAL( doubleClicked( const QModelIndex & ) ), this, SLOT( categoriesDoubleClicked( const QModelIndex & ) ) ); connect( viewCategories, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( contextMenuViewCategories( const QPoint& ) ) ); connect( btnChangeCategorizedSymbol, SIGNAL( clicked() ), this, SLOT( changeCategorizedSymbol() ) ); connect( btnAddCategories, SIGNAL( clicked() ), this, SLOT( addCategories() ) ); connect( btnDeleteCategories, SIGNAL( clicked() ), this, SLOT( deleteCategories() ) ); connect( btnDeleteAllCategories, SIGNAL( clicked() ), this, SLOT( deleteAllCategories() ) ); connect( btnAddCategory, SIGNAL( clicked() ), this, SLOT( addCategory() ) ); connect( cbxInvertedColorRamp, SIGNAL( toggled( bool ) ), this, SLOT( applyColorRamp() ) ); connect( cboCategorizedColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) ); connect( cboCategorizedColorRamp, SIGNAL( sourceRampEdited() ), this, SLOT( applyColorRamp() ) ); connect( mButtonEditRamp, SIGNAL( clicked() ), cboCategorizedColorRamp, SLOT( editSourceRamp() ) ); // menus for data-defined rotation/size QMenu* advMenu = new QMenu; advMenu->addAction( tr( "Match to saved symbols" ), this, SLOT( matchToSymbolsFromLibrary() ) ); advMenu->addAction( tr( "Match to symbols from file..." ), this, SLOT( matchToSymbolsFromXml() ) ); advMenu->addAction( tr( "Symbol levels..." ), this, SLOT( showSymbolLevels() ) ); btnAdvanced->setMenu( advMenu ); mExpressionWidget->registerExpressionContextGenerator( this ); }