Skip to content

Commit d9280b1

Browse files
committed
add scale widget to custom widgets
1 parent 127c882 commit d9280b1

File tree

4 files changed

+170
-15
lines changed

4 files changed

+170
-15
lines changed

src/customwidgets/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ SET (QGIS_CUSTOMWIDGETS_SRCS
3535
qgsrelationeditorwidgetplugin.cpp
3636
qgsrelationreferencewidgetplugin.cpp
3737
qgsscalerangewidgetplugin.cpp
38+
qgsscalewidgetplugin.cpp
3839
qgsspinboxplugin.cpp
3940
)
4041

@@ -54,6 +55,7 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
5455
qgsrelationeditorwidgetplugin.h
5556
qgsrelationreferencewidgetplugin.h
5657
qgsscalerangewidgetplugin.h
58+
qgsscalewidgetplugin.h
5759
qgsspinboxplugin.h
5860
)
5961

@@ -79,6 +81,7 @@ SET(QGIS_CUSTOMWIDGETS_HDRS
7981
qgsrelationeditorwidgetplugin.h
8082
qgsrelationreferencewidgetplugin.h
8183
qgsscalerangewidgetplugin.h
84+
qgsscalewidgetplugin.h
8285
qgsspinboxplugin.h
8386
)
8487

src/customwidgets/qgiscustomwidgets.cpp

+19-15
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,29 @@
3131
#include "qgsrelationeditorwidgetplugin.h"
3232
#include "qgsrelationreferencewidgetplugin.h"
3333
#include "qgsscalerangewidgetplugin.h"
34+
#include "qgsscalewidgetplugin.h"
3435
#include "qgsspinboxplugin.h"
3536

3637

3738
QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
3839
: QObject( parent )
3940
{
40-
mWidgets.append( new QgsCollapsibleGroupBoxPlugin(this) );
41-
mWidgets.append( new QgsColorButtonPlugin(this) );
42-
mWidgets.append( new QgsColorButtonV2Plugin(this) );
43-
mWidgets.append( new QgsDataDefinedButtonPlugin(this) );
44-
mWidgets.append( new QgsDateTimeEditPlugin(this) );
45-
mWidgets.append( new QgsDoubleSpinBoxPlugin(this) );
46-
mWidgets.append( new QgsFieldComboBoxPlugin(this) );
47-
mWidgets.append( new QgsFieldExpressionWidgetPlugin(this) );
48-
mWidgets.append( new QgsFilterLineEditPlugin(this) );
49-
mWidgets.append( new QgsMapLayerComboBoxPlugin(this) );
50-
mWidgets.append( new QgsProjectionSelectionWidgetPlugin(this) );
51-
mWidgets.append( new QgsRelationEditorWidgetPlugin(this) );
52-
mWidgets.append( new QgsRelationReferenceWidgetPlugin(this) );
53-
mWidgets.append( new QgsScaleRangeWidgetPlugin(this) );
54-
mWidgets.append( new QgsSpinBoxPlugin(this) );
41+
mWidgets.append( new QgsCollapsibleGroupBoxPlugin( this ) );
42+
mWidgets.append( new QgsColorButtonPlugin( this ) );
43+
mWidgets.append( new QgsColorButtonV2Plugin( this ) );
44+
mWidgets.append( new QgsDataDefinedButtonPlugin( this ) );
45+
mWidgets.append( new QgsDateTimeEditPlugin( this ) );
46+
mWidgets.append( new QgsDoubleSpinBoxPlugin( this ) );
47+
mWidgets.append( new QgsFieldComboBoxPlugin( this ) );
48+
mWidgets.append( new QgsFieldExpressionWidgetPlugin( this ) );
49+
mWidgets.append( new QgsFilterLineEditPlugin( this ) );
50+
mWidgets.append( new QgsMapLayerComboBoxPlugin( this ) );
51+
mWidgets.append( new QgsProjectionSelectionWidgetPlugin( this ) );
52+
mWidgets.append( new QgsRelationEditorWidgetPlugin( this ) );
53+
mWidgets.append( new QgsRelationReferenceWidgetPlugin( this ) );
54+
mWidgets.append( new QgsScaleRangeWidgetPlugin( this ) );
55+
mWidgets.append( new QgsScaleWidgetPlugin( this ) );
56+
mWidgets.append( new QgsSpinBoxPlugin( this ) );
5557
}
5658

5759
QList<QDesignerCustomWidgetInterface*> QgisCustomWidgets::customWidgets() const
@@ -62,3 +64,5 @@ QList<QDesignerCustomWidgetInterface*> QgisCustomWidgets::customWidgets() const
6264
#if QT_VERSION < 0x050000
6365
Q_EXPORT_PLUGIN2( customwidgetsplugin, QgisCustomWidgets )
6466
#endif
67+
68+
+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/***************************************************************************
2+
qgsscalewidgetplugin.cpp
3+
--------------------------------------
4+
Date : 08.01.2015
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 "qgsscalewidgetplugin.h"
18+
#include "qgsscalewidget.h"
19+
20+
21+
QgsScaleWidgetPlugin::QgsScaleWidgetPlugin( QObject *parent )
22+
: QObject( parent )
23+
, mInitialized( false )
24+
{
25+
}
26+
27+
28+
QString QgsScaleWidgetPlugin::name() const
29+
{
30+
return "QgsScaleWidget";
31+
}
32+
33+
QString QgsScaleWidgetPlugin::group() const
34+
{
35+
return QgisCustomWidgets::groupName();
36+
}
37+
38+
QString QgsScaleWidgetPlugin::includeFile() const
39+
{
40+
return "qgsscalewidget.h";
41+
}
42+
43+
QIcon QgsScaleWidgetPlugin::icon() const
44+
{
45+
return QIcon();
46+
}
47+
48+
bool QgsScaleWidgetPlugin::isContainer() const
49+
{
50+
return false;
51+
}
52+
53+
QWidget *QgsScaleWidgetPlugin::createWidget( QWidget *parent )
54+
{
55+
return new QgsScaleWidget( parent );
56+
}
57+
58+
bool QgsScaleWidgetPlugin::isInitialized() const
59+
{
60+
return mInitialized;
61+
}
62+
63+
void QgsScaleWidgetPlugin::initialize( QDesignerFormEditorInterface *core )
64+
{
65+
Q_UNUSED( core );
66+
if ( mInitialized )
67+
return;
68+
mInitialized = true;
69+
}
70+
71+
72+
QString QgsScaleWidgetPlugin::toolTip() const
73+
{
74+
return tr( "A widget to define the scale" );
75+
}
76+
77+
QString QgsScaleWidgetPlugin::whatsThis() const
78+
{
79+
return tr( "A widget to define the scale." );
80+
}
81+
82+
QString QgsScaleWidgetPlugin::domXml() const
83+
{
84+
return QString( "<ui language=\"c++\">\n"
85+
" <widget class=\"%1\" name=\"mScaleWidget\">\n"
86+
" <property name=\"geometry\">\n"
87+
" <rect>\n"
88+
" <x>0</x>\n"
89+
" <y>0</y>\n"
90+
" <width>200</width>\n"
91+
" <height>27</height>\n"
92+
" </rect>\n"
93+
" </property>\n"
94+
" <property name=\"showCurrentScaleButton\">\n"
95+
" <bool>true</bool>\n"
96+
" </property>\n"
97+
" </widget>\n"
98+
"</ui>\n" )
99+
.arg( name() );
100+
}
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/***************************************************************************
2+
qgsscalewidgetplugin.h
3+
--------------------------------------
4+
Date : 08.01.2015
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 QGSSCALEWIDGETPLUGIN_H
17+
#define QGSSCALEWIDGETPLUGIN_H
18+
19+
#include <QDesignerExportWidget>
20+
#include <QDesignerCustomWidgetInterface>
21+
22+
23+
class CUSTOMWIDGETS_EXPORT QgsScaleWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface
24+
{
25+
Q_OBJECT
26+
Q_INTERFACES( QDesignerCustomWidgetInterface )
27+
28+
public:
29+
explicit QgsScaleWidgetPlugin( 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 // QGSSCALEWIDGETPLUGIN_H

0 commit comments

Comments
 (0)