Skip to content

Commit 6c50caa

Browse files
committed
Merge branch 'master' of https://github.com/qgis/Quantum-GIS into coloramp
2 parents 3f8a467 + c836d61 commit 6c50caa

24 files changed

+903
-278
lines changed

images/images.qrc

+2
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@
210210
<file>themes/default/mIconWarn.png</file>
211211
<file>themes/default/mIconZoom.png</file>
212212
<file>themes/default/mIconZip.png</file>
213+
<file>themes/default/mIconCollapse.png</file>
214+
<file>themes/default/mIconExpand.png</file>
213215
<file>themes/default/mMapserverExport.png</file>
214216
<file>themes/default/plugin.png</file>
215217
<file>themes/default/propertyicons/action.png</file>
1.34 KB
Loading

images/themes/default/mIconExpand.png

1.34 KB
Loading

python/core/qgscomposermultiframe.sip

+1
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ public:
4343
void deleteFrames();
4444

4545
int nFrames() const;
46+
QgsComposerFrame* frame( int i );
4647
};

src/app/qgsoptions.cpp

+18-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "qgsproject.h"
2828

2929
#include "qgsrasterformatsaveoptionswidget.h"
30+
#include "qgsrasterpyramidsoptionswidget.h"
3031
#include "qgsdialog.h"
3132

3233
#include <QInputDialog>
@@ -1118,15 +1119,26 @@ void QgsOptions::editGdalDriver( const QString& driverName )
11181119
QLabel *label = new QLabel( title, &dlg );
11191120
label->setAlignment( Qt::AlignHCenter );
11201121
layout->addWidget( label );
1121-
QgsRasterFormatSaveOptionsWidget* optionsWidget =
1122-
new QgsRasterFormatSaveOptionsWidget( &dlg, driverName,
1123-
QgsRasterFormatSaveOptionsWidget::Full, "gdal" );
1124-
layout->addWidget( optionsWidget );
11251122

1126-
if ( dlg.exec() == QDialog::Accepted )
1123+
if ( driverName == "_pyramids" )
11271124
{
1128-
optionsWidget->apply();
1125+
QgsRasterPyramidsOptionsWidget* optionsWidget =
1126+
new QgsRasterPyramidsOptionsWidget( &dlg, "gdal" );
1127+
layout->addWidget( optionsWidget );
1128+
dlg.resize( 400, 400 );
1129+
if ( dlg.exec() == QDialog::Accepted )
1130+
optionsWidget->apply();
11291131
}
1132+
else
1133+
{
1134+
QgsRasterFormatSaveOptionsWidget* optionsWidget =
1135+
new QgsRasterFormatSaveOptionsWidget( &dlg, driverName,
1136+
QgsRasterFormatSaveOptionsWidget::Full, "gdal" );
1137+
layout->addWidget( optionsWidget );
1138+
if ( dlg.exec() == QDialog::Accepted )
1139+
optionsWidget->apply();
1140+
}
1141+
11301142
}
11311143

11321144
// Return state of the visibility flag for newly added layers. If

src/core/composer/qgscomposermultiframe.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,15 @@ void QgsComposerMultiFrame::deleteFrames()
238238
mResizeMode = bkResizeMode;
239239
}
240240

241+
QgsComposerFrame* QgsComposerMultiFrame::frame( int i )
242+
{
243+
if ( i >= mFrameItems.size() )
244+
{
245+
return 0;
246+
}
247+
return mFrameItems.at( i );
248+
}
249+
241250
bool QgsComposerMultiFrame::_writeXML( QDomElement& elem, QDomDocument& doc, bool ignoreFrames ) const
242251
{
243252
elem.setAttribute( "resizeMode", mResizeMode );

src/core/composer/qgscomposermultiframe.h

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class CORE_EXPORT QgsComposerMultiFrame: public QObject
7070
void deleteFrames();
7171

7272
int nFrames() const { return mFrameItems.size(); }
73+
QgsComposerFrame* frame( int i );
7374

7475
protected:
7576
QgsComposition* mComposition;

src/core/qgsrasterdataprovider.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,11 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast
525525
return false;
526526
}
527527

528-
/** Set no data value on created dataset */
529-
virtual bool setNoDataValue( int, double ) { return false; }
528+
/** Set no data value on created dataset
529+
* @param bandNo band number
530+
* @param noDataValue no data value
531+
*/
532+
virtual bool setNoDataValue( int bandNo, double noDataValue ) { Q_UNUSED( bandNo ); Q_UNUSED( noDataValue ); return false; }
530533

531534
/**Returns the formats supported by create()*/
532535
virtual QStringList createFormats() const { return QStringList(); }

src/core/raster/qgsrastertransparency.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ int QgsRasterTransparency::alphaValue( double theValue, int theGlobalTransparenc
110110

111111
//Search through the transparency list looking for a match
112112
bool myTransparentPixelFound = false;
113-
TransparentSingleValuePixel myTransparentPixel = {0, 100};
113+
TransparentSingleValuePixel myTransparentPixel = {0, 0, 100};
114114
for ( int myListRunner = 0; myListRunner < mTransparentSingleValuePixelList.count(); myListRunner++ )
115115
{
116116
myTransparentPixel = mTransparentSingleValuePixelList[myListRunner];

src/gui/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ qgsprojectionselector.cpp
8383
qgsquickprint.cpp
8484
qgsrasterlayersaveasdialog.cpp
8585
qgsrasterformatsaveoptionswidget.cpp
86+
qgsrasterpyramidsoptionswidget.cpp
8687
qgsrubberband.cpp
8788
qgsscalecombobox.cpp
8889
qgstextannotationitem.cpp
@@ -93,6 +94,7 @@ qgsexpressionbuilderwidget.cpp
9394
qgsexpressionbuilderdialog.cpp
9495
qgsexpressionhighlighter.cpp
9596
qgsquerybuilder.cpp
97+
qgscollapsiblegroupbox.cpp
9698
)
9799

98100
IF (WITH_TOUCH)
@@ -168,6 +170,7 @@ qgsprojectionselector.h
168170
qgsquickprint.h
169171
qgsrasterlayersaveasdialog.h
170172
qgsrasterformatsaveoptionswidget.h
173+
qgsrasterpyramidsoptionswidget.h
171174
qgsludialog.h
172175
qgsprojectbadlayerguihandler.h
173176
qgslonglongvalidator.h
@@ -176,6 +179,7 @@ qgsscalecombobox.h
176179
qgsexpressionbuilderwidget.h
177180
qgsexpressionhighlighter.h
178181
qgsquerybuilder.h
182+
qgscollapsiblegroupbox.h
179183
)
180184

181185
QT4_WRAP_CPP(QGIS_GUI_MOC_SRCS ${QGIS_GUI_MOC_HDRS})
@@ -213,6 +217,7 @@ qgsfieldvalidator.h
213217
qgsexpressionbuilderwidget.h
214218
qgsexpressionbuilderdialog.h
215219
qgsexpressionhighlighter.h
220+
qgscollapsiblegroupbox.h
216221

217222
attributetable/qgsattributetablemodel.h
218223
attributetable/qgsattributetablememorymodel.h

src/gui/qgscollapsiblegroupbox.cpp

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/***************************************************************************
2+
qgscollapsiblegroupbox.cpp
3+
-------------------
4+
begin : August 2012
5+
copyright : (C) 2012 by Etienne Tourigny
6+
email : etourigny dot dev at gmail dot com
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#include "qgscollapsiblegroupbox.h"
19+
20+
#include "qgsapplication.h"
21+
#include "qgslogger.h"
22+
23+
#include <QStyleOptionGroupBox>
24+
#include <QStylePainter>
25+
#include <QLayout>
26+
27+
QgsCollapsibleGroupBox::QgsCollapsibleGroupBox( QWidget *parent )
28+
: QGroupBox( parent ), mCollapsed( false )
29+
{
30+
connect( this, SIGNAL( toggled( bool ) ), this, SLOT( setToggled( bool ) ) );
31+
}
32+
33+
QgsCollapsibleGroupBox::QgsCollapsibleGroupBox( const QString &title, QWidget *parent )
34+
: QGroupBox( title, parent ), mCollapsed( false )
35+
{}
36+
37+
void QgsCollapsibleGroupBox::paintEvent( QPaintEvent * event )
38+
{
39+
QGroupBox::paintEvent( event );
40+
41+
// paint expand/collapse icon only if groupbox is checkable as icon replaces check box
42+
if ( ! isCheckable() )
43+
return;
44+
45+
// create background mask + expand/collapse icon
46+
// icons from http://www.iconfinder.com/search/?q=iconset%3AsplashyIcons
47+
QPixmap icon( mCollapsed ?
48+
QgsApplication::getThemePixmap( "/mIconExpand.png" ) :
49+
QgsApplication::getThemePixmap( "/mIconCollapse.png" ) );
50+
QPixmap background( icon.width() + 2, icon.height() + 2 );
51+
background.fill( palette().color( backgroundRole() ) );
52+
53+
// paint on top of checkbox - does this work with all platforms/themes?
54+
QStylePainter paint( this );
55+
QStyleOptionGroupBox option;
56+
initStyleOption( &option );
57+
paint.drawComplexControl( QStyle::CC_GroupBox, option );
58+
paint.drawItemPixmap( option.rect.adjusted( 4, -1, 0, 0 ),
59+
Qt::AlignTop | Qt::AlignLeft,
60+
background );
61+
paint.drawItemPixmap( option.rect.adjusted( 6, 0, 0, 0 ),
62+
Qt::AlignTop | Qt::AlignLeft,
63+
icon );
64+
}
65+
66+
void QgsCollapsibleGroupBox::showEvent( QShowEvent * event )
67+
{
68+
QGroupBox::showEvent( event );
69+
// collapse if needed - any calls to setCollapsed() before have no effect
70+
if ( isCheckable() && ! isChecked() && ! isCollapsed() )
71+
setCollapsed( true );
72+
}
73+
74+
void QgsCollapsibleGroupBox::setCollapsed( bool collapse )
75+
{
76+
if ( ! isVisible() )
77+
return;
78+
79+
mCollapsed = collapse;
80+
81+
// minimize layout margins and save for subsequent restore
82+
if ( collapse )
83+
{
84+
if ( layout() )
85+
{
86+
mMargins = layout()->contentsMargins();
87+
layout()->setContentsMargins( 1, 1, 1, 1 );
88+
}
89+
}
90+
else
91+
{
92+
if ( layout() )
93+
{
94+
layout()->setContentsMargins( mMargins );
95+
}
96+
}
97+
98+
// if we are collapsing, save hidden widgets in a list
99+
if ( collapse )
100+
{
101+
mHiddenWidgets.clear();
102+
foreach ( QWidget *widget, findChildren<QWidget*>() )
103+
{
104+
if ( widget->isHidden() )
105+
mHiddenWidgets << widget;
106+
}
107+
}
108+
109+
// show/hide widgets
110+
foreach ( QWidget *widget, findChildren<QWidget*>() )
111+
widget->setHidden( collapse );
112+
113+
// if we are expanding, re-hide saved hidden widgets
114+
if ( ! collapse )
115+
{
116+
foreach ( QWidget *widget, mHiddenWidgets )
117+
{
118+
widget->setHidden( true );
119+
}
120+
}
121+
122+
if ( mCollapsed )
123+
emit collapsed( this );
124+
else
125+
emit expanded( this );
126+
}
127+

src/gui/qgscollapsiblegroupbox.h

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/***************************************************************************
2+
qgscollapsiblegroupbox.h
3+
-------------------
4+
begin : August 2012
5+
copyright : (C) 2012 by Etienne Tourigny
6+
email : etourigny dot dev at gmail dot com
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#ifndef QGSCOLLAPSIBLEGROUPBOX_H
19+
#define QGSCOLLAPSIBLEGROUPBOX_H
20+
21+
#include "qgisgui.h"
22+
23+
/** \ingroup gui
24+
* A groupbox that collapses/expands when toggled and draws an expand/collapse icon in lieu of checkbox.
25+
* Widget must be checkable for expand/collapse icon to appear.
26+
*/
27+
28+
#include <QGroupBox>
29+
30+
class GUI_EXPORT QgsCollapsibleGroupBox : public QGroupBox
31+
{
32+
Q_OBJECT
33+
34+
public:
35+
QgsCollapsibleGroupBox( QWidget *parent = 0 );
36+
QgsCollapsibleGroupBox( const QString &title, QWidget *parent = 0 );
37+
38+
bool isCollapsed() const { return mCollapsed; }
39+
40+
signals:
41+
void collapsed( QWidget* );
42+
void expanded( QWidget* );
43+
44+
public slots:
45+
void setToggled( bool toggled ) { setCollapsed( ! toggled ); }
46+
void setCollapsed( bool collapse );
47+
48+
protected:
49+
void paintEvent( QPaintEvent * );
50+
void showEvent( QShowEvent * event );
51+
52+
private:
53+
bool mCollapsed;
54+
QMargins mMargins;
55+
QList< QWidget* > mHiddenWidgets;
56+
};
57+
58+
#endif

0 commit comments

Comments
 (0)