Skip to content

Commit d9a44b4

Browse files
committed
[Qt compatibility] Resolve deprecated warnings for Qt5.15
1 parent 0c27dfe commit d9a44b4

File tree

7 files changed

+38
-10
lines changed

7 files changed

+38
-10
lines changed

src/widgets/basics/graphwidget.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,11 @@ void GraphWidget::wheelEvent(QWheelEvent *event) {
205205

206206
params.autoscale = false;
207207
emit autoscaleChanged(params.autoscale);
208+
#if QT_VERSION_MAJOR == 5 && QT_VERSION_MINOR < 15
208209
double val = val_of_y(event->y());
210+
#else
211+
double val = val_of_y(event->position().y());
212+
#endif
209213
double s = wheelAccumulator < 0 ? 2: 1/2.0;
210214
params.max = val + (params.max-val)*s;
211215
params.min = val + (params.min-val)*s;

src/widgets/flightplaneditor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ void FlightPlanEditor::onMoveWaypointUi(Waypoint* wp, QString acid) {
679679
}
680680
if(!readOnly) {
681681
ui->tree->clearSelection();
682-
ui->tree->setItemSelected(it.key(), true);
682+
it.key()->setSelected(true);
683683
}
684684
if(ui->tree->selectedItems().size() > 0 && ui->tree->selectedItems().first() == it.key()) {
685685
onItemClicked(it.key(), 1);
@@ -776,7 +776,7 @@ void FlightPlanEditor::onNavStatus() {
776776

777777
applyRecursive(last, [=](QTreeWidgetItem* item){
778778
for(int i=0; i<item->columnCount(); ++i) {
779-
item->setBackgroundColor(i, Qt::transparent);
779+
item->setBackground(i, Qt::transparent);
780780
}
781781
});
782782

@@ -800,7 +800,7 @@ void FlightPlanEditor::onNavStatus() {
800800
}
801801

802802
for(int i=0; i<item->columnCount(); ++i) {
803-
item->setBackgroundColor(i, color);
803+
item->setBackground(i, color);
804804
}
805805
});
806806

src/widgets/layer_combo.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ void LayerCombo::mousePressEvent(QMouseEvent* e) {
4444
moved_layer_control = mlc;
4545
press_pos = e->pos();
4646

47-
QSize pSize = mlc->pixmap()->size();
47+
QSize pSize = mlc->pixmap().size();
4848
QSize pixSize = QSize(pSize.width()/2, pSize.height()/2);
49-
moved_thumbnail->setPixmap(mlc->pixmap()->scaled(pixSize));
49+
moved_thumbnail->setPixmap(mlc->pixmap().scaled(pixSize));
5050
moved_thumbnail->raise();
5151

5252
QPoint globalPos = mapToGlobal(e->pos());
@@ -61,7 +61,11 @@ void LayerCombo::mouseMoveEvent(QMouseEvent* e) {
6161
(void) e;
6262
if(moved_layer_control) {
6363
QPoint globalPos = mapToGlobal(e->pos());
64+
#if QT_VERSION_MAJOR == 5 && QT_VERSION_MINOR < 15
6465
QSize pixSize = moved_thumbnail->pixmap()->size();
66+
#else
67+
QSize pixSize = moved_thumbnail->pixmap(Qt::ReturnByValue).size();
68+
#endif
6569
QPoint pos(globalPos.x()-pixSize.width()/2, globalPos.y()-pixSize.height()/2);
6670
moved_thumbnail->move(pos);
6771
int w_y = e->pos().y();

src/widgets/map/map2d.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ void Map2D::wheelEvent(QWheelEvent* event) {
152152
new_zoom = _zoom - 0.5;
153153
}
154154
new_zoom = round(new_zoom*2)/2.0;
155+
#if QT_VERSION_MAJOR == 5 && QT_VERSION_MINOR < 15
155156
zoomCentered(new_zoom, event->pos());
157+
#else
158+
zoomCentered(new_zoom, event->position().toPoint());
159+
#endif
156160
wheelAccumulator = 0;
157161
}
158162

src/widgets/map/maplayercontrol.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ class MapLayerControl : public QWidget
1818
qreal opacity() {return static_cast<qreal>(opacitySlider->value())/opacitySlider->maximum();}
1919
int zValue() {return z_value;}
2020
void setZValue(int z);
21-
const QPixmap* pixmap() {return imageLabel->pixmap();}
21+
QPixmap pixmap() {
22+
#if QT_VERSION_MAJOR == 5 && QT_VERSION_MINOR < 15
23+
QPixmap p = *imageLabel->pixmap();
24+
#else
25+
QPixmap p = imageLabel->pixmap(Qt::ReturnByValue);
26+
#endif
27+
return p;
28+
}
2229
QString name() {return _name;}
2330

2431
bool operator <(const MapLayerControl& mlc) const

src/widgets/pprzmap.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,25 @@ PprzMap::PprzMap(QWidget *parent) :
2929
for(auto ac: AircraftManager::get()->getAircrafts()) {
3030
auto [nw, se] = ac->getFlightPlan()->boundingBox();
3131
auto tile_names = SRTMManager::get()->get_tile_names(se.lat(), nw.lat(), nw.lon(), se.lon());
32+
#if QT_VERSION_MAJOR == 5 && QT_VERSION_MINOR < 15
3233
tiles.unite(tile_names.toSet());
34+
#else
35+
auto tiles_set = QSet<QString>(tile_names.begin(), tile_names.end());
36+
tiles.unite(tiles_set);
37+
#endif
3338
}
3439

3540
// Download SRTM tile(s) for view footprint
3641
Point2DLatLon nw(0, 0), se(0, 0);
3742
ui->map->getViewPoints(nw, se);
3843
auto tile_names = SRTMManager::get()->get_tile_names(se.lat(), nw.lat(), nw.lon(), se.lon());
44+
#if QT_VERSION_MAJOR == 5 && QT_VERSION_MINOR < 15
3945
tiles.unite(tile_names.toSet());
40-
41-
SRTMManager::get()->load_tiles(tiles.toList(), local_only);
46+
#else
47+
auto tiles_set = QSet<QString>(tile_names.begin(), tile_names.end());
48+
tiles.unite(tiles_set);
49+
#endif
50+
SRTMManager::get()->load_tiles(tiles.values(), local_only);
4251

4352
};
4453

src/widgets/windindicator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void WindIndicator::paintEvent(QPaintEvent *event) {
7474
windsock.paint(&painter, r_ws, Qt::AlignCenter);
7575

7676
// text
77-
painter.resetMatrix();
77+
painter.resetTransform();
7878
painter.setPen(m_pen_color);
7979
auto font = QFont();
8080
font.setBold(true);
@@ -144,7 +144,7 @@ void WindIndicator::mouseReleaseEvent(QMouseEvent *event) {
144144
}
145145

146146
void WindIndicator::wheelEvent(QWheelEvent* event) {
147-
double rot = compass + event->delta() / 10.0;
147+
double rot = compass + event->angleDelta().y() / 10.0;
148148
emit requestRotation(rot);
149149
}
150150

0 commit comments

Comments
 (0)