Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
prepare commit & coding style
  • Loading branch information
olivierdalang committed May 15, 2019
1 parent 9029d7e commit d32a319
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 43 deletions.
39 changes: 27 additions & 12 deletions python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in
Expand Up @@ -42,6 +42,11 @@ by implementing filters called from QgsMapToolAdvancedDigitizing.
Parallel
};

enum WidgetSetMode
{
ReturnPressed,
};


class CadConstraint
{
Expand Down Expand Up @@ -332,10 +337,12 @@ Updates canvas item that displays constraints on the ma
.. versionadded:: 3.0
%End

void setX( const QString &value );
void setX( const QString &value, WidgetSetMode mode );
%Docstring
Set and lock the X ``value``.
Can be used to set constraints.
Set the X ``value`` on the widget.
Can be used to set constraints by external widgets.

:param mode: What type of interaction to emulate

.. note::

Expand All @@ -344,10 +351,12 @@ Can be used to set constraints.
.. versionadded:: 3.8
%End

void setY( const QString &value );
void setY( const QString &value, WidgetSetMode mode );
%Docstring
Set and lock the Y ``value``.
Can be used to set constraints.
Set the Y ``value`` on the widget.
Can be used to set constraints by external widgets.

:param mode: What type of interaction to emulate

.. note::

Expand All @@ -356,10 +365,12 @@ Can be used to set constraints.
.. versionadded:: 3.8
%End

void setAngle( const QString &value );
void setAngle( const QString &value, WidgetSetMode mode );
%Docstring
Set and lock the angle ``value``.
Can be used to set constraints.
Set the angle ``value`` on the widget.
Can be used to set constraints by external widgets.

:param mode: What type of interaction to emulate

.. note::

Expand All @@ -368,10 +379,12 @@ Can be used to set constraints.
.. versionadded:: 3.8
%End

void setDistance( const QString &value );
void setDistance( const QString &value, WidgetSetMode mode );
%Docstring
Set and lock the distance ``value``.
Can be used to set constraints.
Set the distance ``value`` on the widget.
Can be used to set constraints by external widgets.

:param mode: What type of interaction to emulate

.. note::

Expand All @@ -380,6 +393,8 @@ Can be used to set constraints.
.. versionadded:: 3.8
%End



signals:

void pushWarning( const QString &message );
Expand Down
60 changes: 36 additions & 24 deletions src/gui/qgsadvanceddigitizingdockwidget.cpp
Expand Up @@ -165,57 +165,69 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas *
void QgsAdvancedDigitizingDockWidget::setX( const QString &value, WidgetSetMode mode )
{
mXLineEdit->setText( value );
if( mode == WidgetSetMode::ReturnPressed){
if ( mode == WidgetSetMode::ReturnPressed )
{
mXLineEdit->returnPressed();
}
else if ( mode == WidgetSetMode::FocusOut){
QEvent *e = new QEvent(QEvent::FocusOut);
QCoreApplication::postEvent(mXLineEdit, e);
else if ( mode == WidgetSetMode::FocusOut )
{
QEvent *e = new QEvent( QEvent::FocusOut );
QCoreApplication::postEvent( mXLineEdit, e );
}
else if ( mode == WidgetSetMode::TextEdited){
mXLineEdit->textEdited(value);
else if ( mode == WidgetSetMode::TextEdited )
{
mXLineEdit->textEdited( value );
}
}
void QgsAdvancedDigitizingDockWidget::setY( const QString &value, WidgetSetMode mode )
{
mYLineEdit->setText( value );
if( mode == WidgetSetMode::ReturnPressed){
if ( mode == WidgetSetMode::ReturnPressed )
{
mYLineEdit->returnPressed();
}
else if ( mode == WidgetSetMode::FocusOut){
QEvent *e = new QEvent(QEvent::FocusOut);
QCoreApplication::postEvent(mYLineEdit, e);
else if ( mode == WidgetSetMode::FocusOut )
{
QEvent *e = new QEvent( QEvent::FocusOut );
QCoreApplication::postEvent( mYLineEdit, e );
}
else if ( mode == WidgetSetMode::TextEdited){
mYLineEdit->textEdited(value);
else if ( mode == WidgetSetMode::TextEdited )
{
mYLineEdit->textEdited( value );
}
}
void QgsAdvancedDigitizingDockWidget::setAngle( const QString &value, WidgetSetMode mode )
{
mAngleLineEdit->setText( value );
if( mode == WidgetSetMode::ReturnPressed){
if ( mode == WidgetSetMode::ReturnPressed )
{
mAngleLineEdit->returnPressed();
}
else if ( mode == WidgetSetMode::FocusOut){
QEvent *e = new QEvent(QEvent::FocusOut);
QCoreApplication::postEvent(mAngleLineEdit, e);
else if ( mode == WidgetSetMode::FocusOut )
{
QEvent *e = new QEvent( QEvent::FocusOut );
QCoreApplication::postEvent( mAngleLineEdit, e );
}
else if ( mode == WidgetSetMode::TextEdited){
mAngleLineEdit->textEdited(value);
else if ( mode == WidgetSetMode::TextEdited )
{
mAngleLineEdit->textEdited( value );
}
}
void QgsAdvancedDigitizingDockWidget::setDistance( const QString &value, WidgetSetMode mode )
{
mDistanceLineEdit->setText( value );
if( mode == WidgetSetMode::ReturnPressed){
if ( mode == WidgetSetMode::ReturnPressed )
{
mDistanceLineEdit->returnPressed();
}
else if ( mode == WidgetSetMode::FocusOut){
QEvent *e = new QEvent(QEvent::FocusOut);
QCoreApplication::postEvent(mDistanceLineEdit, e);
else if ( mode == WidgetSetMode::FocusOut )
{
QEvent *e = new QEvent( QEvent::FocusOut );
QCoreApplication::postEvent( mDistanceLineEdit, e );
}
else if ( mode == WidgetSetMode::TextEdited){
mDistanceLineEdit->textEdited(value);
else if ( mode == WidgetSetMode::TextEdited )
{
mDistanceLineEdit->textEdited( value );
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/gui/qgsadvanceddigitizingdockwidget.h
Expand Up @@ -77,7 +77,8 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private
/**
* Type of interaction to simulate when editing values from external widget
*/
enum WidgetSetMode {
enum WidgetSetMode
{
ReturnPressed, FocusOut, TextEdited
};

Expand Down
8 changes: 4 additions & 4 deletions src/gui/qgsadvanceddigitizingfloater.cpp
Expand Up @@ -85,13 +85,13 @@ QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater( QgsMapCanvas *canvas
connect( mDistanceLineEdit, &QLineEdit::textEdited, cadDockWidget, [ = ]() { cadDockWidget->setDistance( mDistanceLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); } );

QgsFocusWatcher *xWatcher = new QgsFocusWatcher( mXLineEdit );
connect( xWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [=](){ cadDockWidget->setX( mXLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
connect( xWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->setX( mXLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
QgsFocusWatcher *yWatcher = new QgsFocusWatcher( mYLineEdit );
connect( yWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [=](){ cadDockWidget->setY( mYLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
connect( yWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->setY( mYLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
QgsFocusWatcher *angleWatcher = new QgsFocusWatcher( mAngleLineEdit );
connect( angleWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [=](){ cadDockWidget->setAngle( mAngleLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
connect( angleWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->setAngle( mAngleLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
QgsFocusWatcher *distanceWatcher = new QgsFocusWatcher( mDistanceLineEdit );
connect( distanceWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [=](){ cadDockWidget->setDistance( mDistanceLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
connect( distanceWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->setDistance( mDistanceLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );

}

Expand Down
5 changes: 3 additions & 2 deletions src/gui/qgsadvanceddigitizingfloater.h
Expand Up @@ -32,6 +32,7 @@ class QgsAdvancedDigitizingDockWidget;
* \brief The QgsAdvancedDigitizingFloater class is widget that floats
* next to the mouse pointer, and allow interaction with the AdvancedDigitizing
* feature. It proxies display and actions to QgsMapToolAdvancedDigitizingDockWidget.
* \since QGIS 3.8
*/
class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsAdvancedDigitizingFloaterBase
{
Expand All @@ -53,9 +54,9 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA
/**
* Set whether the floater should be active or not.
* Note that the floater may be active but not visible (e.g. if the mouse is not over the canvas).
* \since QGIS 3.8
*
* \param active
* \since QGIS 3.8
*/
void setActive( bool active );

Expand Down Expand Up @@ -97,7 +98,7 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA
bool eventFilter( QObject *obj, QEvent *event ) override SIP_SKIP;

/**
* Move the widget to a new cursor position. A hard-coded offet will be added.
* Move the widget to a new cursor position. A hard-coded offset will be added.
* \param pos position of the cursor
*/
void updatePos( const QPoint &pos );
Expand Down

0 comments on commit d32a319

Please sign in to comment.