Skip to content

Commit c328539

Browse files
committed
Merge branch 'master' into sextante-import
2 parents 7b80206 + 2a32eca commit c328539

File tree

14 files changed

+120
-28
lines changed

14 files changed

+120
-28
lines changed

debian/changelog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ qgis (1.9.0) UNRELEASED; urgency=low
66
* symbology-ng-style now in sqlite3
77
* include cpt-city files
88
* support DEB_BUILD_OPTIONS' parallel=n
9+
* add python-unittest2 build dependency for lucid, maverick and squeeze
910

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

1213
qgis (1.8.0) UNRELEASED; urgency=low
1314

debian/control.lucid

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Build-Depends:
2929
python-qt4-dev (>=4.1.0),
3030
python-sip (>= 4.5.0),
3131
python-sip-dev (>= 4.5.0),
32+
python-unittest2,
3233
git-core,
3334
doxygen,
3435
graphviz,

debian/control.maverick

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Build-Depends:
3030
python-qt4-dev (>=4.1.0),
3131
python-sip (>= 4.5.0),
3232
python-sip-dev (>= 4.5.0),
33+
python-unittest2,
3334
git,
3435
doxygen,
3536
graphviz,

debian/control.squeeze

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Build-Depends:
2929
python-qt4-dev (>=4.1.0),
3030
python-sip (>= 4.5.0),
3131
python-sip-dev (>= 4.5.0),
32+
python-unittest2,
3233
git,
3334
doxygen,
3435
graphviz,

src/app/qgisapp.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4011,7 +4011,10 @@ void QgisApp::saveAsRasterFile()
40114011
return;
40124012
}
40134013

4014-
QgsRasterLayerSaveAsDialog d( rasterLayer, rasterLayer->dataProvider(), mMapCanvas->extent(), rasterLayer->crs(), mMapCanvas->mapRenderer()->destinationCrs() );
4014+
QgsRasterLayerSaveAsDialog d( rasterLayer, rasterLayer->dataProvider(),
4015+
mMapCanvas->extent(), rasterLayer->crs(),
4016+
mMapCanvas->mapRenderer()->destinationCrs(),
4017+
this );
40154018
if ( d.exec() == QDialog::Accepted )
40164019
{
40174020
QgsRasterFileWriter fileWriter( d.outputFileName() );

src/core/qgsrenderchecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ bool QgsRenderChecker::isKnownAnomaly( QString theDiffImageFile )
9898
.arg( theDiffImageFile )
9999
.arg( myImageHash );
100100
//foo CDash
101-
QString myMeasureMessage = "<DartMeasurement name=\"Anomoly check"
101+
QString myMeasureMessage = "<DartMeasurement name=\"Anomaly check"
102102
"\" type=\"text/text\">" + myHashMessage +
103103
"</DartMeasurement>";
104104
qDebug() << myMeasureMessage;

src/gui/qgscollapsiblegroupbox.cpp

Lines changed: 92 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,20 @@
2424
#include <QMouseEvent>
2525
#include <QStyleOptionGroupBox>
2626
#include <QSettings>
27+
#include <QScrollArea>
2728

2829
QIcon QgsCollapsibleGroupBox::mCollapseIcon;
2930
QIcon QgsCollapsibleGroupBox::mExpandIcon;
3031

3132
QgsCollapsibleGroupBox::QgsCollapsibleGroupBox( QWidget *parent )
32-
: QGroupBox( parent ), mCollapsed( false ), mSaveState( true )
33+
: QGroupBox( parent )
3334
{
3435
init();
3536
}
3637

3738
QgsCollapsibleGroupBox::QgsCollapsibleGroupBox( const QString &title,
3839
QWidget *parent )
39-
: QGroupBox( title, parent ), mCollapsed( false ), mSaveState( true )
40+
: QGroupBox( title, parent )
4041
{
4142
init();
4243
}
@@ -48,6 +49,14 @@ QgsCollapsibleGroupBox::~QgsCollapsibleGroupBox()
4849

4950
void QgsCollapsibleGroupBox::init()
5051
{
52+
// variables
53+
mCollapsed = false;
54+
mSaveState = true;
55+
mInitFlat = false;
56+
mScrollOnExpand = true;
57+
mShown = false;
58+
mParentScrollArea = 0;
59+
5160
// init icons
5261
if ( mCollapseIcon.isNull() )
5362
{
@@ -70,11 +79,32 @@ void QgsCollapsibleGroupBox::init()
7079

7180
void QgsCollapsibleGroupBox::showEvent( QShowEvent * event )
7281
{
82+
// initialise widget on first show event only
83+
if ( mShown )
84+
{
85+
event->accept();
86+
return;
87+
}
88+
mShown = true;
89+
90+
// check if groupbox was set to flat in Designer or in code
91+
mInitFlat = isFlat();
92+
93+
// find parent QScrollArea - this might not work in complex layouts - should we look deeper?
94+
if ( parent() && parent()->parent() )
95+
mParentScrollArea = dynamic_cast<QScrollArea*>( parent()->parent()->parent() );
96+
else
97+
mParentScrollArea = 0;
98+
if ( mParentScrollArea )
99+
QgsDebugMsg( "found a QScrollArea parent: " + mParentScrollArea->objectName() );
100+
else
101+
QgsDebugMsg( "did not find a QScrollArea parent" );
102+
73103
loadState();
74104

75105
updateStyle();
76106

77-
// expand if needed - any calls to setCollapsed() before only set mCollapsed
107+
// expand if needed - any calls to setCollapsed() before only set mCollapsed, but have UI effect
78108
if ( mCollapsed )
79109
{
80110
setCollapsed( mCollapsed );
@@ -85,6 +115,7 @@ void QgsCollapsibleGroupBox::showEvent( QShowEvent * event )
85115
still emit signal for connections using expanded state */
86116
emit collapsedStateChanged( this );
87117
}
118+
88119
event->accept();
89120
}
90121

@@ -152,7 +183,6 @@ void QgsCollapsibleGroupBox::saveState()
152183
{
153184
if ( ! mSaveState )
154185
return;
155-
QgsDebugMsg( "key = " + saveKey() + " objectName = " + objectName() );
156186
QSettings settings;
157187
QString key = saveKey();
158188
settings.setValue( key + "/checked", isChecked() );
@@ -178,24 +208,66 @@ void QgsCollapsibleGroupBox::updateStyle()
178208
{
179209
setUpdatesEnabled( false );
180210

181-
// customize style sheet
211+
// margin/offset defaults
212+
int marginLeft = 20; // title margin for disclosure triangle
213+
int marginRight = 5; // a little bit of space on the right, to match space on the left
214+
int offsetLeft = 0; // offset for oxygen theme
215+
int offsetTop = 0;
216+
int offsetTop2 = 0; // offset for triangle
217+
218+
// calculate offset if frame overlaps triangle (oxygen theme)
219+
// using an offset of 6 pixels from frame border
220+
if ( QApplication::style()->objectName().toLower() == "oxygen" )
221+
{
222+
QStyleOptionGroupBox box;
223+
initStyleOption( &box );
224+
QRect rectFrame = style()->subControlRect( QStyle::CC_GroupBox, &box,
225+
QStyle::SC_GroupBoxFrame, this );
226+
QRect rectCheckBox = style()->subControlRect( QStyle::CC_GroupBox, &box,
227+
QStyle::SC_GroupBoxCheckBox, this );
228+
if ( rectFrame.left() <= 0 )
229+
offsetLeft = 6 + rectFrame.left();
230+
if ( rectFrame.top() <= 0 )
231+
{
232+
if ( isCheckable() )
233+
{
234+
// if is checkable align with checkbox
235+
offsetTop = ( rectCheckBox.height() / 2 ) -
236+
( mCollapseButton->height() / 2 ) + rectCheckBox.top();
237+
offsetTop2 = offsetTop + 1;
238+
}
239+
else
240+
{
241+
offsetTop = 6 + rectFrame.top();
242+
offsetTop2 = offsetTop;
243+
}
244+
}
245+
}
246+
247+
QgsDebugMsg( QString( "groupbox: %1 style: %2 offset: left=%3 top=%4 top2=%5" ).arg(
248+
objectName() ).arg( QApplication::style()->objectName() ).arg( offsetLeft ).arg( offsetTop ).arg( offsetTop2 ) );
249+
250+
// customize style sheet for collapse/expand button and force left-aligned title
182251
// TODO: move to app stylesheet system, when appropriate
183252
QString ss;
184253
ss += "QgsCollapsibleGroupBox::title {";
185254
ss += " subcontrol-origin: margin;";
186255
ss += " subcontrol-position: top left;";
187-
ss += " margin-left: 20px;"; // offset for disclosure triangle
188-
ss += " margin-right: 5px;"; // a little bit of space on the right, to match space on the left
256+
ss += QString( " margin-left: %1px;" ).arg( marginLeft );
257+
ss += QString( " margin-right: %1px;" ).arg( marginRight );
258+
ss += QString( " left: %1px;" ).arg( offsetLeft );
259+
ss += QString( " top: %1px;" ).arg( offsetTop );
189260
ss += "}";
190261
setStyleSheet( ss );
191262

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

200272
setUpdatesEnabled( true );
201273
}
@@ -208,14 +280,24 @@ void QgsCollapsibleGroupBox::setCollapsed( bool collapse )
208280
return;
209281

210282
// for consistent look/spacing across platforms when collapsed
211-
setFlat( collapse );
283+
if ( ! mInitFlat ) // skip if initially set to flat in Designer
284+
setFlat( collapse );
285+
212286
// avoid flicker in X11
213287
QApplication::processEvents();
288+
214289
// set maximum height to hide contents - does this work in all envs?
215290
// setMaximumHeight( collapse ? 25 : 16777215 );
216291
setMaximumHeight( collapse ? titleRect().bottom() + 6 : 16777215 );
217292
mCollapseButton->setIcon( collapse ? mExpandIcon : mCollapseIcon );
218293

294+
// if expanding and is in a QScrollArea, scroll down to make entire widget visible
295+
if ( mScrollOnExpand && !collapse && mParentScrollArea )
296+
{
297+
// process events so entire widget is shown
298+
QApplication::processEvents();
299+
mParentScrollArea->ensureWidgetVisible( this );
300+
}
219301
emit collapsedStateChanged( this );
220302
}
221303

src/gui/qgscollapsiblegroupbox.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <QGroupBox>
2929

3030
class QToolButton;
31+
class QScrollArea;
3132

3233
class GUI_EXPORT QgsCollapsibleGroupBox : public QGroupBox
3334
{
@@ -37,17 +38,21 @@ class GUI_EXPORT QgsCollapsibleGroupBox : public QGroupBox
3738
QgsCollapsibleGroupBox( QWidget *parent = 0 );
3839
QgsCollapsibleGroupBox( const QString &title, QWidget *parent = 0 );
3940
~QgsCollapsibleGroupBox();
41+
4042
bool isCollapsed() const { return mCollapsed; }
4143
void setCollapsed( bool collapse );
44+
45+
//! set this to false to not save/restore check and collapse state
4246
void setSaveState( bool save ) { mSaveState = save; }
47+
//! set this to false to not automatically scroll parent QScrollArea to this widget's contents when expanded
48+
void setScrollOnExpand( bool scroll ) { mScrollOnExpand = scroll; }
4349

4450
signals:
4551
void collapsedStateChanged( QWidget* );
4652

4753
public slots:
4854
void checkToggled( bool ckd );
4955
void toggleCollapsed();
50-
void updateStyle();
5156

5257
protected slots:
5358
void loadState();
@@ -57,11 +62,16 @@ class GUI_EXPORT QgsCollapsibleGroupBox : public QGroupBox
5762
void init();
5863
void showEvent( QShowEvent *event );
5964
void mouseReleaseEvent( QMouseEvent *event );
65+
void updateStyle();
6066
QRect titleRect() const;
6167
QString saveKey() const;
6268

6369
bool mCollapsed;
6470
bool mSaveState;
71+
bool mInitFlat;
72+
bool mScrollOnExpand;
73+
bool mShown;
74+
QScrollArea* mParentScrollArea;
6575
QToolButton* mCollapseButton;
6676

6777
static QIcon mCollapseIcon;

src/gui/qgsrasterlayersaveasdialog.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterLayer* rasterLa
106106
{
107107
okButton->setEnabled( false );
108108
}
109-
110-
// this should scroll down to make widget visible, but it's not happening
111-
// (at least part of it is visible)...
112-
connect( mCreateOptionsGroupBox, SIGNAL( collapsedStateChanged( QWidget* ) ),
113-
this, SLOT( groupBoxExpanded( QWidget* ) ) );
114109
}
115110

116111
void QgsRasterLayerSaveAsDialog::setValidators()
@@ -529,12 +524,6 @@ void QgsRasterLayerSaveAsDialog::on_mRawModeRadioButton_toggled( bool checked )
529524
mNoDataGroupBox->setEnabled( checked && mDataProvider->bandCount() == 1 );
530525
}
531526

532-
void QgsRasterLayerSaveAsDialog::groupBoxExpanded( QWidget * widget )
533-
{
534-
if ( !mCreateOptionsGroupBox->isCollapsed() )
535-
mScrollArea->ensureWidgetVisible( widget );
536-
}
537-
538527
void QgsRasterLayerSaveAsDialog::on_mAddNoDataManuallyToolButton_clicked()
539528
{
540529
addNoDataRow( std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN() );

src/gui/qgsrasterlayersaveasdialog.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ class GUI_EXPORT QgsRasterLayerSaveAsDialog: public QDialog, private Ui::QgsRast
9292

9393
void on_mCrsComboBox_currentIndexChanged( int ) { crsChanged(); }
9494

95-
void groupBoxExpanded( QWidget * widget );
9695
void on_mAddNoDataManuallyToolButton_clicked();
9796
void on_mLoadTransparentNoDataToolButton_clicked();
9897
void on_mRemoveSelectedNoDataToolButton_clicked();

0 commit comments

Comments
 (0)