19 #ifndef QGSSQLCOMPOSERDIALOG_H
20 #define QGSSQLCOMPOSERDIALOG_H
22 #include "ui_qgssqlcomposerdialogbase.h"
27 #include <QStringList>
76 virtual bool isValid(
const QString &sql, QString &errorReason, QString &warningMsg ) = 0;
88 Argument(
const QString &nameIn = QString(),
const QString &typeIn = QString() ) : name( nameIn ), type( typeIn ) {}
106 Function(
const QString &nameIn,
int args ) : name( nameIn ), minArgs( args ), maxArgs( args ) {}
108 Function(
const QString &nameIn,
int minArgs,
int maxArgsIn ) : name( nameIn ), minArgs( minArgs ), maxArgs( maxArgsIn ) {}
114 explicit QgsSQLComposerDialog( QWidget *parent =
nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
127 void setSql(
const QString &sql );
133 void setSubsetString(
const QString &subsetString )
override { setSql( subsetString ); }
136 void addTableNames(
const QStringList &list );
138 void addTableNames(
const QList<PairNameTitle> &listNameTitle );
140 void addColumnNames(
const QStringList &list,
const QString &tableName );
142 void addColumnNames(
const QList<PairNameType> &list,
const QString &tableName );
144 void addOperators(
const QStringList &list );
146 void addSpatialPredicates(
const QStringList &list );
148 void addSpatialPredicates(
const QList<Function> &list );
150 void addFunctions(
const QStringList &list );
152 void addFunctions(
const QList<Function> &list );
154 void addApis(
const QStringList &list );
157 void setSupportMultipleTables(
bool bMultipleTables,
const QString &mainTypename = QString() );
164 void setTableSelectedCallback( TableSelectedCallback *tableSelectedCallback );
170 void setSQLValidatorCallback( SQLValidatorCallback *sqlValidatorCallback );
173 bool eventFilter( QObject *obj, QEvent *event )
override;
176 void accept()
override;
178 void mTablesCombo_currentIndexChanged(
int );
179 void mColumnsCombo_currentIndexChanged(
int );
180 void mSpatialPredicatesCombo_currentIndexChanged(
int );
181 void mFunctionsCombo_currentIndexChanged(
int );
182 void mOperatorsCombo_currentIndexChanged(
int );
183 void mAddJoinButton_clicked();
184 void mRemoveJoinButton_clicked();
185 void mTableJoins_itemSelectionChanged();
188 void buildSQLFromFields();
189 void splitSQLIntoFields();
193 QStringList mApiList;
194 QSet<QString> mAlreadySelectedTables;
195 TableSelectedCallback *mTableSelectedCallback =
nullptr;
196 SQLValidatorCallback *mSQLValidatorCallback =
nullptr;
197 QObject *mFocusedObject =
nullptr;
198 bool mAlreadyModifyingFields =
false;
199 bool mDistinct =
false;
201 QMap<QString, QString> mapTableEntryTextToName;
202 QMap<QString, QString> mapColumnEntryTextToName;
203 QMap<QString, QString> mapSpatialPredicateEntryTextToName;
204 QMap<QString, QString> mapFunctionEntryTextToName;
205 QString lastSearchedText;
208 void loadTableColumns(
const QString &table );
209 void functionCurrentIndexChanged( QComboBox *combo,
210 const QMap<QString, QString> &mapEntryTextToName );
211 void getFunctionList(
const QList<Function> &list,
212 QStringList &listApi,
213 QStringList &listCombo,
214 QMap<QString, QString> &mapEntryTextToName );
Callback to do validation check on dialog validation.
virtual ~SQLValidatorCallback()=default
virtual bool isValid(const QString &sql, QString &errorReason, QString &warningMsg)=0
method should return true if the SQL is valid. Otherwise return false and set the errorReason
Callback to do actions on table selection.
virtual void tableSelected(const QString &name)=0
method called when a table is selected
virtual ~TableSelectedCallback()=default
QString subsetString() const override
Returns the subset string entered in the dialog.
QPair< QString, QString > PairNameType
pair (name, type)
QPair< QString, QString > PairNameTitle
pair (name, title)
void setSubsetString(const QString &subsetString) override
Sets a subset string into the dialog.
Interface for a dialog that can edit subset strings.
Represents a vector layer which manages a vector based data sets.
Argument(const QString &nameIn=QString(), const QString &typeIn=QString())
constructor
QString type
type, or empty if unknown
description of server functions
QString returnType
Returns type, or empty if unknown.
Function()=default
default constructor
Function(const QString &nameIn, int args)
constructor with name and fixed number of arguments
QList< Argument > argumentList
list of arguments. May be empty despite minArgs > 0
Function(const QString &nameIn, int minArgs, int maxArgsIn)
constructor with name and min,max number of arguments