19 #include <QMessageBox>
20 #include <QInputDialog>
28 : QWidget(), mLayer( layer ), mStyle( style )
33 mCopyAction->setShortcut( QKeySequence( QKeySequence::Copy ) );
35 mPasteAction->setShortcut( QKeySequence( QKeySequence::Paste ) );
60 if ( symbolList.size() < 1 )
66 if ( color.isValid() )
68 QList<QgsSymbolV2*>::iterator symbolIt = symbolList.begin();
69 for ( ; symbolIt != symbolList.end(); ++symbolIt )
71 ( *symbolIt )->setColor( color );
80 if ( symbolList.size() < 1 )
86 double oldTransparency = ( 1 - symbolList.at( 0 )->alpha() ) * 100;
87 double transparency = QInputDialog::getDouble(
this,
tr(
"Transparency" ),
tr(
"Change symbol transparency [%]" ), oldTransparency, 0.0, 100.0, 0, &ok );
90 QList<QgsSymbolV2*>::iterator symbolIt = symbolList.begin();
91 for ( ; symbolIt != symbolList.end(); ++symbolIt )
93 ( *symbolIt )->setAlpha( 1 - transparency / 100 );
102 if ( symbolList.size() < 1 )
108 int currentUnit = ( symbolList.at( 0 )->outputUnit() ==
QgsSymbolV2::MM ) ? 0 : 1;
109 QString item = QInputDialog::getItem(
this,
tr(
"Symbol unit" ),
tr(
"Select symbol unit" ), QStringList() <<
tr(
"Millimeter" ) <<
tr(
"Map unit" ), currentUnit,
false, &ok );
114 QList<QgsSymbolV2*>::iterator symbolIt = symbolList.begin();
115 for ( ; symbolIt != symbolList.end(); ++symbolIt )
117 ( *symbolIt )->setOutputUnit( unit );
126 if ( symbolList.size() < 1 )
133 double width = QInputDialog::getDouble(
this,
tr(
"Width" ),
tr(
"Change symbol width" ), line ? line->
width() : 0.0 , 0.0, 999999, 1, &ok );
136 QList<QgsSymbolV2*>::iterator symbolIt = symbolList.begin();
137 for ( ; symbolIt != symbolList.end(); ++symbolIt )
150 if ( symbolList.size() < 1 )
158 double size = QInputDialog::getDouble(
this,
tr(
"Size" ),
tr(
"Change symbol size" ), marker ? marker->
size() : 0.0 , 0.0, 999999, 1, &ok );
161 QList<QgsSymbolV2*>::iterator symbolIt = symbolList.begin();
162 for ( ; symbolIt != symbolList.end(); ++symbolIt )
192 : QObject( menu ), mLayer( layer )
209 aScaleByArea->setCheckable(
true );
210 aScaleByDiameter->setCheckable(
true );
214 aScaleByDiameter->setChecked(
true );
218 aScaleByArea->setChecked(
true );
242 QAction* aExpr =
new QAction(
tr(
"- expression -" ), actionGroup );
243 aExpr->setCheckable(
true );
244 menu->addAction( aExpr );
245 menu->addSeparator();
246 QAction* aNo =
new QAction(
tr(
"- no field -" ), actionGroup );
247 aNo->setCheckable(
true );
248 menu->addAction( aNo );
249 menu->addSeparator();
251 bool hasField =
false;
253 for (
int idx = 0; idx < flds.
count(); ++idx )
256 if ( fld.
type() == QVariant::Int || fld.
type() == QVariant::Double )
258 QAction* a =
new QAction( fld.
name(), actionGroup );
259 a->setCheckable(
true );
260 if ( fieldName == fld.
name() )
262 a->setChecked(
true );
265 menu->addAction( a );
271 if ( fieldName.isEmpty() )
273 aNo->setChecked(
true );
277 aExpr->setChecked(
true );
278 aExpr->setText(
tr(
"- expression -" ) + fieldName );
289 QString fldName = a->text();
293 if ( fldName ==
tr(
"- no field -" ) )
297 else if ( fldName.startsWith(
tr(
"- expression -" ) ) )
299 QString expr( fldName );
300 expr.replace( 0,
tr(
"- expression -" ).length(),
"" );
302 if ( !dialog.exec() )
return;
305 a->setText(
tr(
"- expression -" ) + fldName );
316 QString fldName = a->text();
320 if ( fldName ==
tr(
"- no field -" ) )
324 else if ( fldName.startsWith(
tr(
"- expression -" ) ) )
326 QString expr( fldName );
327 expr.replace( 0,
tr(
"- expression -" ).length(),
"" );
329 if ( !dialog.exec() )
return;
332 a->setText(
tr(
"- expression -" ) + fldName );
343 if ( a->text() ==
tr(
"Scale area" ) )
347 else if ( a->text() ==
tr(
"Scale diameter" ) )
352 #if 0 // MK: is there any reason for this?
353 void QgsRendererV2DataDefinedMenus::updateMenu( QActionGroup* actionGroup, QString fieldName )
355 foreach ( QAction* a, actionGroup->actions() )
357 a->setChecked( a->text() == fieldName );