Skip to content

Commit

Permalink
Merge branch 'master' into sextante-import
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Sep 14, 2012
2 parents 7b80206 + 2a32eca commit c328539
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 28 deletions.
3 changes: 2 additions & 1 deletion debian/changelog
Expand Up @@ -6,8 +6,9 @@ qgis (1.9.0) UNRELEASED; urgency=low
* symbology-ng-style now in sqlite3
* include cpt-city files
* support DEB_BUILD_OPTIONS' parallel=n
* add python-unittest2 build dependency for lucid, maverick and squeeze

-- Jürgen E. Fischer <jef@norbit.de> Sat, 08 Sep 2012 12:59:40 +0200
-- Jürgen E. Fischer <jef@norbit.de> Fri, 14 Sep 2012 16:53:29 +0200

qgis (1.8.0) UNRELEASED; urgency=low

Expand Down
1 change: 1 addition & 0 deletions debian/control.lucid
Expand Up @@ -29,6 +29,7 @@ Build-Depends:
python-qt4-dev (>=4.1.0),
python-sip (>= 4.5.0),
python-sip-dev (>= 4.5.0),
python-unittest2,
git-core,
doxygen,
graphviz,
Expand Down
1 change: 1 addition & 0 deletions debian/control.maverick
Expand Up @@ -30,6 +30,7 @@ Build-Depends:
python-qt4-dev (>=4.1.0),
python-sip (>= 4.5.0),
python-sip-dev (>= 4.5.0),
python-unittest2,
git,
doxygen,
graphviz,
Expand Down
1 change: 1 addition & 0 deletions debian/control.squeeze
Expand Up @@ -29,6 +29,7 @@ Build-Depends:
python-qt4-dev (>=4.1.0),
python-sip (>= 4.5.0),
python-sip-dev (>= 4.5.0),
python-unittest2,
git,
doxygen,
graphviz,
Expand Down
5 changes: 4 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -4011,7 +4011,10 @@ void QgisApp::saveAsRasterFile()
return;
}

QgsRasterLayerSaveAsDialog d( rasterLayer, rasterLayer->dataProvider(), mMapCanvas->extent(), rasterLayer->crs(), mMapCanvas->mapRenderer()->destinationCrs() );
QgsRasterLayerSaveAsDialog d( rasterLayer, rasterLayer->dataProvider(),
mMapCanvas->extent(), rasterLayer->crs(),
mMapCanvas->mapRenderer()->destinationCrs(),
this );
if ( d.exec() == QDialog::Accepted )
{
QgsRasterFileWriter fileWriter( d.outputFileName() );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsrenderchecker.cpp
Expand Up @@ -98,7 +98,7 @@ bool QgsRenderChecker::isKnownAnomaly( QString theDiffImageFile )
.arg( theDiffImageFile )
.arg( myImageHash );
//foo CDash
QString myMeasureMessage = "<DartMeasurement name=\"Anomoly check"
QString myMeasureMessage = "<DartMeasurement name=\"Anomaly check"
"\" type=\"text/text\">" + myHashMessage +
"</DartMeasurement>";
qDebug() << myMeasureMessage;
Expand Down
102 changes: 92 additions & 10 deletions src/gui/qgscollapsiblegroupbox.cpp
Expand Up @@ -24,19 +24,20 @@
#include <QMouseEvent>
#include <QStyleOptionGroupBox>
#include <QSettings>
#include <QScrollArea>

QIcon QgsCollapsibleGroupBox::mCollapseIcon;
QIcon QgsCollapsibleGroupBox::mExpandIcon;

QgsCollapsibleGroupBox::QgsCollapsibleGroupBox( QWidget *parent )
: QGroupBox( parent ), mCollapsed( false ), mSaveState( true )
: QGroupBox( parent )
{
init();
}

QgsCollapsibleGroupBox::QgsCollapsibleGroupBox( const QString &title,
QWidget *parent )
: QGroupBox( title, parent ), mCollapsed( false ), mSaveState( true )
: QGroupBox( title, parent )
{
init();
}
Expand All @@ -48,6 +49,14 @@ QgsCollapsibleGroupBox::~QgsCollapsibleGroupBox()

void QgsCollapsibleGroupBox::init()
{
// variables
mCollapsed = false;
mSaveState = true;
mInitFlat = false;
mScrollOnExpand = true;
mShown = false;
mParentScrollArea = 0;

// init icons
if ( mCollapseIcon.isNull() )
{
Expand All @@ -70,11 +79,32 @@ void QgsCollapsibleGroupBox::init()

void QgsCollapsibleGroupBox::showEvent( QShowEvent * event )
{
// initialise widget on first show event only
if ( mShown )
{
event->accept();
return;
}
mShown = true;

// check if groupbox was set to flat in Designer or in code
mInitFlat = isFlat();

// find parent QScrollArea - this might not work in complex layouts - should we look deeper?
if ( parent() && parent()->parent() )
mParentScrollArea = dynamic_cast<QScrollArea*>( parent()->parent()->parent() );
else
mParentScrollArea = 0;
if ( mParentScrollArea )
QgsDebugMsg( "found a QScrollArea parent: " + mParentScrollArea->objectName() );
else
QgsDebugMsg( "did not find a QScrollArea parent" );

loadState();

updateStyle();

// expand if needed - any calls to setCollapsed() before only set mCollapsed
// expand if needed - any calls to setCollapsed() before only set mCollapsed, but have UI effect
if ( mCollapsed )
{
setCollapsed( mCollapsed );
Expand All @@ -85,6 +115,7 @@ void QgsCollapsibleGroupBox::showEvent( QShowEvent * event )
still emit signal for connections using expanded state */
emit collapsedStateChanged( this );
}

event->accept();
}

Expand Down Expand Up @@ -152,7 +183,6 @@ void QgsCollapsibleGroupBox::saveState()
{
if ( ! mSaveState )
return;
QgsDebugMsg( "key = " + saveKey() + " objectName = " + objectName() );
QSettings settings;
QString key = saveKey();
settings.setValue( key + "/checked", isChecked() );
Expand All @@ -178,24 +208,66 @@ void QgsCollapsibleGroupBox::updateStyle()
{
setUpdatesEnabled( false );

// customize style sheet
// margin/offset defaults
int marginLeft = 20; // title margin for disclosure triangle
int marginRight = 5; // a little bit of space on the right, to match space on the left
int offsetLeft = 0; // offset for oxygen theme
int offsetTop = 0;
int offsetTop2 = 0; // offset for triangle

// calculate offset if frame overlaps triangle (oxygen theme)
// using an offset of 6 pixels from frame border
if ( QApplication::style()->objectName().toLower() == "oxygen" )
{
QStyleOptionGroupBox box;
initStyleOption( &box );
QRect rectFrame = style()->subControlRect( QStyle::CC_GroupBox, &box,
QStyle::SC_GroupBoxFrame, this );
QRect rectCheckBox = style()->subControlRect( QStyle::CC_GroupBox, &box,
QStyle::SC_GroupBoxCheckBox, this );
if ( rectFrame.left() <= 0 )
offsetLeft = 6 + rectFrame.left();
if ( rectFrame.top() <= 0 )
{
if ( isCheckable() )
{
// if is checkable align with checkbox
offsetTop = ( rectCheckBox.height() / 2 ) -
( mCollapseButton->height() / 2 ) + rectCheckBox.top();
offsetTop2 = offsetTop + 1;
}
else
{
offsetTop = 6 + rectFrame.top();
offsetTop2 = offsetTop;
}
}
}

QgsDebugMsg( QString( "groupbox: %1 style: %2 offset: left=%3 top=%4 top2=%5" ).arg(
objectName() ).arg( QApplication::style()->objectName() ).arg( offsetLeft ).arg( offsetTop ).arg( offsetTop2 ) );

// customize style sheet for collapse/expand button and force left-aligned title
// TODO: move to app stylesheet system, when appropriate
QString ss;
ss += "QgsCollapsibleGroupBox::title {";
ss += " subcontrol-origin: margin;";
ss += " subcontrol-position: top left;";
ss += " margin-left: 20px;"; // offset for disclosure triangle
ss += " margin-right: 5px;"; // a little bit of space on the right, to match space on the left
ss += QString( " margin-left: %1px;" ).arg( marginLeft );
ss += QString( " margin-right: %1px;" ).arg( marginRight );
ss += QString( " left: %1px;" ).arg( offsetLeft );
ss += QString( " top: %1px;" ).arg( offsetTop );
ss += "}";
setStyleSheet( ss );

// clear toolbutton default background and border
// TODO: move to app stylesheet system, when appropriate
// clear toolbutton default background and border and apply offset
QString ssd;
ssd = QString( "QgsCollapsibleGroupBox > QToolButton#%1 {" ).arg( mCollapseButton->objectName() );
ssd += " background-color: rgba(255, 255, 255, 0); border: none;";
ssd += "}";
mCollapseButton->setStyleSheet( ssd );
if ( offsetLeft != 0 || offsetTop2 != 0 )
mCollapseButton->move( offsetLeft, offsetTop2 );

setUpdatesEnabled( true );
}
Expand All @@ -208,14 +280,24 @@ void QgsCollapsibleGroupBox::setCollapsed( bool collapse )
return;

// for consistent look/spacing across platforms when collapsed
setFlat( collapse );
if ( ! mInitFlat ) // skip if initially set to flat in Designer
setFlat( collapse );

// avoid flicker in X11
QApplication::processEvents();

// set maximum height to hide contents - does this work in all envs?
// setMaximumHeight( collapse ? 25 : 16777215 );
setMaximumHeight( collapse ? titleRect().bottom() + 6 : 16777215 );
mCollapseButton->setIcon( collapse ? mExpandIcon : mCollapseIcon );

// if expanding and is in a QScrollArea, scroll down to make entire widget visible
if ( mScrollOnExpand && !collapse && mParentScrollArea )
{
// process events so entire widget is shown
QApplication::processEvents();
mParentScrollArea->ensureWidgetVisible( this );
}
emit collapsedStateChanged( this );
}

12 changes: 11 additions & 1 deletion src/gui/qgscollapsiblegroupbox.h
Expand Up @@ -28,6 +28,7 @@
#include <QGroupBox>

class QToolButton;
class QScrollArea;

class GUI_EXPORT QgsCollapsibleGroupBox : public QGroupBox
{
Expand All @@ -37,17 +38,21 @@ class GUI_EXPORT QgsCollapsibleGroupBox : public QGroupBox
QgsCollapsibleGroupBox( QWidget *parent = 0 );
QgsCollapsibleGroupBox( const QString &title, QWidget *parent = 0 );
~QgsCollapsibleGroupBox();

bool isCollapsed() const { return mCollapsed; }
void setCollapsed( bool collapse );

//! set this to false to not save/restore check and collapse state
void setSaveState( bool save ) { mSaveState = save; }
//! set this to false to not automatically scroll parent QScrollArea to this widget's contents when expanded
void setScrollOnExpand( bool scroll ) { mScrollOnExpand = scroll; }

signals:
void collapsedStateChanged( QWidget* );

public slots:
void checkToggled( bool ckd );
void toggleCollapsed();
void updateStyle();

protected slots:
void loadState();
Expand All @@ -57,11 +62,16 @@ class GUI_EXPORT QgsCollapsibleGroupBox : public QGroupBox
void init();
void showEvent( QShowEvent *event );
void mouseReleaseEvent( QMouseEvent *event );
void updateStyle();
QRect titleRect() const;
QString saveKey() const;

bool mCollapsed;
bool mSaveState;
bool mInitFlat;
bool mScrollOnExpand;
bool mShown;
QScrollArea* mParentScrollArea;
QToolButton* mCollapseButton;

static QIcon mCollapseIcon;
Expand Down
11 changes: 0 additions & 11 deletions src/gui/qgsrasterlayersaveasdialog.cpp
Expand Up @@ -106,11 +106,6 @@ QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterLayer* rasterLa
{
okButton->setEnabled( false );
}

// this should scroll down to make widget visible, but it's not happening
// (at least part of it is visible)...
connect( mCreateOptionsGroupBox, SIGNAL( collapsedStateChanged( QWidget* ) ),
this, SLOT( groupBoxExpanded( QWidget* ) ) );
}

void QgsRasterLayerSaveAsDialog::setValidators()
Expand Down Expand Up @@ -529,12 +524,6 @@ void QgsRasterLayerSaveAsDialog::on_mRawModeRadioButton_toggled( bool checked )
mNoDataGroupBox->setEnabled( checked && mDataProvider->bandCount() == 1 );
}

void QgsRasterLayerSaveAsDialog::groupBoxExpanded( QWidget * widget )
{
if ( !mCreateOptionsGroupBox->isCollapsed() )
mScrollArea->ensureWidgetVisible( widget );
}

void QgsRasterLayerSaveAsDialog::on_mAddNoDataManuallyToolButton_clicked()
{
addNoDataRow( std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN() );
Expand Down
1 change: 0 additions & 1 deletion src/gui/qgsrasterlayersaveasdialog.h
Expand Up @@ -92,7 +92,6 @@ class GUI_EXPORT QgsRasterLayerSaveAsDialog: public QDialog, private Ui::QgsRast

void on_mCrsComboBox_currentIndexChanged( int ) { crsChanged(); }

void groupBoxExpanded( QWidget * widget );
void on_mAddNoDataManuallyToolButton_clicked();
void on_mLoadTransparentNoDataToolButton_clicked();
void on_mRemoveSelectedNoDataToolButton_clicked();
Expand Down
9 changes: 7 additions & 2 deletions tests/src/python/test_qgscoordinatetransform.py
Expand Up @@ -23,11 +23,16 @@ def testTransformBoundingBox(self):
myProjectedExtent = myXForm.transformBoundingBox(myExtent)
myExpectedExtent = ('150.1509239873580270,-35.7176936443908772 : '
'150.1964384662953194,-35.6971885216629090')
myExpectedValues = [150.1509239873580270,-35.7176936443908772,
150.1964384662953194,-35.6971885216629090]
myMessage = ('Expected:\n%s\nGot:\n%s\n' %
( myExpectedExtent,
myProjectedExtent.toString()))

self.assertEquals(myExpectedExtent, myProjectedExtent.toString(), myMessage)

self.assertAlmostEqual(myExpectedValues[0], myProjectedExtent.xMinimum(), msg=myMessage)
self.assertAlmostEqual(myExpectedValues[1], myProjectedExtent.yMinimum(), msg=myMessage)
self.assertAlmostEqual(myExpectedValues[2], myProjectedExtent.xMaximum(), msg=myMessage)
self.assertAlmostEqual(myExpectedValues[3], myProjectedExtent.yMaximum(), msg=myMessage)

if __name__ == '__main__':
unittest.main()
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c328539

Please sign in to comment.