Added merge printing.
This commit is contained in:
+11
-21
@@ -1,6 +1,6 @@
|
||||
/* ColorNode.cpp
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "ColorNode.h"
|
||||
|
||||
#include "MergeRecord.h"
|
||||
|
||||
|
||||
///
|
||||
/// Default Constructor
|
||||
@@ -158,40 +160,28 @@ uint32_t ColorNode::rgba( void ) const
|
||||
}
|
||||
|
||||
|
||||
#if TODO
|
||||
QColor ColorNode::expand( MergeRecord? record )
|
||||
QColor ColorNode::color( MergeRecord* record ) const
|
||||
{
|
||||
if ( fieldFlag )
|
||||
if ( mFieldFlag )
|
||||
{
|
||||
if ( record == null )
|
||||
if ( record == 0 )
|
||||
{
|
||||
return QColor.fromRgba(0x00000000);
|
||||
return mColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
string? text = record.evalKey( key );
|
||||
if ( text != null )
|
||||
if ( record->contains( mKey ) )
|
||||
{
|
||||
Gdk.Color gdkColor = Gdk.Color();
|
||||
if ( Gdk.Color.parse( text, out gdkColor ) )
|
||||
{
|
||||
Color color = Color.from_gdkColor( gdkColor );
|
||||
return color;
|
||||
return QColor( (*record)[ mKey ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
return Color.fromRgba(0x00000000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Color.fromRgba(0x00000000);
|
||||
return mColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return color;
|
||||
return mColor;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+4
-5
@@ -1,6 +1,6 @@
|
||||
/* ColorNode.h
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
@@ -25,6 +25,8 @@
|
||||
#include <QColor>
|
||||
#include <stdint.h>
|
||||
|
||||
class MergeRecord; // Forward reference
|
||||
|
||||
|
||||
///
|
||||
/// Color Node Type
|
||||
@@ -87,10 +89,7 @@ public:
|
||||
/////////////////////////////////
|
||||
public:
|
||||
uint32_t rgba( void ) const;
|
||||
|
||||
#if TODO
|
||||
QColor expand( MergeRecord? record );
|
||||
#endif
|
||||
QColor color( MergeRecord* record ) const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
@@ -68,11 +68,9 @@ LabelModelBoxObject* LabelModelBoxObject::clone() const
|
||||
///
|
||||
void LabelModelBoxObject::drawShadow( QPainter* painter, bool inEditor, MergeRecord* record ) const
|
||||
{
|
||||
/// TODO expand colors based on record
|
||||
|
||||
QColor lineColor = mLineColorNode.color();
|
||||
QColor fillColor = mFillColorNode.color();
|
||||
QColor shadowColor = mShadowColorNode.color();
|
||||
QColor lineColor = mLineColorNode.color( record );
|
||||
QColor fillColor = mFillColorNode.color( record );
|
||||
QColor shadowColor = mShadowColorNode.color( record );
|
||||
|
||||
shadowColor.setAlphaF( mShadowOpacity );
|
||||
|
||||
@@ -115,10 +113,8 @@ void LabelModelBoxObject::drawShadow( QPainter* painter, bool inEditor, MergeRec
|
||||
///
|
||||
void LabelModelBoxObject::drawObject( QPainter* painter, bool inEditor, MergeRecord* record ) const
|
||||
{
|
||||
/// TODO expand colors based on record
|
||||
|
||||
QColor lineColor = mLineColorNode.color();
|
||||
QColor fillColor = mFillColorNode.color();
|
||||
QColor lineColor = mLineColorNode.color( record );
|
||||
QColor fillColor = mFillColorNode.color( record );
|
||||
|
||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||
painter->setBrush( fillColor );
|
||||
|
||||
+20
-1
@@ -1,6 +1,6 @@
|
||||
/* Merge.cpp
|
||||
*
|
||||
* Copyright (C) 2015 Jim Evins <evins@snaught.com>
|
||||
* Copyright (C) 2015-2016 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
@@ -165,6 +165,25 @@ void Merge::unselectAll()
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Return count of selected records
|
||||
///
|
||||
int Merge::nSelectedRecords() const
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
foreach ( MergeRecord* record, mRecordList )
|
||||
{
|
||||
if ( record->isSelected() )
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Return list of selected records
|
||||
///
|
||||
|
||||
+3
-1
@@ -1,6 +1,6 @@
|
||||
/* Merge.h
|
||||
*
|
||||
* Copyright (C) 2015 Jim Evins <evins@snaught.com>
|
||||
* Copyright (C) 2015-2016 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
@@ -73,6 +73,8 @@ public:
|
||||
void setSelected( int i, bool state = true );
|
||||
void selectAll();
|
||||
void unselectAll();
|
||||
|
||||
int nSelectedRecords() const;
|
||||
const QList<MergeRecord*> selectedRecords() const;
|
||||
|
||||
|
||||
|
||||
+65
-16
@@ -1,6 +1,6 @@
|
||||
/* PageRenderer.cpp
|
||||
*
|
||||
* Copyright (C) 2013-2014 Jim Evins <evins@snaught.com>
|
||||
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "PageRenderer.h"
|
||||
|
||||
#include "LabelModel.h"
|
||||
#include "Merge.h"
|
||||
#include "MergeNone.h"
|
||||
#include "MergeRecord.h"
|
||||
|
||||
#include <QPainter>
|
||||
@@ -37,9 +39,9 @@ namespace
|
||||
|
||||
|
||||
PageRenderer::PageRenderer()
|
||||
: mModel(0), mNLabels(0), mStartLabel(0),
|
||||
: mModel(0), mNCopies(0), mStartLabel(0),
|
||||
mPrintOutlines(false), mPrintCropMarks(false), mPrintReverse(false),
|
||||
mIPage(0), mNPages(0)
|
||||
mIsMerge(false), mIPage(0), mNPages(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -47,15 +49,17 @@ PageRenderer::PageRenderer()
|
||||
void PageRenderer::setModel( const LabelModel* model )
|
||||
{
|
||||
mModel = model;
|
||||
mMerge = mModel->merge();
|
||||
mOrigins = mModel->frame()->getOrigins();
|
||||
mNLabelsPerPage = mModel->frame()->nLabels();
|
||||
mIsMerge = ( dynamic_cast<const MergeNone*>(mMerge) == 0 );
|
||||
updateNPages();
|
||||
}
|
||||
|
||||
|
||||
void PageRenderer::setNLabels( int nLabels )
|
||||
void PageRenderer::setNCopies( int nCopies )
|
||||
{
|
||||
mNLabels = nLabels;
|
||||
mNCopies = nCopies;
|
||||
updateNPages();
|
||||
}
|
||||
|
||||
@@ -114,12 +118,17 @@ void PageRenderer::updateNPages()
|
||||
{
|
||||
if ( mModel )
|
||||
{
|
||||
/// @TODO merge case
|
||||
if ( mIsMerge )
|
||||
{
|
||||
mLastLabel = mStartLabel + mNCopies*mMerge->nSelectedRecords();
|
||||
}
|
||||
else
|
||||
{
|
||||
mLastLabel = mStartLabel + mNCopies;
|
||||
}
|
||||
|
||||
int lastLabel = mStartLabel + mNLabels;
|
||||
|
||||
mNPages = lastLabel / mNLabelsPerPage;
|
||||
if ( lastLabel % mNLabelsPerPage )
|
||||
mNPages = mLastLabel / mNLabelsPerPage;
|
||||
if ( mLastLabel % mNLabelsPerPage )
|
||||
{
|
||||
mNPages++;
|
||||
}
|
||||
@@ -147,10 +156,15 @@ void PageRenderer::printPage( QPainter* painter, int iPage ) const
|
||||
{
|
||||
if ( mModel )
|
||||
{
|
||||
/// @TODO merge case
|
||||
|
||||
if ( mIsMerge )
|
||||
{
|
||||
printMergePage( painter, iPage );
|
||||
}
|
||||
else
|
||||
{
|
||||
printSimplePage( painter, iPage );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,10 +178,9 @@ void PageRenderer::printSimplePage( QPainter* painter, int iPage ) const
|
||||
iStart = mStartLabel;
|
||||
}
|
||||
|
||||
int lastLabel = mStartLabel + mNLabels;
|
||||
if ( (lastLabel / mNLabelsPerPage) == iPage )
|
||||
if ( (mLastLabel / mNLabelsPerPage) == iPage )
|
||||
{
|
||||
iEnd = lastLabel % mNLabelsPerPage;
|
||||
iEnd = mLastLabel % mNLabelsPerPage;
|
||||
}
|
||||
|
||||
printCropMarks( painter );
|
||||
@@ -194,7 +207,43 @@ void PageRenderer::printSimplePage( QPainter* painter, int iPage ) const
|
||||
|
||||
void PageRenderer::printMergePage( QPainter* painter, int iPage ) const
|
||||
{
|
||||
/// @TODO merge case
|
||||
int iStart = 0;
|
||||
int iEnd = mNLabelsPerPage;
|
||||
|
||||
if ( iPage == 0 )
|
||||
{
|
||||
iStart = mStartLabel;
|
||||
}
|
||||
|
||||
if ( (mLastLabel / mNLabelsPerPage) == iPage )
|
||||
{
|
||||
iEnd = mLastLabel % mNLabelsPerPage;
|
||||
}
|
||||
|
||||
const QList<MergeRecord*> records = mMerge->selectedRecords();
|
||||
int iRecord = (iPage*mNLabelsPerPage + iStart - mStartLabel) % records.size();
|
||||
|
||||
printCropMarks( painter );
|
||||
|
||||
for ( int i = iStart; i < iEnd; i++ )
|
||||
{
|
||||
painter->save();
|
||||
|
||||
painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() );
|
||||
|
||||
painter->save();
|
||||
|
||||
clipLabel( painter );
|
||||
printLabel( painter, records[iRecord] );
|
||||
|
||||
painter->restore(); // From before clip
|
||||
|
||||
printOutline( painter );
|
||||
|
||||
painter->restore(); // From before translation
|
||||
|
||||
iRecord = (iRecord + 1) % records.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+11
-8
@@ -27,12 +27,11 @@
|
||||
#include <QVector>
|
||||
#include <QRect>
|
||||
|
||||
|
||||
class QPainter; // Forward reference
|
||||
|
||||
|
||||
class LabelModel; // Forward reference
|
||||
class MergeRecord; // Forward reference
|
||||
// Forward references
|
||||
class QPainter;
|
||||
class LabelModel;
|
||||
class Merge;
|
||||
class MergeRecord;
|
||||
|
||||
|
||||
///
|
||||
@@ -52,7 +51,7 @@ public:
|
||||
/////////////////////////////////
|
||||
public:
|
||||
void setModel( const LabelModel* model );
|
||||
void setNLabels( int nLabels );
|
||||
void setNCopies( int nCopies );
|
||||
void setStartLabel( int startLabel );
|
||||
void setPrintOutlines( bool printOutlinesFlag );
|
||||
void setPrintCropMarks( bool printCropMarksFlag );
|
||||
@@ -82,13 +81,17 @@ private:
|
||||
/////////////////////////////////
|
||||
private:
|
||||
const LabelModel* mModel;
|
||||
int mNLabels;
|
||||
const Merge* mMerge;
|
||||
|
||||
int mNCopies;
|
||||
int mStartLabel;
|
||||
int mLastLabel;
|
||||
bool mPrintOutlines;
|
||||
bool mPrintCropMarks;
|
||||
bool mPrintReverse;
|
||||
int mIPage;
|
||||
|
||||
bool mIsMerge;
|
||||
int mNPages;
|
||||
int mNLabelsPerPage;
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ void PrintView::onLabelSizeChanged()
|
||||
copiesToSpin->setRange( copiesFromSpin->value(), nLabelsPerPage );
|
||||
if ( copiesSheetsRadio->isChecked() )
|
||||
{
|
||||
mRenderer.setNLabels( copiesSheetsSpin->value()*nLabelsPerPage );
|
||||
mRenderer.setNCopies( copiesSheetsSpin->value()*nLabelsPerPage );
|
||||
mRenderer.setStartLabel( 0 );
|
||||
copiesFromSpin->setValue( 1 );
|
||||
copiesToSpin->setValue( nLabelsPerPage );
|
||||
@@ -113,14 +113,14 @@ void PrintView::onFormChanged()
|
||||
// TODO select between simple and merge
|
||||
if ( copiesSheetsRadio->isChecked() )
|
||||
{
|
||||
mRenderer.setNLabels( copiesSheetsSpin->value()*nLabelsPerPage );
|
||||
mRenderer.setNCopies( copiesSheetsSpin->value()*nLabelsPerPage );
|
||||
mRenderer.setStartLabel( 0 );
|
||||
copiesFromSpin->setValue( 1 );
|
||||
copiesToSpin->setValue( nLabelsPerPage );
|
||||
}
|
||||
else
|
||||
{
|
||||
mRenderer.setNLabels( copiesToSpin->value() - copiesFromSpin->value() + 1 );
|
||||
mRenderer.setNCopies( copiesToSpin->value() - copiesFromSpin->value() + 1 );
|
||||
mRenderer.setStartLabel( copiesFromSpin->value() - 1 );
|
||||
copiesSheetsSpin->setValue( 1 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user