more flag operators declaration in SIP, better use of flags in data defined button

This commit is contained in:
Denis Rouzaud 2014-09-01 10:51:06 +02:00
parent 8a65115100
commit 5b1a516f2e
5 changed files with 12 additions and 6 deletions

View File

@ -6,10 +6,10 @@ class QgsDataDefinedButton : QToolButton
public: public:
enum DataType enum DataType
{ {
AnyType,
String, String,
Int, Int,
Double, Double,
AnyType
}; };
typedef QFlags<QgsDataDefinedButton::DataType> DataTypes; typedef QFlags<QgsDataDefinedButton::DataType> DataTypes;
@ -207,3 +207,5 @@ class QgsDataDefinedButton : QToolButton
void setField( QString field ); void setField( QString field );
}; };
QFlags<QgsDataDefinedButton::DataType> operator|(QgsDataDefinedButton::DataType f1, QFlags<QgsDataDefinedButton::DataType> f2);

View File

@ -45,3 +45,5 @@ class QgsFieldProxyModel : QSortFilterProxyModel
bool lessThan( const QModelIndex &left, const QModelIndex &right ) const; bool lessThan( const QModelIndex &left, const QModelIndex &right ) const;
}; };
QFlags<QgsFieldProxyModel::Filter> operator|(QgsFieldProxyModel::Filter f1, QFlags<QgsFieldProxyModel::Filter> f2);

View File

@ -45,6 +45,8 @@ class QgsMapLayerAction : QAction
}; };
QFlags<QgsMapLayerAction::Target> operator|(QgsMapLayerAction::Target f1, QFlags<QgsMapLayerAction::Target> f2);
class QgsMapLayerActionRegistry : QObject class QgsMapLayerActionRegistry : QObject
{ {
%TypeHeaderCode %TypeHeaderCode

View File

@ -131,15 +131,15 @@ void QgsDataDefinedButton::init( const QgsVectorLayer* vl,
mDataTypesString = QString( "" ); mDataTypesString = QString( "" );
QStringList ts; QStringList ts;
if ( mDataTypes.testFlag( AnyType ) || mDataTypes.testFlag( String ) ) if ( mDataTypes.testFlag( String ) )
{ {
ts << tr( "string" ); ts << tr( "string" );
} }
if ( mDataTypes.testFlag( AnyType ) || mDataTypes.testFlag( Int ) ) if ( mDataTypes.testFlag( Int ) )
{ {
ts << tr( "int" ); ts << tr( "int" );
} }
if ( mDataTypes.testFlag( AnyType ) || mDataTypes.testFlag( Double ) ) if ( mDataTypes.testFlag( Double ) )
{ {
ts << tr( "double" ); ts << tr( "double" );
} }

View File

@ -39,10 +39,10 @@ class GUI_EXPORT QgsDataDefinedButton: public QToolButton
public: public:
enum DataType enum DataType
{ {
AnyType = 0,
String = 1, String = 1,
Int = 2, Int = 2,
Double = 4 Double = 4,
AnyType = String | Int | Double
}; };
Q_DECLARE_FLAGS( DataTypes, DataType ) Q_DECLARE_FLAGS( DataTypes, DataType )