QGIS API Documentation  2.9.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgsdatadefinedbutton.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdatadefinedbutton.cpp - Data defined selector button
3  --------------------------------------
4  Date : 27-April-2013
5  Copyright : (C) 2013 by Larry Shaffer
6  Email : larrys at dakcarto dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgsdatadefinedbutton.h"
17 
18 #include <qgsapplication.h>
19 #include <qgsdatadefined.h>
21 #include <qgsexpression.h>
22 #include <qgsmessageviewer.h>
23 #include <qgsvectorlayer.h>
24 
25 #include <QClipboard>
26 #include <QMenu>
27 #include <QMouseEvent>
28 #include <QPointer>
29 
30 
31 QIcon QgsDataDefinedButton::mIconDataDefine;
32 QIcon QgsDataDefinedButton::mIconDataDefineOn;
33 QIcon QgsDataDefinedButton::mIconDataDefineError;
34 QIcon QgsDataDefinedButton::mIconDataDefineExpression;
35 QIcon QgsDataDefinedButton::mIconDataDefineExpressionOn;
36 QIcon QgsDataDefinedButton::mIconDataDefineExpressionError;
37 
39  const QgsVectorLayer* vl,
40  const QgsDataDefined* datadefined,
41  DataTypes datatypes,
42  QString description )
43  : QToolButton( parent )
44 {
45  // set up static icons
46  if ( mIconDataDefine.isNull() )
47  {
48  mIconDataDefine = QgsApplication::getThemeIcon( "/mIconDataDefine.svg" );
49  mIconDataDefineOn = QgsApplication::getThemeIcon( "/mIconDataDefineOn.svg" );
50  mIconDataDefineError = QgsApplication::getThemeIcon( "/mIconDataDefineError.svg" );
51  mIconDataDefineExpression = QgsApplication::getThemeIcon( "/mIconDataDefineExpression.svg" );
52  mIconDataDefineExpressionOn = QgsApplication::getThemeIcon( "/mIconDataDefineExpressionOn.svg" );
53  mIconDataDefineExpressionError = QgsApplication::getThemeIcon( "/mIconDataDefineExpressionError.svg" );
54  }
55 
56  setFocusPolicy( Qt::StrongFocus );
57 
58  // set default tool button icon properties
59  setFixedSize( 30, 26 );
60  setStyleSheet( QString( "QToolButton{ background: none; border: 1px solid rgba(0, 0, 0, 0%);} QToolButton:focus { border: 1px solid palette(highlight); }" ) );
61  setIconSize( QSize( 24, 24 ) );
62  setPopupMode( QToolButton::InstantPopup );
63 
64  mDefineMenu = new QMenu( this );
65  connect( mDefineMenu, SIGNAL( aboutToShow() ), this, SLOT( aboutToShowMenu() ) );
66  connect( mDefineMenu, SIGNAL( triggered( QAction* ) ), this, SLOT( menuActionTriggered( QAction* ) ) );
67  setMenu( mDefineMenu );
68 
69  mFieldsMenu = new QMenu( this );
70 
71  mActionDataTypes = new QAction( this );
72  // list fields and types in submenu, since there may be many
73  mActionDataTypes->setMenu( mFieldsMenu );
74 
75  mActionActive = new QAction( this );
76  QFont f = mActionActive->font();
77  f.setBold( true );
78  mActionActive->setFont( f );
79 
80  mActionDescription = new QAction( tr( "Description..." ), this );
81 
82  mActionExpDialog = new QAction( tr( "Edit..." ), this );
83  mActionExpression = 0;
84  mActionPasteExpr = new QAction( tr( "Paste" ), this );
85  mActionCopyExpr = new QAction( tr( "Copy" ), this );
86  mActionClearExpr = new QAction( tr( "Clear" ), this );
87  mActionAssistant = new QAction( tr( "Assistant..." ), this );
88 
89  // set up sibling widget connections
90  connect( this, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( disableEnabledWidgets( bool ) ) );
91  connect( this, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( checkCheckedWidgets( bool ) ) );
92 
93  init( vl, datadefined, datatypes, description );
94 }
95 
97 {
98  mEnabledWidgets.clear();
99  mCheckedWidgets.clear();
100 }
101 
103  const QgsDataDefined* datadefined,
104  DataTypes datatypes,
105  QString description )
106 {
107  mVectorLayer = vl;
108  // construct default property if none or incorrect passed in
109  if ( !datadefined )
110  {
111  mProperty.insert( "active", "0" );
112  mProperty.insert( "useexpr", "0" );
113  mProperty.insert( "expression", "" );
114  mProperty.insert( "field", "" );
115  }
116  else
117  {
118  mProperty.insert( "active", datadefined->isActive() ? "1" : "0" );
119  mProperty.insert( "useexpr", datadefined->useExpression() ? "1" : "0" );
120  mProperty.insert( "expression", datadefined->expressionString() );
121  mProperty.insert( "field", datadefined->field() );
122  }
123 
124  mDataTypes = datatypes;
125  mFieldNameList.clear();
126  mFieldTypeList.clear();
127 
128  mInputDescription = description;
129  mFullDescription = QString( "" );
130  mUsageInfo = QString( "" );
131  mCurrentDefinition = QString( "" );
132 
133  // set up data types string
134  mDataTypesString = QString( "" );
135 
136  QStringList ts;
137  if ( mDataTypes.testFlag( String ) )
138  {
139  ts << tr( "string" );
140  }
141  if ( mDataTypes.testFlag( Int ) )
142  {
143  ts << tr( "int" );
144  }
145  if ( mDataTypes.testFlag( Double ) )
146  {
147  ts << tr( "double" );
148  }
149 
150  if ( !ts.isEmpty() )
151  {
152  mDataTypesString = ts.join( ", " );
153  mActionDataTypes->setText( tr( "Field type: " ) + mDataTypesString );
154  }
155 
156  if ( mVectorLayer )
157  {
158  // store just a list of fields of unknown type or those that match the expected type
159  const QgsFields& fields = mVectorLayer->pendingFields();
160  for ( int i = 0; i < fields.count(); ++i )
161  {
162  const QgsField& f = fields.at( i );
163  bool fieldMatch = false;
164  // NOTE: these are the only QVariant enums supported at this time (see QgsField)
165  QString fieldType;
166  switch ( f.type() )
167  {
168  case QVariant::String:
169  fieldMatch = mDataTypes.testFlag( String );
170  fieldType = tr( "string" );
171  break;
172  case QVariant::Int:
173  fieldMatch = mDataTypes.testFlag( Int ) || mDataTypes.testFlag( Double );
174  fieldType = tr( "integer" );
175  break;
176  case QVariant::Double:
177  fieldMatch = mDataTypes.testFlag( Double );
178  fieldType = tr( "double" );
179  break;
180  case QVariant::Invalid:
181  default:
182  fieldMatch = true; // field type is unknown
183  fieldType = tr( "unknown type" );
184  }
185  if ( fieldMatch || mDataTypes.testFlag( AnyType ) )
186  {
187  mFieldNameList << f.name();
188  mFieldTypeList << fieldType;
189  }
190  }
191  }
192 
193  updateGui();
194 }
195 
196 void QgsDataDefinedButton::mouseReleaseEvent( QMouseEvent *event )
197 {
198  // Ctrl-click to toggle activated state
199  if (( event->modifiers() & ( Qt::ControlModifier ) )
200  || event->button() == Qt::RightButton )
201  {
202  setActive( !isActive() );
203  updateGui();
204  event->ignore();
205  return;
206  }
207 
208  // pass to default behaviour
209  QToolButton::mousePressEvent( event );
210 }
211 
212 void QgsDataDefinedButton::aboutToShowMenu()
213 {
214  mDefineMenu->clear();
215 
216  bool hasExp = !getExpression().isEmpty();
217  bool hasField = !getField().isEmpty();
218  QString ddTitle = tr( "Data defined override" );
219 
220  QAction* ddTitleAct = mDefineMenu->addAction( ddTitle );
221  QFont titlefont = ddTitleAct->font();
222  titlefont.setItalic( true );
223  ddTitleAct->setFont( titlefont );
224  ddTitleAct->setEnabled( false );
225 
226  bool addActiveAction = false;
227  if ( useExpression() && hasExp )
228  {
229  QgsExpression exp( getExpression() );
230  // whether expression is parse-able
231  addActiveAction = !exp.hasParserError();
232  }
233  else if ( !useExpression() && hasField )
234  {
235  // whether field exists
236  addActiveAction = mFieldNameList.contains( getField() );
237  }
238 
239  if ( addActiveAction )
240  {
241  ddTitleAct->setText( ddTitle + " (" + ( useExpression() ? tr( "expression" ) : tr( "field" ) ) + ")" );
242  mDefineMenu->addAction( mActionActive );
243  mActionActive->setText( isActive() ? tr( "Deactivate" ) : tr( "Activate" ) );
244  mActionActive->setData( QVariant( isActive() ? false : true ) );
245  }
246 
247  if ( !mFullDescription.isEmpty() )
248  {
249  mDefineMenu->addAction( mActionDescription );
250  }
251 
252  mDefineMenu->addSeparator();
253 
254  if ( !mDataTypesString.isEmpty() )
255  {
256  QAction* fieldTitleAct = mDefineMenu->addAction( tr( "Attribute field" ) );
257  fieldTitleAct->setFont( titlefont );
258  fieldTitleAct->setEnabled( false );
259 
260  mDefineMenu->addAction( mActionDataTypes );
261 
262  mFieldsMenu->clear();
263 
264  if ( mFieldNameList.size() > 0 )
265  {
266 
267  for ( int j = 0; j < mFieldNameList.count(); ++j )
268  {
269  QString fldname = mFieldNameList.at( j );
270  QAction* act = mFieldsMenu->addAction( fldname + " (" + mFieldTypeList.at( j ) + ")" );
271  act->setData( QVariant( fldname ) );
272  if ( getField() == fldname )
273  {
274  act->setCheckable( true );
275  act->setChecked( !useExpression() );
276  }
277  }
278  }
279  else
280  {
281  QAction* act = mFieldsMenu->addAction( tr( "No matching field types found" ) );
282  act->setEnabled( false );
283  }
284 
285  mDefineMenu->addSeparator();
286  }
287 
288  QAction* exprTitleAct = mDefineMenu->addAction( tr( "Expression" ) );
289  exprTitleAct->setFont( titlefont );
290  exprTitleAct->setEnabled( false );
291 
292  if ( hasExp )
293  {
294  QString expString = getExpression();
295  if ( expString.length() > 35 )
296  {
297  expString.truncate( 35 );
298  expString.append( "..." );
299  }
300 
301  expString.prepend( tr( "Current: " ) );
302 
303  if ( !mActionExpression )
304  {
305  mActionExpression = new QAction( expString, this );
306  mActionExpression->setCheckable( true );
307  }
308  else
309  {
310  mActionExpression->setText( expString );
311  }
312  mDefineMenu->addAction( mActionExpression );
313  mActionExpression->setChecked( useExpression() );
314 
315  mDefineMenu->addAction( mActionExpDialog );
316  mDefineMenu->addAction( mActionCopyExpr );
317  mDefineMenu->addAction( mActionPasteExpr );
318  mDefineMenu->addAction( mActionClearExpr );
319  }
320  else
321  {
322  mDefineMenu->addAction( mActionExpDialog );
323  mDefineMenu->addAction( mActionPasteExpr );
324  }
325 
326  if ( mAssistant.data() )
327  {
328  mDefineMenu->addSeparator();
329  mDefineMenu->addAction( mActionAssistant );
330  }
331 }
332 
333 void QgsDataDefinedButton::menuActionTriggered( QAction* action )
334 {
335  if ( action == mActionActive )
336  {
337  setActive( mActionActive->data().toBool() );
338  updateGui();
339  }
340  else if ( action == mActionDescription )
341  {
342  showDescriptionDialog();
343  }
344  else if ( action == mActionExpDialog )
345  {
346  showExpressionDialog();
347  }
348  else if ( action == mActionExpression )
349  {
350  setUseExpression( true );
351  setActive( true );
352  updateGui();
353  }
354  else if ( action == mActionCopyExpr )
355  {
356  QApplication::clipboard()->setText( getExpression() );
357  }
358  else if ( action == mActionPasteExpr )
359  {
360  QString exprString = QApplication::clipboard()->text();
361  if ( !exprString.isEmpty() )
362  {
363  setExpression( exprString );
364  setUseExpression( true );
365  setActive( true );
366  updateGui();
367  }
368  }
369  else if ( action == mActionClearExpr )
370  {
371  // only deactivate if defined expression is being used
372  if ( isActive() && useExpression() )
373  {
374  setUseExpression( false );
375  setActive( false );
376  }
377  setExpression( QString( "" ) );
378  updateGui();
379  }
380  else if ( action == mActionAssistant )
381  {
382  showAssistant();
383  }
384  else if ( mFieldsMenu->actions().contains( action ) ) // a field name clicked
385  {
386  if ( action->isEnabled() )
387  {
388  if ( getField() != action->text() )
389  {
390  setField( action->data().toString() );
391  }
392  setUseExpression( false );
393  setActive( true );
394  updateGui();
395  }
396  }
397 }
398 
399 void QgsDataDefinedButton::showDescriptionDialog()
400 {
401  QgsMessageViewer* mv = new QgsMessageViewer( this );
402  mv->setWindowTitle( tr( "Data definition description" ) );
403  mv->setMessageAsHtml( mFullDescription );
404  mv->exec();
405 }
406 
407 void QgsDataDefinedButton::showAssistant()
408 {
409  if ( !mAssistant.data() )
410  return;
411 
412  if ( mAssistant->exec() == QDialog::Accepted )
413  {
414  QScopedPointer<QgsDataDefined> dd( mAssistant->dataDefined() );
415  setUseExpression( dd->useExpression() );
416  setActive( dd->isActive() );
417  if ( dd->isActive() && dd->useExpression() )
418  setExpression( dd->expressionString() );
419  else if ( dd->isActive() )
420  setField( dd->field() );
421  updateGui();
422  }
423  activateWindow(); // reset focus to parent window
424 }
425 
426 void QgsDataDefinedButton::showExpressionDialog()
427 {
428  QgsExpressionBuilderDialog d( const_cast<QgsVectorLayer*>( mVectorLayer ), getExpression() );
429  if ( d.exec() == QDialog::Accepted )
430  {
431  QString newExp = d.expressionText();
432  setExpression( d.expressionText().trimmed() );
433  bool hasExp = !newExp.isEmpty();
434 
435  setUseExpression( hasExp );
436  setActive( hasExp );
437  updateGui();
438  }
439  activateWindow(); // reset focus to parent window
440 }
441 
442 void QgsDataDefinedButton::updateGui()
443 {
444  QString oldDef = mCurrentDefinition;
445  QString newDef( "" );
446  bool hasExp = !getExpression().isEmpty();
447  bool hasField = !getField().isEmpty();
448 
449  if ( useExpression() && !hasExp )
450  {
451  setActive( false );
452  setUseExpression( false );
453  }
454  else if ( !useExpression() && !hasField )
455  {
456  setActive( false );
457  }
458 
459  QIcon icon = mIconDataDefine;
460  QString deftip = tr( "undefined" );
461  if ( useExpression() && hasExp )
462  {
463  icon = isActive() ? mIconDataDefineExpressionOn : mIconDataDefineExpression;
464  newDef = deftip = getExpression();
465 
466  QgsExpression exp( getExpression() );
467  if ( exp.hasParserError() )
468  {
469  setActive( false );
470  icon = mIconDataDefineExpressionError;
471  deftip = tr( "Parse error: %1" ).arg( exp.parserErrorString() );
472  newDef = "";
473  }
474  }
475  else if ( !useExpression() && hasField )
476  {
477  icon = isActive() ? mIconDataDefineOn : mIconDataDefine;
478  newDef = deftip = getField();
479 
480  if ( !mFieldNameList.contains( getField() ) )
481  {
482  setActive( false );
483  icon = mIconDataDefineError;
484  deftip = tr( "'%1' field missing" ).arg( getField() );
485  newDef = "";
486  }
487  }
488 
489  setIcon( icon );
490 
491  // update and emit current definition
492  if ( newDef != oldDef )
493  {
494  mCurrentDefinition = newDef;
495  emit dataDefinedChanged( mCurrentDefinition );
496  }
497 
498  // build full description for tool tip and popup dialog
499  mFullDescription = tr( "<b><u>Data defined override</u></b><br>" );
500 
501  mFullDescription += tr( "<b>Active: </b>%1&nbsp;&nbsp;&nbsp;<i>(ctrl|right-click toggles)</i><br>" ).arg( isActive() ? tr( "yes" ) : tr( "no" ) );
502 
503  if ( !mUsageInfo.isEmpty() )
504  {
505  mFullDescription += tr( "<b>Usage:</b><br>%1<br>" ).arg( mUsageInfo );
506  }
507 
508  if ( !mInputDescription.isEmpty() )
509  {
510  mFullDescription += tr( "<b>Expected input:</b><br>%1<br>" ).arg( mInputDescription );
511  }
512 
513  if ( !mDataTypesString.isEmpty() )
514  {
515  mFullDescription += tr( "<b>Valid input types:</b><br>%1<br>" ).arg( mDataTypesString );
516  }
517 
518  QString deftype( "" );
519  if ( deftip != tr( "undefined" ) )
520  {
521  deftype = QString( " (%1)" ).arg( useExpression() ? tr( "expression" ) : tr( "field" ) );
522  }
523 
524  // truncate long expressions, or tool tip may be too wide for screen
525  if ( deftip.length() > 75 )
526  {
527  deftip.truncate( 75 );
528  deftip.append( "..." );
529  }
530 
531  mFullDescription += tr( "<b>Current definition %1:</b><br>%2" ).arg( deftype ).arg( deftip );
532 
533  setToolTip( mFullDescription );
534 
535 }
536 
538 {
539  if ( isActive() != active )
540  {
541  mProperty.insert( "active", active ? "1" : "0" );
542  emit dataDefinedActivated( active );
543  }
544 }
545 
546 void QgsDataDefinedButton::registerEnabledWidgets( QList<QWidget*> wdgts )
547 {
548  for ( int i = 0; i < wdgts.size(); ++i )
549  {
550  registerEnabledWidget( wdgts.at( i ) );
551  }
552 }
553 
555 {
556  QPointer<QWidget> wdgtP( wdgt );
557  if ( !mEnabledWidgets.contains( wdgtP ) )
558  {
559  mEnabledWidgets.append( wdgtP );
560  }
561 }
562 
564 {
565  QList<QWidget*> wdgtList;
566  for ( int i = 0; i < mEnabledWidgets.size(); ++i )
567  {
568  wdgtList << mEnabledWidgets.at( i );
569  }
570  return wdgtList;
571 }
572 
574 {
575  for ( int i = 0; i < mEnabledWidgets.size(); ++i )
576  {
577  mEnabledWidgets.at( i )->setDisabled( disable );
578  }
579 }
580 
581 void QgsDataDefinedButton::registerCheckedWidgets( QList<QWidget*> wdgts )
582 {
583  for ( int i = 0; i < wdgts.size(); ++i )
584  {
585  registerCheckedWidget( wdgts.at( i ) );
586  }
587 }
588 
590 {
591  QPointer<QWidget> wdgtP( wdgt );
592  if ( !mCheckedWidgets.contains( wdgtP ) )
593  {
594  mCheckedWidgets.append( wdgtP );
595  }
596 }
597 
599 {
600  QList<QWidget*> wdgtList;
601  for ( int i = 0; i < mCheckedWidgets.size(); ++i )
602  {
603  wdgtList << mCheckedWidgets.at( i );
604  }
605  return wdgtList;
606 }
607 
609 {
610  mAssistant.reset( assistant );
611  mAssistant.data()->setParent( this, Qt::Dialog );
612 }
613 
615 {
616  // don't uncheck, only set to checked
617  if ( !check )
618  {
619  return;
620  }
621  for ( int i = 0; i < mCheckedWidgets.size(); ++i )
622  {
623  QAbstractButton *btn = qobject_cast< QAbstractButton * >( mCheckedWidgets.at( i ) );
624  if ( btn && btn->isCheckable() )
625  {
626  btn->setChecked( true );
627  continue;
628  }
629  QGroupBox *grpbx = qobject_cast< QGroupBox * >( mCheckedWidgets.at( i ) );
630  if ( grpbx && grpbx->isCheckable() )
631  {
632  grpbx->setChecked( true );
633  }
634  }
635 }
636 
638 {
639  // just something to reduce translation redundancy
640  return tr( "string " );
641 }
642 
644 {
645  return tr( "bool [<b>1</b>=True|<b>0</b>=False]" );
646 }
647 
649 {
650  return tr( "string of variable length" );
651 }
652 
654 {
655  return tr( "int [&lt;= 0 =&gt;]" );
656 }
657 
659 {
660  return tr( "int [&gt;= 0]" );
661 }
662 
664 {
665  return tr( "int [&gt;= 1]" );
666 }
667 
669 {
670  return tr( "double [&lt;= 0.0 =&gt;]" );
671 }
672 
674 {
675  return tr( "double [&gt;= 0.0]" );
676 }
677 
679 {
680  return tr( "double [0.0-1.0]" );
681 }
682 
684 {
685  return tr( "double coord [<b>X,Y</b>] as &lt;= 0.0 =&gt;" );
686 }
687 
689 {
690  return tr( "double [-180.0 - 180.0]" );
691 }
692 
694 {
695  return tr( "int [0-100]" );
696 }
697 
699 {
700  return trString() + "[<b>MM</b>|<b>MapUnit</b>]";
701 }
702 
704 {
705  return trString() + "[<b>MM</b>|<b>MapUnit</b>|<b>Percent</b>]";
706 }
707 
709 {
710  return tr( "string [<b>r,g,b</b>] as int 0-255" );
711 }
712 
714 {
715  return tr( "string [<b>r,g,b,a</b>] as int 0-255" );
716 }
717 
719 {
720  return trString() + "[<b>Left</b>|<b>Center</b>|<b>Right</b>]";
721 }
722 
724 {
725  return trString() + "[<b>Bottom</b>|<b>Middle</b>|<b>Top</b>]";
726 }
727 
729 {
730  return trString() + "[<b>bevel</b>|<b>miter</b>|<b>round</b>]";
731 }
732 
734 {
735  return trString() + QString( "[<b>Normal</b>|<b>Lighten</b>|<b>Screen</b>|<b>Dodge</b>|<br>"
736  "<b>Addition</b>|<b>Darken</b>|<b>Multiply</b>|<b>Burn</b>|<b>Overlay</b>|<br>"
737  "<b>SoftLight</b>|<b>HardLight</b>|<b>Difference</b>|<b>Subtract</b>]" );
738 }
739 
741 {
742  return trString() + QString( "[<b>filepath</b>] as<br>"
743  "<b>''</b>=empty|absolute|search-paths-relative|<br>"
744  "project-relative|URL" );
745 }
746 
748 {
749  return tr( "string [<b>filepath</b>]" );
750 }
751 
753 {
754  return trString() + QString( "[<b>A5</b>|<b>A4</b>|<b>A3</b>|<b>A2</b>|<b>A1</b>|<b>A0</b>"
755  "<b>B5</b>|<b>B4</b>|<b>B3</b>|<b>B2</b>|<b>B1</b>|<b>B0</b>"
756  "<b>Legal</b>|<b>Ansi A</b>|<b>Ansi B</b>|<b>Ansi C</b>|<b>Ansi D</b>|<b>Ansi E</b>"
757  "<b>Arch A</b>|<b>Arch B</b>|<b>Arch C</b>|<b>Arch D</b>|<b>Arch E</b>|<b>Arch E1</b>]"
758  );
759 }
760 
762 {
763  return trString() + QString( "[<b>portrait</b>|<b>landscape</b>]" );
764 }
765 
767 {
768  return trString() + QString( "[<b>left</b>|<b>center</b>|<b>right</b>]" );
769 }
770 
772 {
773  return trString() + QString( "[<b>top</b>|<b>center</b>|<b>bottom</b>]" );
774 }
775 
777 {
778  return trString() + QString( "[<b>linear</b>|<b>radial</b>|<b>conical</b>]" );
779 }
780 
782 {
783  return trString() + QString( "[<b>feature</b>|<b>viewport</b>]" );
784 }
785 
787 {
788  return trString() + QString( "[<b>pad</b>|<b>repeat</b>|<b>reflect</b>]" );
789 }
790 
792 {
793  return trString() + QString( "[<b>no</b>|<b>solid</b>|<b>dash</b>|<b>dot</b>|<b>dash dot</b>|<b>dash dot dot</b>]" );
794 }
795 
797 {
798  return trString() + QString( "[<b>square</b>|<b>flat</b>|<b>round</b>]" );
799 }
800 
802 {
803  return trString() + QString( "[<b>solid</b>|<b>horizontal</b>|<b>vertical</b>|<b>cross</b>|<b>b_diagonal</b>|<b>f_diagonal"
804  "</b>|<b>diagonal_x</b>|<b>dense1</b>|<b>dense2</b>|<b>dense3</b>|<b>dense4</b>|<b>dense5"
805  "</b>|<b>dense6</b>|<b>dense7</b>|<b>no]" );
806 }
807 
809 {
810  return trString() + QString( "[<b>circle</b>|<b>rectangle</b>|<b>cross</b>|<b>triangle</b>]" );
811 }
812 
814 {
815  return tr( "[<b><dash>;<space></b>] e.g. '8;2;1;2'" );
816 }
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:86
const QString & name() const
Gets the name of the field.
Definition: qgsfield.cpp:59
static QString gradientSpreadDesc()
An assistant (wizard) dialog, accessible from a QgsDataDefinedButton.
void setExpression(QString exp)
Set the current defined expression.
void setField(QString field)
Set the current defined field.
bool isActive()
Whether the current data definition or expression is to be used.
A container class for data source field mapping or expression.
void setAssistant(QgsDataDefinedAssistant *assistant)
Sets an assistant used to define the data defined object properties.
static QString doublePosDesc()
static QString colorNoAlphaDesc()
static QString textVertAlignDesc()
QString field() const
QList< QWidget * > registeredEnabledWidgets()
Return widget siblings that get disabled/enabled when data definition or expression is set/unset...
static QString paperOrientationDesc()
void dataDefinedChanged(const QString &definition)
Emitted when data definition or expression is changed.
static QIcon getThemeIcon(const QString &theName)
Helper to get a theme icon.
static QString unitsMmMuDesc()
void registerCheckedWidgets(QList< QWidget * > wdgts)
Register list of sibling widgets that get checked when data definition or expression is active...
static QString anyStringDesc()
Container of fields for a vector layer.
Definition: qgsfield.h:172
void disableEnabledWidgets(bool disable)
Set siblings' enabled property when data definition or expression is set/unset.
bool useExpression()
Whether the current expression is to be used instead of field mapping.
static QString lineStyleDesc()
QString expressionString() const
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
Definition: qgsfield.h:227
void init(const QgsVectorLayer *vl, const QgsDataDefined *datadefined=0, DataTypes datatypes=AnyType, QString description=QString(""))
Initialize a newly constructed data defined button (useful if button already included from form layou...
static QString horizontalAnchorDesc()
void mouseReleaseEvent(QMouseEvent *event) override
void setMessageAsHtml(const QString &msg)
void setActive(bool active)
Set whether the current data definition or expression is to be used.
static QString unitsMmMuPercentDesc()
void registerEnabledWidget(QWidget *wdgt)
Register a sibling widget that gets disabled/enabled when data definition or expression is set/unset...
static QString textHorzAlignDesc()
static QString penJoinStyleDesc()
static QString double180RotDesc()
static QString gradientTypeDesc()
static QString intTranspDesc()
QString getExpression() const
The current defined expression.
int count() const
Return number of items.
Definition: qgsfield.h:214
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:33
bool useExpression() const
void registerEnabledWidgets(QList< QWidget * > wdgts)
Register list of sibling widgets that get disabled/enabled when data definition or expression is set/...
QList< QWidget * > registeredCheckedWidgets()
Return widget siblings that get checked when data definition or expression is active.
static QString markerStyleDesc()
void dataDefinedActivated(bool active)
Emitted when active state changed.
static QString blendModesDesc()
static QString gradientCoordModeDesc()
static QString trString()
Common descriptions for expected input values.
void registerCheckedWidget(QWidget *wdgt)
Register a sibling widget that get checked when data definition or expression is active.
QString getField() const
The current defined field.
static QString verticalAnchorDesc()
static QString fillStyleDesc()
static QString paperSizeDesc()
void setUseExpression(bool use)
Set whether the current expression is to be used instead of field mapping.
void checkCheckedWidgets(bool check)
Set siblings' checked property when data definition or expression is active.
A generic message view for displaying QGIS messages.
static QString intPosOneDesc()
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
QgsDataDefinedButton(QWidget *parent=0, const QgsVectorLayer *vl=0, const QgsDataDefined *datadefined=0, DataTypes datatypes=AnyType, QString description="")
Construct a new data defined button.
static QString customDashDesc()
Represents a vector layer which manages a vector based data sets.
bool isActive() const
A generic dialog for building expression strings.
static QString double0to1Desc()
static QString colorAlphaDesc()
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.
Definition: qgsfield.cpp:64
#define tr(sourceText)