mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
custom widgets: added color and data defined buttons, missing SIP for scale range and fix flags for field combo / expression widget
This commit is contained in:
parent
74392f7823
commit
aa7085194d
@ -75,6 +75,7 @@
|
||||
%Include qgsrasterpyramidsoptionswidget.sip
|
||||
%Include qgsrubberband.sip
|
||||
%Include qgsscalecombobox.sip
|
||||
%Include qgsscalerangewidget.sip
|
||||
%Include qgssearchquerybuilder.sip
|
||||
%Include qgstextannotationitem.sip
|
||||
%Include qgsvertexmarker.sip
|
||||
|
40
python/gui/qgsscalerangewidget.sip
Normal file
40
python/gui/qgsscalerangewidget.sip
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
class QgsScaleRangeWidget : QWidget
|
||||
{
|
||||
%TypeHeaderCode
|
||||
#include "qgsscalerangewidget.h"
|
||||
%End
|
||||
|
||||
public:
|
||||
explicit QgsScaleRangeWidget( QWidget *parent /TransferThis/ = 0 );
|
||||
~QgsScaleRangeWidget();
|
||||
|
||||
//! set the map canvas which will be used for the current scale buttons
|
||||
/**
|
||||
* @brief setMapCanvas set the map canvas which will be used for the current scale buttons
|
||||
* if not set, the buttons are hidden.
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas* mapCanvas );
|
||||
|
||||
//! return the minimum scale
|
||||
double minimumScale();
|
||||
|
||||
//! return the maximum scale
|
||||
double maximumScale();
|
||||
|
||||
//! return the minimum scale denominator ( = 1 / maximum scale )
|
||||
double minimumScaleDenom();
|
||||
|
||||
//! return the maximum scale denominator ( = 1 / minimum scale )
|
||||
double maximumScaleDenom();
|
||||
|
||||
//! call to reload the project scales and apply them to the 2 scales combo boxes
|
||||
void reloadProjectScales();
|
||||
|
||||
public slots:
|
||||
void setMinimumScale( double scale );
|
||||
|
||||
void setMaximumScale( double scale );
|
||||
|
||||
void setScaleRange( double min, double max );
|
||||
};
|
@ -9,6 +9,8 @@ ADD_DEFINITIONS(-DQT_SHARED)
|
||||
SET (QGIS_CUSTOMWIDGETS_SRCS
|
||||
qgiscustomwidgets.cpp
|
||||
qgscollapsiblegroupboxplugin.cpp
|
||||
qgscolorbuttonplugin.cpp
|
||||
qgsdatadefinedbuttonplugin.cpp
|
||||
qgsfieldcomboboxplugin.cpp
|
||||
qgsfieldexpressionwidgetplugin.cpp
|
||||
qgsmaplayercomboboxplugin.cpp
|
||||
@ -18,6 +20,8 @@ SET (QGIS_CUSTOMWIDGETS_SRCS
|
||||
SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
|
||||
qgiscustomwidgets.h
|
||||
qgscollapsiblegroupboxplugin.h
|
||||
qgscolorbuttonplugin.h
|
||||
qgsdatadefinedbuttonplugin.h
|
||||
qgsfieldcomboboxplugin.h
|
||||
qgsfieldexpressionwidgetplugin.h
|
||||
qgsmaplayercomboboxplugin.h
|
||||
@ -33,6 +37,8 @@ ENDIF(UNIX)
|
||||
SET(QGIS_CUSTOMWIDGETS_HDRS
|
||||
qgiscustomwidgets.h
|
||||
qgscollapsiblegroupboxplugin.h
|
||||
qgscolorbuttonplugin.h
|
||||
qgsdatadefinedbuttonplugin.h
|
||||
qgsfieldcomboboxplugin.h
|
||||
qgsfieldexpressionwidgetplugin.h
|
||||
qgsmaplayercomboboxplugin.h
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "qgiscustomwidgets.h"
|
||||
|
||||
#include "qgscollapsiblegroupboxplugin.h"
|
||||
#include "qgscolorbuttonplugin.h"
|
||||
#include "qgsdatadefinedbuttonplugin.h"
|
||||
#include "qgsfieldcomboboxplugin.h"
|
||||
#include "qgsfieldexpressionwidgetplugin.h"
|
||||
#include "qgsmaplayercomboboxplugin.h"
|
||||
@ -27,13 +29,9 @@
|
||||
QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
|
||||
: QObject( parent )
|
||||
{
|
||||
|
||||
// !!!!!!!!!!!!!!!!!!!!!
|
||||
// do not forget to add the corresponding line in python/customwidgets.py
|
||||
// to make the custom widget available from python
|
||||
// !!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
mWidgets.append( new QgsCollapsibleGroupBoxPlugin );
|
||||
mWidgets.append( new QgsColorButtonPlugin );
|
||||
mWidgets.append( new QgsDataDefinedButtonPlugin );
|
||||
mWidgets.append( new QgsFieldComboBoxPlugin );
|
||||
mWidgets.append( new QgsFieldExpressionWidgetPlugin );
|
||||
mWidgets.append( new QgsMapLayerComboBoxPlugin );
|
||||
|
97
src/customwidgets/qgscolorbuttonplugin.cpp
Normal file
97
src/customwidgets/qgscolorbuttonplugin.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
/***************************************************************************
|
||||
qgscolorbuttonplugin.cpp
|
||||
--------------------------------------
|
||||
Date : 25.04.2014
|
||||
Copyright : (C) 2014 Denis Rouzaud
|
||||
Email : denis.rouzaud@gmail.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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgiscustomwidgets.h"
|
||||
#include "qgscolorbuttonplugin.h"
|
||||
#include "qgscolorbutton.h"
|
||||
|
||||
|
||||
QgsColorButtonPlugin::QgsColorButtonPlugin( QObject *parent )
|
||||
: QObject( parent )
|
||||
, mInitialized( false )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QString QgsColorButtonPlugin::name() const
|
||||
{
|
||||
return "QgsColorButton";
|
||||
}
|
||||
|
||||
QString QgsColorButtonPlugin::group() const
|
||||
{
|
||||
return QgisCustomWidgets::groupName();
|
||||
}
|
||||
|
||||
QString QgsColorButtonPlugin::includeFile() const
|
||||
{
|
||||
return "qgscolorbutton.h";
|
||||
}
|
||||
|
||||
QIcon QgsColorButtonPlugin::icon() const
|
||||
{
|
||||
return QIcon();
|
||||
}
|
||||
|
||||
bool QgsColorButtonPlugin::isContainer() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QWidget *QgsColorButtonPlugin::createWidget( QWidget *parent )
|
||||
{
|
||||
return new QgsColorButton( parent );
|
||||
}
|
||||
|
||||
bool QgsColorButtonPlugin::isInitialized() const
|
||||
{
|
||||
return mInitialized;
|
||||
}
|
||||
|
||||
void QgsColorButtonPlugin::initialize( QDesignerFormEditorInterface *core )
|
||||
{
|
||||
Q_UNUSED( core );
|
||||
if ( mInitialized )
|
||||
return;
|
||||
mInitialized = true;
|
||||
}
|
||||
|
||||
|
||||
QString QgsColorButtonPlugin::toolTip() const
|
||||
{
|
||||
return "A widget to define the scale range";
|
||||
}
|
||||
|
||||
QString QgsColorButtonPlugin::whatsThis() const
|
||||
{
|
||||
return "A widget to define the scale range.";
|
||||
}
|
||||
|
||||
QString QgsColorButtonPlugin::domXml() const
|
||||
{
|
||||
return QString( "<ui language=\"c++\">\n"
|
||||
" <widget class=\"%1\" name=\"mColorButton\">\n"
|
||||
" <property name=\"geometry\">\n"
|
||||
" <rect>\n"
|
||||
" <x>0</x>\n"
|
||||
" <y>0</y>\n"
|
||||
" <width>27</width>\n"
|
||||
" <height>27</height>\n"
|
||||
" </rect>\n"
|
||||
" </property>\n"
|
||||
" </widget>\n"
|
||||
"</ui>\n" )
|
||||
.arg( name() );
|
||||
}
|
48
src/customwidgets/qgscolorbuttonplugin.h
Normal file
48
src/customwidgets/qgscolorbuttonplugin.h
Normal file
@ -0,0 +1,48 @@
|
||||
/***************************************************************************
|
||||
qgscolorbuttonplugin.h
|
||||
--------------------------------------
|
||||
Date : 25.04.2014
|
||||
Copyright : (C) 2014 Denis Rouzaud
|
||||
Email : denis.rouzaud@gmail.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 QGSCOLORBUTTONPLUGIN_H
|
||||
#define QGSCOLORBUTTONPLUGIN_H
|
||||
|
||||
#include <QDesignerExportWidget>
|
||||
#include <QDesignerCustomWidgetInterface>
|
||||
|
||||
|
||||
class QDESIGNER_WIDGET_EXPORT QgsColorButtonPlugin : public QObject, public QDesignerCustomWidgetInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES( QDesignerCustomWidgetInterface )
|
||||
|
||||
public:
|
||||
explicit QgsColorButtonPlugin( QObject *parent = 0 );
|
||||
|
||||
private:
|
||||
bool mInitialized;
|
||||
|
||||
// QDesignerCustomWidgetInterface interface
|
||||
public:
|
||||
QString name() const;
|
||||
QString group() const;
|
||||
QString includeFile() const;
|
||||
QIcon icon() const;
|
||||
bool isContainer() const;
|
||||
QWidget *createWidget( QWidget *parent );
|
||||
bool isInitialized() const;
|
||||
void initialize( QDesignerFormEditorInterface *core );
|
||||
QString toolTip() const;
|
||||
QString whatsThis() const;
|
||||
QString domXml() const;
|
||||
};
|
||||
#endif // QGSCOLORBUTTONPLUGIN_H
|
97
src/customwidgets/qgsdatadefinedbuttonplugin.cpp
Normal file
97
src/customwidgets/qgsdatadefinedbuttonplugin.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
/***************************************************************************
|
||||
qgsdatadefinedbuttonplugin.cpp
|
||||
--------------------------------------
|
||||
Date : 25.04.2014
|
||||
Copyright : (C) 2014 Denis Rouzaud
|
||||
Email : denis.rouzaud@gmail.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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgiscustomwidgets.h"
|
||||
#include "qgsdatadefinedbuttonplugin.h"
|
||||
#include "qgsdatadefinedbutton.h"
|
||||
|
||||
|
||||
QgsDataDefinedButtonPlugin::QgsDataDefinedButtonPlugin( QObject *parent )
|
||||
: QObject( parent )
|
||||
, mInitialized( false )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QString QgsDataDefinedButtonPlugin::name() const
|
||||
{
|
||||
return "QgsDataDefinedButton";
|
||||
}
|
||||
|
||||
QString QgsDataDefinedButtonPlugin::group() const
|
||||
{
|
||||
return QgisCustomWidgets::groupName();
|
||||
}
|
||||
|
||||
QString QgsDataDefinedButtonPlugin::includeFile() const
|
||||
{
|
||||
return "qgsdatadefinedbutton.h";
|
||||
}
|
||||
|
||||
QIcon QgsDataDefinedButtonPlugin::icon() const
|
||||
{
|
||||
return QIcon();
|
||||
}
|
||||
|
||||
bool QgsDataDefinedButtonPlugin::isContainer() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QWidget *QgsDataDefinedButtonPlugin::createWidget( QWidget *parent )
|
||||
{
|
||||
return new QgsDataDefinedButton( parent );
|
||||
}
|
||||
|
||||
bool QgsDataDefinedButtonPlugin::isInitialized() const
|
||||
{
|
||||
return mInitialized;
|
||||
}
|
||||
|
||||
void QgsDataDefinedButtonPlugin::initialize( QDesignerFormEditorInterface *core )
|
||||
{
|
||||
Q_UNUSED( core );
|
||||
if ( mInitialized )
|
||||
return;
|
||||
mInitialized = true;
|
||||
}
|
||||
|
||||
|
||||
QString QgsDataDefinedButtonPlugin::toolTip() const
|
||||
{
|
||||
return "A widget to define the scale range";
|
||||
}
|
||||
|
||||
QString QgsDataDefinedButtonPlugin::whatsThis() const
|
||||
{
|
||||
return "A widget to define the scale range.";
|
||||
}
|
||||
|
||||
QString QgsDataDefinedButtonPlugin::domXml() const
|
||||
{
|
||||
return QString( "<ui language=\"c++\">\n"
|
||||
" <widget class=\"%1\" name=\"mDataDefinedButton\">\n"
|
||||
" <property name=\"geometry\">\n"
|
||||
" <rect>\n"
|
||||
" <x>0</x>\n"
|
||||
" <y>0</y>\n"
|
||||
" <width>27</width>\n"
|
||||
" <height>27</height>\n"
|
||||
" </rect>\n"
|
||||
" </property>\n"
|
||||
" </widget>\n"
|
||||
"</ui>\n" )
|
||||
.arg( name() );
|
||||
}
|
48
src/customwidgets/qgsdatadefinedbuttonplugin.h
Normal file
48
src/customwidgets/qgsdatadefinedbuttonplugin.h
Normal file
@ -0,0 +1,48 @@
|
||||
/***************************************************************************
|
||||
qgsdatadefinedbuttonplugin.h
|
||||
--------------------------------------
|
||||
Date : 25.04.2014
|
||||
Copyright : (C) 2014 Denis Rouzaud
|
||||
Email : denis.rouzaud@gmail.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 QGSDATADEFINEDBUTTONPLUGIN_H
|
||||
#define QGSDATADEFINEDBUTTONPLUGIN_H
|
||||
|
||||
#include <QDesignerExportWidget>
|
||||
#include <QDesignerCustomWidgetInterface>
|
||||
|
||||
|
||||
class QDESIGNER_WIDGET_EXPORT QgsDataDefinedButtonPlugin : public QObject, public QDesignerCustomWidgetInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES( QDesignerCustomWidgetInterface )
|
||||
|
||||
public:
|
||||
explicit QgsDataDefinedButtonPlugin( QObject *parent = 0 );
|
||||
|
||||
private:
|
||||
bool mInitialized;
|
||||
|
||||
// QDesignerCustomWidgetInterface interface
|
||||
public:
|
||||
QString name() const;
|
||||
QString group() const;
|
||||
QString includeFile() const;
|
||||
QIcon icon() const;
|
||||
bool isContainer() const;
|
||||
QWidget *createWidget( QWidget *parent );
|
||||
bool isInitialized() const;
|
||||
void initialize( QDesignerFormEditorInterface *core );
|
||||
QString toolTip() const;
|
||||
QString whatsThis() const;
|
||||
QString domXml() const;
|
||||
};
|
||||
#endif // QGSDATADEFINEDBUTTONPLUGIN_H
|
@ -30,6 +30,11 @@
|
||||
class GUI_EXPORT QgsColorButton: public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( QString colorDialogTitle READ colorDialogTitle WRITE setColorDialogTitle )
|
||||
Q_PROPERTY( bool acceptLiveUpdates READ acceptLiveUpdates WRITE setAcceptLiveUpdates )
|
||||
Q_PROPERTY( QColor color READ color WRITE setColor )
|
||||
Q_FLAGS( QColorDialog::ColorDialogOptions )
|
||||
Q_PROPERTY( QColorDialog::ColorDialogOptions colorDialogOptions READ colorDialogOptions WRITE setColorDialogOptions )
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -34,6 +34,7 @@ class QgsVectorLayer;
|
||||
class GUI_EXPORT QgsDataDefinedButton: public QToolButton
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( QString usageInfo READ usageInfo WRITE setUsageInfo )
|
||||
|
||||
public:
|
||||
enum DataType
|
||||
|
@ -33,6 +33,7 @@ class QgsVectorLayer;
|
||||
class GUI_EXPORT QgsFieldComboBox : public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_FLAGS( QgsFieldProxyModel::Filters )
|
||||
Q_PROPERTY( QgsFieldProxyModel::Filters filters READ filters WRITE setFilters )
|
||||
|
||||
public:
|
||||
|
@ -41,6 +41,7 @@ class GUI_EXPORT QgsFieldExpressionWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( QString expressionDialogTitle READ expressionDialogTitle WRITE setExpressionDialogTitle )
|
||||
Q_FLAGS( QgsFieldProxyModel::Filters )
|
||||
Q_PROPERTY( QgsFieldProxyModel::Filters filters READ filters WRITE setFilters )
|
||||
|
||||
public:
|
||||
|
@ -27,6 +27,8 @@
|
||||
class GUI_EXPORT QgsFieldProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_FLAGS( Filters )
|
||||
|
||||
public:
|
||||
enum Filter
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user