Skip to content

File tree

3 files changed

+261
-0
lines changed

3 files changed

+261
-0
lines changed
 

‎src/designer/Makefile.am

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (C) 2005 Tim Sutton <tim at linfiniti.com>
2+
#
3+
# This file is free software; as a special exception the author gives
4+
# unlimited permission to copy and/or distribute it, with or without
5+
# modifications, as long as this notice is preserved.
6+
#
7+
# This program is distributed in the hope that it will be useful, but
8+
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
9+
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10+
#
11+
# $Id: Makefile.am 4490 2006-01-07 01:09:27Z timlinux $
12+
13+
14+
plugindir = ${pkglibdir}/designer
15+
16+
%.moc.cpp: %.h
17+
$(MOC) -o $@ $<
18+
19+
# name of the designer plugin
20+
plugin_LTLIBRARIES = qgisdesignerwidgets.la
21+
22+
qgisdesignerwidgets_la_SOURCES = qgsdesignerwidgets.cpp \
23+
qgsdesignerwidgets.h \
24+
$(projectionselector_la_MOC)
25+
26+
qgisdesignerwidgets_la_MOC = qgsprojectionselectorplugin.moc.cpp
27+
28+
projectionselector_la_LIBADD = ../src/libqgis.la $(QT_LDADD)
29+
#qgisdesignerwidgets_la_LIBADD = $(QT_LDADD) ../widgets/projectionselector/libqgsprojectionselector.la
30+
qgisdesignerwidgets_la_LDFLAGS = -avoid-version -module
31+
qgisdesignerwidgets_la_CXXFLAGS = $(CXXFLAGS) $(EXTRA_CXXFLAGS) $(QT_CXXFLAGS) $(DEBUG_QGIS) -I../ -I../legend

‎src/designer/qgsdesignerwidgets.cpp

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
#include "qgsdesignerwidgets.h"
2+
#include <qstringlist.h>
3+
#include <qimage.h>
4+
#include <q3dragobject.h>
5+
#include "qgslegend.h"
6+
#include "qgsmapcanvas.h"
7+
#include "qgslinestylewidget.h"
8+
#include "qgsfillstylewidget.h"
9+
#include "qgspointstylewidget.h"
10+
#include "qgsvectorsymbologywidget.h"
11+
//Added by qt3to4:
12+
#include <QPixmap>
13+
#include <Q3ValueList>
14+
static const char *legend_pixmap[] = {
15+
"22 22 8 1",
16+
" c Gray100",
17+
". c Gray97",
18+
"X c #4f504f",
19+
"o c #00007f",
20+
"O c Gray0",
21+
"+ c none",
22+
"@ c Gray0",
23+
"# c Gray0",
24+
"++++++++++++++++++++++",
25+
"++++++++++++++++++++++",
26+
"++++++++++++++++++++++",
27+
"++++++++++++++++++++++",
28+
"+OOOOOOOOOOOOOOOOOOOO+",
29+
"OOXXXXXXXXXXXXXXXXXXOO",
30+
"OXX. O",
31+
"OX. ooooooooo O",
32+
"OX. o o .O",
33+
"OX o o O",
34+
"OX o o O",
35+
"O o o O",
36+
"OX o o o O",
37+
"OX o o o O",
38+
"OX o o O",
39+
"OX ooooooooo o O",
40+
"OO..................OO",
41+
"+OOOOOOOOOOOOOOOOOOOO+",
42+
"++++++++++++++++++++++",
43+
"++++++++++++++++++++++",
44+
"++++++++++++++++++++++",
45+
"++++++++++++++++++++++"
46+
};
47+
48+
//shamelessly snarfed from qwt stuff - a very nice simple neat way to
49+
//accommodate building multiple widgets...Tim
50+
namespace
51+
{
52+
struct Entry
53+
{
54+
Entry() {}
55+
Entry( QString theClassname, QString theHeader, QString thePixmap,
56+
QString theTooltip, QString theWhatsThisString):
57+
classname(theClassname),
58+
header(theHeader),
59+
pixmap(thePixmap),
60+
tooltip(theTooltip),
61+
whatshis(theWhatsThisString)
62+
{}
63+
64+
QString classname;
65+
QString header;
66+
QString pixmap;
67+
QString tooltip;
68+
QString whatshis;
69+
};
70+
71+
Q3ValueList<Entry> mEntriesVector;
72+
73+
const Entry *entry(const QString& theString)
74+
{
75+
for ( uint i = 0; i < mEntriesVector.count(); i++ )
76+
{
77+
if (theString == mEntriesVector[i].classname)
78+
return &mEntriesVector[i];
79+
}
80+
return NULL;
81+
}
82+
}
83+
84+
QgsDesignerWidgets::QgsDesignerWidgets(QObject *parent)
85+
: QObject(parent)
86+
87+
{
88+
mInitialized = false;
89+
90+
mEntriesVector.append(Entry("QgsLegend", "qgslegend.h",
91+
"", "A legend widget that shows layers associated with a mapcanvas.", "A legend widget that shows layers associated with a mapcanvas"));
92+
mEntriesVector.append(Entry("QgsMapCanvas", "qgsmapcanvas.h",
93+
"", "A map canvas widget", "A map canvas is an interactive map that can be panned and zoomed."));
94+
mEntriesVector.append(Entry("QgsLineStyleWidget", "qgslinestylewidget.h",
95+
"", "A widget that lets you select a line style.", "A widget that lets you select a line style"));
96+
mEntriesVector.append(Entry("QgsFillStyleWidget", "qgsfillstylewidget.h",
97+
"", "A widget that lets you select a fill style.", "A widget that lets you select a fill style"));
98+
mEntriesVector.append(Entry("QgsPointStyleWidget", "qgspointstylewidget.h",
99+
"", "A widget that lets you select a point style.", "A widget that lets you select a point style"));
100+
mEntriesVector.append(Entry("QgsVectorSymbologyWidget", "QgsVectorSymbologyWidget",
101+
"", "A widget that lets you select vector symbology.", "A widget that lets you select vector symbology"));
102+
}
103+
104+
105+
void QgsDesignerWidgets::initialize(QDesignerFormEditorInterface * core )
106+
{
107+
if (mInitialized)
108+
return;
109+
110+
mInitialized = true;
111+
}
112+
113+
bool QgsDesignerWidgets::isInitialized() const
114+
{
115+
return mInitialized;
116+
}
117+
118+
QWidget* QgsDesignerWidgets::create(const QString &key,
119+
QWidget* parent, const char* name)
120+
{
121+
if ( key == "QgsLegend" )
122+
return new QgsLegend( parent, name );
123+
else if ( key == "QgsMapCanvas" )
124+
return new QgsMapCanvas ( parent, name );
125+
else if ( key == "QgsLineStyleWidget" )
126+
return new QgsLineStyleWidget ( parent, name );
127+
else if ( key == "QgsFillStyleWidget" )
128+
return new QgsFillStyleWidget ( parent, name );
129+
else if ( key == "QgsPointStyleWidget" )
130+
return new QgsPointStyleWidget ( parent, name );
131+
else if ( key == "QgsVectorSymbologyWidget" )
132+
return new QgsVectorSymbologyWidget( parent, name );
133+
return 0;
134+
}
135+
136+
137+
QStringList QgsDesignerWidgets::keys() const
138+
{
139+
QStringList list;
140+
141+
for (unsigned i = 0; i < mEntriesVector.count(); i++)
142+
list += mEntriesVector[i].classname;
143+
144+
return list;
145+
}
146+
147+
QString QgsDesignerWidgets::group( const QString& feature ) const
148+
{
149+
if (entry(feature) != NULL )
150+
return QString("QGIS");
151+
return QString::null;
152+
}
153+
154+
QIcon QgsDesignerWidgets::iconSet( const QString& thePixmap) const
155+
{
156+
QString pixmapKey("qwtwidget.png");
157+
if (entry(thePixmap) != NULL )
158+
pixmapKey = entry(thePixmap)->pixmap;
159+
160+
const QMimeSource *ms =
161+
Q3MimeSourceFactory::defaultFactory()->data(pixmapKey);
162+
163+
QPixmap pixmap;
164+
Q3ImageDrag::decode(ms, pixmap);
165+
166+
return QIcon(pixmap);
167+
}
168+
169+
QString QgsDesignerWidgets::includeFile( const QString& feature ) const
170+
{
171+
if (entry(feature) != NULL)
172+
return entry(feature)->header;
173+
return QString::null;
174+
}
175+
176+
QString QgsDesignerWidgets::toolTip( const QString& feature ) const
177+
{
178+
if (entry(feature) != NULL )
179+
return entry(feature)->tooltip;
180+
return QString::null;
181+
}
182+
183+
QString QgsDesignerWidgets::whatsThis( const QString& feature ) const
184+
{
185+
if (entry(feature) != NULL)
186+
return entry(feature)->whatshis;
187+
return QString::null;
188+
}
189+
190+
bool QgsDesignerWidgets::isContainer( const QString& ) const
191+
{
192+
return FALSE;
193+
}
194+
195+
/*
196+
The Q_EXPORT_PLUGIN macro.
197+
Q_EXPORT_PLUGIN( CustomWidgetPlugin )
198+
This macro identifies the module as a plugin -- all the other code simply
199+
implements the relevant interface, i.e. wraps the classes you wish to make available.
200+
This macro must appear once in your plugin. It should be copied with the class name
201+
changed to the name of your plugin's class. (See the Qt Plugin documentation for more
202+
information on the plugin entry point.)
203+
Each widget you wrap in a widget plugin implementation becomes a class that the
204+
plugin implementation offers. There is no limit to the number of classes that you
205+
may include in an plugin implementation.
206+
*/
207+
Q_EXPORT_PLUGIN( QgsDesignerWidgets )

‎src/designer/qgsdesignerwidgets.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <QDesignerCustomWidgetInterface>
2+
3+
class QgsDesignerWidgets : public QObject, public QDesignerCustomWidgetInterface
4+
{
5+
Q_OBJECT;
6+
Q_INTERFACES(QDesignerCustomWidgetInterface);
7+
8+
9+
public:
10+
QgsDesignerWidgets(QObject *parent = 0);
11+
void initialize(QDesignerFormEditorInterface *core);
12+
QStringList keys() const;
13+
QWidget* create( const QString &classname, QWidget* parent = 0, const char* name = 0 );
14+
QString group( const QString& ) const;
15+
QIcon iconSet( const QString& ) const;
16+
QString includeFile( const QString& ) const;
17+
QString toolTip( const QString& ) const;
18+
QString whatsThis( const QString& ) const;
19+
bool isContainer( const QString& ) const;
20+
bool isInitialized() const;
21+
private:
22+
bool mInitialized;
23+
};

0 commit comments

Comments
 (0)
Please sign in to comment.