Skip to content

Commit 9b01b2e

Browse files
committedNov 8, 2014
Fix dual view test
* References commit 51e01d6 * And issue #11529
1 parent 1871a4c commit 9b01b2e

File tree

5 files changed

+64
-67
lines changed

5 files changed

+64
-67
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -270,22 +270,6 @@
270270

271271
// Editor widgets
272272
#include "qgseditorwidgetregistry.h"
273-
#include "qgsclassificationwidgetwrapperfactory.h"
274-
#include "qgsrangewidgetfactory.h"
275-
#include "qgsuniquevaluewidgetfactory.h"
276-
#include "qgsfilenamewidgetfactory.h"
277-
#include "qgsvaluemapwidgetfactory.h"
278-
#include "qgsenumerationwidgetfactory.h"
279-
#include "qgshiddenwidgetfactory.h"
280-
#include "qgscheckboxwidgetfactory.h"
281-
#include "qgstexteditwidgetfactory.h"
282-
#include "qgsvaluerelationwidgetfactory.h"
283-
#include "qgsuuidwidgetfactory.h"
284-
#include "qgsphotowidgetfactory.h"
285-
#include "qgswebviewwidgetfactory.h"
286-
#include "qgscolorwidgetfactory.h"
287-
#include "qgsrelationreferencefactory.h"
288-
#include "qgsdatetimeeditfactory.h"
289273

290274
//
291275
// Conditional Includes
@@ -665,23 +649,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
665649
mVectorLayerTools = new QgsGuiVectorLayerTools();
666650

667651
// Init the editor widget types
668-
QgsEditorWidgetRegistry* editorWidgetRegistry = QgsEditorWidgetRegistry::instance();
669-
editorWidgetRegistry->registerWidget( "Classification", new QgsClassificationWidgetWrapperFactory( tr( "Classification" ) ) );
670-
editorWidgetRegistry->registerWidget( "Range", new QgsRangeWidgetFactory( tr( "Range" ) ) );
671-
editorWidgetRegistry->registerWidget( "UniqueValues", new QgsUniqueValueWidgetFactory( tr( "Unique Values" ) ) );
672-
editorWidgetRegistry->registerWidget( "FileName", new QgsFileNameWidgetFactory( tr( "File Name" ) ) );
673-
editorWidgetRegistry->registerWidget( "ValueMap", new QgsValueMapWidgetFactory( tr( "Value Map" ) ) );
674-
editorWidgetRegistry->registerWidget( "Enumeration", new QgsEnumerationWidgetFactory( tr( "Enumeration" ) ) );
675-
editorWidgetRegistry->registerWidget( "Hidden", new QgsHiddenWidgetFactory( tr( "Hidden" ) ) );
676-
editorWidgetRegistry->registerWidget( "CheckBox", new QgsCheckboxWidgetFactory( tr( "Check Box" ) ) );
677-
editorWidgetRegistry->registerWidget( "TextEdit", new QgsTextEditWidgetFactory( tr( "Text Edit" ) ) );
678-
editorWidgetRegistry->registerWidget( "ValueRelation", new QgsValueRelationWidgetFactory( tr( "Value Relation" ) ) );
679-
editorWidgetRegistry->registerWidget( "UuidGenerator", new QgsUuidWidgetFactory( tr( "Uuid Generator" ) ) );
680-
editorWidgetRegistry->registerWidget( "Photo", new QgsPhotoWidgetFactory( tr( "Photo" ) ) );
681-
editorWidgetRegistry->registerWidget( "WebView", new QgsWebViewWidgetFactory( tr( "Web View" ) ) );
682-
editorWidgetRegistry->registerWidget( "Color", new QgsColorWidgetFactory( tr( "Color" ) ) );
683-
editorWidgetRegistry->registerWidget( "RelationReference", new QgsRelationReferenceFactory( tr( "Relation Reference" ), mMapCanvas, mInfoBar ) );
684-
editorWidgetRegistry->registerWidget( "DateTime", new QgsDateTimeEditFactory( tr( "Date/Time" ) ) );
652+
QgsEditorWidgetRegistry::initEditors( mMapCanvas, mInfoBar );
685653

686654
mInternalClipboard = new QgsClipboard; // create clipboard
687655
connect( mInternalClipboard, SIGNAL( changed() ), this, SLOT( clipboardChanged() ) );

‎src/browser/main.cpp

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,6 @@
2929
#include <qmainwindow.h>
3030

3131
#include "qgseditorwidgetregistry.h"
32-
#include "qgsclassificationwidgetwrapperfactory.h"
33-
#include "qgsrangewidgetfactory.h"
34-
#include "qgsuniquevaluewidgetfactory.h"
35-
#include "qgsfilenamewidgetfactory.h"
36-
#include "qgsvaluemapwidgetfactory.h"
37-
#include "qgsenumerationwidgetfactory.h"
38-
#include "qgshiddenwidgetfactory.h"
39-
#include "qgscheckboxwidgetfactory.h"
40-
#include "qgstexteditwidgetfactory.h"
41-
#include "qgsvaluerelationwidgetfactory.h"
42-
#include "qgsuuidwidgetfactory.h"
43-
#include "qgsphotowidgetfactory.h"
44-
#include "qgswebviewwidgetfactory.h"
45-
#include "qgscolorwidgetfactory.h"
46-
#include "qgsrelationreferencefactory.h"
47-
#include "qgsdatetimeeditfactory.h"
4832

4933
int main( int argc, char ** argv )
5034
{
@@ -76,23 +60,7 @@ int main( int argc, char ** argv )
7660

7761
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
7862

79-
QgsEditorWidgetRegistry* editorWidgetRegistry = QgsEditorWidgetRegistry::instance();
80-
editorWidgetRegistry->registerWidget( "Classification", new QgsClassificationWidgetWrapperFactory( QObject::tr( "Classification" ) ) );
81-
editorWidgetRegistry->registerWidget( "Range", new QgsRangeWidgetFactory( QObject::tr( "Range" ) ) );
82-
editorWidgetRegistry->registerWidget( "UniqueValues", new QgsUniqueValueWidgetFactory( QObject::tr( "Unique Values" ) ) );
83-
editorWidgetRegistry->registerWidget( "FileName", new QgsFileNameWidgetFactory( QObject::tr( "File Name" ) ) );
84-
editorWidgetRegistry->registerWidget( "ValueMap", new QgsValueMapWidgetFactory( QObject::tr( "Value Map" ) ) );
85-
editorWidgetRegistry->registerWidget( "Enumeration", new QgsEnumerationWidgetFactory( QObject::tr( "Enumeration" ) ) );
86-
editorWidgetRegistry->registerWidget( "Hidden", new QgsHiddenWidgetFactory( QObject::tr( "Hidden" ) ) );
87-
editorWidgetRegistry->registerWidget( "CheckBox", new QgsCheckboxWidgetFactory( QObject::tr( "Check Box" ) ) );
88-
editorWidgetRegistry->registerWidget( "TextEdit", new QgsTextEditWidgetFactory( QObject::tr( "Text Edit" ) ) );
89-
editorWidgetRegistry->registerWidget( "ValueRelation", new QgsValueRelationWidgetFactory( QObject::tr( "Value Relation" ) ) );
90-
editorWidgetRegistry->registerWidget( "UuidGenerator", new QgsUuidWidgetFactory( QObject::tr( "Uuid Generator" ) ) );
91-
editorWidgetRegistry->registerWidget( "Photo", new QgsPhotoWidgetFactory( QObject::tr( "Photo" ) ) );
92-
editorWidgetRegistry->registerWidget( "WebView", new QgsWebViewWidgetFactory( QObject::tr( "Web View" ) ) );
93-
editorWidgetRegistry->registerWidget( "Color", new QgsColorWidgetFactory( QObject::tr( "Color" ) ) );
94-
editorWidgetRegistry->registerWidget( "RelationReference", new QgsRelationReferenceFactory( QObject::tr( "Relation Reference" ), 0, 0 ) );
95-
editorWidgetRegistry->registerWidget( "DateTime", new QgsDateTimeEditFactory( QObject::tr( "Date/Time" ) ) );
63+
QgsEditorWidgetRegistry::initEditors();
9664

9765
return a.exec();
9866
}

‎src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,51 @@
2323
#include "qgsvectorlayer.h"
2424
#include "qgsmaplayerregistry.h"
2525

26+
// Editors
27+
#include "qgsclassificationwidgetwrapperfactory.h"
28+
#include "qgsrangewidgetfactory.h"
29+
#include "qgsuniquevaluewidgetfactory.h"
30+
#include "qgsfilenamewidgetfactory.h"
31+
#include "qgsvaluemapwidgetfactory.h"
32+
#include "qgsenumerationwidgetfactory.h"
33+
#include "qgshiddenwidgetfactory.h"
34+
#include "qgscheckboxwidgetfactory.h"
35+
#include "qgstexteditwidgetfactory.h"
36+
#include "qgsvaluerelationwidgetfactory.h"
37+
#include "qgsuuidwidgetfactory.h"
38+
#include "qgsphotowidgetfactory.h"
39+
#include "qgswebviewwidgetfactory.h"
40+
#include "qgscolorwidgetfactory.h"
41+
#include "qgsrelationreferencefactory.h"
42+
#include "qgsdatetimeeditfactory.h"
43+
2644
QgsEditorWidgetRegistry* QgsEditorWidgetRegistry::instance()
2745
{
2846
static QgsEditorWidgetRegistry sInstance;
2947
return &sInstance;
3048
}
3149

50+
void QgsEditorWidgetRegistry::initEditors( QgsMapCanvas* mapCanvas, QgsMessageBar* messageBar )
51+
{
52+
QgsEditorWidgetRegistry* reg = instance();
53+
reg->registerWidget( "Classification", new QgsClassificationWidgetWrapperFactory( tr( "Classification" ) ) );
54+
reg->registerWidget( "Range", new QgsRangeWidgetFactory( tr( "Range" ) ) );
55+
reg->registerWidget( "UniqueValues", new QgsUniqueValueWidgetFactory( tr( "Unique Values" ) ) );
56+
reg->registerWidget( "FileName", new QgsFileNameWidgetFactory( tr( "File Name" ) ) );
57+
reg->registerWidget( "ValueMap", new QgsValueMapWidgetFactory( tr( "Value Map" ) ) );
58+
reg->registerWidget( "Enumeration", new QgsEnumerationWidgetFactory( tr( "Enumeration" ) ) );
59+
reg->registerWidget( "Hidden", new QgsHiddenWidgetFactory( tr( "Hidden" ) ) );
60+
reg->registerWidget( "CheckBox", new QgsCheckboxWidgetFactory( tr( "Check Box" ) ) );
61+
reg->registerWidget( "TextEdit", new QgsTextEditWidgetFactory( tr( "Text Edit" ) ) );
62+
reg->registerWidget( "ValueRelation", new QgsValueRelationWidgetFactory( tr( "Value Relation" ) ) );
63+
reg->registerWidget( "UuidGenerator", new QgsUuidWidgetFactory( tr( "Uuid Generator" ) ) );
64+
reg->registerWidget( "Photo", new QgsPhotoWidgetFactory( tr( "Photo" ) ) );
65+
reg->registerWidget( "WebView", new QgsWebViewWidgetFactory( tr( "Web View" ) ) );
66+
reg->registerWidget( "Color", new QgsColorWidgetFactory( tr( "Color" ) ) );
67+
reg->registerWidget( "RelationReference", new QgsRelationReferenceFactory( tr( "Relation Reference" ), mapCanvas, messageBar ) );
68+
reg->registerWidget( "DateTime", new QgsDateTimeEditFactory( tr( "Date/Time" ) ) );
69+
}
70+
3271
QgsEditorWidgetRegistry::QgsEditorWidgetRegistry()
3372
{
3473
connect( QgsProject::instance(), SIGNAL( readMapLayer( QgsMapLayer*, const QDomElement& ) ), this, SLOT( readMapLayer( QgsMapLayer*, const QDomElement& ) ) );

‎src/gui/editorwidgets/core/qgseditorwidgetregistry.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
class QgsMapLayer;
2525
class QDomNode;
26+
class QgsMapCanvas;
27+
class QgsMessageBar;
2628

2729
/**
2830
* This class manages all known edit widget factories
@@ -36,9 +38,27 @@ class GUI_EXPORT QgsEditorWidgetRegistry : public QObject
3638
* This class is a singleton and has therefore to be accessed with this method instead
3739
* of a constructor.
3840
*
39-
* @return
41+
* @return The one and only instance of the editor widget registry
4042
*/
4143
static QgsEditorWidgetRegistry* instance();
44+
45+
/**
46+
* Registers all the default widgets.
47+
* Only call this once on startup of an application.
48+
*
49+
* @param mapCanvas Specify a map canvas with which the widgets (relation reference) work
50+
* @param messageBar Specify a message bar on which messages by widgets will be shown while working with the map canvas
51+
*
52+
* @note Added in QGIS 2.8
53+
* @note Not required for plugins, the QGIS application does that already
54+
*/
55+
static void initEditors( QgsMapCanvas* mapCanvas = 0, QgsMessageBar* messageBar = 0 );
56+
57+
/**
58+
* Destructor
59+
*
60+
* Deletes all the registered widgets
61+
*/
4262
~QgsEditorWidgetRegistry();
4363

4464
/**

‎tests/src/gui/testqgsdualview.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <QtTest>
1818

19+
#include <editorwidgets/core/qgseditorwidgetregistry.h>
1920
#include <attributetable/qgsattributetableview.h>
2021
#include <attributetable/qgsdualview.h>
2122
#include <qgsapplication.h>
@@ -46,6 +47,7 @@ void TestQgsDualView::initTestCase()
4647
QgsApplication::init();
4748
QgsApplication::initQgis();
4849
QgsApplication::showSettings();
50+
QgsEditorWidgetRegistry::initEditors();
4951

5052
// Setup a map canvas with a vector layer loaded...
5153
QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt

0 commit comments

Comments
 (0)
Please sign in to comment.