Skip to content

Commit

Permalink
[georef] Allow report to flow onto multiple pages to show all
Browse files Browse the repository at this point in the history
GCPs (fix #4602)
  • Loading branch information
nyalldawson committed Jun 22, 2015
1 parent 0912314 commit f037b11
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 41 deletions.
6 changes: 5 additions & 1 deletion python/core/composer/qgscomposertablecolumn.sip
Expand Up @@ -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.
Expand Down
38 changes: 38 additions & 0 deletions python/core/composer/qgscomposertexttable.sip
Expand Up @@ -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 );

};

1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/core/composer/qgscomposertablecolumn.cpp
Expand Up @@ -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()
{

Expand Down
6 changes: 5 additions & 1 deletion src/core/composer/qgscomposertablecolumn.h
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/core/composer/qgscomposertablev2.cpp
Expand Up @@ -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 )
{
Expand All @@ -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();

Expand Down
70 changes: 70 additions & 0 deletions src/core/composer/qgscomposertexttable.cpp
Expand Up @@ -17,6 +17,7 @@

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

QgsComposerTextTable::QgsComposerTextTable( QgsComposition* c ): QgsComposerTable( c )
{
Expand Down Expand Up @@ -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();
}
}
37 changes: 37 additions & 0 deletions src/core/composer/qgscomposertexttable.h
Expand Up @@ -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
Expand Down Expand Up @@ -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.