Skip to content
Permalink
Browse files

prepare commit & coding style

  • Loading branch information
olivierdalang committed May 15, 2019
1 parent 9029d7e commit d32a319d2f3a15c15ec24c398efd54b3c1de44fc
@@ -42,6 +42,11 @@ by implementing filters called from QgsMapToolAdvancedDigitizing.
Parallel
};

enum WidgetSetMode
{
ReturnPressed,
};


class CadConstraint
{
@@ -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::

@@ -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::

@@ -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::

@@ -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::

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



signals:

void pushWarning( const QString &message );
@@ -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 );
}
}

@@ -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
};

@@ -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 ); } );

}

@@ -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
{
@@ -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 );

@@ -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 );

0 comments on commit d32a319

Please sign in to comment.
You can’t perform that action at this time.