Remove legacy class QgsComposerLegendItem and subclasses

This commit is contained in:
Martin Dobias 2016-12-12 02:36:15 +08:00
parent 57ff36bc01
commit 3efc28d07b
21 changed files with 4 additions and 931 deletions

View File

@ -236,6 +236,7 @@ All the functionality from the old QgsColorDialog has been moved to the new clas
- QgsComposerAttributeTable and associated classes (eg QgsComposerAttributeTableCompare,
QgsComposerAttributeTableColumnModel, QgsComposerTableSortColumnsProxyModel) were removed.
Use QgsComposerAttributeTableV2 instead.
- QgsComposerLegendItem and subclasses were removed (QgsComposerSymbolItem, QgsComposerRasterSymbolItem, QgsComposerLayerItem, QgsComposerGroupItem, QgsComposerStyleItem).
- QgsComposerTable was removed. Use QgsComposerAttributeTableV2 instead.
- ComposerTextTable was removed. Use ComposerTextTableV2 instead.
- QgsCRSCache was removed. QgsCoordinateReferenceSystem now internally uses a cache for CRS creation,

View File

@ -1,134 +0,0 @@
class QgsComposerLegendItem : QStandardItem
{
%TypeHeaderCode
#include <qgscomposerlegenditem.h>
%End
public:
QgsComposerLegendItem();
QgsComposerLegendItem( const QString& text );
QgsComposerLegendItem( const QIcon& icon, const QString& text );
virtual ~QgsComposerLegendItem();
enum ItemType
{
GroupItem = QStandardItem::UserType,
LayerItem,
SymbologyV2Item,
RasterSymbolItem,
StyleItem
};
virtual void writeXml( QDomElement& elem, QDomDocument& doc ) const = 0;
/** Read item content from xml
@param itemElem item to read from
@param xServerAvailable Read item icons if true (QIcon needs x-server)*/
virtual void readXml( const QDomElement& itemElem, bool xServerAvailable = true ) = 0;
virtual ItemType itemType() const = 0;
virtual QStandardItem* clone() const = 0;
QgsComposerLegendStyle::Style style() const;
void setStyle( QgsComposerLegendStyle::Style style );
// Get text defined by user
virtual QString userText() const;
// Set text defined by user
virtual void setUserText( const QString & text );
protected:
void writeXmlChildren( QDomElement& elem, QDomDocument& doc ) const;
};
class QgsComposerSymbolItem: QgsComposerLegendItem
{
%TypeHeaderCode
#include <qgscomposerlegenditem.h>
%End
public:
QgsComposerSymbolItem();
QgsComposerSymbolItem( const QString& text );
QgsComposerSymbolItem( const QIcon& icon, const QString& text );
virtual ~QgsComposerSymbolItem();
virtual QStandardItem* clone() const /Factory/;
virtual void writeXml( QDomElement& elem, QDomDocument& doc ) const;
virtual void readXml( const QDomElement& itemElem, bool xServerAvailable = true );
/** Set symbol (takes ownership)*/
void setSymbol( QgsSymbol* s /Transfer/ );
QgsSymbol* symbol();
ItemType itemType() const;
};
class QgsComposerRasterSymbolItem : QgsComposerLegendItem
{
%TypeHeaderCode
#include <qgscomposerlegenditem.h>
%End
public:
QgsComposerRasterSymbolItem();
QgsComposerRasterSymbolItem( const QString& text );
QgsComposerRasterSymbolItem( const QIcon& icon, const QString& text );
virtual ~QgsComposerRasterSymbolItem();
virtual QStandardItem* clone() const /Factory/;
virtual void writeXml( QDomElement& elem, QDomDocument& doc ) const;
virtual void readXml( const QDomElement& itemElem, bool xServerAvailable = true );
ItemType itemType() const;
void setLayerId( const QString& id );
QString layerId() const;
void setColor( const QColor& c );
QColor color() const;
};
class QgsComposerLayerItem : QgsComposerLegendItem
{
%TypeHeaderCode
#include <qgscomposerlegenditem.h>
%End
public:
QgsComposerLayerItem();
QgsComposerLayerItem( const QString& text );
virtual ~QgsComposerLayerItem();
virtual QStandardItem* clone() const /Factory/;
virtual void writeXml( QDomElement& elem, QDomDocument& doc ) const;
virtual void readXml( const QDomElement& itemElem, bool xServerAvailable = true );
ItemType itemType() const;
void setLayerId( const QString& id );
QString layerId() const;
void setShowFeatureCount( bool show );
bool showFeatureCount() const;
void setDefaultStyle( double scaleDenominator = -1, const QString& rule = "" );
};
class QgsComposerGroupItem : QgsComposerLegendItem
{
%TypeHeaderCode
#include <qgscomposerlegenditem.h>
%End
public:
QgsComposerGroupItem();
QgsComposerGroupItem( const QString& text );
virtual ~QgsComposerGroupItem();
virtual QStandardItem* clone() const /Factory/;
virtual void writeXml( QDomElement& elem, QDomDocument& doc ) const;
virtual void readXml( const QDomElement& itemElem, bool xServerAvailable = true );
ItemType itemType() const;
};

View File

@ -191,7 +191,6 @@
%Include composer/qgscomposeritemgroup.sip
%Include composer/qgscomposerlabel.sip
%Include composer/qgscomposerlegend.sip
%Include composer/qgscomposerlegenditem.sip
%Include composer/qgscomposerlegendstyle.sip
%Include composer/qgscomposermap.sip
%Include composer/qgscomposermapgrid.sip

View File

@ -145,7 +145,6 @@ SET(QGIS_APP_SRCS
composer/qgscomposerpolygonwidget.cpp
composer/qgscomposerpolylinewidget.cpp
composer/qgscomposertablebackgroundcolorsdialog.cpp
composer/qgscomposerlegenditemdialog.cpp
composer/qgscomposerlegendlayersdialog.cpp
composer/qgscomposerlegendwidget.cpp
composer/qgscompositionwidget.cpp
@ -308,7 +307,6 @@ SET (QGIS_APP_MOC_HDRS
composer/qgscomposeritemwidget.h
composer/qgscomposerlabelwidget.h
composer/qgscomposerlegendwidget.h
composer/qgscomposerlegenditemdialog.h
composer/qgscomposerlegendlayersdialog.h
composer/qgscomposermanager.h
composer/qgscomposermapgridwidget.h

View File

@ -1,44 +0,0 @@
/***************************************************************************
qgscomposerlegenditemdialog.cpp
-------------------------------
begin : July 2008
copyright : (C) 2008 by Marco Hugentobler
email : marco dot hugentobler at karto dot baug dot ethz dot ch
***************************************************************************/
/***************************************************************************
* *
* 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 "qgscomposerlegenditemdialog.h"
#include <QStandardItem>
QgsComposerLegendItemDialog::QgsComposerLegendItemDialog( const QStandardItem* item, QWidget* parent ): QDialog( parent )
{
setupUi( this );
if ( item )
{
mItemTextLineEdit->setText( item->text() );
}
}
QgsComposerLegendItemDialog::QgsComposerLegendItemDialog(): QDialog( nullptr )
{
}
QgsComposerLegendItemDialog::~QgsComposerLegendItemDialog()
{
}
QString QgsComposerLegendItemDialog::itemText() const
{
return mItemTextLineEdit->text();
}

View File

@ -1,44 +0,0 @@
/***************************************************************************
qgscomposerlegenditemdialog.h
-----------------------------
begin : July 2008
copyright : (C) 2008 by Marco Hugentobler
email : marco dot hugentobler at karto dot baug dot ethz dot ch
***************************************************************************/
/***************************************************************************
* *
* 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 QGSCOMPOSERLEGENDITEMDIALOG_H
#define QGSCOMPOSERLEGENDITEMDIALOG_H
#include <QDialog>
#include "ui_qgscomposerlegenditemdialogbase.h"
class QStandardItem;
/** \ingroup app
* A dialog to enter properties of composer legend items (currently only item text)
* */
class QgsComposerLegendItemDialog: public QDialog, private Ui::QgsComposerLegendItemDialogBase
{
Q_OBJECT
public:
QgsComposerLegendItemDialog( const QStandardItem* item, QWidget* parent = nullptr );
~QgsComposerLegendItemDialog();
//! Returns the item text inserted by user
QString itemText() const;
private:
QgsComposerLegendItemDialog(); //forbidden
};
#endif //QGSCOMPOSERLEGENDITEMDIALOG_H

View File

@ -38,4 +38,4 @@ class QgsComposerLegendLayersDialog: public QDialog, private Ui::QgsComposerLege
QMap<QListWidgetItem*, QgsMapLayer*> mItemLayerMap;
};
#endif //QGSCOMPOSERLEGENDITEMDIALOG_H
#endif //QGSCOMPOSERLEGENDLAYERSDIALOG_H

View File

@ -17,8 +17,6 @@
#include "qgscomposerlegendwidget.h"
#include "qgscomposerlegend.h"
#include "qgscomposerlegenditem.h"
#include "qgscomposerlegenditemdialog.h"
#include "qgscomposerlegendlayersdialog.h"
#include "qgscomposeritemwidget.h"
#include "qgscomposermap.h"

View File

@ -256,7 +256,6 @@ SET(QGIS_CORE_SRCS
composer/qgscomposeritemgroup.cpp
composer/qgscomposerlabel.cpp
composer/qgscomposerlegend.cpp
composer/qgscomposerlegenditem.cpp
composer/qgscomposerlegendstyle.cpp
composer/qgscomposermap.cpp
composer/qgscomposermapgrid.cpp
@ -769,7 +768,6 @@ SET(QGIS_CORE_HDRS
composer/qgscomposerarrow.h
composer/qgscomposerframe.h
composer/qgscomposeritemcommand.h
composer/qgscomposerlegenditem.h
composer/qgscomposerlegendstyle.h
composer/qgscomposermultiframecommand.h
composer/qgscomposertexttable.h

View File

@ -18,7 +18,6 @@
#include "qgscomposerlegendstyle.h"
#include "qgscomposerlegend.h"
#include "qgscomposerlegenditem.h"
#include "qgscomposermap.h"
#include "qgscomposition.h"
#include "qgscomposermodel.h"

View File

@ -24,8 +24,6 @@
class QgsLayerTreeModel;
class QgsSymbol;
class QgsComposerGroupItem;
class QgsComposerLayerItem;
class QgsComposerMap;
class QgsLegendRenderer;

View File

@ -1,409 +0,0 @@
/***************************************************************************
qgscomposerlegenditem.cpp - description
-------------------------
begin : May 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************/
/***************************************************************************
* *
* 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 "qgscomposerlegendstyle.h"
#include "qgscomposerlegenditem.h"
#include "qgscomposerlegend.h"
#include "qgsproject.h"
#include "qgsrasterlayer.h"
#include "qgsrenderer.h"
#include "qgssymbol.h"
#include "qgssymbollayerutils.h"
#include "qgsvectorlayer.h"
#include "qgsapplication.h"
#include <QDomDocument>
#include <QDomElement>
QgsComposerLegendItem::QgsComposerLegendItem( QgsComposerLegendStyle::Style s ): QStandardItem()
, mStyle( s )
{
}
QgsComposerLegendItem::QgsComposerLegendItem( const QString& text, QgsComposerLegendStyle::Style s ): QStandardItem( text )
, mStyle( s )
{
}
QgsComposerLegendItem::QgsComposerLegendItem( const QIcon& icon, const QString& text, QgsComposerLegendStyle::Style s ): QStandardItem( icon, text )
, mStyle( s )
{
}
QgsComposerLegendItem::~QgsComposerLegendItem()
{
}
void QgsComposerLegendItem::writeXmlChildren( QDomElement& elem, QDomDocument& doc ) const
{
int numRows = rowCount();
QgsComposerLegendItem* currentItem = nullptr;
for ( int i = 0; i < numRows; ++i )
{
currentItem = dynamic_cast<QgsComposerLegendItem*>( child( i, 0 ) );
if ( currentItem )
{
currentItem->writeXml( elem, doc );
}
}
}
////////////////QgsComposerSymbolItem
QgsComposerSymbolItem::QgsComposerSymbolItem(): QgsComposerLegendItem( QgsComposerLegendStyle::Symbol ), mSymbol( nullptr )
{
}
QgsComposerSymbolItem::QgsComposerSymbolItem( const QString& text ): QgsComposerLegendItem( text, QgsComposerLegendStyle::Symbol ), mSymbol( nullptr )
{
}
QgsComposerSymbolItem::QgsComposerSymbolItem( const QIcon& icon, const QString& text ): QgsComposerLegendItem( icon, text, QgsComposerLegendStyle::Symbol ), mSymbol( nullptr )
{
}
QgsComposerSymbolItem::~QgsComposerSymbolItem()
{
delete mSymbol;
}
QStandardItem* QgsComposerSymbolItem::clone() const
{
QgsComposerSymbolItem* cloneItem = new QgsComposerSymbolItem();
*cloneItem = *this;
if ( mSymbol )
{
cloneItem->setSymbol( mSymbol->clone() );
}
return cloneItem;
}
void QgsComposerSymbolItem::writeXml( QDomElement& elem, QDomDocument& doc ) const
{
QDomElement vectorClassElem = doc.createElement( QStringLiteral( "VectorClassificationItemNg" ) );
if ( mSymbol )
{
QgsSymbolMap saveSymbolMap;
saveSymbolMap.insert( QStringLiteral( "classificationSymbol" ), mSymbol );
QDomElement symbolsElem = QgsSymbolLayerUtils::saveSymbols( saveSymbolMap, QStringLiteral( "symbols" ), doc );
vectorClassElem.appendChild( symbolsElem );
}
vectorClassElem.setAttribute( QStringLiteral( "text" ), text() );
vectorClassElem.setAttribute( QStringLiteral( "userText" ), userText() );
elem.appendChild( vectorClassElem );
}
void QgsComposerSymbolItem::readXml( const QDomElement& itemElem, bool xServerAvailable )
{
if ( itemElem.isNull() )
{
return;
}
setText( itemElem.attribute( QStringLiteral( "text" ), QLatin1String( "" ) ) );
setUserText( itemElem.attribute( QStringLiteral( "userText" ), QLatin1String( "" ) ) );
QDomElement symbolsElem = itemElem.firstChildElement( QStringLiteral( "symbols" ) );
if ( !symbolsElem.isNull() )
{
QgsSymbolMap loadSymbolMap = QgsSymbolLayerUtils::loadSymbols( symbolsElem );
//we assume there is only one symbol in the map...
QgsSymbolMap::iterator mapIt = loadSymbolMap.begin();
if ( mapIt != loadSymbolMap.end() )
{
QgsSymbol* symbolNg = mapIt.value();
if ( symbolNg )
{
setSymbol( symbolNg );
if ( xServerAvailable )
{
setIcon( QgsSymbolLayerUtils::symbolPreviewIcon( symbolNg, QSize( 30, 30 ) ) );
}
}
}
}
}
void QgsComposerSymbolItem::setSymbol( QgsSymbol* s )
{
delete mSymbol;
mSymbol = s;
}
////////////////////QgsComposerRasterSymbolItem
QgsComposerRasterSymbolItem::QgsComposerRasterSymbolItem(): QgsComposerLegendItem( QgsComposerLegendStyle::Symbol )
{
}
QgsComposerRasterSymbolItem::QgsComposerRasterSymbolItem( const QString& text ): QgsComposerLegendItem( text, QgsComposerLegendStyle::Symbol )
{
}
QgsComposerRasterSymbolItem::QgsComposerRasterSymbolItem( const QIcon& icon, const QString& text ): QgsComposerLegendItem( icon, text, QgsComposerLegendStyle::Symbol )
{
}
QgsComposerRasterSymbolItem::~QgsComposerRasterSymbolItem()
{
}
QStandardItem* QgsComposerRasterSymbolItem::clone() const
{
QgsComposerRasterSymbolItem* cloneItem = new QgsComposerRasterSymbolItem();
*cloneItem = *this;
cloneItem->setLayerId( mLayerID );
return cloneItem;
}
void QgsComposerRasterSymbolItem::writeXml( QDomElement& elem, QDomDocument& doc ) const
{
QDomElement rasterClassElem = doc.createElement( QStringLiteral( "RasterClassificationItem" ) );
rasterClassElem.setAttribute( QStringLiteral( "layerId" ), mLayerID );
rasterClassElem.setAttribute( QStringLiteral( "text" ), text() );
rasterClassElem.setAttribute( QStringLiteral( "userText" ), userText() );
rasterClassElem.setAttribute( QStringLiteral( "color" ), mColor.name() );
elem.appendChild( rasterClassElem );
}
void QgsComposerRasterSymbolItem::readXml( const QDomElement& itemElem, bool xServerAvailable )
{
if ( itemElem.isNull() )
{
return;
}
setText( itemElem.attribute( QStringLiteral( "text" ), QLatin1String( "" ) ) );
setUserText( itemElem.attribute( QStringLiteral( "userText" ), QLatin1String( "" ) ) );
setLayerId( itemElem.attribute( QStringLiteral( "layerId" ), QLatin1String( "" ) ) );
setColor( QColor( itemElem.attribute( QStringLiteral( "color" ) ) ) );
if ( xServerAvailable )
{
QPixmap itemPixmap( 20, 20 );
itemPixmap.fill( mColor );
setIcon( QIcon( itemPixmap ) );
}
}
////////////////////QgsComposerLayerItem
QgsComposerLayerItem::QgsComposerLayerItem(): QgsComposerLegendItem( QgsComposerLegendStyle::Subgroup )
, mShowFeatureCount( false )
{
}
QgsComposerLayerItem::QgsComposerLayerItem( const QString& text ): QgsComposerLegendItem( text, QgsComposerLegendStyle::Subgroup )
, mShowFeatureCount( false )
{
}
QgsComposerLayerItem::~QgsComposerLayerItem()
{
}
QStandardItem* QgsComposerLayerItem::clone() const
{
QgsComposerLayerItem* cloneItem = new QgsComposerLayerItem();
*cloneItem = *this;
cloneItem->setLayerId( mLayerID );
return cloneItem;
}
void QgsComposerLayerItem::writeXml( QDomElement& elem, QDomDocument& doc ) const
{
QDomElement layerItemElem = doc.createElement( QStringLiteral( "LayerItem" ) );
layerItemElem.setAttribute( QStringLiteral( "layerId" ), mLayerID );
layerItemElem.setAttribute( QStringLiteral( "text" ), text() );
layerItemElem.setAttribute( QStringLiteral( "userText" ), userText() );
layerItemElem.setAttribute( QStringLiteral( "showFeatureCount" ), showFeatureCount() );
layerItemElem.setAttribute( QStringLiteral( "style" ), QgsComposerLegendStyle::styleName( mStyle ) );
writeXmlChildren( layerItemElem, doc );
elem.appendChild( layerItemElem );
}
void QgsComposerLayerItem::readXml( const QDomElement& itemElem, bool xServerAvailable )
{
if ( itemElem.isNull() )
{
return;
}
setText( itemElem.attribute( QStringLiteral( "text" ), QLatin1String( "" ) ) );
setUserText( itemElem.attribute( QStringLiteral( "userText" ), QLatin1String( "" ) ) );
setLayerId( itemElem.attribute( QStringLiteral( "layerId" ), QLatin1String( "" ) ) );
setShowFeatureCount( itemElem.attribute( QStringLiteral( "showFeatureCount" ), QLatin1String( "" ) ) == QLatin1String( "1" ) ? true : false );
setStyle( QgsComposerLegendStyle::styleFromName( itemElem.attribute( QStringLiteral( "style" ), QStringLiteral( "subgroup" ) ) ) );
//now call readXml for all the child items
QDomNodeList childList = itemElem.childNodes();
QDomNode currentNode;
QDomElement currentElem;
QgsComposerLegendItem* currentChildItem = nullptr;
int nChildItems = childList.count();
for ( int i = 0; i < nChildItems; ++i )
{
currentNode = childList.at( i );
if ( !currentNode.isElement() )
{
continue;
}
currentElem = currentNode.toElement();
QString elemTag = currentElem.tagName();
if ( elemTag == QLatin1String( "VectorClassificationItem" ) )
{
continue; // legacy - unsupported
}
else if ( elemTag == QLatin1String( "VectorClassificationItemNg" ) )
{
currentChildItem = new QgsComposerSymbolItem();
}
else if ( elemTag == QLatin1String( "RasterClassificationItem" ) )
{
currentChildItem = new QgsComposerRasterSymbolItem();
}
else
{
continue; //unsupported child type
}
currentChildItem->readXml( currentElem, xServerAvailable );
appendRow( currentChildItem );
}
}
void QgsComposerLayerItem::setDefaultStyle( double scaleDenominator, const QString& rule )
{
// set default style according to number of symbols
QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer*>( QgsProject::instance()->mapLayer( layerId() ) );
if ( vLayer )
{
QgsFeatureRenderer* renderer = vLayer->renderer();
if ( renderer )
{
QPair<QString, QgsSymbol*> symbolItem = renderer->legendSymbolItems( scaleDenominator, rule ).value( 0 );
if ( renderer->legendSymbolItems( scaleDenominator, rule ).size() > 1 || !symbolItem.first.isEmpty() )
{
setStyle( QgsComposerLegendStyle::Subgroup );
}
else
{
// Hide title by default for single symbol
setStyle( QgsComposerLegendStyle::Hidden );
}
}
}
}
////////////////////QgsComposerGroupItem
QgsComposerGroupItem::QgsComposerGroupItem(): QgsComposerLegendItem( QgsComposerLegendStyle::Group )
{
}
QgsComposerGroupItem::QgsComposerGroupItem( const QString& text ): QgsComposerLegendItem( text, QgsComposerLegendStyle::Group )
{
}
QgsComposerGroupItem::~QgsComposerGroupItem()
{
}
QStandardItem* QgsComposerGroupItem::clone() const
{
QgsComposerGroupItem* cloneItem = new QgsComposerGroupItem();
*cloneItem = *this;
return cloneItem;
}
void QgsComposerGroupItem::writeXml( QDomElement& elem, QDomDocument& doc ) const
{
QDomElement layerGroupElem = doc.createElement( QStringLiteral( "GroupItem" ) );
// text is always user text, but for forward compatibility for now write both
layerGroupElem.setAttribute( QStringLiteral( "text" ), text() );
layerGroupElem.setAttribute( QStringLiteral( "userText" ), userText() );
layerGroupElem.setAttribute( QStringLiteral( "style" ), QgsComposerLegendStyle::styleName( mStyle ) );
writeXmlChildren( layerGroupElem, doc );
elem.appendChild( layerGroupElem );
}
void QgsComposerGroupItem::readXml( const QDomElement& itemElem, bool xServerAvailable )
{
if ( itemElem.isNull() )
{
return;
}
// text is always user text but for backward compatibility we read also text
QString userText = itemElem.attribute( QStringLiteral( "userText" ), QLatin1String( "" ) );
if ( userText.isEmpty() )
{
userText = itemElem.attribute( QStringLiteral( "text" ), QLatin1String( "" ) );
}
setText( userText );
setUserText( userText );
setStyle( QgsComposerLegendStyle::styleFromName( itemElem.attribute( QStringLiteral( "style" ), QStringLiteral( "group" ) ) ) );
//now call readXml for all the child items
QDomNodeList childList = itemElem.childNodes();
QDomNode currentNode;
QDomElement currentElem;
QgsComposerLegendItem* currentChildItem = nullptr;
int nChildItems = childList.count();
for ( int i = 0; i < nChildItems; ++i )
{
currentNode = childList.at( i );
if ( !currentNode.isElement() )
{
continue;
}
currentElem = currentNode.toElement();
QString elemTag = currentElem.tagName();
if ( elemTag == QLatin1String( "GroupItem" ) )
{
currentChildItem = new QgsComposerGroupItem();
}
else if ( elemTag == QLatin1String( "LayerItem" ) )
{
currentChildItem = new QgsComposerLayerItem();
}
else
{
continue; //unsupported child item type
}
currentChildItem->readXml( currentElem, xServerAvailable );
QList<QStandardItem *> itemsList;
itemsList << currentChildItem << new QgsComposerStyleItem( currentChildItem );
appendRow( itemsList );
}
}
QgsComposerStyleItem::QgsComposerStyleItem(): QStandardItem()
{
}
QgsComposerStyleItem::QgsComposerStyleItem( QgsComposerLegendItem *item ): QStandardItem()
{
setData( QgsComposerLegendStyle::styleLabel( item->style() ), Qt::DisplayRole );
}
QgsComposerStyleItem::~QgsComposerStyleItem()
{
}

View File

@ -1,197 +0,0 @@
/***************************************************************************
qgscomposerlegenditem.h - description
------------------------
begin : May 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************/
/***************************************************************************
* *
* 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 QGSCOMPOSERLEGENDITEM_H
#define QGSCOMPOSERLEGENDITEM_H
#include "qgscomposerlegendstyle.h"
#include <QStandardItem>
class QDomDocument;
class QDomElement;
/** \ingroup core
* Abstract base class for the legend item types
*/
class CORE_EXPORT QgsComposerLegendItem: public QStandardItem
{
public:
QgsComposerLegendItem( QgsComposerLegendStyle::Style s = QgsComposerLegendStyle::Undefined );
QgsComposerLegendItem( const QString& text, QgsComposerLegendStyle::Style s = QgsComposerLegendStyle::Undefined );
QgsComposerLegendItem( const QIcon& icon, const QString& text, QgsComposerLegendStyle::Style s = QgsComposerLegendStyle::Undefined );
virtual ~QgsComposerLegendItem();
enum ItemType
{
GroupItem = QStandardItem::UserType,
LayerItem,
SymbologyV2Item,
RasterSymbolItem,
StyleItem
};
virtual void writeXml( QDomElement& elem, QDomDocument& doc ) const = 0;
/** Read item content from xml
@param itemElem item to read from
@param xServerAvailable Read item icons if true (QIcon needs x-server)*/
virtual void readXml( const QDomElement& itemElem, bool xServerAvailable = true ) = 0;
virtual ItemType itemType() const = 0;
virtual QStandardItem* clone() const override = 0;
QgsComposerLegendStyle::Style style() const { return mStyle; }
void setStyle( QgsComposerLegendStyle::Style style ) { mStyle = style; }
// Get text defined by user
virtual QString userText() const { return mUserText; }
// Set text defined by user
virtual void setUserText( const QString & text ) { mUserText = text; }
protected:
void writeXmlChildren( QDomElement& elem, QDomDocument& doc ) const;
QgsComposerLegendStyle::Style mStyle;
// User defined text
QString mUserText;
};
class QgsSymbol;
/** \ingroup core
* \class QgsComposerSymbolItem
*/
class CORE_EXPORT QgsComposerSymbolItem: public QgsComposerLegendItem
{
public:
QgsComposerSymbolItem();
QgsComposerSymbolItem( const QString& text );
QgsComposerSymbolItem( const QIcon& icon, const QString& text );
virtual ~QgsComposerSymbolItem();
virtual QStandardItem* clone() const override;
virtual void writeXml( QDomElement& elem, QDomDocument& doc ) const override;
virtual void readXml( const QDomElement& itemElem, bool xServerAvailable = true ) override;
//! Set symbol (takes ownership)
void setSymbol( QgsSymbol* s );
QgsSymbol* symbol() {return mSymbol;}
ItemType itemType() const override { return SymbologyV2Item; }
private:
QgsSymbol* mSymbol;
};
/** \ingroup core
* \class QgsComposerRasterSymbolItem
*/
class CORE_EXPORT QgsComposerRasterSymbolItem : public QgsComposerLegendItem
{
public:
QgsComposerRasterSymbolItem();
QgsComposerRasterSymbolItem( const QString& text );
QgsComposerRasterSymbolItem( const QIcon& icon, const QString& text );
virtual ~QgsComposerRasterSymbolItem();
virtual QStandardItem* clone() const override;
virtual void writeXml( QDomElement& elem, QDomDocument& doc ) const override;
virtual void readXml( const QDomElement& itemElem, bool xServerAvailable = true ) override;
void setLayerId( const QString& id ) { mLayerID = id; }
QString layerId() const { return mLayerID; }
ItemType itemType() const override { return RasterSymbolItem; }
void setColor( const QColor& c ) { mColor = c; }
QColor color() const { return mColor; }
private:
QString mLayerID;
QColor mColor;
};
/** \ingroup core
* \class QgsComposerLayerItem
*/
class CORE_EXPORT QgsComposerLayerItem : public QgsComposerLegendItem
{
public:
QgsComposerLayerItem();
QgsComposerLayerItem( const QString& text );
virtual ~QgsComposerLayerItem();
virtual QStandardItem* clone() const override;
virtual void writeXml( QDomElement& elem, QDomDocument& doc ) const override;
virtual void readXml( const QDomElement& itemElem, bool xServerAvailable = true ) override;
ItemType itemType() const override { return LayerItem; }
/**
* Sets the associated layer ID.
* @see layerId()
*/
void setLayerId( const QString& id ) { mLayerID = id; }
/**
* Returns the ID of the associated layer.
* @see setLayerId()
*/
QString layerId() const { return mLayerID; }
void setShowFeatureCount( bool show ) { mShowFeatureCount = show; }
bool showFeatureCount() const { return mShowFeatureCount; }
void setDefaultStyle( double scaleDenominator = -1, const QString& rule = "" );
private:
QString mLayerID;
// Show vector feature counts
bool mShowFeatureCount;
};
/** \ingroup core
* \class QgsComposerGroupItem
*/
class CORE_EXPORT QgsComposerGroupItem: public QgsComposerLegendItem
{
public:
QgsComposerGroupItem();
QgsComposerGroupItem( const QString& text );
virtual ~QgsComposerGroupItem();
virtual QStandardItem* clone() const override;
virtual void writeXml( QDomElement& elem, QDomDocument& doc ) const override;
virtual void readXml( const QDomElement& itemElem, bool xServerAvailable = true ) override;
ItemType itemType() const override { return GroupItem; }
};
/** \ingroup core
* \class QgsComposerStyleItem
*/
class CORE_EXPORT QgsComposerStyleItem: public QStandardItem
{
public:
QgsComposerStyleItem();
QgsComposerStyleItem( QgsComposerLegendItem *item );
~QgsComposerStyleItem();
};
#endif // QGSCOMPOSERLEGENDITEM_H

View File

@ -15,7 +15,7 @@
#include "qgslegendrenderer.h"
#include "qgscomposerlegenditem.h"
#include "qgscomposerlegendstyle.h"
#include "qgslayertree.h"
#include "qgslayertreemodel.h"
#include "qgslayertreemodellegendnode.h"

View File

@ -66,8 +66,7 @@ class CORE_EXPORT QgsLegendRenderer
private:
/** Nucleon is either group title, layer title or layer child item.
* Nucleon is similar to QgsComposerLegendItem but it does not have
* the same hierarchy. E.g. layer title nucleon is just title, it does not
* E.g. layer title nucleon is just title, it does not
* include all layer subitems, the same with groups.
*/
class Nucleon

View File

@ -23,8 +23,6 @@ class QRectF;
#include "qgscomposerlegendstyle.h"
class QgsComposerLegendItem;
/** \ingroup core
* @brief The QgsLegendSettings class stores the appearance and layout settings

View File

@ -32,7 +32,6 @@
#include "qgsvectorlayer.h"
#include "qgsmapserviceexception.h"
#include "qgssymbol.h"
#include "qgscomposerlegenditem.h"
#include "qgsrequesthandler.h"
#include "qgsogcutils.h"
#include "qgsaccesscontrol.h"

View File

@ -28,8 +28,6 @@
#include "qgswfsprojectparser.h"
class QgsCoordinateReferenceSystem;
class QgsComposerLayerItem;
class QgsComposerLegendItem;
class QgsComposition;
class QgsFields;
class QgsMapLayer;

View File

@ -28,8 +28,6 @@
class QgsCapabilitiesCache;
class QgsCoordinateReferenceSystem;
class QgsComposerLayerItem;
class QgsComposerLegendItem;
class QgsComposition;
class QgsConfigParser;
class QgsFeature;

View File

@ -1,81 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QgsComposerLegendItemDialogBase</class>
<widget class="QDialog" name="QgsComposerLegendItemDialogBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>360</width>
<height>91</height>
</rect>
</property>
<property name="windowTitle">
<string>Legend item properties</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="mItemTextLabel">
<property name="text">
<string>Item text</string>
</property>
<property name="buddy">
<cstring>mItemTextLineEdit</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="mItemTextLineEdit"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>mItemTextLineEdit</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QgsComposerLegendItemDialogBase</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>257</x>
<y>76</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QgsComposerLegendItemDialogBase</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>325</x>
<y>76</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -18,7 +18,6 @@
#include "qgsapplication.h"
#include "qgscategorizedsymbolrenderer.h"
#include "qgscomposerlegenditem.h"
#include "qgsfontutils.h"
#include "qgslayertree.h"
#include "qgslayertreeutils.h"