35 #include <QColorDialog>    37 #include <QStandardItemModel>    38 #include <QInputDialog>    39 #include <QMessageBox>    45 #include <QStandardItem>    49 static const int SymbolLayerItemType = QStandardItem::UserType + 1;
    53     , mMarkerSymbolLayer( nullptr )
    55     , mLineSymbolLayer( nullptr )
    62     mDDSize = mMarker->dataDefinedSize();
    63     mDDAngle = mMarker->dataDefinedAngle();
    72     mDDWidth = mLine->dataDefinedWidth();
    80 void DataDefinedRestorer::save()
    84     mSize = mMarkerSymbolLayer->size();
    85     mAngle = mMarkerSymbolLayer->angle();
    86     mMarkerOffset = mMarkerSymbolLayer->offset();
    90     mWidth = mLineSymbolLayer->width();
    91     mLineOffset = mLineSymbolLayer->offset();
    95 void DataDefinedRestorer::restore()
   100          ( mSize != mMarkerSymbolLayer->size() || mMarkerOffset != mMarkerSymbolLayer->offset() ) )
   101       mMarker->setDataDefinedSize( mDDSize );
   103          mAngle != mMarkerSymbolLayer->angle() )
   104       mMarker->setDataDefinedAngle( mDDAngle );
   109          ( mWidth != mLineSymbolLayer->width() || mLineOffset != mLineSymbolLayer->offset() ) )
   110       mLine->setDataDefinedWidth( mDDWidth );
   156         static_cast<SymbolLayerItem*
>( 
parent() )->updatePreview();
   159     int type()
 const override { 
return SymbolLayerItemType; }
   160     bool isLayer() { 
return mIsLayer; }
   173     QVariant data( 
int role )
 const override   175       if ( role == Qt::DisplayRole || role == Qt::EditRole )
   194       if ( role == Qt::SizeHintRole )
   196       if ( role == Qt::CheckStateRole )
   243   btnLock->setIcon( iconLock );
   250   layersTree->setModel( 
model );
   251   layersTree->setHeaderHidden( 
true );
   270   layersTree->setCurrentIndex( newIndex );
   305   mPresetExpressionContext.
reset( context );
   314   QWidget* widget = stackedWidget->currentWidget();
   326   SymbolLayerItem* symbolItem = 
new SymbolLayerItem( symbol );
   327   QFont boldFont = symbolItem->font();
   329   symbolItem->setFont( boldFont );
   330   parent->appendRow( symbolItem );
   333   for ( 
int i = count - 1; i >= 0; i-- )
   335     SymbolLayerItem *layerItem = 
new SymbolLayerItem( symbol->
symbolLayer( i ) );
   336     layerItem->setEditable( 
false );
   337     symbolItem->appendRow( layerItem );
   342     layersTree->setExpanded( layerItem->index(), true );
   344   layersTree->setExpanded( symbolItem->index(), true );
   356   QModelIndex currentIdx =  layersTree->currentIndex();
   360   SymbolLayerItem *item = 
static_cast<SymbolLayerItem*
>( 
model->
itemFromIndex( currentIdx ) );
   361   if ( !item->isLayer() )
   363     btnUp->setEnabled( 
false );
   364     btnDown->setEnabled( 
false );
   365     btnRemoveLayer->setEnabled( 
false );
   366     btnLock->setEnabled( 
false );
   367     btnDuplicate->setEnabled( 
false );
   371   int rowCount = item->parent()->rowCount();
   372   int currentRow = item->row();
   374   btnUp->setEnabled( currentRow > 0 );
   375   btnDown->setEnabled( currentRow < rowCount - 1 );
   376   btnRemoveLayer->setEnabled( rowCount > 1 );
   377   btnLock->setEnabled( 
true );
   378   btnDuplicate->setEnabled( 
true );
   394     item->updatePreview();
   406   if ( !item->isLayer() )
   419   if ( item->isLayer() )
   420     return item->layer();
   429   SymbolLayerItem *currentItem = 
static_cast<SymbolLayerItem*
>( 
model->
itemFromIndex( layersTree->currentIndex() ) );
   433   if ( currentItem->isLayer() )
   435     SymbolLayerItem *
parent = 
static_cast<SymbolLayerItem*
>( currentItem->parent() );
   436     mDataDefineRestorer.
reset( 
new DataDefinedRestorer( parent->symbol(), currentItem->layer() ) );
   441     connect( layerProp, SIGNAL( changed() ), mDataDefineRestorer.
data(), SLOT( restore() ) );
   448     mDataDefineRestorer.
reset();
   464   SymbolLayerItem *currentItem = 
static_cast<SymbolLayerItem*
>( 
model->
itemFromIndex( layersTree->currentIndex() ) );
   465   if ( !currentItem || currentItem->isLayer() )
   469   if ( currentItem->parent() )
   473     SymbolLayerItem *
parent = 
static_cast<SymbolLayerItem*
>( currentItem->parent() );
   474     parent->removeRow( 0 );
   476     layersTree->setCurrentIndex( parent->child( 0 )->index() );
   477     parent->updatePreview();
   484     layersTree->setCurrentIndex( newIndex );
   493   int index = stackedWidget->addWidget( widget );
   494   stackedWidget->setCurrentIndex( index );
   505   btnLock->setChecked( layer->
isLocked() );
   516   if ( item->isLayer() )
   518     insertIdx = item->row();
   519     item = 
static_cast<SymbolLayerItem*
>( item->parent() );
   536   if ( insertIdx == -1 )
   543     static_cast<QgsMarkerSymbolV2 *>( parentSymbol )->setDataDefinedSize( ddSize );
   545     static_cast<QgsMarkerSymbolV2 *
>( parentSymbol )->setDataDefinedAngle( ddAngle );
   547     static_cast<QgsLineSymbolV2 *>( parentSymbol )->setDataDefinedWidth( ddWidth );
   549   SymbolLayerItem *newLayerItem = 
new SymbolLayerItem( newLayer );
   550   item->insertRow( insertIdx == -1 ? 0 : insertIdx, newLayerItem );
   551   item->updatePreview();
   561   int row = item->row();
   562   SymbolLayerItem *
parent = 
static_cast<SymbolLayerItem*
>( item->parent() );
   564   int layerIdx = parent->rowCount() - row - 1; 
   568   parent->removeRow( row );
   569   parent->updatePreview();
   572   layersTree->setCurrentIndex( newIdx );
   595   int row = item->row();
   597   SymbolLayerItem *
parent = 
static_cast<SymbolLayerItem*
>( item->parent() );
   600   int layerIdx = parent->rowCount() - row - 1;
   606   parent->insertRows( row + offset, rowItems );
   607   parent->updatePreview();
   610   layersTree->setCurrentIndex( newIdx );
   621   layer->
setLocked( btnLock->isChecked() );
   631   if ( !item->isLayer() )
   636   int insertIdx = item->row();
   637   item = 
static_cast<SymbolLayerItem*
>( item->parent() );
   642   if ( insertIdx == -1 )
   647   SymbolLayerItem *newLayerItem = 
new SymbolLayerItem( newLayer );
   648   item->insertRow( insertIdx == -1 ? 0 : insertIdx, newLayerItem );
   652     layersTree->setExpanded( newLayerItem->index(), true );
   654   item->updatePreview();
   665                                         tr( 
"Please enter name for the symbol:" ), QLineEdit::Normal, 
tr( 
"New symbol" ), &ok );
   673                                     tr( 
"Symbol with name '%1' already exists. Overwrite?" )
   675                                     QMessageBox::Yes | QMessageBox::No );
   676     if ( res != QMessageBox::Yes )
   696     item->removeRow( 0 );
   699   item->setLayer( newLayer );
   704     layersTree->setExpanded( item->index(), true );
   708   QgsSymbolV2* symbol = 
static_cast<SymbolLayerItem*
>( item->parent() )->symbol();
   709   int layerIdx = item->parent()->rowCount() - item->row() - 1;
   712   item->updatePreview();
 
void setLocked(bool locked)
 
QByteArray toByteArray() const
 
void setExpressionContext(QgsExpressionContext *context)
Sets the optional expression context used for the widget. 
 
void setContentsMargins(int left, int top, int right, int bottom)
 
static QgsSymbolLayerV2 * defaultSymbolLayer(QgsSymbolV2::SymbolType type)
create a new instance of symbol layer for specified symbol type with default settings ...
 
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const =0
 
~QgsSymbolV2SelectorDialog()
 
virtual QgsSymbolLayerV2 * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance. 
 
A container class for data source field mapping or expression. 
 
static QIcon symbolLayerPreviewIcon(QgsSymbolLayerV2 *layer, QgsSymbolV2::OutputUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale())
 
QStandardItem * invisibleRootItem() const
 
bool addSymbol(const QString &name, QgsSymbolV2 *symbol, bool update=false)
add symbol to style. takes symbol's ownership 
 
virtual QgsSymbolV2 * clone() const =0
 
void symbolChanged()
Slot to update tree when a new symbol from style. 
 
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file. 
 
bool contains(const QString &str, Qt::CaseSensitivity cs) const
 
bool changeSymbolLayer(int index, QgsSymbolLayerV2 *layer)
delete layer at specified index and set a new one 
 
QPixmap fromImage(const QImage &image, QFlags< Qt::ImageConversionFlag > flags)
 
static QgsSymbolLayerV2Registry * instance()
return the single instance of this class (instantiate it if not exists) 
 
QStandardItemModel * model
 
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
const QgsVectorLayer * mVectorLayer
 
QString tr(const char *sourceText, const char *disambiguation, int n)
 
Map canvas is a class for displaying all GIS data types on a canvas. 
 
void setBold(bool enable)
 
void setValue(const QString &key, const QVariant &value)
 
const char * name() const
 
The output shall be in millimeters. 
 
static QIcon symbolPreviewIcon(QgsSymbolV2 *symbol, QSize size)
 
void setWidget(QWidget *widget)
 
bool appendSymbolLayer(QgsSymbolLayerV2 *layer)
Append symbol layer at the end of the list Ownership will be transferred. 
 
bool saveSymbol(const QString &name, QgsSymbolV2 *symbol, int groupid, const QStringList &tags)
add the symbol to the DB with the tags 
 
void keyPressEvent(QKeyEvent *event) override
Reimplements dialog keyPress event so we can ignore it. 
 
QModelIndex indexFromItem(const QStandardItem *item) const
 
QMenu * advancedMenu()
return menu for "advanced" button - create it if doesn't exist and show the advanced button ...
 
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
 
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol. 
 
bool isLayer(QgsLayerTreeNode *node)
Check whether the node is a valid layer node. 
 
QStringList symbolNames()
return a list of names of symbols 
 
QgsSymbolLayerV2AbstractMetadata * symbolLayerMetadata(const QString &name) const 
return metadata for specified symbol layer. Returns NULL if not found 
 
QString getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode mode, const QString &text, bool *ok, QFlags< Qt::WindowType > flags, QFlags< Qt::InputMethodHint > inputMethodHints)
 
QgsSymbolV2::SymbolType type() const 
 
SymbolLayerItem * currentLayerItem()
 
QgsSymbolLayerV2 * currentLayer()
 
QImage bigSymbolPreviewImage(QgsExpressionContext *expressionContext=nullptr)
Returns a large (roughly 100x100 pixel) preview image for the symbol. 
 
virtual QgsSymbolV2 * subSymbol()
 
void addFile(const QString &fileName, const QSize &size, Mode mode, State state)
 
virtual void keyPressEvent(QKeyEvent *e)
 
QVariant value(const QString &key, const QVariant &defaultValue) const
 
const QAbstractItemModel * model() const
 
void duplicateLayer()
Duplicates the current symbol layer and places the duplicated layer above the current symbol layer...
 
bool insertSymbolLayer(int index, QgsSymbolLayerV2 *layer)
Insert symbol layer to specified index Ownership will be transferred. 
 
QStandardItem * itemFromIndex(const QModelIndex &index) const
 
QgsSymbolV2SelectorDialog(QgsSymbolV2 *symbol, QgsStyleV2 *style, const QgsVectorLayer *vl, QWidget *parent=nullptr, bool embedded=false)
 
void moveLayerByOffset(int offset)
 
QString translate(const char *context, const char *sourceText, const char *disambiguation, Encoding encoding)
 
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the dialog. 
 
void changeLayer(QgsSymbolLayerV2 *layer)
alters tree and sets proper widget when Layer Type is changed 
 
StandardButton warning(QWidget *parent, const QString &title, const QString &text, QFlags< QMessageBox::StandardButton > buttons, StandardButton defaultButton)
 
QgsSymbolLayerV2 * takeSymbolLayer(int index)
Remove symbol layer from the list and return pointer to it. 
 
QgsSymbolLayerV2 * symbolLayer(int layer)
Returns a specific symbol layers contained in the symbol. 
 
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
Represents a vector layer which manages a vector based data sets. 
 
void updateLayerPreview()
 
virtual QVariant data(int role) const
 
Q_DECL_DEPRECATED void saveSymbol()