Skip to content
Permalink
Browse files

[georef] Allow report to flow onto multiple pages to show all

GCPs (fix #4602)
  • Loading branch information
nyalldawson committed Jun 21, 2015
1 parent 0912314 commit f037b11f8e99633b0b5ec953e688d9232a5429f1
@@ -8,7 +8,11 @@ class QgsComposerTableColumn: QObject
%End
public:

QgsComposerTableColumn();
/** Constructor for QgsComposerTableColumn.
* @param heading column heading
*/
QgsComposerTableColumn( const QString& heading = QString() );

virtual ~QgsComposerTableColumn();

/**Writes the column's properties to xml for storage.
@@ -46,3 +46,41 @@ class QgsComposerTextTable: QgsComposerTable
*/
// bool getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps );
};



/**A text table item that reads text from string lists
* @note added in QGIS 2.10
*/
class QgsComposerTextTableV2 : QgsComposerTableV2
{

%TypeHeaderCode
#include <qgscomposertexttable.h>
%End

public:
QgsComposerTextTableV2( QgsComposition* c /TransferThis/, bool createUndoCommands );
~QgsComposerTextTableV2();

/** 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 co ntains more strings then the number
* of columns in the table then these extra strings will be ignored.
* @note if adding many rows, @link setContents @endlink is much faster
*/
void addRow( const QStringList& row );

/** Sets the contents of the text table.
* @param contents list of table rows
* @see addRow
*/
void setContents( const QList< QStringList >& contents );

bool getTableContents( QgsComposerTableContents &contents );

virtual void addFrame( QgsComposerFrame* frame, bool recalcFrameSizes = true );

};

@@ -433,6 +433,7 @@ SET(QGIS_CORE_MOC_HDRS
composer/qgscomposertable.h
composer/qgscomposertablev2.h
composer/qgscomposertablecolumn.h
composer/qgscomposertexttable.h
composer/qgscomposerhtml.h
composer/qgscomposermultiframe.h
composer/qgscomposereffect.h
@@ -17,16 +17,18 @@

#include "qgscomposertablecolumn.h"

QgsComposerTableColumn::QgsComposerTableColumn() :
QgsComposerTableColumn::QgsComposerTableColumn( const QString& heading ) :
mBackgroundColor( Qt::transparent ),
mHAlignment( Qt::AlignLeft ),
mHeading( heading ),
mSortByRank( 0 ),
mSortOrder( Qt::AscendingOrder ),
mWidth( 0.0 )
{

}


QgsComposerTableColumn::~QgsComposerTableColumn()
{

@@ -30,7 +30,11 @@ class CORE_EXPORT QgsComposerTableColumn: public QObject

public:

QgsComposerTableColumn();
/** Constructor for QgsComposerTableColumn.
* @param heading column heading
*/
QgsComposerTableColumn( const QString& heading = QString() );

virtual ~QgsComposerTableColumn();

/**Writes the column's properties to xml for storage.
@@ -265,9 +265,6 @@ void QgsComposerTableV2::render( QPainter *p, const QRectF &renderExtent, const
return;
}

//calculate which rows to show in this frame
QPair< int, int > rowsToShow = rowRange( renderExtent, frameIndex );

if ( mComposition->plotStyle() == QgsComposition::Print ||
mComposition->plotStyle() == QgsComposition::Postscript )
{
@@ -276,6 +273,9 @@ void QgsComposerTableV2::render( QPainter *p, const QRectF &renderExtent, const
refreshAttributes();
}

//calculate which rows to show in this frame
QPair< int, int > rowsToShow = rowRange( renderExtent, frameIndex );

double gridSize = mShowGrid ? mGridStrokeWidth : 0;
QList<QgsComposerTableColumn*>::const_iterator columnIt = mColumns.constBegin();

@@ -17,6 +17,7 @@

#include "qgscomposertexttable.h"
#include "qgscomposertablecolumn.h"
#include "qgscomposerframe.h"

QgsComposerTextTable::QgsComposerTextTable( QgsComposition* c ): QgsComposerTable( c )
{
@@ -84,3 +85,72 @@ bool QgsComposerTextTable::getFeatureAttributes( QList<QgsAttributeMap>& attribu

return true;
}


QgsComposerTextTableV2::QgsComposerTextTableV2( QgsComposition* c, bool createUndoCommands )
: QgsComposerTableV2( c, createUndoCommands )
{

}

QgsComposerTextTableV2::~QgsComposerTextTableV2()
{

}

void QgsComposerTextTableV2::addRow( const QStringList& row )
{
mRowText.append( row );
refreshAttributes();
}

void QgsComposerTextTableV2::setContents( const QList<QStringList>& contents )
{
mRowText = contents;
refreshAttributes();
}

bool QgsComposerTextTableV2::getTableContents( QgsComposerTableContents& contents )
{
contents.clear();

QList< QStringList >::const_iterator rowIt = mRowText.constBegin();
for ( ; rowIt != mRowText.constEnd(); ++rowIt )
{
QgsComposerTableRow currentRow;

for ( int i = 0; i < mColumns.count(); ++i )
{
if ( i < ( *rowIt ).count() )
{
currentRow << ( *rowIt ).at( i );
}
else
{
currentRow << QString();
}
}
contents << currentRow;
}

recalculateTableSize();
return true;
}

void QgsComposerTextTableV2::addFrame( QgsComposerFrame* frame, bool recalcFrameSizes )
{
mFrameItems.push_back( frame );
connect( frame, SIGNAL( sizeChanged() ), this, SLOT( recalculateFrameSizes() ) );

if ( mComposition )
{
//TODO - if QgsComposerTextTableV2 gains a UI, this will need a dedicated add method
//added to QgsComposition
mComposition->addItem( frame );
}

if ( recalcFrameSizes )
{
recalculateFrameSizes();
}
}
@@ -19,6 +19,7 @@
#define QGSCOMPOSERTEXTTABLE_H

#include "qgscomposertable.h"
#include "qgscomposertablev2.h"

/**A text table item that reads text from string lists*/
class CORE_EXPORT QgsComposerTextTable: public QgsComposerTable
@@ -70,4 +71,40 @@ class CORE_EXPORT QgsComposerTextTable: public QgsComposerTable
QList< QStringList > mRowText;
};

/**A text table item that reads text from string lists
* @note added in QGIS 2.10
*/
class CORE_EXPORT QgsComposerTextTableV2 : public QgsComposerTableV2
{

Q_OBJECT

public:
QgsComposerTextTableV2( QgsComposition* c, bool createUndoCommands );
~QgsComposerTextTableV2();

/** 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.
* @note if adding many rows, @link setContents @endlink is much faster
*/
void addRow( const QStringList& row );

/** Sets the contents of the text table.
* @param contents list of table rows
* @see addRow
*/
void setContents( const QList< QStringList >& contents );

bool getTableContents( QgsComposerTableContents &contents ) override;

virtual void addFrame( QgsComposerFrame* frame, bool recalcFrameSizes = true ) override;

private:
/**One stringlist per row*/
QList< QStringList > mRowText;
};

#endif // QGSCOMPOSERTEXTTABLE_H

0 comments on commit f037b11

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