Skip to content
Permalink
Browse files

Fix deprecation warnings and update unit tests

  • Loading branch information
nyalldawson committed Jul 10, 2020
1 parent b449361 commit 54c5e7ee9a5a6f5167c683974adc61e880b195bf
Showing with 58 additions and 177 deletions.
  1. +6 −42 src/gui/layout/qgslayoutmanualtablewidget.cpp
  2. +0 −2 src/gui/layout/qgslayoutmanualtablewidget.h
  3. +8 −94 src/ui/layout/qgslayoutmanualtablewidgetbase.ui
  4. +8 −5 tests/src/core/testqgslayoutmanualtable.cpp
  5. +36 −34 tests/src/core/testqgslayouttable.cpp
  6. BIN ...es/composer_table/expected_composerattributetable_align/expected_composerattributetable_align.png
  7. BIN ...ble/expected_composerattributetable_autowrap/default/expected_composerattributetable_autowrap.png
  8. BIN ...poser_table/expected_composerattributetable_autowrap/expected_composerattributetable_autowrap.png
  9. BIN ...able/expected_composerattributetable_autowrap/fedora/expected_composerattributetable_autowrap.png
  10. BIN ...ser_table/expected_composerattributetable_cellstyle/expected_composerattributetable_cellstyle.png
  11. BIN ...able/expected_composerattributetable_cellstyle/expected_composerattributetable_cellstyle_mask.png
  12. BIN ...table/expected_composerattributetable_columnwidth/expected_composerattributetable_columnwidth.png
  13. BIN .../expected_composerattributetable_columnwidth/expected_composerattributetable_columnwidth_mask.png
  14. BIN ...ed_composerattributetable_conditionalstyles/expected_composerattributetable_conditionalstyles.png
  15. BIN ...ser_table/expected_composerattributetable_drawempty/expected_composerattributetable_drawempty.png
  16. BIN ...able/expected_composerattributetable_drawempty/expected_composerattributetable_drawempty_mask.png
  17. BIN ...table/expected_composerattributetable_headersonly/expected_composerattributetable_headersonly.png
  18. BIN .../expected_composerattributetable_headersonly/expected_composerattributetable_headersonly_mask.png
  19. BIN ...ser_table/expected_composerattributetable_hidetable/expected_composerattributetable_hidetable.png
  20. BIN ...able/expected_composerattributetable_hidetable/expected_composerattributetable_hidetable_mask.png
  21. BIN ...expected_composerattributetable_horizontalgrid/expected_composerattributetable_horizontalgrid.png
  22. BIN ...ted_composerattributetable_horizontalgrid/expected_composerattributetable_horizontalgrid_mask.png
  23. BIN ...ser_table/expected_composerattributetable_multiline/expected_composerattributetable_multiline.png
  24. BIN ...able/expected_composerattributetable_multiline/expected_composerattributetable_multiline_mask.png
  25. BIN .../composer_table/expected_composerattributetable_render/expected_composerattributetable_render.png
  26. BIN ...oser_table/expected_composerattributetable_render/expected_composerattributetable_render_mask.png
  27. BIN ...table/expected_composerattributetable_showmessage/expected_composerattributetable_showmessage.png
  28. BIN .../expected_composerattributetable_showmessage/expected_composerattributetable_showmessage_mask.png
  29. BIN ...ble/expected_composerattributetable_verticalgrid/expected_composerattributetable_verticalgrid.png
  30. BIN ...xpected_composerattributetable_verticalgrid/expected_composerattributetable_verticalgrid_mask.png
  31. BIN ..._images/layout_manual_table/expected_manualtable_columnwidth/expected_manualtable_columnwidth.png
  32. BIN ...es/layout_manual_table/expected_manualtable_columnwidth/expected_manualtable_columnwidth_mask.png
  33. BIN .../control_images/layout_manual_table/expected_manualtable_headers/expected_manualtable_headers.png
  34. BIN ...rol_images/layout_manual_table/expected_manualtable_headers/expected_manualtable_headers_mask.png
  35. BIN ...trol_images/layout_manual_table/expected_manualtable_rowheight/expected_manualtable_rowheight.png
  36. BIN ...images/layout_manual_table/expected_manualtable_rowheight/expected_manualtable_rowheight_mask.png
@@ -37,8 +37,6 @@ QgsLayoutManualTableWidget::QgsLayoutManualTableWidget( QgsLayoutFrame *frame )
connect( mGridStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutManualTableWidget::mGridStrokeWidthSpinBox_valueChanged );
connect( mGridColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutManualTableWidget::mGridColorButton_colorChanged );
connect( mBackgroundColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutManualTableWidget::mBackgroundColorButton_colorChanged );
connect( mHeaderFontColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutManualTableWidget::mHeaderFontColorButton_colorChanged );
connect( mContentFontColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutManualTableWidget::mContentFontColorButton_colorChanged );
connect( mDrawHorizontalGrid, &QCheckBox::toggled, this, &QgsLayoutManualTableWidget::mDrawHorizontalGrid_toggled );
connect( mDrawVerticalGrid, &QCheckBox::toggled, this, &QgsLayoutManualTableWidget::mDrawVerticalGrid_toggled );
connect( mShowGridGroupCheckBox, &QgsCollapsibleGroupBoxBasic::toggled, this, &QgsLayoutManualTableWidget::mShowGridGroupCheckBox_toggled );
@@ -53,8 +51,8 @@ QgsLayoutManualTableWidget::QgsLayoutManualTableWidget( QgsLayoutFrame *frame )
connect( mAdvancedCustomizationButton, &QPushButton::clicked, this, &QgsLayoutManualTableWidget::mAdvancedCustomizationButton_clicked );
setPanelTitle( tr( "Table Properties" ) );

mContentFontToolButton->setMode( QgsFontButton::ModeQFont );
mHeaderFontToolButton->setMode( QgsFontButton::ModeQFont );
mContentFontToolButton->setMode( QgsFontButton::ModeTextRenderer );
mHeaderFontToolButton->setMode( QgsFontButton::ModeTextRenderer );

blockAllSignals( true );

@@ -74,12 +72,6 @@ QgsLayoutManualTableWidget::QgsLayoutManualTableWidget( QgsLayoutFrame *frame )
mHeaderHAlignmentComboBox->addItem( tr( "Center" ), QgsLayoutTable::HeaderCenter );
mHeaderHAlignmentComboBox->addItem( tr( "Right" ), QgsLayoutTable::HeaderRight );

mHeaderFontColorButton->setColorDialogTitle( tr( "Select Header Font Color" ) );
mHeaderFontColorButton->setAllowOpacity( true );
mHeaderFontColorButton->setContext( QStringLiteral( "composer" ) );
mContentFontColorButton->setColorDialogTitle( tr( "Select Content Font Color" ) );
mContentFontColorButton->setAllowOpacity( true );
mContentFontColorButton->setContext( QStringLiteral( "composer" ) );
mGridColorButton->setColorDialogTitle( tr( "Select Grid Color" ) );
mGridColorButton->setAllowOpacity( true );
mGridColorButton->setContext( QStringLiteral( "composer" ) );
@@ -269,31 +261,7 @@ void QgsLayoutManualTableWidget::contentFontChanged()
}

mTable->beginCommand( tr( "Change Table Font" ) );
mTable->setContentFont( mContentFontToolButton->currentFont() );
mTable->endCommand();
}

void QgsLayoutManualTableWidget::mContentFontColorButton_colorChanged( const QColor &newColor )
{
if ( !mTable )
{
return;
}

mTable->beginCommand( tr( "Change Font Color" ), QgsLayoutMultiFrame::UndoTableContentFontColor );
mTable->setContentFontColor( newColor );
mTable->endCommand();
}

void QgsLayoutManualTableWidget::mHeaderFontColorButton_colorChanged( const QColor &newColor )
{
if ( !mTable )
{
return;
}

mTable->beginCommand( tr( "Change Font Color" ), QgsLayoutMultiFrame::UndoTableHeaderFontColor );
mTable->setHeaderFontColor( newColor );
mTable->setContentTextFormat( mContentFontToolButton->textFormat() );
mTable->endCommand();
}

@@ -399,7 +367,7 @@ void QgsLayoutManualTableWidget::headerFontChanged()
return;

mTable->beginCommand( tr( "Change Table Font" ) );
mTable->setHeaderFont( mHeaderFontToolButton->currentFont() );
mTable->setHeaderTextFormat( mHeaderFontToolButton->textFormat() );
mTable->endCommand();
}

@@ -427,10 +395,8 @@ void QgsLayoutManualTableWidget::updateGuiElements()
}
mBackgroundColorButton->setColor( mTable->backgroundColor() );

mHeaderFontColorButton->setColor( mTable->headerFontColor() );
mContentFontColorButton->setColor( mTable->contentFontColor() );
mHeaderFontToolButton->setCurrentFont( mTable->headerFont() );
mContentFontToolButton->setCurrentFont( mTable->contentFont() );
mHeaderFontToolButton->setTextFormat( mTable->headerTextFormat() );
mContentFontToolButton->setTextFormat( mTable->contentTextFormat() );

mDrawEmptyCheckBox->setChecked( mTable->showEmptyRows() );
mWrapBehaviorComboBox->setCurrentIndex( mWrapBehaviorComboBox->findData( mTable->wrapBehavior() ) );
@@ -456,8 +422,6 @@ void QgsLayoutManualTableWidget::blockAllSignals( bool b )
mDrawHorizontalGrid->blockSignals( b );
mDrawVerticalGrid->blockSignals( b );
mShowGridGroupCheckBox->blockSignals( b );
mContentFontColorButton->blockSignals( b );
mHeaderFontColorButton->blockSignals( b );
mResizeModeComboBox->blockSignals( b );
mEmptyFrameCheckBox->blockSignals( b );
mHideEmptyBgCheckBox->blockSignals( b );
@@ -68,8 +68,6 @@ class GUI_EXPORT QgsLayoutManualTableWidget: public QgsLayoutItemBaseWidget, pri
void mBackgroundColorButton_colorChanged( const QColor &newColor );
void headerFontChanged();
void contentFontChanged();
void mContentFontColorButton_colorChanged( const QColor &newColor );
void mHeaderFontColorButton_colorChanged( const QColor &newColor );
void mDrawHorizontalGrid_toggled( bool state );
void mDrawVerticalGrid_toggled( bool state );
void mShowGridGroupCheckBox_toggled( bool state );
@@ -56,7 +56,7 @@
<x>0</x>
<y>0</y>
<width>394</width>
<height>976</height>
<height>914</height>
</rect>
</property>
<layout class="QVBoxLayout" name="mainLayout">
@@ -323,49 +323,6 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QgsColorButton" name="mHeaderFontColorButton">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Alignment</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="mHeaderHAlignmentComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@@ -375,13 +332,6 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
@@ -402,6 +352,13 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Alignment</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -418,49 +375,6 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QgsColorButton" name="mContentFontColorButton">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="QgsFontButton" name="mContentFontToolButton">
<property name="sizePolicy">
@@ -63,6 +63,8 @@ void TestQgsLayoutManualTable::initTestCase()
QgsApplication::initQgis();

mReport = QStringLiteral( "<h1>Layout Manual Table Tests</h1>\n" );

QgsFontUtils::loadStandardTestFonts( QStringList() << QStringLiteral( "Bold" ) );
}

void TestQgsLayoutManualTable::cleanupTestCase()
@@ -336,7 +338,7 @@ void TestQgsLayoutManualTable::rowHeight()
table->addFrame( frame1 );
table->setBackgroundColor( Qt::yellow );

table->setContentFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) );
table->setContentTextFormat( QgsTextFormat::fromQFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) ) );

frame1->setFrameEnabled( false );
table->setShowGrid( true );
@@ -364,7 +366,7 @@ void TestQgsLayoutManualTable::columnWidth()
table->addFrame( frame1 );
table->setBackgroundColor( Qt::yellow );

table->setContentFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) );
table->setContentTextFormat( QgsTextFormat::fromQFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) ) );

frame1->setFrameEnabled( false );
table->setShowGrid( true );
@@ -392,14 +394,15 @@ void TestQgsLayoutManualTable::headers()
table->addFrame( frame1 );
table->setBackgroundColor( Qt::yellow );

table->setContentFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) );
table->setHeaderFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ), 16 ) );
table->setContentTextFormat( QgsTextFormat::fromQFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) ) );
QgsTextFormat headerFormat( QgsTextFormat::fromQFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ), 16 ) ) );
headerFormat.setColor( QColor( 255, 0, 255 ) );
table->setHeaderTextFormat( headerFormat );

frame1->setFrameEnabled( false );
table->setShowGrid( true );
table->setHorizontalGrid( true );
table->setVerticalGrid( true );
table->setHeaderFontColor( QColor( 255, 0, 255 ) );

table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) << QgsTableCell( QStringLiteral( "Helicopter" ) ) << QgsTableCell( QStringLiteral( "Plane" ) ) )
<< ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "B" ) ) << QgsTableCell( QStringLiteral( "C" ) ) ) );

0 comments on commit 54c5e7e

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