Skip to content
Permalink
Browse files

Merge branch 'master' into sextante-import

  • Loading branch information
alexbruy committed Sep 14, 2012
2 parents 7b80206 + 2a32eca commit c328539479377e2fd45827807018ae70dcc1a1e7
@@ -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

@@ -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,
@@ -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,
@@ -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,
@@ -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() );
@@ -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;
@@ -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();
}
@@ -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() )
{
@@ -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 );
@@ -85,6 +115,7 @@ void QgsCollapsibleGroupBox::showEvent( QShowEvent * event )
still emit signal for connections using expanded state */
emit collapsedStateChanged( this );
}

event->accept();
}

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

@@ -28,6 +28,7 @@
#include <QGroupBox>

class QToolButton;
class QScrollArea;

class GUI_EXPORT QgsCollapsibleGroupBox : public QGroupBox
{
@@ -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();
@@ -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;
@@ -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()
@@ -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() );
@@ -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();
@@ -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()
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit c328539

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