Qt: fix some Qt 5.15.2 deprecation warnings

This commit is contained in:
Pascal Quantin 2020-11-23 22:08:04 +01:00 committed by AndersBroman
parent 15d315c2ae
commit fb2414ae6d
2 changed files with 21 additions and 3 deletions

View File

@ -791,7 +791,11 @@ void PacketList::mousePressEvent (QMouseEvent *event)
QModelIndex curIndex = indexAt(event->pos());
mouse_pressed_at_ = curIndex;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
bool midButton = (event->buttons() & Qt::MiddleButton) == Qt::MiddleButton;
#else
bool midButton = (event->buttons() & Qt::MidButton) == Qt::MidButton;
#endif
if (midButton && cap_file_ && packet_list_model_)
{
packet_list_model_->toggleFrameMark(QModelIndexList() << curIndex);

View File

@ -136,7 +136,11 @@ PrintDialog::~PrintDialog()
gboolean PrintDialog::printHeader()
{
if (!cap_file_ || !cap_file_->filename || !cur_printer_ || !cur_painter_) return FALSE;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
int page_top = cur_printer_->pageLayout().paintRectPixels(cur_printer_->resolution()).top();
#else
int page_top = cur_printer_->pageRect().top();
#endif
if (page_pos_ > page_top) {
if (in_preview_) {
@ -162,7 +166,7 @@ gboolean PrintDialog::printHeader()
gboolean PrintDialog::printLine(int indent, const char *line)
{
QRect out_rect;
QRect out_rect, page_rect;
QString out_line;
if (!line || !cur_printer_ || !cur_painter_) return FALSE;
@ -171,9 +175,15 @@ gboolean PrintDialog::printLine(int indent, const char *line)
out_line.fill(' ', indent * 4);
out_line += line;
out_rect = cur_painter_->boundingRect(cur_printer_->pageRect(), Qt::TextWordWrap, out_line);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
page_rect = cur_printer_->pageLayout().paintRectPixels(cur_printer_->resolution());
#else
page_rect = cur_printer_->pageRect();
#endif
if (cur_printer_->pageRect().height() < page_pos_ + out_rect.height()) {
out_rect = cur_painter_->boundingRect(page_rect, Qt::TextWordWrap, out_line);
if (page_rect.height() < page_pos_ + out_rect.height()) {
//
// We're past the end of the page, so this line will be on
// the next page.
@ -233,7 +243,11 @@ void PrintDialog::printPackets(QPrinter *printer, bool in_preview)
if (!printer) return;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
page_pos_ = printer->pageLayout().paintRectPixels(cur_printer_->resolution()).top();
#else
page_pos_ = printer->pageRect().top();
#endif
in_preview_ = in_preview;
/* Fill in our print args */