This file is indexed.

/usr/include/qgis/qgssqlcomposerdialog.h is in libqgis-dev 2.18.17+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/***************************************************************************
                qgssqlcomposerdialog.cpp
       Dialog to compose SQL queries

begin                : Apr 2016
copyright            : (C) 2016 Even Rouault
email                : even.rouault at spatialys.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef QGSSQLCOMPOSERDIALOG_H
#define QGSSQLCOMPOSERDIALOG_H

#include "ui_qgssqlcomposerdialogbase.h"
#include <qgis.h>
#include <qgisgui.h>
#include "qgscontexthelp.h"

#include <QPair>
#include <QStringList>
#include <QSet>

/** \ingroup gui
 * SQL composer dialog
 *  @note not available in Python bindings
 */
class GUI_EXPORT QgsSQLComposerDialog : public QDialog, private Ui::QgsSQLComposerDialogBase
{
    Q_OBJECT

  public:

    //! pair (name, title)
    typedef QPair<QString, QString> PairNameTitle;

    //! pair (name, type)
    typedef QPair<QString, QString> PairNameType;

    /** \ingroup gui
     * Callback to do actions on table selection
     * @note not available in Python bindings
     */
    class GUI_EXPORT TableSelectedCallback
    {
      public:
        virtual ~TableSelectedCallback();
        //! method called when a table is selected
        virtual void tableSelected( const QString& name ) = 0;
    };

    /** \ingroup gui
     * Callback to do validation check on dialog validation.
     * @note not available in Python bindings
     */
    class GUI_EXPORT SQLValidatorCallback
    {
      public:
        virtual ~SQLValidatorCallback();
        //! method should return true if the SQL is valid. Otherwise return false and set the errorReason
        virtual bool isValid( const QString& sql, QString& errorReason, QString& warningMsg ) = 0;
    };

    //! argument of a function
    struct Argument
    {
      //! name
      QString name;
      //! type, or empty if unknown
      QString type;

      //! constructor
      Argument( const QString& nameIn = QString(), const QString& typeIn = QString() ) : name( nameIn ), type( typeIn ) {}
    };

    //! description of server functions
    struct Function
    {
      //! name
      QString name;
      //! return type, or empty if unknown
      QString returnType;
      //! minimum number of argument (or -1 if unknown)
      int minArgs;
      //! maximum number of argument (or -1 if unknown)
      int maxArgs;
      //! list of arguments. May be empty despite minArgs > 0
      QList<Argument> argumentList;

      //! constructor with name and fixed number of arguments
      Function( const QString& nameIn, int args ) : name( nameIn ), minArgs( args ), maxArgs( args ) {}
      //! constructor with name and min,max number of arguments
      Function( const QString& nameIn, int minArgs, int maxArgsIn ) : name( nameIn ), minArgs( minArgs ), maxArgs( maxArgsIn ) {}
      //! default constructor
      Function() : minArgs( -1 ), maxArgs( -1 ) {}
    };

    //! constructor
    explicit QgsSQLComposerDialog( QWidget * parent = nullptr, Qt::WindowFlags fl = QgisGui::ModalDialogFlags );
    virtual ~QgsSQLComposerDialog();

    //! initialize the SQL statement
    void setSql( const QString& sql );

    //! get the SQL statement
    QString sql() const;

    //! add a list of table names
    void addTableNames( const QStringList& list );
    //! add a list of table names
    void addTableNames( const QList<PairNameTitle> & listNameTitle );
    //! add a list of column names
    void addColumnNames( const QStringList& list, const QString& tableName );
    //! add a list of column names
    void addColumnNames( const QList<PairNameType>& list, const QString& tableName );
    //! add a list of operators
    void addOperators( const QStringList& list );
    //! add a list of spatial predicates
    void addSpatialPredicates( const QStringList& list );
    //! add a list of spatial predicates
    void addSpatialPredicates( const QList<Function>& list );
    //! add a list of functions
    void addFunctions( const QStringList& list );
    //! add a list of functions
    void addFunctions( const QList<Function>& list );
    //! add a list of API for autocompletion
    void addApis( const QStringList& list );

    //! set if multiple tables/joins are supported. Default is false
    void setSupportMultipleTables( bool bMultipleTables, QString mainTypename = QString() );

    /** Set a callback that will be called when a new table is selected, so
        that new column names can be added typically.
        Ownership of the callback remains to the caller */
    void setTableSelectedCallback( TableSelectedCallback* tableSelectedCallback );

    /** Set a callback that will be called when the OK button is pushed.
        Ownership of the callback remains to the caller */
    void setSQLValidatorCallback( SQLValidatorCallback* sqlValidatorCallback );

  protected:
    bool eventFilter( QObject *obj, QEvent *event ) override;

  private slots:
    void accept() override;

    void on_mTablesCombo_currentIndexChanged( int );
    void on_mColumnsCombo_currentIndexChanged( int );
    void on_mSpatialPredicatesCombo_currentIndexChanged( int );
    void on_mFunctionsCombo_currentIndexChanged( int );
    void on_mOperatorsCombo_currentIndexChanged( int );
    void on_mAddJoinButton_clicked();
    void on_mRemoveJoinButton_clicked();
    void on_mTableJoins_itemSelectionChanged();

    void on_mButtonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }

    void reset();
    void buildSQLFromFields();
    void splitSQLIntoFields();

  private:
    QStringList mApiList;
    QSet<QString> mAlreadySelectedTables;
    TableSelectedCallback* mTableSelectedCallback;
    SQLValidatorCallback* mSQLValidatorCallback;
    QObject* mFocusedObject;
    bool mAlreadyModifyingFields;
    bool mDistinct;
    QString mResetSql;
    QMap<QString, QString> mapTableEntryTextToName;
    QMap<QString, QString> mapColumnEntryTextToName;
    QMap<QString, QString> mapSpatialPredicateEntryTextToName;
    QMap<QString, QString> mapFunctionEntryTextToName;
    QString lastSearchedText;


    void loadTableColumns( const QString& table );
    void functionCurrentIndexChanged( QComboBox* combo,
                                      const QMap<QString, QString>& mapEntryTextToName );
    void getFunctionList( const QList<Function>& list,
                          QStringList& listApi,
                          QStringList& listCombo,
                          QMap<QString, QString>& mapEntryTextToName );
};

#endif