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
|
class QgsDataDefinedButton : QToolButton
{
%TypeHeaderCode
#include <qgsdatadefinedbutton.h>
%End
public:
enum DataType
{
AnyType,
String,
Int,
Double,
};
typedef QFlags<QgsDataDefinedButton::DataType> DataTypes;
/**
* 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 = 0,
const QgsVectorLayer* vl = 0,
const QgsDataDefined* datadefined = 0,
DataTypes datatypes = AnyType,
QString description = "" );
~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 = 0,
DataTypes datatypes = AnyType,
QString description = QString( "" ) );
QMap< QString, QString > definedProperty() const;
/**
* Whether the current data definition or expression is to be used
*/
bool isActive();
/**
* Whether the current expression is to be used instead of field mapping
*/
bool useExpression();
/**
* The current defined expression
*/
QString getExpression() const;
/**
* The current defined field
*/
QString getField() const;
/**
* The current definition
* @returns empty QString if not active, otherwise currently defined expression or field name
*/
QString currentDefinition() const;
/**
* 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;
/**
* The full definition description and current definition (internally generated on a contextual basis)
*/
QString fullDescription() const;
/**
* The usage information about this data definition
*/
QString usageInfo() const;
/**
* Set the usage information about this data definition
*/
void setUsageInfo( const QString& info );
/**
* Register list of sibling widgets that get disabled/enabled when data definition or expression is set/unset
*/
void registerEnabledWidgets( 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();
/**
* Register list of sibling widgets that get checked when data definition or expression is active
*/
void registerCheckedWidgets( 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();
/**
* Common descriptions for expected input values
*/
static QString trString();
static QString boolDesc();
static QString anyStringDesc();
static QString intDesc();
static QString intPosDesc();
static QString intPosOneDesc();
static QString doubleDesc();
static QString doublePosDesc();
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();
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 );
/**
* Set whether the current expression is to be used instead of field mapping
*/
void setUseExpression( bool use );
/**
* Set the current defined expression
*/
void setExpression( QString exp );
/**
* Set the current defined field
*/
void setField( QString field );
};
|