Skip to content

Commit 054ac10

Browse files
committedSep 25, 2014
add Qgs(Double)SpinBox to custom widgets
1 parent 48cdd74 commit 054ac10

File tree

6 files changed

+300
-0
lines changed

6 files changed

+300
-0
lines changed
 

‎src/customwidgets/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ SET (QGIS_CUSTOMWIDGETS_SRCS
2020
qgscolorbuttonv2plugin.cpp
2121
qgsdatetimeeditplugin.cpp
2222
qgsdatadefinedbuttonplugin.cpp
23+
qgsdoublespinboxplugin.cpp
2324
qgsfieldcomboboxplugin.cpp
2425
qgsfieldexpressionwidgetplugin.cpp
2526
qgsfilterlineeditplugin.cpp
2627
qgsmaplayercomboboxplugin.cpp
2728
qgsrelationeditorwidgetplugin.cpp
2829
qgsrelationreferencewidgetplugin.cpp
2930
qgsscalerangewidgetplugin.cpp
31+
qgsspinboxplugin.cpp
3032
)
3133

3234
SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
@@ -36,13 +38,15 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
3638
qgscolorbuttonv2plugin.h
3739
qgsdatetimeeditplugin.h
3840
qgsdatadefinedbuttonplugin.h
41+
qgsdoublespinboxplugin.h
3942
qgsfieldcomboboxplugin.h
4043
qgsfieldexpressionwidgetplugin.h
4144
qgsfilterlineeditplugin.h
4245
qgsmaplayercomboboxplugin.h
4346
qgsrelationeditorwidgetplugin.h
4447
qgsrelationreferencewidgetplugin.h
4548
qgsscalerangewidgetplugin.h
49+
qgsspinboxplugin.h
4650
)
4751

4852
QT4_WRAP_CPP(QGIS_CUSTOMWIDGETS_MOC_SRCS ${QGIS_CUSTOMWIDGETS_MOC_HDRS})
@@ -60,13 +64,15 @@ SET(QGIS_CUSTOMWIDGETS_HDRS
6064
qgscolorbuttonv2plugin.h
6165
qgsdatetimeeditplugin.h
6266
qgsdatadefinedbuttonplugin.h
67+
qgsdoublespinboxplugin.h
6368
qgsfieldcomboboxplugin.h
6469
qgsfieldexpressionwidgetplugin.h
6570
qgsfilterlineeditplugin.h
6671
qgsmaplayercomboboxplugin.h
6772
qgsrelationeditorwidgetplugin.h
6873
qgsrelationreferencewidgetplugin.h
6974
qgsscalerangewidgetplugin.h
75+
qgsspinboxplugin.h
7076
)
7177

7278
# left commented as there is no UI file yet

‎src/customwidgets/qgiscustomwidgets.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
#include "qgscolorbuttonplugin.h"
2222
#include "qgscolorbuttonv2plugin.h"
2323
#include "qgsdatadefinedbuttonplugin.h"
24+
#include "qgsdoublespinboxplugin.h"
2425
#include "qgsfieldcomboboxplugin.h"
2526
#include "qgsfieldexpressionwidgetplugin.h"
2627
#include "qgsmaplayercomboboxplugin.h"
2728
#include "qgsrelationeditorwidgetplugin.h"
2829
#include "qgsrelationreferencewidgetplugin.h"
2930
#include "qgsscalerangewidgetplugin.h"
31+
#include "qgsspinboxplugin.h"
3032

3133

3234
QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
@@ -36,12 +38,14 @@ QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
3638
mWidgets.append( new QgsColorButtonPlugin );
3739
mWidgets.append( new QgsColorButtonV2Plugin );
3840
mWidgets.append( new QgsDataDefinedButtonPlugin );
41+
mWidgets.append( new QgsDoubleSpinBoxPlugin );
3942
mWidgets.append( new QgsFieldComboBoxPlugin );
4043
mWidgets.append( new QgsFieldExpressionWidgetPlugin );
4144
mWidgets.append( new QgsMapLayerComboBoxPlugin );
4245
mWidgets.append( new QgsRelationEditorWidgetPlugin );
4346
mWidgets.append( new QgsRelationReferenceWidgetPlugin );
4447
mWidgets.append( new QgsScaleRangeWidgetPlugin );
48+
mWidgets.append( new QgsSpinBoxPlugin );
4549
}
4650

4751
QList<QDesignerCustomWidgetInterface*> QgisCustomWidgets::customWidgets() const
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/***************************************************************************
2+
qgsdoublespinboxplugin.cpp
3+
--------------------------------------
4+
Date : 01.09.2014
5+
Copyright : (C) 2014 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 "qgsdoublespinboxplugin.h"
18+
#include "qgsdoublespinbox.h"
19+
20+
21+
QgsDoubleSpinBoxPlugin::QgsDoubleSpinBoxPlugin( QObject *parent )
22+
: QObject( parent )
23+
, mInitialized( false )
24+
{
25+
}
26+
27+
28+
QString QgsDoubleSpinBoxPlugin::name() const
29+
{
30+
return "QgsDoubleSpinBox";
31+
}
32+
33+
QString QgsDoubleSpinBoxPlugin::group() const
34+
{
35+
return QgisCustomWidgets::groupName();
36+
}
37+
38+
QString QgsDoubleSpinBoxPlugin::includeFile() const
39+
{
40+
return "qgsdoublespinbox.h";
41+
}
42+
43+
QIcon QgsDoubleSpinBoxPlugin::icon() const
44+
{
45+
return QIcon();
46+
}
47+
48+
bool QgsDoubleSpinBoxPlugin::isContainer() const
49+
{
50+
return false;
51+
}
52+
53+
QWidget *QgsDoubleSpinBoxPlugin::createWidget( QWidget *parent )
54+
{
55+
return new QgsDoubleSpinBox( parent );
56+
}
57+
58+
bool QgsDoubleSpinBoxPlugin::isInitialized() const
59+
{
60+
return mInitialized;
61+
}
62+
63+
void QgsDoubleSpinBoxPlugin::initialize( QDesignerFormEditorInterface *core )
64+
{
65+
Q_UNUSED( core );
66+
if ( mInitialized )
67+
return;
68+
mInitialized = true;
69+
}
70+
71+
72+
QString QgsDoubleSpinBoxPlugin::toolTip() const
73+
{
74+
return "";
75+
}
76+
77+
QString QgsDoubleSpinBoxPlugin::whatsThis() const
78+
{
79+
return "";
80+
}
81+
82+
QString QgsDoubleSpinBoxPlugin::domXml() const
83+
{
84+
return QString( "<ui language=\"c++\">\n"
85+
" <widget class=\"%1\" name=\"mQgsDoubleSpinBox\">\n"
86+
" <property name=\"geometry\">\n"
87+
" <rect>\n"
88+
" <x>0</x>\n"
89+
" <y>0</y>\n"
90+
" <width>90</width>\n"
91+
" <height>27</height>\n"
92+
" </rect>\n"
93+
" </property>\n"
94+
" </widget>\n"
95+
"</ui>\n" )
96+
.arg( name() );
97+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/***************************************************************************
2+
qgsdoublespinboxplugin.h
3+
--------------------------------------
4+
Date : 01.09.2014
5+
Copyright : (C) 2014 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 QGSDOUBLESPINBOXPLUGIN_H
17+
#define QGSDOUBLESPINBOXPLUGIN_H
18+
19+
#include <QDesignerExportWidget>
20+
#include <QDesignerCustomWidgetInterface>
21+
22+
23+
class CUSTOMWIDGETS_EXPORT QgsDoubleSpinBoxPlugin : public QObject, public QDesignerCustomWidgetInterface
24+
{
25+
Q_OBJECT
26+
Q_INTERFACES( QDesignerCustomWidgetInterface )
27+
28+
public:
29+
explicit QgsDoubleSpinBoxPlugin( QObject *parent = 0 );
30+
31+
private:
32+
bool mInitialized;
33+
34+
// QDesignerCustomWidgetInterface interface
35+
public:
36+
QString name() const;
37+
QString group() const;
38+
QString includeFile() const;
39+
QIcon icon() const;
40+
bool isContainer() const;
41+
QWidget *createWidget( QWidget *parent );
42+
bool isInitialized() const;
43+
void initialize( QDesignerFormEditorInterface *core );
44+
QString toolTip() const;
45+
QString whatsThis() const;
46+
QString domXml() const;
47+
};
48+
#endif // QGSDOUBLESPINBOXPLUGIN_H
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/***************************************************************************
2+
qgsspinboxplugin.cpp
3+
--------------------------------------
4+
Date : 01.09.2014
5+
Copyright : (C) 2014 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 "qgsspinboxplugin.h"
18+
#include "qgsspinbox.h"
19+
20+
21+
QgsSpinBoxPlugin::QgsSpinBoxPlugin( QObject *parent )
22+
: QObject( parent )
23+
, mInitialized( false )
24+
{
25+
}
26+
27+
28+
QString QgsSpinBoxPlugin::name() const
29+
{
30+
return "QgsSpinBox";
31+
}
32+
33+
QString QgsSpinBoxPlugin::group() const
34+
{
35+
return QgisCustomWidgets::groupName();
36+
}
37+
38+
QString QgsSpinBoxPlugin::includeFile() const
39+
{
40+
return "qgsspinbox.h";
41+
}
42+
43+
QIcon QgsSpinBoxPlugin::icon() const
44+
{
45+
return QIcon();
46+
}
47+
48+
bool QgsSpinBoxPlugin::isContainer() const
49+
{
50+
return false;
51+
}
52+
53+
QWidget *QgsSpinBoxPlugin::createWidget( QWidget *parent )
54+
{
55+
return new QgsSpinBox( parent );
56+
}
57+
58+
bool QgsSpinBoxPlugin::isInitialized() const
59+
{
60+
return mInitialized;
61+
}
62+
63+
void QgsSpinBoxPlugin::initialize( QDesignerFormEditorInterface *core )
64+
{
65+
Q_UNUSED( core );
66+
if ( mInitialized )
67+
return;
68+
mInitialized = true;
69+
}
70+
71+
72+
QString QgsSpinBoxPlugin::toolTip() const
73+
{
74+
return "";
75+
}
76+
77+
QString QgsSpinBoxPlugin::whatsThis() const
78+
{
79+
return "";
80+
}
81+
82+
QString QgsSpinBoxPlugin::domXml() const
83+
{
84+
return QString( "<ui language=\"c++\">\n"
85+
" <widget class=\"%1\" name=\"mQgsSpinBox\">\n"
86+
" <property name=\"geometry\">\n"
87+
" <rect>\n"
88+
" <x>0</x>\n"
89+
" <y>0</y>\n"
90+
" <width>90</width>\n"
91+
" <height>27</height>\n"
92+
" </rect>\n"
93+
" </property>\n"
94+
" </widget>\n"
95+
"</ui>\n" )
96+
.arg( name() );
97+
}

‎src/customwidgets/qgsspinboxplugin.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/***************************************************************************
2+
qgsspinboxplugin.h
3+
--------------------------------------
4+
Date : 01.09.2014
5+
Copyright : (C) 2014 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 QGSSPINBOXPLUGIN_H
17+
#define QGSSPINBOXPLUGIN_H
18+
19+
#include <QDesignerExportWidget>
20+
#include <QDesignerCustomWidgetInterface>
21+
22+
23+
class CUSTOMWIDGETS_EXPORT QgsSpinBoxPlugin : public QObject, public QDesignerCustomWidgetInterface
24+
{
25+
Q_OBJECT
26+
Q_INTERFACES( QDesignerCustomWidgetInterface )
27+
28+
public:
29+
explicit QgsSpinBoxPlugin( QObject *parent = 0 );
30+
31+
private:
32+
bool mInitialized;
33+
34+
// QDesignerCustomWidgetInterface interface
35+
public:
36+
QString name() const;
37+
QString group() const;
38+
QString includeFile() const;
39+
QIcon icon() const;
40+
bool isContainer() const;
41+
QWidget *createWidget( QWidget *parent );
42+
bool isInitialized() const;
43+
void initialize( QDesignerFormEditorInterface *core );
44+
QString toolTip() const;
45+
QString whatsThis() const;
46+
QString domXml() const;
47+
};
48+
#endif // QGSSPINBOXPLUGIN_H

0 commit comments

Comments
 (0)
Please sign in to comment.