Skip to content

Commit bf04b0c

Browse files
authoredMay 1, 2020
add QgsFeaturePickerWidget to custom widgets (#36119)
1 parent e85c656 commit bf04b0c

File tree

5 files changed

+159
-8
lines changed

5 files changed

+159
-8
lines changed
 

‎scripts/customwidget_create.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ for i in "${EXT[@]}"
3434
do
3535
DESTFILE=$DIR/../src/customwidgets/${CLASSLOWER}plugin.$i
3636
cp "$DIR"/customwidget."$i".template "$DESTFILE"
37-
${GP}sed -i s/%DATE%/${TODAY}/g ${DESTFILE}
38-
${GP}sed -i s/%YEAR%/${YEAR}/g ${DESTFILE}
39-
${GP}sed -i s/%AUTHOR%/${AUTHOR}/g ${DESTFILE}
40-
${GP}sed -i s/%EMAIL%/${EMAIL}/g ${DESTFILE}
41-
${GP}sed -i s/%CLASSUPPERCASE%/${CLASSUPPER}/g ${DESTFILE}
42-
${GP}sed -i s/%CLASSLOWERCASE%/${CLASSLOWER}/g ${DESTFILE}
43-
${GP}sed -i s/%CLASSMIXEDCASE%/${CLASSNAME}/g ${DESTFILE}
44-
${GP}sed -i s/%CLASSWITHOUTQGS%/${CLASSWITHOUTQGS}/g ${DESTFILE}
37+
${GP}sed -i "s/%DATE%/${TODAY}/g" ${DESTFILE}
38+
${GP}sed -i "s/%YEAR%/${YEAR}/g" ${DESTFILE}
39+
${GP}sed -i "s/%AUTHOR%/${AUTHOR}/g" ${DESTFILE}
40+
${GP}sed -i "s/%EMAIL%/${EMAIL}/g" ${DESTFILE}
41+
${GP}sed -i "s/%CLASSUPPERCASE%/${CLASSUPPER}/g" ${DESTFILE}
42+
${GP}sed -i "s/%CLASSLOWERCASE%/${CLASSLOWER}/g" ${DESTFILE}
43+
${GP}sed -i "s/%CLASSMIXEDCASE%/${CLASSNAME}/g" ${DESTFILE}
44+
${GP}sed -i "s/%CLASSWITHOUTQGS%/${CLASSWITHOUTQGS}/g" ${DESTFILE}
4545
done

‎src/customwidgets/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ SET (QGIS_CUSTOMWIDGETS_SRCS
2323
qgsextentgroupboxplugin.cpp
2424
qgsexternalresourcewidgetplugin.cpp
2525
qgsfeaturelistcomboboxplugin.cpp
26+
qgsfeaturepickerwidgetplugin.cpp
2627
qgsfieldcomboboxplugin.cpp
2728
qgsfieldexpressionwidgetplugin.cpp
2829
qgsfilewidgetplugin.cpp
@@ -56,6 +57,7 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
5657
qgsextentgroupboxplugin.h
5758
qgsexternalresourcewidgetplugin.h
5859
qgsfeaturelistcomboboxplugin.h
60+
qgsfeaturepickerwidgetplugin.h
5961
qgsfieldcomboboxplugin.h
6062
qgsfieldexpressionwidgetplugin.h
6163
qgsfilewidgetplugin.h

‎src/customwidgets/qgiscustomwidgets.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "qgsextentgroupboxplugin.h"
2828
#include "qgsexternalresourcewidgetplugin.h"
2929
#include "qgsfeaturelistcomboboxplugin.h"
30+
#include "qgsfeaturepickerwidgetplugin.h"
3031
#include "qgsfieldcomboboxplugin.h"
3132
#include "qgsfieldexpressionwidgetplugin.h"
3233
#include "qgsfilewidgetplugin.h"
@@ -60,6 +61,7 @@ QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
6061
mWidgets.append( new QgsExtentGroupBoxPlugin( this ) );
6162
mWidgets.append( new QgsExternalResourceWidgetPlugin( this ) );
6263
mWidgets.append( new QgsFeatureListComboBoxPlugin( this ) );
64+
mWidgets.append( new QgsFeaturePickerWidgetPlugin( this ) );
6365
mWidgets.append( new QgsFieldComboBoxPlugin( this ) );
6466
mWidgets.append( new QgsFieldExpressionWidgetPlugin( this ) );
6567
mWidgets.append( new QgsFileWidgetPlugin( this ) );
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/***************************************************************************
2+
qgsfeaturepickerwidgetplugin.cpp
3+
--------------------------------------
4+
Date : 01.05.2020
5+
Copyright : (C) 2020 Denis Rouzaud
6+
Email : denis.rouzaud@gmail.com
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
16+
#include "qgiscustomwidgets.h"
17+
#include "qgsfeaturepickerwidgetplugin.h"
18+
#include "qgsfeaturepickerwidget.h"
19+
20+
21+
QgsFeaturePickerWidgetPlugin::QgsFeaturePickerWidgetPlugin( QObject *parent )
22+
: QObject( parent )
23+
, mInitialized( false )
24+
{
25+
}
26+
27+
QString QgsFeaturePickerWidgetPlugin::name() const
28+
{
29+
return "QgsFeaturePickerWidget";
30+
}
31+
32+
QString QgsFeaturePickerWidgetPlugin::group() const
33+
{
34+
return QgisCustomWidgets::groupName();
35+
}
36+
37+
QString QgsFeaturePickerWidgetPlugin::includeFile() const
38+
{
39+
return "qgsfeaturepickerwidget.h";
40+
}
41+
42+
QIcon QgsFeaturePickerWidgetPlugin::icon() const
43+
{
44+
return QIcon( ":/images/icons/qgis-icon-60x60.png" );
45+
}
46+
47+
bool QgsFeaturePickerWidgetPlugin::isContainer() const
48+
{
49+
return false;
50+
}
51+
52+
QWidget *QgsFeaturePickerWidgetPlugin::createWidget( QWidget *parent )
53+
{
54+
return new QgsFeaturePickerWidget( parent );
55+
}
56+
57+
bool QgsFeaturePickerWidgetPlugin::isInitialized() const
58+
{
59+
return mInitialized;
60+
}
61+
62+
void QgsFeaturePickerWidgetPlugin::initialize( QDesignerFormEditorInterface *core )
63+
{
64+
Q_UNUSED( core )
65+
if ( mInitialized )
66+
return;
67+
mInitialized = true;
68+
}
69+
70+
71+
QString QgsFeaturePickerWidgetPlugin::toolTip() const
72+
{
73+
return "";
74+
}
75+
76+
QString QgsFeaturePickerWidgetPlugin::whatsThis() const
77+
{
78+
return "";
79+
}
80+
81+
QString QgsFeaturePickerWidgetPlugin::domXml() const
82+
{
83+
return QString( "<ui language=\"c++\">\n"
84+
" <widget class=\"%1\" name=\"mFeaturePickerWidget\">\n"
85+
" <property name=\"geometry\">\n"
86+
" <rect>\n"
87+
" <x>0</x>\n"
88+
" <y>0</y>\n"
89+
" <width>90</width>\n"
90+
" <height>27</height>\n"
91+
" </rect>\n"
92+
" </property>\n"
93+
" </widget>\n"
94+
"</ui>\n" )
95+
.arg( name() );
96+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/***************************************************************************
2+
qgsfeaturepickerwidgetplugin.h
3+
--------------------------------------
4+
Date : 01.05.2020
5+
Copyright : (C) 2020 Denis Rouzaud
6+
Email : denis.rouzaud@gmail.com
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
16+
#ifndef QGSFEATUREPICKERWIDGETPLUGIN_H
17+
#define QGSFEATUREPICKERWIDGETPLUGIN_H
18+
19+
20+
#include <QtGlobal>
21+
#include <QtUiPlugin/QDesignerCustomWidgetInterface>
22+
#include <QtUiPlugin/QDesignerExportWidget>
23+
#include "qgis_customwidgets.h"
24+
25+
26+
class CUSTOMWIDGETS_EXPORT QgsFeaturePickerWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface
27+
{
28+
Q_OBJECT
29+
Q_INTERFACES( QDesignerCustomWidgetInterface )
30+
31+
public:
32+
explicit QgsFeaturePickerWidgetPlugin( QObject *parent = nullptr );
33+
34+
private:
35+
bool mInitialized;
36+
37+
// QDesignerCustomWidgetInterface interface
38+
public:
39+
QString name() const override;
40+
QString group() const override;
41+
QString includeFile() const override;
42+
QIcon icon() const override;
43+
bool isContainer() const override;
44+
QWidget *createWidget( QWidget *parent ) override;
45+
bool isInitialized() const override;
46+
void initialize( QDesignerFormEditorInterface *core ) override;
47+
QString toolTip() const override;
48+
QString whatsThis() const override;
49+
QString domXml() const override;
50+
};
51+
#endif // QGSFEATUREPICKERWIDGETPLUGIN_H

0 commit comments

Comments
 (0)
Please sign in to comment.