/usr/include/qgis/qgsdatadefinedbutton.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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | /***************************************************************************
qgsdatadefinedbutton.h - Data defined selector button
--------------------------------------
Date : 27-April-2013
Copyright : (C) 2013 by Larry Shaffer
Email : larrys at dakcarto dot 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 QGSDATADEFINEDBUTTON_H
#define QGSDATADEFINEDBUTTON_H
#include <QDialog>
#include <QFlags>
#include <QMap>
#include <QPointer>
#include <QToolButton>
#include <QScopedPointer>
#include "qgsexpressioncontext.h"
class QgsVectorLayer;
class QgsDataDefined;
class QgsMapCanvas;
/** \ingroup gui
* \class QgsDataDefinedAssistant
* An assistant (wizard) dialog, accessible from a QgsDataDefinedButton.
* Can be used to guide users through creation of an expression for the
* data defined button.
* @note added in 2.10
*/
class GUI_EXPORT QgsDataDefinedAssistant: public QDialog
{
Q_OBJECT
public:
QgsDataDefinedAssistant() : mMapCanvas( nullptr ) {}
virtual QgsDataDefined dataDefined() const = 0;
/** Sets the map canvas associated with the widget. This allows the widget to retrieve the current
* map scale and other properties from the canvas.
* @param canvas map canvas
* @see mapCanvas()
* @note added in QGIS 2.12
*/
virtual void setMapCanvas( QgsMapCanvas* canvas ) { mMapCanvas = canvas; }
/** Returns the map canvas associated with the widget.
* @see setMapCanvas
* @note added in QGIS 2.12
*/
const QgsMapCanvas* mapCanvas() const { return mMapCanvas; }
protected:
QgsMapCanvas* mMapCanvas;
};
/** \ingroup gui
* \class QgsDataDefinedButton
* A button for defining data source field mappings or expressions.
*/
class GUI_EXPORT QgsDataDefinedButton: public QToolButton
{
Q_OBJECT
Q_PROPERTY( QString usageInfo READ usageInfo WRITE setUsageInfo )
public:
enum DataType
{
String = 1,
Int = 2,
Double = 4,
AnyType = String | Int | Double
};
Q_DECLARE_FLAGS( DataTypes, DataType )
/**
* Construct a new data defined button
*
* @param parent The parent QWidget
* @param vl Pointer to the associated vector layer
* @param datadefined Data defined property
* @param datatypes The expected data types to be compared against the variant type of the QgsField from data source and expression result
* @param description The description of expected input data
*/
QgsDataDefinedButton( QWidget* parent = nullptr,
const QgsVectorLayer* vl = nullptr,
const QgsDataDefined* datadefined = nullptr,
const QgsDataDefinedButton::DataTypes& datatypes = AnyType,
const QString& description = QString() );
~QgsDataDefinedButton();
/**
* Initialize a newly constructed data defined button (useful if button already included from form layout)
*
* @param vl Pointer to the associated vector layer
* @param datadefined Data defined property
* @param datatypes The expected data types to be compared against the variant type of the QgsField from data source and expression result
* @param description The description of expected input data
*/
void init( const QgsVectorLayer* vl,
const QgsDataDefined* datadefined = nullptr,
const QgsDataDefinedButton::DataTypes& datatypes = AnyType,
const QString& description = QString() );
QMap< QString, QString > definedProperty() const { return mProperty; }
/** Updates a QgsDataDefined with the current settings from the button
* @param dd QgsDataDefined to update
* @note added in QGIS 2.9
* @see currentDataDefined
*/
void updateDataDefined( QgsDataDefined* dd ) const;
/** Returns a QgsDataDefined which reflects the current settings from the
* button.
* @note added in QGIS 2.9
* @see updateDataDefined
*/
QgsDataDefined currentDataDefined() const;
/**
* Whether the current data definition or expression is to be used
*/
bool isActive() const { return mProperty.value( "active" ).toInt(); }
/**
* Whether the current expression is to be used instead of field mapping
*/
bool useExpression() const { return mProperty.value( "useexpr" ).toInt(); }
/**
* The current defined expression
*/
QString getExpression() const { return mProperty.value( "expression" ); }
/**
* The current defined field
*/
QString getField() const { return mProperty.value( "field" ); }
/**
* The current definition
* @returns empty QString if not active, otherwise currently defined expression or field name
*/
QString currentDefinition() const { return mCurrentDefinition; }
/**
* The valid data types that will work for the definition (QVariant-coercible to expected type)
* Compared against the variant type of the QgsField from data source and expression result
*/
const DataTypes& validDataTypes() const { return mDataTypes; }
/**
* The full definition description and current definition (internally generated on a contextual basis)
*/
QString fullDescription() const { return mFullDescription; }
/**
* The usage information about this data definition
*/
QString usageInfo() const { return mUsageInfo; }
/**
* Set the usage information about this data definition
*/
void setUsageInfo( const QString& info ) { mUsageInfo = info; updateGui(); }
/**
* Register list of sibling widgets that get disabled/enabled when data definition or expression is set/unset
*/
void registerEnabledWidgets( const QList<QWidget*>& wdgts );
/**
* Register a sibling widget that gets disabled/enabled when data definition or expression is set/unset
*/
void registerEnabledWidget( QWidget* wdgt );
/**
* Return widget siblings that get disabled/enabled when data definition or expression is set/unset
*
* @return unguarded pointers from guarded ones
*/
QList<QWidget*> registeredEnabledWidgets();
/**
* Clears list of sibling widgets
*/
void clearEnabledWidgets() { mEnabledWidgets.clear(); }
/**
* Register list of sibling widgets that get checked when data definition or expression is active
*/
void registerCheckedWidgets( const QList<QWidget*>& wdgts );
/**
* Register a sibling widget that get checked when data definition or expression is active
*/
void registerCheckedWidget( QWidget* wdgt );
/**
* Return widget siblings that get checked when data definition or expression is active
*
* @return unguarded pointers from guarded ones
*/
QList<QWidget*> registeredCheckedWidgets();
/**
* Clears list of checkable sibling widgets
*/
void clearCheckedWidgets() { mCheckedWidgets.clear(); }
//! Callback function for retrieving the expression context for the button
typedef QgsExpressionContext( *ExpressionContextCallback )( const void* context );
/** Register callback function for retrieving the expression context for the button
* @param fnGetExpressionContext call back function, will be called when the data defined
* button requires the current expression context
* @param context context for callback function
* @note added in QGIS 2.12
* @note not available in Python bindings
*/
void registerGetExpressionContextCallback( ExpressionContextCallback fnGetExpressionContext, const void* context );
/**
* Sets an assistant used to define the data defined object properties.
* Ownership of the assistant is transferred to the widget.
* @param title menu title for the assistant
* @param assistant data defined assistant. Set to null to remove the assistant
* option from the button.
* @note added in 2.10
* @see assistant()
*/
void setAssistant( const QString& title, QgsDataDefinedAssistant * assistant );
/** Returns the assistant used to defined the data defined object properties, if set.
* @see setAssistant()
* @note added in QGIS 2.12
*/
QgsDataDefinedAssistant* assistant();
/**
* Common descriptions for expected input values
*/
static QString trString();
static QString charDesc();
static QString boolDesc();
static QString anyStringDesc();
static QString intDesc();
static QString intPosDesc();
static QString intPosOneDesc();
static QString doubleDesc();
static QString doublePosDesc();
static QString double0to1Desc();
static QString doubleXYDesc();
static QString double180RotDesc();
static QString intTranspDesc();
static QString unitsMmMuDesc();
static QString unitsMmMuPercentDesc();
static QString colorNoAlphaDesc();
static QString colorAlphaDesc();
static QString textHorzAlignDesc();
static QString textVertAlignDesc();
static QString penJoinStyleDesc();
static QString blendModesDesc();
static QString svgPathDesc();
static QString filePathDesc();
static QString paperSizeDesc();
static QString paperOrientationDesc();
static QString horizontalAnchorDesc();
static QString verticalAnchorDesc();
static QString gradientTypeDesc();
static QString gradientCoordModeDesc();
static QString gradientSpreadDesc();
static QString lineStyleDesc();
static QString capStyleDesc();
static QString fillStyleDesc();
static QString markerStyleDesc();
static QString customDashDesc();
public slots:
/**
* Set whether the current data definition or expression is to be used
*/
void setActive( bool active );
/**
* Set siblings' enabled property when data definition or expression is set/unset
*/
void disableEnabledWidgets( bool disable );
/**
* Set siblings' checked property when data definition or expression is active
*/
void checkCheckedWidgets( bool check );
signals:
/**
* Emitted when data definition or expression is changed
* @param definition The current definition or expression (empty string if inactive)
*/
void dataDefinedChanged( const QString& definition );
/**
* Emitted when active state changed
* @param active Whether the definition is active
*/
void dataDefinedActivated( bool active );
protected:
void mouseReleaseEvent( QMouseEvent *event ) override;
/**
* Set whether the current expression is to be used instead of field mapping
*/
void setUseExpression( bool use ) { mProperty.insert( "useexpr", use ? "1" : "0" ); }
/**
* Set the current defined expression
*/
void setExpression( const QString& exp ) { mProperty.insert( "expression", exp ); }
/**
* Set the current defined field
*/
void setField( const QString& field ) { mProperty.insert( "field", field ); }
private:
void showDescriptionDialog();
void showExpressionDialog();
void showAssistant();
void updateGui();
void updateFieldLists();
const QgsVectorLayer* mVectorLayer;
QStringList mFieldNameList;
QStringList mFieldTypeList;
QMap< QString, QString > mProperty;
QList< QPointer<QWidget> > mEnabledWidgets;
QList< QPointer<QWidget> > mCheckedWidgets;
QMenu* mDefineMenu;
QAction* mActionDataTypes;
QMenu* mFieldsMenu;
QMenu* mVariablesMenu;
QAction* mActionVariables;
QAction* mActionActive;
QAction* mActionDescription;
QAction* mActionExpDialog;
QAction* mActionExpression;
QAction* mActionPasteExpr;
QAction* mActionCopyExpr;
QAction* mActionClearExpr;
QAction* mActionAssistant;
DataTypes mDataTypes;
QString mDataTypesString;
QString mInputDescription;
QString mFullDescription;
QString mUsageInfo;
QString mCurrentDefinition;
QScopedPointer<QgsDataDefinedAssistant> mAssistant;
QIcon mIconDataDefine;
QIcon mIconDataDefineOn;
QIcon mIconDataDefineError;
QIcon mIconDataDefineExpression;
QIcon mIconDataDefineExpressionOn;
QIcon mIconDataDefineExpressionError;
ExpressionContextCallback mExpressionContextCallback;
const void* mExpressionContextCallbackContext;
private slots:
void aboutToShowMenu();
void menuActionTriggered( QAction* action );
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsDataDefinedButton::DataTypes )
#endif // QGSDATADEFINEDBUTTON_H
|