QGIS API Documentation  2.11.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
qgsdatadefinedsymboldialog.cpp
Go to the documentation of this file.
4 #include "qgsvectorlayer.h"
5 #include "qgslogger.h"
6 
7 #include <QCheckBox>
8 #include <QSettings>
9 
10 
12  : QDialog( parent, f )
13  , mVectorLayer( vl )
14 {
15  setupUi( this );
16 
17  QgsFields attributeFields;
18  if ( mVectorLayer )
19  {
20  attributeFields = mVectorLayer->fields();
21  }
22 
23  int i = 0;
25  for ( ; entryIt != entries.constEnd(); ++entryIt )
26  {
27  QTreeWidgetItem* item = new QTreeWidgetItem( mTreeWidget );
28 
29  //check box
30  QCheckBox* cb = new QCheckBox( entryIt->title, this );
31  cb->setChecked( !entryIt->initialValue.isEmpty() );
32  item->setData( 0, Qt::UserRole, entryIt->property );
33  mTreeWidget->setItemWidget( item, 0, cb );
34 
35  // expression
37  few->setMaximumWidth( 350 );
38  few->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum );
39  few->setLayer( const_cast<QgsVectorLayer*>( vl ) );
40  few->setField( entryIt->initialValue );
41  mTreeWidget->setItemWidget( item, 1, few );
42 
43  //help text
44  item->setText( 2, entryIt->helpText );
45 
46  mTreeWidget->addTopLevelItem( item );
47  ++i;
48  }
49 
50  for ( int c = 0; c != mTreeWidget->columnCount() - 1; c++ )
51  mTreeWidget->resizeColumnToContents( c );
52 
53  QSettings settings;
54  restoreGeometry( settings.value( "/Windows/QgsDataDefinedSymbolDialog/geometry" ).toByteArray() );
55 }
56 
58 {
59  QSettings settings;
60  settings.setValue( "/Windows/QgsDataDefinedSymbolDialog/geometry", saveGeometry() );
61 }
62 
64 {
65  QMap< QString, QString > propertyMap;
66  int rowCount = mTreeWidget->topLevelItemCount();
67  for ( int i = 0; i < rowCount; ++i )
68  {
69  QTreeWidgetItem* item = mTreeWidget->topLevelItem( i );
70  //property
71  QString propertyKey = item->data( 0, Qt::UserRole ).toString();
72  //checked?
73  bool checked = false;
74  QCheckBox* cb = qobject_cast<QCheckBox*>( mTreeWidget->itemWidget( item, 0 ) );
75  if ( cb )
76  {
77  checked = cb->isChecked();
78  }
79  QString expressionString;
80  if ( checked )
81  {
82  QgsFieldExpressionWidget* few = qobject_cast<QgsFieldExpressionWidget*>( mTreeWidget->itemWidget( item, 1 ) );
83  expressionString = few->currentField();
84  }
85  propertyMap.insert( propertyKey, expressionString );
86  }
87  return propertyMap;
88 }
89 
91 {
92  return tr( "double" );
93 }
94 
96 {
97  return tr( "'<red>,<green>,<blue>,<alpha>'" );
98 }
99 
101 {
102  return "'<x>,<y>'";
103 }
104 
106 {
107  return tr( "'<filename>'" );
108 }
109 
111 {
112  // Don't translate, localized keywords are not supported.
113  return "'left'|'center'|'right'";
114 }
115 
117 {
118  // Don't translate, localized keywords are not supported.
119  return "'top'|'center'|'bottom'";
120 }
121 
123 {
124  return tr( "'linear'|'radial'|'conical'" );
125 }
126 
128 {
129  return tr( "'feature'|'viewport'" );
130 }
131 
133 {
134  return tr( "'pad'|'repeat'|'reflect'" );
135 }
136 
138 {
139  return tr( "0 (false)|1 (true)" );
140 }
141 
143 {
144  return "'no'|'solid'|'dash'|'dot'|'dash dot'|'dash dot dot'";
145 }
146 
148 {
149  return "'bevel'|'miter'|'round'";
150 }
151 
153 {
154  return "'square'|'flat'|'round'";
155 }
156 
158 {
159  return "'solid'|'horizontal'|'vertical'|'cross'|'b_diagonal'|'f_diagonal'|"
160  "'diagonal_x'|'dense1'|'dense2'|'dense3'|'dense4'|'dense5'|"
161  "'dense6'|'dense7'|'no'";
162 }
163 
164 
The QgsFieldExpressionWidget class reates a widget to choose fields and edit expressions It contains ...
QByteArray toByteArray() const
void setupUi(QWidget *widget)
static Q_DECL_DEPRECATED QString gradientSpreadHelpText()
static Q_DECL_DEPRECATED QString gradientCoordModeHelpText()
static Q_DECL_DEPRECATED QString fileNameHelpText()
Q_DECL_DEPRECATED QgsDataDefinedSymbolDialog(const QList< DataDefinedSymbolEntry > &entries, const QgsVectorLayer *vl, QWidget *parent=0, Qt::WindowFlags f=0)
QgsFields fields() const
Returns the list of fields of this layer.
static Q_DECL_DEPRECATED QString lineStyleHelpText()
Container of fields for a vector layer.
Definition: qgsfield.h:177
static Q_DECL_DEPRECATED QString offsetHelpText()
virtual void setData(int column, int role, const QVariant &value)
void setLayer(QgsVectorLayer *layer)
set the layer used to display the fields and expression
static Q_DECL_DEPRECATED QString horizontalAnchorHelpText()
virtual QVariant data(int column, int role) const
QString tr(const char *sourceText, const char *disambiguation, int n)
static Q_DECL_DEPRECATED QString fillStyleHelpText()
void setValue(const QString &key, const QVariant &value)
static Q_DECL_DEPRECATED QString doubleHelpText()
Q_DECL_DEPRECATED QMap< QString, QString > dataDefinedProperties() const
bool restoreGeometry(const QByteArray &geometry)
static Q_DECL_DEPRECATED QString joinStyleHelpText()
void setSizePolicy(QSizePolicy)
static Q_DECL_DEPRECATED QString gradientTypeHelpText()
void setChecked(bool)
static Q_DECL_DEPRECATED QString capStyleHelpText()
QVariant value(const QString &key, const QVariant &defaultValue) const
void setMaximumWidth(int maxw)
QString currentField(bool *isExpression=0, bool *isValid=0) const
currentField returns the currently selected field or expression if allowed
QByteArray saveGeometry() const
void setField(const QString &fieldName)
sets the current field or expression in the widget
void setText(int column, const QString &text)
typedef WindowFlags
iterator insert(const Key &key, const T &value)
const_iterator constEnd() const
const_iterator constBegin() const
static Q_DECL_DEPRECATED QString boolHelpText()
Represents a vector layer which manages a vector based data sets.
static Q_DECL_DEPRECATED QString colorHelpText()
static Q_DECL_DEPRECATED QString verticalAnchorHelpText()
QString toString() const