Skip to content
Permalink
Browse files

Extent group box improvements: custom title base, checkable group box

  • Loading branch information
wonder-sk committed Jun 25, 2015
1 parent b452bc0 commit 9e169527329352ec93c928c3ec18779a53c137f8
Showing with 54 additions and 1 deletion.
  1. +9 −0 python/gui/qgsextentgroupbox.sip
  2. +33 −1 src/gui/qgsextentgroupbox.cpp
  3. +12 −0 src/gui/qgsextentgroupbox.h
@@ -44,6 +44,13 @@ class QgsExtentGroupBox : QgsCollapsibleGroupBox

QgsExtentGroupBox::ExtentState extentState() const;

//! Set base part of title of the group box (will be appended with extent state)
//! @note added in 2.12
void setTitleBase( const QString& title );
//! Set base part of title of the group box (will be appended with extent state)
//! @note added in 2.12
QString titleBase() const;

public slots:
//! set output extent to be the same as original extent (may be transformed to output CRS)
void setOutputExtentFromOriginal();
@@ -65,6 +72,8 @@ class QgsExtentGroupBox : QgsCollapsibleGroupBox
void on_mYMinLineEdit_textEdited( const QString & );
void on_mYMaxLineEdit_textEdited( const QString & );

void groupBoxClicked();

protected:
void setOutputExtent( const QgsRectangle& r, const QgsCoordinateReferenceSystem& srcCrs, QgsExtentGroupBox::ExtentState state );
void setOutputExtentFromLineEdit();
@@ -5,6 +5,7 @@

QgsExtentGroupBox::QgsExtentGroupBox( QWidget* parent )
: QgsCollapsibleGroupBox( parent )
, mTitleBase( tr( "Extent" ) )
, mExtentState( OriginalExtent )
{
setupUi( this );
@@ -16,6 +17,7 @@ QgsExtentGroupBox::QgsExtentGroupBox( QWidget* parent )

connect( mCurrentExtentButton, SIGNAL( clicked() ), this, SLOT( setOutputExtentFromCurrent() ) );
connect( mOriginalExtentButton, SIGNAL( clicked() ), this, SLOT( setOutputExtentFromOriginal() ) );
connect( this, SIGNAL( clicked( bool ) ), this, SLOT( groupBoxClicked() ) );
}


@@ -58,6 +60,9 @@ void QgsExtentGroupBox::setOutputExtent( const QgsRectangle& r, const QgsCoordin

mExtentState = state;

if ( isCheckable() && !isChecked() )
setChecked( true );

updateTitle();

emit extentChanged( extent );
@@ -91,7 +96,9 @@ void QgsExtentGroupBox::updateTitle()
default:
break;
}
msg = tr( "Extent (current: %1)" ).arg( msg );
if ( isCheckable() && !isChecked() )
msg = tr( "none" );
msg = tr( "%1 (current: %2)" ).arg( mTitleBase ).arg( msg );

setTitle( msg );
}
@@ -114,9 +121,34 @@ void QgsExtentGroupBox::setOutputExtentFromUser( const QgsRectangle& extent, con
setOutputExtent( extent, crs, UserExtent );
}

void QgsExtentGroupBox::groupBoxClicked()
{
if ( !isCheckable() )
return;

updateTitle();

// output extent just went from null to something (or vice versa)
emit extentChanged( outputExtent() );
}


QgsRectangle QgsExtentGroupBox::outputExtent() const
{
if ( isCheckable() && !isChecked() )
return QgsRectangle();

return QgsRectangle( mXMinLineEdit->text().toDouble(), mYMinLineEdit->text().toDouble(),
mXMaxLineEdit->text().toDouble(), mYMaxLineEdit->text().toDouble() );
}

void QgsExtentGroupBox::setTitleBase(const QString& title)
{
mTitleBase = title;
updateTitle();
}

QString QgsExtentGroupBox::titleBase() const
{
return mTitleBase;
}
@@ -54,6 +54,13 @@ class GUI_EXPORT QgsExtentGroupBox : public QgsCollapsibleGroupBox, private Ui::

ExtentState extentState() const { return mExtentState; }

//! Set base part of title of the group box (will be appended with extent state)
//! @note added in 2.12
void setTitleBase( const QString& title );
//! Set base part of title of the group box (will be appended with extent state)
//! @note added in 2.12
QString titleBase() const;

public slots:
//! set output extent to be the same as original extent (may be transformed to output CRS)
void setOutputExtentFromOriginal();
@@ -75,11 +82,16 @@ class GUI_EXPORT QgsExtentGroupBox : public QgsCollapsibleGroupBox, private Ui::
void on_mYMinLineEdit_textEdited( const QString & ) { setOutputExtentFromLineEdit(); }
void on_mYMaxLineEdit_textEdited( const QString & ) { setOutputExtentFromLineEdit(); }

void groupBoxClicked();

protected:
void setOutputExtent( const QgsRectangle& r, const QgsCoordinateReferenceSystem& srcCrs, ExtentState state );
void setOutputExtentFromLineEdit();
void updateTitle();

//! Base part of the title used for the extent
QString mTitleBase;

ExtentState mExtentState;

QgsCoordinateReferenceSystem mOutputCrs;

0 comments on commit 9e16952

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