Skip to content

Commit

Permalink
Fix more deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 4, 2020
1 parent 692a140 commit 3d3e1a7
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 32 deletions.
1 change: 0 additions & 1 deletion src/app/qgsattributetabledialog.h
Expand Up @@ -34,7 +34,6 @@ class QPushButton;
class QLineEdit;
class QComboBox;
class QMenu;
class QSignalMapper;
class QgsAttributeTableModel;
class QgsAttributeTableFilterModel;
class QgsRubberBand;
Expand Down
13 changes: 2 additions & 11 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -766,9 +766,6 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
QStringList wfstInsertLayerIdList = QgsProject::instance()->readListEntry( QStringLiteral( "WFSTLayers" ), QStringLiteral( "Insert" ) );
QStringList wfstDeleteLayerIdList = QgsProject::instance()->readListEntry( QStringLiteral( "WFSTLayers" ), QStringLiteral( "Delete" ) );

QSignalMapper *smPublied = new QSignalMapper( this );
connect( smPublied, SIGNAL( mapped( int ) ), this, SLOT( cbxWFSPubliedStateChanged( int ) ) );

const QMap<QString, QgsMapLayer *> &mapLayers = QgsProject::instance()->mapLayers();

twWFSLayers->setColumnCount( 6 );
Expand All @@ -795,9 +792,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
QCheckBox *cbp = new QCheckBox();
cbp->setChecked( wfsLayerIdList.contains( currentLayer->id() ) );
twWFSLayers->setCellWidget( j, 1, cbp );

smPublied->setMapping( cbp, j );
connect( cbp, SIGNAL( stateChanged( int ) ), smPublied, SLOT( map() ) );
connect( cbp, &QCheckBox::stateChanged, this, [ = ] { cbxWCSPubliedStateChanged( j ); } );

QSpinBox *psb = new QSpinBox();
psb->setValue( QgsProject::instance()->readNumEntry( QStringLiteral( "WFSLayersPrecision" ), "/" + currentLayer->id(), 8 ) );
Expand Down Expand Up @@ -833,9 +828,6 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
mWCSUrlLineEdit->setText( QgsProject::instance()->readEntry( QStringLiteral( "WCSUrl" ), QStringLiteral( "/" ), QString() ) );
QStringList wcsLayerIdList = QgsProject::instance()->readListEntry( QStringLiteral( "WCSLayers" ), QStringLiteral( "/" ) );

QSignalMapper *smWcsPublied = new QSignalMapper( this );
connect( smWcsPublied, SIGNAL( mapped( int ) ), this, SLOT( cbxWCSPubliedStateChanged( int ) ) );

twWCSLayers->setColumnCount( 2 );
twWCSLayers->horizontalHeader()->setVisible( true );
twWCSLayers->setRowCount( mapLayers.size() );
Expand All @@ -860,8 +852,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
cbp->setChecked( wcsLayerIdList.contains( currentLayer->id() ) );
twWCSLayers->setCellWidget( j, 1, cbp );

smWcsPublied->setMapping( cbp, j );
connect( cbp, SIGNAL( stateChanged( int ) ), smWcsPublied, SLOT( map() ) );
connect( cbp, &QCheckBox::stateChanged, this, [ = ] { cbxWCSPubliedStateChanged( j ); } );

j++;
}
Expand Down
1 change: 0 additions & 1 deletion src/gui/attributetable/qgsdualview.h
Expand Up @@ -26,7 +26,6 @@
#include "qgis_gui.h"

class QgsFeatureRequest;
class QSignalMapper;
class QgsMapLayerAction;
class QgsScrollArea;
class QgsFieldConditionalFormatWidget;
Expand Down
11 changes: 4 additions & 7 deletions src/gui/attributetable/qgsfeaturefilterwidget.cpp
Expand Up @@ -46,7 +46,6 @@ QgsFeatureFilterWidget::QgsFeatureFilterWidget( QWidget *parent )
setupUi( this );

// Initialize filter gui elements
mFilterActionMapper = new QSignalMapper( this );
mFilterColumnsMenu = new QMenu( this );
mActionFilterColumnsMenu->setMenu( mFilterColumnsMenu );
mStoredFilterExpressionMenu = new QMenu( this );
Expand Down Expand Up @@ -74,7 +73,6 @@ QgsFeatureFilterWidget::QgsFeatureFilterWidget( QWidget *parent )
connect( mActionSelectedFilter, &QAction::triggered, this, &QgsFeatureFilterWidget::filterSelected );
connect( mActionVisibleFilter, &QAction::triggered, this, &QgsFeatureFilterWidget::filterVisible );
connect( mActionEditedFilter, &QAction::triggered, this, &QgsFeatureFilterWidget::filterEdited );
connect( mFilterActionMapper, SIGNAL( mapped( QObject * ) ), SLOT( filterColumnChanged( QObject * ) ) );
connect( mFilterQuery, &QLineEdit::returnPressed, this, &QgsFeatureFilterWidget::filterQueryAccepted );
connect( mActionApplyFilter, &QAction::triggered, this, &QgsFeatureFilterWidget::filterQueryAccepted );
connect( mFilterQuery, &QLineEdit::textChanged, this, &QgsFeatureFilterWidget::onFilterQueryTextChanged );
Expand Down Expand Up @@ -186,7 +184,6 @@ void QgsFeatureFilterWidget::columnBoxInit()
for ( QAction *a : constActions )
{
mFilterColumnsMenu->removeAction( a );
mFilterActionMapper->removeMappings( a );
mFilterButton->removeAction( a );
delete a;
}
Expand Down Expand Up @@ -219,8 +216,8 @@ void QgsFeatureFilterWidget::columnBoxInit()
// Generate action for the filter popup button
QAction *filterAction = new QAction( icon, alias, mFilterButton );
filterAction->setData( field.name() );
mFilterActionMapper->setMapping( filterAction, filterAction );
connect( filterAction, SIGNAL( triggered() ), mFilterActionMapper, SLOT( map() ) );

connect( filterAction, &QAction::triggered, this, [ = ] { filterColumnChanged( filterAction ); } );
mFilterColumnsMenu->addAction( filterAction );
}
}
Expand Down Expand Up @@ -283,9 +280,9 @@ void QgsFeatureFilterWidget::storeExpressionButtonInit()
}


void QgsFeatureFilterWidget::filterColumnChanged( QObject *filterAction )
void QgsFeatureFilterWidget::filterColumnChanged( QAction *filterAction )
{
mFilterButton->setDefaultAction( qobject_cast<QAction *>( filterAction ) );
mFilterButton->setDefaultAction( filterAction );
mFilterButton->setPopupMode( QToolButton::InstantPopup );
// replace the search line edit with a search widget that is suited to the selected field
// delete previous widget
Expand Down
3 changes: 1 addition & 2 deletions src/gui/attributetable/qgsfeaturefilterwidget_p.h
Expand Up @@ -114,15 +114,14 @@ class GUI_EXPORT QgsFeatureFilterWidget : public QWidget, private Ui::QgsFeature
*/
void updateCurrentStoredFilterExpression( );

void filterColumnChanged( QObject *filterAction );
void filterColumnChanged( QAction *filterAction );

private:

/* replace the search widget with a new one */
void replaceSearchWidget( QWidget *oldw, QWidget *neww );

QMenu *mFilterColumnsMenu = nullptr;
QSignalMapper *mFilterActionMapper = nullptr;
QMenu *mStoredFilterExpressionMenu = nullptr;
QTimer mFilterQueryTimer;
QgsSearchWidgetWrapper *mCurrentSearchWidgetWrapper = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/auth/qgsauthcertificateinfo.cpp
Expand Up @@ -580,7 +580,7 @@ void QgsAuthCertInfo::populateInfoDetailsSection()
mCurrentACert.subjectInfo().value( QCA::XMPP ),
LineEdit );

QMultiMap<QSsl::AlternateNameEntryType, QString> alts( mCurrentQCert.alternateSubjectNames() );
QMultiMap<QSsl::AlternateNameEntryType, QString> alts( mCurrentQCert.subjectAlternativeNames() );
QStringList altslist;
QString email( tr( "Email: " ) );
QStringList emails( alts.values( QSsl::EmailEntry ) );
Expand Down
4 changes: 3 additions & 1 deletion src/gui/auth/qgsauthsslimportdialog.cpp
Expand Up @@ -192,7 +192,9 @@ void QgsAuthSslImportDialog::secureConnect()
this, &QgsAuthSslImportDialog::socketReadyRead );
}

mSocket->setCaCertificates( mTrustedCAs );
QSslConfiguration sslConfig = mSocket->sslConfiguration();
sslConfig.setCaCertificates( mTrustedCAs );
mSocket->setSslConfiguration( sslConfig );

if ( !mTimer )
{
Expand Down
1 change: 0 additions & 1 deletion src/gui/qgsactionmenu.h
Expand Up @@ -18,7 +18,6 @@

#include <QMenu>
#include "qgis_sip.h"
#include <QSignalMapper>

#include "qgsfeature.h"
#include "qgsaction.h"
Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgsnewnamedialog.cpp
Expand Up @@ -57,7 +57,13 @@ QgsNewNameDialog::QgsNewNameDialog( const QString &source, const QString &initia
QRegExpValidator *validator = new QRegExpValidator( regexp, this );
mLineEdit->setValidator( validator );
}


#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
mLineEdit->setMinimumWidth( mLineEdit->fontMetrics().width( QStringLiteral( "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ) ) );
#else
mLineEdit->setMinimumWidth( mLineEdit->fontMetrics().horizontalAdvance( 'x' ) * 44 );
#endif
connect( mLineEdit, &QLineEdit::textChanged, this, &QgsNewNameDialog::nameChanged );
connect( mLineEdit, &QLineEdit::textChanged, this, &QgsNewNameDialog::newNameChanged );
layout()->addWidget( mLineEdit );
Expand Down
10 changes: 10 additions & 0 deletions src/gui/qgsstyleitemslistwidget.cpp
Expand Up @@ -72,9 +72,19 @@ QgsStyleItemsListWidget::QgsStyleItemsListWidget( QWidget *parent )
btnAdvanced->hide(); // advanced button is hidden by default
btnAdvanced->setMenu( new QMenu( this ) );


#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
double iconSize = Qgis::UI_SCALE_FACTOR * fontMetrics().width( 'X' ) * 10;
#else
double iconSize = Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 10;
#endif
viewSymbols->setIconSize( QSize( static_cast< int >( iconSize ), static_cast< int >( iconSize * 0.9 ) ) ); // ~100, 90 on low dpi

#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
double treeIconSize = Qgis::UI_SCALE_FACTOR * fontMetrics().width( 'X' ) * 2;
#else
double treeIconSize = Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 2;
#endif
mSymbolTreeView->setIconSize( QSize( static_cast< int >( treeIconSize ), static_cast< int >( treeIconSize ) ) );

viewSymbols->setSelectionBehavior( QAbstractItemView::SelectRows );
Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgssymbolbutton.cpp
Expand Up @@ -550,7 +550,12 @@ void QgsSymbolButton::updatePreview( const QColor &color, QgsSymbol *tempSymbol

// set tooltip
// create very large preview image

#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
int width = static_cast< int >( Qgis::UI_SCALE_FACTOR * fontMetrics().width( 'X' ) * 23 );
#else
int width = static_cast< int >( Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 23 );
#endif
int height = static_cast< int >( width / 1.61803398875 ); // golden ratio

QPixmap pm = QgsSymbolLayerUtils::symbolPreviewPixmap( previewSymbol.get(), QSize( width, height ), height / 20 );
Expand Down
20 changes: 20 additions & 0 deletions src/gui/qgstaskmanagerwidget.cpp
Expand Up @@ -46,9 +46,19 @@ QgsTaskManagerWidget::QgsTaskManagerWidget( QgsTaskManager *manager, QWidget *pa
mTreeView->setHeaderHidden( true );
mTreeView->setRootIsDecorated( false );
mTreeView->setSelectionBehavior( QAbstractItemView::SelectRows );

#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
int progressColWidth = static_cast< int >( fontMetrics().width( 'X' ) * 10 * Qgis::UI_SCALE_FACTOR );
#else
int progressColWidth = static_cast< int >( fontMetrics().horizontalAdvance( 'X' ) * 10 * Qgis::UI_SCALE_FACTOR );
#endif
mTreeView->setColumnWidth( QgsTaskManagerModel::Progress, progressColWidth );

#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
int statusColWidth = static_cast< int >( fontMetrics().width( 'X' ) * 2 * Qgis::UI_SCALE_FACTOR );
#else
int statusColWidth = static_cast< int >( fontMetrics().horizontalAdvance( 'X' ) * 2 * Qgis::UI_SCALE_FACTOR );
#endif
mTreeView->setColumnWidth( QgsTaskManagerModel::Status, statusColWidth );
mTreeView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
mTreeView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
Expand Down Expand Up @@ -571,7 +581,12 @@ QgsTaskManagerFloatingWidget::QgsTaskManagerFloatingWidget( QgsTaskManager *mana
{
setLayout( new QVBoxLayout() );
QgsTaskManagerWidget *w = new QgsTaskManagerWidget( manager );

#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
int minWidth = static_cast< int >( fontMetrics().width( 'X' ) * 60 * Qgis::UI_SCALE_FACTOR );
#else
int minWidth = static_cast< int >( fontMetrics().horizontalAdvance( 'X' ) * 60 * Qgis::UI_SCALE_FACTOR );
#endif
int minHeight = static_cast< int >( fontMetrics().height() * 15 * Qgis::UI_SCALE_FACTOR );
setMinimumSize( minWidth, minHeight );
layout()->addWidget( w );
Expand Down Expand Up @@ -610,7 +625,12 @@ QgsTaskManagerStatusBarWidget::QgsTaskManagerStatusBarWidget( QgsTaskManager *ma

QSize QgsTaskManagerStatusBarWidget::sizeHint() const
{

#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
int width = static_cast< int >( fontMetrics().width( 'X' ) * 20 * Qgis::UI_SCALE_FACTOR );
#else
int width = static_cast< int >( fontMetrics().horizontalAdvance( 'X' ) * 20 * Qgis::UI_SCALE_FACTOR );
#endif
int height = QToolButton::sizeHint().height();
return QSize( width, height );
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.cpp
Expand Up @@ -1157,7 +1157,7 @@ void eVisGenericEventBrowserGui::renderSymbol( QPainter *painter )
QPixmap myTempPixmap( mPointerSymbol.height(), mPointerSymbol.height() );
myTempPixmap.fill( QColor( 255, 255, 255, 0 ) );
QPainter p( &myTempPixmap );
QMatrix wm;
QTransform wm;
wm.translate( myTempPixmap.width() / 2, myTempPixmap.height() / 2 ); // really center

double myBearing = mCompassBearing;
Expand All @@ -1183,7 +1183,7 @@ void eVisGenericEventBrowserGui::renderSymbol( QPainter *painter )

wm.rotate( myBearing );

p.setWorldMatrix( wm );
p.setWorldTransform( wm );
p.drawPixmap( -mPointerSymbol.width() / 2, -mPointerSymbol.height() / 2, mPointerSymbol );

int xShift = static_cast<int>( myPoint.x() ) - ( myTempPixmap.width() / 2 );
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/geometry_checker/qgsgeometrycheckerresulttab.cpp
Expand Up @@ -106,10 +106,10 @@ QgsGeometryCheckerResultTab::QgsGeometryCheckerResultTab( QgisInterface *iface,
ui.tableWidgetErrors->horizontalHeader()->setSortIndicator( 0, Qt::AscendingOrder );
ui.tableWidgetErrors->resizeColumnToContents( 0 );
ui.tableWidgetErrors->resizeColumnToContents( 1 );
ui.tableWidgetErrors->horizontalHeader()->setResizeMode( 2, QHeaderView::Stretch );
ui.tableWidgetErrors->horizontalHeader()->setResizeMode( 3, QHeaderView::Stretch );
ui.tableWidgetErrors->horizontalHeader()->setResizeMode( 4, QHeaderView::Stretch );
ui.tableWidgetErrors->horizontalHeader()->setResizeMode( 5, QHeaderView::Stretch );
ui.tableWidgetErrors->horizontalHeader()->setSectionResizeMode( 2, QHeaderView::Stretch );
ui.tableWidgetErrors->horizontalHeader()->setSectionResizeMode( 3, QHeaderView::Stretch );
ui.tableWidgetErrors->horizontalHeader()->setSectionResizeMode( 4, QHeaderView::Stretch );
ui.tableWidgetErrors->horizontalHeader()->setSectionResizeMode( 5, QHeaderView::Stretch );
// Not sure why, but this is needed...
ui.tableWidgetErrors->setSortingEnabled( true );
ui.tableWidgetErrors->setSortingEnabled( false );
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/offline_editing/offline_editing_plugin_gui.cpp
Expand Up @@ -115,7 +115,7 @@ QgsOfflineEditingPluginGui::QgsOfflineEditingPluginGui( QWidget *parent, Qt::Win
QgsLayerTree *rootNode = QgsProject::instance()->layerTreeRoot()->clone();
QgsLayerTreeModel *treeModel = new QgsSelectLayerTreeModel( rootNode, this );
mLayerTree->setModel( treeModel );
mLayerTree->header()->setResizeMode( QHeaderView::ResizeToContents );
mLayerTree->header()->setSectionResizeMode( QHeaderView::ResizeToContents );

connect( mSelectAllButton, &QAbstractButton::clicked, this, &QgsOfflineEditingPluginGui::selectAll );
connect( mDeselectAllButton, &QAbstractButton::clicked, this, &QgsOfflineEditingPluginGui::deSelectAll );
Expand Down

0 comments on commit 3d3e1a7

Please sign in to comment.