Merge pull request #3485 from nyalldawson/composer_dep

Remove deprecated methods from composer
This commit is contained in:
Nyall Dawson 2016-09-15 05:59:17 +10:00 committed by GitHub
commit aac7e9aa39
77 changed files with 176 additions and 7894 deletions

View File

@ -181,6 +181,11 @@ This page tries to maintain a list with incompatible changes that happened in pr
<li>QgsColorbutton was removed. QgsColorButtonV2 has now been renamed to QgsColorButton. Hence, QgsColorButtonV2 does not exist anymore.</li>
<li>QgsColorDialog was removed, and QgsColorDialogV2 was renamed to QgsColorDialog. Hence, QgsColorButtonV2 does not exist anymore.
All the functionality from the old QgsColorDialog has been moved to the new class.</li>
<li>QgsComposerAttributeTable and associated classes (eg QgsComposerAttributeTableCompare,
QgsComposerAttributeTableColumnModel, QgsComposerTableSortColumnsProxyModel) were removed.
Use QgsComposerAttributeTableV2 instead.</li>
<li>QgsComposerTable was removed. Use QgsComposerAttributeTableV2 instead.</li>
<li>ComposerTextTable was removed. Use ComposerTextTableV2 instead.</li>
<li>QgsCRSCache was removed. QgsCoordinateReferenceSystem now internally uses a cache for CRS creation,
so there is no longer a need for the separate cache class. Code which previously called QgsCRSCache::updateCRSCache()
should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinateTransformCache::instance()->invalidateCrs( authid ).</li>
@ -290,6 +295,15 @@ variant instead.</li>
<ul>
<li>readXMLMapSettings() has been renamed to readXmlMapSettings()</li>
<li>composerMap() and setComposerMap() were removed. Use QgsComposerMap::atlasDriven() and setAtlasDriven()
instead</li>
<li>fixedScale() and setFixedScale() were removed. Use QgsComposerMap::atlasScalingMode() and setAtlasScalingMode()
instead</li>
<li>margin() and setMargin() were removed. Use QgsComposerMap::atlasMargin() and setAtlasMargin()
instead</li>
<li>setSortKeyAttributeIndex() and sortKeyAttributeIndex() were removed. Use sortKeyAttributeName()
and setSortKeyAttributeName() instead.</li>
<li>currentFeature() was removed. Use feature() instead.</li>
</ul>
\subsection qgis_api_break_3_0_QgsAuthConfigUriEdit QgsAuthConfigUriEdit
@ -323,6 +337,36 @@ and the new ramp can be retrieved after executing the dialog by calling ramp().<
<li>Some internal methods which were previously public or protected were made private.</li>
</ul>
\subsection qgis_api_break_3_0_QgsComposerArrow QgsComposerArrow
<ul>
<li>setOutlineWidth(), outlineWidth(), arrowColor() and setArrowColor() were removed.
Use setArrowHeadOutlineWidth(), arrowHeadOutlineWidth(), arrowHeadOutlineColor(),
setArrowHeadOutlineColor(), arrowHeadFillColor(), setArrowHeadFillColor(),
setLineSymbol() or lineSymbol() instead.</li>
</ul>
\subsection qgis_api_break_3_0_QgsComposerAttributeTableV2 QgsComposerAttributeTableV2
<ul>
<li>setDisplayAttributes() was removed. Use setDisplayedFields() instead.</li>
</ul>
\subsection qgis_api_break_3_0_QgsComposerItem QgsComposerItem
<ul>
<li>zoomContent( int delta, double x, double y ) was removed. Use zoomContent( double, QPointF, ZoomMode )
instead.</li>
<li>drawText(), textWidthMillimeters(), fontHeightCharacterMM(), fontAscentMillimeters(),
fontDescentMillimeters(), fontHeightMillimeters(), pixelFontSize(), scaledFontPixelSize(),
drawArrowHead(), angle(), largestRotatedRectWithinBounds(), and rotate() were removed.
Use the corresponding methods in QgsComposerUtils instead.</li>
<li>rotation() and setRotation() were removed. Use itemRotation() and setItemRotation()
instead.</li>
<li>lockSymbolSize(), imageSizeConsideringRotation(), cornerPointOnRotatedAndScaledRect(),
sizeChangedByRotation() were removed. No replacement is offered for these methods.</li>
</ul>
\subsection qgis_api_break_3_0_QgsComposerLabel QgsComposerLabel
<ul>
@ -330,6 +374,7 @@ and the new ramp can be retrieved after executing the dialog by calling ramp().<
expression variables in the composer label item instead.</li>
<li>setSubstitutions has been removed. Use expression context variables in the composer
label item instead.</li>
<li>margin() was removed. Use marginX() and marginY() instead.</li>
</ul>
\subsection qgis_api_break_3_0_QgsComposerLegend QgsComposerLegend
@ -350,6 +395,34 @@ label item instead.</li>
<ul>
<li>containsWMSLayer() has been renamed to containsWmsLayer()</li>
<li>mapRenderer() has been removed. Use mapSettings() instead.</li>
<li>All grid style and format enums were moved to QgsComposerMapGrid.</li>
<li>All grid property getters and setters were moved to QgsComposerMapGrid,
and should be accessed using QgsComposerMap::grid() or QgsComposerMap::grids().</li>
<li>All overview property getters and setters were moved to QgsComposerMapOverview,
and should be accessed using QgsComposerMap::overview() or QgsComposerMap::overviews().</li>
<li>overviewExtentChanged() was moved to QgsComposerMapOverview.</li>
<li>toggleAtlasPreview(), connectMapOverviewSignals() were no longer required and are removed.</li>
<li>setRotation() and rotation() were removed. Use setMapRotation() and mapRotation()
instead.</li>
<li>atlasFixedScale() and setAtlasFixedScale() were removed. Use atlasScalingMode()
and setAtlasScalingMode() instead.</li>
</ul>
\subsection qgis_api_break_3_0_QgsComposerMapGrid QgsComposerMapGrid
<ul>
<li>The annotation position Disabled was removed. QgsComposerMapGrid::HideAll
should be used instead.</li>
</ul>
\subsection qgis_api_break_3_0_QgsComposerMultiFrame QgsComposerMultiFrame
<ul>
<li>render( QPainter* p, const QRectF& renderExtent ) was removed. Use
render( QPainter* painter, const QRectF& renderExtent, const int frameIndex )
instead.</li>
<li>render( QPainter* painter, const QRectF& renderExtent, const int frameIndex )
was made pure virtual.</li>
</ul>
\subsection qgis_api_break_3_0_QgsComposerNodesItem QgsComposerNodesItem
@ -359,6 +432,20 @@ label item instead.</li>
<li>_writeXMLStyle() has been renamed to _writeXMLStyle()</li>
</ul>
\subsection qgis_api_break_3_0_QgsComposerPicture QgsComposerPicture
<ul>
<li>setPictureFile() and pictureFile() were removed. Use setPicturePath()
and picturePath() instead.</li>
<li>rotation() and setRotation() were removed. Use pictureRotation()
and setPictureRotation() instead.</li>
<li>usePictureExpression() and pictureExpression() were removed. Use
QgsComposerObject::dataDefinedProperty instead.</li>
<li>setUsePictureExpression() was removed. Use
QgsComposerObject::setDataDefinedProperty() instead.</li>
<li>updatePictureExpression() was removed.</li>
</ul>
\subsection qgis_api_break_3_0_QgsComposerTable QgsComposerTable
<ul>
@ -366,6 +453,12 @@ label item instead.</li>
<li>tableReadXML() has been renamed to tableReadXml()</li>
</ul>
\subsection qgis_api_break_3_0_QgsComposerTableV2 QgsComposerTableV2
<ul>
<li>rowsVisible(), rowRange(), drawHorizontalGridLines() and
drawVerticalGridLines() were removed.</li>
</ul>
\subsection qgis_api_break_3_0_QgsComposition QgsComposition
@ -373,6 +466,12 @@ label item instead.</li>
<li>addItemsFromXML() has been renamed to addItemsFromXml()</li>
<li>Constructor with QgsMapRenderer parameter has been removed. Use the variant with QgsMapSettings parameter.</li>
<li>mapRenderer() has been removed. Use mapSettings() instead.</li>
<li>setSnapGridTolerance(), setAlignmentSnapTolerance(), alignmentSnapTolerance() and snapGridTolerance()
were removed. Use setSnapTolerance() and snapTolerance() instead.</li>
<li>getComposerHtmlByItem() was removed. Use QgsComposerFrame::multiFrame() instead.</li>
<li>pixelFontSize(), pointFontSize(), relativeResizeRect(), relativePosition() were removed. Use the corresponding methods in QgsComposerUtils instead.</li>
<li>sortZList() was removed. Use refreshZList() instead.</li>
<li>addComposerTable(), composerTableAdded() were removed.</li>
</ul>
\subsection qgis_api_break_3_0_QgsCoordinateReferenceSystem QgsCoordinateReferenceSystem

View File

@ -21,4 +21,9 @@ be updated so that any expressions in use have the following changes:
<li>$numfeatures has been replaced by \@atlas_totalfeatures</li>
</ul>
\section qgis3_user_changes_composer Composer
Very old projects containing composer attribute tables will not restore the attribute
tables when loaded into QGIS 3.0. These tables must be manually readded to the compositions.
*/

View File

@ -223,49 +223,6 @@ public:
/** Recalculates the bounds of an atlas driven map */
void prepareMap( QgsComposerMap* map );
//deprecated methods
/** Returns the map used by the atlas
* @deprecated Use QgsComposerMap::atlasDriven() instead
*/
QgsComposerMap* composerMap() const /Deprecated/;
/** Sets the map used by the atlas
* @deprecated Use QgsComposerMap::setAtlasDriven( true ) instead
*/
void setComposerMap( QgsComposerMap* map ) /Deprecated/;
/** Returns whether the atlas map uses a fixed scale
* @deprecated since 2.4 Use QgsComposerMap::atlasScalingMode() instead
*/
bool fixedScale() const /Deprecated/;
/** Sets whether the atlas map should use a fixed scale
* @deprecated since 2.4 Use QgsComposerMap::setAtlasScalingMode() instead
*/
void setFixedScale( bool fixed ) /Deprecated/;
/** Returns the margin for the atlas map
* @deprecated Use QgsComposerMap::atlasMargin() instead
*/
float margin() const /Deprecated/;
/** Sets the margin for the atlas map
* @deprecated Use QgsComposerMap::setAtlasMargin( double ) instead
*/
void setMargin( float margin ) /Deprecated/;
//! @deprecated use sortKeyAttributeName instead
int sortKeyAttributeIndex() const /Deprecated/;
//! @deprecated use setSortKeyAttributeName instead
void setSortKeyAttributeIndex( int idx ) /Deprecated/;
/** Returns the current atlas feature. Must be called after prepareForFeature( i ).
* @deprecated use feature() instead
*/
QgsFeature* currentFeature() /Deprecated/;
/** Returns the current atlas geometry in the given projection system (default to the coverage layer's CRS) */
QgsGeometry currentGeometry( const QgsCoordinateReferenceSystem& projectedTo = QgsCoordinateReferenceSystem() ) const;

View File

@ -48,16 +48,6 @@ class QgsComposerArrow: QgsComposerItem
*/
double arrowHeadWidth() const;
/** Sets the pen width for drawing the line and arrow head
* @deprecated use setArrowHeadOutlineWidth or setLineSymbol instead
*/
void setOutlineWidth( double width ) /Deprecated/;
/** Returns the pen width for drawing the line and arrow head
* @deprecated use arrowHeadOutlineWidth or lineSymbol instead
*/
double outlineWidth() const /Deprecated/;
/** Sets the marker to draw at the start of the line
* @param svgPath file path for svg marker graphic to draw
* @see startMarker
@ -86,16 +76,6 @@ class QgsComposerArrow: QgsComposerItem
*/
QString endMarker() const;
/** Returns the color for the line and arrow head
* @deprecated use arrowHeadOutlineColor, arrowHeadFillColor or lineStyle instead
*/
QColor arrowColor() const /Deprecated/;
/** Sets the color for the line and arrow head
* @deprecated use setArrowHeadOutlineColor, setArrowHeadFillColor or setLineStyle instead
*/
void setArrowColor( const QColor& c ) /Deprecated/;
/** Returns the color used to draw outline around the the arrow head.
* @returns arrow head outline color
* @see arrowHeadFillColor

View File

@ -1,237 +0,0 @@
/** \ingroup core
* Attribute table item for map composer.
*/
/** Helper class for sorting tables, takes into account sorting column and ascending / descending*/
class QgsComposerAttributeTableCompare
{
%TypeHeaderCode
#include <qgscomposerattributetable.h>
%End
public:
QgsComposerAttributeTableCompare();
// bool operator()( const QgsAttributeMap& m1, const QgsAttributeMap& m2 );
/** Sets column number to sort by
* @param col column number for sorting
*/
void setSortColumn( int col );
/** Sets sort order for column sorting
* @param asc set to true to sort in ascending order, false to sort in descending order
*/
void setAscending( bool asc );
};
/** A table class that displays a vector attribute table
* @deprecated use QgsComposerAttributeTableV2 instead
*/
class QgsComposerAttributeTable : QgsComposerTable
{
%TypeHeaderCode
#include <qgscomposerattributetable.h>
%End
public:
QgsComposerAttributeTable( QgsComposition* composition /TransferThis/ ) /Deprecated/;
~QgsComposerAttributeTable();
/** Return correct graphics item type. */
virtual int type() const;
/** \brief Reimplementation of QCanvasItem::paint*/
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
/** Writes properties specific to attribute tables
* @param elem an existing QDomElement in which to store the attribute table's properties.
* @param doc QDomDocument for the destination xml.
* @see readXML
*/
bool writeXml( QDomElement& elem, QDomDocument & doc ) const;
/** Reads the properties specific to an attribute table from xml.
* @param itemElem a QDomElement holding the attribute table's desired properties.
* @param doc QDomDocument for the source xml.
* @see writeXML
*/
bool readXml( const QDomElement& itemElem, const QDomDocument& doc );
/** Sets the vector layer from which to display feature attributes
* @param layer Vector layer for attribute table
* @see vectorLayer
*/
void setVectorLayer( QgsVectorLayer* layer );
/** Returns the vector layer the attribute table is currently using
* @returns attribute table's current vector layer
* @see setVectorLayer
*/
QgsVectorLayer* vectorLayer() const;
/** Resets the attribute table's columns to match the vector layer's fields
* @note added in 2.3
* @see setVectorLayer
*/
void resetColumns();
/** Sets the composer map to use to limit the extent of features shown in the
* attribute table. This setting only has an effect if setDisplayOnlyVisibleFeatures is
* set to true. Changing the composer map forces the table to refetch features from its
* vector layer, and may result in the table changing size to accommodate the new displayed
* feature attributes.
* @param map QgsComposerMap which drives the extents of the table's features
* @see composerMap
* @see setDisplayOnlyVisibleFeatures
*/
void setComposerMap( const QgsComposerMap* map );
/** Returns the composer map whose extents are controlling the features shown in the
* table. The extents of the map are only used if displayOnlyVisibleFeatures() is true.
* @returns composer map controlling the attribute table
* @see setComposerMap
* @see displayOnlyVisibleFeatures
*/
const QgsComposerMap* composerMap() const;
/** Sets the maximum number of features shown by the table. Changing this setting may result
* in the attribute table changing its size to accommodate the new number of rows, and requires
* the table to refetch features from its vector layer.
* @param features maximum number of features to show in the table
* @see maximumNumberOfFeatures
*/
void setMaximumNumberOfFeatures( int features );
/** Returns the maximum number of features to be shown by the table.
* @returns maximum number of features
* @see setMaximumNumberOfFeatures
*/
int maximumNumberOfFeatures() const;
/** Sets attribute table to only show features which are visible in a composer map item. Changing
* this setting forces the table to refetch features from its vector layer, and may result in
* the table changing size to accommodate the new displayed feature attributes.
* @param visibleOnly set to true to show only visible features
* @see displayOnlyVisibleFeatures
* @see setComposerMap
*/
void setDisplayOnlyVisibleFeatures( bool b );
/** Returns true if the table is set to show only features visible on a corresponding
* composer map item.
* @returns true if table only shows visible features
* @see composerMap
* @see setDisplayOnlyVisibleFeatures
*/
bool displayOnlyVisibleFeatures() const;
/** Returns true if a feature filter is active on the attribute table
* @returns bool state of the feature filter
* @note added in 2.3
* @see setFilterFeatures
* @see featureFilter
*/
bool filterFeatures() const;
/** Sets whether the feature filter is active for the attribute table. Changing
* this setting forces the table to refetch features from its vector layer, and may result in
* the table changing size to accommodate the new displayed feature attributes.
* @param filter Set to true to enable the feature filter
* @note added in 2.3
* @see filterFeatures
* @see setFeatureFilter
*/
void setFilterFeatures( bool filter );
/** Returns the current expression used to filter features for the table. The filter is only
* active if filterFeatures() is true.
* @returns feature filter expression
* @note added in 2.3
* @see setFeatureFilter
* @see filterFeatures
*/
QString featureFilter() const;
/** Sets the expression used for filtering features in the table. The filter is only
* active if filterFeatures() is set to true. Changing this setting forces the table
* to refetch features from its vector layer, and may result in
* the table changing size to accommodate the new displayed feature attributes.
* @param expression filter to use for selecting which features to display in the table
* @note added in 2.3
* @see featureFilter
* @see setFilterFeatures
*/
void setFeatureFilter( const QString& expression );
/** Returns the attributes fields which are shown by the table.
* @returns a QSet of integers refering to the attributes in the vector layer. If
* result is an empty QSet than all feature attributes will be shown.
* @see setDisplayAttributes
* @deprecated use QgsComposerTable::columns() instead
*/
QSet<int> displayAttributes() const /Deprecated/;
/** Sets the attributes to display in the table.
* @param attr QSet of integer values refering to the attributes from the vector layer to show.
* Set to an empty QSet to show all feature attributes.
* @param refresh set to true to force the table to refetch features from its vector layer
* and immediately update the display of the table. This may result in the table changing size
* to accommodate the new displayed feature attributes.
* @see displayAttributes
*/
void setDisplayAttributes( const QSet<int>& attr );
/** Returns the attribute field aliases, which control how fields are named in the table's
* header row.
* @returns a QMap of integers to strings, where the string is the field's alias and the
* integer is the field index from the associated vector layer.
* @see setFieldAliasMap
* @deprecated use QgsComposerTable::columns() instead
*/
QMap<int, QString> fieldAliasMap() const /Deprecated/;
/** Sets the attribute field aliases, which control how fields are named in the table's
* header row.
* @param map QMap of integers to strings, where the string is the alias to use for the
* corresponding field, and the integer is the field index from the vector layer
* @see fieldAliasMap
* @deprecated use QgsComposerTable::columns() instead
*/
void setFieldAliasMap( const QMap<int, QString>& map ) /Deprecated/;
/** Adapts mMaximumNumberOfFeatures depending on the rectangle height. Calling this forces
* the table to refetch features from its vector layer and immediately updates the display
* of the table.
* @see maximumNumberOfFeatures
* @see setMaximumNumberOfFeatures
*/
void setSceneRect( const QRectF& rectangle );
/** Sets the attributes to use to sort the table's features.
* @param att QList integers/bool pairs, where the integer refers to the attribute index and
* the bool sets the sort order for the attribute. If true the attribute is sorted ascending,
* if false, the attribute is sorted in descending order. Note that features are sorted
* after the maximum number of displayed features have been fetched from the vector layer's
* provider.
* @see sortAttributes
* @deprecated use QgsComposerTable::columns() instead
* @note not available in python bindings
*/
// void setSortAttributes( const QList<QPair<int, bool> >& att ) /Deprecated/;
/** Returns the attributes used to sort the table's features.
* @returns a QList of integer/bool pairs, where the integer refers to the attribute index and
* the bool to the sort order for the attribute. If true the attribute is sorted ascending,
* if false, the attribute is sorted in descending order.
* @note not available in python bindings
*/
// QList<QPair<int, bool> > sortAttributes() const;
/** Queries the attribute table's vector layer for attributes to show in the table.
* @param attributeMaps list of QgsAttributeMaps where the fetched feature attributes will be stored
* @returns true if attributes were successfully fetched
* @note not available in python bindings
*/
// bool getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps );
};

View File

@ -1,167 +0,0 @@
/** A model for displaying columns shown in a QgsComposerAttributeTable*/
class QgsComposerAttributeTableColumnModel: QAbstractTableModel
{
%TypeHeaderCode
#include <qgscomposerattributetablemodel.h>
%End
public:
/** Controls whether a row/column is shifted up or down
*/
enum ShiftDirection
{
ShiftUp, /*!< shift the row/column up */
ShiftDown /*!< shift the row/column down */
};
/** Constructor for QgsComposerAttributeTableColumnModel.
* @param composerTable QgsComposerAttributeTable the model is attached to
* @param parent optional parent
*/
QgsComposerAttributeTableColumnModel( QgsComposerAttributeTable *composerTable, QObject *parent /TransferThis/ = 0 );
virtual ~QgsComposerAttributeTableColumnModel();
virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
int columnCount( const QModelIndex &parent = QModelIndex() ) const;
virtual QVariant data( const QModelIndex &index, int role ) const;
QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
Qt::ItemFlags flags( const QModelIndex &index ) const;
bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() );
bool insertRows( int row, int count, const QModelIndex &parent = QModelIndex() );
QModelIndex index( int row, int column, const QModelIndex &parent ) const;
QModelIndex parent( const QModelIndex &child ) const;
/** Moves the specified row up or down in the model. Used for rearranging the attribute tables
* columns.
* @returns true if the move is allowed
* @param row row in model representing attribute table column to move
* @param direction direction to move the attribute table column
* @note added in 2.3
*/
bool moveRow( int row, ShiftDirection direction );
/** Resets the attribute table's columns to match the source layer's fields. Remove all existing
* attribute table columns and column customisations.
* @note added in 2.3
*/
void resetToLayer();
/** Returns the QgsComposerTableColumn corresponding to an index in the model.
* @returns QgsComposerTableColumn for specified index
* @param index a QModelIndex
* @note added in 2.3
* @see indexFromColumn
*/
QgsComposerTableColumn* columnFromIndex( const QModelIndex & index ) const;
/** Returns a QModelIndex corresponding to a QgsComposerTableColumn in the model.
* @returns QModelIndex for specified QgsComposerTableColumn
* @param column a QgsComposerTableColumn
* @note added in 2.3
* @see columnFromIndex
*/
QModelIndex indexFromColumn( QgsComposerTableColumn *column );
/** Sets a specified column as a sorted column in the QgsComposerAttributeTable. The column will be
* added to the end of the sort rank list, ie it will take the next largest available sort rank.
* @param column a QgsComposerTableColumn
* @param order sort order for column
* @note added in 2.3
* @see removeColumnFromSort
* @see moveColumnInSortRank
*/
void setColumnAsSorted( QgsComposerTableColumn *column, Qt::SortOrder order );
/** Sets a specified column as an unsorted column in the QgsComposerAttributeTable. The column will be
* removed from the sort rank list.
* @param column a QgsComposerTableColumn
* @note added in 2.3
* @see setColumnAsSorted
*/
void setColumnAsUnsorted( QgsComposerTableColumn * column );
/** Moves a column up or down in the sort rank for the QgsComposerAttributeTable.
* @param column a QgsComposerTableColumn
* @param direction direction to move the column in the sort rank list
* @note added in 2.3
* @see setColumnAsSorted
*/
bool moveColumnInSortRank( QgsComposerTableColumn * column, ShiftDirection direction );
};
//QgsComposerTableSortColumnsProxyModel
/** Allows for filtering QgsComposerAttributeTable columns by columns which are sorted or unsorted*/
class QgsComposerTableSortColumnsProxyModel : QSortFilterProxyModel
{
%TypeHeaderCode
#include <qgscomposerattributetablemodel.h>
%End
public:
/** Controls whether the proxy model shows sorted or unsorted columns
*/
enum ColumnFilterType
{
ShowSortedColumns, /*!< show only sorted columns */
ShowUnsortedColumns /*!< show only unsorted columns */
};
/** Constructor for QgsComposerTableSortColumnsProxyModel.
* @param composerTable QgsComposerAttributeTable the model is attached to
* @param filterType filter for columns, controls whether sorted or unsorted columns are shown
* @param parent optional parent
*/
QgsComposerTableSortColumnsProxyModel( QgsComposerAttributeTable *composerTable, QgsComposerTableSortColumnsProxyModel::ColumnFilterType filterType, QObject *parent /TransferThis/ = 0 );
virtual ~QgsComposerTableSortColumnsProxyModel();
bool lessThan( const QModelIndex &left, const QModelIndex &right ) const;
int columnCount( const QModelIndex &parent = QModelIndex() ) const;
virtual QVariant data( const QModelIndex &index, int role ) const;
QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
Qt::ItemFlags flags( const QModelIndex &index ) const;
virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
/** Returns the QgsComposerTableColumn corresponding to a row in the proxy model.
* @returns QgsComposerTableColumn for specified row
* @param row a row number
* @note added in 2.3
* @see columnFromIndex
*/
QgsComposerTableColumn* columnFromRow( int row );
/** Returns the QgsComposerTableColumn corresponding to an index in the proxy model.
* @returns QgsComposerTableColumn for specified index
* @param index a QModelIndex
* @note added in 2.3
* @see columnFromRow
* @see columnFromSourceIndex
*/
QgsComposerTableColumn* columnFromIndex( const QModelIndex & index ) const;
/** Returns the QgsComposerTableColumn corresponding to an index from the source
* QgsComposerAttributeTableColumnModel model.
* @returns QgsComposerTableColumn for specified index from QgsComposerAttributeTableColumnModel
* @param sourceIndex a QModelIndex
* @note added in 2.3
* @see columnFromRow
* @see columnFromIndex
*/
QgsComposerTableColumn* columnFromSourceIndex( const QModelIndex& sourceIndex ) const;
/** Invalidates the current filter used by the proxy model
* @note added in 2.3
*/
void resetFilter();
protected:
bool filterAcceptsRow( int source_row, const QModelIndex & source_parent ) const;
};

View File

@ -230,16 +230,6 @@ class QgsComposerAttributeTableV2 : QgsComposerTableV2
*/
void setFeatureFilter( const QString& expression );
/** Sets the attributes to display in the table.
* @param attr QSet of integer values refering to the attributes from the vector layer to show.
* Set to an empty QSet to show all feature attributes.
* @param refresh set to true to force the table to refetch features from its vector layer
* and immediately update the display of the table. This may result in the table changing size
* to accommodate the new displayed feature attributes.
* @deprecated use setDisplayedFields() instead
*/
void setDisplayAttributes( const QSet<int>& attr, bool refresh = true ) /Deprecated/;
/** Sets the attributes to display in the table.
* @param fields list of fields names from the vector layer to show.
* Set to an empty list to show all feature attributes.

View File

@ -17,9 +17,7 @@ class QgsComposerItem : QgsComposerObject, QGraphicsRectItem
#include <qgscomposershape.h>
#include <qgscomposerpolygon.h>
#include <qgscomposerpolyline.h>
#include <qgscomposertable.h>
#include <qgscomposertexttable.h>
#include <qgscomposerattributetable.h>
%End
%ConvertToSubClassCode
@ -75,18 +73,6 @@ class QgsComposerItem : QgsComposerObject, QGraphicsRectItem
sipType = sipType_QgsComposerPolyline;
*sipCppRet = static_cast<QgsComposerPolyline*>(sipCpp);
break;
case QgsComposerItem::ComposerTable:
sipType = sipType_QgsComposerTable;
*sipCppRet = static_cast<QgsComposerTable*>(sipCpp);
break;
case QgsComposerItem::ComposerAttributeTable:
sipType = sipType_QgsComposerAttributeTable;
*sipCppRet = static_cast<QgsComposerAttributeTable*>(sipCpp);
break;
case QgsComposerItem::ComposerTextTable:
sipType = sipType_QgsComposerTextTable;
*sipCppRet = static_cast<QgsComposerTextTable*>(sipCpp);
break;
case QgsComposerItem::ComposerFrame:
sipType = sipType_QgsComposerFrame;
*sipCppRet = static_cast<QgsComposerFrame*>(sipCpp);
@ -210,14 +196,6 @@ class QgsComposerItem : QgsComposerObject, QGraphicsRectItem
@param dy move in y-direction(canvas coordinates)*/
virtual void moveContent( double dx, double dy );
/** Zoom content of item. Does nothing per default (but implemented in composer map)
* @param delta value from wheel event that describes direction (positive /negative number)
* @param x x-position of mouse cursor (in item coordinates)
* @param y y-position of mouse cursor (in item coordinates)
* @deprecated use zoomContent( double, QPointF, ZoomMode ) instead
*/
virtual void zoomContent( int delta, double x, double y ) /Deprecated/;
/** Zoom content of item. Does nothing per default (but implemented in composer map)
* @param factor zoom factor, where > 1 results in a zoom in and < 1 results in a zoom out
* @param point item point for zoom center
@ -473,61 +451,6 @@ class QgsComposerItem : QgsComposerObject, QGraphicsRectItem
//functions that encapsulate the workaround for the Qt font bug (that is to scale the font size up and then scale the
//painter down by the same factor for drawing
/** Draws Text. Takes care about all the composer specific issues (calculation to pixel, scaling of font and painter
* to work around the Qt font bug)
* @deprecated use QgsComposerUtils::drawText instead
*/
void drawText( QPainter* p, double x, double y, const QString& text, const QFont& font ) const /Deprecated/;
/** Like the above, but with a rectangle for multiline text
* @param p painter to use
* @param rect rectangle to draw into
* @param text text to draw
* @param font font to use
* @param halignment optional horizontal alignment
* @param valignment optional vertical alignment
* @param flags allows for passing Qt::TextFlags to control appearance of rendered text
* @deprecated use QgsComposerUtils::drawText instead
*/
void drawText( QPainter* p, const QRectF& rect, const QString& text, const QFont& font, Qt::AlignmentFlag halignment = Qt::AlignLeft, Qt::AlignmentFlag valignment = Qt::AlignTop, int flags = Qt::TextWordWrap ) const /Deprecated/;
/** Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE
* @deprecated use QgsComposerUtils::textWidthMM instead
*/
double textWidthMillimeters( const QFont& font, const QString& text ) const /Deprecated/;
/** Returns the font height of a character in millimeters
* @deprecated use QgsComposerUtils::fontHeightCharacterMM instead
*/
double fontHeightCharacterMM( const QFont& font, QChar c ) const /Deprecated/;
/** Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE
* @deprecated use QgsComposerUtils::fontAscentMM instead
*/
double fontAscentMillimeters( const QFont& font ) const /Deprecated/;
/** Returns the font descent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE
* @deprecated use QgsComposerUtils::fontDescentMM instead
*/
double fontDescentMillimeters( const QFont& font ) const /Deprecated/;
/** Returns the font height in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE.
* Font height equals the font ascent+descent+1 (for baseline).
* @note Added in version 2.4
* @deprecated use QgsComposerUtils::fontHeightMM instead
*/
double fontHeightMillimeters( const QFont& font ) const /Deprecated/;
/** Calculates font size in mm from a font point size
* @deprecated use QgsComposerUtils::mmFontSize instead
*/
double pixelFontSize( double pointSize ) const /Deprecated/;
/** Returns a font where size is in pixel and font size is upscaled with FONT_WORKAROUND_SCALE
* @deprecated use QgsComposerUtils::scaledFontPixelSize instead
*/
QFont scaledFontPixelSize( const QFont& font ) const /Deprecated/;
/** Locks / unlocks the item position for mouse drags
* @param lock set to true to prevent item movement and resizing via the mouse
* @see positionLock
@ -550,11 +473,6 @@ class QgsComposerItem : QgsComposerObject, QGraphicsRectItem
*/
double itemRotation( const QgsComposerObject::PropertyValueType valueType = QgsComposerObject::EvaluatedValue ) const;
/** Returns the rotation for the composer item
* @deprecated Use itemRotation() instead
*/
double rotation() const /Deprecated/;
/** Updates item, with the possibility to do custom update for subclasses*/
virtual void updateItem();
@ -648,10 +566,6 @@ class QgsComposerItem : QgsComposerObject, QGraphicsRectItem
QgsExpressionContext createExpressionContext() const;
public slots:
/** Sets the item rotation
* @deprecated Use setItemRotation( double rotation ) instead
*/
virtual void setRotation( double r );
/** Sets the item rotation
* @param r item rotation in degrees
@ -694,25 +608,10 @@ class QgsComposerItem : QgsComposerObject, QGraphicsRectItem
/** Draw background*/
virtual void drawBackground( QPainter* p );
/** Draws arrowhead
* @deprecated use QgsComposerUtils::drawArrowHead instead
*/
void drawArrowHead( QPainter* p, double x, double y, double angle, double arrowHeadWidth ) const /Deprecated/;
/** Returns angle of the line from p1 to p2 (clockwise, starting at N)
* @deprecated will be removed in QGIS 3.0
*/
double angle( QPointF p1, QPointF p2 ) const /Deprecated/;
/** Returns the current (zoom level dependent) tolerance to decide if mouse position is close enough to the
item border for resizing*/
double rectHandlerBorderTolerance() const;
/** Returns the size of the lock symbol depending on the composer zoom level and the item size
* @deprecated will be removed in QGIS 3.0
*/
double lockSymbolSize() const /Deprecated/;
/** Returns the zoom factor of the graphics view.
* @return the factor or -1 in case of error (e.g. graphic view does not exist)
*/
@ -720,53 +619,6 @@ class QgsComposerItem : QgsComposerObject, QGraphicsRectItem
//some utility functions
/** Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation.
* @deprecated will be removed in QGIS 3.0
*/
bool imageSizeConsideringRotation( double& width, double& height, double rotation ) const /Deprecated/;
/** Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation
* @deprecated will be removed in QGIS 3.0
*/
bool imageSizeConsideringRotation( double& width, double& height ) const /Deprecated/;
/** Calculates the largest scaled version of originalRect which fits within boundsRect, when it is rotated by
* a specified amount
* @param originalRect QRectF to be rotated and scaled
* @param boundsRect QRectF specifying the bounds which the rotated and scaled rectangle must fit within
* @param rotation the rotation in degrees to be applied to the rectangle
* @deprecated use QgsComposerUtils::largestRotatedRectWithinBounds instead
*/
QRectF largestRotatedRectWithinBounds( const QRectF& originalRect, const QRectF& boundsRect, double rotation ) const /Deprecated/;
/** Calculates corner point after rotation and scaling
* @deprecated will be removed in QGIS 3.0
*/
bool cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height, double rotation ) const /Deprecated/;
/** Calculates corner point after rotation and scaling
* @deprecated will be removed in QGIS 3.0
*/
bool cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height ) const /Deprecated/;
/** Calculates width / height of the bounding box of a rotated rectangle
* @deprecated will be removed in QGIS 3.0
*/
void sizeChangedByRotation( double& width, double& height, double rotation ) /Deprecated/;
/** Calculates width / height of the bounding box of a rotated rectangle
* @deprecated will be removed in QGIS 3.0
*/
void sizeChangedByRotation( double& width, double& height ) /Deprecated/;
/** Rotates a point / vector
* @param angle rotation angle in degrees, counterclockwise
* @param x in/out: x coordinate before / after the rotation
* @param y in/out: y cooreinate before / after the rotation
* @deprecated use QgsComposerUtils:rotate instead
*/
void rotate( double angle, double& x, double& y ) const /Deprecated/;
/** Return horizontal align snap item. Creates a new graphics line if 0*/
QGraphicsLineItem* hAlignSnapItem();
void deleteHAlignSnapItem();

View File

@ -49,12 +49,6 @@ class QgsComposerLabel : QgsComposerItem
*/
void setVAlign( Qt::AlignmentFlag a );
/** Returns the margin between the edge of the frame and the label contents
* @returns margin in mm
* @deprecated use marginX and marginY instead
*/
double margin() /Deprecated/;
/** Returns the horizontal margin between the edge of the frame and the label
* contents.
* @returns horizontal margin in mm

View File

@ -27,62 +27,6 @@ class QgsComposerMap : QgsComposerItem
Rectangle // Display only rectangle
};
//grid enums are moved to QgsComposerMapGrid
//TODO - remove for QGIS 3.0
enum GridStyle
{
Solid, //solid lines
Cross, //only draw line crossings
Markers,
FrameAnnotationsOnly
};
enum GridAnnotationPosition
{
InsideMapFrame,
OutsideMapFrame,
Disabled
};
enum GridAnnotationDirection
{
Horizontal,
Vertical,
HorizontalAndVertical,
BoundaryDirection
};
enum GridAnnotationFormat
{
Decimal,
DegreeMinute,
DegreeMinuteSecond,
DecimalWithSuffix,
DegreeMinuteNoSuffix,
DegreeMinutePadded,
DegreeMinuteSecondNoSuffix,
DegreeMinuteSecondPadded
};
enum GridFrameStyle
{
NoGridFrame,
Zebra, // black/white pattern
InteriorTicks,
ExteriorTicks,
InteriorExteriorTicks,
LineBorder
};
/** Enum for different frame borders*/
enum Border
{
Left,
Right,
Bottom,
Top
};
/** Scaling modes used for the serial rendering (atlas)
*/
enum AtlasScalingMode
@ -132,14 +76,6 @@ class QgsComposerMap : QgsComposerItem
*/
void moveContent( double dx, double dy );
/** Zoom content of map
* @param delta value from wheel event that describes direction (positive /negative number)
* @param x x-position of mouse cursor (in item coordinates)
* @param y y-position of mouse cursor (in item coordinates)
* @deprecated use zoomContent( double, QPointF, ZoomMode ) instead
*/
void zoomContent( int delta, double x, double y ) /Deprecated/;
/** Zoom content of item. Does nothing per default (but implemented in composer map)
* @param factor zoom factor, where > 1 results in a zoom in and < 1 results in a zoom out
* @param point item point for zoom center
@ -180,11 +116,6 @@ class QgsComposerMap : QgsComposerItem
*/
void setNewAtlasFeatureExtent( const QgsRectangle& extent );
/** Called when atlas preview is toggled, to force map item to update its extent and redraw
* @deprecated no longer required
*/
void toggleAtlasPreview() /Deprecated/;
/** Returns a pointer to the current map extent, which is either the original user specified
* extent or the temporary atlas-driven feature extent depending on the current atlas state
* of the composition. Both a const and non-const version are included.
@ -270,263 +201,6 @@ class QgsComposerMap : QgsComposerItem
*/
bool readXml( const QDomElement& itemElem, const QDomDocument& doc );
/** Enables a coordinate grid that is shown on top of this composermap.
* @deprecated use grid()->setEnabled() or grids() instead
*/
void setGridEnabled( bool enabled ) /Deprecated/;
/**
* @deprecated use grid()->enabled() or grids() instead
*/
bool gridEnabled() const /Deprecated/;
/** Sets coordinate grid style to solid or cross
* @deprecated use grid()->setStyle() or grids() instead
*/
void setGridStyle( GridStyle style ) /Deprecated/;
/**
* @deprecated use grid()->style() or grids() instead
*/
GridStyle gridStyle() const /Deprecated/;
/** Sets coordinate interval in x-direction for composergrid.
* @deprecated use grid()->setIntervalX() or grids() instead
*/
void setGridIntervalX( double interval ) /Deprecated/;
/**
* @deprecated use grid()->intervalX() or grids() instead
*/
double gridIntervalX() const /Deprecated/;
/** Sets coordinate interval in y-direction for composergrid.
* @deprecated use grid()->setIntervalY() or grids() instead
*/
void setGridIntervalY( double interval ) /Deprecated/;
/**
* @deprecated use grid()->intervalY() or grids() instead
*/
double gridIntervalY() const /Deprecated/;
/** Sets x-coordinate offset for composer grid
* @deprecated use grid()->setOffsetX() or grids() instead
*/
void setGridOffsetX( double offset ) /Deprecated/;
/**
* @deprecated use grid()->offsetX() or grids() instead
*/
double gridOffsetX() const /Deprecated/;
/** Sets y-coordinate offset for composer grid
* @deprecated use grid()->setOffsetY() or grids() instead
*/
void setGridOffsetY( double offset ) /Deprecated/;
/**
* @deprecated use grid()->offsetY() or grids() instead
*/
double gridOffsetY() const /Deprecated/;
/** Sets the pen to draw composer grid
* @deprecated use grid()->setPenWidth(), grid()->setPenColor() or grids() instead
*/
void setGridPen( const QPen& p ) /Deprecated/;
/**
* @deprecated use grid()->pen() or grids() instead
*/
QPen gridPen() const /Deprecated/;
/** Sets width of grid pen
* @deprecated use grid()->setPenWidth() or grids() instead
*/
void setGridPenWidth( double w ) /Deprecated/;
/** Sets the color of the grid pen
* @deprecated use grid()->setPenColor() or grids() instead
*/
void setGridPenColor( const QColor& c ) /Deprecated/;
/** Sets font for grid annotations
* @deprecated use grid()->setAnnotationFont() or grids() instead
*/
void setGridAnnotationFont( const QFont& f ) /Deprecated/;
/**
* @deprecated use grid()->annotationFont() or grids() instead
*/
QFont gridAnnotationFont() const /Deprecated/;
/** Sets font color for grid annotations
* @deprecated use grid()->setAnnotationFontColor() or grids() instead
*/
void setAnnotationFontColor( const QColor& c ) /Deprecated/;
/** Get font color for grid annotations
* @deprecated use grid()->annotationFontColor() or grids() instead
*/
QColor annotationFontColor() const /Deprecated/;
/** Sets coordinate precision for grid annotations
* @deprecated use grid()->setAnnotationPrecision or grids() instead
*/
void setGridAnnotationPrecision( int p ) /Deprecated/;
/**
* @deprecated use grid()->annotationPrecision() or grids() instead
*/
int gridAnnotationPrecision() const /Deprecated/;
/** Sets flag if grid annotation should be shown
* @deprecated use grid()->setAnnotationEnabled() or grids() instead
*/
void setShowGridAnnotation( bool show ) /Deprecated/;
/**
* @deprecated use grid()->annotationEnabled() or grids() instead
*/
bool showGridAnnotation() const /Deprecated/;
/**
* @deprecated use grid()->setAnnotationPosition() or grids() instead
*/
void setGridAnnotationPosition( GridAnnotationPosition p, QgsComposerMap::Border border ) /Deprecated/;
/**
* @deprecated use grid()->annotationPosition() or grids() instead
*/
GridAnnotationPosition gridAnnotationPosition( QgsComposerMap::Border border ) const /Deprecated/;
/** Sets distance between map frame and annotations
* @deprecated use grid()->setAnnotationFrameDistance() or grids() instead
*/
void setAnnotationFrameDistance( double d ) /Deprecated/;
/**
* @deprecated use grid()->annotationFrameDistance() or grids() instead
*/
double annotationFrameDistance() const /Deprecated/;
/**
* @deprecated use grid()->setAnnotationDirection() or grids() instead
*/
void setGridAnnotationDirection( GridAnnotationDirection d, QgsComposerMap::Border border ) /Deprecated/;
/**
* @deprecated use grid()->annotationDirection() or grids() instead
*/
GridAnnotationDirection gridAnnotationDirection( QgsComposerMap::Border border ) const /Deprecated/;
/**
* @deprecated use grid()->setAnnotationFormat() or grids() instead
*/
void setGridAnnotationFormat( GridAnnotationFormat f ) /Deprecated/;
/**
* @deprecated use grid()->annotationFormat() or grids() instead
*/
GridAnnotationFormat gridAnnotationFormat() const /Deprecated/;
/** Set grid frame style (NoGridFrame or Zebra)
* @deprecated use grid()->setFrameStyle() or grids() instead
*/
void setGridFrameStyle( GridFrameStyle style ) /Deprecated/;
/**
* @deprecated use grid()->frameStyle() or grids() instead
*/
GridFrameStyle gridFrameStyle() const /Deprecated/;
/** Set grid frame width
* @deprecated use grid()->setFrameWidth() or grids() instead
*/
void setGridFrameWidth( double w ) /Deprecated/;
/**
* @deprecated use grid()->frameWidth() or grids() instead
*/
double gridFrameWidth() const /Deprecated/;
/** Set grid frame pen thickness
* @note: this function was added in version 2.1
* @deprecated use grid()->setFramePenSize() or grids() instead
*/
void setGridFramePenSize( double w ) /Deprecated/;
/**
* @deprecated use grid()->framePenSize() or grids() instead
*/
double gridFramePenSize() const /Deprecated/;
/** Sets pen color for grid frame
* @note: this function was added in version 2.1
* @deprecated use grid()->setFramePenColor() or grids() instead
*/
void setGridFramePenColor( const QColor& c ) /Deprecated/;
/** Get pen color for grid frame
* @note: this function was added in version 2.1
* @deprecated use grid()->framePenColor() or grids() instead
*/
QColor gridFramePenColor() const /Deprecated/;
/** Sets first fill color for grid zebra frame
* @note: this function was added in version 2.1
* @deprecated use grid()->setFrameFillColor1() or grids() instead
*/
void setGridFrameFillColor1( const QColor& c ) /Deprecated/;
/** Get first fill color for grid zebra frame
* @note: this function was added in version 2.1
* @deprecated use grid()->frameFillColor1() or grids() instead
*/
QColor gridFrameFillColor1() const /Deprecated/;
/** Sets second fill color for grid zebra frame
* @note: this function was added in version 2.1
* @deprecated use grid()->setFrameFillColor2() or grids() instead
*/
void setGridFrameFillColor2( const QColor& c ) /Deprecated/;
/** Get second fill color for grid zebra frame
* @note: this function was added in version 2.1
* @deprecated use grid()->frameFillColor2() or grids() instead
*/
QColor gridFrameFillColor2() const /Deprecated/;
/** Sets length of the cross segments (if grid style is cross)
* @deprecated use grid()->setCrossLength() or grids() instead
*/
void setCrossLength( double l ) /Deprecated/;
/**
* @deprecated use grid()->crossLength() or grids() instead
*/
double crossLength() /Deprecated/;
/**
* @deprecated use grid()->setLineSymbol() or grids() instead
*/
void setGridLineSymbol( QgsLineSymbol* symbol /Transfer/) /Deprecated/;
/**
* @deprecated use grid()->lineSymbol() or grids() instead
*/
QgsLineSymbol* gridLineSymbol() /Deprecated/;
/** Returns the grid's blending mode
* @deprecated use grid()->blendMode() or grids() instead
*/
QPainter::CompositionMode gridBlendMode() const /Deprecated/;
/** Sets the grid's blending mode
* @deprecated use grid()->setBlendMode() or grids() instead
*/
void setGridBlendMode( QPainter::CompositionMode blendMode ) /Deprecated/;
/** Returns the map item's grid stack, which is used to control how grids
* are drawn over the map's contents.
* @returns pointer to grid stack
@ -563,17 +237,6 @@ class QgsComposerMap : QgsComposerItem
/* reimplement setFrameOutlineWidth, so that updateBoundingRect() is called after setting the frame width */
virtual void setFrameOutlineWidth( const double outlineWidth );
/** Sets rotation for the map - this does not affect the composer item shape, only the
way the map is drawn within the item
* @deprecated Use setMapRotation( double rotation ) instead
*/
void setRotation( double r ) /Deprecated/;
/** Returns the rotation used for drawing the map within the composer item
* @deprecated Use mapRotation() instead
*/
double rotation() const /Deprecated/;
/** Sets rotation for the map - this does not affect the composer item shape, only the
* way the map is drawn within the item
* @note this function was added in version 2.1
@ -599,76 +262,10 @@ class QgsComposerMap : QgsComposerItem
/** Returns the conversion factor map units -> mm*/
double mapUnitsToMM() const;
/** Sets overview frame map. -1 disables the overview frame
* @deprecated use overview()->setFrameMap() or overviews() instead
*/
void setOverviewFrameMap( int mapId ) /Deprecated/;
/** Returns id of overview frame (or -1 if no overfiew frame)
* @deprecated use overview()->frameMapId() or overviews() instead
*/
int overviewFrameMapId() const /Deprecated/;
/**
* @deprecated use overview()->setFrameSymbol() or overviews() instead
*/
void setOverviewFrameMapSymbol( QgsFillSymbol* symbol /Transfer/ ) /Deprecated/;
/**
* @deprecated use overview()->frameSymbol() or overviews() instead
*/
QgsFillSymbol* overviewFrameMapSymbol() /Deprecated/;
/** Returns the overview's blending mode
* @deprecated use overview()->blendMode() or overviews() instead
*/
QPainter::CompositionMode overviewBlendMode() const /Deprecated/;
/** Sets the overview's blending mode
* @deprecated use overview()->setBlendMode() or overviews() instead
*/
void setOverviewBlendMode( QPainter::CompositionMode blendMode ) /Deprecated/;
/** Returns true if the overview frame is inverted
* @deprecated use overview()->inverted() or overviews() instead
*/
bool overviewInverted() const /Deprecated/;
/** Sets the overview's inversion mode
* @deprecated use overview()->setInverted() or overviews() instead
*/
void setOverviewInverted( bool inverted ) /Deprecated/;
/** Returns true if the extent is forced to center on the overview
* @deprecated use overview()->centered() or overviews() instead
*/
bool overviewCentered() const /Deprecated/;
/** Set the overview's centering mode
* @deprecated use overview()->setCentered() or overviews() instead
*/
void setOverviewCentered( bool centered ) /Deprecated/;
/** Sets mId to a number not yet used in the composition. mId is kept if it is not in use.
Usually, this function is called before adding the composer map to the composition*/
void assignFreeId();
/** Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation
* @deprecated Use bool QgsComposerItem::imageSizeConsideringRotation( double& width, double& height, double rotation )
* instead
*/
bool imageSizeConsideringRotation( double& width, double& height ) const /Deprecated/;
/** Calculates corner point after rotation and scaling
* @deprecated Use QgsComposerItem::cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height, double rotation )
* instead
*/
bool cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height ) const /Deprecated/;
/** Calculates width / height of the bounding box of a rotated rectangle
* @deprecated Use QgsComposerItem::sizeChangedByRotation( double& width, double& height, double rotation )
* instead
*/
void sizeChangedByRotation( double& width, double& height ) /Deprecated/;
/** Returns whether the map extent is set to follow the current atlas feature.
* @returns true if map will follow the current atlas feature.
* @see setAtlasDriven
@ -683,16 +280,6 @@ class QgsComposerMap : QgsComposerItem
*/
void setAtlasDriven( bool enabled );
/** Returns true if the map uses a fixed scale when in atlas mode
* @deprecated since 2.4 Use atlasScalingMode() instead
*/
bool atlasFixedScale() const /Deprecated/;
/** Set to true if the map should use a fixed scale when in atlas mode
* @deprecated since 2.4 Use setAtlasScalingMode() instead
*/
void setAtlasFixedScale( bool fixed ) /Deprecated/;
/** Returns the current atlas scaling mode. This controls how the map's extents
* are calculated for the current atlas feature when an atlas composition
* is enabled.
@ -762,9 +349,6 @@ class QgsComposerMap : QgsComposerItem
/** Transforms map coordinates to item coordinates (considering rotation and move offset)*/
QPointF mapToItemCoords( QPointF mapCoords ) const;
//! @deprecated will be removed in QGIS 3.0
void connectMapOverviewSignals() /Deprecated/;
/** Calculates the extent to request and the yShift of the top-left point in case of rotation.
* @note added in 2.6 */
void requestedExtent( QgsRectangle& extent ) const;
@ -799,9 +383,6 @@ class QgsComposerMap : QgsComposerItem
/** Updates the bounding rect of this item. Call this function before doing any changes related to annotation out of the map rectangle */
void updateBoundingRect();
/** @deprecated use QgsComposerMapOverview::overviewExtentChanged instead*/
void overviewExtentChanged();
virtual void refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property = QgsComposerObject::AllProperties, const QgsExpressionContext* context = 0 );
protected slots:

View File

@ -171,8 +171,6 @@ class QgsComposerMapGrid : QgsComposerMapItem
{
InsideMapFrame = 0,
OutsideMapFrame, /*!< draw annotations outside the map frame */
Disabled /*!< disable annotation
* @deprecated in QGIS 2.7, use QgsComposerMapGrid::HideAll instead */
};
/** Direction of grid annotations

View File

@ -81,20 +81,13 @@ class QgsComposerMultiFrame: QgsComposerObject
*/
virtual QSizeF minFrameSize( const int frameIndex = -1 ) const;
/** Renders a portion of the multiframe's content into a painter.
* @param p destination painter
* @param renderExtent visible extent of content to render into the painter.
* @deprecated use render( QPainter* painter, const QRectF& renderExtent, const int frameIndex ) instead
*/
virtual void render( QPainter* p, const QRectF& renderExtent ) /Deprecated/;
/** Renders a portion of the multiframe's content into a painter.
* @param painter destination painter
* @param renderExtent visible extent of content to render into the painter.
* @param frameIndex frame number for content
* @note added in version 2.5
*/
virtual void render( QPainter* painter, const QRectF& renderExtent, const int frameIndex );
virtual void render( QPainter* painter, const QRectF& renderExtent, const int frameIndex ) = 0;
/** Adds a frame to the multiframe.
* @param frame frame to add

View File

@ -39,24 +39,6 @@ class QgsComposerPicture: QgsComposerItem
/** Reimplementation of QCanvasItem::paint*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
/** Sets the source file of the image (may be svg or a raster format). Data defined
* picture source may override this value.
* @param path full path to the source image
* @see usePictureExpression
* @see pictureFile
* @deprecated use setPicturePath instead
*/
void setPictureFile( const QString& path ) /Deprecated/;
/** Returns the path of the source image file. Data defined picture source may override
* this value.
* @returns path to the source image
* @see usePictureExpression
* @see setPictureFile
* @deprecated use picturePath instead
*/
QString pictureFile() const /Deprecated/;
/** Sets the source path of the image (may be svg or a raster format). Data defined
* picture source may override this value. The path can either be a local path
* or a remote (http) path.
@ -93,11 +75,6 @@ class QgsComposerPicture: QgsComposerItem
*/
bool readXml( const QDomElement& itemElem, const QDomDocument& doc );
/** Returns the rotation used for drawing the picture within the composer item
* @deprecated Use pictureRotation() instead
*/
double rotation() const /Deprecated/;
/** Returns the rotation used for drawing the picture within the item's frame
* @returns picture rotation in degrees
* @note added in 2.2
@ -207,45 +184,6 @@ class QgsComposerPicture: QgsComposerItem
*/
void setSvgBorderWidth( double width );
/** Returns whether the picture item is using an expression for the image source.
* @returns true if the picture is using an expression for the source, false if
* it is using a single static file path for the source.
* @note added in 2.3
* @see setUsePictureExpression
* @see pictureFile
* @see pictureExpression
* @deprecated use QgsComposerObject::dataDefinedProperty( QgsComposerObject::PictureSource ) instead
*/
bool usePictureExpression() const /Deprecated/;
/** Returns the expression the item is using for the picture source. This is only
* used if usePictureExpression() is true.
* @returns expression for the picture item's image path
* @note added in 2.3
* @see setPictureExpression
* @see usePictureExpression
* @deprecated use QgsComposerObject::dataDefinedProperty( QgsComposerObject::PictureSource ) instead
*/
QString pictureExpression() const /Deprecated/;
/** Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation
* @deprecated Use bool QgsComposerItem::imageSizeConsideringRotation( double& width, double& height, double rotation )
* instead
*/
bool imageSizeConsideringRotation( double& width, double& height ) const /Deprecated/;
/** Calculates corner point after rotation and scaling
* @deprecated Use QgsComposerItem::cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height, double rotation )
* instead
*/
bool cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height ) const /Deprecated/;
/** Calculates width / height of the bounding box of a rotated rectangle
* @deprecated Use QgsComposerItem::sizeChangedByRotation( double& width, double& height, double rotation )
* instead
*/
void sizeChangedByRotation( double& width, double& height ) /Deprecated/;
/** Returns the current picture mode (image format).
* @returns picture mode
* @note added in 2.3
@ -253,11 +191,6 @@ class QgsComposerPicture: QgsComposerItem
Mode mode() const;
public slots:
/** Sets the picture rotation within the item bounds. This does not affect
* the item rectangle, only the way the picture is drawn within the item.
* @deprecated Use setPictureRotation( double rotation ) instead
*/
virtual void setRotation( double r ) /Deprecated/;
/** Sets the picture rotation within the item bounds. This does not affect
* the item's frame, only the way the picture is drawn within the item.
@ -274,27 +207,6 @@ class QgsComposerPicture: QgsComposerItem
*/
virtual void setResizeMode( ResizeMode mode );
/** Sets whether the picture should use an expression based image source path
* @param useExpression set to true to use an expression based image source,
* set to false to use a single image source path
* @note added in 2.3
* @see usePictureExpression
* @see setPictureFile
* @see setPictureExpression
* @deprecated use QgsComposerObject::dataDefinedProperty( QgsComposerObject::PictureSource ) instead
*/
virtual void setUsePictureExpression( bool useExpression ) /Deprecated/;
/** Sets an expression to use for the picture source. This expression is only
* used if usePictureExpression() is true.
* @param expression to use for picture path
* @note added in 2.3
* @see setUsePictureExpression
* @see pictureExpression
* @deprecated use QgsComposerObject::dataDefinedProperty( QgsComposerObject::PictureSource ) instead
*/
virtual void setPictureExpression( const QString& expression ) /Deprecated/;
/** Recalculates the source image (if using an expression for picture's source)
* and reloads and redraws the picture.
* @param context expression context for evaluating data defined picture sources
@ -302,13 +214,6 @@ class QgsComposerPicture: QgsComposerItem
*/
void refreshPicture( const QgsExpressionContext* context = 0 );
/** Prepares the picture's source expression after it is altered or the compositions
* atlas coverage layer changes.
* @note added in 2.3
* @deprecated no longer required
*/
void updatePictureExpression() /Deprecated/;
/** Forces a recalculation of the picture's frame size
* @note added in 2.3
*/

View File

@ -1,274 +0,0 @@
/** A class to display feature attributes in the print composer
* @deprecated use QgsComposerTableV2 instead
*/
class QgsComposerTable: QgsComposerItem
{
%TypeHeaderCode
#include <qgscomposertable.h>
%End
public:
/** Controls how headers are horizontally aligned in a table
*/
enum HeaderHAlignment
{
FollowColumn, /*!< header uses the same alignment as the column */
HeaderLeft, /*!< align headers left */
HeaderCenter, /*!< align headers to center */
HeaderRight /*!< align headers right */
};
QgsComposerTable( QgsComposition* composition /TransferThis/ ) /Deprecated/;
virtual ~QgsComposerTable();
/** Return correct graphics item type. */
virtual int type() const;
/** \brief Reimplementation of QCanvasItem::paint*/
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
virtual bool writeXml( QDomElement& elem, QDomDocument & doc ) const = 0;
virtual bool readXml( const QDomElement& itemElem, const QDomDocument& doc ) = 0;
/** Sets the margin distance between cell borders and their contents.
* @param d margin for cell contents
* @see lineTextDistance
*/
void setLineTextDistance( double d );
/** Returns the margin distance between cell borders and their contents.
* @returns margin for cell contents
* @see setLineTextDistance
*/
double lineTextDistance() const;
/** Sets the font used to draw header text in the table.
* @param f font for header cells
* @see headerFont
* @see setContentFont
*/
void setHeaderFont( const QFont& f );
/** Returns the font used to draw header text in the table.
* @returns font for header cells
* @see setHeaderFont
* @see contentFont
*/
QFont headerFont() const;
/** Sets the color used to draw header text in the table.
* @param color header text color
* @see headerFontColor
* @see setHeaderFont
* @see setContentFontColor
* @note added in 2.5
*/
void setHeaderFontColor( const QColor& color );
/** Returns the color used to draw header text in the table.
* @returns color for header text
* @see setHeaderFontColor
* @see headerFont
* @see contentFontColor
* @note added in 2.5
*/
QColor headerFontColor() const;
/** Sets the horizontal alignment for table headers
* @param alignment Horizontal alignment for table header cells
* @note added in 2.3
* @see headerHAlignment
*/
void setHeaderHAlignment( const HeaderHAlignment alignment );
/** Returns the horizontal alignment for table headers
* @returns Horizontal alignment for table header cells
* @note added in 2.3
* @see setHeaderHAlignment
*/
HeaderHAlignment headerHAlignment() const;
/** Sets the font used to draw text in table body cells.
* @param f font for table cells
* @see contentFont
* @see setHeaderFont
*/
void setContentFont( const QFont& f );
/** Returns the font used to draw text in table body cells.
* @returns font for table cells
* @see setContentFont
* @see headerFont
*/
QFont contentFont() const;
/** Sets the color used to draw text in table body cells.
* @param color table cell text color
* @see contentFontColor
* @see setContentFont
* @see setHeaderFontColor
* @note added in 2.5
*/
void setContentFontColor( const QColor& color );
/** Returns the color used to draw text in table body cells.
* @returns text color for table cells
* @see setContentFontColor
* @see contentFont
* @see headerFontColor
* @note added in 2.5
*/
QColor contentFontColor() const;
/** Sets whether grid lines should be drawn in the table
* @param show set to true to show grid lines
* @see showGrid
* @see setGridStrokeWidth
* @see setGridColor
*/
void setShowGrid( bool show );
/** Returns whether grid lines are drawn in the table
* @returns true if grid lines are shown
* @see setShowGrid
* @see gridStrokeWidth
* @see gridColor
*/
bool showGrid() const;
/** Sets the width for grid lines in the table.
* @param w grid line width
* @see gridStrokeWidth
* @see setShowGrid
* @see setGridColor
*/
void setGridStrokeWidth( double w );
/** Returns the width of grid lines in the table.
* @returns grid line width
* @see setGridStrokeWidth
* @see showGrid
* @see gridColor
*/
double gridStrokeWidth() const;
/** Sets color used for grid lines in the table.
* @param c grid line color
* @see gridColor
* @see setShowGrid
* @see setGridStrokeWidth
*/
void setGridColor( const QColor& c );
/** Returns the color used for grid lines in the table.
* @returns grid line color
* @see setGridColor
* @see showGrid
* @see gridStrokeWidth
*/
QColor gridColor() const;
/** Returns the text used in the column headers for the table.
* @returns QMap of int to QString, where the int is the column index (starting at 0),
* and the string is the text to use for the column's header
* @note added in 2.3
* @note not available in python bindings
*/
// virtual QMap<int, QString> headerLabels() const;
//TODO - make this more generic for next API break, eg rename as getRowValues, use QStringList rather than
//QgsAttributeMap
/** Fetches the text used for the rows of the table.
* @returns true if attribute text was successfully retrieved.
* @param attributeMaps QList of QgsAttributeMap to store retrieved row data in
* @note not available in python bindings
*/
// virtual bool getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps ) { Q_UNUSED( attributeMaps ); return false; }
/** Returns a pointer to the list of QgsComposerTableColumns shown in the table
* @returns pointer to list of columns in table
* @note added in 2.3
* @see setColumns
*/
QList<QgsComposerTableColumn*>* columns();
/** Replaces the columns in the table with a specified list of QgsComposerTableColumns.
* @param columns list of QgsComposerTableColumns to show in table
* @note added in 2.3
* @see columns
*/
void setColumns( const QList<QgsComposerTableColumn*>& columns );
public slots:
/** Refreshes the attributes shown in the table by querying the vector layer for new data.
* This also causes the column widths and size of the table to change to accommodate the
* new data.
* @note added in 2.3
* @see adjustFrameToSize
*/
virtual void refreshAttributes();
/** Adapts the size of the frame to match the content. First, the optimal width of the columns
* is recalculated by checking the maximum width of attributes shown in the table. Then, the
* table is resized to fit its contents. This slot utilises the table's attribute cache so
* that a re-query of the vector layer is not required.
* @note added in 2.3
* @see refreshAttributes
*/
virtual void adjustFrameToSize();
protected:
/** Calculates the maximum width of text shown in columns.
* @param maxWidthMap QMap of int to double in which to store the maximum widths. The int will be filled
* with the column number and the double with the maximum width of text present in the column.
* @param attributeMaps list of attribute values for each row shown in the table
* @note not available in python bindings
* @see adaptItemFrame
*/
// virtual bool calculateMaxColumnWidths( QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeMaps ) const;
/** Adapts the size of the item frame to match the table's content.
* @param maxWidthMap QMap of int to double, where the int contains the column number and the double is the
* maximum width of text present in the column.
* @param attributeMaps list of attribute values for each row shown in the table
* @note not available in python bindings
* @see calculateMaxColumnWidths
*/
// void adaptItemFrame( const QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeMaps );
/** Draws the horizontal grid lines for the table.
* @param p destination painter for grid lines
* @param nAttributes number of attribute rows shown in table
* @see drawVerticalGridLines
*/
void drawHorizontalGridLines( QPainter* p, int nAttributes );
/** Draws the vertical grid lines for the table.
* @param p destination painter for grid lines
* @param maxWidthMap QMap of int to double, where the int contains the column number and the double is the
* maximum width of text present in the column.
* @note not available in python bindings
* @see drawVerticalGridLines
* @see calculateMaxColumnWidths
*/
// void drawVerticalGridLines( QPainter* p, const QMap<int, double>& maxWidthMap );
/** Writes common table properties to xml for storage.
* @param itemElem an existing QDomElement in which to store the table's properties.
* @param doc QDomDocument for the destination xml.
* @see tableReadXML
* @see writeXML
*/
bool tableWriteXml( QDomElement& itemElem, QDomDocument& doc ) const;
/** Reads the table's common properties from xml.
* @param itemElem a QDomElement holding the table's desired properties.
* @param doc QDomDocument for the source xml.
* @see tableWriteXML
* @see readXML
*/
bool tableReadXml( const QDomElement& itemElem, const QDomDocument& doc );
};

View File

@ -504,56 +504,4 @@ class QgsComposerTableV2: QgsComposerMultiFrame
*/
bool contentsContainsRow( const QgsComposerTableContents &contents, const QgsComposerTableRow &row ) const;
//deprecated methods
/** Calculates how many content rows are visible within a given frame
* @param frameIndex index number for frame
* @returns number of visible content rows (excludes header rows)
* @deprecated will be removed in QGIS 3.0
*/
int rowsVisible( const int frameIndex ) const /Deprecated/;
/** Calculates how many content rows would be visible within a specified
* height.
* @param frameHeight height of frame
* @param includeHeader set to true if frame would include a header row
* @returns number of visible content rows (excluding header row)
* @deprecated will be removed in QGIS 3.0
*/
int rowsVisible( const double frameHeight, const bool includeHeader ) const /Deprecated/;
/** Calculates a range of rows which should be visible in a given
* frame extent.
* @param extent visible extent
* @param frameIndex index number for frame
* @returns row range
* @deprecated will be removed in QGIS 3.0
*/
QPair<int, int> rowRange( const QRectF &extent, const int frameIndex ) const /Deprecated/;
/** Draws the horizontal grid lines for the table.
* @param painter destination painter for grid lines
* @param rows number of rows shown in table
* @param drawHeaderLines set to true to include for the table header
* @see drawVerticalGridLines
* @deprecated will be removed in QGIS 3.0
*/
void drawHorizontalGridLines( QPainter* painter, const int rows, const bool drawHeaderLines ) const /Deprecated/;
/** Draws the vertical grid lines for the table.
* @param painter destination painter for grid lines
* @param maxWidthMap QMap of int to double, where the int contains the column number and the double is the
* maximum width of text present in the column.
* @param numberRows number of rows of content in table frame
* @param hasHeader set to true if table frame includes header cells
* @param mergeCells set to true to merge table content cells
* @note not available in python bindings
* @see drawVerticalGridLines
* @see calculateMaxColumnWidths
* @note not available in python bindings
* @deprecated will be removed in QGIS 3.0
*/
// void drawVerticalGridLines( QPainter* painter, const QMap<int, double>& maxWidthMap, const int numberRows, const bool hasHeader, const bool mergeCells = false ) const /Deprecated/;
};

View File

@ -1,54 +1,3 @@
/** A text table item that reads text from string lists
* @deprecated use QgsComposerTextTableV2 instead
*/
class QgsComposerTextTable: QgsComposerTable
{
%TypeHeaderCode
#include <qgscomposertexttable.h>
%End
public:
QgsComposerTextTable( QgsComposition* c /TransferThis/ ) /Deprecated/;
~QgsComposerTextTable();
/** Return correct graphics item type. */
virtual int type() const;
/** Sets the text to use for the header row for the table
* @param labels list of strings to use for each column's header row
* @see headerLabels
*/
void setHeaderLabels( const QStringList& labels );
/** Adds a row to the table
* @param row list of strings to use for each cell's value in the newly added row
* @note If row is shorter than the number of columns in the table than blank cells
* will be inserted at the end of the row. If row contains more strings then the number
* of columns in the table then these extra strings will be ignored.
*/
void addRow( const QStringList& row );
/** Writes properties specific to text tables
* @param elem an existing QDomElement in which to store the text table's properties.
* @param doc QDomDocument for the destination xml.
* @see readXML
*/
bool writeXml( QDomElement& elem, QDomDocument & doc ) const;
/** Reads the properties specific to a text table from xml.
* @param itemElem a QDomElement holding the text table's desired properties.
* @param doc QDomDocument for the source xml.
* @see writeXML
*/
bool readXml( const QDomElement& itemElem, const QDomDocument& doc );
/** Queries the text table for text to show in the cells.
* @param attributeMaps list of QgsAttributeMaps where the cell text will be stored
* @returns true if attribute values were successfully set from table's text
* @note not available in python bindings
*/
// bool getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps );
};
/** A text table item that reads text from string lists
* @note added in QGIS 2.10

View File

@ -232,38 +232,6 @@ class QgsComposition : QGraphicsScene
void setGridStyle( const GridStyle s );
GridStyle gridStyle() const;
/** Sets the snap tolerance to use when automatically snapping items during movement and resizing to the
* composition grid.
* @param tolerance snap tolerance in pixels
* @see snapGridTolerance
* @deprecated Use setSnapTolerance instead
*/
void setSnapGridTolerance( const double tolerance ) /Deprecated/;
/** Returns the snap tolerance to use when automatically snapping items during movement and resizing to the
* composition grid.
* @returns snap tolerance in pixels
* @see setSnapGridTolerance
* @deprecated Use snapTolerance instead
*/
double snapGridTolerance() const /Deprecated/;
/** Sets the snap tolerance to use when automatically snapping items during movement and resizing to guides
* and the edges and centers of other items.
* @param t snap tolerance in pixels
* @see alignmentSnapTolerance
* @deprecated Use setSnapTolerance instead
*/
void setAlignmentSnapTolerance( double t ) /Deprecated/;
/** Returns the snap tolerance to use when automatically snapping items during movement and resizing to guides
* and the edges and centers of other items.
* @returns snap tolerance in pixels
* @see setAlignmentSnapTolerance
* @deprecated Use snapTolerance instead
*/
double alignmentSnapTolerance() const /Deprecated/;
/** Sets the snap tolerance to use when automatically snapping items during movement and resizing to guides
* and the edges and centers of other items.
* @param snapTolerance snap tolerance in pixels
@ -350,14 +318,6 @@ class QgsComposition : QGraphicsScene
*/
const QgsComposerMap* getComposerMapById( const int id ) const;
/** Returns the composer html with specified id (a string as named in the
* composer user interface item properties).
* @param item the item.
* @return QgsComposerHtml pointer or 0 pointer if no such item exists.
* @deprecated Use QgsComposerFrame::multiFrame() instead
*/
const QgsComposerHtml* getComposerHtmlByItem( QgsComposerItem *item ) const /Deprecated/;
/** Returns a composer item given its text identifier.
* Ids are not necessarely unique, but this function returns only one element.
* @param theId - A QString representing the identifier of the item to retrieve.
@ -418,17 +378,6 @@ class QgsComposition : QGraphicsScene
QgsComposition::PlotStyle plotStyle() const;
void setPlotStyle( const QgsComposition::PlotStyle style );
/** Returns the mm font size for a font that has point size set.
* Each item that sets a font should call this function before drawing text
* @deprecated use QgsComposerUtils::pointsToMM instead
*/
int pixelFontSize( double pointSize ) const /Deprecated/;
/** Does the inverse calculation and returns points for mm
* @deprecated use QgsComposerUtils::mmToPoints instead
*/
double pointFontSize( int pixelSize ) const /Deprecated/;
/** Writes settings to xml (paper dimension)*/
bool writeXml( QDomElement& composerElem, QDomDocument& doc );
@ -512,12 +461,6 @@ class QgsComposition : QGraphicsScene
*/
QList<QgsComposerItem*> ungroupItems( QgsComposerItemGroup* group );
/** Sorts the zList. The only time where this function needs to be called is from QgsComposer
* after reading all the items from xml file
* @deprecated use refreshZList instead
*/
void sortZList() /Deprecated/;
/** Rebuilds the z order list by adding any item which are present in the composition
* but missing from the z order list.
*/
@ -583,8 +526,6 @@ class QgsComposition : QGraphicsScene
void addComposerPolygon( QgsComposerPolygon* polygon );
/** Adds a composer polyline and advises composer to create a widget for it (through signal)*/
void addComposerPolyline( QgsComposerPolyline* polyline );
/** Adds a composer table to the graphics scene and advises composer to create a widget for it (through signal)*/
void addComposerTable( QgsComposerAttributeTable* table );
/** Adds composer html frame and advises composer to create a widget for it (through signal)*/
void addComposerHtmlFrame( QgsComposerHtml* html /Transfer/, QgsComposerFrame* frame /Transfer/);
/** Adds composer tablev2 frame and advises composer to create a widget for it (through signal)*/
@ -703,16 +644,6 @@ class QgsComposition : QGraphicsScene
QgsAtlasComposition& atlasComposition();
/** Resizes a QRectF relative to the change from boundsBefore to boundsAfter
* @deprecated use QgsComposerUtils::relativeResizeRect instead
*/
static void relativeResizeRect( QRectF& rectToResize, const QRectF& boundsBefore, const QRectF& boundsAfter ) /Deprecated/;
/** Returns a scaled position given a before and after range
* @deprecated use QgsComposerUtils::relativePosition instead
*/
static double relativePosition( double position, double beforeMin, double beforeMax, double afterMin, double afterMax ) /Deprecated/;
/** Returns the current atlas mode of the composition
* @returns current atlas mode
* @see setAtlasMode
@ -882,8 +813,6 @@ class QgsComposition : QGraphicsScene
void composerPictureAdded( QgsComposerPicture* picture );
/** Is emitted when a new composer shape has been added*/
void composerShapeAdded( QgsComposerShape* shape );
/** Is emitted when a new composer table has been added*/
void composerTableAdded( QgsComposerAttributeTable* table );
/** Is emitted when a new composer table frame has been added to the view*/
void composerTableFrameAdded( QgsComposerAttributeTableV2* table, QgsComposerFrame* frame );
/** Is emitted when a composer item has been removed from the scene*/

View File

@ -177,8 +177,6 @@
%Include composer/qgsaddremovemultiframecommand.sip
%Include composer/qgsatlascomposition.sip
%Include composer/qgscomposerarrow.sip
%Include composer/qgscomposerattributetable.sip
%Include composer/qgscomposerattributetablemodel.sip
%Include composer/qgscomposerattributetablemodelv2.sip
%Include composer/qgscomposerattributetablev2.sip
%Include composer/qgscomposereffect.sip
@ -205,7 +203,6 @@
%Include composer/qgscomposernodesitem.sip
%Include composer/qgscomposerpolygon.sip
%Include composer/qgscomposerpolyline.sip
%Include composer/qgscomposertable.sip
%Include composer/qgscomposertablecolumn.sip
%Include composer/qgscomposertablev2.sip
%Include composer/qgscomposertexttable.sip

View File

@ -143,7 +143,6 @@ SET(QGIS_APP_SRCS
composer/qgscomposershapewidget.cpp
composer/qgscomposerpolygonwidget.cpp
composer/qgscomposerpolylinewidget.cpp
composer/qgscomposertablewidget.cpp
composer/qgscomposertablebackgroundcolorsdialog.cpp
composer/qgscomposerlegenditemdialog.cpp
composer/qgscomposerlegendlayersdialog.cpp
@ -316,7 +315,6 @@ SET (QGIS_APP_MOC_HDRS
composer/qgscomposermapwidget.h
composer/qgscomposerpicturewidget.h
composer/qgscomposerscalebarwidget.h
composer/qgscomposertablewidget.h
composer/qgscomposertablebackgroundcolorsdialog.h
composer/qgscomposershapewidget.h
composer/qgscomposerpolygonwidget.h

View File

@ -16,9 +16,7 @@
***************************************************************************/
#include "qgsattributeselectiondialog.h"
#include "qgscomposerattributetable.h"
#include "qgscomposerattributetablev2.h"
#include "qgscomposerattributetablemodel.h"
#include "qgscomposerattributetablemodelv2.h"
#include "qgsvectorlayer.h"
#include "qgsfieldexpressionwidget.h"
@ -273,14 +271,10 @@ QgsAttributeSelectionDialog::QgsAttributeSelectionDialog( QgsComposerAttributeTa
QWidget* parent, Qt::WindowFlags f )
: QDialog( parent, f )
, mComposerTable( table )
, mComposerTableV1( nullptr )
, mVectorLayer( vLayer )
, mColumnModel( nullptr )
, mColumnModelV1( nullptr )
, mSortedProxyModel( nullptr )
, mSortedProxyModelV1( nullptr )
, mAvailableSortProxyModel( nullptr )
, mAvailableSortProxyModelV1( nullptr )
, mColumnAlignmentDelegate( nullptr )
, mColumnSourceDelegate( nullptr )
, mColumnSortOrderDelegate( nullptr )
@ -325,59 +319,6 @@ QgsAttributeSelectionDialog::QgsAttributeSelectionDialog( QgsComposerAttributeTa
mOrderComboBox->insertItem( 1, tr( "Descending" ) );
}
QgsAttributeSelectionDialog::QgsAttributeSelectionDialog( QgsComposerAttributeTable *table, QgsVectorLayer *vLayer, QWidget *parent, Qt::WindowFlags f )
: QDialog( parent, f )
, mComposerTable( nullptr )
, mComposerTableV1( table )
, mVectorLayer( vLayer )
, mColumnModel( nullptr )
, mColumnModelV1( nullptr )
, mSortedProxyModel( nullptr )
, mSortedProxyModelV1( nullptr )
, mAvailableSortProxyModel( nullptr )
, mAvailableSortProxyModelV1( nullptr )
, mColumnAlignmentDelegate( nullptr )
, mColumnSourceDelegate( nullptr )
, mColumnSortOrderDelegate( nullptr )
, mColumnWidthDelegate( nullptr )
{
setupUi( this );
QSettings settings;
restoreGeometry( settings.value( "/Windows/AttributeSelectionDialog/geometry" ).toByteArray() );
if ( mComposerTableV1 )
{
//set up models, views and delegates
mColumnModelV1 = new QgsComposerAttributeTableColumnModel( mComposerTableV1, mColumnsTableView );
mColumnsTableView->setModel( mColumnModelV1 );
mColumnsTableView->horizontalHeader()->setResizeMode( QHeaderView::Stretch );
mColumnSourceDelegate = new QgsComposerColumnSourceDelegate( vLayer, mColumnsTableView, mComposerTableV1 );
mColumnsTableView->setItemDelegateForColumn( 0, mColumnSourceDelegate );
mColumnAlignmentDelegate = new QgsComposerColumnAlignmentDelegate( mColumnsTableView );
mColumnsTableView->setItemDelegateForColumn( 2, mColumnAlignmentDelegate );
mAvailableSortProxyModelV1 = new QgsComposerTableSortColumnsProxyModel( mComposerTableV1, QgsComposerTableSortColumnsProxyModel::ShowUnsortedColumns, mSortColumnComboBox );
mAvailableSortProxyModelV1->setSourceModel( mColumnModelV1 );
mSortColumnComboBox->setModel( mAvailableSortProxyModelV1 );
mSortColumnComboBox->setModelColumn( 0 );
mColumnSortOrderDelegate = new QgsComposerColumnSortOrderDelegate( mSortColumnTableView );
mSortColumnTableView->setItemDelegateForColumn( 1, mColumnSortOrderDelegate );
mSortedProxyModelV1 = new QgsComposerTableSortColumnsProxyModel( mComposerTableV1, QgsComposerTableSortColumnsProxyModel::ShowSortedColumns, mSortColumnTableView );
mSortedProxyModelV1->setSourceModel( mColumnModelV1 );
mSortedProxyModelV1->sort( 0, Qt::AscendingOrder );
mSortColumnTableView->setSortingEnabled( false );
mSortColumnTableView->setModel( mSortedProxyModelV1 );
mSortColumnTableView->horizontalHeader()->setResizeMode( QHeaderView::Stretch );
}
mOrderComboBox->insertItem( 0, tr( "Ascending" ) );
mOrderComboBox->insertItem( 1, tr( "Descending" ) );
}
QgsAttributeSelectionDialog::~QgsAttributeSelectionDialog()
{
QSettings settings;
@ -386,138 +327,63 @@ QgsAttributeSelectionDialog::~QgsAttributeSelectionDialog()
void QgsAttributeSelectionDialog::on_mRemoveColumnPushButton_clicked()
{
if ( mComposerTable )
//remove selected row from model
QItemSelection viewSelection( mColumnsTableView->selectionModel()->selection() );
if ( viewSelection.length() > 0 )
{
//remove selected row from model
QItemSelection viewSelection( mColumnsTableView->selectionModel()->selection() );
if ( viewSelection.length() > 0 )
{
int selectedRow = viewSelection.indexes().at( 0 ).row();
mColumnModel->removeRow( selectedRow );
}
int selectedRow = viewSelection.indexes().at( 0 ).row();
mColumnModel->removeRow( selectedRow );
}
if ( mComposerTableV1 )
{
//remove selected row from model
QItemSelection viewSelection( mColumnsTableView->selectionModel()->selection() );
if ( viewSelection.length() > 0 )
{
int selectedRow = viewSelection.indexes().at( 0 ).row();
mColumnModelV1->removeRow( selectedRow );
}
}
}
void QgsAttributeSelectionDialog::on_mAddColumnPushButton_clicked()
{
if ( mComposerTable )
{
//add a new row to the model
mColumnModel->insertRow( mColumnModel->rowCount() );
}
else if ( mComposerTableV1 )
{
//add a new row to the model
mColumnModelV1->insertRow( mColumnModelV1->rowCount() );
}
//add a new row to the model
mColumnModel->insertRow( mColumnModel->rowCount() );
}
void QgsAttributeSelectionDialog::on_mColumnUpPushButton_clicked()
{
if ( mComposerTable )
//move selected row up
QItemSelection viewSelection( mColumnsTableView->selectionModel()->selection() );
if ( viewSelection.size() > 0 )
{
//move selected row up
QItemSelection viewSelection( mColumnsTableView->selectionModel()->selection() );
if ( viewSelection.size() > 0 )
{
int selectedRow = viewSelection.indexes().at( 0 ).row();
mColumnModel->moveRow( selectedRow, QgsComposerAttributeTableColumnModelV2::ShiftUp );
}
}
else if ( mComposerTableV1 )
{
//move selected row up
QItemSelection viewSelection( mColumnsTableView->selectionModel()->selection() );
if ( viewSelection.size() > 0 )
{
int selectedRow = viewSelection.indexes().at( 0 ).row();
mColumnModelV1->moveRow( selectedRow, QgsComposerAttributeTableColumnModel::ShiftUp );
}
int selectedRow = viewSelection.indexes().at( 0 ).row();
mColumnModel->moveRow( selectedRow, QgsComposerAttributeTableColumnModelV2::ShiftUp );
}
}
void QgsAttributeSelectionDialog::on_mColumnDownPushButton_clicked()
{
if ( mComposerTable )
//move selected row down
QItemSelection viewSelection( mColumnsTableView->selectionModel()->selection() );
if ( viewSelection.size() > 0 )
{
//move selected row down
QItemSelection viewSelection( mColumnsTableView->selectionModel()->selection() );
if ( viewSelection.size() > 0 )
{
int selectedRow = viewSelection.indexes().at( 0 ).row();
mColumnModel->moveRow( selectedRow, QgsComposerAttributeTableColumnModelV2::ShiftDown );
}
int selectedRow = viewSelection.indexes().at( 0 ).row();
mColumnModel->moveRow( selectedRow, QgsComposerAttributeTableColumnModelV2::ShiftDown );
}
else if ( mComposerTableV1 )
{
//move selected row down
QItemSelection viewSelection( mColumnsTableView->selectionModel()->selection() );
if ( viewSelection.size() > 0 )
{
int selectedRow = viewSelection.indexes().at( 0 ).row();
mColumnModelV1->moveRow( selectedRow, QgsComposerAttributeTableColumnModel::ShiftDown );
}
}
}
void QgsAttributeSelectionDialog::on_mResetColumnsPushButton_clicked()
{
if ( mComposerTable )
{
//reset columns to match vector layer's fields
mColumnModel->resetToLayer();
}
else if ( mComposerTableV1 )
{
//reset columns to match vector layer's fields
mColumnModelV1->resetToLayer();
}
//reset columns to match vector layer's fields
mColumnModel->resetToLayer();
mSortColumnComboBox->setCurrentIndex( 0 );
}
void QgsAttributeSelectionDialog::on_mAddSortColumnPushButton_clicked()
{
//add column to sort order widget
if ( mComposerTable )
QgsComposerTableColumn* column = mAvailableSortProxyModel->columnFromRow( mSortColumnComboBox->currentIndex() );
if ( ! column )
{
QgsComposerTableColumn* column = mAvailableSortProxyModel->columnFromRow( mSortColumnComboBox->currentIndex() );
if ( ! column )
{
return;
}
mColumnModel->setColumnAsSorted( column, mOrderComboBox->currentIndex() == 0 ? Qt::AscendingOrder : Qt::DescendingOrder );
//required so that rows can be reordered if initially no rows were shown in the table view
mSortedProxyModel->resetFilter();
}
else if ( mComposerTableV1 )
{
QgsComposerTableColumn* column = mAvailableSortProxyModelV1->columnFromRow( mSortColumnComboBox->currentIndex() );
if ( ! column )
{
return;
}
mColumnModelV1->setColumnAsSorted( column, mOrderComboBox->currentIndex() == 0 ? Qt::AscendingOrder : Qt::DescendingOrder );
//required so that rows can be reordered if initially no rows were shown in the table view
mSortedProxyModelV1->resetFilter();
return;
}
mColumnModel->setColumnAsSorted( column, mOrderComboBox->currentIndex() == 0 ? Qt::AscendingOrder : Qt::DescendingOrder );
//required so that rows can be reordered if initially no rows were shown in the table view
mSortedProxyModel->resetFilter();
}
void QgsAttributeSelectionDialog::on_mRemoveSortColumnPushButton_clicked()
@ -533,14 +399,7 @@ void QgsAttributeSelectionDialog::on_mRemoveSortColumnPushButton_clicked()
//find corresponding column
QgsComposerTableColumn * column = nullptr;
if ( mComposerTable )
{
column = mSortedProxyModel->columnFromIndex( selectedIndex );
}
else if ( mComposerTableV1 )
{
column = mSortedProxyModelV1->columnFromIndex( selectedIndex );
}
column = mSortedProxyModel->columnFromIndex( selectedIndex );
if ( !column )
{
@ -548,14 +407,7 @@ void QgsAttributeSelectionDialog::on_mRemoveSortColumnPushButton_clicked()
}
//set column as unsorted
if ( mComposerTable )
{
mColumnModel->setColumnAsUnsorted( column );
}
else if ( mComposerTableV1 )
{
mColumnModelV1->setColumnAsUnsorted( column );
}
mColumnModel->setColumnAsUnsorted( column );
//set next row as selected
mSortColumnTableView->selectRow( rowToRemove );
}
@ -570,26 +422,13 @@ void QgsAttributeSelectionDialog::on_mSortColumnUpPushButton_clicked()
}
QModelIndex selectedIndex = sortSelection.indexes().at( 0 );
if ( mComposerTable )
{
QgsComposerTableColumn * column = mSortedProxyModel->columnFromIndex( selectedIndex );
QgsComposerTableColumn * column = mSortedProxyModel->columnFromIndex( selectedIndex );
if ( !column )
{
return;
}
mColumnModel->moveColumnInSortRank( column, QgsComposerAttributeTableColumnModelV2::ShiftUp );
}
else if ( mComposerTableV1 )
if ( !column )
{
QgsComposerTableColumn * column = mSortedProxyModelV1->columnFromIndex( selectedIndex );
if ( !column )
{
return;
}
mColumnModelV1->moveColumnInSortRank( column, QgsComposerAttributeTableColumnModel::ShiftUp );
return;
}
mColumnModel->moveColumnInSortRank( column, QgsComposerAttributeTableColumnModelV2::ShiftUp );
}
void QgsAttributeSelectionDialog::on_mSortColumnDownPushButton_clicked()
@ -603,25 +442,12 @@ void QgsAttributeSelectionDialog::on_mSortColumnDownPushButton_clicked()
QModelIndex selectedIndex = sortSelection.indexes().at( 0 );
if ( mComposerTable )
{
QgsComposerTableColumn * column = mSortedProxyModel->columnFromIndex( selectedIndex );
QgsComposerTableColumn * column = mSortedProxyModel->columnFromIndex( selectedIndex );
if ( !column )
{
return;
}
mColumnModel->moveColumnInSortRank( column, QgsComposerAttributeTableColumnModelV2::ShiftDown );
}
else if ( mComposerTableV1 )
if ( !column )
{
QgsComposerTableColumn * column = mSortedProxyModelV1->columnFromIndex( selectedIndex );
if ( !column )
{
return;
}
mColumnModelV1->moveColumnInSortRank( column, QgsComposerAttributeTableColumnModel::ShiftDown );
return;
}
mColumnModel->moveColumnInSortRank( column, QgsComposerAttributeTableColumnModelV2::ShiftDown );
}

View File

@ -28,11 +28,8 @@
class QGridLayout;
class QgsVectorLayer;
class QPushButton;
class QgsComposerAttributeTable;
class QgsComposerAttributeTableV2;
class QgsComposerAttributeTableColumnModel;
class QgsComposerAttributeTableColumnModelV2;
class QgsComposerTableSortColumnsProxyModel;
class QgsComposerTableSortColumnsProxyModelV2;
class QgsComposerTableAvailableSortProxyModel;
class QgsComposerObject;
@ -118,10 +115,6 @@ class QgsAttributeSelectionDialog: public QDialog, private Ui::QgsAttributeSelec
public:
QgsAttributeSelectionDialog( QgsComposerAttributeTableV2* table, QgsVectorLayer* vLayer, QWidget * parent = nullptr, Qt::WindowFlags f = 0 );
//todo - remove for QGIS 3.0
QgsAttributeSelectionDialog( QgsComposerAttributeTable* table, QgsVectorLayer* vLayer, QWidget * parent = nullptr, Qt::WindowFlags f = 0 );
~QgsAttributeSelectionDialog();
private slots:
@ -137,18 +130,14 @@ class QgsAttributeSelectionDialog: public QDialog, private Ui::QgsAttributeSelec
private:
QgsComposerAttributeTableV2* mComposerTable;
QgsComposerAttributeTable* mComposerTableV1;
const QgsVectorLayer* mVectorLayer;
QgsComposerAttributeTableColumnModelV2* mColumnModel;
QgsComposerAttributeTableColumnModel* mColumnModelV1;
QgsComposerTableSortColumnsProxyModelV2* mSortedProxyModel;
QgsComposerTableSortColumnsProxyModel* mSortedProxyModelV1;
QgsComposerTableSortColumnsProxyModelV2* mAvailableSortProxyModel;
QgsComposerTableSortColumnsProxyModel* mAvailableSortProxyModelV1;
QgsComposerColumnAlignmentDelegate *mColumnAlignmentDelegate;
QgsComposerColumnSourceDelegate *mColumnSourceDelegate;

View File

@ -51,9 +51,7 @@
#include "qgscomposerscalebarwidget.h"
#include "qgscomposershape.h"
#include "qgscomposershapewidget.h"
#include "qgscomposerattributetable.h"
#include "qgscomposerattributetablev2.h"
#include "qgscomposertablewidget.h"
#include "qgsexception.h"
#include "qgslogger.h"
#include "qgsproject.h"
@ -3754,17 +3752,6 @@ void QgsComposer::addComposerShape( QgsComposerShape* shape )
mItemWidgetMap.insert( shape, sWidget );
}
void QgsComposer::addComposerTable( QgsComposerAttributeTable* table )
{
if ( !table )
{
return;
}
QgsComposerTableWidget* tWidget = new QgsComposerTableWidget( table );
mItemWidgetMap.insert( table, tWidget );
}
void QgsComposer::addComposerTableV2( QgsComposerAttributeTableV2 *table, QgsComposerFrame* frame )
{
if ( !table )

View File

@ -414,9 +414,6 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
/** Adds a composer shape to the item/widget map and creates a configuration widget*/
void addComposerShape( QgsComposerShape* shape );
/** Adds a composer table to the item/widget map and creates a configuration widget*/
void addComposerTable( QgsComposerAttributeTable* table );
/** Adds a composer table v2 to the item/widget map and creates a configuration widget*/
void addComposerTableV2( QgsComposerAttributeTableV2* table, QgsComposerFrame* frame );

View File

@ -1006,10 +1006,6 @@ void QgsComposerMapWidget::handleChangedAnnotationPosition( QgsComposerMapGrid::
{
grid->setAnnotationPosition( QgsComposerMapGrid::InsideMapFrame, border );
}
else if ( text == tr( "Disabled" ) )
{
grid->setAnnotationPosition( QgsComposerMapGrid::Disabled, border );
}
else //Outside frame
{
grid->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, border );

View File

@ -1,526 +0,0 @@
/***************************************************************************
qgscomposertablewidget.cpp
--------------------------
begin : January 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco at hugis dot net
***************************************************************************/
/***************************************************************************
* *
* 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 "qgscomposertablewidget.h"
#include "qgsattributeselectiondialog.h"
#include "qgscomposeritemwidget.h"
#include "qgscomposerattributetable.h"
#include "qgscomposertablecolumn.h"
#include "qgscomposermap.h"
#include "qgscomposition.h"
#include "qgsmaplayerregistry.h"
#include "qgsvectorlayer.h"
#include "qgsexpressionbuilderdialog.h"
#include "qgisgui.h"
QgsComposerTableWidget::QgsComposerTableWidget( QgsComposerAttributeTable* table ): QgsComposerItemBaseWidget( nullptr, table ), mComposerTable( table )
{
setupUi( this );
//add widget for general composer item properties
QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget( this, mComposerTable );
mainLayout->addWidget( itemPropertiesWidget );
blockAllSignals( true );
mLayerComboBox->setFilters( QgsMapLayerProxyModel::VectorLayer );
connect( mLayerComboBox, SIGNAL( layerChanged( QgsMapLayer* ) ), this, SLOT( changeLayer( QgsMapLayer* ) ) );
refreshMapComboBox();
mHeaderFontColorButton->setColorDialogTitle( tr( "Select header font color" ) );
mHeaderFontColorButton->setAllowAlpha( true );
mHeaderFontColorButton->setContext( "composer" );
mContentFontColorButton->setColorDialogTitle( tr( "Select content font color" ) );
mContentFontColorButton->setAllowAlpha( true );
mContentFontColorButton->setContext( "composer" );
mGridColorButton->setColorDialogTitle( tr( "Select grid color" ) );
mGridColorButton->setAllowAlpha( true );
mGridColorButton->setContext( "composer" );
updateGuiElements();
on_mComposerMapComboBox_activated( mComposerMapComboBox->currentIndex() );
if ( mComposerTable )
{
QObject::connect( mComposerTable, SIGNAL( itemChanged() ), this, SLOT( updateGuiElements() ) );
}
}
QgsComposerTableWidget::~QgsComposerTableWidget()
{
}
void QgsComposerTableWidget::showEvent( QShowEvent* /* event */ )
{
refreshMapComboBox();
}
void QgsComposerTableWidget::refreshMapComboBox()
{
//save the current entry in case it is still present after refresh
QString saveCurrentComboText = mComposerMapComboBox->currentText();
mComposerMapComboBox->blockSignals( true );
mComposerMapComboBox->clear();
if ( mComposerTable )
{
const QgsComposition* tableComposition = mComposerTable->composition();
if ( tableComposition )
{
QList<const QgsComposerMap*> mapList = tableComposition->composerMapItems();
QList<const QgsComposerMap*>::const_iterator mapIt = mapList.constBegin();
for ( ; mapIt != mapList.constEnd(); ++mapIt )
{
int mapId = ( *mapIt )->id();
mComposerMapComboBox->addItem( tr( "Map %1" ).arg( mapId ), mapId );
}
}
}
mComposerMapComboBox->blockSignals( false );
if ( mComposerMapComboBox->findText( saveCurrentComboText ) == -1 )
{
//the former entry is no longer present. Inform the scalebar about the changed composer map
on_mComposerMapComboBox_activated( mComposerMapComboBox->currentIndex() );
}
else
{
//the former entry is still present. Make it the current entry again
mComposerMapComboBox->setCurrentIndex( mComposerMapComboBox->findText( saveCurrentComboText ) );
}
}
void QgsComposerTableWidget::on_mRefreshPushButton_clicked()
{
if ( !mComposerTable )
{
return;
}
mComposerTable->refreshAttributes();
}
void QgsComposerTableWidget::on_mAttributesPushButton_clicked()
{
if ( !mComposerTable )
{
return;
}
//make deep copy of current columns, so we can restore them in case of cancellation
QList<QgsComposerTableColumn*> currentColumns;
QList<QgsComposerTableColumn*>::const_iterator it = mComposerTable->columns()->constBegin();
for ( ; it != mComposerTable->columns()->constEnd() ; ++it )
{
QgsComposerTableColumn* copy = ( *it )->clone();
currentColumns.append( copy );
}
mComposerTable->beginCommand( tr( "Table attribute settings" ) );
QgsAttributeSelectionDialog d( mComposerTable, mComposerTable->vectorLayer(), this );
if ( d.exec() == QDialog::Accepted )
{
mComposerTable->refreshAttributes();
mComposerTable->update();
mComposerTable->endCommand();
//clear currentColumns to free memory
qDeleteAll( currentColumns );
currentColumns.clear();
}
else
{
//undo changes
mComposerTable->setColumns( currentColumns );
mComposerTable->cancelCommand();
}
}
void QgsComposerTableWidget::on_mComposerMapComboBox_activated( int index )
{
if ( !mComposerTable )
{
return;
}
QVariant itemData = mComposerMapComboBox->itemData( index );
if ( itemData.type() == QVariant::Invalid )
{
return;
}
int mapId = itemData.toInt();
const QgsComposition* tableComposition = mComposerTable->composition();
if ( tableComposition )
{
if ( sender() ) //only create command if called from GUI
{
mComposerTable->beginCommand( tr( "Table map changed" ) );
}
mComposerTable->setComposerMap( tableComposition->getComposerMapById( mapId ) );
mComposerTable->update();
if ( sender() )
{
mComposerTable->endCommand();
}
}
}
void QgsComposerTableWidget::on_mMaximumColumnsSpinBox_valueChanged( int i )
{
if ( !mComposerTable )
{
return;
}
mComposerTable->beginCommand( tr( "Table maximum columns" ), QgsComposerMergeCommand::TableMaximumFeatures );
mComposerTable->setMaximumNumberOfFeatures( i );
mComposerTable->update();
mComposerTable->endCommand();
}
void QgsComposerTableWidget::on_mMarginSpinBox_valueChanged( double d )
{
if ( !mComposerTable )
{
return;
}
mComposerTable->beginCommand( tr( "Table maximum columns" ), QgsComposerMergeCommand::TableMargin );
mComposerTable->setLineTextDistance( d );
mComposerTable->update();
mComposerTable->endCommand();
}
void QgsComposerTableWidget::on_mHeaderFontPushButton_clicked()
{
if ( !mComposerTable )
{
return;
}
bool ok;
QFont newFont = QgisGui::getFont( ok, mComposerTable->headerFont(), tr( "Select Font" ) );
if ( ok )
{
mComposerTable->beginCommand( tr( "Table header font" ) );
mComposerTable->setHeaderFont( newFont );
mComposerTable->endCommand();
}
}
void QgsComposerTableWidget::on_mHeaderFontColorButton_colorChanged( const QColor &newColor )
{
if ( !mComposerTable )
{
return;
}
mComposerTable->beginCommand( tr( "Table header font color" ) );
mComposerTable->setHeaderFontColor( newColor );
mComposerTable->update();
mComposerTable->endCommand();
}
void QgsComposerTableWidget::on_mContentFontPushButton_clicked()
{
if ( !mComposerTable )
{
return;
}
bool ok;
QFont newFont = QgisGui::getFont( ok, mComposerTable->contentFont(), tr( "Select Font" ) );
if ( ok )
{
mComposerTable->beginCommand( tr( "Table content font" ) );
mComposerTable->setContentFont( newFont );
mComposerTable->endCommand();
}
}
void QgsComposerTableWidget::on_mContentFontColorButton_colorChanged( const QColor &newColor )
{
if ( !mComposerTable )
{
return;
}
mComposerTable->beginCommand( tr( "Table content font color" ) );
mComposerTable->setContentFontColor( newColor );
mComposerTable->update();
mComposerTable->endCommand();
}
void QgsComposerTableWidget::on_mGridStrokeWidthSpinBox_valueChanged( double d )
{
if ( !mComposerTable )
{
return;
}
mComposerTable->beginCommand( tr( "Table grid line" ), QgsComposerMergeCommand::TableGridStrokeWidth );
mComposerTable->setGridStrokeWidth( d );
mComposerTable->update();
mComposerTable->endCommand();
}
void QgsComposerTableWidget::on_mGridColorButton_colorChanged( const QColor& newColor )
{
if ( !mComposerTable )
{
return;
}
mComposerTable->beginCommand( tr( "Table grid color" ) );
mComposerTable->setGridColor( newColor );
mComposerTable->update();
mComposerTable->endCommand();
}
void QgsComposerTableWidget::on_mShowGridGroupCheckBox_toggled( bool state )
{
if ( !mComposerTable )
{
return;
}
mComposerTable->beginCommand( tr( "Table grid toggled" ) );
mComposerTable->setShowGrid( state );
mComposerTable->update();
mComposerTable->endCommand();
}
void QgsComposerTableWidget::updateGuiElements()
{
if ( !mComposerTable )
{
return;
}
blockAllSignals( true );
//layer combo box
if ( mComposerTable->vectorLayer() )
{
mLayerComboBox->setLayer( mComposerTable->vectorLayer() );
if ( mComposerTable->vectorLayer()->geometryType() == QgsWkbTypes::NullGeometry )
{
//layer has no geometry, so uncheck & disable controls which require geometry
mShowOnlyVisibleFeaturesCheckBox->setChecked( false );
mShowOnlyVisibleFeaturesCheckBox->setEnabled( false );
}
else
{
mShowOnlyVisibleFeaturesCheckBox->setEnabled( true );
}
}
//map combo box
const QgsComposerMap* cm = mComposerTable->composerMap();
if ( cm )
{
int mapIndex = mComposerMapComboBox->findText( tr( "Map %1" ).arg( cm->id() ) );
if ( mapIndex != -1 )
{
mComposerMapComboBox->setCurrentIndex( mapIndex );
}
}
mMaximumColumnsSpinBox->setValue( mComposerTable->maximumNumberOfFeatures() );
mMarginSpinBox->setValue( mComposerTable->lineTextDistance() );
mGridStrokeWidthSpinBox->setValue( mComposerTable->gridStrokeWidth() );
mGridColorButton->setColor( mComposerTable->gridColor() );
if ( mComposerTable->showGrid() )
{
mShowGridGroupCheckBox->setChecked( true );
}
else
{
mShowGridGroupCheckBox->setChecked( false );
}
mHeaderFontColorButton->setColor( mComposerTable->headerFontColor() );
mContentFontColorButton->setColor( mComposerTable->contentFontColor() );
if ( mComposerTable->displayOnlyVisibleFeatures() && mShowOnlyVisibleFeaturesCheckBox->isEnabled() )
{
mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Checked );
mComposerMapComboBox->setEnabled( true );
mComposerMapLabel->setEnabled( true );
}
else
{
mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Unchecked );
mComposerMapComboBox->setEnabled( false );
mComposerMapLabel->setEnabled( false );
}
mFeatureFilterEdit->setText( mComposerTable->featureFilter() );
mFeatureFilterCheckBox->setCheckState( mComposerTable->filterFeatures() ? Qt::Checked : Qt::Unchecked );
mFeatureFilterEdit->setEnabled( mComposerTable->filterFeatures() );
mFeatureFilterButton->setEnabled( mComposerTable->filterFeatures() );
mHeaderHAlignmentComboBox->setCurrentIndex(( int )mComposerTable->headerHAlignment() );
blockAllSignals( false );
}
void QgsComposerTableWidget::blockAllSignals( bool b )
{
mLayerComboBox->blockSignals( b );
mComposerMapComboBox->blockSignals( b );
mMaximumColumnsSpinBox->blockSignals( b );
mMarginSpinBox->blockSignals( b );
mGridColorButton->blockSignals( b );
mGridStrokeWidthSpinBox->blockSignals( b );
mShowGridGroupCheckBox->blockSignals( b );
mShowOnlyVisibleFeaturesCheckBox->blockSignals( b );
mFeatureFilterEdit->blockSignals( b );
mFeatureFilterCheckBox->blockSignals( b );
mHeaderHAlignmentComboBox->blockSignals( b );
mHeaderFontColorButton->blockSignals( b );
mContentFontColorButton->blockSignals( b );
}
void QgsComposerTableWidget::setMaximumNumberOfFeatures( int n )
{
mMaximumColumnsSpinBox->blockSignals( true );
mMaximumColumnsSpinBox->setValue( n );
mMaximumColumnsSpinBox->blockSignals( false );
}
void QgsComposerTableWidget::on_mShowOnlyVisibleFeaturesCheckBox_stateChanged( int state )
{
if ( !mComposerTable )
{
return;
}
mComposerTable->beginCommand( tr( "Table visible only toggled" ) );
bool showOnlyVisibleFeatures = ( state == Qt::Checked );
mComposerTable->setDisplayOnlyVisibleFeatures( showOnlyVisibleFeatures );
mComposerTable->update();
mComposerTable->endCommand();
//enable/disable map combobox based on state of checkbox
mComposerMapComboBox->setEnabled( state == Qt::Checked );
mComposerMapLabel->setEnabled( state == Qt::Checked );
}
void QgsComposerTableWidget::on_mFeatureFilterCheckBox_stateChanged( int state )
{
if ( !mComposerTable )
{
return;
}
if ( state == Qt::Checked )
{
mFeatureFilterEdit->setEnabled( true );
mFeatureFilterButton->setEnabled( true );
}
else
{
mFeatureFilterEdit->setEnabled( false );
mFeatureFilterButton->setEnabled( false );
}
mComposerTable->beginCommand( tr( "Table feature filter toggled" ) );
mComposerTable->setFilterFeatures( state == Qt::Checked );
mComposerTable->update();
mComposerTable->endCommand();
}
void QgsComposerTableWidget::on_mFeatureFilterEdit_editingFinished()
{
if ( !mComposerTable )
{
return;
}
mComposerTable->beginCommand( tr( "Table feature filter modified" ) );
mComposerTable->setFeatureFilter( mFeatureFilterEdit->text() );
mComposerTable->update();
mComposerTable->endCommand();
}
void QgsComposerTableWidget::on_mFeatureFilterButton_clicked()
{
if ( !mComposerTable )
{
return;
}
QgsExpressionContext context = mComposerTable->createExpressionContext();
QgsExpressionBuilderDialog exprDlg( mComposerTable->vectorLayer(), mFeatureFilterEdit->text(), this, "generic", context );
exprDlg.setWindowTitle( tr( "Expression based filter" ) );
if ( exprDlg.exec() == QDialog::Accepted )
{
QString expression = exprDlg.expressionText();
if ( !expression.isEmpty() )
{
mFeatureFilterEdit->setText( expression );
mComposerTable->beginCommand( tr( "Table feature filter modified" ) );
mComposerTable->setFeatureFilter( mFeatureFilterEdit->text() );
mComposerTable->update();
mComposerTable->endCommand();
}
}
}
void QgsComposerTableWidget::on_mHeaderHAlignmentComboBox_currentIndexChanged( int index )
{
if ( !mComposerTable )
{
return;
}
mComposerTable->beginCommand( tr( "Table header alignment changed" ) );
mComposerTable->setHeaderHAlignment(( QgsComposerTable::HeaderHAlignment )index );
mComposerTable->endCommand();
}
void QgsComposerTableWidget::changeLayer( QgsMapLayer *layer )
{
if ( !mComposerTable )
{
return;
}
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( layer );
if ( !vl )
{
return;
}
mComposerTable->beginCommand( tr( "Table layer changed" ) );
mComposerTable->setVectorLayer( vl );
mComposerTable->update();
mComposerTable->endCommand();
if ( vl->geometryType() == QgsWkbTypes::NullGeometry )
{
//layer has no geometry, so uncheck & disable controls which require geometry
mShowOnlyVisibleFeaturesCheckBox->setChecked( false );
mShowOnlyVisibleFeaturesCheckBox->setEnabled( false );
}
else
{
mShowOnlyVisibleFeaturesCheckBox->setEnabled( true );
}
}

View File

@ -1,71 +0,0 @@
/***************************************************************************
qgscomposertablewidget.h
------------------------
begin : January 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco at hugis dot net
***************************************************************************/
/***************************************************************************
* *
* 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 QGSCOMPOSERTABLEWIDGET_H
#define QGSCOMPOSERTABLEWIDGET_H
#include "ui_qgscomposertablewidgetbase.h"
#include "qgscomposeritemwidget.h"
class QgsComposerAttributeTable;
class QgsComposerTableWidget: public QgsComposerItemBaseWidget, private Ui::QgsComposerTableWidgetBase
{
Q_OBJECT
public:
explicit QgsComposerTableWidget( QgsComposerAttributeTable* table );
~QgsComposerTableWidget();
protected:
void showEvent( QShowEvent * event ) override;
private:
QgsComposerAttributeTable* mComposerTable;
/** Blocks / unblocks the signals of all GUI elements*/
void blockAllSignals( bool b );
void refreshMapComboBox();
private slots:
void on_mRefreshPushButton_clicked();
void on_mAttributesPushButton_clicked();
void on_mComposerMapComboBox_activated( int index );
void on_mMaximumColumnsSpinBox_valueChanged( int i );
void on_mMarginSpinBox_valueChanged( double d );
void on_mGridStrokeWidthSpinBox_valueChanged( double d );
void on_mGridColorButton_colorChanged( const QColor& newColor );
void on_mHeaderFontPushButton_clicked();
void on_mHeaderFontColorButton_colorChanged( const QColor& newColor );
void on_mContentFontPushButton_clicked();
void on_mContentFontColorButton_colorChanged( const QColor& newColor );
void on_mShowGridGroupCheckBox_toggled( bool state );
void on_mShowOnlyVisibleFeaturesCheckBox_stateChanged( int state );
void on_mFeatureFilterCheckBox_stateChanged( int state );
void on_mFeatureFilterEdit_editingFinished();
void on_mFeatureFilterButton_clicked();
void on_mHeaderHAlignmentComboBox_currentIndexChanged( int index );
void changeLayer( QgsMapLayer* layer );
/** Inserts a new maximum number of features into the spin box (without the spinbox emitting a signal)*/
void setMaximumNumberOfFeatures( int n );
/** Sets the GUI elements to the values of mComposerTable*/
void updateGuiElements();
};
#endif // QGSCOMPOSERTABLEWIDGET_H

View File

@ -233,8 +233,6 @@ SET(QGIS_CORE_SRCS
composer/qgsaddremovemultiframecommand.cpp
composer/qgsatlascomposition.cpp
composer/qgscomposerarrow.cpp
composer/qgscomposerattributetable.cpp
composer/qgscomposerattributetablemodel.cpp
composer/qgscomposerattributetablemodelv2.cpp
composer/qgscomposerattributetablev2.cpp
composer/qgscomposereffect.cpp
@ -262,7 +260,6 @@ SET(QGIS_CORE_SRCS
composer/qgscomposernodesitem.cpp
composer/qgscomposerpolygon.cpp
composer/qgscomposerpolyline.cpp
composer/qgscomposertable.cpp
composer/qgscomposertablecolumn.cpp
composer/qgscomposertablev2.cpp
composer/qgscomposertexttable.cpp
@ -507,8 +504,6 @@ SET(QGIS_CORE_MOC_HDRS
composer/qgsaddremoveitemcommand.h
composer/qgsatlascomposition.h
composer/qgscomposerarrow.h
composer/qgscomposerattributetable.h
composer/qgscomposerattributetablemodel.h
composer/qgscomposerattributetablemodelv2.h
composer/qgscomposerattributetablev2.h
composer/qgscomposereffect.h
@ -533,7 +528,6 @@ SET(QGIS_CORE_MOC_HDRS
composer/qgscomposerpolygon.h
composer/qgscomposerpolyline.h
composer/qgscomposertablecolumn.h
composer/qgscomposertable.h
composer/qgscomposertablev2.h
composer/qgscomposertexttable.h
composer/qgscomposition.h
@ -759,7 +753,6 @@ SET(QGIS_CORE_HDRS
composer/qgscomposerlegenditem.h
composer/qgscomposerlegendstyle.h
composer/qgscomposermultiframecommand.h
composer/qgscomposertable.h
composer/qgscomposertexttable.h
composer/qgsdoubleboxscalebarstyle.h
composer/qgsnumericscalebarstyle.h

View File

@ -104,61 +104,6 @@ QString QgsAtlasComposition::nameForPage( int pageNumber ) const
return mFeatureIds.at( pageNumber ).second;
}
QgsComposerMap* QgsAtlasComposition::composerMap() const
{
//deprecated method. Until removed just return the first atlas-enabled composer map
//build a list of composer maps
QList<QgsComposerMap*> maps;
mComposition->composerItems( maps );
for ( QList<QgsComposerMap*>::iterator mit = maps.begin(); mit != maps.end(); ++mit )
{
QgsComposerMap* currentMap = ( *mit );
if ( currentMap->atlasDriven() )
{
return currentMap;
}
}
return nullptr;
}
void QgsAtlasComposition::setComposerMap( QgsComposerMap* map )
{
//deprecated
if ( !map )
{
return;
}
map->setAtlasDriven( true );
}
int QgsAtlasComposition::sortKeyAttributeIndex() const
{
if ( !mCoverageLayer )
{
return -1;
}
return mCoverageLayer->fieldNameIndex( mSortKeyAttributeName );
}
void QgsAtlasComposition::setSortKeyAttributeIndex( int idx )
{
if ( mCoverageLayer )
{
QgsFields fields = mCoverageLayer->fields();
if ( idx >= 0 && idx < fields.count() )
{
mSortKeyAttributeName = fields.at( idx ).name();
return;
}
}
mSortKeyAttributeName = "";
}
/// @cond PRIVATE
class FieldSorter
{
@ -855,55 +800,6 @@ void QgsAtlasComposition::setPredefinedScales( const QVector<qreal>& scales )
qSort( mPredefinedScales.begin(), mPredefinedScales.end() );
}
Q_NOWARN_DEPRECATED_PUSH
bool QgsAtlasComposition::fixedScale() const
{
//deprecated method. Until removed just return the property for the first atlas-enabled composer map
QgsComposerMap * map = composerMap();
if ( !map )
{
return false;
}
return map->atlasFixedScale();
}
void QgsAtlasComposition::setFixedScale( bool fixed )
{
//deprecated method. Until removed just set the property for the first atlas-enabled composer map
QgsComposerMap * map = composerMap();
if ( !map )
{
return;
}
map->setAtlasScalingMode( fixed ? QgsComposerMap::Fixed : QgsComposerMap::Auto );
}
float QgsAtlasComposition::margin() const
{
//deprecated method. Until removed just return the property for the first atlas-enabled composer map
QgsComposerMap * map = composerMap();
if ( !map )
{
return 0;
}
return map->atlasMargin();
}
void QgsAtlasComposition::setMargin( float margin )
{
//deprecated method. Until removed just set the property for the first atlas-enabled composer map
QgsComposerMap * map = composerMap();
if ( !map )
{
return;
}
map->setAtlasMargin( static_cast< double >( margin ) );
}
QgsGeometry QgsAtlasComposition::currentGeometry( const QgsCoordinateReferenceSystem& crs ) const
{
if ( !mCoverageLayer || !mCurrentFeature.isValid() || !mCurrentFeature.hasGeometry() )
@ -934,5 +830,3 @@ QgsGeometry QgsAtlasComposition::currentGeometry( const QgsCoordinateReferenceSy
mGeometryCache[crs.srsid()] = transformed;
return transformed;
}
Q_NOWARN_DEPRECATED_POP

View File

@ -254,49 +254,6 @@ class CORE_EXPORT QgsAtlasComposition : public QObject
/** Recalculates the bounds of an atlas driven map */
void prepareMap( QgsComposerMap* map );
//deprecated methods
/** Returns the map used by the atlas
* @deprecated Use QgsComposerMap::atlasDriven() instead
*/
Q_DECL_DEPRECATED QgsComposerMap* composerMap() const;
/** Sets the map used by the atlas
* @deprecated Use QgsComposerMap::setAtlasDriven( true ) instead
*/
Q_DECL_DEPRECATED void setComposerMap( QgsComposerMap* map );
/** Returns whether the atlas map uses a fixed scale
* @deprecated since 2.4 Use QgsComposerMap::atlasScalingMode() instead
*/
Q_DECL_DEPRECATED bool fixedScale() const;
/** Sets whether the atlas map should use a fixed scale
* @deprecated since 2.4 Use QgsComposerMap::setAtlasScalingMode() instead
*/
Q_DECL_DEPRECATED void setFixedScale( bool fixed );
/** Returns the margin for the atlas map
* @deprecated Use QgsComposerMap::atlasMargin() instead
*/
Q_DECL_DEPRECATED float margin() const;
/** Sets the margin for the atlas map
* @deprecated Use QgsComposerMap::setAtlasMargin( double ) instead
*/
Q_DECL_DEPRECATED void setMargin( float margin );
//! @deprecated use sortKeyAttributeName instead
Q_DECL_DEPRECATED int sortKeyAttributeIndex() const;
//! @deprecated use setSortKeyAttributeName instead
Q_DECL_DEPRECATED void setSortKeyAttributeIndex( int idx );
/** Returns the current atlas feature. Must be called after prepareForFeature( i ).
* @deprecated use feature() instead
*/
Q_DECL_DEPRECATED QgsFeature* currentFeature() { return &mCurrentFeature; }
/** Returns the current atlas geometry in the given projection system (default to the coverage layer's CRS) */
QgsGeometry currentGeometry( const QgsCoordinateReferenceSystem& projectedTo = QgsCoordinateReferenceSystem() ) const;

View File

@ -332,28 +332,6 @@ void QgsComposerArrow::setEndMarker( const QString& svgPath )
adaptItemSceneRect();
}
QColor QgsComposerArrow::arrowColor() const
{
if ( mLineSymbol )
{
return mLineSymbol->color();
}
return Qt::black;
}
void QgsComposerArrow::setArrowColor( const QColor &c )
{
if ( mLineSymbol )
{
mLineSymbol->setColor( c );
}
mArrowHeadOutlineColor = c;
mArrowHeadFillColor = c;
mPen.setColor( c );
mBrush.setColor( c );
}
void QgsComposerArrow::setArrowHeadOutlineColor( const QColor &color )
{
mArrowHeadOutlineColor = color;
@ -366,28 +344,6 @@ void QgsComposerArrow::setArrowHeadFillColor( const QColor &color )
mBrush.setColor( color );
}
void QgsComposerArrow::setOutlineWidth( double width )
{
if ( mLineSymbol )
{
mLineSymbol->setWidth( width );
}
mArrowHeadOutlineWidth = width;
mPen.setWidthF( mArrowHeadOutlineWidth );
adaptItemSceneRect();
}
double QgsComposerArrow::outlineWidth() const
{
if ( mLineSymbol )
{
return mLineSymbol->width();
}
return 0;
}
void QgsComposerArrow::setArrowHeadOutlineWidth( const double width )
{
mArrowHeadOutlineWidth = width;

View File

@ -76,16 +76,6 @@ class CORE_EXPORT QgsComposerArrow: public QgsComposerItem
*/
double arrowHeadWidth() const { return mArrowHeadWidth; }
/** Sets the pen width for drawing the line and arrow head
* @deprecated use setArrowHeadOutlineWidth or setLineSymbol instead
*/
Q_DECL_DEPRECATED void setOutlineWidth( double width );
/** Returns the pen width for drawing the line and arrow head
* @deprecated use arrowHeadOutlineWidth or lineSymbol instead
*/
Q_DECL_DEPRECATED double outlineWidth() const;
/** Sets the marker to draw at the start of the line
* @param svgPath file path for svg marker graphic to draw
* @see startMarker
@ -114,16 +104,6 @@ class CORE_EXPORT QgsComposerArrow: public QgsComposerItem
*/
QString endMarker() const { return mEndMarkerFile; }
/** Returns the color for the line and arrow head
* @deprecated use arrowHeadOutlineColor, arrowHeadFillColor or lineStyle instead
*/
Q_DECL_DEPRECATED QColor arrowColor() const;
/** Sets the color for the line and arrow head
* @deprecated use setArrowHeadOutlineColor, setArrowHeadFillColor or setLineStyle instead
*/
Q_DECL_DEPRECATED void setArrowColor( const QColor& c );
/** Returns the color used to draw outline around the the arrow head.
* @returns arrow head outline color
* @see arrowHeadFillColor

View File

@ -1,672 +0,0 @@
/***************************************************************************
qgscomposerattributetable.cpp
-----------------------------
begin : April 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco at hugis dot net
***************************************************************************/
/***************************************************************************
* *
* 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 "qgscomposerattributetable.h"
#include "qgscomposertablecolumn.h"
#include "qgscomposermap.h"
#include "qgscomposerutils.h"
#include "qgsfeatureiterator.h"
#include "qgsmaplayerregistry.h"
#include "qgsvectorlayer.h"
#include "qgscsexception.h"
#include "qgsmapsettings.h"
//QgsComposerAttributeTableCompare
QgsComposerAttributeTableCompare::QgsComposerAttributeTableCompare()
: mCurrentSortColumn( 0 )
, mAscending( true )
{
}
bool QgsComposerAttributeTableCompare::operator()( const QgsAttributeMap& m1, const QgsAttributeMap& m2 )
{
return ( mAscending ? qgsVariantLessThan( m1[mCurrentSortColumn], m2[mCurrentSortColumn] )
: qgsVariantGreaterThan( m1[mCurrentSortColumn], m2[mCurrentSortColumn] ) );
}
//QgsComposerAttributeTable
QgsComposerAttributeTable::QgsComposerAttributeTable( QgsComposition* composition )
: QgsComposerTable( composition )
, mVectorLayer( nullptr )
, mComposerMap( nullptr )
, mMaximumNumberOfFeatures( 5 )
, mShowOnlyVisibleFeatures( false )
, mFilterFeatures( false )
, mFeatureFilter( "" )
{
//set first vector layer from layer registry as default one
QMap<QString, QgsMapLayer*> layerMap = QgsMapLayerRegistry::instance()->mapLayers();
QMap<QString, QgsMapLayer*>::const_iterator mapIt = layerMap.constBegin();
for ( ; mapIt != layerMap.constEnd(); ++mapIt )
{
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( mapIt.value() );
if ( vl )
{
mVectorLayer = vl;
break;
}
}
if ( mVectorLayer )
{
resetColumns();
}
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) );
if ( mComposition )
{
//refresh table attributes when composition is refreshed
connect( mComposition, SIGNAL( refreshItemsTriggered() ), this, SLOT( refreshAttributes() ) );
//connect to atlas feature changes to update table rows
connect( &mComposition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( refreshAttributes() ) );
}
}
QgsComposerAttributeTable::~QgsComposerAttributeTable()
{
}
void QgsComposerAttributeTable::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
{
if ( mComposerMap && mComposerMap->isDrawing() )
{
return;
}
if ( !shouldDrawItem() )
{
return;
}
QgsComposerTable::paint( painter, itemStyle, pWidget );
}
void QgsComposerAttributeTable::setVectorLayer( QgsVectorLayer* layer )
{
if ( layer == mVectorLayer )
{
//no change
return;
}
if ( mVectorLayer )
{
//disconnect from previous layer
QObject::disconnect( mVectorLayer, SIGNAL( layerModified() ), this, SLOT( refreshAttributes() ) );
}
mVectorLayer = layer;
//rebuild column list to match all columns from layer
resetColumns();
refreshAttributes();
//listen for modifications to layer and refresh table when they occur
QObject::connect( mVectorLayer, SIGNAL( layerModified() ), this, SLOT( refreshAttributes() ) );
}
void QgsComposerAttributeTable::resetColumns()
{
if ( !mVectorLayer )
{
return;
}
//remove existing columns
qDeleteAll( mColumns );
mColumns.clear();
//rebuild columns list from vector layer fields
int idx = 0;
Q_FOREACH ( const QgsField& field, mVectorLayer->fields() )
{
QString currentAlias = mVectorLayer->attributeDisplayName( idx );
QgsComposerTableColumn* col = new QgsComposerTableColumn;
col->setAttribute( field.name() );
col->setHeading( currentAlias );
mColumns.append( col );
idx++;
}
}
void QgsComposerAttributeTable::setComposerMap( const QgsComposerMap* map )
{
if ( map == mComposerMap )
{
//no change
return;
}
if ( mComposerMap )
{
//disconnect from previous map
QObject::disconnect( mComposerMap, SIGNAL( extentChanged() ), this, SLOT( refreshAttributes() ) );
}
mComposerMap = map;
if ( mComposerMap )
{
//listen out for extent changes in linked map
QObject::connect( mComposerMap, SIGNAL( extentChanged() ), this, SLOT( refreshAttributes() ) );
}
refreshAttributes();
}
void QgsComposerAttributeTable::setMaximumNumberOfFeatures( int features )
{
if ( features == mMaximumNumberOfFeatures )
{
return;
}
mMaximumNumberOfFeatures = features;
refreshAttributes();
}
void QgsComposerAttributeTable::setDisplayOnlyVisibleFeatures( bool visibleOnly )
{
if ( visibleOnly == mShowOnlyVisibleFeatures )
{
return;
}
mShowOnlyVisibleFeatures = visibleOnly;
refreshAttributes();
}
void QgsComposerAttributeTable::setFilterFeatures( bool filter )
{
if ( filter == mFilterFeatures )
{
return;
}
mFilterFeatures = filter;
refreshAttributes();
}
void QgsComposerAttributeTable::setFeatureFilter( const QString& expression )
{
if ( expression == mFeatureFilter )
{
return;
}
mFeatureFilter = expression;
refreshAttributes();
}
QSet<int> QgsComposerAttributeTable::displayAttributes() const
{
return fieldsToDisplay().toSet();
}
void QgsComposerAttributeTable::setDisplayAttributes( const QSet<int>& attr, bool refresh )
{
if ( !mVectorLayer )
{
return;
}
//rebuild columns list, taking only attributes with index in supplied QSet
qDeleteAll( mColumns );
mColumns.clear();
const QgsFields& fields = mVectorLayer->fields();
if ( !attr.empty() )
{
QSet<int>::const_iterator attIt = attr.constBegin();
for ( ; attIt != attr.constEnd(); ++attIt )
{
int attrIdx = ( *attIt );
if ( !fields.exists( attrIdx ) )
{
continue;
}
QString currentAlias = mVectorLayer->attributeDisplayName( attrIdx );
QgsComposerTableColumn* col = new QgsComposerTableColumn;
col->setAttribute( fields.at( attrIdx ).name() );
col->setHeading( currentAlias );
mColumns.append( col );
}
}
else
{
//resetting, so add all attributes to columns
int idx = 0;
Q_FOREACH ( const QgsField& field, fields )
{
QString currentAlias = mVectorLayer->attributeDisplayName( idx );
QgsComposerTableColumn* col = new QgsComposerTableColumn;
col->setAttribute( field.name() );
col->setHeading( currentAlias );
mColumns.append( col );
idx++;
}
}
if ( refresh )
{
refreshAttributes();
}
}
QMap<int, QString> QgsComposerAttributeTable::fieldAliasMap() const
{
QMap<int, QString> fieldAliasMap;
QList<QgsComposerTableColumn*>::const_iterator columnIt = mColumns.constBegin();
for ( ; columnIt != mColumns.constEnd(); ++columnIt )
{
int attrIdx = mVectorLayer->fieldNameIndex(( *columnIt )->attribute() );
fieldAliasMap.insert( attrIdx, ( *columnIt )->heading() );
}
return fieldAliasMap;
}
void QgsComposerAttributeTable::restoreFieldAliasMap( const QMap<int, QString>& map )
{
if ( !mVectorLayer )
{
return;
}
QList<QgsComposerTableColumn*>::const_iterator columnIt = mColumns.constBegin();
for ( ; columnIt != mColumns.constEnd(); ++columnIt )
{
int attrIdx = mVectorLayer->fieldNameIndex(( *columnIt )->attribute() );
if ( map.contains( attrIdx ) )
{
( *columnIt )->setHeading( map.value( attrIdx ) );
}
else
{
( *columnIt )->setHeading( mVectorLayer->attributeDisplayName( attrIdx ) );
}
}
}
void QgsComposerAttributeTable::setFieldAliasMap( const QMap<int, QString>& map )
{
restoreFieldAliasMap( map );
refreshAttributes();
}
QList<int> QgsComposerAttributeTable::fieldsToDisplay() const
{
//kept for api compatibility with 2.0 only, can be removed after next api break
QList<int> fields;
QList<QgsComposerTableColumn*>::const_iterator columnIt = mColumns.constBegin();
for ( ; columnIt != mColumns.constEnd(); ++columnIt )
{
int idx = mVectorLayer->fieldNameIndex(( *columnIt )->attribute() );
fields.append( idx );
}
return fields;
}
bool QgsComposerAttributeTable::getFeatureAttributes( QList<QgsAttributeMap> &attributeMaps )
{
if ( !mVectorLayer )
{
return false;
}
QgsExpressionContext context = createExpressionContext();
context.setFields( mVectorLayer->fields() );
attributeMaps.clear();
//prepare filter expression
QScopedPointer<QgsExpression> filterExpression;
bool activeFilter = false;
if ( mFilterFeatures && !mFeatureFilter.isEmpty() )
{
filterExpression.reset( new QgsExpression( mFeatureFilter ) );
if ( !filterExpression->hasParserError() )
{
activeFilter = true;
}
}
QgsRectangle selectionRect;
if ( mComposerMap && mShowOnlyVisibleFeatures )
{
selectionRect = *mComposerMap->currentMapExtent();
if ( mComposition->mapSettings().hasCrsTransformEnabled() )
{
//transform back to layer CRS
QgsCoordinateTransform coordTransform( mVectorLayer->crs(), mComposition->mapSettings().destinationCrs() );
try
{
selectionRect = coordTransform.transformBoundingBox( selectionRect, QgsCoordinateTransform::ReverseTransform );
}
catch ( QgsCsException &cse )
{
Q_UNUSED( cse );
return false;
}
}
}
QgsFeatureRequest req;
if ( !selectionRect.isEmpty() )
req.setFilterRect( selectionRect );
req.setFlags( mShowOnlyVisibleFeatures ? QgsFeatureRequest::ExactIntersect : QgsFeatureRequest::NoFlags );
QgsFeature f;
int counter = 0;
QgsFeatureIterator fit = mVectorLayer->getFeatures( req );
while ( fit.nextFeature( f ) && counter < mMaximumNumberOfFeatures )
{
context.setFeature( f );
//check feature against filter
if ( activeFilter && !filterExpression.isNull() )
{
QVariant result = filterExpression->evaluate( &context );
// skip this feature if the filter evaluation is false
if ( !result.toBool() )
{
continue;
}
}
attributeMaps.push_back( QgsAttributeMap() );
QList<QgsComposerTableColumn*>::const_iterator columnIt = mColumns.constBegin();
int i = 0;
for ( ; columnIt != mColumns.constEnd(); ++columnIt )
{
int idx = mVectorLayer->fieldNameIndex(( *columnIt )->attribute() );
if ( idx != -1 )
{
attributeMaps.last().insert( i, f.attributes().at( idx ) );
}
else
{
// Lets assume it's an expression
QgsExpression* expression = new QgsExpression(( *columnIt )->attribute() );
context.lastScope()->setVariable( QString( "row_number" ), counter + 1 );
expression->prepare( &context );
QVariant value = expression->evaluate( &context );
attributeMaps.last().insert( i, value.toString() );
}
i++;
}
++counter;
}
//sort the list, starting with the last attribute
QgsComposerAttributeTableCompare c;
QList< QPair<int, bool> > sortColumns = sortAttributes();
for ( int i = sortColumns.size() - 1; i >= 0; --i )
{
c.setSortColumn( sortColumns.at( i ).first );
c.setAscending( sortColumns.at( i ).second );
qStableSort( attributeMaps.begin(), attributeMaps.end(), c );
}
adjustFrameToSize();
return true;
}
void QgsComposerAttributeTable::removeLayer( const QString& layerId )
{
if ( mVectorLayer )
{
if ( layerId == mVectorLayer->id() )
{
mVectorLayer = nullptr;
//remove existing columns
qDeleteAll( mColumns );
mColumns.clear();
}
}
}
void QgsComposerAttributeTable::setSceneRect( const QRectF& rectangle )
{
//update rect for data defined size and position
QRectF evaluatedRect = evalItemRect( rectangle );
QgsComposerItem::setSceneRect( evaluatedRect );
//refresh table attributes, since number of features has likely changed
refreshAttributes();
}
void QgsComposerAttributeTable::setSortAttributes( const QList<QPair<int, bool> >& att )
{
//first, clear existing sort by ranks
Q_FOREACH ( QgsComposerTableColumn* column, mColumns )
{
column->setSortByRank( 0 );
}
//now, update sort rank of specified columns
QList< QPair<int, bool > >::const_iterator sortedColumnIt = att.constBegin();
int rank = 1;
for ( ; sortedColumnIt != att.constEnd(); ++sortedColumnIt )
{
if (( *sortedColumnIt ).first >= mColumns.length() )
{
continue;
}
mColumns.at(( *sortedColumnIt ).first )->setSortByRank( rank );
mColumns.at(( *sortedColumnIt ).first )->setSortOrder(( *sortedColumnIt ).second ? Qt::AscendingOrder : Qt::DescendingOrder );
rank++;
}
refreshAttributes();
}
static bool columnsBySortRank( QPair<int, QgsComposerTableColumn* > a, QPair<int, QgsComposerTableColumn* > b )
{
return a.second->sortByRank() < b.second->sortByRank();
}
QList<QPair<int, bool> > QgsComposerAttributeTable::sortAttributes() const
{
//generate list of all sorted columns
QVector< QPair<int, QgsComposerTableColumn* > > sortedColumns;
QList<QgsComposerTableColumn*>::const_iterator columnIt = mColumns.constBegin();
int idx = 0;
for ( ; columnIt != mColumns.constEnd(); ++columnIt )
{
if (( *columnIt )->sortByRank() > 0 )
{
sortedColumns.append( qMakePair( idx, *columnIt ) );
}
idx++;
}
//sort columns by rank
qSort( sortedColumns.begin(), sortedColumns.end(), columnsBySortRank );
//generate list of column index, bool for sort direction (to match 2.0 api)
QList<QPair<int, bool> > attributesBySortRank;
QVector< QPair<int, QgsComposerTableColumn* > >::const_iterator sortedColumnIt = sortedColumns.constBegin();
for ( ; sortedColumnIt != sortedColumns.constEnd(); ++sortedColumnIt )
{
attributesBySortRank.append( qMakePair(( *sortedColumnIt ).first,
( *sortedColumnIt ).second->sortOrder() == Qt::AscendingOrder ) );
}
return attributesBySortRank;
}
bool QgsComposerAttributeTable::writeXml( QDomElement& elem, QDomDocument & doc ) const
{
QDomElement composerTableElem = doc.createElement( "ComposerAttributeTable" );
composerTableElem.setAttribute( "showOnlyVisibleFeatures", mShowOnlyVisibleFeatures );
composerTableElem.setAttribute( "maxFeatures", mMaximumNumberOfFeatures );
composerTableElem.setAttribute( "filterFeatures", mFilterFeatures ? "true" : "false" );
composerTableElem.setAttribute( "featureFilter", mFeatureFilter );
if ( mComposerMap )
{
composerTableElem.setAttribute( "composerMap", mComposerMap->id() );
}
else
{
composerTableElem.setAttribute( "composerMap", -1 );
}
if ( mVectorLayer )
{
composerTableElem.setAttribute( "vectorLayer", mVectorLayer->id() );
}
elem.appendChild( composerTableElem );
bool ok = tableWriteXml( composerTableElem, doc );
return ok;
}
bool QgsComposerAttributeTable::readXml( const QDomElement& itemElem, const QDomDocument& doc )
{
if ( itemElem.isNull() )
{
return false;
}
//read general table properties
if ( !tableReadXml( itemElem, doc ) )
{
return false;
}
mShowOnlyVisibleFeatures = itemElem.attribute( "showOnlyVisibleFeatures", "1" ).toInt();
mFilterFeatures = itemElem.attribute( "filterFeatures", "false" ) == "true" ? true : false;
mFeatureFilter = itemElem.attribute( "featureFilter", "" );
//composer map
int composerMapId = itemElem.attribute( "composerMap", "-1" ).toInt();
if ( composerMapId == -1 )
{
mComposerMap = nullptr;
}
if ( composition() )
{
mComposerMap = composition()->getComposerMapById( composerMapId );
}
else
{
mComposerMap = nullptr;
}
if ( mComposerMap )
{
//if we have found a valid map item, listen out to extent changes on it and refresh the table
QObject::connect( mComposerMap, SIGNAL( extentChanged() ), this, SLOT( refreshAttributes() ) );
}
//vector layer
QString layerId = itemElem.attribute( "vectorLayer", "not_existing" );
if ( layerId == "not_existing" )
{
mVectorLayer = nullptr;
}
else
{
QgsMapLayer* ml = QgsMapLayerRegistry::instance()->mapLayer( layerId );
if ( ml )
{
mVectorLayer = dynamic_cast<QgsVectorLayer*>( ml );
if ( mVectorLayer )
{
//if we have found a valid vector layer, listen for modifications on it and refresh the table
QObject::connect( mVectorLayer, SIGNAL( layerModified() ), this, SLOT( refreshAttributes() ) );
}
}
}
//restore display attribute map. This is required to upgrade pre 2.4 projects.
QSet<int> displayAttributes;
QDomNodeList displayAttributeList = itemElem.elementsByTagName( "displayAttributes" );
if ( !displayAttributeList.isEmpty() )
{
QDomElement displayAttributesElem = displayAttributeList.at( 0 ).toElement();
QDomNodeList attributeEntryList = displayAttributesElem.elementsByTagName( "attributeEntry" );
for ( int i = 0; i < attributeEntryList.size(); ++i )
{
QDomElement attributeEntryElem = attributeEntryList.at( i ).toElement();
int index = attributeEntryElem.attribute( "index", "-1" ).toInt();
if ( index != -1 )
{
displayAttributes.insert( index );
}
}
setDisplayAttributes( displayAttributes, false );
}
//restore alias map. This is required to upgrade pre 2.4 projects.
QMap<int, QString> fieldAliasMap;
QDomNodeList aliasMapNodeList = itemElem.elementsByTagName( "attributeAliasMap" );
if ( !aliasMapNodeList.isEmpty() )
{
QDomElement attributeAliasMapElem = aliasMapNodeList.at( 0 ).toElement();
QDomNodeList aliasMepEntryList = attributeAliasMapElem.elementsByTagName( "aliasEntry" );
for ( int i = 0; i < aliasMepEntryList.size(); ++i )
{
QDomElement aliasEntryElem = aliasMepEntryList.at( i ).toElement();
int key = aliasEntryElem.attribute( "key", "-1" ).toInt();
QString value = aliasEntryElem.attribute( "value", "" );
fieldAliasMap.insert( key, value );
}
restoreFieldAliasMap( fieldAliasMap );
}
//restore sort columns. This is required to upgrade pre 2.4 projects.
QDomElement sortColumnsElem = itemElem.firstChildElement( "sortColumns" );
if ( !sortColumnsElem.isNull() && mVectorLayer )
{
QDomNodeList columns = sortColumnsElem.elementsByTagName( "column" );
const QgsFields& fields = mVectorLayer->fields();
for ( int i = 0; i < columns.size(); ++i )
{
QDomElement columnElem = columns.at( i ).toElement();
int attribute = columnElem.attribute( "index" ).toInt();
Qt::SortOrder order = columnElem.attribute( "ascending" ) == "true" ? Qt::AscendingOrder : Qt::DescendingOrder;
//find corresponding column
Q_FOREACH ( QgsComposerTableColumn* column, mColumns )
{
if ( column->attribute() == fields.at( attribute ).name() )
{
column->setSortByRank( i + 1 );
column->setSortOrder( order );
break;
}
}
}
}
//must be done here because tableReadXML->setSceneRect changes mMaximumNumberOfFeatures
mMaximumNumberOfFeatures = itemElem.attribute( "maxFeatures", "5" ).toInt();
refreshAttributes();
emit itemChanged();
return true;
}

View File

@ -1,293 +0,0 @@
/***************************************************************************
qgscomposerattributetable.h
---------------------------
begin : April 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco at hugis dot net
***************************************************************************/
/***************************************************************************
* *
* 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 QGSCOMPOSERATTRIBUTETABLE_H
#define QGSCOMPOSERATTRIBUTETABLE_H
#include "qgscomposertable.h"
class QgsComposerMap;
class QgsVectorLayer;
/** \ingroup core
* Helper class for sorting tables, takes into account sorting column and ascending / descending
*/
class CORE_EXPORT QgsComposerAttributeTableCompare
{
public:
QgsComposerAttributeTableCompare();
bool operator()( const QgsAttributeMap& m1, const QgsAttributeMap& m2 );
/** Sets column number to sort by
* @param col column number for sorting
*/
void setSortColumn( int col ) { mCurrentSortColumn = col; }
/** Sets sort order for column sorting
* @param asc set to true to sort in ascending order, false to sort in descending order
*/
void setAscending( bool asc ) { mAscending = asc; }
private:
int mCurrentSortColumn;
bool mAscending;
};
/** \ingroup core
* A table class that displays a vector attribute table
* @deprecated use QgsComposerAttributeTableV2 instead
*/
// TODO QGIS 3.0 - remove
class CORE_EXPORT QgsComposerAttributeTable: public QgsComposerTable
{
Q_OBJECT
public:
QgsComposerAttributeTable( QgsComposition* composition );
~QgsComposerAttributeTable();
/** Return correct graphics item type. */
virtual int type() const override { return ComposerAttributeTable; }
/** \brief Reimplementation of QCanvasItem::paint*/
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ) override;
/** Writes properties specific to attribute tables
* @param elem an existing QDomElement in which to store the attribute table's properties.
* @param doc QDomDocument for the destination xml.
* @see readXml
*/
bool writeXml( QDomElement& elem, QDomDocument & doc ) const override;
/** Reads the properties specific to an attribute table from xml.
* @param itemElem a QDomElement holding the attribute table's desired properties.
* @param doc QDomDocument for the source xml.
* @see writeXml
*/
bool readXml( const QDomElement& itemElem, const QDomDocument& doc ) override;
/** Sets the vector layer from which to display feature attributes
* @param layer Vector layer for attribute table
* @see vectorLayer
*/
void setVectorLayer( QgsVectorLayer* layer );
/** Returns the vector layer the attribute table is currently using
* @returns attribute table's current vector layer
* @see setVectorLayer
*/
QgsVectorLayer* vectorLayer() const { return mVectorLayer; }
/** Resets the attribute table's columns to match the vector layer's fields
* @note added in 2.3
* @see setVectorLayer
*/
void resetColumns();
/** Sets the composer map to use to limit the extent of features shown in the
* attribute table. This setting only has an effect if setDisplayOnlyVisibleFeatures is
* set to true. Changing the composer map forces the table to refetch features from its
* vector layer, and may result in the table changing size to accommodate the new displayed
* feature attributes.
* @param map QgsComposerMap which drives the extents of the table's features
* @see composerMap
* @see setDisplayOnlyVisibleFeatures
*/
void setComposerMap( const QgsComposerMap* map );
/** Returns the composer map whose extents are controlling the features shown in the
* table. The extents of the map are only used if displayOnlyVisibleFeatures() is true.
* @returns composer map controlling the attribute table
* @see setComposerMap
* @see displayOnlyVisibleFeatures
*/
const QgsComposerMap* composerMap() const { return mComposerMap; }
/** Sets the maximum number of features shown by the table. Changing this setting may result
* in the attribute table changing its size to accommodate the new number of rows, and requires
* the table to refetch features from its vector layer.
* @param features maximum number of features to show in the table
* @see maximumNumberOfFeatures
*/
void setMaximumNumberOfFeatures( int features );
/** Returns the maximum number of features to be shown by the table.
* @returns maximum number of features
* @see setMaximumNumberOfFeatures
*/
int maximumNumberOfFeatures() const { return mMaximumNumberOfFeatures; }
/** Sets attribute table to only show features which are visible in a composer map item. Changing
* this setting forces the table to refetch features from its vector layer, and may result in
* the table changing size to accommodate the new displayed feature attributes.
* @param visibleOnly set to true to show only visible features
* @see displayOnlyVisibleFeatures
* @see setComposerMap
*/
void setDisplayOnlyVisibleFeatures( bool visibleOnly );
/** Returns true if the table is set to show only features visible on a corresponding
* composer map item.
* @returns true if table only shows visible features
* @see composerMap
* @see setDisplayOnlyVisibleFeatures
*/
bool displayOnlyVisibleFeatures() const { return mShowOnlyVisibleFeatures; }
/** Returns true if a feature filter is active on the attribute table
* @returns bool state of the feature filter
* @note added in 2.3
* @see setFilterFeatures
* @see featureFilter
*/
bool filterFeatures() const { return mFilterFeatures; }
/** Sets whether the feature filter is active for the attribute table. Changing
* this setting forces the table to refetch features from its vector layer, and may result in
* the table changing size to accommodate the new displayed feature attributes.
* @param filter Set to true to enable the feature filter
* @note added in 2.3
* @see filterFeatures
* @see setFeatureFilter
*/
void setFilterFeatures( bool filter );
/** Returns the current expression used to filter features for the table. The filter is only
* active if filterFeatures() is true.
* @returns feature filter expression
* @note added in 2.3
* @see setFeatureFilter
* @see filterFeatures
*/
QString featureFilter() const { return mFeatureFilter; }
/** Sets the expression used for filtering features in the table. The filter is only
* active if filterFeatures() is set to true. Changing this setting forces the table
* to refetch features from its vector layer, and may result in
* the table changing size to accommodate the new displayed feature attributes.
* @param expression filter to use for selecting which features to display in the table
* @note added in 2.3
* @see featureFilter
* @see setFilterFeatures
*/
void setFeatureFilter( const QString& expression );
/** Returns the attributes fields which are shown by the table.
* @returns a QSet of integers refering to the attributes in the vector layer. If
* result is an empty QSet than all feature attributes will be shown.
* @see setDisplayAttributes
* @deprecated use QgsComposerTable::columns() instead
*/
Q_DECL_DEPRECATED QSet<int> displayAttributes() const;
/** Sets the attributes to display in the table.
* @param attr QSet of integer values refering to the attributes from the vector layer to show.
* Set to an empty QSet to show all feature attributes.
* @param refresh set to true to force the table to refetch features from its vector layer
* and immediately update the display of the table. This may result in the table changing size
* to accommodate the new displayed feature attributes.
* @see displayAttributes
*/
void setDisplayAttributes( const QSet<int>& attr, bool refresh = true );
/** Returns the attribute field aliases, which control how fields are named in the table's
* header row.
* @returns a QMap of integers to strings, where the string is the field's alias and the
* integer is the field index from the associated vector layer.
* @see setFieldAliasMap
* @deprecated use QgsComposerTable::columns() instead
*/
Q_DECL_DEPRECATED QMap<int, QString> fieldAliasMap() const;
/** Sets the attribute field aliases, which control how fields are named in the table's
* header row.
* @param map QMap of integers to strings, where the string is the alias to use for the
* corresponding field, and the integer is the field index from the vector layer
* @see fieldAliasMap
* @deprecated use QgsComposerTable::columns() instead
*/
Q_DECL_DEPRECATED void setFieldAliasMap( const QMap<int, QString>& map );
/** Adapts mMaximumNumberOfFeatures depending on the rectangle height. Calling this forces
* the table to refetch features from its vector layer and immediately updates the display
* of the table.
* @see maximumNumberOfFeatures
* @see setMaximumNumberOfFeatures
*/
void setSceneRect( const QRectF& rectangle ) override;
/** Sets the attributes to use to sort the table's features.
* @param att QList integers/bool pairs, where the integer refers to the attribute index and
* the bool sets the sort order for the attribute. If true the attribute is sorted ascending,
* if false, the attribute is sorted in descending order. Note that features are sorted
* after the maximum number of displayed features have been fetched from the vector layer's
* provider.
* @see sortAttributes
* @deprecated use QgsComposerTable::columns() instead
* @note not available in python bindings
*/
Q_DECL_DEPRECATED void setSortAttributes( const QList<QPair<int, bool> >& att );
/** Returns the attributes used to sort the table's features.
* @returns a QList of integer/bool pairs, where the integer refers to the attribute index and
* the bool to the sort order for the attribute. If true the attribute is sorted ascending,
* if false, the attribute is sorted in descending order.
* @note not available in python bindings
*/
QList<QPair<int, bool> > sortAttributes() const;
/** Queries the attribute table's vector layer for attributes to show in the table.
* @param attributeMaps list of QgsAttributeMaps where the fetched feature attributes will be stored
* @returns true if attributes were successfully fetched
* @note not available in python bindings
*/
bool getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps ) override;
private:
/** Associated vector layer*/
QgsVectorLayer* mVectorLayer;
/** Associated composer map (used to display the visible features)*/
const QgsComposerMap* mComposerMap;
/** Maximum number of features that is displayed*/
int mMaximumNumberOfFeatures;
/** Shows only the features that are visible in the associated composer map (true by default)*/
bool mShowOnlyVisibleFeatures;
/** True if feature filtering enabled*/
bool mFilterFeatures;
/** Feature filter expression*/
QString mFeatureFilter;
/** Returns a list of attribute indices corresponding to displayed fields in the table.
* @note kept for compatibility with 2.0 api only
*/
QList<int> fieldsToDisplay() const;
/** Restores a field alias map from a pre 2.4 format project file format
* @param map QMap of integers to strings, where the string is the alias to use for the
* corresponding field, and the integer is the field index from the vector layer
*/
void restoreFieldAliasMap( const QMap<int, QString>& map );
private slots:
/** Checks if this vector layer will be removed (and sets mVectorLayer to 0 if yes) */
void removeLayer( const QString& layerId );
};
#endif // QGSCOMPOSERATTRIBUTETABLE_H

View File

@ -1,622 +0,0 @@
/***************************************************************************
qgscomposerattributetablemodel.cpp
--------------------
begin : April 2014
copyright : (C) 2014 by 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 "qgscomposerattributetable.h"
#include "qgscomposerattributetablemodel.h"
#include "qgscomposertable.h"
#include "qgscomposertablecolumn.h"
//QgsComposerAttributeTableColumnModel
QgsComposerAttributeTableColumnModel::QgsComposerAttributeTableColumnModel( QgsComposerAttributeTable *composerTable, QObject *parent ) : QAbstractTableModel( parent )
, mComposerTable( composerTable )
{
}
QgsComposerAttributeTableColumnModel::~QgsComposerAttributeTableColumnModel()
{
}
QModelIndex QgsComposerAttributeTableColumnModel::index( int row, int column, const QModelIndex &parent ) const
{
if ( hasIndex( row, column, parent ) )
{
if (( *mComposerTable->columns() )[row] )
{
return createIndex( row, column, ( *mComposerTable->columns() )[row] );
}
}
return QModelIndex();
}
QModelIndex QgsComposerAttributeTableColumnModel::parent( const QModelIndex &child ) const
{
Q_UNUSED( child );
return QModelIndex();
}
int QgsComposerAttributeTableColumnModel::rowCount( const QModelIndex &parent ) const
{
if ( parent.isValid() )
return 0;
return mComposerTable->columns()->length();
}
int QgsComposerAttributeTableColumnModel::columnCount( const QModelIndex &parent ) const
{
Q_UNUSED( parent );
return 3;
}
QVariant QgsComposerAttributeTableColumnModel::data( const QModelIndex &index, int role ) const
{
if ( !index.isValid() ||
( role != Qt::DisplayRole && role != Qt::EditRole && role != Qt::UserRole ) )
{
return QVariant();
}
if ( index.row() >= mComposerTable->columns()->length() )
{
return QVariant();
}
//get column for index
QgsComposerTableColumn* column = columnFromIndex( index );
if ( !column )
{
return QVariant();
}
if ( role == Qt::UserRole )
{
//user role stores reference in column object
return qVariantFromValue( qobject_cast<QObject *>( column ) );
}
switch ( index.column() )
{
case 0:
return column->attribute();
case 1:
return column->heading();
case 2:
{
if ( role == Qt::DisplayRole )
{
switch ( column->hAlignment() )
{
case Qt::AlignHCenter:
switch ( column->vAlignment() )
{
case Qt::AlignTop:
return tr( "Top center" );
case Qt::AlignBottom:
return tr( "Bottom center" );
default:
return tr( "Middle center" );
}
case Qt::AlignRight:
switch ( column->vAlignment() )
{
case Qt::AlignTop:
return tr( "Top right" );
case Qt::AlignBottom:
return tr( "Bottom right" );
default:
return tr( "Middle right" );
}
case Qt::AlignLeft:
default:
switch ( column->vAlignment() )
{
case Qt::AlignTop:
return tr( "Top left" );
case Qt::AlignBottom:
return tr( "Bottom left" );
default:
return tr( "Middle left" );
}
}
}
else
{
//edit role
return int( column->hAlignment() | column->vAlignment() );
}
}
default:
return QVariant();
}
}
QVariant QgsComposerAttributeTableColumnModel::headerData( int section, Qt::Orientation orientation, int role ) const
{
if ( !mComposerTable )
{
return QVariant();
}
if ( role == Qt::DisplayRole )
{
if ( orientation == Qt::Vertical ) //row
{
return QVariant( section );
}
else
{
switch ( section )
{
case 0:
return QVariant( tr( "Attribute" ) );
case 1:
return QVariant( tr( "Heading" ) );
case 2:
return QVariant( tr( "Alignment" ) );
default:
return QVariant();
}
}
}
else
{
return QVariant();
}
}
bool QgsComposerAttributeTableColumnModel::setData( const QModelIndex& index, const QVariant& value, int role )
{
if ( !index.isValid() || role != Qt::EditRole || !mComposerTable )
{
return false;
}
if ( index.row() >= mComposerTable->columns()->length() )
{
return false;
}
//get column for index
QgsComposerTableColumn* column = columnFromIndex( index );
if ( !column )
{
return false;
}
switch ( index.column() )
{
case 0:
// also update column's heading, if it hasn't been customised
if ( column->heading().isEmpty() || ( column->heading() == column->attribute() ) )
{
column->setHeading( value.toString() );
emit dataChanged( createIndex( index.row(), 1 ), createIndex( index.row(), 1 ) );
}
column->setAttribute( value.toString() );
emit dataChanged( index, index );
return true;
case 1:
column->setHeading( value.toString() );
emit dataChanged( index, index );
return true;
case 2:
column->setHAlignment( Qt::AlignmentFlag( value.toInt() & Qt::AlignHorizontal_Mask ) );
column->setVAlignment( Qt::AlignmentFlag( value.toInt() & Qt::AlignVertical_Mask ) );
emit dataChanged( index, index );
return true;
default:
break;
}
return false;
}
Qt::ItemFlags QgsComposerAttributeTableColumnModel::flags( const QModelIndex& index ) const
{
Qt::ItemFlags flags = QAbstractItemModel::flags( index );
if ( index.isValid() )
{
return flags | Qt::ItemIsEditable;
}
else
{
return flags;
}
}
bool QgsComposerAttributeTableColumnModel::removeRows( int row, int count, const QModelIndex& parent )
{
Q_UNUSED( parent );
int maxRow = qMin( row + count - 1, mComposerTable->columns()->length() - 1 );
beginRemoveRows( QModelIndex(), row, maxRow );
//move backwards through rows, removing each corresponding QgsComposerTableColumn
for ( int i = maxRow; i >= row; --i )
{
delete( *mComposerTable->columns() )[i];
mComposerTable->columns()->removeAt( i );
}
endRemoveRows();
return true;
}
bool QgsComposerAttributeTableColumnModel::insertRows( int row, int count, const QModelIndex& parent )
{
Q_UNUSED( parent );
beginInsertRows( QModelIndex(), row, row + count - 1 );
//create new QgsComposerTableColumns for each inserted row
for ( int i = row; i < row + count; ++i )
{
QgsComposerTableColumn* col = new QgsComposerTableColumn;
mComposerTable->columns()->insert( i, col );
}
endInsertRows();
return true;
}
bool QgsComposerAttributeTableColumnModel::moveRow( int row, ShiftDirection direction )
{
if (( direction == ShiftUp && row <= 0 ) ||
( direction == ShiftDown && row >= rowCount() - 1 ) )
{
//row is already at top/bottom
return false;
}
//we shift a row by removing the next row up/down, then reinserting it before/after the target row
int swapWithRow = direction == ShiftUp ? row - 1 : row + 1;
//remove row
beginRemoveRows( QModelIndex(), swapWithRow, swapWithRow );
QgsComposerTableColumn* temp = mComposerTable->columns()->takeAt( swapWithRow );
endRemoveRows();
//insert row
beginInsertRows( QModelIndex(), row, row );
mComposerTable->columns()->insert( row, temp );
endInsertRows();
return true;
}
void QgsComposerAttributeTableColumnModel::resetToLayer()
{
beginResetModel();
mComposerTable->resetColumns();
endResetModel();
}
QgsComposerTableColumn* QgsComposerAttributeTableColumnModel::columnFromIndex( const QModelIndex &index ) const
{
QgsComposerTableColumn* column = static_cast<QgsComposerTableColumn*>( index.internalPointer() );
return column;
}
QModelIndex QgsComposerAttributeTableColumnModel::indexFromColumn( QgsComposerTableColumn* column )
{
if ( !mComposerTable )
{
return QModelIndex();
}
int r = mComposerTable->columns()->indexOf( column );
QModelIndex idx = index( r, 0, QModelIndex() );
if ( idx.isValid() )
{
return idx;
}
return QModelIndex();
}
void QgsComposerAttributeTableColumnModel::setColumnAsSorted( QgsComposerTableColumn* column, Qt::SortOrder order )
{
if ( !column || !mComposerTable )
{
return;
}
//find current highest sort by rank
int highestRank = 0;
QList<QgsComposerTableColumn*>::const_iterator columnIt = mComposerTable->columns()->constBegin();
for ( ; columnIt != mComposerTable->columns()->constEnd(); ++columnIt )
{
highestRank = qMax( highestRank, ( *columnIt )->sortByRank() );
}
column->setSortByRank( highestRank + 1 );
column->setSortOrder( order );
QModelIndex idx = indexFromColumn( column );
emit dataChanged( idx, idx );
}
void QgsComposerAttributeTableColumnModel::setColumnAsUnsorted( QgsComposerTableColumn * column )
{
if ( !mComposerTable || !column )
{
return;
}
column->setSortByRank( 0 );
QModelIndex idx = indexFromColumn( column );
emit dataChanged( idx, idx );
}
static bool columnsBySortRank( QgsComposerTableColumn * a, QgsComposerTableColumn * b )
{
return a->sortByRank() < b->sortByRank();
}
bool QgsComposerAttributeTableColumnModel::moveColumnInSortRank( QgsComposerTableColumn * column, ShiftDirection direction )
{
if ( !mComposerTable || !column )
{
return false;
}
if (( direction == ShiftUp && column->sortByRank() <= 1 )
|| ( direction == ShiftDown && column->sortByRank() <= 0 ) )
{
//already at start/end of list or not being used for sort
return false;
}
//find column before this one in sort order
QList<QgsComposerTableColumn*> sortedColumns;
Q_FOREACH ( QgsComposerTableColumn* currentColumn, *mComposerTable->columns() )
{
if ( currentColumn->sortByRank() > 0 )
{
sortedColumns.append( currentColumn );
}
}
qStableSort( sortedColumns.begin(), sortedColumns.end(), columnsBySortRank );
int columnPos = sortedColumns.indexOf( column );
if (( columnPos == 0 && direction == ShiftUp )
|| (( columnPos == sortedColumns.length() - 1 ) && direction == ShiftDown ) )
{
//column already at start/end
return false;
}
QgsComposerTableColumn* swapColumn = direction == ShiftUp ?
sortedColumns[ columnPos - 1]
: sortedColumns[ columnPos + 1];
QModelIndex idx = indexFromColumn( column );
QModelIndex idxSwap = indexFromColumn( swapColumn );
//now swap sort ranks
int oldSortRank = column->sortByRank();
column->setSortByRank( swapColumn->sortByRank() );
emit dataChanged( idx, idx );
swapColumn->setSortByRank( oldSortRank );
emit dataChanged( idxSwap, idxSwap );
return true;
}
//QgsComposerTableSortColumnsProxyModel
QgsComposerTableSortColumnsProxyModel::QgsComposerTableSortColumnsProxyModel( QgsComposerAttributeTable *composerTable, ColumnFilterType filterType, QObject *parent )
: QSortFilterProxyModel( parent )
, mComposerTable( composerTable )
, mFilterType( filterType )
{
setDynamicSortFilter( true );
}
QgsComposerTableSortColumnsProxyModel::~QgsComposerTableSortColumnsProxyModel()
{
}
bool QgsComposerTableSortColumnsProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const
{
//get QgsComposerTableColumn corresponding to row
QModelIndex index = sourceModel()->index( source_row, 0, source_parent );
QgsComposerTableColumn* column = columnFromSourceIndex( index );
if ( !column )
{
return false;
}
if (( column->sortByRank() > 0 && mFilterType == ShowSortedColumns )
|| ( column->sortByRank() <= 0 && mFilterType == ShowUnsortedColumns ) )
{
//column matches filter type
return true;
}
else
{
return false;
}
}
QgsComposerTableColumn *QgsComposerTableSortColumnsProxyModel::columnFromIndex( const QModelIndex &index ) const
{
//get column corresponding to an index from the proxy
QModelIndex sourceIndex = mapToSource( index );
return columnFromSourceIndex( sourceIndex );
}
QgsComposerTableColumn* QgsComposerTableSortColumnsProxyModel::columnFromSourceIndex( const QModelIndex &sourceIndex ) const
{
//get column corresponding to an index from the source model
QVariant columnAsVariant = sourceModel()->data( sourceIndex, Qt::UserRole );
QgsComposerTableColumn* column = qobject_cast<QgsComposerTableColumn *>( columnAsVariant.value<QObject *>() );
return column;
}
bool QgsComposerTableSortColumnsProxyModel::lessThan( const QModelIndex &left, const QModelIndex &right ) const
{
QgsComposerTableColumn* column1 = columnFromSourceIndex( left );
QgsComposerTableColumn* column2 = columnFromSourceIndex( right );
if ( !column1 )
{
return false;
}
if ( !column2 )
{
return true;
}
return column1->sortByRank() < column2->sortByRank();
}
int QgsComposerTableSortColumnsProxyModel::columnCount( const QModelIndex &parent ) const
{
Q_UNUSED( parent );
return 2;
}
QVariant QgsComposerTableSortColumnsProxyModel::data( const QModelIndex &index, int role ) const
{
if (( role != Qt::DisplayRole && role != Qt::EditRole ) || !index.isValid() )
{
return QVariant();
}
QgsComposerTableColumn* column = columnFromIndex( index );
if ( !column )
{
return QVariant();
}
switch ( index.column() )
{
case 0:
return column->attribute();
case 1:
if ( role == Qt::DisplayRole )
{
switch ( column->sortOrder() )
{
case Qt::DescendingOrder:
return tr( "Descending" );
case Qt::AscendingOrder:
default:
return tr( "Ascending" );
}
}
else
{
//edit role
return column->sortOrder();
}
default:
return QVariant();
}
}
QVariant QgsComposerTableSortColumnsProxyModel::headerData( int section, Qt::Orientation orientation, int role ) const
{
if ( !mComposerTable )
{
return QVariant();
}
if ( role == Qt::DisplayRole )
{
if ( orientation == Qt::Vertical ) //row
{
return QVariant( section );
}
else
{
switch ( section )
{
case 0:
return QVariant( tr( "Attribute" ) );
case 1:
return QVariant( tr( "Sort Order" ) );
default:
return QVariant();
}
}
}
else
{
return QVariant();
}
}
Qt::ItemFlags QgsComposerTableSortColumnsProxyModel::flags( const QModelIndex& index ) const
{
Qt::ItemFlags flags = QAbstractItemModel::flags( index );
if ( index.column() == 1 )
{
//only sort order is editable
flags |= Qt::ItemIsEditable;
}
return flags;
}
bool QgsComposerTableSortColumnsProxyModel::setData( const QModelIndex& index, const QVariant& value, int role )
{
if ( !index.isValid() || role != Qt::EditRole )
return false;
if ( !mComposerTable )
{
return false;
}
QgsComposerTableColumn* column = columnFromIndex( index );
if ( !column )
{
return false;
}
if ( index.column() == 1 )
{
column->setSortOrder( static_cast< Qt::SortOrder >( value.toInt() ) );
emit dataChanged( index, index );
return true;
}
return false;
}
QgsComposerTableColumn *QgsComposerTableSortColumnsProxyModel::columnFromRow( int row )
{
QModelIndex proxyIndex = index( row, 0 );
return columnFromIndex( proxyIndex );
}
void QgsComposerTableSortColumnsProxyModel::resetFilter()
{
invalidate();
}

View File

@ -1,209 +0,0 @@
/***************************************************************************
qgscomposerattributetablemodel.h
--------------------
begin : April 2014
copyright : (C) 2014 by 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. *
* *
***************************************************************************/
#ifndef QGSCOMPOSERATTRIBUTETABLEMODEL_H
#define QGSCOMPOSERATTRIBUTETABLEMODEL_H
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
class QgsComposerAttributeTable;
class QgsComposerTableColumn;
//QgsComposerAttributeTableColumnModel
/** \ingroup core
* A model for displaying columns shown in a QgsComposerAttributeTable
*/
class CORE_EXPORT QgsComposerAttributeTableColumnModel: public QAbstractTableModel
{
Q_OBJECT
public:
/** Controls whether a row/column is shifted up or down
*/
enum ShiftDirection
{
ShiftUp, /*!< shift the row/column up */
ShiftDown /*!< shift the row/column down */
};
/** Constructor for QgsComposerAttributeTableColumnModel.
* @param composerTable QgsComposerAttributeTable the model is attached to
* @param parent optional parent
*/
QgsComposerAttributeTableColumnModel( QgsComposerAttributeTable *composerTable, QObject *parent = nullptr );
virtual ~QgsComposerAttributeTableColumnModel();
virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
virtual QVariant data( const QModelIndex &index, int role ) const override;
QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
Qt::ItemFlags flags( const QModelIndex &index ) const override;
bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
bool insertRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
QModelIndex index( int row, int column, const QModelIndex &parent ) const override;
QModelIndex parent( const QModelIndex &child ) const override;
/** Moves the specified row up or down in the model. Used for rearranging the attribute tables
* columns.
* @returns true if the move is allowed
* @param row row in model representing attribute table column to move
* @param direction direction to move the attribute table column
* @note added in 2.3
*/
bool moveRow( int row, ShiftDirection direction );
/** Resets the attribute table's columns to match the source layer's fields. Remove all existing
* attribute table columns and column customisations.
* @note added in 2.3
*/
void resetToLayer();
/** Returns the QgsComposerTableColumn corresponding to an index in the model.
* @returns QgsComposerTableColumn for specified index
* @param index a QModelIndex
* @note added in 2.3
* @see indexFromColumn
*/
QgsComposerTableColumn* columnFromIndex( const QModelIndex & index ) const;
/** Returns a QModelIndex corresponding to a QgsComposerTableColumn in the model.
* @returns QModelIndex for specified QgsComposerTableColumn
* @param column a QgsComposerTableColumn
* @note added in 2.3
* @see columnFromIndex
*/
QModelIndex indexFromColumn( QgsComposerTableColumn *column );
/** Sets a specified column as a sorted column in the QgsComposerAttributeTable. The column will be
* added to the end of the sort rank list, ie it will take the next largest available sort rank.
* @param column a QgsComposerTableColumn
* @param order sort order for column
* @note added in 2.3
* @see removeColumnFromSort
* @see moveColumnInSortRank
*/
void setColumnAsSorted( QgsComposerTableColumn *column, Qt::SortOrder order );
/** Sets a specified column as an unsorted column in the QgsComposerAttributeTable. The column will be
* removed from the sort rank list.
* @param column a QgsComposerTableColumn
* @note added in 2.3
* @see setColumnAsSorted
*/
void setColumnAsUnsorted( QgsComposerTableColumn * column );
/** Moves a column up or down in the sort rank for the QgsComposerAttributeTable.
* @param column a QgsComposerTableColumn
* @param direction direction to move the column in the sort rank list
* @note added in 2.3
* @see setColumnAsSorted
*/
bool moveColumnInSortRank( QgsComposerTableColumn * column, ShiftDirection direction );
private:
QgsComposerAttributeTable * mComposerTable;
};
//QgsComposerTableSortColumnsProxyModel
/** \ingroup core
* Allows for filtering QgsComposerAttributeTable columns by columns which are sorted or unsorted
*/
class CORE_EXPORT QgsComposerTableSortColumnsProxyModel: public QSortFilterProxyModel
{
Q_OBJECT
public:
/** Controls whether the proxy model shows sorted or unsorted columns
*/
enum ColumnFilterType
{
ShowSortedColumns, /*!< show only sorted columns */
ShowUnsortedColumns/*!< show only unsorted columns */
};
/** Constructor for QgsComposerTableSortColumnsProxyModel.
* @param composerTable QgsComposerAttributeTable the model is attached to
* @param filterType filter for columns, controls whether sorted or unsorted columns are shown
* @param parent optional parent
*/
QgsComposerTableSortColumnsProxyModel( QgsComposerAttributeTable *composerTable, ColumnFilterType filterType, QObject *parent = nullptr );
virtual ~QgsComposerTableSortColumnsProxyModel();
bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override;
int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
virtual QVariant data( const QModelIndex &index, int role ) const override;
QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
Qt::ItemFlags flags( const QModelIndex &index ) const override;
virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
/** Returns the QgsComposerTableColumn corresponding to a row in the proxy model.
* @returns QgsComposerTableColumn for specified row
* @param row a row number
* @note added in 2.3
* @see columnFromIndex
*/
QgsComposerTableColumn* columnFromRow( int row );
/** Returns the QgsComposerTableColumn corresponding to an index in the proxy model.
* @returns QgsComposerTableColumn for specified index
* @param index a QModelIndex
* @note added in 2.3
* @see columnFromRow
* @see columnFromSourceIndex
*/
QgsComposerTableColumn* columnFromIndex( const QModelIndex & index ) const;
/** Returns the QgsComposerTableColumn corresponding to an index from the source
* QgsComposerAttributeTableColumnModel model.
* @returns QgsComposerTableColumn for specified index from QgsComposerAttributeTableColumnModel
* @param sourceIndex a QModelIndex
* @note added in 2.3
* @see columnFromRow
* @see columnFromIndex
*/
QgsComposerTableColumn* columnFromSourceIndex( const QModelIndex& sourceIndex ) const;
/** Invalidates the current filter used by the proxy model
* @note added in 2.3
*/
void resetFilter();
protected:
bool filterAcceptsRow( int source_row, const QModelIndex & source_parent ) const override;
private:
QgsComposerAttributeTable * mComposerTable;
ColumnFilterType mFilterType;
/** Returns a list of QgsComposerTableColumns without a set sort rank
* @returns QgsComposerTableColumns in attribute table without a sort rank
* @note added in 2.3
*/
QList<QgsComposerTableColumn*> columnsWithoutSortRank() const;
};
#endif // QGSCOMPOSERATTRIBUTETABLEMODEL_H

View File

@ -312,58 +312,6 @@ void QgsComposerAttributeTableV2::setFeatureFilter( const QString& expression )
emit changed();
}
void QgsComposerAttributeTableV2::setDisplayAttributes( const QSet<int>& attr, bool refresh )
{
QgsVectorLayer* source = sourceLayer();
if ( !source )
{
return;
}
//rebuild columns list, taking only attributes with index in supplied QSet
qDeleteAll( mColumns );
mColumns.clear();
const QgsFields& fields = source->fields();
if ( !attr.empty() )
{
QSet<int>::const_iterator attIt = attr.constBegin();
for ( ; attIt != attr.constEnd(); ++attIt )
{
int attrIdx = ( *attIt );
if ( !fields.exists( attrIdx ) )
{
continue;
}
QString currentAlias = source->attributeDisplayName( attrIdx );
QgsComposerTableColumn* col = new QgsComposerTableColumn;
col->setAttribute( fields.at( attrIdx ).name() );
col->setHeading( currentAlias );
mColumns.append( col );
}
}
else
{
//resetting, so add all attributes to columns
int idx = 0;
Q_FOREACH ( const QgsField& field, fields )
{
QString currentAlias = source->attributeDisplayName( idx );
QgsComposerTableColumn* col = new QgsComposerTableColumn;
col->setAttribute( field.name() );
col->setHeading( currentAlias );
mColumns.append( col );
idx++;
}
}
if ( refresh )
{
refreshAttributes();
}
}
void QgsComposerAttributeTableV2::setDisplayedFields( const QStringList& fields, bool refresh )
{
QgsVectorLayer* source = sourceLayer();

View File

@ -255,16 +255,6 @@ class CORE_EXPORT QgsComposerAttributeTableV2: public QgsComposerTableV2
*/
void setFeatureFilter( const QString& expression );
/** Sets the attributes to display in the table.
* @param attr QSet of integer values refering to the attributes from the vector layer to show.
* Set to an empty QSet to show all feature attributes.
* @param refresh set to true to force the table to refetch features from its vector layer
* and immediately update the display of the table. This may result in the table changing size
* to accommodate the new displayed feature attributes.
* @deprecated use setDisplayedFields() instead
*/
Q_DECL_DEPRECATED void setDisplayAttributes( const QSet<int>& attr, bool refresh = true );
/** Sets the attributes to display in the table.
* @param fields list of fields names from the vector layer to show.
* Set to an empty list to show all feature attributes.

View File

@ -866,16 +866,6 @@ void QgsComposerItem::drawBackground( QPainter* p )
}
}
void QgsComposerItem::drawArrowHead( QPainter *p, double x, double y, double angle, double arrowHeadWidth ) const
{
QgsComposerUtils::drawArrowHead( p, x, y, angle, arrowHeadWidth );
}
double QgsComposerItem::angle( QPointF p1, QPointF p2 ) const
{
return QgsComposerUtils::angle( p1, p2 );
}
void QgsComposerItem::setBackgroundColor( const QColor& backgroundColor )
{
mBackgroundColor = backgroundColor;
@ -949,50 +939,6 @@ void QgsComposerItem::setEffectsEnabled( const bool effectsEnabled )
mEffect->setEnabled( effectsEnabled );
}
void QgsComposerItem::drawText( QPainter* p, double x, double y, const QString& text, const QFont& font, const QColor& c ) const
{
QgsComposerUtils::drawText( p, QPointF( x, y ), text, font, c );
}
void QgsComposerItem::drawText( QPainter* p, const QRectF& rect, const QString& text, const QFont& font, Qt::AlignmentFlag halignment, Qt::AlignmentFlag valignment, int flags ) const
{
QgsComposerUtils::drawText( p, rect, text, font, QColor(), halignment, valignment, flags );
}
double QgsComposerItem::textWidthMillimeters( const QFont& font, const QString& text ) const
{
return QgsComposerUtils::textWidthMM( font, text );
}
double QgsComposerItem::fontHeightCharacterMM( const QFont& font, QChar c ) const
{
return QgsComposerUtils::fontHeightCharacterMM( font, c );
}
double QgsComposerItem::fontAscentMillimeters( const QFont& font ) const
{
return QgsComposerUtils::fontAscentMM( font );
}
double QgsComposerItem::fontDescentMillimeters( const QFont& font ) const
{
return QgsComposerUtils::fontDescentMM( font );
}
double QgsComposerItem::fontHeightMillimeters( const QFont& font ) const
{
return QgsComposerUtils::fontHeightMM( font );
}
double QgsComposerItem::pixelFontSize( double pointSize ) const
{
return QgsComposerUtils::pointsToMM( pointSize );
}
QFont QgsComposerItem::scaledFontPixelSize( const QFont& font ) const
{
return QgsComposerUtils::scaledFontPixelSize( font );
}
double QgsComposerItem::horizontalViewScaleFactor() const
{
double result = -1;
@ -1030,28 +976,6 @@ double QgsComposerItem::rectHandlerBorderTolerance() const
return rectHandlerSize;
}
double QgsComposerItem::lockSymbolSize() const
{
double lockSymbolSize = 20.0 / horizontalViewScaleFactor();
if ( lockSymbolSize > ( rect().width() / 3 ) )
{
lockSymbolSize = rect().width() / 3;
}
if ( lockSymbolSize > ( rect().height() / 3 ) )
{
lockSymbolSize = rect().height() / 3;
}
return lockSymbolSize;
}
void QgsComposerItem::setRotation( const double r )
{
//kept for api compatibility with QGIS 2.0
//remove after 2.0 series
setItemRotation( r, true );
}
void QgsComposerItem::setItemRotation( const double r, const bool adjustPosition )
{
if ( r >= 360 )
@ -1118,180 +1042,6 @@ void QgsComposerItem::refreshRotation( const bool updateItem, const bool adjustP
}
}
bool QgsComposerItem::imageSizeConsideringRotation( double& width, double& height ) const
{
//kept for api compatibility with QGIS 2.0, use item rotation
Q_NOWARN_DEPRECATED_PUSH
return imageSizeConsideringRotation( width, height, mEvaluatedItemRotation );
Q_NOWARN_DEPRECATED_POP
}
bool QgsComposerItem::imageSizeConsideringRotation( double& width, double& height, double rotation ) const
{
if ( qAbs( rotation ) <= 0.0 ) //width and height stays the same if there is no rotation
{
return true;
}
if ( qgsDoubleNear( qAbs( rotation ), 90 ) || qgsDoubleNear( qAbs( rotation ), 270 ) )
{
double tmp = width;
width = height;
height = tmp;
return true;
}
double x1 = 0;
double y1 = 0;
double x2 = width;
double y2 = 0;
double x3 = width;
double y3 = height;
double x4 = 0;
double y4 = height;
double midX = width / 2.0;
double midY = height / 2.0;
Q_NOWARN_DEPRECATED_PUSH
if ( !cornerPointOnRotatedAndScaledRect( x1, y1, width, height, rotation ) )
{
return false;
}
if ( !cornerPointOnRotatedAndScaledRect( x2, y2, width, height, rotation ) )
{
return false;
}
if ( !cornerPointOnRotatedAndScaledRect( x3, y3, width, height, rotation ) )
{
return false;
}
if ( !cornerPointOnRotatedAndScaledRect( x4, y4, width, height, rotation ) )
{
return false;
}
Q_NOWARN_DEPRECATED_POP
//assume points 1 and 3 are on the rectangle boundaries. Calculate 2 and 4.
double distM1 = sqrt(( x1 - midX ) * ( x1 - midX ) + ( y1 - midY ) * ( y1 - midY ) );
QPointF p2 = QgsSymbolLayerUtils::pointOnLineWithDistance( QPointF( midX, midY ), QPointF( x2, y2 ), distM1 );
if ( p2.x() < width && p2.x() > 0 && p2.y() < height && p2.y() > 0 )
{
width = sqrt(( p2.x() - x1 ) * ( p2.x() - x1 ) + ( p2.y() - y1 ) * ( p2.y() - y1 ) );
height = sqrt(( x3 - p2.x() ) * ( x3 - p2.x() ) + ( y3 - p2.y() ) * ( y3 - p2.y() ) );
return true;
}
//else assume that points 2 and 4 are on the rectangle boundaries. Calculate 1 and 3
double distM2 = sqrt(( x2 - midX ) * ( x2 - midX ) + ( y2 - midY ) * ( y2 - midY ) );
QPointF p1 = QgsSymbolLayerUtils::pointOnLineWithDistance( QPointF( midX, midY ), QPointF( x1, y1 ), distM2 );
QPointF p3 = QgsSymbolLayerUtils::pointOnLineWithDistance( QPointF( midX, midY ), QPointF( x3, y3 ), distM2 );
width = sqrt(( x2 - p1.x() ) * ( x2 - p1.x() ) + ( y2 - p1.y() ) * ( y2 - p1.y() ) );
height = sqrt(( p3.x() - x2 ) * ( p3.x() - x2 ) + ( p3.y() - y2 ) * ( p3.y() - y2 ) );
return true;
}
QRectF QgsComposerItem::largestRotatedRectWithinBounds( const QRectF& originalRect, const QRectF& boundsRect, double rotation ) const
{
return QgsComposerUtils::largestRotatedRectWithinBounds( originalRect, boundsRect, rotation );
}
bool QgsComposerItem::cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height ) const
{
//kept for api compatibility with QGIS 2.0, use item rotation
Q_NOWARN_DEPRECATED_PUSH
return cornerPointOnRotatedAndScaledRect( x, y, width, height, mEvaluatedItemRotation );
Q_NOWARN_DEPRECATED_POP
}
bool QgsComposerItem::cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height, double rotation ) const
{
//first rotate point clockwise
double rotToRad = rotation * M_PI / 180.0;
QPointF midpoint( width / 2.0, height / 2.0 );
double xVector = x - midpoint.x();
double yVector = y - midpoint.y();
//double xRotated = cos(rotToRad) * xVector + sin(rotToRad) * yVector;
//double yRotated = -sin(rotToRad) * xVector + cos(rotToRad) * yVector;
double xRotated = cos( rotToRad ) * xVector - sin( rotToRad ) * yVector;
double yRotated = sin( rotToRad ) * xVector + cos( rotToRad ) * yVector;
//create line from midpoint to rotated point
QLineF line( midpoint.x(), midpoint.y(), midpoint.x() + xRotated, midpoint.y() + yRotated );
//intersect with all four borders and return result
QList<QLineF> borders;
borders << QLineF( 0, 0, width, 0 );
borders << QLineF( width, 0, width, height );
borders << QLineF( width, height, 0, height );
borders << QLineF( 0, height, 0, 0 );
QList<QLineF>::const_iterator it = borders.constBegin();
QPointF intersectionPoint;
for ( ; it != borders.constEnd(); ++it )
{
if ( line.intersect( *it, &intersectionPoint ) == QLineF::BoundedIntersection )
{
x = intersectionPoint.x();
y = intersectionPoint.y();
return true;
}
}
return false;
}
void QgsComposerItem::sizeChangedByRotation( double& width, double& height )
{
//kept for api compatibility with QGIS 2.0, use item rotation
Q_NOWARN_DEPRECATED_PUSH
return sizeChangedByRotation( width, height, mEvaluatedItemRotation );
Q_NOWARN_DEPRECATED_POP
}
void QgsComposerItem::sizeChangedByRotation( double& width, double& height, double rotation )
{
if ( rotation == 0.0 )
{
return;
}
//vector to p1
double x1 = -width / 2.0;
double y1 = -height / 2.0;
QgsComposerUtils::rotate( rotation, x1, y1 );
//vector to p2
double x2 = width / 2.0;
double y2 = -height / 2.0;
QgsComposerUtils::rotate( rotation, x2, y2 );
//vector to p3
double x3 = width / 2.0;
double y3 = height / 2.0;
QgsComposerUtils::rotate( rotation, x3, y3 );
//vector to p4
double x4 = -width / 2.0;
double y4 = height / 2.0;
QgsComposerUtils::rotate( rotation, x4, y4 );
//double midpoint
QPointF midpoint( width / 2.0, height / 2.0 );
QPolygonF rotatedRectPoly;
rotatedRectPoly << QPointF( midpoint.x() + x1, midpoint.y() + y1 );
rotatedRectPoly << QPointF( midpoint.x() + x2, midpoint.y() + y2 );
rotatedRectPoly << QPointF( midpoint.x() + x3, midpoint.y() + y3 );
rotatedRectPoly << QPointF( midpoint.x() + x4, midpoint.y() + y4 );
QRectF boundingRect = rotatedRectPoly.boundingRect();
width = boundingRect.width();
height = boundingRect.height();
}
void QgsComposerItem::rotate( double angle, double& x, double& y ) const
{
QgsComposerUtils::rotate( angle, x, y );
}
QGraphicsLineItem* QgsComposerItem::hAlignSnapItem()
{
if ( !mHAlignSnapItem )

View File

@ -153,14 +153,6 @@ class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRec
@param dy move in y-direction(canvas coordinates)*/
virtual void moveContent( double dx, double dy ) { Q_UNUSED( dx ); Q_UNUSED( dy ); }
/** Zoom content of item. Does nothing per default (but implemented in composer map)
* @param delta value from wheel event that describes direction (positive /negative number)
* @param x x-position of mouse cursor (in item coordinates)
* @param y y-position of mouse cursor (in item coordinates)
* @deprecated use zoomContent( double, QPointF, ZoomMode ) instead
*/
Q_DECL_DEPRECATED virtual void zoomContent( int delta, double x, double y ) { Q_UNUSED( delta ); Q_UNUSED( x ); Q_UNUSED( y ); }
/** Zoom content of item. Does nothing per default (but implemented in composer map)
* @param factor zoom factor, where > 1 results in a zoom in and < 1 results in a zoom out
* @param point item point for zoom center
@ -416,61 +408,6 @@ class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRec
//functions that encapsulate the workaround for the Qt font bug (that is to scale the font size up and then scale the
//painter down by the same factor for drawing
/** Draws Text. Takes care about all the composer specific issues (calculation to pixel, scaling of font and painter
* to work around the Qt font bug)
* @deprecated use QgsComposerUtils::drawText instead
*/
Q_DECL_DEPRECATED void drawText( QPainter* p, double x, double y, const QString& text, const QFont& font, const QColor& c = QColor() ) const;
/** Like the above, but with a rectangle for multiline text
* @param p painter to use
* @param rect rectangle to draw into
* @param text text to draw
* @param font font to use
* @param halignment optional horizontal alignment
* @param valignment optional vertical alignment
* @param flags allows for passing Qt::TextFlags to control appearance of rendered text
* @deprecated use QgsComposerUtils::drawText instead
*/
Q_DECL_DEPRECATED void drawText( QPainter* p, const QRectF& rect, const QString& text, const QFont& font, Qt::AlignmentFlag halignment = Qt::AlignLeft, Qt::AlignmentFlag valignment = Qt::AlignTop, int flags = Qt::TextWordWrap ) const;
/** Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE
* @deprecated use QgsComposerUtils::textWidthMM instead
*/
Q_DECL_DEPRECATED double textWidthMillimeters( const QFont& font, const QString& text ) const;
/** Returns the font height of a character in millimeters
* @deprecated use QgsComposerUtils::fontHeightCharacterMM instead
*/
Q_DECL_DEPRECATED double fontHeightCharacterMM( const QFont& font, QChar c ) const;
/** Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE
* @deprecated use QgsComposerUtils::fontAscentMM instead
*/
Q_DECL_DEPRECATED double fontAscentMillimeters( const QFont& font ) const;
/** Returns the font descent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE
* @deprecated use QgsComposerUtils::fontDescentMM instead
*/
Q_DECL_DEPRECATED double fontDescentMillimeters( const QFont& font ) const;
/** Returns the font height in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE.
* Font height equals the font ascent+descent+1 (for baseline).
* @note Added in version 2.4
* @deprecated use QgsComposerUtils::fontHeightMM instead
*/
Q_DECL_DEPRECATED double fontHeightMillimeters( const QFont& font ) const;
/** Calculates font size in mm from a font point size
* @deprecated use QgsComposerUtils::mmFontSize instead
*/
Q_DECL_DEPRECATED double pixelFontSize( double pointSize ) const;
/** Returns a font where size is in pixel and font size is upscaled with FONT_WORKAROUND_SCALE
* @deprecated use QgsComposerUtils::scaledFontPixelSize instead
*/
Q_DECL_DEPRECATED QFont scaledFontPixelSize( const QFont& font ) const;
/** Locks / unlocks the item position for mouse drags
* @param lock set to true to prevent item movement and resizing via the mouse
* @see positionLock
@ -493,11 +430,6 @@ class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRec
*/
double itemRotation( const QgsComposerObject::PropertyValueType valueType = QgsComposerObject::EvaluatedValue ) const;
/** Returns the rotation for the composer item
* @deprecated Use itemRotation() instead
*/
Q_DECL_DEPRECATED double rotation() const { return mEvaluatedItemRotation; }
/** Updates item, with the possibility to do custom update for subclasses*/
virtual void updateItem() { QGraphicsRectItem::update(); }
@ -591,10 +523,6 @@ class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRec
virtual QgsExpressionContext createExpressionContext() const override;
public slots:
/** Sets the item rotation
* @deprecated Use setItemRotation( double rotation ) instead
*/
virtual void setRotation( double r );
/** Sets the item rotation
* @param r item rotation in degrees
@ -694,25 +622,10 @@ class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRec
/** Draw background*/
virtual void drawBackground( QPainter* p );
/** Draws arrowhead
* @deprecated use QgsComposerUtils::drawArrowHead instead
*/
Q_DECL_DEPRECATED void drawArrowHead( QPainter* p, double x, double y, double angle, double arrowHeadWidth ) const;
/** Returns angle of the line from p1 to p2 (clockwise, starting at N)
* @deprecated will be removed in QGIS 3.0
*/
Q_DECL_DEPRECATED double angle( QPointF p1, QPointF p2 ) const;
/** Returns the current (zoom level dependent) tolerance to decide if mouse position is close enough to the
item border for resizing*/
double rectHandlerBorderTolerance() const;
/** Returns the size of the lock symbol depending on the composer zoom level and the item size
* @deprecated will be removed in QGIS 3.0
*/
Q_DECL_DEPRECATED double lockSymbolSize() const;
/** Returns the zoom factor of the graphics view.
* @return the factor or -1 in case of error (e.g. graphic view does not exist)
*/
@ -720,53 +633,6 @@ class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRec
//some utility functions
/** Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation.
* @deprecated will be removed in QGIS 3.0
*/
Q_DECL_DEPRECATED bool imageSizeConsideringRotation( double& width, double& height, double rotation ) const;
/** Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation
* @deprecated will be removed in QGIS 3.0
*/
Q_DECL_DEPRECATED bool imageSizeConsideringRotation( double& width, double& height ) const;
/** Calculates the largest scaled version of originalRect which fits within boundsRect, when it is rotated by
* a specified amount
* @param originalRect QRectF to be rotated and scaled
* @param boundsRect QRectF specifying the bounds which the rotated and scaled rectangle must fit within
* @param rotation the rotation in degrees to be applied to the rectangle
* @deprecated use QgsComposerUtils::largestRotatedRectWithinBounds instead
*/
Q_DECL_DEPRECATED QRectF largestRotatedRectWithinBounds( const QRectF& originalRect, const QRectF& boundsRect, double rotation ) const;
/** Calculates corner point after rotation and scaling
* @deprecated will be removed in QGIS 3.0
*/
Q_DECL_DEPRECATED bool cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height, double rotation ) const;
/** Calculates corner point after rotation and scaling
* @deprecated will be removed in QGIS 3.0
*/
Q_DECL_DEPRECATED bool cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height ) const;
/** Calculates width / height of the bounding box of a rotated rectangle
* @deprecated will be removed in QGIS 3.0
*/
Q_DECL_DEPRECATED void sizeChangedByRotation( double& width, double& height, double rotation );
/** Calculates width / height of the bounding box of a rotated rectangle
* @deprecated will be removed in QGIS 3.0
*/
Q_DECL_DEPRECATED void sizeChangedByRotation( double& width, double& height );
/** Rotates a point / vector
* @param angle rotation angle in degrees, counterclockwise
* @param x in/out: x coordinate before / after the rotation
* @param y in/out: y cooreinate before / after the rotation
* @deprecated use QgsComposerUtils:rotate instead
*/
Q_DECL_DEPRECATED void rotate( double angle, double& x, double& y ) const;
/** Return horizontal align snap item. Creates a new graphics line if 0*/
QGraphicsLineItem* hAlignSnapItem();
void deleteHAlignSnapItem();

View File

@ -74,12 +74,6 @@ class CORE_EXPORT QgsComposerLabel: public QgsComposerItem
*/
void setVAlign( Qt::AlignmentFlag a ) { mVAlignment = a; }
/** Returns the margin between the edge of the frame and the label contents
* @returns margin in mm
* @deprecated use marginX and marginY instead
*/
Q_DECL_DEPRECATED double margin() { return mMarginX; }
/** Returns the horizontal margin between the edge of the frame and the label
* contents.
* @returns horizontal margin in mm

View File

@ -650,24 +650,6 @@ void QgsComposerMap::moveContent( double dx, double dy )
}
}
void QgsComposerMap::zoomContent( int delta, double x, double y )
{
QSettings settings;
//read zoom mode
QgsComposerItem::ZoomMode zoomMode = static_cast< QgsComposerItem::ZoomMode >( settings.value( "/qgis/wheel_action", 2 ).toInt() );
if ( zoomMode == QgsComposerItem::NoZoom )
{
//do nothing
return;
}
double zoomFactor = settings.value( "/qgis/zoom_factor", 2.0 ).toDouble();
zoomFactor = delta > 0 ? zoomFactor : 1 / zoomFactor;
zoomContent( zoomFactor, QPointF( x, y ), zoomMode );
}
void QgsComposerMap::zoomContent( const double factor, const QPointF point, const ZoomMode mode )
{
if ( mDrawing )
@ -942,12 +924,6 @@ void QgsComposerMap::setOffset( double xOffset, double yOffset )
mYOffset = yOffset;
}
void QgsComposerMap::setRotation( double r )
{
//kept for api compatibility with QGIS 2.0
setMapRotation( r );
}
void QgsComposerMap::setMapRotation( double r )
{
mMapRotation = r;
@ -1672,308 +1648,6 @@ const QgsComposerMapGrid* QgsComposerMap::constFirstMapGrid() const
return const_cast<QgsComposerMap*>( this )->grid();
}
void QgsComposerMap::setGridStyle( GridStyle style )
{
QgsComposerMapGrid* g = grid();
g->setStyle( QgsComposerMapGrid::GridStyle( style ) );
}
QgsComposerMap::GridStyle QgsComposerMap::gridStyle() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return static_cast< QgsComposerMap::GridStyle >( g->style() );
}
void QgsComposerMap::setGridIntervalX( double interval )
{
QgsComposerMapGrid* g = grid();
g->setIntervalX( interval );
}
double QgsComposerMap::gridIntervalX() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->intervalX();
}
void QgsComposerMap::setGridIntervalY( double interval )
{
QgsComposerMapGrid* g = grid();
g->setIntervalY( interval );
}
double QgsComposerMap::gridIntervalY() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->intervalY();
}
void QgsComposerMap::setGridOffsetX( double offset )
{
QgsComposerMapGrid* g = grid();
g->setOffsetX( offset );
}
double QgsComposerMap::gridOffsetX() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->offsetX();
}
void QgsComposerMap::setGridOffsetY( double offset )
{
QgsComposerMapGrid* g = grid();
g->setOffsetY( offset );
}
double QgsComposerMap::gridOffsetY() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->offsetY();
}
void QgsComposerMap::setGridPenWidth( double w )
{
QgsComposerMapGrid* g = grid();
g->setGridLineWidth( w );
}
void QgsComposerMap::setGridPenColor( const QColor& c )
{
QgsComposerMapGrid* g = grid();
g->setGridLineColor( c );
}
void QgsComposerMap::setGridPen( const QPen& p )
{
QgsComposerMapGrid* g = grid();
g->setGridLineWidth( p.widthF() );
g->setGridLineColor( p.color() );
}
QPen QgsComposerMap::gridPen() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
QPen p;
if ( g->lineSymbol() )
{
QgsLineSymbol* line = g->lineSymbol()->clone();
if ( !line )
{
return p;
}
p.setWidthF( line->width() );
p.setColor( line->color() );
p.setCapStyle( Qt::FlatCap );
delete line;
}
return p;
}
void QgsComposerMap::setGridAnnotationFont( const QFont& f )
{
QgsComposerMapGrid* g = grid();
g->setAnnotationFont( f );
}
QFont QgsComposerMap::gridAnnotationFont() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->annotationFont();
}
void QgsComposerMap::setAnnotationFontColor( const QColor& c )
{
QgsComposerMapGrid* g = grid();
g->setAnnotationFontColor( c );
}
QColor QgsComposerMap::annotationFontColor() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->annotationFontColor();
}
void QgsComposerMap::setGridAnnotationPrecision( int p )
{
QgsComposerMapGrid* g = grid();
g->setAnnotationPrecision( p );
}
int QgsComposerMap::gridAnnotationPrecision() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->annotationPrecision();
}
void QgsComposerMap::setShowGridAnnotation( bool show )
{
QgsComposerMapGrid* g = grid();
g->setAnnotationEnabled( show );
}
bool QgsComposerMap::showGridAnnotation() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->annotationEnabled();
}
void QgsComposerMap::setGridAnnotationPosition( QgsComposerMap::GridAnnotationPosition p, QgsComposerMap::Border border )
{
QgsComposerMapGrid* g = grid();
if ( p != QgsComposerMap::Disabled )
{
g->setAnnotationPosition( static_cast< QgsComposerMapGrid::AnnotationPosition >( p ), static_cast< QgsComposerMapGrid::BorderSide >( border ) );
}
else
{
g->setAnnotationDisplay( QgsComposerMapGrid::HideAll, static_cast< QgsComposerMapGrid::BorderSide >( border ) );
}
}
QgsComposerMap::GridAnnotationPosition QgsComposerMap::gridAnnotationPosition( QgsComposerMap::Border border ) const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return static_cast< QgsComposerMap::GridAnnotationPosition >( g->annotationPosition( static_cast< QgsComposerMapGrid::BorderSide >( border ) ) );
}
void QgsComposerMap::setAnnotationFrameDistance( double d )
{
QgsComposerMapGrid* g = grid();
g->setAnnotationFrameDistance( d );
}
double QgsComposerMap::annotationFrameDistance() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->annotationFrameDistance();
}
void QgsComposerMap::setGridAnnotationDirection( GridAnnotationDirection d, QgsComposerMap::Border border )
{
QgsComposerMapGrid* g = grid();
//map grid direction to QgsComposerMapGrid direction (values are different)
QgsComposerMapGrid::AnnotationDirection gridDirection;
switch ( d )
{
case QgsComposerMap::Horizontal:
gridDirection = QgsComposerMapGrid::Horizontal;
break;
case QgsComposerMap::Vertical:
gridDirection = QgsComposerMapGrid::Vertical;
break;
case QgsComposerMap::BoundaryDirection:
gridDirection = QgsComposerMapGrid::BoundaryDirection;
break;
default:
gridDirection = QgsComposerMapGrid::Horizontal;
}
g->setAnnotationDirection( gridDirection, static_cast< QgsComposerMapGrid::BorderSide >( border ) );
}
QgsComposerMap::GridAnnotationDirection QgsComposerMap::gridAnnotationDirection( QgsComposerMap::Border border ) const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return static_cast< QgsComposerMap::GridAnnotationDirection >( g->annotationDirection( static_cast< QgsComposerMapGrid::BorderSide >( border ) ) );
}
void QgsComposerMap::setGridAnnotationFormat( QgsComposerMap::GridAnnotationFormat f )
{
QgsComposerMapGrid* g = grid();
g->setAnnotationFormat( static_cast< QgsComposerMapGrid::AnnotationFormat >( f ) );
}
QgsComposerMap::GridAnnotationFormat QgsComposerMap::gridAnnotationFormat() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return static_cast< QgsComposerMap::GridAnnotationFormat >( g->annotationFormat() );
}
void QgsComposerMap::setGridFrameStyle( GridFrameStyle style )
{
QgsComposerMapGrid* g = grid();
g->setFrameStyle( static_cast< QgsComposerMapGrid::FrameStyle >( style ) );
}
QgsComposerMap::GridFrameStyle QgsComposerMap::gridFrameStyle() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return static_cast< QgsComposerMap::GridFrameStyle >( g->frameStyle() );
}
void QgsComposerMap::setGridFrameWidth( double w )
{
QgsComposerMapGrid* g = grid();
g->setFrameWidth( w );
}
double QgsComposerMap::gridFrameWidth() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->frameWidth();
}
void QgsComposerMap::setGridFramePenSize( double w )
{
QgsComposerMapGrid* g = grid();
g->setFramePenSize( w );
}
double QgsComposerMap::gridFramePenSize() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->framePenSize();
}
void QgsComposerMap::setGridFramePenColor( const QColor& c )
{
QgsComposerMapGrid* g = grid();
g->setFramePenColor( c );
}
QColor QgsComposerMap::gridFramePenColor() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->framePenColor();
}
void QgsComposerMap::setGridFrameFillColor1( const QColor& c )
{
QgsComposerMapGrid* g = grid();
g->setFrameFillColor1( c );
}
QColor QgsComposerMap::gridFrameFillColor1() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->frameFillColor1();
}
void QgsComposerMap::setGridFrameFillColor2( const QColor& c )
{
QgsComposerMapGrid* g = grid();
g->setFrameFillColor2( c );
}
QColor QgsComposerMap::gridFrameFillColor2() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->frameFillColor2();
}
void QgsComposerMap::setCrossLength( double l )
{
QgsComposerMapGrid* g = grid();
g->setCrossLength( l );
}
double QgsComposerMap::crossLength()
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->crossLength();
}
QgsComposerMapOverview *QgsComposerMap::overview()
{
if ( mOverviewStack->size() < 1 )
@ -1989,18 +1663,6 @@ const QgsComposerMapOverview *QgsComposerMap::constFirstMapOverview() const
return const_cast<QgsComposerMap*>( this )->overview();
}
void QgsComposerMap::setGridBlendMode( QPainter::CompositionMode blendMode )
{
QgsComposerMapGrid* g = grid();
g->setBlendMode( blendMode );
}
QPainter::CompositionMode QgsComposerMap::gridBlendMode() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->blendMode();
}
QRectF QgsComposerMap::boundingRect() const
{
return mCurrentRectangle;
@ -2182,18 +1844,6 @@ double QgsComposerMap::mapUnitsToMM() const
return rect().width() / extentWidth;
}
void QgsComposerMap::setOverviewFrameMap( int mapId )
{
QgsComposerMapOverview* o = overview();
o->setFrameMap( mapId );
}
int QgsComposerMap::overviewFrameMapId() const
{
const QgsComposerMapOverview* o = constFirstMapOverview();
return o->frameMapId();
}
void QgsComposerMap::refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property, const QgsExpressionContext* context )
{
QgsExpressionContext scopedContext = createExpressionContext();
@ -2221,79 +1871,6 @@ void QgsComposerMap::refreshDataDefinedProperty( const QgsComposerObject::DataDe
QgsComposerItem::refreshDataDefinedProperty( property, evalContext );
}
void QgsComposerMap::setOverviewFrameMapSymbol( QgsFillSymbol* symbol )
{
QgsComposerMapOverview* o = overview();
o->setFrameSymbol( symbol );
}
QgsFillSymbol *QgsComposerMap::overviewFrameMapSymbol()
{
QgsComposerMapOverview* o = overview();
return o->frameSymbol();
}
QPainter::CompositionMode QgsComposerMap::overviewBlendMode() const
{
const QgsComposerMapOverview* o = constFirstMapOverview();
return o->blendMode();
}
void QgsComposerMap::setOverviewBlendMode( QPainter::CompositionMode blendMode )
{
QgsComposerMapOverview* o = overview();
o->setBlendMode( blendMode );
}
bool QgsComposerMap::overviewInverted() const
{
const QgsComposerMapOverview* o = constFirstMapOverview();
return o->inverted();
}
void QgsComposerMap::setOverviewInverted( bool inverted )
{
QgsComposerMapOverview* o = overview();
o->setInverted( inverted );
}
bool QgsComposerMap::overviewCentered() const
{
const QgsComposerMapOverview* o = constFirstMapOverview();
return o->centered();
}
void QgsComposerMap::setOverviewCentered( bool centered )
{
QgsComposerMapOverview* o = overview();
o->setCentered( centered );
//overviewExtentChanged();
}
void QgsComposerMap::setGridLineSymbol( QgsLineSymbol* symbol )
{
QgsComposerMapGrid* g = grid();
g->setLineSymbol( symbol );
}
QgsLineSymbol* QgsComposerMap::gridLineSymbol()
{
QgsComposerMapGrid* g = grid();
return g->lineSymbol();
}
void QgsComposerMap::setGridEnabled( bool enabled )
{
QgsComposerMapGrid* g = grid();
g->setEnabled( enabled );
}
bool QgsComposerMap::gridEnabled() const
{
const QgsComposerMapGrid* g = constFirstMapGrid();
return g->enabled();
}
void QgsComposerMap::transformShift( double& xShift, double& yShift ) const
{
double mmToMapUnits = 1.0 / mapUnitsToMM();
@ -2327,11 +1904,6 @@ QPointF QgsComposerMap::mapToItemCoords( QPointF mapCoords ) const
return QPointF( xItem, yItem );
}
void QgsComposerMap::connectMapOverviewSignals()
{
}
void QgsComposerMap::drawCanvasItems( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle )
{
if ( !mMapCanvas || !mDrawCanvasItems )
@ -2445,30 +2017,6 @@ void QgsComposerMap::assignFreeId()
updateToolTip();
}
bool QgsComposerMap::imageSizeConsideringRotation( double& width, double& height ) const
{
//kept for api compatibility with QGIS 2.0 - use mMapRotation
Q_NOWARN_DEPRECATED_PUSH
return QgsComposerItem::imageSizeConsideringRotation( width, height, mEvaluatedMapRotation );
Q_NOWARN_DEPRECATED_POP
}
bool QgsComposerMap::cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height ) const
{
//kept for api compatibility with QGIS 2.0 - use mMapRotation
Q_NOWARN_DEPRECATED_PUSH
return QgsComposerItem::cornerPointOnRotatedAndScaledRect( x, y, width, height, mEvaluatedMapRotation );
Q_NOWARN_DEPRECATED_POP
}
void QgsComposerMap::sizeChangedByRotation( double& width, double& height )
{
//kept for api compatibility with QGIS 2.0 - use mMapRotation
Q_NOWARN_DEPRECATED_PUSH
return QgsComposerItem::sizeChangedByRotation( width, height, mEvaluatedMapRotation );
Q_NOWARN_DEPRECATED_POP
}
void QgsComposerMap::setAtlasDriven( bool enabled )
{
mAtlasDriven = enabled;
@ -2481,17 +2029,6 @@ void QgsComposerMap::setAtlasDriven( bool enabled )
}
}
bool QgsComposerMap::atlasFixedScale() const
{
return mAtlasScalingMode == Fixed;
}
void QgsComposerMap::setAtlasFixedScale( bool fixed )
{
// implicit : if set to false => auto scaling
mAtlasScalingMode = fixed ? Fixed : Auto;
}
double QgsComposerMap::atlasMargin( const QgsComposerObject::PropertyValueType valueType )
{
if ( valueType == QgsComposerObject::EvaluatedValue )

View File

@ -43,7 +43,6 @@ class QgsAnnotation;
* \brief Object representing map window.
*/
Q_NOWARN_DEPRECATED_PUSH
class CORE_EXPORT QgsComposerMap : public QgsComposerItem
{
Q_OBJECT
@ -66,62 +65,6 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
Rectangle // Display only rectangle
};
//grid enums are moved to QgsComposerMapGrid
//TODO - remove for QGIS 3.0
enum GridStyle
{
Solid = 0, //solid lines
Cross, //only draw line crossings
Markers,
FrameAnnotationsOnly
};
enum GridAnnotationPosition
{
InsideMapFrame = 0,
OutsideMapFrame,
Disabled
};
enum GridAnnotationDirection
{
Horizontal = 0,
Vertical,
HorizontalAndVertical,
BoundaryDirection
};
enum GridAnnotationFormat
{
Decimal = 0,
DegreeMinute,
DegreeMinuteSecond,
DecimalWithSuffix,
DegreeMinuteNoSuffix,
DegreeMinutePadded,
DegreeMinuteSecondNoSuffix,
DegreeMinuteSecondPadded
};
enum GridFrameStyle
{
NoGridFrame = 0,
Zebra, // black/white pattern
InteriorTicks,
ExteriorTicks,
InteriorExteriorTicks,
LineBorder
};
/** Enum for different frame borders*/
enum Border
{
Left,
Right,
Bottom,
Top
};
/** Scaling modes used for the serial rendering (atlas)
*/
enum AtlasScalingMode
@ -171,14 +114,6 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
*/
void moveContent( double dx, double dy ) override;
/** Zoom content of map
* @param delta value from wheel event that describes direction (positive /negative number)
* @param x x-position of mouse cursor (in item coordinates)
* @param y y-position of mouse cursor (in item coordinates)
* @deprecated use zoomContent( double, QPointF, ZoomMode ) instead
*/
Q_DECL_DEPRECATED void zoomContent( int delta, double x, double y ) override;
/** Zoom content of item. Does nothing per default (but implemented in composer map)
* @param factor zoom factor, where > 1 results in a zoom in and < 1 results in a zoom out
* @param point item point for zoom center
@ -219,11 +154,6 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
*/
void setNewAtlasFeatureExtent( const QgsRectangle& extent );
/** Called when atlas preview is toggled, to force map item to update its extent and redraw
* @deprecated no longer required
*/
Q_DECL_DEPRECATED void toggleAtlasPreview() {}
/** Returns a pointer to the current map extent, which is either the original user specified
* extent or the temporary atlas-driven feature extent depending on the current atlas state
* of the composition. Both a const and non-const version are included.
@ -309,263 +239,6 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
*/
bool readXml( const QDomElement& itemElem, const QDomDocument& doc ) override;
/** Enables a coordinate grid that is shown on top of this composermap.
* @deprecated use grid()->setEnabled() or grids() instead
*/
Q_DECL_DEPRECATED void setGridEnabled( bool enabled );
/**
* @deprecated use grid()->enabled() or grids() instead
*/
Q_DECL_DEPRECATED bool gridEnabled() const;
/** Sets coordinate grid style to solid or cross
* @deprecated use grid()->setStyle() or grids() instead
*/
Q_DECL_DEPRECATED void setGridStyle( GridStyle style );
/**
* @deprecated use grid()->style() or grids() instead
*/
Q_DECL_DEPRECATED GridStyle gridStyle() const;
/** Sets coordinate interval in x-direction for composergrid.
* @deprecated use grid()->setIntervalX() or grids() instead
*/
Q_DECL_DEPRECATED void setGridIntervalX( double interval );
/**
* @deprecated use grid()->intervalX() or grids() instead
*/
Q_DECL_DEPRECATED double gridIntervalX() const;
/** Sets coordinate interval in y-direction for composergrid.
* @deprecated use grid()->setIntervalY() or grids() instead
*/
Q_DECL_DEPRECATED void setGridIntervalY( double interval );
/**
* @deprecated use grid()->intervalY() or grids() instead
*/
Q_DECL_DEPRECATED double gridIntervalY() const;
/** Sets x-coordinate offset for composer grid
* @deprecated use grid()->setOffsetX() or grids() instead
*/
Q_DECL_DEPRECATED void setGridOffsetX( double offset );
/**
* @deprecated use grid()->offsetX() or grids() instead
*/
Q_DECL_DEPRECATED double gridOffsetX() const;
/** Sets y-coordinate offset for composer grid
* @deprecated use grid()->setOffsetY() or grids() instead
*/
Q_DECL_DEPRECATED void setGridOffsetY( double offset );
/**
* @deprecated use grid()->offsetY() or grids() instead
*/
Q_DECL_DEPRECATED double gridOffsetY() const;
/** Sets the pen to draw composer grid
* @deprecated use grid()->setPenWidth(), grid()->setPenColor() or grids() instead
*/
Q_DECL_DEPRECATED void setGridPen( const QPen& p );
/**
* @deprecated use grid()->pen() or grids() instead
*/
Q_DECL_DEPRECATED QPen gridPen() const;
/** Sets width of grid pen
* @deprecated use grid()->setPenWidth() or grids() instead
*/
Q_DECL_DEPRECATED void setGridPenWidth( double w );
/** Sets the color of the grid pen
* @deprecated use grid()->setPenColor() or grids() instead
*/
Q_DECL_DEPRECATED void setGridPenColor( const QColor& c );
/** Sets font for grid annotations
* @deprecated use grid()->setAnnotationFont() or grids() instead
*/
Q_DECL_DEPRECATED void setGridAnnotationFont( const QFont& f );
/**
* @deprecated use grid()->annotationFont() or grids() instead
*/
Q_DECL_DEPRECATED QFont gridAnnotationFont() const;
/** Sets font color for grid annotations
* @deprecated use grid()->setAnnotationFontColor() or grids() instead
*/
Q_DECL_DEPRECATED void setAnnotationFontColor( const QColor& c );
/** Get font color for grid annotations
* @deprecated use grid()->annotationFontColor() or grids() instead
*/
Q_DECL_DEPRECATED QColor annotationFontColor() const;
/** Sets coordinate precision for grid annotations
* @deprecated use grid()->setAnnotationPrecision or grids() instead
*/
Q_DECL_DEPRECATED void setGridAnnotationPrecision( int p );
/**
* @deprecated use grid()->annotationPrecision() or grids() instead
*/
Q_DECL_DEPRECATED int gridAnnotationPrecision() const;
/** Sets flag if grid annotation should be shown
* @deprecated use grid()->setAnnotationEnabled() or grids() instead
*/
Q_DECL_DEPRECATED void setShowGridAnnotation( bool show );
/**
* @deprecated use grid()->annotationEnabled() or grids() instead
*/
Q_DECL_DEPRECATED bool showGridAnnotation() const;
/**
* @deprecated use grid()->setAnnotationPosition() or grids() instead
*/
Q_DECL_DEPRECATED void setGridAnnotationPosition( GridAnnotationPosition p, QgsComposerMap::Border border );
/**
* @deprecated use grid()->annotationPosition() or grids() instead
*/
Q_DECL_DEPRECATED GridAnnotationPosition gridAnnotationPosition( QgsComposerMap::Border border ) const;
/** Sets distance between map frame and annotations
* @deprecated use grid()->setAnnotationFrameDistance() or grids() instead
*/
Q_DECL_DEPRECATED void setAnnotationFrameDistance( double d );
/**
* @deprecated use grid()->annotationFrameDistance() or grids() instead
*/
Q_DECL_DEPRECATED double annotationFrameDistance() const;
/**
* @deprecated use grid()->setAnnotationDirection() or grids() instead
*/
Q_DECL_DEPRECATED void setGridAnnotationDirection( GridAnnotationDirection d, QgsComposerMap::Border border );
/**
* @deprecated use grid()->annotationDirection() or grids() instead
*/
Q_DECL_DEPRECATED GridAnnotationDirection gridAnnotationDirection( QgsComposerMap::Border border ) const;
/**
* @deprecated use grid()->setAnnotationFormat() or grids() instead
*/
Q_DECL_DEPRECATED void setGridAnnotationFormat( GridAnnotationFormat f );
/**
* @deprecated use grid()->annotationFormat() or grids() instead
*/
Q_DECL_DEPRECATED GridAnnotationFormat gridAnnotationFormat() const;
/** Set grid frame style (NoGridFrame or Zebra)
* @deprecated use grid()->setFrameStyle() or grids() instead
*/
Q_DECL_DEPRECATED void setGridFrameStyle( GridFrameStyle style );
/**
* @deprecated use grid()->frameStyle() or grids() instead
*/
Q_DECL_DEPRECATED GridFrameStyle gridFrameStyle() const;
/** Set grid frame width
* @deprecated use grid()->setFrameWidth() or grids() instead
*/
Q_DECL_DEPRECATED void setGridFrameWidth( double w );
/**
* @deprecated use grid()->frameWidth() or grids() instead
*/
Q_DECL_DEPRECATED double gridFrameWidth() const;
/** Set grid frame pen thickness
* @note: this function was added in version 2.1
* @deprecated use grid()->setFramePenSize() or grids() instead
*/
Q_DECL_DEPRECATED void setGridFramePenSize( double w );
/**
* @deprecated use grid()->framePenSize() or grids() instead
*/
Q_DECL_DEPRECATED double gridFramePenSize() const;
/** Sets pen color for grid frame
* @note: this function was added in version 2.1
* @deprecated use grid()->setFramePenColor() or grids() instead
*/
Q_DECL_DEPRECATED void setGridFramePenColor( const QColor& c );
/** Get pen color for grid frame
* @note: this function was added in version 2.1
* @deprecated use grid()->framePenColor() or grids() instead
*/
Q_DECL_DEPRECATED QColor gridFramePenColor() const;
/** Sets first fill color for grid zebra frame
* @note: this function was added in version 2.1
* @deprecated use grid()->setFrameFillColor1() or grids() instead
*/
Q_DECL_DEPRECATED void setGridFrameFillColor1( const QColor& c );
/** Get first fill color for grid zebra frame
* @note: this function was added in version 2.1
* @deprecated use grid()->frameFillColor1() or grids() instead
*/
Q_DECL_DEPRECATED QColor gridFrameFillColor1() const;
/** Sets second fill color for grid zebra frame
* @note: this function was added in version 2.1
* @deprecated use grid()->setFrameFillColor2() or grids() instead
*/
Q_DECL_DEPRECATED void setGridFrameFillColor2( const QColor& c );
/** Get second fill color for grid zebra frame
* @note: this function was added in version 2.1
* @deprecated use grid()->frameFillColor2() or grids() instead
*/
Q_DECL_DEPRECATED QColor gridFrameFillColor2() const;
/** Sets length of the cross segments (if grid style is cross)
* @deprecated use grid()->setCrossLength() or grids() instead
*/
Q_DECL_DEPRECATED void setCrossLength( double l );
/**
* @deprecated use grid()->crossLength() or grids() instead
*/
Q_DECL_DEPRECATED double crossLength();
/**
* @deprecated use grid()->setLineSymbol() or grids() instead
*/
Q_DECL_DEPRECATED void setGridLineSymbol( QgsLineSymbol* symbol );
/**
* @deprecated use grid()->lineSymbol() or grids() instead
*/
Q_DECL_DEPRECATED QgsLineSymbol* gridLineSymbol();
/** Returns the grid's blending mode
* @deprecated use grid()->blendMode() or grids() instead
*/
Q_DECL_DEPRECATED QPainter::CompositionMode gridBlendMode() const;
/** Sets the grid's blending mode
* @deprecated use grid()->setBlendMode() or grids() instead
*/
Q_DECL_DEPRECATED void setGridBlendMode( QPainter::CompositionMode blendMode );
/** Returns the map item's grid stack, which is used to control how grids
* are drawn over the map's contents.
* @returns pointer to grid stack
@ -602,17 +275,6 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
/* reimplement setFrameOutlineWidth, so that updateBoundingRect() is called after setting the frame width */
virtual void setFrameOutlineWidth( const double outlineWidth ) override;
/** Sets rotation for the map - this does not affect the composer item shape, only the
way the map is drawn within the item
* @deprecated Use setMapRotation( double rotation ) instead
*/
Q_DECL_DEPRECATED void setRotation( double r ) override;
/** Returns the rotation used for drawing the map within the composer item
* @deprecated Use mapRotation() instead
*/
Q_DECL_DEPRECATED double rotation() const { return mMapRotation;}
/** Sets rotation for the map - this does not affect the composer item shape, only the
* way the map is drawn within the item
* @note this function was added in version 2.1
@ -638,76 +300,10 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
/** Returns the conversion factor map units -> mm*/
double mapUnitsToMM() const;
/** Sets overview frame map. -1 disables the overview frame
* @deprecated use overview()->setFrameMap() or overviews() instead
*/
Q_DECL_DEPRECATED void setOverviewFrameMap( int mapId );
/** Returns id of overview frame (or -1 if no overfiew frame)
* @deprecated use overview()->frameMapId() or overviews() instead
*/
Q_DECL_DEPRECATED int overviewFrameMapId() const;
/**
* @deprecated use overview()->setFrameSymbol() or overviews() instead
*/
Q_DECL_DEPRECATED void setOverviewFrameMapSymbol( QgsFillSymbol* symbol );
/**
* @deprecated use overview()->frameSymbol() or overviews() instead
*/
Q_DECL_DEPRECATED QgsFillSymbol* overviewFrameMapSymbol();
/** Returns the overview's blending mode
* @deprecated use overview()->blendMode() or overviews() instead
*/
Q_DECL_DEPRECATED QPainter::CompositionMode overviewBlendMode() const;
/** Sets the overview's blending mode
* @deprecated use overview()->setBlendMode() or overviews() instead
*/
Q_DECL_DEPRECATED void setOverviewBlendMode( QPainter::CompositionMode blendMode );
/** Returns true if the overview frame is inverted
* @deprecated use overview()->inverted() or overviews() instead
*/
Q_DECL_DEPRECATED bool overviewInverted() const;
/** Sets the overview's inversion mode
* @deprecated use overview()->setInverted() or overviews() instead
*/
Q_DECL_DEPRECATED void setOverviewInverted( bool inverted );
/** Returns true if the extent is forced to center on the overview
* @deprecated use overview()->centered() or overviews() instead
*/
Q_DECL_DEPRECATED bool overviewCentered() const;
/** Set the overview's centering mode
* @deprecated use overview()->setCentered() or overviews() instead
*/
Q_DECL_DEPRECATED void setOverviewCentered( bool centered );
/** Sets mId to a number not yet used in the composition. mId is kept if it is not in use.
Usually, this function is called before adding the composer map to the composition*/
void assignFreeId();
/** Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation
* @deprecated Use bool QgsComposerItem::imageSizeConsideringRotation( double& width, double& height, double rotation )
* instead
*/
Q_DECL_DEPRECATED bool imageSizeConsideringRotation( double& width, double& height ) const;
/** Calculates corner point after rotation and scaling
* @deprecated Use QgsComposerItem::cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height, double rotation )
* instead
*/
Q_DECL_DEPRECATED bool cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height ) const;
/** Calculates width / height of the bounding box of a rotated rectangle
* @deprecated Use QgsComposerItem::sizeChangedByRotation( double& width, double& height, double rotation )
* instead
*/
Q_DECL_DEPRECATED void sizeChangedByRotation( double& width, double& height );
/** Returns whether the map extent is set to follow the current atlas feature.
* @returns true if map will follow the current atlas feature.
* @see setAtlasDriven
@ -722,16 +318,6 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
*/
void setAtlasDriven( bool enabled );
/** Returns true if the map uses a fixed scale when in atlas mode
* @deprecated since 2.4 Use atlasScalingMode() instead
*/
Q_DECL_DEPRECATED bool atlasFixedScale() const;
/** Set to true if the map should use a fixed scale when in atlas mode
* @deprecated since 2.4 Use setAtlasScalingMode() instead
*/
Q_DECL_DEPRECATED void setAtlasFixedScale( bool fixed );
/** Returns the current atlas scaling mode. This controls how the map's extents
* are calculated for the current atlas feature when an atlas composition
* is enabled.
@ -801,9 +387,6 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
/** Transforms map coordinates to item coordinates (considering rotation and move offset)*/
QPointF mapToItemCoords( QPointF mapCoords ) const;
//! @deprecated will be removed in QGIS 3.0
Q_DECL_DEPRECATED void connectMapOverviewSignals();
/** Calculates the extent to request and the yShift of the top-left point in case of rotation.
* @note added in 2.6 */
void requestedExtent( QgsRectangle& extent ) const;
@ -838,9 +421,6 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
/** Updates the bounding rect of this item. Call this function before doing any changes related to annotation out of the map rectangle */
void updateBoundingRect();
/** @deprecated use QgsComposerMapOverview::overviewExtentChanged instead*/
void overviewExtentChanged() {}
virtual void refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property = QgsComposerObject::AllProperties, const QgsExpressionContext* context = nullptr ) override;
protected slots:
@ -994,7 +574,6 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
friend class QgsComposerMapOverview; //to access mXOffset, mYOffset
friend class TestQgsComposerMap;
};
Q_NOWARN_DEPRECATED_POP
#endif

View File

@ -419,27 +419,6 @@ bool QgsComposerMapGrid::readXml( const QDomElement& itemElem, const QDomDocumen
mRightGridAnnotationDisplay = QgsComposerMapGrid::DisplayMode( itemElem.attribute( "rightAnnotationDisplay", "0" ).toInt() );
mTopGridAnnotationDisplay = QgsComposerMapGrid::DisplayMode( itemElem.attribute( "topAnnotationDisplay", "0" ).toInt() );
mBottomGridAnnotationDisplay = QgsComposerMapGrid::DisplayMode( itemElem.attribute( "bottomAnnotationDisplay", "0" ).toInt() );
//upgrade pre-2.7 projects
if ( mLeftGridAnnotationPosition == QgsComposerMapGrid::Disabled )
{
mLeftGridAnnotationDisplay = QgsComposerMapGrid::HideAll;
mLeftGridAnnotationPosition = QgsComposerMapGrid::OutsideMapFrame;
}
if ( mRightGridAnnotationPosition == QgsComposerMapGrid::Disabled )
{
mRightGridAnnotationDisplay = QgsComposerMapGrid::HideAll;
mRightGridAnnotationPosition = QgsComposerMapGrid::OutsideMapFrame;
}
if ( mTopGridAnnotationPosition == QgsComposerMapGrid::Disabled )
{
mTopGridAnnotationDisplay = QgsComposerMapGrid::HideAll;
mTopGridAnnotationPosition = QgsComposerMapGrid::OutsideMapFrame;
}
if ( mBottomGridAnnotationPosition == QgsComposerMapGrid::Disabled )
{
mBottomGridAnnotationDisplay = QgsComposerMapGrid::HideAll;
mBottomGridAnnotationPosition = QgsComposerMapGrid::OutsideMapFrame;
}
mLeftGridAnnotationDirection = QgsComposerMapGrid::AnnotationDirection( itemElem.attribute( "leftAnnotationDirection", "0" ).toInt() );
mRightGridAnnotationDirection = QgsComposerMapGrid::AnnotationDirection( itemElem.attribute( "rightAnnotationDirection", "0" ).toInt() );

View File

@ -200,10 +200,8 @@ class CORE_EXPORT QgsComposerMapGrid : public QgsComposerMapItem
*/
enum AnnotationPosition
{
InsideMapFrame = 0,
InsideMapFrame = 0, /*!< draw annotations inside the map frame */
OutsideMapFrame, /*!< draw annotations outside the map frame */
Disabled /*!< disable annotation
* @deprecated in QGIS 2.7, use QgsComposerMapGrid::HideAll instead */
};
/** Direction of grid annotations

View File

@ -41,22 +41,6 @@ QgsComposerMultiFrame::~QgsComposerMultiFrame()
deleteFrames();
}
void QgsComposerMultiFrame::render( QPainter *p, const QRectF &renderExtent )
{
//base implementation does nothing
Q_UNUSED( p );
Q_UNUSED( renderExtent );
}
void QgsComposerMultiFrame::render( QPainter *painter, const QRectF &renderExtent, const int frameIndex )
{
Q_UNUSED( frameIndex );
//base implementation ignores frameIndex
Q_NOWARN_DEPRECATED_PUSH
render( painter, renderExtent );
Q_NOWARN_DEPRECATED_POP
}
void QgsComposerMultiFrame::setResizeMode( ResizeMode mode )
{
if ( mode != mResizeMode )

View File

@ -90,20 +90,13 @@ class CORE_EXPORT QgsComposerMultiFrame: public QgsComposerObject
*/
virtual QSizeF minFrameSize( const int frameIndex = -1 ) const { Q_UNUSED( frameIndex ); return QSizeF( 0, 0 ); }
/** Renders a portion of the multiframe's content into a painter.
* @param p destination painter
* @param renderExtent visible extent of content to render into the painter.
* @deprecated use render( QPainter* painter, const QRectF& renderExtent, const int frameIndex ) instead
*/
Q_DECL_DEPRECATED virtual void render( QPainter* p, const QRectF& renderExtent );
/** Renders a portion of the multiframe's content into a painter.
* @param painter destination painter
* @param renderExtent visible extent of content to render into the painter.
* @param frameIndex frame number for content
* @note added in version 2.5
*/
virtual void render( QPainter* painter, const QRectF& renderExtent, const int frameIndex );
virtual void render( QPainter* painter, const QRectF& renderExtent, const int frameIndex ) = 0;
/** Adds a frame to the multiframe.
* @param frame frame to add

View File

@ -83,10 +83,6 @@ void QgsComposerPicture::init()
//data defined strings
mDataDefinedNames.insert( QgsComposerObject::PictureSource, QString( "dataDefinedSource" ) );
//insert PictureSource data defined property (only required due to deprecated API elements,
//remove after 3.0
setDataDefinedProperty( QgsComposerObject::PictureSource, false, true, QString(), QString() );
//connect some signals
//connect to atlas feature changing
@ -301,11 +297,6 @@ QRect QgsComposerPicture::clippedImageRect( double &boundRectWidthMM, double &bo
return QRect( leftClip, topClip, boundRectWidthPixels, boundRectHeightPixels );
}
void QgsComposerPicture::setPictureFile( const QString& path )
{
setPicturePath( path );
}
void QgsComposerPicture::refreshPicture( const QgsExpressionContext *context )
{
QgsExpressionContext scopedContext = createExpressionContext();
@ -316,7 +307,8 @@ void QgsComposerPicture::refreshPicture( const QgsExpressionContext *context )
//data defined source set?
mHasExpressionError = false;
QVariant exprVal;
if ( dataDefinedProperty( QgsComposerObject::PictureSource )->isActive() )
if ( dataDefinedProperty( QgsComposerObject::PictureSource ) &&
dataDefinedProperty( QgsComposerObject::PictureSource )->isActive() )
{
if ( dataDefinedEvaluate( QgsComposerObject::PictureSource, exprVal, *evalContext ) )
{
@ -596,12 +588,6 @@ void QgsComposerPicture::setSceneRect( const QRectF& rectangle )
}
}
void QgsComposerPicture::setRotation( double r )
{
//kept for compatibility for QGIS2.0 api
setPictureRotation( r );
}
void QgsComposerPicture::setPictureRotation( double r )
{
double oldRotation = mPictureRotation;
@ -699,23 +685,6 @@ void QgsComposerPicture::refreshDataDefinedProperty( const QgsComposerObject::Da
QgsComposerItem::refreshDataDefinedProperty( property, evalContext );
}
void QgsComposerPicture::setUsePictureExpression( bool useExpression )
{
dataDefinedProperty( QgsComposerObject::PictureSource )->setActive( useExpression );
refreshPicture();
}
void QgsComposerPicture::setPictureExpression( const QString& expression )
{
dataDefinedProperty( QgsComposerObject::PictureSource )->setExpressionString( expression );
refreshPicture();
}
QString QgsComposerPicture::pictureFile() const
{
return picturePath();
}
void QgsComposerPicture::setPicturePath( const QString &path )
{
mSourcePath = path;
@ -876,37 +845,3 @@ void QgsComposerPicture::setSvgBorderWidth( double width )
mSvgBorderWidth = width;
refreshPicture();
}
bool QgsComposerPicture::usePictureExpression() const
{
return dataDefinedProperty( QgsComposerObject::PictureSource )->isActive();
}
QString QgsComposerPicture::pictureExpression() const
{
return dataDefinedProperty( QgsComposerObject::PictureSource )->expressionString();
}
bool QgsComposerPicture::imageSizeConsideringRotation( double& width, double& height ) const
{
//kept for api compatibility with QGIS 2.0 - use mPictureRotation
Q_NOWARN_DEPRECATED_PUSH
return QgsComposerItem::imageSizeConsideringRotation( width, height, mPictureRotation );
Q_NOWARN_DEPRECATED_POP
}
bool QgsComposerPicture::cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height ) const
{
//kept for api compatibility with QGIS 2.0 - use mPictureRotation
Q_NOWARN_DEPRECATED_PUSH
return QgsComposerItem::cornerPointOnRotatedAndScaledRect( x, y, width, height, mPictureRotation );
Q_NOWARN_DEPRECATED_POP
}
void QgsComposerPicture::sizeChangedByRotation( double& width, double& height )
{
//kept for api compatibility with QGIS 2.0 - use mPictureRotation
Q_NOWARN_DEPRECATED_PUSH
return QgsComposerItem::sizeChangedByRotation( width, height, mPictureRotation );
Q_NOWARN_DEPRECATED_POP
}

View File

@ -62,24 +62,6 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
/** Reimplementation of QCanvasItem::paint*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ) override;
/** Sets the source file of the image (may be svg or a raster format). Data defined
* picture source may override this value.
* @param path full path to the source image
* @see usePictureExpression
* @see pictureFile
* @deprecated use setPicturePath instead
*/
Q_DECL_DEPRECATED void setPictureFile( const QString& path );
/** Returns the path of the source image file. Data defined picture source may override
* this value.
* @returns path to the source image
* @see usePictureExpression
* @see setPictureFile
* @deprecated use picturePath instead
*/
Q_DECL_DEPRECATED QString pictureFile() const;
/** Sets the source path of the image (may be svg or a raster format). Data defined
* picture source may override this value. The path can either be a local path
* or a remote (http) path.
@ -116,11 +98,6 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
*/
bool readXml( const QDomElement& itemElem, const QDomDocument& doc ) override;
/** Returns the rotation used for drawing the picture within the composer item
* @deprecated Use pictureRotation() instead
*/
Q_DECL_DEPRECATED double rotation() const { return mPictureRotation; }
/** Returns the rotation used for drawing the picture within the item's frame
* @returns picture rotation in degrees
* @note added in 2.2
@ -230,45 +207,6 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
*/
void setSvgBorderWidth( double width );
/** Returns whether the picture item is using an expression for the image source.
* @returns true if the picture is using an expression for the source, false if
* it is using a single static file path for the source.
* @note added in 2.3
* @see setUsePictureExpression
* @see pictureFile
* @see pictureExpression
* @deprecated use QgsComposerObject::dataDefinedProperty( QgsComposerObject::PictureSource ) instead
*/
Q_DECL_DEPRECATED bool usePictureExpression() const;
/** Returns the expression the item is using for the picture source. This is only
* used if usePictureExpression() is true.
* @returns expression for the picture item's image path
* @note added in 2.3
* @see setPictureExpression
* @see usePictureExpression
* @deprecated use QgsComposerObject::dataDefinedProperty( QgsComposerObject::PictureSource ) instead
*/
Q_DECL_DEPRECATED QString pictureExpression() const;
/** Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation
* @deprecated Use bool QgsComposerItem::imageSizeConsideringRotation( double& width, double& height, double rotation )
* instead
*/
Q_DECL_DEPRECATED bool imageSizeConsideringRotation( double& width, double& height ) const;
/** Calculates corner point after rotation and scaling
* @deprecated Use QgsComposerItem::cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height, double rotation )
* instead
*/
Q_DECL_DEPRECATED bool cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height ) const;
/** Calculates width / height of the bounding box of a rotated rectangle
* @deprecated Use QgsComposerItem::sizeChangedByRotation( double& width, double& height, double rotation )
* instead
*/
Q_DECL_DEPRECATED void sizeChangedByRotation( double& width, double& height );
/** Returns the current picture mode (image format).
* @returns picture mode
* @note added in 2.3
@ -276,11 +214,6 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
Mode mode() const { return mMode; }
public slots:
/** Sets the picture rotation within the item bounds. This does not affect
* the item rectangle, only the way the picture is drawn within the item.
* @deprecated Use setPictureRotation( double rotation ) instead
*/
virtual void setRotation( double r ) override;
/** Sets the picture rotation within the item bounds. This does not affect
* the item's frame, only the way the picture is drawn within the item.
@ -297,27 +230,6 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
*/
virtual void setResizeMode( ResizeMode mode );
/** Sets whether the picture should use an expression based image source path
* @param useExpression set to true to use an expression based image source,
* set to false to use a single image source path
* @note added in 2.3
* @see usePictureExpression
* @see setPictureFile
* @see setPictureExpression
* @deprecated use QgsComposerObject::dataDefinedProperty( QgsComposerObject::PictureSource ) instead
*/
virtual void setUsePictureExpression( bool useExpression );
/** Sets an expression to use for the picture source. This expression is only
* used if usePictureExpression() is true.
* @param expression to use for picture path
* @note added in 2.3
* @see setUsePictureExpression
* @see pictureExpression
* @deprecated use QgsComposerObject::dataDefinedProperty( QgsComposerObject::PictureSource ) instead
*/
virtual void setPictureExpression( const QString& expression );
/** Recalculates the source image (if using an expression for picture's source)
* and reloads and redraws the picture.
* @param context expression context for evaluating data defined picture sources
@ -325,13 +237,6 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
*/
void refreshPicture( const QgsExpressionContext* context = nullptr );
/** Prepares the picture's source expression after it is altered or the compositions
* atlas coverage layer changes.
* @note added in 2.3
* @deprecated no longer required
*/
Q_DECL_DEPRECATED void updatePictureExpression() {}
/** Forces a recalculation of the picture's frame size
* @note added in 2.3
*/

View File

@ -1,446 +0,0 @@
/***************************************************************************
qgscomposertable.cpp
--------------------
begin : January 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco at hugis dot net
***************************************************************************/
/***************************************************************************
* *
* 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 "qgscomposertable.h"
#include "qgscomposertablecolumn.h"
#include "qgssymbollayerutils.h"
#include "qgscomposerutils.h"
#include "qgsfontutils.h"
#include <QPainter>
#include <QSettings>
QgsComposerTable::QgsComposerTable( QgsComposition* composition )
: QgsComposerItem( composition )
, mLineTextDistance( 1.0 )
, mHeaderFontColor( Qt::black )
, mContentFontColor( Qt::black )
, mHeaderHAlignment( FollowColumn )
, mShowGrid( true )
, mGridStrokeWidth( 0.5 )
, mGridColor( QColor( 0, 0, 0 ) )
{
//get default composer font from settings
QSettings settings;
QString defaultFontString = settings.value( "/Composer/defaultFont" ).toString();
if ( !defaultFontString.isEmpty() )
{
mHeaderFont.setFamily( defaultFontString );
mContentFont.setFamily( defaultFontString );
}
}
QgsComposerTable::~QgsComposerTable()
{
qDeleteAll( mColumns );
mColumns.clear();
}
void QgsComposerTable::refreshAttributes()
{
mMaxColumnWidthMap.clear();
mAttributeMaps.clear();
//getFeatureAttributes
if ( !getFeatureAttributes( mAttributeMaps ) )
{
return;
}
//since attributes have changed, we also need to recalculate the column widths
//and size of table
adjustFrameToSize();
}
void QgsComposerTable::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
{
Q_UNUSED( itemStyle );
Q_UNUSED( pWidget );
if ( !painter )
{
return;
}
if ( !shouldDrawItem() )
{
return;
}
if ( mComposition->plotStyle() == QgsComposition::Print ||
mComposition->plotStyle() == QgsComposition::Postscript )
{
//exporting composition, so force an attribute refresh
//we do this in case vector layer has changed via an external source (eg, another database user)
refreshAttributes();
}
drawBackground( painter );
painter->save();
//antialiasing on
painter->setRenderHint( QPainter::Antialiasing, true );
painter->setPen( Qt::SolidLine );
//now draw the text
double currentX = mGridStrokeWidth;
double currentY;
QList<QgsComposerTableColumn*>::const_iterator columnIt = mColumns.constBegin();
int col = 0;
double cellHeaderHeight = QgsComposerUtils::fontAscentMM( mHeaderFont ) + 2 * mLineTextDistance;
double cellBodyHeight = QgsComposerUtils::fontAscentMM( mContentFont ) + 2 * mLineTextDistance;
QRectF cell;
for ( ; columnIt != mColumns.constEnd(); ++columnIt )
{
currentY = mGridStrokeWidth;
currentX += mLineTextDistance;
cell = QRectF( currentX, currentY, mMaxColumnWidthMap[col], cellHeaderHeight );
//calculate alignment of header
Qt::AlignmentFlag headerAlign = Qt::AlignLeft;
switch ( mHeaderHAlignment )
{
case FollowColumn:
headerAlign = ( *columnIt )->hAlignment();
break;
case HeaderLeft:
headerAlign = Qt::AlignLeft;
break;
case HeaderCenter:
headerAlign = Qt::AlignHCenter;
break;
case HeaderRight:
headerAlign = Qt::AlignRight;
break;
}
QgsComposerUtils::drawText( painter, cell, ( *columnIt )->heading(), mHeaderFont, mHeaderFontColor, headerAlign, Qt::AlignVCenter, Qt::TextDontClip );
currentY += cellHeaderHeight;
currentY += mGridStrokeWidth;
//draw the attribute values
QList<QgsAttributeMap>::const_iterator attIt = mAttributeMaps.constBegin();
for ( ; attIt != mAttributeMaps.constEnd(); ++attIt )
{
cell = QRectF( currentX, currentY, mMaxColumnWidthMap[col], cellBodyHeight );
const QgsAttributeMap &currentAttributeMap = *attIt;
QString str = currentAttributeMap[ col ].toString();
QgsComposerUtils::drawText( painter, cell, str, mContentFont, mContentFontColor, ( *columnIt )->hAlignment(), ( *columnIt )->vAlignment(), Qt::TextDontClip );
currentY += cellBodyHeight;
currentY += mGridStrokeWidth;
}
currentX += mMaxColumnWidthMap[ col ];
currentX += mLineTextDistance;
currentX += mGridStrokeWidth;
col++;
}
//and the borders
if ( mShowGrid )
{
QPen gridPen;
gridPen.setWidthF( mGridStrokeWidth );
gridPen.setColor( mGridColor );
gridPen.setJoinStyle( Qt::MiterJoin );
painter->setPen( gridPen );
drawHorizontalGridLines( painter, mAttributeMaps.size() );
drawVerticalGridLines( painter, mMaxColumnWidthMap );
}
painter->restore();
//draw frame and selection boxes if necessary
drawFrame( painter );
if ( isSelected() )
{
drawSelectionBoxes( painter );
}
}
void QgsComposerTable::setLineTextDistance( double d )
{
mLineTextDistance = d;
//since spacing has changed, we need to recalculate the table size
adjustFrameToSize();
}
void QgsComposerTable::setHeaderFont( const QFont& f )
{
mHeaderFont = f;
//since font attributes have changed, we need to recalculate the table size
adjustFrameToSize();
}
void QgsComposerTable::setHeaderFontColor( const QColor &color )
{
mHeaderFontColor = color;
repaint();
}
void QgsComposerTable::setHeaderHAlignment( const QgsComposerTable::HeaderHAlignment alignment )
{
mHeaderHAlignment = alignment;
repaint();
}
void QgsComposerTable::setContentFont( const QFont& f )
{
mContentFont = f;
//since font attributes have changed, we need to recalculate the table size
adjustFrameToSize();
}
void QgsComposerTable::setContentFontColor( const QColor &color )
{
mContentFontColor = color;
repaint();
}
void QgsComposerTable::setShowGrid( bool show )
{
mShowGrid = show;
//since grid spacing has changed, we need to recalculate the table size
adjustFrameToSize();
}
void QgsComposerTable::setGridStrokeWidth( double w )
{
mGridStrokeWidth = w;
//since grid spacing has changed, we need to recalculate the table size
adjustFrameToSize();
}
void QgsComposerTable::adjustFrameToSize()
{
//check how much space each column needs
if ( !calculateMaxColumnWidths( mMaxColumnWidthMap, mAttributeMaps ) )
{
return;
}
//adapt item frame to max width / height
adaptItemFrame( mMaxColumnWidthMap, mAttributeMaps );
repaint();
}
QMap<int, QString> QgsComposerTable::headerLabels() const
{
QMap<int, QString> headers;
QList<QgsComposerTableColumn*>::const_iterator columnIt = mColumns.constBegin();
int col = 0;
for ( ; columnIt != mColumns.constEnd(); ++columnIt )
{
headers.insert( col, ( *columnIt )->heading() );
col++;
}
return headers;
}
void QgsComposerTable::setColumns( const QList<QgsComposerTableColumn*>& columns )
{
//remove existing columns
qDeleteAll( mColumns );
mColumns.clear();
mColumns.append( columns );
}
bool QgsComposerTable::tableWriteXml( QDomElement& elem, QDomDocument & doc ) const
{
elem.setAttribute( "lineTextDist", QString::number( mLineTextDistance ) );
elem.appendChild( QgsFontUtils::toXmlElement( mHeaderFont, doc, "headerFontProperties" ) );
elem.setAttribute( "headerFontColor", QgsSymbolLayerUtils::encodeColor( mHeaderFontColor ) );
elem.setAttribute( "headerHAlignment", QString::number( static_cast< int >( mHeaderHAlignment ) ) );
elem.appendChild( QgsFontUtils::toXmlElement( mContentFont, doc, "contentFontProperties" ) );
elem.setAttribute( "contentFontColor", QgsSymbolLayerUtils::encodeColor( mContentFontColor ) );
elem.setAttribute( "gridStrokeWidth", QString::number( mGridStrokeWidth ) );
elem.setAttribute( "gridColor", QgsSymbolLayerUtils::encodeColor( mGridColor ) );
elem.setAttribute( "showGrid", mShowGrid );
//columns
QDomElement displayColumnsElem = doc.createElement( "displayColumns" );
QList<QgsComposerTableColumn*>::const_iterator columnIt = mColumns.constBegin();
for ( ; columnIt != mColumns.constEnd(); ++columnIt )
{
QDomElement columnElem = doc.createElement( "column" );
( *columnIt )->writeXml( columnElem, doc );
displayColumnsElem.appendChild( columnElem );
}
elem.appendChild( displayColumnsElem );
return _writeXml( elem, doc );
}
bool QgsComposerTable::tableReadXml( const QDomElement& itemElem, const QDomDocument& doc )
{
if ( itemElem.isNull() )
{
return false;
}
if ( !QgsFontUtils::setFromXmlChildNode( mHeaderFont, itemElem, "headerFontProperties" ) )
{
mHeaderFont.fromString( itemElem.attribute( "headerFont", "" ) );
}
mHeaderFontColor = QgsSymbolLayerUtils::decodeColor( itemElem.attribute( "headerFontColor", "0,0,0,255" ) );
mHeaderHAlignment = QgsComposerTable::HeaderHAlignment( itemElem.attribute( "headerHAlignment", "0" ).toInt() );
if ( !QgsFontUtils::setFromXmlChildNode( mContentFont, itemElem, "contentFontProperties" ) )
{
mContentFont.fromString( itemElem.attribute( "contentFont", "" ) );
}
mContentFontColor = QgsSymbolLayerUtils::decodeColor( itemElem.attribute( "contentFontColor", "0,0,0,255" ) );
mLineTextDistance = itemElem.attribute( "lineTextDist", "1.0" ).toDouble();
mGridStrokeWidth = itemElem.attribute( "gridStrokeWidth", "0.5" ).toDouble();
mShowGrid = itemElem.attribute( "showGrid", "1" ).toInt();
//grid color
if ( itemElem.hasAttribute( "gridColor" ) )
{
mGridColor = QgsSymbolLayerUtils::decodeColor( itemElem.attribute( "gridColor", "0,0,0,255" ) );
}
else
{
//old style grid color
int gridRed = itemElem.attribute( "gridColorRed", "0" ).toInt();
int gridGreen = itemElem.attribute( "gridColorGreen", "0" ).toInt();
int gridBlue = itemElem.attribute( "gridColorBlue", "0" ).toInt();
int gridAlpha = itemElem.attribute( "gridColorAlpha", "255" ).toInt();
mGridColor = QColor( gridRed, gridGreen, gridBlue, gridAlpha );
}
//restore column specifications
qDeleteAll( mColumns );
mColumns.clear();
QDomNodeList columnsList = itemElem.elementsByTagName( "displayColumns" );
if ( !columnsList.isEmpty() )
{
QDomElement columnsElem = columnsList.at( 0 ).toElement();
QDomNodeList columnEntryList = columnsElem.elementsByTagName( "column" );
for ( int i = 0; i < columnEntryList.size(); ++i )
{
QDomElement columnElem = columnEntryList.at( i ).toElement();
QgsComposerTableColumn* column = new QgsComposerTableColumn;
column->readXml( columnElem );
mColumns.append( column );
}
}
//restore general composer item properties
QDomNodeList composerItemList = itemElem.elementsByTagName( "ComposerItem" );
if ( !composerItemList.isEmpty() )
{
QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
_readXml( composerItemElem, doc );
}
return true;
}
bool QgsComposerTable::calculateMaxColumnWidths( QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeMaps ) const
{
maxWidthMap.clear();
QList<QgsComposerTableColumn*>::const_iterator columnIt = mColumns.constBegin();
int col = 0;
for ( ; columnIt != mColumns.constEnd(); ++columnIt )
{
maxWidthMap.insert( col, QgsComposerUtils::textWidthMM( mHeaderFont, ( *columnIt )->heading() ) );
col++;
}
//go through all the attributes and adapt the max width values
QList<QgsAttributeMap>::const_iterator attIt = attributeMaps.constBegin();
double currentAttributeTextWidth;
for ( ; attIt != attributeMaps.constEnd(); ++attIt )
{
QgsAttributeMap::const_iterator attIt2 = attIt->constBegin();
for ( ; attIt2 != attIt->constEnd(); ++attIt2 )
{
currentAttributeTextWidth = QgsComposerUtils::textWidthMM( mContentFont, attIt2.value().toString() );
if ( currentAttributeTextWidth > maxWidthMap[ attIt2.key()] )
{
maxWidthMap[ attIt2.key()] = currentAttributeTextWidth;
}
}
}
return true;
}
void QgsComposerTable::adaptItemFrame( const QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeMaps )
{
//calculate height
int n = attributeMaps.size();
double totalHeight = QgsComposerUtils::fontAscentMM( mHeaderFont )
+ n * QgsComposerUtils::fontAscentMM( mContentFont )
+ ( n + 1 ) * mLineTextDistance * 2
+ ( n + 2 ) * mGridStrokeWidth;
//adapt frame to total width
double totalWidth = 0;
QMap<int, double>::const_iterator maxColWidthIt = maxWidthMap.constBegin();
for ( ; maxColWidthIt != maxWidthMap.constEnd(); ++maxColWidthIt )
{
totalWidth += maxColWidthIt.value();
}
totalWidth += ( 2 * maxWidthMap.size() * mLineTextDistance );
totalWidth += ( maxWidthMap.size() + 1 ) * mGridStrokeWidth;
QRectF evaluatedRect = evalItemRect( QRectF( pos().x(), pos().y(), totalWidth, totalHeight ) );
//update rect for data defined size and position
QgsComposerItem::setSceneRect( evaluatedRect );
}
void QgsComposerTable::drawHorizontalGridLines( QPainter* p, int nAttributes )
{
//horizontal lines
double halfGridStrokeWidth = mGridStrokeWidth / 2.0;
double currentY = halfGridStrokeWidth;
p->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF( rect().width() - halfGridStrokeWidth, currentY ) );
currentY += mGridStrokeWidth;
currentY += ( QgsComposerUtils::fontAscentMM( mHeaderFont ) + 2 * mLineTextDistance );
for ( int i = 0; i < nAttributes; ++i )
{
p->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF( rect().width() - halfGridStrokeWidth, currentY ) );
currentY += mGridStrokeWidth;
currentY += ( QgsComposerUtils::fontAscentMM( mContentFont ) + 2 * mLineTextDistance );
}
p->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF( rect().width() - halfGridStrokeWidth, currentY ) );
}
void QgsComposerTable::drawVerticalGridLines( QPainter* p, const QMap<int, double>& maxWidthMap )
{
//vertical lines
double halfGridStrokeWidth = mGridStrokeWidth / 2.0;
double currentX = halfGridStrokeWidth;
p->drawLine( QPointF( currentX, halfGridStrokeWidth ), QPointF( currentX, rect().height() - halfGridStrokeWidth ) );
currentX += mGridStrokeWidth;
QMap<int, double>::const_iterator maxColWidthIt = maxWidthMap.constBegin();
for ( ; maxColWidthIt != maxWidthMap.constEnd(); ++maxColWidthIt )
{
currentX += ( maxColWidthIt.value() + 2 * mLineTextDistance );
p->drawLine( QPointF( currentX, halfGridStrokeWidth ), QPointF( currentX, rect().height() - halfGridStrokeWidth ) );
currentX += mGridStrokeWidth;
}
}

View File

@ -1,322 +0,0 @@
/***************************************************************************
qgscomposertable.h
------------------
begin : January 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco at hugis dot net
***************************************************************************/
/***************************************************************************
* *
* 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 QGSCOMPOSERTABLE_H
#define QGSCOMPOSERTABLE_H
#include "qgscomposeritem.h"
#include "qgsfeature.h"
#include <QSet>
#include <QObject>
class QgsComposerTableColumn;
/** \ingroup core
* A class to display feature attributes in the print composer
* @deprecated use QgsComposerTableV2 instead
*/
//TODO QGIS 3.0 -remove
class CORE_EXPORT QgsComposerTable: public QgsComposerItem
{
Q_OBJECT
public:
/** Controls how headers are horizontally aligned in a table
*/
enum HeaderHAlignment
{
FollowColumn, /*!< header uses the same alignment as the column */
HeaderLeft, /*!< align headers left */
HeaderCenter, /*!< align headers to center */
HeaderRight /*!< align headers right */
};
QgsComposerTable( QgsComposition* composition );
virtual ~QgsComposerTable();
/** Return correct graphics item type. */
virtual int type() const override { return ComposerTable; }
/** \brief Reimplementation of QCanvasItem::paint*/
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ) override;
virtual bool writeXml( QDomElement& elem, QDomDocument & doc ) const override = 0;
virtual bool readXml( const QDomElement& itemElem, const QDomDocument& doc ) override = 0;
/** Sets the margin distance between cell borders and their contents.
* @param d margin for cell contents
* @see lineTextDistance
*/
void setLineTextDistance( double d );
/** Returns the margin distance between cell borders and their contents.
* @returns margin for cell contents
* @see setLineTextDistance
*/
double lineTextDistance() const { return mLineTextDistance; }
/** Sets the font used to draw header text in the table.
* @param f font for header cells
* @see headerFont
* @see setContentFont
*/
void setHeaderFont( const QFont& f );
/** Returns the font used to draw header text in the table.
* @returns font for header cells
* @see setHeaderFont
* @see contentFont
*/
QFont headerFont() const { return mHeaderFont; }
/** Sets the color used to draw header text in the table.
* @param color header text color
* @see headerFontColor
* @see setHeaderFont
* @see setContentFontColor
* @note added in 2.5
*/
void setHeaderFontColor( const QColor& color );
/** Returns the color used to draw header text in the table.
* @returns color for header text
* @see setHeaderFontColor
* @see headerFont
* @see contentFontColor
* @note added in 2.5
*/
QColor headerFontColor() const { return mHeaderFontColor; }
/** Sets the horizontal alignment for table headers
* @param alignment Horizontal alignment for table header cells
* @note added in 2.3
* @see headerHAlignment
*/
void setHeaderHAlignment( const HeaderHAlignment alignment );
/** Returns the horizontal alignment for table headers
* @returns Horizontal alignment for table header cells
* @note added in 2.3
* @see setHeaderHAlignment
*/
HeaderHAlignment headerHAlignment() const { return mHeaderHAlignment; }
/** Sets the font used to draw text in table body cells.
* @param f font for table cells
* @see contentFont
* @see setHeaderFont
*/
void setContentFont( const QFont& f );
/** Returns the font used to draw text in table body cells.
* @returns font for table cells
* @see setContentFont
* @see headerFont
*/
QFont contentFont() const { return mContentFont; }
/** Sets the color used to draw text in table body cells.
* @param color table cell text color
* @see contentFontColor
* @see setContentFont
* @see setHeaderFontColor
* @note added in 2.5
*/
void setContentFontColor( const QColor& color );
/** Returns the color used to draw text in table body cells.
* @returns text color for table cells
* @see setContentFontColor
* @see contentFont
* @see headerFontColor
* @note added in 2.5
*/
QColor contentFontColor() const { return mContentFontColor; }
/** Sets whether grid lines should be drawn in the table
* @param show set to true to show grid lines
* @see showGrid
* @see setGridStrokeWidth
* @see setGridColor
*/
void setShowGrid( bool show );
/** Returns whether grid lines are drawn in the table
* @returns true if grid lines are shown
* @see setShowGrid
* @see gridStrokeWidth
* @see gridColor
*/
bool showGrid() const { return mShowGrid; }
/** Sets the width for grid lines in the table.
* @param w grid line width
* @see gridStrokeWidth
* @see setShowGrid
* @see setGridColor
*/
void setGridStrokeWidth( double w );
/** Returns the width of grid lines in the table.
* @returns grid line width
* @see setGridStrokeWidth
* @see showGrid
* @see gridColor
*/
double gridStrokeWidth() const { return mGridStrokeWidth; }
/** Sets color used for grid lines in the table.
* @param c grid line color
* @see gridColor
* @see setShowGrid
* @see setGridStrokeWidth
*/
void setGridColor( const QColor& c ) { mGridColor = c; }
/** Returns the color used for grid lines in the table.
* @returns grid line color
* @see setGridColor
* @see showGrid
* @see gridStrokeWidth
*/
QColor gridColor() const { return mGridColor; }
/** Returns the text used in the column headers for the table.
* @returns QMap of int to QString, where the int is the column index (starting at 0),
* and the string is the text to use for the column's header
* @note added in 2.3
* @note not available in python bindings
*/
virtual QMap<int, QString> headerLabels() const;
//TODO - make this more generic for next API break, eg rename as getRowValues, use QStringList rather than
//QgsAttributeMap
/** Fetches the text used for the rows of the table.
* @returns true if attribute text was successfully retrieved.
* @param attributeMaps QList of QgsAttributeMap to store retrieved row data in
* @note not available in python bindings
*/
virtual bool getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps ) { Q_UNUSED( attributeMaps ); return false; }
/** Returns a pointer to the list of QgsComposerTableColumns shown in the table
* @returns pointer to list of columns in table
* @note added in 2.3
* @see setColumns
*/
QList<QgsComposerTableColumn*>* columns() { return &mColumns; }
/** Replaces the columns in the table with a specified list of QgsComposerTableColumns.
* @param columns list of QgsComposerTableColumns to show in table
* @note added in 2.3
* @see columns
*/
void setColumns( const QList<QgsComposerTableColumn*>& columns );
public slots:
/** Refreshes the attributes shown in the table by querying the vector layer for new data.
* This also causes the column widths and size of the table to change to accommodate the
* new data.
* @note added in 2.3
* @see adjustFrameToSize
*/
virtual void refreshAttributes();
/** Adapts the size of the frame to match the content. First, the optimal width of the columns
* is recalculated by checking the maximum width of attributes shown in the table. Then, the
* table is resized to fit its contents. This slot utilises the table's attribute cache so
* that a re-query of the vector layer is not required.
* @note added in 2.3
* @see refreshAttributes
*/
virtual void adjustFrameToSize();
protected:
/** Distance between table lines and text*/
double mLineTextDistance;
QFont mHeaderFont;
QColor mHeaderFontColor;
QFont mContentFont;
QColor mContentFontColor;
HeaderHAlignment mHeaderHAlignment;
bool mShowGrid;
double mGridStrokeWidth;
QColor mGridColor;
QList<QgsAttributeMap> mAttributeMaps;
QMap<int, double> mMaxColumnWidthMap;
QList<QgsComposerTableColumn*> mColumns;
/** Calculates the maximum width of text shown in columns.
* @param maxWidthMap QMap of int to double in which to store the maximum widths. The int will be filled
* with the column number and the double with the maximum width of text present in the column.
* @param attributeMaps list of attribute values for each row shown in the table
* @note not available in python bindings
* @see adaptItemFrame
*/
virtual bool calculateMaxColumnWidths( QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeMaps ) const;
/** Adapts the size of the item frame to match the table's content.
* @param maxWidthMap QMap of int to double, where the int contains the column number and the double is the
* maximum width of text present in the column.
* @param attributeMaps list of attribute values for each row shown in the table
* @note not available in python bindings
* @see calculateMaxColumnWidths
*/
void adaptItemFrame( const QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeMaps );
/** Draws the horizontal grid lines for the table.
* @param p destination painter for grid lines
* @param nAttributes number of attribute rows shown in table
* @see drawVerticalGridLines
*/
void drawHorizontalGridLines( QPainter* p, int nAttributes );
/** Draws the vertical grid lines for the table.
* @param p destination painter for grid lines
* @param maxWidthMap QMap of int to double, where the int contains the column number and the double is the
* maximum width of text present in the column.
* @note not available in python bindings
* @see drawVerticalGridLines
* @see calculateMaxColumnWidths
*/
void drawVerticalGridLines( QPainter* p, const QMap<int, double>& maxWidthMap );
/** Writes common table properties to xml for storage.
* @param itemElem an existing QDomElement in which to store the table's properties.
* @param doc QDomDocument for the destination xml.
* @see tableReadXML
* @see writeXml
*/
bool tableWriteXml( QDomElement& itemElem, QDomDocument& doc ) const;
/** Reads the table's common properties from xml.
* @param itemElem a QDomElement holding the table's desired properties.
* @param doc QDomDocument for the source xml.
* @see tableWriteXML
* @see readXml
*/
bool tableReadXml( const QDomElement& itemElem, const QDomDocument& doc );
};
#endif // QGSCOMPOSERTABLE_H

View File

@ -232,49 +232,6 @@ QSizeF QgsComposerTableV2::totalSize() const
return mTableSize;
}
int QgsComposerTableV2::rowsVisible( const int frameIndex ) const
{
//get frame extent
if ( frameIndex >= frameCount() )
{
return 0;
}
QRectF frameExtent = frame( frameIndex )->extent();
bool includeHeader = false;
if (( mHeaderMode == QgsComposerTableV2::FirstFrame && frameIndex < 1 )
|| ( mHeaderMode == QgsComposerTableV2::AllFrames ) )
{
includeHeader = true;
}
Q_NOWARN_DEPRECATED_PUSH
return rowsVisible( frameExtent.height(), includeHeader );
Q_NOWARN_DEPRECATED_POP
}
int QgsComposerTableV2::rowsVisible( const double frameHeight, const bool includeHeader ) const
{
//calculate header height
double headerHeight = 0;
if ( includeHeader )
{
//frame has a header
headerHeight = 2 * ( mShowGrid ? mGridStrokeWidth : 0 ) + 2 * mCellMargin + QgsComposerUtils::fontAscentMM( mHeaderFont );
}
else
{
//frame has no header text, just the stroke
headerHeight = ( mShowGrid ? mGridStrokeWidth : 0 );
}
//remaining height available for content rows
double contentHeight = frameHeight - headerHeight;
//calculate number of visible rows
double rowHeight = ( mShowGrid ? mGridStrokeWidth : 0 ) + 2 * mCellMargin + QgsComposerUtils::fontAscentMM( mContentFont );
return qMax( floor( contentHeight / rowHeight ), 0.0 );
}
int QgsComposerTableV2::rowsVisible( double frameHeight, int firstRow, bool includeHeader , bool includeEmptyRows ) const
{
//calculate header height
@ -355,13 +312,6 @@ QPair<int, int> QgsComposerTableV2::rowRange( const int frameIndex ) const
return qMakePair( firstVisible, lastVisible );
}
QPair< int, int > QgsComposerTableV2::rowRange( const QRectF &extent, const int frameIndex ) const
{
Q_UNUSED( extent );
return rowRange( frameIndex );
}
void QgsComposerTableV2::render( QPainter *p, const QRectF &, const int frameIndex )
{
if ( !p )
@ -1124,12 +1074,6 @@ double QgsComposerTableV2::totalHeight()
return height;
}
void QgsComposerTableV2::drawHorizontalGridLines( QPainter *painter, const int rows, const bool drawHeaderLines ) const
{
//hacky shortcut to maintain 2.10 API without adding code - whooo!
drawHorizontalGridLines( painter, 100000, 100000 + rows, drawHeaderLines );
}
void QgsComposerTableV2::drawHorizontalGridLines( QPainter *painter, int firstRow, int lastRow, bool drawHeaderLines ) const
{
//horizontal lines
@ -1158,12 +1102,6 @@ void QgsComposerTableV2::drawHorizontalGridLines( QPainter *painter, int firstRo
painter->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF( mTableSize.width() - halfGridStrokeWidth, currentY ) );
}
void QgsComposerTableV2::drawVerticalGridLines( QPainter *painter, const QMap<int, double> &maxWidthMap, const int numberRows, const bool hasHeader, const bool mergeCells ) const
{
//hacky shortcut to maintain 2.10 API without adding code - whooo!
drawVerticalGridLines( painter, maxWidthMap, 100000, 100000 + numberRows, hasHeader, mergeCells );
}
bool QgsComposerTableV2::textRequiresWrapping( const QString& text, double columnWidth, const QFont &font ) const
{
if ( qgsDoubleNear( columnWidth, 0.0 ) || mWrapBehaviour != WrapText )

View File

@ -591,57 +591,6 @@ class CORE_EXPORT QgsComposerTableV2: public QgsComposerMultiFrame
*/
bool contentsContainsRow( const QgsComposerTableContents &contents, const QgsComposerTableRow &row ) const;
//deprecated methods
/** Calculates how many content rows are visible within a given frame
* @param frameIndex index number for frame
* @returns number of visible content rows (excludes header rows)
* @deprecated will be removed in QGIS 3.0
*/
Q_DECL_DEPRECATED int rowsVisible( const int frameIndex ) const;
/** Calculates how many content rows would be visible within a specified
* height.
* @param frameHeight height of frame
* @param includeHeader set to true if frame would include a header row
* @returns number of visible content rows (excluding header row)
* @deprecated will be removed in QGIS 3.0
*/
Q_DECL_DEPRECATED int rowsVisible( const double frameHeight, const bool includeHeader ) const;
/** Calculates a range of rows which should be visible in a given
* frame extent.
* @param extent visible extent
* @param frameIndex index number for frame
* @returns row range
* @deprecated will be removed in QGIS 3.0
*/
Q_DECL_DEPRECATED QPair<int, int> rowRange( const QRectF &extent, const int frameIndex ) const;
/** Draws the horizontal grid lines for the table.
* @param painter destination painter for grid lines
* @param rows number of rows shown in table
* @param drawHeaderLines set to true to include for the table header
* @see drawVerticalGridLines
* @deprecated will be removed in QGIS 3.0
*/
Q_DECL_DEPRECATED void drawHorizontalGridLines( QPainter* painter, const int rows, const bool drawHeaderLines ) const;
/** Draws the vertical grid lines for the table.
* @param painter destination painter for grid lines
* @param maxWidthMap QMap of int to double, where the int contains the column number and the double is the
* maximum width of text present in the column.
* @param numberRows number of rows of content in table frame
* @param hasHeader set to true if table frame includes header cells
* @param mergeCells set to true to merge table content cells
* @note not available in python bindings
* @see drawVerticalGridLines
* @see calculateMaxColumnWidths
* @note not available in python bindings
* @deprecated will be removed in QGIS 3.0
*/
Q_DECL_DEPRECATED void drawVerticalGridLines( QPainter* painter, const QMap<int, double>& maxWidthMap, const int numberRows, const bool hasHeader, const bool mergeCells = false ) const;
private:
QMap< CellStyleGroup, QString > mCellStyleNames;

View File

@ -20,74 +20,6 @@
#include "qgscomposerframe.h"
#include "qgscomposition.h"
QgsComposerTextTable::QgsComposerTextTable( QgsComposition* c ): QgsComposerTable( c )
{
}
QgsComposerTextTable::~QgsComposerTextTable()
{
}
void QgsComposerTextTable::setHeaderLabels( const QStringList& labels )
{
//update existing column headings, or add new columns if required
QStringList::const_iterator labelIt = labels.constBegin();
int idx = 0;
for ( ; labelIt != labels.constEnd(); ++labelIt )
{
QgsComposerTableColumn* col;
if ( idx < mColumns.count() )
{
col = mColumns.at( idx );
}
else
{
col = new QgsComposerTableColumn;
mColumns.append( col );
}
col->setHeading(( *labelIt ) );
idx++;
}
}
bool QgsComposerTextTable::writeXml( QDomElement& elem, QDomDocument & doc ) const
{
QDomElement composerTableElem = doc.createElement( "ComposerTextTable" );
//todo: write headers and text entries
bool ok = _writeXml( composerTableElem, doc );
elem.appendChild( composerTableElem );
return ok;
}
bool QgsComposerTextTable::readXml( const QDomElement& itemElem, const QDomDocument& doc )
{
//todo: read headers and text entries
return tableReadXml( itemElem, doc );
}
bool QgsComposerTextTable::getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps )
{
attributeMaps.clear();
QList< QStringList >::const_iterator rowIt = mRowText.constBegin();
QStringList currentStringList;
for ( ; rowIt != mRowText.constEnd(); ++rowIt )
{
currentStringList = *rowIt;
attributeMaps.push_back( QgsAttributeMap() );
for ( int i = 0; i < currentStringList.size(); ++i )
{
attributeMaps.last().insert( i, QVariant( currentStringList.at( i ) ) );
}
}
return true;
}
QgsComposerTextTableV2::QgsComposerTextTableV2( QgsComposition* c, bool createUndoCommands )
: QgsComposerTableV2( c, createUndoCommands )
{

View File

@ -18,64 +18,8 @@
#ifndef QGSCOMPOSERTEXTTABLE_H
#define QGSCOMPOSERTEXTTABLE_H
#include "qgscomposertable.h"
#include "qgscomposertablev2.h"
/** \ingroup core
* A text table item that reads text from string lists
* @deprecated use QgsComposerTextTableV2 intead
*/
//TODO QGIS 3.0 - remove
class CORE_EXPORT QgsComposerTextTable: public QgsComposerTable
{
Q_OBJECT
public:
QgsComposerTextTable( QgsComposition* c );
~QgsComposerTextTable();
/** Return correct graphics item type. */
virtual int type() const override { return ComposerTextTable; }
/** Sets the text to use for the header row for the table
* @param labels list of strings to use for each column's header row
* @see headerLabels
*/
void setHeaderLabels( const QStringList& labels );
/** Adds a row to the table
* @param row list of strings to use for each cell's value in the newly added row
* @note If row is shorter than the number of columns in the table than blank cells
* will be inserted at the end of the row. If row contains more strings then the number
* of columns in the table then these extra strings will be ignored.
*/
void addRow( const QStringList& row ) { mRowText.append( row ); }
/** Writes properties specific to text tables
* @param elem an existing QDomElement in which to store the text table's properties.
* @param doc QDomDocument for the destination xml.
* @see readXml
*/
bool writeXml( QDomElement& elem, QDomDocument & doc ) const override;
/** Reads the properties specific to a text table from xml.
* @param itemElem a QDomElement holding the text table's desired properties.
* @param doc QDomDocument for the source xml.
* @see writeXml
*/
bool readXml( const QDomElement& itemElem, const QDomDocument& doc ) override;
/** Queries the text table for text to show in the cells.
* @param attributeMaps list of QgsAttributeMaps where the cell text will be stored
* @returns true if attribute values were successfully set from table's text
* @note not available in python bindings
*/
bool getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps ) override;
private:
/** One stringlist per row*/
QList< QStringList > mRowText;
};
/** \ingroup core
* A text table item that reads text from string lists
* @note added in QGIS 2.10

View File

@ -31,7 +31,6 @@
#include "qgscomposerscalebar.h"
#include "qgscomposershape.h"
#include "qgscomposermodel.h"
#include "qgscomposerattributetable.h"
#include "qgscomposerattributetablev2.h"
#include "qgsaddremovemultiframecommand.h"
#include "qgscomposermultiframecommand.h"
@ -703,25 +702,6 @@ const QgsComposerMap* QgsComposition::getComposerMapById( const int id ) const
return nullptr;
}
const QgsComposerHtml* QgsComposition::getComposerHtmlByItem( QgsComposerItem *item ) const
{
// an html item will be a composer frame and if it is we can try to get
// its multiframe parent and then try to cast that to a composer html
const QgsComposerFrame* composerFrame =
dynamic_cast<const QgsComposerFrame *>( item );
if ( composerFrame )
{
const QgsComposerMultiFrame * mypMultiFrame = composerFrame->multiFrame();
const QgsComposerHtml* composerHtml =
dynamic_cast<const QgsComposerHtml *>( mypMultiFrame );
if ( composerHtml )
{
return composerHtml;
}
}
return nullptr;
}
const QgsComposerItem* QgsComposition::getComposerItemById( const QString& theId ) const
{
QList<QGraphicsItem *> itemList = items();
@ -831,16 +811,6 @@ void QgsComposition::setUseAdvancedEffects( const bool effectsEnabled )
}
}
int QgsComposition::pixelFontSize( double pointSize ) const
{
return qRound( QgsComposerUtils::pointsToMM( pointSize ) ); //round to nearest mm
}
double QgsComposition::pointFontSize( int pixelSize ) const
{
return QgsComposerUtils::mmToPoints( pixelSize );
}
bool QgsComposition::writeXml( QDomElement& composerElem, QDomDocument& doc )
{
if ( composerElem.isNull() )
@ -1468,34 +1438,7 @@ void QgsComposition::addItemsFromXml( const QDomElement& elem, const QDomDocumen
pushAddRemoveCommand( newLegend, tr( "Legend added" ) );
}
}
// table
QDomNodeList composerTableList = elem.elementsByTagName( "ComposerAttributeTable" );
for ( int i = 0; i < composerTableList.size(); ++i )
{
QDomElement currentComposerTableElem = composerTableList.at( i ).toElement();
QgsComposerAttributeTable* newTable = new QgsComposerAttributeTable( this );
newTable->readXml( currentComposerTableElem, doc );
if ( pos )
{
if ( pasteInPlace )
{
newTable->setItemPosition( newTable->pos().x(), fmod( newTable->pos().y(), ( paperHeight() + spaceBetweenPages() ) ) );
newTable->move( pasteInPlacePt->x(), pasteInPlacePt->y() );
}
else
{
newTable->move( pasteShiftPos.x(), pasteShiftPos.y() );
}
newTable->setSelected( true );
lastPastedItem = newTable;
}
addComposerTable( newTable );
newTable->setZValue( newTable->zValue() + zOrderOffset );
if ( addUndoCommands )
{
pushAddRemoveCommand( newTable, tr( "Table added" ) );
}
}
// html
//TODO - fix this. pasting multiframe frame items has no effect
QDomNodeList composerHtmlList = elem.elementsByTagName( "ComposerHtml" );
@ -2588,16 +2531,6 @@ void QgsComposition::addComposerShape( QgsComposerShape* shape )
emit composerShapeAdded( shape );
}
void QgsComposition::addComposerTable( QgsComposerAttributeTable* table )
{
addItem( table );
updateBounds();
connect( table, SIGNAL( sizeChanged() ), this, SLOT( updateBounds() ) );
emit composerTableAdded( table );
}
void QgsComposition::addComposerHtmlFrame( QgsComposerHtml* html, QgsComposerFrame* frame )
{
addItem( frame );
@ -2786,13 +2719,7 @@ void QgsComposition::sendItemAddedSignal( QgsComposerItem* item )
emit selectedItemChanged( polyline );
return;
}
QgsComposerAttributeTable* table = dynamic_cast<QgsComposerAttributeTable*>( item );
if ( table )
{
emit composerTableAdded( table );
emit selectedItemChanged( table );
return;
}
QgsComposerFrame* frame = dynamic_cast<QgsComposerFrame*>( item );
if ( frame )
{
@ -3649,12 +3576,3 @@ void QgsComposition::prepareAllDataDefinedExpressions()
prepareDataDefinedExpression( nullptr, &mDataDefinedProperties, context );
}
void QgsComposition::relativeResizeRect( QRectF& rectToResize, const QRectF& boundsBefore, const QRectF& boundsAfter )
{
QgsComposerUtils::relativeResizeRect( rectToResize, boundsBefore, boundsAfter );
}
double QgsComposition::relativePosition( double position, double beforeMin, double beforeMax, double afterMin, double afterMax )
{
return QgsComposerUtils::relativePosition( position, beforeMin, beforeMax, afterMin, afterMax );
}

View File

@ -55,7 +55,6 @@ class QgsComposerMap;
class QgsComposerPicture;
class QgsComposerScaleBar;
class QgsComposerShape;
class QgsComposerAttributeTable;
class QgsComposerAttributeTableV2;
class QgsComposerMultiFrame;
class QgsComposerMultiFrameCommand;
@ -297,38 +296,6 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene, public QgsExpressionCo
void setGridStyle( const GridStyle s );
GridStyle gridStyle() const {return mGridStyle;}
/** Sets the snap tolerance to use when automatically snapping items during movement and resizing to the
* composition grid.
* @param tolerance snap tolerance in pixels
* @see snapGridTolerance
* @deprecated Use setSnapTolerance instead
*/
Q_DECL_DEPRECATED void setSnapGridTolerance( double tolerance ) { mSnapTolerance = tolerance; }
/** Returns the snap tolerance to use when automatically snapping items during movement and resizing to the
* composition grid.
* @returns snap tolerance in pixels
* @see setSnapGridTolerance
* @deprecated Use snapTolerance instead
*/
Q_DECL_DEPRECATED double snapGridTolerance() const {return mSnapTolerance;}
/** Sets the snap tolerance to use when automatically snapping items during movement and resizing to guides
* and the edges and centers of other items.
* @param t snap tolerance in pixels
* @see alignmentSnapTolerance
* @deprecated Use setSnapTolerance instead
*/
Q_DECL_DEPRECATED void setAlignmentSnapTolerance( double t ) { mSnapTolerance = t; }
/** Returns the snap tolerance to use when automatically snapping items during movement and resizing to guides
* and the edges and centers of other items.
* @returns snap tolerance in pixels
* @see setAlignmentSnapTolerance
* @deprecated Use snapTolerance instead
*/
Q_DECL_DEPRECATED double alignmentSnapTolerance() const { return mSnapTolerance; }
/** Sets the snap tolerance to use when automatically snapping items during movement and resizing to guides
* and the edges and centers of other items.
* @param snapTolerance snap tolerance in pixels
@ -413,14 +380,6 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene, public QgsExpressionCo
*/
const QgsComposerMap* getComposerMapById( const int id ) const;
/** Returns the composer html with specified id (a string as named in the
* composer user interface item properties).
* @param item the item.
* @return QgsComposerHtml pointer or 0 pointer if no such item exists.
* @deprecated Use QgsComposerFrame::multiFrame() instead
*/
Q_DECL_DEPRECATED const QgsComposerHtml* getComposerHtmlByItem( QgsComposerItem *item ) const;
/** Returns a composer item given its text identifier.
* Ids are not necessarely unique, but this function returns only one element.
* @param theId - A QString representing the identifier of the item to retrieve.
@ -481,17 +440,6 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene, public QgsExpressionCo
QgsComposition::PlotStyle plotStyle() const { return mPlotStyle; }
void setPlotStyle( const QgsComposition::PlotStyle style ) { mPlotStyle = style; }
/** Returns the mm font size for a font that has point size set.
* Each item that sets a font should call this function before drawing text
* @deprecated use QgsComposerUtils::pointsToMM instead
*/
Q_DECL_DEPRECATED int pixelFontSize( double pointSize ) const;
/** Does the inverse calculation and returns points for mm
* @deprecated use QgsComposerUtils::mmToPoints instead
*/
Q_DECL_DEPRECATED double pointFontSize( int pixelSize ) const;
/** Writes settings to xml (paper dimension)*/
bool writeXml( QDomElement& composerElem, QDomDocument& doc );
@ -576,12 +524,6 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene, public QgsExpressionCo
*/
QList<QgsComposerItem*> ungroupItems( QgsComposerItemGroup* group );
/** Sorts the zList. The only time where this function needs to be called is from QgsComposer
* after reading all the items from xml file
* @deprecated use refreshZList instead
*/
Q_DECL_DEPRECATED void sortZList() {}
/** Rebuilds the z order list by adding any item which are present in the composition
* but missing from the z order list.
*/
@ -647,8 +589,6 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene, public QgsExpressionCo
void addComposerPolygon( QgsComposerPolygon* polygon );
/** Adds a composer polyline and advises composer to create a widget for it (through signal)*/
void addComposerPolyline( QgsComposerPolyline* polyline );
/** Adds a composer table to the graphics scene and advises composer to create a widget for it (through signal)*/
void addComposerTable( QgsComposerAttributeTable* table );
/** Adds composer html frame and advises composer to create a widget for it (through signal)*/
void addComposerHtmlFrame( QgsComposerHtml* html, QgsComposerFrame* frame );
/** Adds composer tablev2 frame and advises composer to create a widget for it (through signal)*/
@ -767,16 +707,6 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene, public QgsExpressionCo
QgsAtlasComposition& atlasComposition() { return mAtlasComposition; }
/** Resizes a QRectF relative to the change from boundsBefore to boundsAfter
* @deprecated use QgsComposerUtils::relativeResizeRect instead
*/
Q_DECL_DEPRECATED static void relativeResizeRect( QRectF& rectToResize, const QRectF& boundsBefore, const QRectF& boundsAfter );
/** Returns a scaled position given a before and after range
* @deprecated use QgsComposerUtils::relativePosition instead
*/
Q_DECL_DEPRECATED static double relativePosition( double position, double beforeMin, double beforeMax, double afterMin, double afterMax );
/** Returns the current atlas mode of the composition
* @returns current atlas mode
* @see setAtlasMode
@ -1125,8 +1055,6 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene, public QgsExpressionCo
void composerPictureAdded( QgsComposerPicture* picture );
/** Is emitted when a new composer shape has been added*/
void composerShapeAdded( QgsComposerShape* shape );
/** Is emitted when a new composer table has been added*/
void composerTableAdded( QgsComposerAttributeTable* table );
/** Is emitted when a new composer table frame has been added to the view*/
void composerTableFrameAdded( QgsComposerAttributeTableV2* table, QgsComposerFrame* frame );
/** Is emitted when a composer item has been removed from the scene*/

View File

@ -47,7 +47,6 @@
#include "qgsmapcanvas.h" //for QgsMapCanvas::WheelAction
#include "qgscursors.h"
#include "qgscomposerutils.h"
#include "qgscomposerattributetable.h"
#define MIN_VIEW_SCALE 0.05
#define MAX_VIEW_SCALE 1000.0
@ -1089,34 +1088,6 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent* e )
}
break;
case AddTable:
if ( !composition() || !mRubberBandItem )
{
removeRubberBand();
return;
}
else
{
QgsComposerAttributeTable* newTable = new QgsComposerAttributeTable( composition() );
QList<const QgsComposerMap*> mapItemList = composition()->composerMapItems();
if ( !mapItemList.isEmpty() )
{
newTable->setComposerMap( mapItemList.at( 0 ) );
}
newTable->setSceneRect( QRectF( mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(), mRubberBandItem->rect().height() ) );
composition()->addComposerTable( newTable );
composition()->setAllUnselected();
newTable->setSelected( true );
emit selectedItemChanged( newTable );
removeRubberBand();
emit actionFinished();
composition()->pushAddRemoveCommand( newTable, tr( "Table added" ) );
}
break;
case AddAttributeTable:
if ( !composition() || !mRubberBandItem )
{

View File

@ -29,7 +29,6 @@
#include "qgscomposition.h"
#include "qgscomposerarrow.h"
#include "qgscomposerattributetable.h"
#include "qgscomposerlabel.h"
#include "qgscomposerlegend.h"
#include "qgscomposermap.h"

View File

@ -113,9 +113,6 @@ ADD_QGIS_TEST(composerpicturetest testqgscomposerpicture.cpp)
ADD_QGIS_TEST(composerrotationtest testqgscomposerrotation.cpp)
ADD_QGIS_TEST(composerscalebartest testqgscomposerscalebar.cpp )
ADD_QGIS_TEST(composershapestest testqgscomposershapes.cpp)
IF(NOT DISABLE_DEPRECATED)
ADD_QGIS_TEST(composertabletest testqgscomposertable.cpp)
ENDIF(NOT DISABLE_DEPRECATED)
ADD_QGIS_TEST(composertablev2test testqgscomposertablev2.cpp)
ADD_QGIS_TEST(composerutils testqgscomposerutils.cpp)
ADD_QGIS_TEST(connectionpooltest testqgsconnectionpool.cpp)

View File

@ -61,12 +61,8 @@ class TestQgsAtlasComposition : public QObject
void filename();
// test rendering with an autoscale atlas
void autoscale_render();
// test rendering with an autoscale atlas using the old api
void autoscale_render_2_0_api();
// test rendering with a fixed scale atlas
void fixedscale_render();
// test rendering with a fixed scale atlas using the old api
void fixedscale_render_2_0_api();
// test rendering with predefined scales
void predefinedscales_render();
// test rendering with two atlas-driven maps
@ -248,28 +244,6 @@ void TestQgsAtlasComposition::autoscale_render()
mAtlas->endRender();
}
void TestQgsAtlasComposition::autoscale_render_2_0_api()
{
Q_NOWARN_DEPRECATED_PUSH
mAtlas->setComposerMap( mAtlasMap );
mAtlas->setFixedScale( false );
mAtlas->setMargin( 0.10f );
Q_NOWARN_DEPRECATED_POP
mAtlas->beginRender();
for ( int fit = 0; fit < 2; ++fit )
{
mAtlas->prepareForFeature( fit );
mLabel1->adjustSizeToText();
QgsCompositionChecker checker( QString( "atlas_autoscale_old_api%1" ).arg((( int )fit ) + 1 ), mComposition );
checker.setControlPathPrefix( "atlas" );
QVERIFY( checker.testComposition( mReport, 0, 100 ) );
}
mAtlas->endRender();
}
void TestQgsAtlasComposition::fixedscale_render()
{
//TODO QGIS3.0 - setting the extent AFTER setting atlas driven/fixed scaling mode should
@ -292,27 +266,6 @@ void TestQgsAtlasComposition::fixedscale_render()
mAtlas->endRender();
}
void TestQgsAtlasComposition::fixedscale_render_2_0_api()
{
Q_NOWARN_DEPRECATED_PUSH
mAtlasMap->setNewExtent( QgsRectangle( 209838.166, 6528781.020, 610491.166, 6920530.620 ) );
mAtlas->setComposerMap( mAtlasMap );
mAtlas->setFixedScale( true );
Q_NOWARN_DEPRECATED_POP
mAtlas->beginRender();
for ( int fit = 0; fit < 2; ++fit )
{
mAtlas->prepareForFeature( fit );
mLabel1->adjustSizeToText();
QgsCompositionChecker checker( QString( "atlas_fixedscale_old_api%1" ).arg((( int )fit ) + 1 ), mComposition );
checker.setControlPathPrefix( "atlas" );
QVERIFY( checker.testComposition( mReport, 0, 100 ) );
}
mAtlas->endRender();
}
void TestQgsAtlasComposition::predefinedscales_render()
{
//TODO QGIS3.0 - setting the extent AFTER setting atlas driven/predefined scaling mode should

View File

@ -19,7 +19,6 @@
#include "qgscomposition.h"
#include "qgscomposermap.h"
#include "qgscomposertexttable.h"
#include "qgscomposerattributetable.h"
#include "qgsmaplayerregistry.h"
#include "qgsmapsettings.h"
#include "qgsvectorlayer.h"

View File

@ -128,9 +128,9 @@ void TestQgsComposerMapGrid::grid()
mComposerMap->grid()->setAnnotationEnabled( true );
mComposerMap->grid()->setGridLineColor( QColor( 0, 255, 0 ) );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::Disabled, QgsComposerMapGrid::Left );
mComposerMap->grid()->setAnnotationDisplay( QgsComposerMapGrid::HideAll, QgsComposerMapGrid::Left );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Right );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::Disabled, QgsComposerMapGrid::Top );
mComposerMap->grid()->setAnnotationDisplay( QgsComposerMapGrid::HideAll, QgsComposerMapGrid::Top );
mComposerMap->grid()->setAnnotationPosition( QgsComposerMapGrid::OutsideMapFrame, QgsComposerMapGrid::Bottom );
mComposerMap->grid()->setAnnotationDirection( QgsComposerMapGrid::Horizontal, QgsComposerMapGrid::Right );
mComposerMap->grid()->setAnnotationDirection( QgsComposerMapGrid::Horizontal, QgsComposerMapGrid::Bottom );

View File

@ -39,7 +39,6 @@ class TestQgsComposerPicture : public QObject
void pictureRotation(); //test if picture pictureRotation is functioning
void pictureItemRotation(); //test if composer picture item rotation is functioning
//void oldPictureRotationApi(); //test if old deprectated composer picture rotation api is functioning
void pictureResizeZoom();
void pictureResizeStretch();
@ -158,22 +157,6 @@ void TestQgsComposerPicture::pictureItemRotation()
mComposerPicture->setItemRotation( 0, true );
}
#if 0
void TestQgsComposerPicture::oldPictureRotationApi()
{
//test old style deprecated rotation api - remove test after 2.0 series
mComposition->addComposerPicture( mComposerPicture );
mComposerPicture->setRotation( 45 );
QgsCompositionChecker checker( "composerpicture_rotation_oldapi", mComposition );
checker.setControlPathPrefix( "composer_picture" );
QVERIFY( checker.testComposition( mReport ) );
mComposition->removeItem( mComposerPicture );
mComposerPicture->setRotation( 0 );
}
#endif
void TestQgsComposerPicture::pictureResizeZoom()
{
//test picture resize Zoom mode
@ -411,15 +394,17 @@ void TestQgsComposerPicture::pictureExpression()
mComposition->addComposerPicture( mComposerPicture );
QString expr = QString( "'%1' || '/sample_svg.svg'" ).arg( TEST_DATA_DIR );
mComposerPicture->setPictureExpression( expr );
mComposerPicture->setUsePictureExpression( true );
mComposerPicture->setDataDefinedProperty( QgsComposerObject::PictureSource,
true, true, expr, QString() );
mComposerPicture->refreshPicture();
QgsCompositionChecker checker( "composerpicture_expression", mComposition );
checker.setControlPathPrefix( "composer_picture" );
QVERIFY( checker.testComposition( mReport, 0, 0 ) );
mComposition->removeItem( mComposerPicture );
mComposerPicture->setUsePictureExpression( false );
mComposerPicture->setDataDefinedProperty( QgsComposerObject::PictureSource,
false, false, QString(), QString() );
}
void TestQgsComposerPicture::pictureInvalidExpression()
@ -428,15 +413,17 @@ void TestQgsComposerPicture::pictureInvalidExpression()
mComposition->addComposerPicture( mComposerPicture );
QString expr = QString( "bad expression" );
mComposerPicture->setPictureExpression( expr );
mComposerPicture->setUsePictureExpression( true );
mComposerPicture->setDataDefinedProperty( QgsComposerObject::PictureSource,
true, true, expr, QString() );
mComposerPicture->refreshPicture();
QgsCompositionChecker checker( "composerpicture_badexpression", mComposition );
checker.setControlPathPrefix( "composer_picture" );
QVERIFY( checker.testComposition( mReport, 0, 0 ) );
mComposition->removeItem( mComposerPicture );
mComposerPicture->setUsePictureExpression( false );
mComposerPicture->setDataDefinedProperty( QgsComposerObject::PictureSource,
false, false, QString(), QString() );
}
QTEST_MAIN( TestQgsComposerPicture )

View File

@ -51,15 +51,10 @@ class TestQgsComposerRotation : public QObject
void init();// will be called before each testfunction is executed.
void cleanup();// will be called after every testfunction.
// All old (deprecated) methods tests disabled (we have enough troubles to maintain not deprecated)
// Label tests disabled because are platform dependent (font)
void shapeRotation(); //test if composer shape rotation is functioning
//void oldShapeRotationApi(); //test if old deprecated composer shape rotation api is functioning
void labelRotation(); //test if composer label rotation is functioning
//void oldLabelRotationApi(); //test if old deprectated composer label rotation api is functioning
void mapRotation(); //test if composer map mapRotation is functioning
void mapItemRotation(); //test if composer map item rotation is functioning
//void oldMapRotationApi(); //test if old deprectated composer map rotation api is functioning
private:
QgsComposition* mComposition;
@ -157,22 +152,6 @@ void TestQgsComposerRotation::shapeRotation()
mComposerRect->setItemRotation( 0, true );
}
#if 0
void TestQgsComposerRotation::oldShapeRotationApi()
{
//test old style deprecated rotation api - remove after 2.0 series
mComposition->addComposerShape( mComposerRect );
mComposerRect->setRotation( 45 );
QgsCompositionChecker checker( "composerrotation_shape_oldapi", mComposition );
checker.setControlPathPrefix( "composer_items" );
QVERIFY( checker.testComposition( mReport ) );
mComposition->removeItem( mComposerRect );
}
#endif
void TestQgsComposerRotation::labelRotation()
{
mComposition->addComposerLabel( mComposerLabel );
@ -183,22 +162,6 @@ void TestQgsComposerRotation::labelRotation()
QVERIFY( checker.testComposition( mReport, 0, 0 ) );
}
#if 0
void TestQgsComposerRotation::oldLabelRotationApi()
{
//test old style deprecated rotation api - remove test after 2.0 series
mComposition->addComposerLabel( mComposerLabel );
mComposerLabel->setRotation( 135 );
QgsCompositionChecker checker( "composerrotation_label_oldapi", mComposition );
checker.setControlPathPrefix( "composer_items" );
QVERIFY( checker.testComposition( mReport ) );
mComposition->removeItem( mComposerLabel );
}
#endif
void TestQgsComposerRotation::mapRotation()
{
// cleanup after labelRotation()

View File

@ -1,525 +0,0 @@
/***************************************************************************
testqgscomposertable.cpp
----------------------
begin : April 2014
copyright : (C) 2014 by 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 "qgsapplication.h"
#include "qgscomposition.h"
#include "qgscomposermap.h"
#include "qgscomposertexttable.h"
#include "qgscomposerattributetable.h"
#include "qgsmapsettings.h"
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
#include "qgsfeature.h"
#include <QObject>
#include <QtTest/QtTest>
class TestQgsComposerTable : public QObject
{
Q_OBJECT
public:
TestQgsComposerTable()
: mComposition( 0 )
, mComposerMap( 0 )
, mComposerTextTable( 0 )
, mMapSettings( 0 )
, mVectorLayer( 0 )
, mComposerAttributeTable( 0 )
{}
private slots:
void initTestCase();// will be called before the first testfunction is executed.
void cleanupTestCase();// will be called after the last testfunction was executed.
void init();// will be called before each testfunction is executed.
void cleanup();// will be called after every testfunction.
void textTableHeadings(); //test setting/retrieving text table headers
void textTableRows(); //test adding and retrieving text table rows
void attributeTableHeadings(); //test retrieving attribute table headers
void attributeTableRows(); //test retrieving attribute table rows
void attributeTableFilterFeatures(); //test filtering attribute table rows
void attributeTableSetAttributes(); //test subset of attributes in table
void attributeTableSetAliasOnSubset(); //test setting alias for attribute table with subset of attributes
void attributeTableAlias(); //test setting alias for attribute column
void attributeTableGetAlias(); //test getting alias map for attribute table
void attributeTableVisibleOnly(); //test displaying only visible attributes
void attributeTableSort(); //test sorting of attribute table
void attributeTableGetAttributes(); //test getting subset of attributes in table
private:
QgsComposition* mComposition;
QgsComposerMap* mComposerMap;
QgsComposerTextTable* mComposerTextTable;
QgsMapSettings *mMapSettings;
QgsVectorLayer* mVectorLayer;
QgsComposerAttributeTable* mComposerAttributeTable;
//compares rows in mComposerAttributeTable to expected rows
void compareTable( QList<QStringList> &expectedRows );
};
void TestQgsComposerTable::initTestCase()
{
QgsApplication::init();
QgsApplication::initQgis();
mMapSettings = new QgsMapSettings();
//create maplayers from testdata and add to layer registry
QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + '/' + "points.shp" );
mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(),
vectorFileInfo.completeBaseName(),
"ogr" );
//create composition with composer map
mMapSettings->setLayers( QStringList() << mVectorLayer->id() );
mMapSettings->setCrsTransformEnabled( false );
mComposition = new QgsComposition( *mMapSettings );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
mComposerTextTable = new QgsComposerTextTable( mComposition );
mComposition->addItem( mComposerTextTable );
mComposerAttributeTable = new QgsComposerAttributeTable( mComposition );
mComposition->addComposerTable( mComposerAttributeTable );
mComposerAttributeTable->setVectorLayer( mVectorLayer );
mComposerAttributeTable->setDisplayOnlyVisibleFeatures( false );
mComposerAttributeTable->setMaximumNumberOfFeatures( 10 );
}
void TestQgsComposerTable::cleanupTestCase()
{
delete mComposerMap;
delete mComposition;
delete mMapSettings;
QgsApplication::exitQgis();
}
void TestQgsComposerTable::init()
{
}
void TestQgsComposerTable::cleanup()
{
}
void TestQgsComposerTable::textTableHeadings()
{
//test setting/retrieving text table headers
QStringList headers;
headers << "1" << "2";
mComposerTextTable->setHeaderLabels( headers );
//call this twice, to test that headers are overwritten and not appended
headers.clear();
headers << "a" << "b" << "c";
mComposerTextTable->setHeaderLabels( headers );
//get header labels and compare
QMap<int, QString> headerMap = mComposerTextTable->headerLabels();
QMap<int, QString>::const_iterator headerIt = headerMap.constBegin();
int col = 0;
QString expected;
QString evaluated;
for ( ; headerIt != headerMap.constEnd(); ++headerIt )
{
col = headerIt.key();
evaluated = headerIt.value();
expected = headers.at( col );
QCOMPARE( evaluated, expected );
}
}
void TestQgsComposerTable::textTableRows()
{
//test adding and retrieving text table rows
//add some rows to the table
QList<QStringList> rows;
QStringList row;
row << "a1" << "b1" << "c1";
rows.append( row );
row.clear();
row << "a2" << "b2" << "c2";
rows.append( row );
row.clear();
row << "a3" << "b3" << "c3";
rows.append( row );
QList<QStringList>::const_iterator rowIt = rows.constBegin();
for ( ; rowIt != rows.constEnd(); ++rowIt )
{
mComposerTextTable->addRow( *rowIt );
}
//now retrieve rows and check
QList<QgsAttributeMap> evaluatedRows;
bool result = mComposerTextTable->getFeatureAttributes( evaluatedRows );
QCOMPARE( result, true );
QList<QgsAttributeMap>::const_iterator resultIt = evaluatedRows.constBegin();
int rowNumber = 0;
int colNumber = 0;
for ( ; resultIt != evaluatedRows.constEnd(); ++resultIt )
{
colNumber = 0;
QgsAttributeMap::const_iterator cellIt = ( *resultIt ).constBegin();
for ( ; cellIt != ( *resultIt ).constEnd(); ++cellIt )
{
QCOMPARE(( *cellIt ).toString(), rows.at( rowNumber ).at( colNumber ) );
colNumber++;
}
rowNumber++;
}
}
void TestQgsComposerTable::attributeTableHeadings()
{
//test retrieving attribute table headers
QStringList expectedHeaders;
expectedHeaders << "Class" << "Heading" << "Importance" << "Pilots" << "Cabin Crew" << "Staff";
//get header labels and compare
QMap<int, QString> headerMap = mComposerAttributeTable->headerLabels();
QMap<int, QString>::const_iterator headerIt = headerMap.constBegin();
QString expected;
QString evaluated;
for ( ; headerIt != headerMap.constEnd(); ++headerIt )
{
evaluated = headerIt.value();
expected = expectedHeaders.at( headerIt.key() );
QCOMPARE( evaluated, expected );
}
}
void TestQgsComposerTable::compareTable( QList<QStringList> &expectedRows )
{
//retrieve rows and check
QList<QgsAttributeMap> evaluatedRows;
bool result = mComposerAttributeTable->getFeatureAttributes( evaluatedRows );
QCOMPARE( result, true );
QList<QgsAttributeMap>::const_iterator resultIt = evaluatedRows.constBegin();
int rowNumber = 0;
int colNumber = 0;
//check that number of rows matches expected
QCOMPARE( evaluatedRows.count(), expectedRows.count() );
for ( ; resultIt != evaluatedRows.constEnd(); ++resultIt )
{
colNumber = 0;
QgsAttributeMap::const_iterator cellIt = ( *resultIt ).constBegin();
for ( ; cellIt != ( *resultIt ).constEnd(); ++cellIt )
{
QCOMPARE(( *cellIt ).toString(), expectedRows.at( rowNumber ).at( colNumber ) );
colNumber++;
}
//also check that number of columns matches expected
QCOMPARE(( *resultIt ).count(), expectedRows.at( rowNumber ).count() );
rowNumber++;
}
}
void TestQgsComposerTable::attributeTableRows()
{
//test retrieving attribute table rows
QList<QStringList> expectedRows;
QStringList row;
row << "Jet" << "90" << "3" << "2" << "0" << "2";
expectedRows.append( row );
row.clear();
row << "Biplane" << "0" << "1" << "3" << "3" << "6";
expectedRows.append( row );
row.clear();
row << "Jet" << "85" << "3" << "1" << "1" << "2";
expectedRows.append( row );
//retrieve rows and check
mComposerAttributeTable->setMaximumNumberOfFeatures( 3 );
compareTable( expectedRows );
}
void TestQgsComposerTable::attributeTableFilterFeatures()
{
//test filtering attribute table rows
mComposerAttributeTable->setMaximumNumberOfFeatures( 10 );
mComposerAttributeTable->setFeatureFilter( QString( "\"Class\"='B52'" ) );
mComposerAttributeTable->setFilterFeatures( true );
QList<QStringList> expectedRows;
QStringList row;
row << "B52" << "0" << "10" << "2" << "1" << "3";
expectedRows.append( row );
row.clear();
row << "B52" << "12" << "10" << "1" << "1" << "2";
expectedRows.append( row );
row.clear();
row << "B52" << "34" << "10" << "2" << "1" << "3";
expectedRows.append( row );
row.clear();
row << "B52" << "80" << "10" << "2" << "1" << "3";
expectedRows.append( row );
//retrieve rows and check
compareTable( expectedRows );
mComposerAttributeTable->setFilterFeatures( false );
}
void TestQgsComposerTable::attributeTableSetAttributes()
{
//test subset of attributes in table
QSet<int> attributes;
attributes << 0 << 3 << 4;
mComposerAttributeTable->setDisplayAttributes( attributes );
mComposerAttributeTable->setMaximumNumberOfFeatures( 3 );
//check headers
QStringList expectedHeaders;
expectedHeaders << "Class" << "Pilots" << "Cabin Crew";
//get header labels and compare
QMap<int, QString> headerMap = mComposerAttributeTable->headerLabels();
QMap<int, QString>::const_iterator headerIt = headerMap.constBegin();
QString expected;
QString evaluated;
for ( ; headerIt != headerMap.constEnd(); ++headerIt )
{
evaluated = headerIt.value();
expected = expectedHeaders.at( headerIt.key() );
QCOMPARE( evaluated, expected );
}
QList<QStringList> expectedRows;
QStringList row;
row << "Jet" << "2" << "0";
expectedRows.append( row );
row.clear();
row << "Biplane" << "3" << "3";
expectedRows.append( row );
row.clear();
row << "Jet" << "1" << "1";
expectedRows.append( row );
//retrieve rows and check
compareTable( expectedRows );
attributes.clear();
mComposerAttributeTable->setDisplayAttributes( attributes );
}
void TestQgsComposerTable::attributeTableSetAliasOnSubset()
{
//test setting alias for attribute table with subset of attributes
QStringList expectedHeaders;
expectedHeaders << "1Heading" << "2Pilots" << "3Cabin Crew";
QSet<int> attributes;
attributes << 1 << 3 << 4;
mComposerAttributeTable->setDisplayAttributes( attributes );
QMap<int, QString> aliases;
aliases.insert( 1, QString( "1Heading" ) );
aliases.insert( 3, QString( "2Pilots" ) );
aliases.insert( 4, QString( "3Cabin Crew" ) );
Q_NOWARN_DEPRECATED_PUSH
mComposerAttributeTable->setFieldAliasMap( aliases );
Q_NOWARN_DEPRECATED_POP
//get header labels and compare
QMap<int, QString> headerMap = mComposerAttributeTable->headerLabels();
QMap<int, QString>::const_iterator headerIt = headerMap.constBegin();
QString expected;
QString evaluated;
for ( ; headerIt != headerMap.constEnd(); ++headerIt )
{
evaluated = headerIt.value();
expected = expectedHeaders.at( headerIt.key() );
QCOMPARE( evaluated, expected );
}
attributes.clear();
aliases.clear();
mComposerAttributeTable->setDisplayAttributes( attributes );
Q_NOWARN_DEPRECATED_PUSH
mComposerAttributeTable->setFieldAliasMap( aliases );
Q_NOWARN_DEPRECATED_POP
}
void TestQgsComposerTable::attributeTableGetAttributes()
{
//test getting subset of attributes in table
QSet<int> attributes;
attributes << 0 << 3 << 4;
mComposerAttributeTable->setDisplayAttributes( attributes );
Q_NOWARN_DEPRECATED_PUSH
QSet<int> evaluated = mComposerAttributeTable->displayAttributes();
Q_NOWARN_DEPRECATED_POP
QCOMPARE( evaluated, attributes );
attributes.clear();
mComposerAttributeTable->setDisplayAttributes( attributes );
}
void TestQgsComposerTable::attributeTableAlias()
{
//test setting alias for attribute column
QMap<int, QString> fieldAliasMap;
fieldAliasMap.insert( 0, QString( "alias 0" ) );
fieldAliasMap.insert( 3, QString( "alias 3" ) );
Q_NOWARN_DEPRECATED_PUSH
mComposerAttributeTable->setFieldAliasMap( fieldAliasMap );
Q_NOWARN_DEPRECATED_POP
QStringList expectedHeaders;
expectedHeaders << "alias 0" << "Heading" << "Importance" << "alias 3" << "Cabin Crew" << "Staff";
//get header labels and compare
QMap<int, QString> headerMap = mComposerAttributeTable->headerLabels();
QMap<int, QString>::const_iterator headerIt = headerMap.constBegin();
QString expected;
QString evaluated;
for ( ; headerIt != headerMap.constEnd(); ++headerIt )
{
evaluated = headerIt.value();
expected = expectedHeaders.at( headerIt.key() );
QCOMPARE( evaluated, expected );
}
fieldAliasMap.clear();
Q_NOWARN_DEPRECATED_PUSH
mComposerAttributeTable->setFieldAliasMap( fieldAliasMap );
Q_NOWARN_DEPRECATED_POP
}
void TestQgsComposerTable::attributeTableGetAlias()
{
QSet<int> attributes;
attributes << 1 << 3 << 4;
mComposerAttributeTable->setDisplayAttributes( attributes );
//test getting alias map
QMap<int, QString> fieldAliasMap;
fieldAliasMap.insert( 1, QString( "alias 1" ) );
fieldAliasMap.insert( 2, QString( "alias 2" ) );
Q_NOWARN_DEPRECATED_PUSH
mComposerAttributeTable->setFieldAliasMap( fieldAliasMap );
Q_NOWARN_DEPRECATED_POP
QMap<int, QString> expectedAliases;
expectedAliases.insert( 1, QString( "alias 1" ) );
expectedAliases.insert( 3, QString( "Pilots" ) );
expectedAliases.insert( 4, QString( "Cabin Crew" ) );
//get header labels and compare
Q_NOWARN_DEPRECATED_PUSH
QMap<int, QString> aliasMap = mComposerAttributeTable->fieldAliasMap();
Q_NOWARN_DEPRECATED_POP
QMap<int, QString>::const_iterator aliasIt = aliasMap.constBegin();
QString expected;
QString evaluated;
for ( ; aliasIt != aliasMap.constEnd(); ++aliasIt )
{
evaluated = aliasIt.value();
expected = expectedAliases.value( aliasIt.key() );
QCOMPARE( evaluated, expected );
}
fieldAliasMap.clear();
Q_NOWARN_DEPRECATED_PUSH
mComposerAttributeTable->setFieldAliasMap( fieldAliasMap );
Q_NOWARN_DEPRECATED_POP
attributes.clear();
mComposerAttributeTable->setDisplayAttributes( attributes );
}
void TestQgsComposerTable::attributeTableSort()
{
//test sorting of attribute table
QList< QPair<int, bool> > sort;
sort.append( qMakePair( 0, true ) );
sort.append( qMakePair( 1, false ) );
sort.append( qMakePair( 3, true ) );
Q_NOWARN_DEPRECATED_PUSH
mComposerAttributeTable->setSortAttributes( sort );
Q_NOWARN_DEPRECATED_POP
mComposerAttributeTable->setMaximumNumberOfFeatures( 5 );
QList<QStringList> expectedRows;
QStringList row;
row << "Biplane" << "0" << "1" << "3" << "3" << "6";
expectedRows.append( row );
row.clear();
row << "Jet" << "95" << "3" << "1" << "1" << "2";
expectedRows.append( row );
row.clear();
row << "Jet" << "90" << "3" << "2" << "0" << "2";
expectedRows.append( row );
row.clear();
row << "Jet" << "90" << "3" << "1" << "0" << "1";
expectedRows.append( row );
row.clear();
row << "Jet" << "85" << "3" << "1" << "1" << "2";
expectedRows.append( row );
//retrieve rows and check
compareTable( expectedRows );
sort.clear();
Q_NOWARN_DEPRECATED_PUSH
mComposerAttributeTable->setSortAttributes( sort );
Q_NOWARN_DEPRECATED_POP
}
void TestQgsComposerTable::attributeTableVisibleOnly()
{
//test displaying only visible attributes
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
mComposerMap->setFrameEnabled( true );
mComposition->addComposerMap( mComposerMap );
mComposerMap->setNewExtent( QgsRectangle( -131.767, 30.558, -110.743, 41.070 ) );
mComposerAttributeTable->setComposerMap( mComposerMap );
mComposerAttributeTable->setDisplayOnlyVisibleFeatures( true );
QList<QStringList> expectedRows;
QStringList row;
row << "Jet" << "90" << "3" << "2" << "0" << "2";
expectedRows.append( row );
row.clear();
row << "Biplane" << "240" << "1" << "3" << "2" << "5";
expectedRows.append( row );
row.clear();
row << "Jet" << "180" << "3" << "1" << "0" << "1";
expectedRows.append( row );
//retrieve rows and check
compareTable( expectedRows );
mComposerAttributeTable->setDisplayOnlyVisibleFeatures( false );
mComposerAttributeTable->setComposerMap( 0 );
mComposition->removeItem( mComposerMap );
}
QTEST_MAIN( TestQgsComposerTable )
#include "testqgscomposertable.moc"

View File

@ -78,7 +78,7 @@ class TestQgsAtlasComposition(unittest.TestCase):
# an overview
mOverview = QgsComposerMap(self.mComposition, 180, 20, 50, 50)
mOverview.setFrameEnabled(True)
mOverview.setOverviewFrameMap(self.mAtlasMap.id())
mOverview.overview().setFrameMap(self.mAtlasMap.id())
self.mComposition.addComposerMap(mOverview)
nextent = QgsRectangle(49670.718, 6415139.086, 699672.519, 7065140.887)
mOverview.setNewExtent(nextent)
@ -86,7 +86,7 @@ class TestQgsAtlasComposition(unittest.TestCase):
# set the fill symbol of the overview map
props2 = {"color": "127,0,0,127"}
fillSymbol2 = QgsFillSymbol.createSimple(props2)
mOverview.setOverviewFrameMapSymbol(fillSymbol2)
mOverview.overview().setFrameSymbol(fillSymbol2)
# header label
self.mLabel1 = QgsComposerLabel(self.mComposition)
@ -112,7 +112,6 @@ class TestQgsAtlasComposition(unittest.TestCase):
self.filename_test()
self.autoscale_render_test()
self.autoscale_render_test_old_api()
self.fixedscale_render_test()
self.predefinedscales_render_test()
self.hidden_render_test()
@ -151,29 +150,6 @@ class TestQgsAtlasComposition(unittest.TestCase):
self.mAtlasMap.setAtlasScalingMode(QgsComposerMap.Fixed)
self.mAtlasMap.setAtlasMargin(0)
def autoscale_render_test_old_api(self):
self.mAtlas.setComposerMap(self.mAtlasMap)
self.mAtlas.setFixedScale(False)
self.mAtlas.setMargin(0.10)
self.mAtlas.beginRender()
for i in range(0, 2):
self.mAtlas.prepareForFeature(i)
self.mLabel1.adjustSizeToText()
checker = QgsCompositionChecker('atlas_autoscale_old_api%d' % (i + 1), self.mComposition)
checker.setControlPathPrefix("atlas")
myTestResult, myMessage = checker.testComposition(0, 200)
assert myTestResult
self.mAtlas.endRender()
self.mAtlas.setFixedScale(True)
self.mAtlas.setMargin(0)
self.mAtlas.setComposerMap(None)
self.mAtlasMap.setAtlasDriven(False)
def fixedscale_render_test(self):
self.mAtlasMap.setNewExtent(QgsRectangle(209838.166, 6528781.020, 610491.166, 6920530.620))
self.mAtlasMap.setAtlasDriven(True)

View File

@ -136,21 +136,5 @@ class TestQgsComposerHtml(unittest.TestCase):
assert myTestResult, myMessage
def testComposerHtmlAccessor(self):
"""Test that we can retrieve the ComposerHtml instance given an item.
"""
myComposition = QgsComposition(self.iface.mapCanvas().mapSettings())
mySubstitutionMap = {'replace-me': 'Foo bar'}
myFile = os.path.join(TEST_DATA_DIR, 'template.qpt')
with open(myFile, 'rt') as myTemplateFile:
myTemplateContent = myTemplateFile.read()
myDocument = QDomDocument()
myDocument.setContent(myTemplateContent)
myComposition.loadFromTemplate(myDocument, mySubstitutionMap)
myItem = myComposition.getComposerItemById('html-test')
myComposerHtml = myComposition.getComposerHtmlByItem(myItem)
myMessage = 'Could not retrieve the composer html given an item'
self.assertIsNotNone(myComposerHtml, myMessage)
if __name__ == '__main__':
unittest.main()

View File

@ -72,7 +72,7 @@ class TestQgsComposerMap(unittest.TestCase):
self.mComposerMap.setNewExtent(myRectangle)
myRectangle2 = QgsRectangle(0, -256, 256, 0)
overviewMap.setNewExtent(myRectangle2)
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
overviewMap.overview().setFrameMap(self.mComposerMap.id())
checker = QgsCompositionChecker('composermap_overview', self.mComposition)
checker.setControlPathPrefix("composer_mapoverview")
myTestResult, myMessage = checker.testComposition()
@ -88,8 +88,8 @@ class TestQgsComposerMap(unittest.TestCase):
self.mComposerMap.setNewExtent(myRectangle)
myRectangle2 = QgsRectangle(0, -256, 256, 0)
overviewMap.setNewExtent(myRectangle2)
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
overviewMap.setOverviewBlendMode(QPainter.CompositionMode_Multiply)
overviewMap.overview().setFrameMap(self.mComposerMap.id())
overviewMap.overview().setBlendMode(QPainter.CompositionMode_Multiply)
checker = QgsCompositionChecker('composermap_overview_blending', self.mComposition)
checker.setControlPathPrefix("composer_mapoverview")
myTestResult, myMessage = checker.testComposition()
@ -105,8 +105,8 @@ class TestQgsComposerMap(unittest.TestCase):
self.mComposerMap.setNewExtent(myRectangle)
myRectangle2 = QgsRectangle(0, -256, 256, 0)
overviewMap.setNewExtent(myRectangle2)
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
overviewMap.setOverviewInverted(True)
overviewMap.overview().setFrameMap(self.mComposerMap.id())
overviewMap.overview().setInverted(True)
checker = QgsCompositionChecker('composermap_overview_invert', self.mComposition)
checker.setControlPathPrefix("composer_mapoverview")
myTestResult, myMessage = checker.testComposition()
@ -122,9 +122,9 @@ class TestQgsComposerMap(unittest.TestCase):
self.mComposerMap.setNewExtent(myRectangle)
myRectangle2 = QgsRectangle(0, -256, 256, 0)
overviewMap.setNewExtent(myRectangle2)
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
overviewMap.setOverviewInverted(False)
overviewMap.setOverviewCentered(True)
overviewMap.overview().setFrameMap(self.mComposerMap.id())
overviewMap.overview().setInverted(False)
overviewMap.overview().setCentered(True)
checker = QgsCompositionChecker('composermap_overview_center', self.mComposition)
checker.setControlPathPrefix("composer_mapoverview")
myTestResult, myMessage = checker.testComposition()

View File

@ -63,9 +63,9 @@ class TestQgsComposerMap(unittest.TestCase):
self.mComposerMap.grid().setGridLineWidth(0.5)
self.mComposerMap.grid().setAnnotationFont(QgsFontUtils.getStandardTestFont())
self.mComposerMap.grid().setAnnotationPrecision(0)
self.mComposerMap.grid().setAnnotationPosition(QgsComposerMapGrid.Disabled, QgsComposerMapGrid.Left)
self.mComposerMap.grid().setAnnotationDisplay(QgsComposerMapGrid.HideAll, QgsComposerMapGrid.Left)
self.mComposerMap.grid().setAnnotationPosition(QgsComposerMapGrid.OutsideMapFrame, QgsComposerMapGrid.Right)
self.mComposerMap.grid().setAnnotationPosition(QgsComposerMapGrid.Disabled, QgsComposerMapGrid.Top)
self.mComposerMap.grid().setAnnotationDisplay(QgsComposerMapGrid.HideAll, QgsComposerMapGrid.Top)
self.mComposerMap.grid().setAnnotationPosition(QgsComposerMapGrid.OutsideMapFrame, QgsComposerMapGrid.Bottom)
self.mComposerMap.grid().setAnnotationDirection(QgsComposerMapGrid.Horizontal, QgsComposerMapGrid.Right)
self.mComposerMap.grid().setAnnotationDirection(QgsComposerMapGrid.Horizontal, QgsComposerMapGrid.Bottom)
@ -76,8 +76,8 @@ class TestQgsComposerMap(unittest.TestCase):
checker = QgsCompositionChecker('composermap_grid', self.mComposition)
checker.setControlPathPrefix("composer_mapgrid")
myTestResult, myMessage = checker.testComposition()
self.mComposerMap.setGridEnabled(False)
self.mComposerMap.setShowGridAnnotation(False)
self.mComposerMap.grid().setEnabled(False)
self.mComposerMap.grid().setAnnotationEnabled(False)
assert myTestResult, myMessage
@ -152,7 +152,7 @@ class TestQgsComposerMap(unittest.TestCase):
assert myTestResult, myMessage
def testZebraStyle(self):
self.mComposerMap.setGridFrameStyle(QgsComposerMap.Zebra)
self.mComposerMap.grid().setFrameStyle(QgsComposerMapGrid.Zebra)
myRectangle = QgsRectangle(785462.375, 3341423.125,
789262.375, 3343323.125)
self.mComposerMap.setNewExtent(myRectangle)
@ -177,7 +177,7 @@ class TestQgsComposerMap(unittest.TestCase):
assert myTestResult, myMessage
def testZebraStyleSides(self):
self.mComposerMap.setGridFrameStyle(QgsComposerMap.Zebra)
self.mComposerMap.grid().setFrameStyle(QgsComposerMapGrid.Zebra)
myRectangle = QgsRectangle(781662.375, 3339523.125, 793062.375, 3345223.125)
self.mComposerMap.setNewExtent(myRectangle)
self.mComposerMap.grid().setIntervalX(2000)
@ -223,7 +223,7 @@ class TestQgsComposerMap(unittest.TestCase):
self.mComposerMap.grid().setFrameStyle(QgsComposerMapGrid.NoFrame)
def testInteriorTicks(self):
self.mComposerMap.setGridFrameStyle(QgsComposerMap.Zebra)
self.mComposerMap.grid().setFrameStyle(QgsComposerMapGrid.Zebra)
myRectangle = QgsRectangle(781662.375, 3339523.125, 793062.375, 3345223.125)
self.mComposerMap.setNewExtent(myRectangle)
self.mComposerMap.grid().setIntervalX(2000)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB