Skip to content

Commit

Permalink
Fix deprecation warnings and update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 10, 2020
1 parent b449361 commit 54c5e7e
Show file tree
Hide file tree
Showing 36 changed files with 58 additions and 177 deletions.
48 changes: 6 additions & 42 deletions src/gui/layout/qgslayoutmanualtablewidget.cpp
Expand Up @@ -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 );
Expand All @@ -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 );

Expand All @@ -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" ) );
Expand Down Expand Up @@ -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();
}

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

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

Expand Down Expand Up @@ -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() ) );
Expand All @@ -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 );
Expand Down
2 changes: 0 additions & 2 deletions src/gui/layout/qgslayoutmanualtablewidget.h
Expand Up @@ -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 );
Expand Down
102 changes: 8 additions & 94 deletions src/ui/layout/qgslayoutmanualtablewidgetbase.ui
Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand All @@ -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">
Expand All @@ -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>
Expand All @@ -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">
Expand Down
13 changes: 8 additions & 5 deletions tests/src/core/testqgslayoutmanualtable.cpp
Expand Up @@ -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()
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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" ) ) ) );
Expand Down

0 comments on commit 54c5e7e

Please sign in to comment.