Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge branch 'master' of https://github.com/qgis/Quantum-GIS into col…
…oramp
- Loading branch information
Showing
24 changed files
with
903 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,5 @@ public: | |
void deleteFrames(); | ||
|
||
int nFrames() const; | ||
QgsComposerFrame* frame( int i ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/*************************************************************************** | ||
qgscollapsiblegroupbox.cpp | ||
------------------- | ||
begin : August 2012 | ||
copyright : (C) 2012 by Etienne Tourigny | ||
email : etourigny dot dev at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgscollapsiblegroupbox.h" | ||
|
||
#include "qgsapplication.h" | ||
#include "qgslogger.h" | ||
|
||
#include <QStyleOptionGroupBox> | ||
#include <QStylePainter> | ||
#include <QLayout> | ||
|
||
QgsCollapsibleGroupBox::QgsCollapsibleGroupBox( QWidget *parent ) | ||
: QGroupBox( parent ), mCollapsed( false ) | ||
{ | ||
connect( this, SIGNAL( toggled( bool ) ), this, SLOT( setToggled( bool ) ) ); | ||
} | ||
|
||
QgsCollapsibleGroupBox::QgsCollapsibleGroupBox( const QString &title, QWidget *parent ) | ||
: QGroupBox( title, parent ), mCollapsed( false ) | ||
{} | ||
|
||
void QgsCollapsibleGroupBox::paintEvent( QPaintEvent * event ) | ||
{ | ||
QGroupBox::paintEvent( event ); | ||
|
||
// paint expand/collapse icon only if groupbox is checkable as icon replaces check box | ||
if ( ! isCheckable() ) | ||
return; | ||
|
||
// create background mask + expand/collapse icon | ||
// icons from http://www.iconfinder.com/search/?q=iconset%3AsplashyIcons | ||
QPixmap icon( mCollapsed ? | ||
QgsApplication::getThemePixmap( "/mIconExpand.png" ) : | ||
QgsApplication::getThemePixmap( "/mIconCollapse.png" ) ); | ||
QPixmap background( icon.width() + 2, icon.height() + 2 ); | ||
background.fill( palette().color( backgroundRole() ) ); | ||
|
||
// paint on top of checkbox - does this work with all platforms/themes? | ||
QStylePainter paint( this ); | ||
QStyleOptionGroupBox option; | ||
initStyleOption( &option ); | ||
paint.drawComplexControl( QStyle::CC_GroupBox, option ); | ||
paint.drawItemPixmap( option.rect.adjusted( 4, -1, 0, 0 ), | ||
Qt::AlignTop | Qt::AlignLeft, | ||
background ); | ||
paint.drawItemPixmap( option.rect.adjusted( 6, 0, 0, 0 ), | ||
Qt::AlignTop | Qt::AlignLeft, | ||
icon ); | ||
} | ||
|
||
void QgsCollapsibleGroupBox::showEvent( QShowEvent * event ) | ||
{ | ||
QGroupBox::showEvent( event ); | ||
// collapse if needed - any calls to setCollapsed() before have no effect | ||
if ( isCheckable() && ! isChecked() && ! isCollapsed() ) | ||
setCollapsed( true ); | ||
} | ||
|
||
void QgsCollapsibleGroupBox::setCollapsed( bool collapse ) | ||
{ | ||
if ( ! isVisible() ) | ||
return; | ||
|
||
mCollapsed = collapse; | ||
|
||
// minimize layout margins and save for subsequent restore | ||
if ( collapse ) | ||
{ | ||
if ( layout() ) | ||
{ | ||
mMargins = layout()->contentsMargins(); | ||
layout()->setContentsMargins( 1, 1, 1, 1 ); | ||
} | ||
} | ||
else | ||
{ | ||
if ( layout() ) | ||
{ | ||
layout()->setContentsMargins( mMargins ); | ||
} | ||
} | ||
|
||
// if we are collapsing, save hidden widgets in a list | ||
if ( collapse ) | ||
{ | ||
mHiddenWidgets.clear(); | ||
foreach ( QWidget *widget, findChildren<QWidget*>() ) | ||
{ | ||
if ( widget->isHidden() ) | ||
mHiddenWidgets << widget; | ||
} | ||
} | ||
|
||
// show/hide widgets | ||
foreach ( QWidget *widget, findChildren<QWidget*>() ) | ||
widget->setHidden( collapse ); | ||
|
||
// if we are expanding, re-hide saved hidden widgets | ||
if ( ! collapse ) | ||
{ | ||
foreach ( QWidget *widget, mHiddenWidgets ) | ||
{ | ||
widget->setHidden( true ); | ||
} | ||
} | ||
|
||
if ( mCollapsed ) | ||
emit collapsed( this ); | ||
else | ||
emit expanded( this ); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/*************************************************************************** | ||
qgscollapsiblegroupbox.h | ||
------------------- | ||
begin : August 2012 | ||
copyright : (C) 2012 by Etienne Tourigny | ||
email : etourigny dot dev at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSCOLLAPSIBLEGROUPBOX_H | ||
#define QGSCOLLAPSIBLEGROUPBOX_H | ||
|
||
#include "qgisgui.h" | ||
|
||
/** \ingroup gui | ||
* A groupbox that collapses/expands when toggled and draws an expand/collapse icon in lieu of checkbox. | ||
* Widget must be checkable for expand/collapse icon to appear. | ||
*/ | ||
|
||
#include <QGroupBox> | ||
|
||
class GUI_EXPORT QgsCollapsibleGroupBox : public QGroupBox | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
QgsCollapsibleGroupBox( QWidget *parent = 0 ); | ||
QgsCollapsibleGroupBox( const QString &title, QWidget *parent = 0 ); | ||
|
||
bool isCollapsed() const { return mCollapsed; } | ||
|
||
signals: | ||
void collapsed( QWidget* ); | ||
void expanded( QWidget* ); | ||
|
||
public slots: | ||
void setToggled( bool toggled ) { setCollapsed( ! toggled ); } | ||
void setCollapsed( bool collapse ); | ||
|
||
protected: | ||
void paintEvent( QPaintEvent * ); | ||
void showEvent( QShowEvent * event ); | ||
|
||
private: | ||
bool mCollapsed; | ||
QMargins mMargins; | ||
QList< QWidget* > mHiddenWidgets; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.