Skip to content

Commit

Permalink
Use 'report' text instead of 'atlas' when inside a report designer
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 5, 2018
1 parent 5d64f3c commit d2c880a
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/gui/layout/qgslayoutitemwidget.sip
Expand Up @@ -90,6 +90,14 @@ updated to match ``item``'s properties.

If false is returned, then the widget could not be successfully updated
to show the properties of ``item``.
%End

virtual void setReportTypeString( const QString &string );
%Docstring
Sets the ``string`` to use to describe the current report type (e.g.
"atlas" or "report").
Subclasses which display this text to users should override this
and update their widget labels accordingly.
%End

protected:
Expand Down
5 changes: 5 additions & 0 deletions src/app/layout/qgslayoutattributetablewidget.cpp
Expand Up @@ -145,6 +145,11 @@ QgsLayoutAttributeTableWidget::QgsLayoutAttributeTableWidget( QgsLayoutFrame *fr
connect( mContentFontToolButton, &QgsFontButton::changed, this, &QgsLayoutAttributeTableWidget::contentFontChanged );
}

void QgsLayoutAttributeTableWidget::setReportTypeString( const QString &string )
{
mIntersectAtlasCheckBox->setText( tr( "Show only features intersecting %1 feature" ).arg( string ) );
}

bool QgsLayoutAttributeTableWidget::setNewItem( QgsLayoutItem *item )
{
QgsLayoutFrame *frame = qobject_cast< QgsLayoutFrame * >( item );
Expand Down
2 changes: 2 additions & 0 deletions src/app/layout/qgslayoutattributetablewidget.h
Expand Up @@ -30,6 +30,8 @@ class QgsLayoutAttributeTableWidget: public QgsLayoutItemBaseWidget, private Ui:
public:
QgsLayoutAttributeTableWidget( QgsLayoutFrame *frame );

void setReportTypeString( const QString &string ) override;

protected:

bool setNewItem( QgsLayoutItem *item ) override;
Expand Down
9 changes: 9 additions & 0 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Expand Up @@ -889,6 +889,7 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa
if ( ! widget )
return;

widget->setReportTypeString( reportTypeString() );

if ( QgsLayoutPagePropertiesWidget *ppWidget = qobject_cast< QgsLayoutPagePropertiesWidget * >( widget.get() ) )
connect( ppWidget, &QgsLayoutPagePropertiesWidget::pageOrientationChanged, this, &QgsLayoutDesignerDialog::pageOrientationChanged );
Expand Down Expand Up @@ -3961,6 +3962,14 @@ QPrinter *QgsLayoutDesignerDialog::printer()
return mPrinter.get();
}

QString QgsLayoutDesignerDialog::reportTypeString()
{
if ( atlas() )
return tr( "atlas" );
else
return tr( "report" );
}

void QgsLayoutDesignerDialog::selectItems( const QList<QgsLayoutItem *> items )
{
for ( QGraphicsItem *item : items )
Expand Down
1 change: 1 addition & 0 deletions src/app/layout/qgslayoutdesignerdialog.h
Expand Up @@ -478,6 +478,7 @@ class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesigner

void setPrinterPageOrientation( QgsLayoutItemPage::Orientation orientation );
QPrinter *printer();
QString reportTypeString();
};

#endif // QGSLAYOUTDESIGNERDIALOG_H
Expand Down
6 changes: 6 additions & 0 deletions src/app/layout/qgslayoutlegendwidget.cpp
Expand Up @@ -922,6 +922,12 @@ void QgsLayoutLegendWidget::updateLegend()
}
}

void QgsLayoutLegendWidget::setReportTypeString( const QString &string )
{
mFilterLegendByAtlasCheckBox->setText( tr( "Only show items inside current %1 feature" ).arg( string ) );
mFilterLegendByAtlasCheckBox->setToolTip( tr( "Filter out legend elements that lie outside the current %1 feature." ).arg( string ) );
}

bool QgsLayoutLegendWidget::setNewItem( QgsLayoutItem *item )
{
if ( item->type() != QgsLayoutItemRegistry::LayoutLegend )
Expand Down
1 change: 1 addition & 0 deletions src/app/layout/qgslayoutlegendwidget.h
Expand Up @@ -39,6 +39,7 @@ class QgsLayoutLegendWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayo
void updateLegend();

QgsLayoutItemLegend *legend() { return mLegend; }
void setReportTypeString( const QString &string ) override;

protected:

Expand Down
6 changes: 6 additions & 0 deletions src/app/layout/qgslayoutmapwidget.cpp
Expand Up @@ -155,6 +155,12 @@ QgsLayoutMapWidget::QgsLayoutMapWidget( QgsLayoutItemMap *item )
blockAllSignals( false );
}

void QgsLayoutMapWidget::setReportTypeString( const QString &string )
{
mAtlasCheckBox->setTitle( tr( "Controlled by %1" ).arg( string ) );
mAtlasPredefinedScaleRadio->setToolTip( tr( "Use one of the predefined scales of the project where the %1 feature best fits." ).arg( string ) );
}

bool QgsLayoutMapWidget::setNewItem( QgsLayoutItem *item )
{
if ( item->type() != QgsLayoutItemRegistry::LayoutMap )
Expand Down
2 changes: 2 additions & 0 deletions src/app/layout/qgslayoutmapwidget.h
Expand Up @@ -37,6 +37,8 @@ class QgsLayoutMapWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutM
public:
explicit QgsLayoutMapWidget( QgsLayoutItemMap *item );

void setReportTypeString( const QString &string ) override;

public slots:
void mScaleLineEdit_editingFinished();
void mSetToMapCanvasExtentButton_clicked();
Expand Down
4 changes: 4 additions & 0 deletions src/gui/layout/qgslayoutitemwidget.cpp
Expand Up @@ -154,6 +154,10 @@ bool QgsLayoutItemBaseWidget::setItem( QgsLayoutItem *item )
return false;
}

void QgsLayoutItemBaseWidget::setReportTypeString( const QString & )
{
}

void QgsLayoutItemBaseWidget::registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsLayoutObject::DataDefinedProperty property )
{
mConfigObject->initializeDataDefinedButton( button, property );
Expand Down
8 changes: 8 additions & 0 deletions src/gui/layout/qgslayoutitemwidget.h
Expand Up @@ -134,6 +134,14 @@ class GUI_EXPORT QgsLayoutItemBaseWidget: public QgsPanelWidget
*/
bool setItem( QgsLayoutItem *item );

/**
* Sets the \a string to use to describe the current report type (e.g.
* "atlas" or "report").
* Subclasses which display this text to users should override this
* and update their widget labels accordingly.
*/
virtual void setReportTypeString( const QString &string );

protected:

/**
Expand Down

0 comments on commit d2c880a

Please sign in to comment.