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 );
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();