16 #ifndef QGSEXPRESSIONBUILDER_H 17 #define QGSEXPRESSIONBUILDER_H 21 #include "ui_qgsexpressionbuilder.h" 26 #include "QStandardItemModel" 27 #include "QStandardItem" 28 #include "QSortFilterProxyModel" 29 #include "QStringListModel" 51 const QString &expressionText,
52 const QString &helpText,
54 : QStandardItem( label )
56 mExpressionText = expressionText;
59 setData( itemType, ITEM_TYPE_ROLE );
63 const QString &expressionText,
65 : QStandardItem( label )
67 mExpressionText = expressionText;
69 setData( itemType, ITEM_TYPE_ROLE );
86 void setHelpText(
const QString &helpText ) { mHelpText = helpText; }
96 static const int CUSTOM_SORT_ROLE = Qt::UserRole + 1;
98 static const int ITEM_TYPE_ROLE = Qt::UserRole + 2;
101 QString mExpressionText;
120 bool filterAcceptsRow(
int source_row,
const QModelIndex &source_parent )
const override;
124 bool lessThan(
const QModelIndex &left,
const QModelIndex &right )
const override;
154 void loadFieldNames();
156 void loadFieldNames(
const QgsFields &fields );
163 void loadFieldsAndValues(
const QMap<QString, QStringList> &fieldValues );
171 QString expressionText();
174 void setExpressionText(
const QString &expression );
203 void registerItem(
const QString &group,
const QString &label,
const QString &expressionText,
204 const QString &helpText = QString(),
206 bool highlightedItem =
false,
int sortOrder = 1 );
208 bool isExpressionValid();
214 void saveToRecent(
const QString &collection =
"generic" );
220 void loadRecent(
const QString &collection =
"generic" );
225 void newFunctionFile(
const QString &fileName =
"scratch" );
230 void saveFunctionFile( QString fileName );
235 void loadCodeFromFile( QString path );
240 void loadFunctionCode(
const QString &code );
245 void updateFunctionFileList(
const QString &path );
252 QStandardItemModel *model();
275 bool evalError()
const;
283 bool parserError()
const;
290 void loadSampleValues();
295 void loadAllValues();
310 void showContextMenu( QPoint );
311 void setExpressionState(
bool state );
312 void currentChanged(
const QModelIndex &index,
const QModelIndex & );
313 void operatorButtonClicked();
314 void btnRun_pressed();
315 void btnNewFile_pressed();
316 void cmbFileNames_currentItemChanged( QListWidgetItem *item, QListWidgetItem *lastitem );
317 void expressionTree_doubleClicked(
const QModelIndex &index );
318 void txtExpressionString_textChanged();
319 void txtSearchEdit_textChanged();
320 void txtSearchEditValues_textChanged();
321 void lblPreview_linkActivated(
const QString &link );
322 void mValuesListView_doubleClicked(
const QModelIndex &index );
323 void txtPython_textChanged();
333 void expressionParsed(
bool isValid );
341 void evalErrorChanged();
349 void parserErrorChanged();
352 void showEvent( QShowEvent *e )
override;
355 void runPythonCode(
const QString &code );
356 void updateFunctionTree();
357 void fillFieldValues(
const QString &fieldName,
int countLimit );
359 QString helpStylesheet()
const;
361 void loadExpressionContext();
364 void loadRelations();
379 void registerItemForAllGroups(
const QStringList &groups,
const QString &label,
const QString &expressionText,
380 const QString &helpText = QString(),
382 bool highlightedItem =
false,
int sortOrder = 1 );
387 QString formatRelationHelp(
const QgsRelation &relation )
const;
392 QString formatLayerHelp(
const QgsMapLayer *layer )
const;
400 void setEvalError(
bool evalError );
408 void setParserError(
bool parserError );
410 bool mAutoSave =
true;
411 QString mFunctionsPath;
413 QStandardItemModel *mModel =
nullptr;
414 QStringListModel *mValuesModel =
nullptr;
415 QSortFilterProxyModel *mProxyValues =
nullptr;
417 QMap<QString, QgsExpressionItem *> mExpressionGroups;
419 bool mExpressionValid =
false;
422 QMap<QString, QStringList> mFieldValues;
424 QPointer< QgsProject > mProject;
425 bool mEvalError =
true;
426 bool mParserError =
true;
431 #endif // QGSEXPRESSIONBUILDER_H Base class for all map layer types.
QgsExpressionItem(const QString &label, const QString &expressionText, const QString &helpText, QgsExpressionItem::ItemType itemType=ExpressionNode)
Container of fields for a vector layer.
Search proxy used to filter the QgsExpressionBuilderWidget tree.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Reads and writes project states.
QgsExpressionItem::ItemType getItemType() const
Get the type of expression item, e.g., header, field, ExpressionNode.
QgsExpressionItem(const QString &label, const QString &expressionText, QgsExpressionItem::ItemType itemType=ExpressionNode)
A general purpose distance and area calculator, capable of performing ellipsoid based calculations...
An expression item that can be used in the QgsExpressionBuilderWidget tree.
QString getExpressionText() const
QString getHelpText() const
Get the help text that is associated with this expression item.
Represents a vector layer which manages a vector based data sets.
void setHelpText(const QString &helpText)
Set the help text for the current item.