28 #include <QStringList> 31 #include <QStandardItemModel> 32 #include <QColorDialog> 33 #include <QInputDialog> 34 #include <QMessageBox> 45 mSymbolUnitWidget->setUnits( QStringList() <<
tr(
"Millimeter" ) <<
tr(
"Map unit" ), 1 );
50 btnAdvanced->setMenu( menu );
55 groupsCombo->addItem(
"" );
58 foreach ( QString group, groups )
60 groupsCombo->addItem( group, QVariant(
"smart" ) );
63 QStandardItemModel* model =
new QStandardItemModel( viewSymbols );
64 viewSymbols->setModel( model );
65 connect( viewSymbols->selectionModel(), SIGNAL( currentChanged(
const QModelIndex &,
const QModelIndex & ) ),
this, SLOT(
setSymbolFromStyle(
const QModelIndex & ) ) );
68 connect( openStyleManagerButton, SIGNAL( pressed() ),
this, SLOT(
openStyleManager() ) );
70 lblSymbolName->setText(
"" );
80 stackedWidget->setCurrentIndex( symbol->
type() );
81 connect( btnColor, SIGNAL( colorChanged(
const QColor& ) ),
this, SLOT(
setSymbolColor(
const QColor& ) ) );
82 connect( spinAngle, SIGNAL( valueChanged(
double ) ),
this, SLOT(
setMarkerAngle(
double ) ) );
83 connect( spinSize, SIGNAL( valueChanged(
double ) ),
this, SLOT(
setMarkerSize(
double ) ) );
84 connect( spinWidth, SIGNAL( valueChanged(
double ) ),
this, SLOT(
setLineWidth(
double ) ) );
87 btnColor->setAcceptLiveUpdates(
false );
88 btnColor->setAllowAlpha(
true );
89 btnColor->setColorDialogTitle(
tr(
"Select color" ) );
90 btnColor->setContext(
"symbology" );
93 void QgsSymbolsListWidget::populateGroups( QString parent, QString prepend )
96 QgsSymbolGroupMap::const_iterator i = groups.constBegin();
97 while ( i != groups.constEnd() )
100 if ( !prepend.isEmpty() )
102 text = prepend +
"/" + i.value();
108 groupsCombo->addItem( text, QVariant( i.key() ) );
109 populateGroups( i.value(), text );
121 QSize previewSize = viewSymbols->iconSize();
122 QPixmap p( previewSize );
125 QStandardItemModel* model = qobject_cast<QStandardItemModel*>( viewSymbols->model() );
132 for (
int i = 0; i < names.count(); i++ )
140 QStandardItem* item =
new QStandardItem( names[i] );
141 item->setData( names[i], Qt::UserRole );
142 item->setText( names[i] );
143 item->setToolTip( names[i] );
144 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
146 QFont itemFont = item->font();
147 itemFont.setPointSize( 10 );
148 item->setFont( itemFont );
151 item->setIcon( icon );
153 model->appendRow( item );
184 if ( markerSymbol->
size() == size )
193 if ( lineSymbol->
width() == width )
209 QString name = QInputDialog::getText(
this,
tr(
"Symbol name" ),
210 tr(
"Please enter name for the symbol:" ), QLineEdit::Normal,
tr(
"New symbol" ), &ok );
211 if ( !ok || name.isEmpty() )
217 int res = QMessageBox::warning(
this,
tr(
"Save symbol" ),
218 tr(
"Symbol with name '%1' already exists. Overwrite?" )
220 QMessageBox::Yes | QMessageBox::No );
221 if ( res != QMessageBox::Yes )
251 double alpha = 1 - ( value / 255.0 );
253 displayTransparency( alpha );
258 void QgsSymbolsListWidget::displayTransparency(
double alpha )
260 double transparencyPercent = ( 1 - alpha ) * 100;
261 mTransparencyLabel->setText(
tr(
"Transparency %1%" ).arg((
int ) transparencyPercent ) );
266 btnColor->blockSignals(
true );
268 btnColor->blockSignals(
false );
278 spinSize->setValue( markerSymbol->
size() );
279 spinAngle->setValue( markerSymbol->
angle() );
284 spinWidth->setValue( lineSymbol->
width() );
287 mSymbolUnitWidget->blockSignals(
true );
290 mSymbolUnitWidget->blockSignals(
false );
292 mTransparencySlider->blockSignals(
true );
294 mTransparencySlider->setValue( transparency * 255 );
296 mTransparencySlider->blockSignals(
false );
301 QString symbolName = index.data( Qt::UserRole ).toString();
302 lblSymbolName->setText( symbolName );
327 QString text = groupsCombo->itemText( index );
329 if ( text.isEmpty() )
336 if ( groupsCombo->itemData( index ).toString() ==
"smart" )
343 groupid = groupsCombo->itemData( index ).toInt();
bool deleteSymbolLayer(int index)
delete symbol layer at specified index
bool saveSymbol(QString name, QgsSymbolV2 *symbol, int groupid, QStringList tags)
add the symbol to the DB with the tags
virtual QgsSymbolV2 * clone() const =0
QStringList symbolsOfGroup(StyleEntity type, int groupid)
returns the symbolnames of a given groupid
QgsMapUnitScale mapUnitScale() const
QgsSymbolV2 * symbol(QString name)
return a NEW copy of symbol
void setWidth(double width)
void setMapUnitScale(const QgsMapUnitScale &scale)
QgsSymbolGroupMap childGroupNames(QString parent="")
return a map of groupid and names for the given parent group
bool addSymbol(QString name, QgsSymbolV2 *symbol, bool update=false)
add symbol to style. takes symbol's ownership
void setColor(const QColor &color)
static QIcon symbolPreviewIcon(QgsSymbolV2 *symbol, QSize size)
bool appendSymbolLayer(QgsSymbolLayerV2 *layer)
append symbol layer at the end of the list
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
void setAngle(double angle)
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
void setSize(double size)
QStringList symbolsOfSmartgroup(StyleEntity type, int id)
returns the symbols for the smartgroup
QStringList symbolNames()
return a list of names of symbols
QMap< int, QString > QgsSymbolGroupMap
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
QStringList smartgroupNames()
returns the smart groups list
QgsSymbolV2::OutputUnit outputUnit() const
QgsSymbolLayerV2 * takeSymbolLayer(int index)
remove symbol layer from the list and return pointer to it
QStringList findSymbols(StyleEntity type, QString qword)
return the names of the symbols which have a matching 'substring' in its defintion ...
int smartgroupId(QString smartgroup)
return the DB id for the given smartgroup name
void setOutputUnit(QgsSymbolV2::OutputUnit u)
void setAlpha(qreal alpha)
Set alpha transparency 1 for opaque, 0 for invisible.