Skip to content

Commit

Permalink
relation editor: use a public constructor, remove UI file
Browse files Browse the repository at this point in the history
rename file according to class name
  • Loading branch information
3nids authored and m-kuhn committed Aug 27, 2014
1 parent 4b8288c commit c243c58
Show file tree
Hide file tree
Showing 8 changed files with 317 additions and 425 deletions.
6 changes: 3 additions & 3 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ qgsrasterformatsaveoptionswidget.cpp
qgsrasterlayersaveasdialog.cpp
qgsrasterpyramidsoptionswidget.cpp
qgsrelationadddlg.cpp
qgsrelationeditor.cpp
qgsrelationeditorwidget.cpp
qgsrelationmanagerdialog.cpp
qgsrubberband.cpp
qgsscalecombobox.cpp
Expand Down Expand Up @@ -392,7 +392,7 @@ qgsrasterformatsaveoptionswidget.h
qgsrasterlayersaveasdialog.h
qgsrasterpyramidsoptionswidget.h
qgsrelationadddlg.h
qgsrelationeditor.h
qgsrelationeditorwidget.h
qgsrelationmanagerdialog.h
qgsscalecombobox.h
qgsscalerangewidget.h
Expand Down Expand Up @@ -467,7 +467,7 @@ qgsmessageviewer.h
qgsoptionsdialogbase.h
qgsowssourceselect.h
qgsprojectionselector.h
qgsrelationeditor.h
qgsrelationeditorwidget.h
qgsrubberband.h
qgsscalecombobox.h
qgsscalerangewidget.h
Expand Down
23 changes: 15 additions & 8 deletions src/gui/editorwidgets/qgsrelationwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,38 @@

#include "qgsrelationwidgetwrapper.h"

#include "qgsrelationeditor.h"
#include "qgsrelationeditorwidget.h"

#include <QWidget>

QgsRelationWidgetWrapper::QgsRelationWidgetWrapper( QgsVectorLayer* vl, const QgsRelation& relation, QWidget* editor, QWidget* parent )
: QgsWidgetWrapper( vl, editor, parent )
, mRelation( relation )
, mRelationWidget( 0 )
, mWidget( NULL )
{
initWidget(editor);
}

QWidget* QgsRelationWidgetWrapper::createWidget( QWidget* parent )
{
return new QWidget( parent );
return new QgsRelationEditorWidget( parent );
}

void QgsRelationWidgetWrapper::setFeature( const QgsFeature& feature )
{
delete( mRelationWidget );
mRelationWidget = QgsRelationEditorWidget::createRelationEditor( mRelation, feature, context(), widget() );
widget()->layout()->addWidget( mRelationWidget );
if ( mWidget )
mWidget->setRelationFeature( mRelation, feature, context() );
}

void QgsRelationWidgetWrapper::initWidget( QWidget* editor )
{
if ( !editor->layout() )
editor->setLayout( new QGridLayout( editor ) );
QgsRelationEditorWidget* w = dynamic_cast<QgsRelationEditorWidget*>( editor );

// if the editor cannot be cast to relation editor, insert a new one
if ( !w )
{
w = new QgsRelationEditorWidget( editor );
}

mWidget = w;
}
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsrelationwidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GUI_EXPORT QgsRelationWidgetWrapper : public QgsWidgetWrapper

private:
QgsRelation mRelation;
QgsRelationEditorWidget* mRelationWidget;
QgsRelationEditorWidget* mWidget;
};

#endif // QGSRELATIONWIDGETWRAPPER_H
2 changes: 1 addition & 1 deletion src/gui/qgsattributeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "qgslonglongvalidator.h"
#include "qgsmaplayerregistry.h"
#include "qgsnetworkaccessmanager.h"
#include "qgsrelationeditor.h"
#include "qgsrelationeditorwidget.h"
#include "qgsrelationmanager.h"
#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"
Expand Down
183 changes: 0 additions & 183 deletions src/gui/qgsrelationeditor.cpp

This file was deleted.

Loading

0 comments on commit c243c58

Please sign in to comment.