@@ -40,7 +40,7 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog(): QDialog(), mVectorLayer( 0 )
4040 QgsDebugMsg ( " entered." );
4141}
4242
43- QgsSingleSymbolDialog::QgsSingleSymbolDialog ( QgsVectorLayer * layer, bool disabled ): QDialog(), mVectorLayer( layer )
43+ QgsSingleSymbolDialog::QgsSingleSymbolDialog ( QgsVectorLayer * layer, bool disabled ): QDialog(), mVectorLayer( layer ), mDisabled( disabled )
4444{
4545 setupUi ( this );
4646 QgsDebugMsg ( " entered." );
@@ -59,6 +59,43 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog( QgsVectorLayer * layer, bool disab
5959 // loops can be removed now with changes I have made to use combo
6060 // boxes for line style and fill style...test and remove if poss.
6161
62+ QAction *refreshAction = new QAction ( tr ( " Refresh markers" ), lstSymbols );
63+ lstSymbols->addAction ( refreshAction );
64+ connect ( refreshAction, SIGNAL ( triggered () ), QgsMarkerCatalogue::instance (), SLOT ( refreshList () ) );
65+ connect ( QgsMarkerCatalogue::instance (), SIGNAL ( markersRefreshed () ), this , SLOT ( refreshMarkers () ) );
66+ lstSymbols->setContextMenuPolicy ( Qt::ActionsContextMenu );
67+
68+ // do the signal/slot connections
69+ connect ( btnOutlineColor, SIGNAL ( clicked () ), this , SLOT ( selectOutlineColor () ) );
70+ connect ( btnFillColor, SIGNAL ( clicked () ), this , SLOT ( selectFillColor () ) );
71+ connect ( outlinewidthspinbox, SIGNAL ( valueChanged ( double ) ), this , SLOT ( resendSettingsChanged () ) );
72+ connect ( mLabelEdit , SIGNAL ( textChanged ( const QString& ) ), this , SLOT ( resendSettingsChanged () ) );
73+ connect ( lstSymbols, SIGNAL ( currentItemChanged ( QListWidgetItem *, QListWidgetItem * ) ),
74+ this , SLOT ( symbolChanged ( QListWidgetItem *, QListWidgetItem * ) ) );
75+ connect ( mPointSizeSpinBox , SIGNAL ( valueChanged ( double ) ), this , SLOT ( resendSettingsChanged () ) );
76+ connect ( mPointSizeUnitsCheckBox , SIGNAL ( toggled () ), this , SLOT ( resendSettingsChanged () ) );
77+ connect ( mRotationClassificationComboBox , SIGNAL ( currentIndexChanged ( const QString & ) ),
78+ this , SLOT ( resendSettingsChanged () ) );
79+ connect ( mScaleClassificationComboBox , SIGNAL ( currentIndexChanged ( const QString & ) ),
80+ this , SLOT ( resendSettingsChanged () ) );
81+ connect ( mSymbolComboBox , SIGNAL ( currentIndexChanged ( const QString & ) ),
82+ this , SLOT ( resendSettingsChanged () ) );
83+ connect ( cboOutlineStyle, SIGNAL (
84+ currentIndexChanged ( const QString & ) ), this , SLOT ( resendSettingsChanged () ) );
85+ connect ( cboFillStyle, SIGNAL (
86+ currentIndexChanged ( const QString & ) ), this , SLOT ( resendSettingsChanged () ) );
87+ // need this to deal with when texture fill is selected or deselected
88+ connect ( cboFillStyle, SIGNAL (
89+ currentIndexChanged ( int ) ), this , SLOT ( fillStyleChanged ( int ) ) );
90+ connect ( toolSelectTexture, SIGNAL ( clicked () ), this , SLOT ( selectTextureImage () ) );
91+
92+ refreshMarkers ();
93+ }
94+
95+ void QgsSingleSymbolDialog::refreshMarkers ()
96+ {
97+ lstSymbols->blockSignals ( true );
98+ lstSymbols->clear ();
6299
63100 QPen pen ( QColor ( 0 , 0 , 255 ) );
64101 QBrush brush ( QColor ( 220 , 220 , 220 ), Qt::SolidPattern );
@@ -73,17 +110,18 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog( QgsVectorLayer * layer, bool disab
73110 myIcon.addPixmap ( myPixmap );
74111 mypItem->setIcon ( myIcon );
75112 mypItem->setText ( " " );
113+ mypItem->setToolTip ( *it );
76114 // store the symbol offset in the UserData role for later retrieval
77115 mypItem->setData ( Qt::UserRole, *it );
78116 mypItem->setFlags ( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
79- if ( layer ->geometryType () != QGis::Point )
117+ if ( mVectorLayer && mVectorLayer ->geometryType () != QGis::Point )
80118 {
81119 break ;
82120 }
83121 ++myCounter;
84122 }
85123
86- // Find out the numerical fields of mVectorLayer, and populate the ComboBox
124+ // Find out the numerical fields of mVectorLayer, and populate the ComboBoxes
87125 QgsVectorDataProvider *provider = mVectorLayer ->dataProvider ();
88126 if ( provider )
89127 {
@@ -92,6 +130,7 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog( QgsVectorLayer * layer, bool disab
92130
93131 mRotationClassificationComboBox ->addItem ( DO_NOT_USE_STR, -1 );
94132 mScaleClassificationComboBox ->addItem ( DO_NOT_USE_STR, -1 );
133+ mSymbolComboBox ->addItem ( DO_NOT_USE_STR, -1 );
95134 for ( QgsFieldMap::const_iterator it = fields.begin ();
96135 it != fields.end ();
97136 ++it )
@@ -102,6 +141,10 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog( QgsVectorLayer * layer, bool disab
102141 mRotationClassificationComboBox ->addItem ( it->name (), it.key () );
103142 mScaleClassificationComboBox ->addItem ( it->name (), it.key () );
104143 }
144+ else if ( type == QVariant::String )
145+ {
146+ mSymbolComboBox ->addItem ( it->name (), it.key () );
147+ }
105148 }
106149 }
107150 else
@@ -139,13 +182,13 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog( QgsVectorLayer * layer, bool disab
139182 cboFillStyle->addItem ( QIcon ( QgsSymbologyUtils::char2PatternPixmap ( " NoBrush" ) ), tr ( " No Brush" ), " NoBrush" );
140183 cboFillStyle->addItem ( QIcon ( QgsSymbologyUtils::char2PatternPixmap ( " TexturePattern" ) ), tr ( " Texture" ), " TexturePattern" );
141184
142- if ( mVectorLayer && layer ->geometryType () != QGis::Point )
185+ if ( mVectorLayer && mVectorLayer ->geometryType () != QGis::Point )
143186 {
144187 mGroupPoint ->setVisible ( false );
145188 mGroupPoint ->setEnabled ( false );
146189 }
147190
148- if ( disabled )
191+ if ( mDisabled )
149192 {
150193 unset ();
151194 }
@@ -173,27 +216,7 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog( QgsVectorLayer * layer, bool disab
173216 }
174217 }
175218
176- // do the signal/slot connections
177- connect ( btnOutlineColor, SIGNAL ( clicked () ), this , SLOT ( selectOutlineColor () ) );
178- connect ( btnFillColor, SIGNAL ( clicked () ), this , SLOT ( selectFillColor () ) );
179- connect ( outlinewidthspinbox, SIGNAL ( valueChanged ( double ) ), this , SLOT ( resendSettingsChanged () ) );
180- connect ( mLabelEdit , SIGNAL ( textChanged ( const QString& ) ), this , SLOT ( resendSettingsChanged () ) );
181- connect ( lstSymbols, SIGNAL ( currentItemChanged ( QListWidgetItem *, QListWidgetItem * ) ),
182- this , SLOT ( symbolChanged ( QListWidgetItem *, QListWidgetItem * ) ) );
183- connect ( mPointSizeSpinBox , SIGNAL ( valueChanged ( double ) ), this , SLOT ( resendSettingsChanged () ) );
184- connect ( mRotationClassificationComboBox , SIGNAL ( currentIndexChanged ( const QString & ) ),
185- this , SLOT ( resendSettingsChanged () ) );
186- connect ( mScaleClassificationComboBox , SIGNAL ( currentIndexChanged ( const QString & ) ),
187- this , SLOT ( resendSettingsChanged () ) );
188- connect ( cboOutlineStyle, SIGNAL (
189- currentIndexChanged ( const QString & ) ), this , SLOT ( resendSettingsChanged () ) );
190- connect ( cboFillStyle, SIGNAL (
191- currentIndexChanged ( const QString & ) ), this , SLOT ( resendSettingsChanged () ) );
192- // need this to deal with when texture fill is selected or deselected
193- connect ( cboFillStyle, SIGNAL (
194- currentIndexChanged ( int ) ), this , SLOT ( fillStyleChanged ( int ) ) );
195- connect ( toolSelectTexture, SIGNAL ( clicked () ), this , SLOT ( selectTextureImage () ) );
196-
219+ lstSymbols->blockSignals ( false );
197220}
198221
199222QgsSingleSymbolDialog::~QgsSingleSymbolDialog ()
@@ -264,6 +287,8 @@ void QgsSingleSymbolDialog::apply( QgsSymbol *sy )
264287 if ( mPointSizeSpinBox ->isEnabled () )
265288 sy->setPointSize ( mPointSizeSpinBox ->value () );
266289
290+ if ( mPointSizeUnitsCheckBox ->isEnabled () )
291+ sy->setPointSizeUnits ( mPointSizeUnitsCheckBox ->isChecked () );
267292
268293 std::map<QString, int >::iterator iter;
269294 if ( mRotationClassificationComboBox ->isEnabled () )
@@ -276,6 +301,11 @@ void QgsSingleSymbolDialog::apply( QgsSymbol *sy )
276301 sy->setScaleClassificationField ( mScaleClassificationComboBox ->itemData ( mScaleClassificationComboBox ->currentIndex () ).toInt () );
277302 }
278303
304+ if ( mSymbolComboBox ->isEnabled () )
305+ {
306+ sy->setSymbolField ( mSymbolComboBox ->itemData ( mSymbolComboBox ->currentIndex () ).toInt () );
307+ }
308+
279309 //
280310 // Apply the line style
281311 //
@@ -323,8 +353,10 @@ void QgsSingleSymbolDialog::unset()
323353 mLabelEdit ->setEnabled ( false );
324354 lstSymbols->setEnabled ( false );
325355 mPointSizeSpinBox ->setEnabled ( false );
356+ mPointSizeUnitsCheckBox ->setEnabled ( false );
326357 mRotationClassificationComboBox ->setEnabled ( false );
327358 mScaleClassificationComboBox ->setEnabled ( false );
359+ mSymbolComboBox ->setEnabled ( false );
328360 outlinewidthspinbox->setEnabled ( false );
329361 btnOutlineColor->setEnabled ( false );
330362 cboOutlineStyle->setEnabled ( false );
@@ -350,6 +382,7 @@ void QgsSingleSymbolDialog::set( const QgsSymbol *sy )
350382 }
351383 }
352384 mPointSizeSpinBox ->setValue ( sy->pointSize () );
385+ mPointSizeUnitsCheckBox ->setChecked ( sy->pointSizeUnits () );
353386
354387 int index;
355388
@@ -359,6 +392,9 @@ void QgsSingleSymbolDialog::set( const QgsSymbol *sy )
359392 index = mScaleClassificationComboBox ->findData ( sy->scaleClassificationField () );
360393 mScaleClassificationComboBox ->setCurrentIndex ( index < 0 ? 0 : index );
361394
395+ index = mSymbolComboBox ->findData ( sy->symbolField () );
396+ mSymbolComboBox ->setCurrentIndex ( index < 0 ? 0 : index );
397+
362398 outlinewidthspinbox->setValue ( sy->pen ().widthF () );
363399
364400 // set line width 1 as minimum to avoid confusion between line width 0 and no pen line style
@@ -418,8 +454,10 @@ void QgsSingleSymbolDialog::set( const QgsSymbol *sy )
418454 mLabelEdit ->setEnabled ( true );
419455 lstSymbols->setEnabled ( true );
420456 mPointSizeSpinBox ->setEnabled ( true );
457+ mPointSizeUnitsCheckBox ->setEnabled ( true );
421458 mRotationClassificationComboBox ->setEnabled ( true );
422459 mScaleClassificationComboBox ->setEnabled ( true );
460+ mSymbolComboBox ->setEnabled ( true );
423461 outlinewidthspinbox->setEnabled ( true );
424462 btnOutlineColor->setEnabled ( true );
425463 cboOutlineStyle->setEnabled ( true );
@@ -442,6 +480,9 @@ void QgsSingleSymbolDialog::updateSet( const QgsSymbol *sy )
442480 if ( mPointSizeSpinBox ->isEnabled () && mPointSizeSpinBox ->value () != sy->pointSize () )
443481 mPointSizeSpinBox ->setEnabled ( false );
444482
483+ if ( mPointSizeUnitsCheckBox ->isEnabled () && mPointSizeUnitsCheckBox ->isChecked () != sy->pointSizeUnits () )
484+ mPointSizeUnitsCheckBox ->setEnabled ( false );
485+
445486 if ( mRotationClassificationComboBox ->isEnabled () &&
446487 mRotationClassificationComboBox ->itemData ( mRotationClassificationComboBox ->currentIndex () ).toInt () != sy->rotationClassificationField () )
447488 mRotationClassificationComboBox ->setEnabled ( false );
@@ -450,6 +491,10 @@ void QgsSingleSymbolDialog::updateSet( const QgsSymbol *sy )
450491 mScaleClassificationComboBox ->itemData ( mScaleClassificationComboBox ->currentIndex () ).toInt () != sy->scaleClassificationField () )
451492 mScaleClassificationComboBox ->setEnabled ( false );
452493
494+ if ( mSymbolComboBox ->isEnabled () &&
495+ mSymbolComboBox ->itemData ( mSymbolComboBox ->currentIndex () ).toInt () != sy->symbolField () )
496+ mSymbolComboBox ->setEnabled ( false );
497+
453498 if ( outlinewidthspinbox->isEnabled () && outlinewidthspinbox->value () != sy->pen ().widthF () )
454499 outlinewidthspinbox->setEnabled ( false );
455500
0 commit comments