| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| ADD_DEFINITIONS(-DQT_PLUGIN) | ||
| ADD_DEFINITIONS(-DQT_NO_DEBUG) | ||
| ADD_DEFINITIONS(-DQT_SHARED) | ||
|
|
||
|
|
||
| ######################################################## | ||
| # Files | ||
|
|
||
| SET (QGIS_CUSTOMWIDGETS_SRCS | ||
| qgiscustomwidgets.cpp | ||
| qgscollapsiblegroupboxplugin.cpp | ||
| qgsfieldcomboboxplugin.cpp | ||
| qgsfieldexpressionwidgetplugin.cpp | ||
| qgsmaplayercomboboxplugin.cpp | ||
| qgsscalerangewidgetplugin.cpp | ||
| ) | ||
|
|
||
| SET (QGIS_CUSTOMWIDGETS_MOC_HDRS | ||
| qgiscustomwidgets.h | ||
| qgscollapsiblegroupboxplugin.h | ||
| qgsfieldcomboboxplugin.h | ||
| qgsfieldexpressionwidgetplugin.h | ||
| qgsmaplayercomboboxplugin.h | ||
| qgsscalerangewidgetplugin.h | ||
| ) | ||
|
|
||
| QT4_WRAP_CPP(QGIS_CUSTOMWIDGETS_MOC_SRCS ${QGIS_CUSTOMWIDGETS_MOC_HDRS}) | ||
|
|
||
| IF(UNIX) | ||
| SET_SOURCE_FILES_PROPERTIES(${QGIS_CUSTOMWIDGETS_MOC_SRCS} PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations" ) | ||
| ENDIF(UNIX) | ||
|
|
||
| SET(QGIS_CUSTOMWIDGETS_HDRS | ||
| qgiscustomwidgets.h | ||
| qgscollapsiblegroupboxplugin.h | ||
| qgsfieldcomboboxplugin.h | ||
| qgsfieldexpressionwidgetplugin.h | ||
| qgsmaplayercomboboxplugin.h | ||
| qgsscalerangewidgetplugin.h | ||
| ) | ||
|
|
||
| # left commented as there is no UI file yet | ||
| # SET(QGIS_CUSTOMWIDGETS_UI_HDRS | ||
| # ${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsXXXwidget.h | ||
| # ) | ||
|
|
||
| INCLUDE_DIRECTORIES( | ||
| ${CMAKE_CURRENT_SOURCE_DIR} | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/../core/ | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/../gui/ | ||
| # ${CMAKE_CURRENT_BINARY_DIR}/../ui (no UI file yet) | ||
| ) | ||
|
|
||
| ############################################################# | ||
| # qgis_customwidgets library | ||
|
|
||
| ADD_LIBRARY(qgis_customwidgets SHARED ${QGIS_CUSTOMWIDGETS_SRCS} ${QGIS_CUSTOMWIDGETS_MOC_SRCS} ${QGIS_CUSTOMWIDGETS_HDRS}) | ||
|
|
||
| # TODO: apple | ||
| INSTALL(FILES ${QGIS_CUSTOMWIDGETS_HDRS} DESTINATION ${QGIS_INCLUDE_DIR}) | ||
|
|
||
| SET_TARGET_PROPERTIES(qgis_customwidgets PROPERTIES | ||
| VERSION ${COMPLETE_VERSION} | ||
| SOVERSION ${COMPLETE_VERSION} | ||
| ) | ||
|
|
||
| # make sure that UI files will be processed first | ||
| # left commented as there is no UI file yet | ||
| # ADD_DEPENDENCIES(qgis_customwidgets ui) | ||
|
|
||
| TARGET_LINK_LIBRARIES(qgis_customwidgets qgis_gui) | ||
|
|
||
| # install | ||
| INSTALL(TARGETS qgis_customwidgets | ||
| LIBRARY DESTINATION ${QGIS_CUSTOMWIDGETS_DIR}) | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /*************************************************************************** | ||
| qgscustomwidgets.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 "qplugin.h" | ||
|
|
||
| #include "qgiscustomwidgets.h" | ||
|
|
||
| #include "qgscollapsiblegroupboxplugin.h" | ||
| #include "qgsfieldcomboboxplugin.h" | ||
| #include "qgsfieldexpressionwidgetplugin.h" | ||
| #include "qgsmaplayercomboboxplugin.h" | ||
| #include "qgsscalerangewidgetplugin.h" | ||
|
|
||
|
|
||
| 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 QgsFieldComboBoxPlugin ); | ||
| mWidgets.append( new QgsFieldExpressionWidgetPlugin ); | ||
| mWidgets.append( new QgsMapLayerComboBoxPlugin ); | ||
| mWidgets.append( new QgsScaleRangeWidgetPlugin ); | ||
| } | ||
|
|
||
| QList<QDesignerCustomWidgetInterface*> QgisCustomWidgets::customWidgets() const | ||
| { | ||
| return mWidgets; | ||
| } | ||
|
|
||
| Q_EXPORT_PLUGIN2( customwidgetsplugin, QgisCustomWidgets ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /*************************************************************************** | ||
| qgscustomwidgets.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 QGISCUSTOMWIDGETS_H | ||
| #define QGISCUSTOMWIDGETS_H | ||
|
|
||
| #include <QDesignerCustomWidgetCollectionInterface> | ||
| #include <qplugin.h> | ||
|
|
||
| class QgisCustomWidgets : public QObject, public QDesignerCustomWidgetCollectionInterface | ||
| { | ||
| Q_OBJECT | ||
| Q_INTERFACES( QDesignerCustomWidgetCollectionInterface ) | ||
|
|
||
| public: | ||
| explicit QgisCustomWidgets( QObject *parent = 0 ); | ||
|
|
||
| virtual QList<QDesignerCustomWidgetInterface*> customWidgets() const; | ||
|
|
||
| static QString groupName() {return "QGIS custom widgets";} | ||
|
|
||
| private: | ||
| QList<QDesignerCustomWidgetInterface*> mWidgets; | ||
| }; | ||
|
|
||
| #endif // QGISCUSTOMWIDGETS_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /*************************************************************************** | ||
| qgscollapsiblegroupboxplugin.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 "qgscollapsiblegroupbox.h" | ||
| #include "qgscollapsiblegroupboxplugin.h" | ||
|
|
||
|
|
||
| QgsCollapsibleGroupBoxPlugin::QgsCollapsibleGroupBoxPlugin( QObject *parent ) | ||
| : QObject( parent ) | ||
| , mInitialized( false ) | ||
| { | ||
| } | ||
|
|
||
|
|
||
| QString QgsCollapsibleGroupBoxPlugin::name() const | ||
| { | ||
| return "QgsCollapsibleGroupBox"; | ||
| } | ||
|
|
||
| QString QgsCollapsibleGroupBoxPlugin::group() const | ||
| { | ||
| return QgisCustomWidgets::groupName(); | ||
| } | ||
|
|
||
| QString QgsCollapsibleGroupBoxPlugin::includeFile() const | ||
| { | ||
| return "qgscollapsiblegroupbox.h"; | ||
| } | ||
|
|
||
| QIcon QgsCollapsibleGroupBoxPlugin::icon() const | ||
| { | ||
| return QIcon(); | ||
| } | ||
|
|
||
| bool QgsCollapsibleGroupBoxPlugin::isContainer() const | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| QWidget *QgsCollapsibleGroupBoxPlugin::createWidget( QWidget *parent ) | ||
| { | ||
| return new QgsCollapsibleGroupBox( parent ); | ||
| } | ||
|
|
||
| bool QgsCollapsibleGroupBoxPlugin::isInitialized() const | ||
| { | ||
| return mInitialized; | ||
| } | ||
|
|
||
| void QgsCollapsibleGroupBoxPlugin::initialize( QDesignerFormEditorInterface *core ) | ||
| { | ||
| Q_UNUSED( core ); | ||
| if ( mInitialized ) | ||
| return; | ||
| mInitialized = true; | ||
| } | ||
|
|
||
|
|
||
| QString QgsCollapsibleGroupBoxPlugin::toolTip() const | ||
| { | ||
| return "A collapsible group box"; | ||
| } | ||
|
|
||
| QString QgsCollapsibleGroupBoxPlugin::whatsThis() const | ||
| { | ||
| return "A collapsible group box with save state capability"; | ||
| } | ||
|
|
||
| QString QgsCollapsibleGroupBoxPlugin::domXml() const | ||
| { | ||
| return QString( "<ui language=\"c++\">\n" | ||
| " <widget class=\"%1\" name=\"mGroupBox\">\n" | ||
| " <property name=\"geometry\">\n" | ||
| " <rect>\n" | ||
| " <x>0</x>\n" | ||
| " <y>0</y>\n" | ||
| " <width>300</width>\n" | ||
| " <height>100</height>\n" | ||
| " </rect>\n" | ||
| " </property>\n" | ||
| " </widget>\n" | ||
| "</ui>\n" ) | ||
| .arg( name() ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /*************************************************************************** | ||
| qgscollapsiblegroupboxplugin.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 QGSCOLLAPSIBLEGROUPBOXPLUGIN_H | ||
| #define QGSCOLLAPSIBLEGROUPBOXPLUGIN_H | ||
|
|
||
| #include <QDesignerExportWidget> | ||
| #include <QDesignerCustomWidgetInterface> | ||
|
|
||
|
|
||
| class QDESIGNER_WIDGET_EXPORT QgsCollapsibleGroupBoxPlugin : public QObject, public QDesignerCustomWidgetInterface | ||
| { | ||
| Q_OBJECT | ||
| Q_INTERFACES( QDesignerCustomWidgetInterface ) | ||
|
|
||
| public: | ||
| explicit QgsCollapsibleGroupBoxPlugin( 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 // QGSCOLLAPSIBLEGROUPBOXPLUGIN_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /*************************************************************************** | ||
| qgsfieldcomboboxplugin.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 "qgsfieldcombobox.h" | ||
| #include "qgsfieldcomboboxplugin.h" | ||
|
|
||
|
|
||
| QgsFieldComboBoxPlugin::QgsFieldComboBoxPlugin( QObject *parent ) | ||
| : QObject( parent ) | ||
| , mInitialized( false ) | ||
| { | ||
| } | ||
|
|
||
|
|
||
| QString QgsFieldComboBoxPlugin::name() const | ||
| { | ||
| return "QgsFieldComboBox"; | ||
| } | ||
|
|
||
| QString QgsFieldComboBoxPlugin::group() const | ||
| { | ||
| return QgisCustomWidgets::groupName(); | ||
| } | ||
|
|
||
| QString QgsFieldComboBoxPlugin::includeFile() const | ||
| { | ||
| return "qgsfieldcombobox.h"; | ||
| } | ||
|
|
||
| QIcon QgsFieldComboBoxPlugin::icon() const | ||
| { | ||
| return QIcon(); | ||
| } | ||
|
|
||
| bool QgsFieldComboBoxPlugin::isContainer() const | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| QWidget *QgsFieldComboBoxPlugin::createWidget( QWidget *parent ) | ||
| { | ||
| return new QgsFieldComboBox( parent ); | ||
| } | ||
|
|
||
| bool QgsFieldComboBoxPlugin::isInitialized() const | ||
| { | ||
| return mInitialized; | ||
| } | ||
|
|
||
| void QgsFieldComboBoxPlugin::initialize( QDesignerFormEditorInterface *core ) | ||
| { | ||
| Q_UNUSED( core ); | ||
| if ( mInitialized ) | ||
| return; | ||
| mInitialized = true; | ||
| } | ||
|
|
||
|
|
||
| QString QgsFieldComboBoxPlugin::toolTip() const | ||
| { | ||
| return "A combo box to list the fields of a layer"; | ||
| } | ||
|
|
||
| QString QgsFieldComboBoxPlugin::whatsThis() const | ||
| { | ||
| return "A combo box to list the field of a layer."; | ||
| } | ||
|
|
||
| QString QgsFieldComboBoxPlugin::domXml() const | ||
| { | ||
| return QString( "<ui language=\"c++\">\n" | ||
| " <widget class=\"%1\" name=\"mFieldComboBox\">\n" | ||
| " <property name=\"geometry\">\n" | ||
| " <rect>\n" | ||
| " <x>0</x>\n" | ||
| " <y>0</y>\n" | ||
| " <width>160</width>\n" | ||
| " <height>27</height>\n" | ||
| " </rect>\n" | ||
| " </property>\n" | ||
| " </widget>\n" | ||
| "</ui>\n" ) | ||
| .arg( name() ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /*************************************************************************** | ||
| qgsfieldcomboboxplugin.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 QGSFIELDCOMBOBOXPLUGIN_H | ||
| #define QGSFIELDCOMBOBOXPLUGIN_H | ||
|
|
||
| #include <QDesignerExportWidget> | ||
| #include <QDesignerCustomWidgetInterface> | ||
|
|
||
|
|
||
| class QDESIGNER_WIDGET_EXPORT QgsFieldComboBoxPlugin : public QObject, public QDesignerCustomWidgetInterface | ||
| { | ||
| Q_OBJECT | ||
| Q_INTERFACES( QDesignerCustomWidgetInterface ) | ||
|
|
||
| public: | ||
| explicit QgsFieldComboBoxPlugin( 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 // QGSFIELDCOMBOBOXPLUGIN_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /*************************************************************************** | ||
| qgsfieldexpressionwidgetplugin.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 "qgsfieldexpressionwidgetplugin.h" | ||
| #include "qgsfieldexpressionwidget.h" | ||
|
|
||
|
|
||
| QgsFieldExpressionWidgetPlugin::QgsFieldExpressionWidgetPlugin( QObject *parent ) | ||
| : QObject( parent ) | ||
| , mInitialized( false ) | ||
| { | ||
| } | ||
|
|
||
|
|
||
| QString QgsFieldExpressionWidgetPlugin::name() const | ||
| { | ||
| return "QgsFieldExpressionWidget"; | ||
| } | ||
|
|
||
| QString QgsFieldExpressionWidgetPlugin::group() const | ||
| { | ||
| return QgisCustomWidgets::groupName(); | ||
| } | ||
|
|
||
| QString QgsFieldExpressionWidgetPlugin::includeFile() const | ||
| { | ||
| return "qgsfieldexpressionwidget.h"; | ||
| } | ||
|
|
||
| QIcon QgsFieldExpressionWidgetPlugin::icon() const | ||
| { | ||
| return QIcon(); | ||
| } | ||
|
|
||
| bool QgsFieldExpressionWidgetPlugin::isContainer() const | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| QWidget *QgsFieldExpressionWidgetPlugin::createWidget( QWidget *parent ) | ||
| { | ||
| return new QgsFieldExpressionWidget( parent ); | ||
| } | ||
|
|
||
| bool QgsFieldExpressionWidgetPlugin::isInitialized() const | ||
| { | ||
| return mInitialized; | ||
| } | ||
|
|
||
| void QgsFieldExpressionWidgetPlugin::initialize( QDesignerFormEditorInterface *core ) | ||
| { | ||
| Q_UNUSED( core ); | ||
| if ( mInitialized ) | ||
| return; | ||
| mInitialized = true; | ||
| } | ||
|
|
||
|
|
||
| QString QgsFieldExpressionWidgetPlugin::toolTip() const | ||
| { | ||
| return "An editable combo box to enter an expression"; | ||
| } | ||
|
|
||
| QString QgsFieldExpressionWidgetPlugin::whatsThis() const | ||
| { | ||
| return "An editable combo box to enter an expression. A button allows opening the expression dialog. Expression are evaluated to detect errors."; | ||
| } | ||
|
|
||
| QString QgsFieldExpressionWidgetPlugin::domXml() const | ||
| { | ||
| return QString( "<ui language=\"c++\">\n" | ||
| " <widget class=\"%1\" name=\"mFieldExpressionWidget\">\n" | ||
| " <property name=\"geometry\">\n" | ||
| " <rect>\n" | ||
| " <x>0</x>\n" | ||
| " <y>0</y>\n" | ||
| " <width>200</width>\n" | ||
| " <height>27</height>\n" | ||
| " </rect>\n" | ||
| " </property>\n" | ||
| " </widget>\n" | ||
| "</ui>\n" ) | ||
| .arg( name() ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /*************************************************************************** | ||
| qgsfieldexpressionwidgetplugin.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 QGSFIELDEXPRESSIONWIDGETPLUGIN_H | ||
| #define QGSFIELDEXPRESSIONWIDGETPLUGIN_H | ||
|
|
||
| #include <QDesignerExportWidget> | ||
| #include <QDesignerCustomWidgetInterface> | ||
|
|
||
|
|
||
| class QDESIGNER_WIDGET_EXPORT QgsFieldExpressionWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface | ||
| { | ||
| Q_OBJECT | ||
| Q_INTERFACES( QDesignerCustomWidgetInterface ) | ||
|
|
||
| public: | ||
| explicit QgsFieldExpressionWidgetPlugin( 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 // QGSFIELDEXPRESSIONWIDGETPLUGIN_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /*************************************************************************** | ||
| qgsmaplayercomboboxplugin.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 "qgsmaplayercombobox.h" | ||
| #include "qgsmaplayercomboboxplugin.h" | ||
|
|
||
|
|
||
| QgsMapLayerComboBoxPlugin::QgsMapLayerComboBoxPlugin( QObject *parent ) | ||
| : QObject( parent ) | ||
| , mInitialized( false ) | ||
| { | ||
| } | ||
|
|
||
|
|
||
| QString QgsMapLayerComboBoxPlugin::name() const | ||
| { | ||
| return "QgsMapLayerComboBox"; | ||
| } | ||
|
|
||
| QString QgsMapLayerComboBoxPlugin::group() const | ||
| { | ||
| return QgisCustomWidgets::groupName(); | ||
| } | ||
|
|
||
| QString QgsMapLayerComboBoxPlugin::includeFile() const | ||
| { | ||
| return "qgsmaplayercombobox.h"; | ||
| } | ||
|
|
||
| QIcon QgsMapLayerComboBoxPlugin::icon() const | ||
| { | ||
| return QIcon(); | ||
| } | ||
|
|
||
| bool QgsMapLayerComboBoxPlugin::isContainer() const | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| QWidget *QgsMapLayerComboBoxPlugin::createWidget( QWidget *parent ) | ||
| { | ||
| return new QgsMapLayerComboBox( parent ); | ||
| } | ||
|
|
||
| bool QgsMapLayerComboBoxPlugin::isInitialized() const | ||
| { | ||
| return mInitialized; | ||
| } | ||
|
|
||
| void QgsMapLayerComboBoxPlugin::initialize( QDesignerFormEditorInterface *core ) | ||
| { | ||
| Q_UNUSED( core ); | ||
| if ( mInitialized ) | ||
| return; | ||
| mInitialized = true; | ||
| } | ||
|
|
||
|
|
||
| QString QgsMapLayerComboBoxPlugin::toolTip() const | ||
| { | ||
| return "A combo box to list the layers"; | ||
| } | ||
|
|
||
| QString QgsMapLayerComboBoxPlugin::whatsThis() const | ||
| { | ||
| return "A combo box to list the layers registered in QGIS. Layers might be filtered according to their type."; | ||
| } | ||
|
|
||
| QString QgsMapLayerComboBoxPlugin::domXml() const | ||
| { | ||
| return QString( "<ui language=\"c++\">\n" | ||
| " <widget class=\"%1\" name=\"mMapLayerComboBox\">\n" | ||
| " <property name=\"geometry\">\n" | ||
| " <rect>\n" | ||
| " <x>0</x>\n" | ||
| " <y>0</y>\n" | ||
| " <width>160</width>\n" | ||
| " <height>27</height>\n" | ||
| " </rect>\n" | ||
| " </property>\n" | ||
| " </widget>\n" | ||
| "</ui>\n" ) | ||
| .arg( name() ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /*************************************************************************** | ||
| qgsmaplayercomboboxplugin.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 QGSMAPLAYERCOMBOBOXPLUGIN_H | ||
| #define QGSMAPLAYERCOMBOBOXPLUGIN_H | ||
|
|
||
| #include <QDesignerExportWidget> | ||
| #include <QDesignerCustomWidgetInterface> | ||
|
|
||
|
|
||
| class QDESIGNER_WIDGET_EXPORT QgsMapLayerComboBoxPlugin : public QObject, public QDesignerCustomWidgetInterface | ||
| { | ||
| Q_OBJECT | ||
| Q_INTERFACES( QDesignerCustomWidgetInterface ) | ||
|
|
||
| public: | ||
| explicit QgsMapLayerComboBoxPlugin( 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 // QGSMAPLAYERCOMBOBOXPLUGIN_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /*************************************************************************** | ||
| qgsscalerangewidgetplugin.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 "qgsscalerangewidgetplugin.h" | ||
| #include "qgsscalerangewidget.h" | ||
|
|
||
|
|
||
| QgsScaleRangeWidgetPlugin::QgsScaleRangeWidgetPlugin( QObject *parent ) | ||
| : QObject( parent ) | ||
| , mInitialized( false ) | ||
| { | ||
| } | ||
|
|
||
|
|
||
| QString QgsScaleRangeWidgetPlugin::name() const | ||
| { | ||
| return "QgsScaleRangeWidget"; | ||
| } | ||
|
|
||
| QString QgsScaleRangeWidgetPlugin::group() const | ||
| { | ||
| return QgisCustomWidgets::groupName(); | ||
| } | ||
|
|
||
| QString QgsScaleRangeWidgetPlugin::includeFile() const | ||
| { | ||
| return "qgsscalerangewidget.h"; | ||
| } | ||
|
|
||
| QIcon QgsScaleRangeWidgetPlugin::icon() const | ||
| { | ||
| return QIcon(); | ||
| } | ||
|
|
||
| bool QgsScaleRangeWidgetPlugin::isContainer() const | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| QWidget *QgsScaleRangeWidgetPlugin::createWidget( QWidget *parent ) | ||
| { | ||
| return new QgsScaleRangeWidget( parent ); | ||
| } | ||
|
|
||
| bool QgsScaleRangeWidgetPlugin::isInitialized() const | ||
| { | ||
| return mInitialized; | ||
| } | ||
|
|
||
| void QgsScaleRangeWidgetPlugin::initialize( QDesignerFormEditorInterface *core ) | ||
| { | ||
| Q_UNUSED( core ); | ||
| if ( mInitialized ) | ||
| return; | ||
| mInitialized = true; | ||
| } | ||
|
|
||
|
|
||
| QString QgsScaleRangeWidgetPlugin::toolTip() const | ||
| { | ||
| return "A widget to define the scale range"; | ||
| } | ||
|
|
||
| QString QgsScaleRangeWidgetPlugin::whatsThis() const | ||
| { | ||
| return "A widget to define the scale range."; | ||
| } | ||
|
|
||
| QString QgsScaleRangeWidgetPlugin::domXml() const | ||
| { | ||
| return QString( "<ui language=\"c++\">\n" | ||
| " <widget class=\"%1\" name=\"mScaleRangeWidget\">\n" | ||
| " <property name=\"geometry\">\n" | ||
| " <rect>\n" | ||
| " <x>0</x>\n" | ||
| " <y>0</y>\n" | ||
| " <width>400</width>\n" | ||
| " <height>100</height>\n" | ||
| " </rect>\n" | ||
| " </property>\n" | ||
| " </widget>\n" | ||
| "</ui>\n" ) | ||
| .arg( name() ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /*************************************************************************** | ||
| qgsscalerangewidgetplugin.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 QGSSCALERANGEWIDGETPLUGIN_H | ||
| #define QGSSCALERANGEWIDGETPLUGIN_H | ||
|
|
||
| #include <QDesignerExportWidget> | ||
| #include <QDesignerCustomWidgetInterface> | ||
|
|
||
|
|
||
| class QDESIGNER_WIDGET_EXPORT QgsScaleRangeWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface | ||
| { | ||
| Q_OBJECT | ||
| Q_INTERFACES( QDesignerCustomWidgetInterface ) | ||
|
|
||
| public: | ||
| explicit QgsScaleRangeWidgetPlugin( 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 // QGSSCALERANGEWIDGETPLUGIN_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| /*************************************************************************** | ||
| qgsscalerangewidget.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 "qgsscalerangewidget.h" | ||
| #include "qgsapplication.h" | ||
| #include "qgsproject.h" | ||
|
|
||
|
|
||
| QgsScaleRangeWidget::QgsScaleRangeWidget( QWidget *parent ) | ||
| : QWidget( parent ) | ||
| , mCanvas( 0 ) | ||
| , mMaximumScaleSetCurrentPushButton( 0 ) | ||
| , mMinimumScaleSetCurrentPushButton( 0 ) | ||
| { | ||
| mLayout = new QGridLayout( this ); | ||
| mLayout->setContentsMargins( 0, 0, 0, 0 ); | ||
|
|
||
| QLabel* minLbl = new QLabel( tr( "Minimimum\n(exclusive)" ), this ); | ||
| minLbl->setWordWrap( true ); | ||
| minLbl->setAlignment( Qt::AlignTop ); | ||
| minLbl->setToolTip( tr( "Minimum scale, i.e. maximum scale denominator. " | ||
| "This limit is exclusive, that means the layer will not be displayed on this scale." ) ); | ||
| QLabel* maxLbl = new QLabel( tr( "Maximimum\n(inclusive)" ), this ); | ||
| maxLbl->setWordWrap( true ); | ||
| maxLbl->setAlignment( Qt::AlignTop ); | ||
| maxLbl->setToolTip( tr( "Maximum scale, i.e. minimum scale denominator. " | ||
| "This limit is inclusive, that means the layer will be displayed on this scale." ) ); | ||
|
|
||
| mMinimumScaleIconLabel = new QLabel( this ); | ||
| mMinimumScaleIconLabel->setPixmap( QgsApplication::getThemePixmap( "/mActionZoomOut.svg" ) ); | ||
| mMaximumScaleIconLabel = new QLabel( this ); | ||
| mMaximumScaleIconLabel->setPixmap( QgsApplication::getThemePixmap( "/mActionZoomIn.svg" ) ); | ||
|
|
||
| mMinimumScaleComboBox = new QgsScaleComboBox( this ); | ||
| mMaximumScaleComboBox = new QgsScaleComboBox( this ); | ||
| reloadProjectScales(); | ||
| // add start, add comprehension of scales by settings fake ordered values | ||
| mMinimumScaleComboBox->setCurrentIndex( 2 ); | ||
| mMaximumScaleComboBox->setCurrentIndex( mMinimumScaleComboBox->currentIndex() + 2 ); | ||
|
|
||
| mLayout->addWidget( minLbl, 0, 0, 2, 1 ); | ||
| mLayout->addWidget( mMinimumScaleIconLabel, 0, 1 ); | ||
| mLayout->addWidget( mMinimumScaleComboBox, 0, 2 ); | ||
| mLayout->addWidget( maxLbl, 0, 3, 2, 1 ); | ||
| mLayout->addWidget( mMaximumScaleIconLabel, 0, 4 ); | ||
| mLayout->addWidget( mMaximumScaleComboBox, 0, 5 ); | ||
|
|
||
| mLayout->setColumnStretch( 0, 0 ); | ||
| mLayout->setColumnStretch( 1, 0 ); | ||
| mLayout->setColumnStretch( 2, 3 ); | ||
| mLayout->setColumnStretch( 3, 0 ); | ||
| mLayout->setColumnStretch( 4, 0 ); | ||
| mLayout->setColumnStretch( 5, 3 ); | ||
| } | ||
|
|
||
| QgsScaleRangeWidget::~QgsScaleRangeWidget() | ||
| { | ||
| } | ||
|
|
||
| void QgsScaleRangeWidget::reloadProjectScales() | ||
| { | ||
| bool projectScales = QgsProject::instance()->readBoolEntry( "Scales", "/useProjectScales" ); | ||
| if ( projectScales ) | ||
| { | ||
| QStringList scalesList = QgsProject::instance()->readListEntry( "Scales", "/ScalesList" ); | ||
| mMinimumScaleComboBox->updateScales( scalesList ); | ||
| mMaximumScaleComboBox->updateScales( scalesList ); | ||
| } | ||
| } | ||
|
|
||
| void QgsScaleRangeWidget::setMapCanvas( QgsMapCanvas *mapCanvas ) | ||
| { | ||
| if ( mMinimumScaleSetCurrentPushButton ) | ||
| { | ||
| delete mMinimumScaleSetCurrentPushButton; | ||
| mMinimumScaleSetCurrentPushButton = 0; | ||
| } | ||
| if ( mMaximumScaleSetCurrentPushButton ) | ||
| { | ||
| delete mMaximumScaleSetCurrentPushButton; | ||
| mMaximumScaleSetCurrentPushButton = 0; | ||
| } | ||
|
|
||
| if ( !mapCanvas ) | ||
| return; | ||
|
|
||
| mCanvas = mapCanvas; | ||
|
|
||
| mMinimumScaleSetCurrentPushButton = new QPushButton( tr( "current" ), this ); | ||
| connect( mMinimumScaleSetCurrentPushButton, SIGNAL( clicked() ), this, SLOT( setMinScaleFromCanvas() ) ); | ||
| mMaximumScaleSetCurrentPushButton = new QPushButton( tr( "current" ), this ); | ||
| connect( mMaximumScaleSetCurrentPushButton, SIGNAL( clicked() ), this, SLOT( setMaxScaleFromCanvas() ) ); | ||
|
|
||
| mLayout->addWidget( mMinimumScaleSetCurrentPushButton, 1, 2 ); | ||
| mLayout->addWidget( mMaximumScaleSetCurrentPushButton, 1, 5 ); | ||
| } | ||
|
|
||
| void QgsScaleRangeWidget::setMinimumScale( double scale ) | ||
| { | ||
| mMinimumScaleComboBox->setScale( scale ); | ||
| } | ||
|
|
||
| double QgsScaleRangeWidget::minimumScale() | ||
| { | ||
| return mMinimumScaleComboBox->scale(); | ||
| } | ||
|
|
||
| void QgsScaleRangeWidget::setMaximumScale( double scale ) | ||
| { | ||
| mMaximumScaleComboBox->setScale( scale ); | ||
| } | ||
|
|
||
| double QgsScaleRangeWidget::maximumScale() | ||
| { | ||
| return mMaximumScaleComboBox->scale(); | ||
| } | ||
|
|
||
| double QgsScaleRangeWidget::minimumScaleDenom() | ||
| { | ||
| return qRound( 1.0 / maximumScale() ); | ||
| } | ||
|
|
||
| double QgsScaleRangeWidget::maximumScaleDenom() | ||
| { | ||
| return qRound( 1.0 / minimumScale() ); | ||
| } | ||
|
|
||
| void QgsScaleRangeWidget::setScaleRange( double min, double max ) | ||
| { | ||
| setMaximumScale( max ); | ||
| setMinimumScale( min ); | ||
| } | ||
|
|
||
| void QgsScaleRangeWidget::setMinScaleFromCanvas() | ||
| { | ||
| mMinimumScaleComboBox->setScale( 1.0 / mCanvas->mapSettings().scale() ); | ||
| } | ||
|
|
||
| void QgsScaleRangeWidget::setMaxScaleFromCanvas() | ||
| { | ||
| mMaximumScaleComboBox->setScale( 1.0 / mCanvas->mapSettings().scale() ); | ||
| } | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /*************************************************************************** | ||
| qgsscalerangewidget.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 QGSSCALERANGEWIDGET_H | ||
| #define QGSSCALERANGEWIDGET_H | ||
|
|
||
| #include <QGridLayout> | ||
| #include <QLabel> | ||
| #include <QPushButton> | ||
|
|
||
|
|
||
| #include "qgscollapsiblegroupbox.h" | ||
| #include "qgsmaplayer.h" | ||
| #include "qgsmapcanvas.h" | ||
| #include "qgsscalecombobox.h" | ||
|
|
||
|
|
||
| class GUI_EXPORT QgsScaleRangeWidget : public QWidget | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| explicit QgsScaleRangeWidget( QWidget *parent = 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 ); | ||
|
|
||
| private slots: | ||
| void setMaxScaleFromCanvas(); | ||
| void setMinScaleFromCanvas(); | ||
|
|
||
| private: | ||
| //! pointer to the map canvas used for current buttons. | ||
| QgsMapCanvas* mCanvas; | ||
|
|
||
| // ui | ||
| QGridLayout* mLayout; | ||
| QLabel* mMaximumScaleIconLabel; | ||
| QLabel* mMinimumScaleIconLabel; | ||
| QPushButton* mMaximumScaleSetCurrentPushButton; | ||
| QPushButton* mMinimumScaleSetCurrentPushButton; | ||
| QgsScaleComboBox* mMaximumScaleComboBox; | ||
| QgsScaleComboBox* mMinimumScaleComboBox; | ||
| }; | ||
|
|
||
| #endif // QGSSCALERANGEWIDGET_H |