mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[composer] Fix new frames not inheriting outline color, clean up item api a bit
This commit is contained in:
parent
7a389f634e
commit
a5b5bd4c45
@ -269,26 +269,47 @@ class QgsComposerItem : QgsComposerObject, QGraphicsRectItem
|
||||
* @see setFrameEnabled
|
||||
* @see frameOutlineWidth
|
||||
* @see frameJoinStyle
|
||||
* @see frameOutlineColor
|
||||
*/
|
||||
bool hasFrame() const;
|
||||
|
||||
/**Set whether this item has a frame drawn around it or not.
|
||||
* @param drawFrame draw frame
|
||||
* @returns nothing
|
||||
* @note introduced in 1.8
|
||||
* @see hasFrame
|
||||
* @see setFrameOutlineWidth
|
||||
* @see setFrameJoinStyle
|
||||
* @see setFrameOutlineColor
|
||||
*/
|
||||
void setFrameEnabled( const bool drawFrame );
|
||||
|
||||
/**Sets frame outline color
|
||||
* @param color new color for outline frame
|
||||
* @note introduced in 2.6
|
||||
* @see frameOutlineColor
|
||||
* @see setFrameEnabled
|
||||
* @see setFrameJoinStyle
|
||||
* @see setFrameOutlineWidth
|
||||
*/
|
||||
virtual void setFrameOutlineColor( const QColor& color );
|
||||
|
||||
/**Returns the frame's outline color. Only used if hasFrame is true.
|
||||
* @returns frame outline color
|
||||
* @note introduced in 2.6
|
||||
* @see hasFrame
|
||||
* @see setFrameOutlineColor
|
||||
* @see frameJoinStyle
|
||||
* @see setFrameOutlineColor
|
||||
*/
|
||||
QColor frameOutlineColor() const;
|
||||
|
||||
/**Sets frame outline width
|
||||
* @param outlineWidth new width for outline frame
|
||||
* @returns nothing
|
||||
* @note introduced in 2.2
|
||||
* @see frameOutlineWidth
|
||||
* @see setFrameEnabled
|
||||
* @see setFrameJoinStyle
|
||||
* @see setFrameOutlineColor
|
||||
*/
|
||||
virtual void setFrameOutlineWidth( const double outlineWidth );
|
||||
|
||||
@ -298,6 +319,7 @@ class QgsComposerItem : QgsComposerObject, QGraphicsRectItem
|
||||
* @see hasFrame
|
||||
* @see setFrameOutlineWidth
|
||||
* @see frameJoinStyle
|
||||
* @see frameOutlineColor
|
||||
*/
|
||||
double frameOutlineWidth() const;
|
||||
|
||||
@ -307,16 +329,17 @@ class QgsComposerItem : QgsComposerObject, QGraphicsRectItem
|
||||
* @see hasFrame
|
||||
* @see setFrameJoinStyle
|
||||
* @see frameOutlineWidth
|
||||
* @see frameOutlineColor
|
||||
*/
|
||||
Qt::PenJoinStyle frameJoinStyle() const;
|
||||
|
||||
/**Sets join style used when drawing the item's frame
|
||||
* @param style Join style for outline frame
|
||||
* @returns nothing
|
||||
* @note introduced in 2.3
|
||||
* @see setFrameEnabled
|
||||
* @see frameJoinStyle
|
||||
* @see setFrameOutlineWidth
|
||||
* @see setFrameOutlineColor
|
||||
*/
|
||||
void setFrameJoinStyle( const Qt::PenJoinStyle style );
|
||||
|
||||
|
@ -191,13 +191,6 @@ void QgsComposerItemWidget::showFrameGroup( bool showGroup )
|
||||
}
|
||||
|
||||
//slots
|
||||
void QgsComposerItemWidget::on_mFrameColorButton_clicked()
|
||||
{
|
||||
if ( !mItem )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void QgsComposerItemWidget::on_mFrameColorButton_colorChanged( const QColor& newFrameColor )
|
||||
{
|
||||
@ -206,10 +199,7 @@ void QgsComposerItemWidget::on_mFrameColorButton_colorChanged( const QColor& new
|
||||
return;
|
||||
}
|
||||
mItem->beginCommand( tr( "Frame color changed" ) );
|
||||
QPen thePen = mItem->pen();
|
||||
thePen.setColor( newFrameColor );
|
||||
|
||||
mItem->setPen( thePen );
|
||||
mItem->setFrameOutlineColor( newFrameColor );
|
||||
mItem->update();
|
||||
mItem->endCommand();
|
||||
}
|
||||
@ -486,8 +476,8 @@ void QgsComposerItemWidget::setValuesForGuiNonPositionElements()
|
||||
mItemRotationSpinBox->blockSignals( true );
|
||||
mExcludeFromPrintsCheckBox->blockSignals( true );
|
||||
|
||||
mBackgroundColorButton->setColor( mItem->brush().color() );
|
||||
mFrameColorButton->setColor( mItem->pen().color() );
|
||||
mBackgroundColorButton->setColor( mItem->backgroundColor() );
|
||||
mFrameColorButton->setColor( mItem->frameOutlineColor() );
|
||||
mOutlineWidthSpinBox->setValue( mItem->frameOutlineWidth() );
|
||||
mFrameJoinStyleCombo->setPenJoinStyle( mItem->frameJoinStyle() );
|
||||
mItemIdLineEdit->setText( mItem->id() );
|
||||
|
@ -73,7 +73,7 @@ class QgsComposerItemWidget: public QgsComposerItemBaseWidget, private Ui::QgsCo
|
||||
void showFrameGroup( bool showGroup );
|
||||
|
||||
public slots:
|
||||
void on_mFrameColorButton_clicked();
|
||||
|
||||
/** Set the frame color
|
||||
* @note added in 1.9
|
||||
*/
|
||||
|
13
src/core/composer/qgscomposeritem.cpp
Executable file → Normal file
13
src/core/composer/qgscomposeritem.cpp
Executable file → Normal file
@ -422,6 +422,19 @@ void QgsComposerItem::setFrameEnabled( const bool drawFrame )
|
||||
emit frameChanged();
|
||||
}
|
||||
|
||||
void QgsComposerItem::setFrameOutlineColor( const QColor &color )
|
||||
{
|
||||
QPen itemPen = pen();
|
||||
if ( itemPen.color() == color )
|
||||
{
|
||||
//no change
|
||||
return;
|
||||
}
|
||||
itemPen.setColor( color );
|
||||
setPen( itemPen );
|
||||
emit frameChanged();
|
||||
}
|
||||
|
||||
void QgsComposerItem::setFrameOutlineWidth( const double outlineWidth )
|
||||
{
|
||||
QPen itemPen = pen();
|
||||
|
@ -227,26 +227,47 @@ class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRec
|
||||
* @see setFrameEnabled
|
||||
* @see frameOutlineWidth
|
||||
* @see frameJoinStyle
|
||||
* @see frameOutlineColor
|
||||
*/
|
||||
bool hasFrame() const {return mFrame;}
|
||||
|
||||
/**Set whether this item has a frame drawn around it or not.
|
||||
* @param drawFrame draw frame
|
||||
* @returns nothing
|
||||
* @note introduced in 1.8
|
||||
* @see hasFrame
|
||||
* @see setFrameOutlineWidth
|
||||
* @see setFrameJoinStyle
|
||||
* @see setFrameOutlineColor
|
||||
*/
|
||||
void setFrameEnabled( const bool drawFrame );
|
||||
|
||||
/**Sets frame outline color
|
||||
* @param color new color for outline frame
|
||||
* @note introduced in 2.6
|
||||
* @see frameOutlineColor
|
||||
* @see setFrameEnabled
|
||||
* @see setFrameJoinStyle
|
||||
* @see setFrameOutlineWidth
|
||||
*/
|
||||
virtual void setFrameOutlineColor( const QColor& color );
|
||||
|
||||
/**Returns the frame's outline color. Only used if hasFrame is true.
|
||||
* @returns frame outline color
|
||||
* @note introduced in 2.6
|
||||
* @see hasFrame
|
||||
* @see setFrameOutlineColor
|
||||
* @see frameJoinStyle
|
||||
* @see setFrameOutlineColor
|
||||
*/
|
||||
QColor frameOutlineColor() const { return pen().color(); }
|
||||
|
||||
/**Sets frame outline width
|
||||
* @param outlineWidth new width for outline frame
|
||||
* @returns nothing
|
||||
* @note introduced in 2.2
|
||||
* @see frameOutlineWidth
|
||||
* @see setFrameEnabled
|
||||
* @see setFrameJoinStyle
|
||||
* @see setFrameOutlineColor
|
||||
*/
|
||||
virtual void setFrameOutlineWidth( const double outlineWidth );
|
||||
|
||||
@ -256,6 +277,7 @@ class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRec
|
||||
* @see hasFrame
|
||||
* @see setFrameOutlineWidth
|
||||
* @see frameJoinStyle
|
||||
* @see frameOutlineColor
|
||||
*/
|
||||
double frameOutlineWidth() const { return pen().widthF(); }
|
||||
|
||||
@ -265,16 +287,17 @@ class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRec
|
||||
* @see hasFrame
|
||||
* @see setFrameJoinStyle
|
||||
* @see frameOutlineWidth
|
||||
* @see frameOutlineColor
|
||||
*/
|
||||
Qt::PenJoinStyle frameJoinStyle() const { return mFrameJoinStyle; }
|
||||
|
||||
/**Sets join style used when drawing the item's frame
|
||||
* @param style Join style for outline frame
|
||||
* @returns nothing
|
||||
* @note introduced in 2.3
|
||||
* @see setFrameEnabled
|
||||
* @see frameJoinStyle
|
||||
* @see setFrameOutlineWidth
|
||||
* @see setFrameOutlineColor
|
||||
*/
|
||||
void setFrameJoinStyle( const Qt::PenJoinStyle style );
|
||||
|
||||
|
@ -211,9 +211,10 @@ QgsComposerFrame* QgsComposerMultiFrame::createNewFrame( QgsComposerFrame* curre
|
||||
newFrame->setBackgroundEnabled( currentFrame->hasBackground() );
|
||||
newFrame->setBlendMode( currentFrame->blendMode() );
|
||||
newFrame->setFrameEnabled( currentFrame->hasFrame() );
|
||||
newFrame->setFrameOutlineColor( currentFrame->frameOutlineColor() );
|
||||
newFrame->setFrameJoinStyle( currentFrame->frameJoinStyle() );
|
||||
newFrame->setFrameOutlineWidth( currentFrame->frameOutlineWidth() );
|
||||
newFrame->setOpacity( currentFrame->opacity() );
|
||||
newFrame->setTransparency( currentFrame->transparency() );
|
||||
newFrame->setHideBackgroundIfEmpty( currentFrame->hideBackgroundIfEmpty() );
|
||||
|
||||
addFrame( newFrame, false );
|
||||
|
@ -31,6 +31,7 @@ class TestQgsComposerMultiFrame: public QObject
|
||||
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 addFrame(); //test creating new frame inherits all properties of existing frame
|
||||
void frameIsEmpty(); //test if frame is empty works
|
||||
void addRemovePage(); //test if page is added and removed for RepeatUntilFinished mode
|
||||
|
||||
@ -72,6 +73,49 @@ void TestQgsComposerMultiFrame::cleanup()
|
||||
|
||||
}
|
||||
|
||||
void TestQgsComposerMultiFrame::addFrame()
|
||||
{
|
||||
QgsComposerHtml* htmlItem = new QgsComposerHtml( mComposition, false );
|
||||
QgsComposerFrame* frame1 = new QgsComposerFrame( mComposition, htmlItem, 0, 0, 100, 200 );
|
||||
|
||||
//should not be inherited
|
||||
frame1->setHidePageIfEmpty( true );
|
||||
|
||||
//should be inherited
|
||||
frame1->setHideBackgroundIfEmpty( true );
|
||||
frame1->setFrameOutlineWidth( 5.0 );
|
||||
frame1->setFrameJoinStyle( Qt::RoundJoin );
|
||||
frame1->setFrameEnabled( true );
|
||||
frame1->setFrameOutlineColor( QColor( Qt::red ) );
|
||||
frame1->setBackgroundEnabled( true );
|
||||
frame1->setBackgroundColor( QColor( Qt::green ) );
|
||||
frame1->setBlendMode( QPainter::CompositionMode_ColorBurn );
|
||||
frame1->setTransparency( 50 );
|
||||
|
||||
QgsComposerFrame* frame2 = htmlItem->createNewFrame( frame1, QPointF( 50, 55 ), QSizeF( 70, 120 ) );
|
||||
|
||||
//check frame created in correct place
|
||||
QCOMPARE( frame2->rect().height(), 120.0 );
|
||||
QCOMPARE( frame2->rect().width(), 70.0 );
|
||||
QCOMPARE( frame2->scenePos().x(), 50.0 );
|
||||
QCOMPARE( frame2->scenePos().y(), 55.0 );
|
||||
|
||||
//check frame properties
|
||||
QCOMPARE( frame2->frameOutlineWidth(), frame1->frameOutlineWidth() );
|
||||
QCOMPARE( frame2->frameOutlineColor(), frame1->frameOutlineColor() );
|
||||
QCOMPARE( frame2->frameJoinStyle(), frame1->frameJoinStyle() );
|
||||
QCOMPARE( frame2->hasBackground(), frame1->hasBackground() );
|
||||
QCOMPARE( frame2->backgroundColor(), frame1->backgroundColor() );
|
||||
QCOMPARE( frame2->blendMode(), frame1->blendMode() );
|
||||
QCOMPARE( frame2->transparency(), frame1->transparency() );
|
||||
|
||||
//check non-inherited properties
|
||||
QVERIFY( !frame2->hidePageIfEmpty() );
|
||||
|
||||
mComposition->removeMultiFrame( htmlItem );
|
||||
delete htmlItem;
|
||||
}
|
||||
|
||||
void TestQgsComposerMultiFrame::frameIsEmpty()
|
||||
{
|
||||
QgsComposerHtml* htmlItem = new QgsComposerHtml( mComposition, false );
|
||||
|
Loading…
x
Reference in New Issue
Block a user