Skip to content
Permalink
Browse files

Work on resurrecting overviews

  • Loading branch information
nyalldawson committed Oct 21, 2017
1 parent 5d5c858 commit 1f769da68d034c84231c108759003349e50d490d
Showing with 1,818 additions and 51 deletions.
  1. +1 −0 python/gui/gui_auto.sip
  2. +100 −0 python/gui/layout/qgslayoutitemcombobox.sip
  3. +7 −6 src/app/layout/qgslayoutmapwidget.cpp
  4. +3 −4 src/core/layout/qgslayoutitemmap.cpp
  5. +2 −1 src/core/layout/qgslayoutitemmapgrid.h
  6. +3 −2 src/core/layout/qgslayoutitemmapoverview.cpp
  7. +0 −2 src/core/layout/qgslayoutmodel.cpp
  8. +2 −0 src/gui/CMakeLists.txt
  9. +117 −0 src/gui/layout/qgslayoutitemcombobox.cpp
  10. +110 −0 src/gui/layout/qgslayoutitemcombobox.h
  11. +3 −3 src/ui/layout/qgslayoutmapwidgetbase.ui
  12. +2 −0 tests/src/core/CMakeLists.txt
  13. +1,021 −0 tests/src/core/testqgslayoutmapgrid.cpp
  14. +298 −0 tests/src/core/testqgslayoutmapoverview.cpp
  15. +1 −0 tests/src/gui/CMakeLists.txt
  16. +115 −0 tests/src/gui/testqgslayoutgui.cpp
  17. +33 −33 tests/src/python/test_qgslayoutmap.py
  18. BIN ...ol_images/composer_mapgrid/expected_composermap_crossgrid/expected_composermap_crossgrid_mask.png
  19. BIN ...s/composer_mapgrid/expected_composermap_exteriorticks/expected_composermap_exteriorticks_mask.png
  20. BIN ...composer_mapgrid/expected_composermap_framedivisions/expected_composermap_framedivisions_mask.png
  21. BIN ...s/composer_mapgrid/expected_composermap_gridframeonly/expected_composermap_gridframeonly_mask.png
  22. BIN ...mposer_mapgrid/expected_composermap_gridreprojected/expected_composermap_gridreprojected_mask.png
  23. BIN ...id/expected_composermap_interiorexteriorticks/expected_composermap_interiorexteriorticks_mask.png
  24. BIN ...s/composer_mapgrid/expected_composermap_interiorticks/expected_composermap_interiorticks_mask.png
  25. BIN ..._images/composer_mapgrid/expected_composermap_lineborder/expected_composermap_lineborder_mask.png
  26. BIN ..._images/composer_mapgrid/expected_composermap_markergrid/expected_composermap_markergrid_mask.png
  27. BIN ...ges/composer_mapgrid/expected_composermap_rotatedframe/expected_composermap_rotatedframe_mask.png
  28. BIN ..._images/composer_mapgrid/expected_composermap_zebrastyle/expected_composermap_zebrastyle_mask.png
  29. BIN ...mposer_mapgrid/expected_composermap_zebrastyle_left/expected_composermap_zebrastyle_left_mask.png
  30. BIN ..._mapgrid/expected_composermap_zebrastyle_lefttop/expected_composermap_zebrastyle_lefttop_mask.png
  31. BIN ...xpected_composermap_zebrastyle_lefttopright/expected_composermap_zebrastyle_lefttopright_mask.png
  32. BIN ..._images/composer_mapoverview/expected_composermap_overview/expected_composermap_overview_mask.png
  33. BIN ...apoverview/expected_composermap_overview_blending/expected_composermap_overview_blending_mask.png
  34. BIN ...er_mapoverview/expected_composermap_overview_center/expected_composermap_overview_center_mask.png
  35. BIN ...er_mapoverview/expected_composermap_overview_invert/expected_composermap_overview_invert_mask.png
  36. BIN ..._mapoverview/expected_composermap_overview_rotated/expected_composermap_overview_rotated_mask.png
  37. BIN ...apoverview/expected_composermap_overview_rotated2/expected_composermap_overview_rotated2_mask.png
@@ -287,6 +287,7 @@
%Include layertree/qgslayertreeview.sip
%Include layertree/qgslayertreeviewdefaultactions.sip
%Include layout/qgslayoutdesignerinterface.sip
%Include layout/qgslayoutitemcombobox.sip
%Include layout/qgslayoutitemguiregistry.sip
%Include layout/qgslayoutitemwidget.sip
%Include layout/qgslayoutnewitempropertiesdialog.sip
@@ -0,0 +1,100 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/layout/qgslayoutitemcombobox.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/



class QgsLayoutItemComboBox : QComboBox
{
%Docstring
The QgsLayoutItemComboBox class is a combo box which displays items of
a matching type from a layout.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgslayoutitemcombobox.h"
%End
public:

explicit QgsLayoutItemComboBox( QWidget *parent /TransferThis/ = 0, QgsLayout *layout = 0 );
%Docstring
QgsLayoutItemComboBox creates a combo box to display a list of items in a
``layout``. The items can optionally be filtered by type.
If ``layout`` is not set, no items will be shown
until setCurrentLayout() is called
%End

void setCurrentLayout( QgsLayout *layout );
%Docstring
Sets the ``layout`` containing the items to list in the combo box.
%End

void setItemType( QgsLayoutItemRegistry::ItemType itemType );
%Docstring
Sets a filter for the item type to show in the combo box.
\param itemType type of items to show. Set to QgsLayoutItemRegistry.LayoutItem to
show all items.
.. seealso:: itemType()
%End

QgsLayoutItemRegistry::ItemType itemType() const;
%Docstring
Returns the filter for the item types to show in the combo box.
.. seealso:: setItemType()
:rtype: QgsLayoutItemRegistry.ItemType
%End

void setExceptedItemList( const QList< QgsLayoutItem * > &exceptList );
%Docstring
Sets a list of specific items to exclude from the combo box.
.. seealso:: exceptedItemList()
%End

QList< QgsLayoutItem * > exceptedItemList() const;
%Docstring
Returns the list of specific items excluded from the combo box.
.. seealso:: setExceptedItemList()
:rtype: list of QgsLayoutItem
%End

QgsLayoutItem *item( int index ) const;
%Docstring
Return the item currently shown at the specified ``index`` within the combo box.
.. seealso:: currentItem()
:rtype: QgsLayoutItem
%End

QgsLayoutItem *currentItem() const;
%Docstring
Returns the item currently selected in the combo box.
:rtype: QgsLayoutItem
%End

public slots:

void setItem( const QgsLayoutItem *item );
%Docstring
Sets the currently selected ``item`` in the combo box.
%End

signals:

void itemChanged( QgsLayoutItem *item );
%Docstring
Emitted whenever the currently selected item changes
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/layout/qgslayoutitemcombobox.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -118,11 +118,11 @@ QgsLayoutMapWidget::QgsLayoutMapWidget( QgsLayoutItemMap *item )

compositionAtlasToggled( atlas->enabled() );
}
mOverviewFrameMapComboBox->setComposition( composerMap->composition() );
mOverviewFrameMapComboBox->setItemType( QgsComposerItem::ComposerMap );
mOverviewFrameMapComboBox->setExceptedItemList( QList< QgsComposerItem * >() << composerMap );
connect( mOverviewFrameMapComboBox, &QgsComposerItemComboBox::itemChanged, this, &QgsLayoutMapWidget::overviewMapChanged );
#endif
mOverviewFrameMapComboBox->setCurrentLayout( item->layout() );
mOverviewFrameMapComboBox->setItemType( QgsLayoutItemRegistry::LayoutMap );

connect( mOverviewFrameMapComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutMapWidget::overviewMapChanged );
}

connect( mCrsSelector, &QgsProjectionSelectionWidget::crsChanged, this, &QgsLayoutMapWidget::mapCrsChanged );
@@ -1496,9 +1496,8 @@ void QgsLayoutMapWidget::setOverviewItems( QgsLayoutItemMapOverview *overview )
mOverviewCheckBox->setChecked( overview->enabled() );

//overview frame
#if 0 //TODO
mOverviewFrameMapComboBox->setItem( overview->frameMap() );
#endif

//overview frame blending mode
mOverviewBlendModeComboBox->setBlendMode( overview->blendMode() );
//overview inverted
@@ -1563,6 +1562,8 @@ void QgsLayoutMapWidget::loadOverviewEntries()
return;
}

mOverviewFrameMapComboBox->setExceptedItemList( QList< QgsLayoutItem * >() << mMapItem );

//load all composer overviews into list widget
QList< QgsLayoutItemMapOverview * > overviews = mMapItem->overviews()->asList();
QList< QgsLayoutItemMapOverview * >::const_iterator overviewIt = overviews.constBegin();
@@ -53,10 +53,9 @@ QgsLayoutItemMap::QgsLayoutItemMap( QgsLayout *layout )
shapeChanged();
} );

# if 0
mGridStack = new QgsComposerMapGridStack( this );
mOverviewStack = new QgsComposerMapOverviewStack( this );
#endif
mGridStack = qgis::make_unique< QgsLayoutItemMapGridStack >( this );
mOverviewStack = qgis::make_unique< QgsLayoutItemMapOverviewStack >( this );

if ( layout )
connectUpdateSlot();
}
@@ -1001,7 +1001,8 @@ class CORE_EXPORT QgsLayoutItemMapGrid : public QgsLayoutItemMapItem
bool shouldShowDivisionForSide( AnnotationCoordinate coordinate, BorderSide side ) const;
bool shouldShowDivisionForDisplayMode( AnnotationCoordinate coordinate, DisplayMode mode ) const;

friend class TestQgsLayoutItemMapGrid;
friend class TestQgsLayoutMapGrid;

};

Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLayoutItemMapGrid::FrameSideFlags )
@@ -221,16 +221,17 @@ void QgsLayoutItemMapOverview::setFrameMapUuid( const QString &mapId )
mFrameMapId = mapId;
//connect to new map signals
connectSignals();
mMap->update();
}

void QgsLayoutItemMapOverview::setFrameMap( QgsLayoutItemMap *map )
{
mFrameMapId = map ? map->uuid() : QString();
setFrameMapUuid( map ? map->uuid() : QString() );
}

QgsLayoutItemMap *QgsLayoutItemMapOverview::frameMap()
{
if ( mFrameMapId.isEmpty() && mMap && mMap->layout() )
if ( !mFrameMapId.isEmpty() && mMap && mMap->layout() )
{
return dynamic_cast< QgsLayoutItemMap * >( mMap->layout()->itemByUuid( mFrameMapId ) );
}
@@ -500,11 +500,9 @@ void QgsLayoutModel::rebuildSceneItemList()
///@cond PRIVATE
void QgsLayoutModel::addItemAtTop( QgsLayoutItem *item )
{
beginInsertRows( QModelIndex(), 0, 0 );
mItemZList.push_front( item );
refreshItemsInScene();
item->setZValue( mItemZList.size() );
endInsertRows();
}

void QgsLayoutModel::removeItem( QgsLayoutItem *item )
@@ -160,6 +160,7 @@ SET(QGIS_GUI_SRCS
layertree/qgslayertreeviewdefaultactions.cpp

layout/qgslayoutitemguiregistry.cpp
layout/qgslayoutitemcombobox.cpp
layout/qgslayoutitemwidget.cpp
layout/qgslayoutmousehandles.cpp
layout/qgslayoutnewitempropertiesdialog.cpp
@@ -667,6 +668,7 @@ SET(QGIS_GUI_MOC_HDRS
layertree/qgslayertreeviewdefaultactions.h

layout/qgslayoutdesignerinterface.h
layout/qgslayoutitemcombobox.h
layout/qgslayoutitemguiregistry.h
layout/qgslayoutitemwidget.h
layout/qgslayoutmousehandles.h
@@ -0,0 +1,117 @@
/***************************************************************************
qgslayoutitemcombobox.cpp
--------------------------------------
Date : October 2017
Copyright : (C) 201\7 Nyall Dawson
Email : nyall dot dawson 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 "qgslayoutitemcombobox.h"
#include "qgslayoutmodel.h"

QgsLayoutItemComboBox::QgsLayoutItemComboBox( QWidget *parent, QgsLayout *layout )
: QComboBox( parent )
{
setCurrentLayout( layout );

setModelColumn( QgsLayoutModel::ItemId );
connect( this, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutItemComboBox::indexChanged );
}

void QgsLayoutItemComboBox::setCurrentLayout( QgsLayout *layout )
{
mProxyModel = qgis::make_unique< QgsLayoutProxyModel >( layout, this );
connect( mProxyModel.get(), &QAbstractItemModel::rowsInserted, this, &QgsLayoutItemComboBox::rowsChanged );
connect( mProxyModel.get(), &QAbstractItemModel::rowsRemoved, this, &QgsLayoutItemComboBox::rowsChanged );
setModel( mProxyModel.get() );
setModelColumn( QgsLayoutModel::ItemId );
mProxyModel->sort( 0, Qt::AscendingOrder );
}

void QgsLayoutItemComboBox::setItem( const QgsLayoutItem *item )
{
if ( !mProxyModel->sourceLayerModel() )
return;

QModelIndex idx = mProxyModel->sourceLayerModel()->indexForItem( const_cast< QgsLayoutItem * >( item ) );
if ( idx.isValid() )
{
QModelIndex proxyIdx = mProxyModel->mapFromSource( idx );
if ( proxyIdx.isValid() )
{
setCurrentIndex( proxyIdx.row() );
emit itemChanged( currentItem() );
return;
}
}
setCurrentIndex( -1 );
emit itemChanged( currentItem() );
}

QgsLayoutItem *QgsLayoutItemComboBox::currentItem() const
{
return item( currentIndex() );
}

void QgsLayoutItemComboBox::indexChanged( int i )
{
Q_UNUSED( i );
emit itemChanged( currentItem() );
}

void QgsLayoutItemComboBox::rowsChanged()
{
if ( count() == 1 )
{
//currently selected item has changed
emit itemChanged( currentItem() );
}
else if ( count() == 0 )
{
emit itemChanged( nullptr );
}
}

void QgsLayoutItemComboBox::setItemType( QgsLayoutItemRegistry::ItemType itemType )
{
mProxyModel->setFilterType( itemType );
}

QgsLayoutItemRegistry::ItemType QgsLayoutItemComboBox::itemType() const
{
return mProxyModel->filterType();
}

void QgsLayoutItemComboBox::setExceptedItemList( const QList<QgsLayoutItem *> &exceptList )
{
mProxyModel->setExceptedItemList( exceptList );
}

QList< QgsLayoutItem *> QgsLayoutItemComboBox::exceptedItemList() const
{
return mProxyModel->exceptedItemList();
}

QgsLayoutItem *QgsLayoutItemComboBox::item( int index ) const
{
const QModelIndex proxyIndex = mProxyModel->index( index, 0 );
if ( !proxyIndex.isValid() )
{
return nullptr;
}

QModelIndex sourceIndex = mProxyModel->mapToSource( proxyIndex );
if ( !sourceIndex.isValid() )
{
return nullptr;
}

return mProxyModel->itemFromSourceIndex( sourceIndex );
}

0 comments on commit 1f769da

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