Merge "Merge remote-tracking branch 'origin/5.14' into 5.15"

This commit is contained in:
Qt Forward Merge Bot 2019-09-19 21:54:52 +02:00
commit 580572f3c9
80 changed files with 1458 additions and 1346 deletions

View File

@ -766,7 +766,7 @@
"debug_and_release": {
"label": "Compile libs in debug and release mode",
"autoDetect": "input.debug == ''",
"condition": "config.darwin || config.win32",
"condition": "config.darwin || (config.win32 && !config.gcc)",
"output": [ "publicFeature", "publicQtConfig", "debugAndRelease" ]
},
"force_debug_info": {

View File

@ -142,6 +142,9 @@
pendingAdditiveOperator and \c pendingMultiplicativeOperator
variables don't need to be initialized explicitly, because the
QString constructor initializes them to empty strings.
It is also possible to initialize those variable directly in the
header. This is called \c member-initializaton and avoids a long
initialization list.
\snippet widgets/calculator/calculator.cpp 1
\snippet widgets/calculator/calculator.cpp 2

View File

@ -95,7 +95,7 @@
\snippet widgets/tooltips/sortingbox.h 2
We keep all the shape items in a QList, and we keep three
We keep all the shape items in a QVector, and we keep three
QPainterPath objects holding the shapes of a circle, a square and
a triangle. We also need to have a pointer to an item when it is
moving, and we need to know its previous position.

View File

@ -50,7 +50,9 @@
#include "analogclock.h"
#include <QtWidgets>
#include <QPainter>
#include <QTime>
#include <QTimer>
//! [0] //! [1]
AnalogClock::AnalogClock(QWidget *parent)

View File

@ -50,8 +50,6 @@
#include "button.h"
#include <QtWidgets>
//! [0]
Button::Button(const QString &text, QWidget *parent)
: QToolButton(parent)

View File

@ -48,21 +48,18 @@
**
****************************************************************************/
#include "button.h"
#include "calculator.h"
#include "button.h"
#include <QtWidgets>
#include <cmath>
#include <QGridLayout>
#include <QLineEdit>
#include <QtMath>
//! [0]
Calculator::Calculator(QWidget *parent)
: QWidget(parent)
: QWidget(parent), sumInMemory(0.0), sumSoFar(0.0)
, factorSoFar(0.0), waitingForOperand(true)
{
sumInMemory = 0.0;
sumSoFar = 0.0;
factorSoFar = 0.0;
waitingForOperand = true;
//! [0]
//! [1]
@ -78,9 +75,8 @@ Calculator::Calculator(QWidget *parent)
//! [2]
//! [4]
for (int i = 0; i < NumDigitButtons; ++i) {
for (int i = 0; i < NumDigitButtons; ++i)
digitButtons[i] = createButton(QString::number(i), SLOT(digitClicked()));
}
Button *pointButton = createButton(tr("."), SLOT(pointClicked()));
Button *changeSignButton = createButton(tr("\302\261"), SLOT(changeSignClicked()));
@ -194,6 +190,8 @@ void Calculator::additiveOperatorClicked()
//! [10] //! [11]
{
Button *clickedButton = qobject_cast<Button *>(sender());
if (!clickedButton)
return;
QString clickedOperator = clickedButton->text();
double operand = display->text().toDouble();
@ -233,6 +231,8 @@ void Calculator::additiveOperatorClicked()
void Calculator::multiplicativeOperatorClicked()
{
Button *clickedButton = qobject_cast<Button *>(sender());
if (!clickedButton)
return;
QString clickedOperator = clickedButton->text();
double operand = display->text().toDouble();

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtWidgets>
#include <QApplication>
#include "window.h"

View File

@ -48,10 +48,18 @@
**
****************************************************************************/
#include <QtWidgets>
#include "window.h"
#include <QCalendarWidget>
#include <QCheckBox>
#include <QComboBox>
#include <QDateEdit>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QLocale>
#include <QTextCharFormat>
//! [0]
Window::Window(QWidget *parent)
: QWidget(parent)
@ -166,13 +174,12 @@ void Window::reformatHeaders()
QString text = headerTextFormatCombo->currentText();
QTextCharFormat format;
if (text == tr("Bold")) {
if (text == tr("Bold"))
format.setFontWeight(QFont::Bold);
} else if (text == tr("Italic")) {
else if (text == tr("Italic"))
format.setFontItalic(true);
} else if (text == tr("Green")) {
else if (text == tr("Green"))
format.setForeground(Qt::green);
}
calendar->setHeaderTextFormat(format);
}
//! [7]

View File

@ -50,11 +50,14 @@
#include "characterwidget.h"
#include <QtWidgets>
#include <QFontDatabase>
#include <QMouseEvent>
#include <QPainter>
#include <QToolTip>
//! [0]
CharacterWidget::CharacterWidget(QWidget *parent)
: QWidget(parent), columns(16), lastKey(-1)
: QWidget(parent)
{
calculateSquareSize();
setMouseTracking(true);
@ -110,7 +113,7 @@ void CharacterWidget::calculateSquareSize()
//! [3]
QSize CharacterWidget::sizeHint() const
{
return QSize(columns*squareSize, (65536/columns)*squareSize);
return QSize(columns*squareSize, (65536 / columns) * squareSize);
}
//! [3]
@ -118,7 +121,7 @@ QSize CharacterWidget::sizeHint() const
void CharacterWidget::mouseMoveEvent(QMouseEvent *event)
{
QPoint widgetPosition = mapFromGlobal(event->globalPos());
uint key = (widgetPosition.y()/squareSize)*columns + widgetPosition.x()/squareSize;
uint key = (widgetPosition.y() / squareSize) * columns + widgetPosition.x() / squareSize;
QString text = QString::fromLatin1("<p>Character: <span style=\"font-size: 24pt; font-family: %1\">").arg(displayFont.family())
+ QChar(key)
@ -132,7 +135,7 @@ void CharacterWidget::mouseMoveEvent(QMouseEvent *event)
void CharacterWidget::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
lastKey = (event->y()/squareSize)*columns + event->x()/squareSize;
lastKey = (event->y() / squareSize) * columns + event->x() / squareSize;
if (QChar(lastKey).category() != QChar::Other_NotAssigned)
emit characterSelected(QString(QChar(lastKey)));
update();
@ -152,17 +155,17 @@ void CharacterWidget::paintEvent(QPaintEvent *event)
//! [7]
QRect redrawRect = event->rect();
int beginRow = redrawRect.top()/squareSize;
int endRow = redrawRect.bottom()/squareSize;
int beginColumn = redrawRect.left()/squareSize;
int endColumn = redrawRect.right()/squareSize;
int beginRow = redrawRect.top() / squareSize;
int endRow = redrawRect.bottom() / squareSize;
int beginColumn = redrawRect.left() / squareSize;
int endColumn = redrawRect.right() / squareSize;
//! [7]
//! [8]
painter.setPen(QPen(Qt::gray));
for (int row = beginRow; row <= endRow; ++row) {
for (int column = beginColumn; column <= endColumn; ++column) {
painter.drawRect(column*squareSize, row*squareSize, squareSize, squareSize);
painter.drawRect(column * squareSize, row * squareSize, squareSize, squareSize);
}
//! [8] //! [9]
}
@ -172,17 +175,17 @@ void CharacterWidget::paintEvent(QPaintEvent *event)
QFontMetrics fontMetrics(displayFont);
painter.setPen(QPen(Qt::black));
for (int row = beginRow; row <= endRow; ++row) {
for (int column = beginColumn; column <= endColumn; ++column) {
int key = row*columns + column;
painter.setClipRect(column*squareSize, row*squareSize, squareSize, squareSize);
int key = row * columns + column;
painter.setClipRect(column * squareSize, row * squareSize, squareSize, squareSize);
if (key == lastKey)
painter.fillRect(column*squareSize + 1, row*squareSize + 1, squareSize, squareSize, QBrush(Qt::red));
painter.fillRect(column * squareSize + 1, row * squareSize + 1,
squareSize, squareSize, QBrush(Qt::red));
painter.drawText(column*squareSize + (squareSize / 2) - fontMetrics.horizontalAdvance(QChar(key))/2,
row*squareSize + 4 + fontMetrics.ascent(),
painter.drawText(column * squareSize + (squareSize / 2) -
fontMetrics.horizontalAdvance(QChar(key)) / 2,
row * squareSize + 4 + fontMetrics.ascent(),
QString(QChar(key)));
}
}

View File

@ -88,9 +88,9 @@ private:
void calculateSquareSize();
QFont displayFont;
int columns;
int lastKey;
int squareSize;
int columns = 16;
int lastKey = -1;
int squareSize = 0;
};
//! [0]

View File

@ -48,13 +48,27 @@
**
****************************************************************************/
#include <QtWidgets>
#include "characterwidget.h"
#include "mainwindow.h"
#include "characterwidget.h"
#include <QApplication>
#include <QBoxLayout>
#include <QCheckBox>
#include <QClipboard>
#include <QDesktopWidget>
#include <QDialog>
#include <QDialogButtonBox>
#include <QFontComboBox>
#include <QLabel>
#include <QLineEdit>
#include <QMenuBar>
#include <QPlainTextEdit>
#include <QPushButton>
#include <QScrollArea>
#include <QStatusBar>
#include <QTextStream>
//! [0]
Q_DECLARE_METATYPE(QFontComboBox::FontFilter)
MainWindow::MainWindow(QWidget *parent)

View File

@ -48,10 +48,11 @@
**
****************************************************************************/
#include <QtWidgets>
#include "codeeditor.h"
#include <QPainter>
#include <QTextBlock>
//![constructor]
CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent)
@ -157,8 +158,8 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
//![extraAreaPaintEvent_1]
QTextBlock block = firstVisibleBlock();
int blockNumber = block.blockNumber();
int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top();
int bottom = top + (int) blockBoundingRect(block).height();
int top = qRound(blockBoundingGeometry(block).translated(contentOffset()).top());
int bottom = top + qRound(blockBoundingRect(block).height());
//![extraAreaPaintEvent_1]
//![extraAreaPaintEvent_2]
@ -172,7 +173,7 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
block = block.next();
top = bottom;
bottom = top + (int) blockBoundingRect(block).height();
bottom = top + qRound(blockBoundingRect(block).height());
++blockNumber;
}
}

View File

@ -80,7 +80,7 @@ protected:
private slots:
void updateLineNumberAreaWidth(int newBlockCount);
void highlightCurrentLine();
void updateLineNumberArea(const QRect &, int);
void updateLineNumberArea(const QRect &rect, int dy);
private:
QWidget *lineNumberArea;
@ -92,16 +92,17 @@ private:
class LineNumberArea : public QWidget
{
public:
LineNumberArea(CodeEditor *editor) : QWidget(editor) {
codeEditor = editor;
}
LineNumberArea(CodeEditor *editor) : QWidget(editor), codeEditor(editor)
{}
QSize sizeHint() const override {
QSize sizeHint() const override
{
return QSize(codeEditor->lineNumberAreaWidth(), 0);
}
protected:
void paintEvent(QPaintEvent *event) override {
void paintEvent(QPaintEvent *event) override
{
codeEditor->lineNumberAreaPaintEvent(event);
}

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtWidgets>
#include <QApplication>
#include "codeeditor.h"

View File

@ -50,7 +50,8 @@
#include "digitalclock.h"
#include <QtWidgets>
#include <QTime>
#include <QTimer>
//! [0]
DigitalClock::DigitalClock(QWidget *parent)

View File

@ -48,10 +48,15 @@
**
****************************************************************************/
#include <QtWidgets>
#include "window.h"
#include <QCheckBox>
#include <QGridLayout>
#include <QGroupBox>
#include <QMenu>
#include <QPushButton>
#include <QRadioButton>
//! [0]
Window::Window(QWidget *parent)
: QWidget(parent)

View File

@ -50,7 +50,8 @@
#include "iconpreviewarea.h"
#include <QtWidgets>
#include <QGridLayout>
#include <QLabel>
//! [0]
IconPreviewArea::IconPreviewArea(QWidget *parent)

View File

@ -50,7 +50,7 @@
#include "iconsizespinbox.h"
#include <QtWidgets>
#include <QRegularExpression>
//! [0]
IconSizeSpinBox::IconSizeSpinBox(QWidget *parent)

View File

@ -51,7 +51,7 @@
#include "imagedelegate.h"
#include "iconpreviewarea.h"
#include <QtWidgets>
#include <QComboBox>
//! [0]
ImageDelegate::ImageDelegate(QObject *parent)

View File

@ -48,14 +48,29 @@
**
****************************************************************************/
#include <QtWidgets>
#include "mainwindow.h"
#include "iconpreviewarea.h"
#include "iconsizespinbox.h"
#include "imagedelegate.h"
#include "mainwindow.h"
#include <memory>
#include <QApplication>
#include <QButtonGroup>
#include <QCheckBox>
#include <QFileDialog>
#include <QHeaderView>
#include <QFormLayout>
#include <QGridLayout>
#include <QGroupBox>
#include <QImageReader>
#include <QLabel>
#include <QMenuBar>
#include <QMessageBox>
#include <QRadioButton>
#include <QScreen>
#include <QStandardPaths>
#include <QStyleFactory>
#include <QTableWidget>
#include <QWindow>
//! [40]
enum { OtherSize = QStyle::PM_CustomBase };

View File

@ -50,7 +50,24 @@
#include "imageviewer.h"
#include <QtWidgets>
#include <QApplication>
#include <QClipboard>
#include <QColorSpace>
#include <QDir>
#include <QFileDialog>
#include <QImageReader>
#include <QImageWriter>
#include <QLabel>
#include <QMenuBar>
#include <QMessageBox>
#include <QMimeData>
#include <QPainter>
#include <QScreen>
#include <QScrollArea>
#include <QScrollBar>
#include <QStandardPaths>
#include <QStatusBar>
#if defined(QT_PRINTSUPPORT_LIB)
#include <QtPrintSupport/qtprintsupportglobal.h>
#if QT_CONFIG(printdialog)
@ -60,8 +77,8 @@
//! [0]
ImageViewer::ImageViewer(QWidget *parent)
: QMainWindow(parent), imageLabel(new QLabel),
scrollArea(new QScrollArea), scaleFactor(1)
: QMainWindow(parent), imageLabel(new QLabel)
, scrollArea(new QScrollArea)
{
imageLabel->setBackgroundRole(QPalette::Base);
imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);

View File

@ -98,7 +98,7 @@ private:
QImage image;
QLabel *imageLabel;
QScrollArea *scrollArea;
double scaleFactor;
double scaleFactor = 1;
#ifndef QT_NO_PRINTER
QPrinter printer;

View File

@ -48,10 +48,14 @@
**
****************************************************************************/
#include <QtWidgets>
#include "window.h"
#include <QComboBox>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
//! [0]
Window::Window(QWidget *parent)
: QWidget(parent)
@ -197,6 +201,7 @@ void Window::echoChanged(int index)
break;
case 3:
echoLineEdit->setEchoMode(QLineEdit::NoEcho);
break;
}
}
//! [9]
@ -215,6 +220,7 @@ void Window::validatorChanged(int index)
case 2:
validatorLineEdit->setValidator(new QDoubleValidator(-999.0,
999.0, 2, validatorLineEdit));
break;
}
validatorLineEdit->clear();
@ -233,6 +239,7 @@ void Window::alignmentChanged(int index)
break;
case 2:
alignmentLineEdit->setAlignment(Qt::AlignRight);
break;
}
}
//! [11]
@ -254,6 +261,7 @@ void Window::inputMaskChanged(int index)
break;
case 3:
inputMaskLineEdit->setInputMask(">AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;#");
break;
}
}
//! [12]
@ -267,6 +275,7 @@ void Window::accessChanged(int index)
break;
case 1:
accessLineEdit->setReadOnly(true);
break;
}
}
//! [13]

View File

@ -50,7 +50,15 @@
#include "movieplayer.h"
#include <QtWidgets>
#include <QCheckBox>
#include <QFileDialog>
#include <QLabel>
#include <QMovie>
#include <QSlider>
#include <QSpinBox>
#include <QStyle>
#include <QToolButton>
#include <QVBoxLayout>
MoviePlayer::MoviePlayer(QWidget *parent)
: QWidget(parent)

View File

@ -48,11 +48,17 @@
**
****************************************************************************/
#include <QtWidgets>
#include "mainwindow.h"
#include "scribblearea.h"
#include <QApplication>
#include <QColorDialog>
#include <QFileDialog>
#include <QImageWriter>
#include <QInputDialog>
#include <QMenuBar>
#include <QMessageBox>
//! [0]
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), scribbleArea(new ScribbleArea(this))
@ -71,11 +77,10 @@ MainWindow::MainWindow(QWidget *parent)
void MainWindow::closeEvent(QCloseEvent *event)
//! [1] //! [2]
{
if (maybeSave()) {
if (maybeSave())
event->accept();
} else {
else
event->ignore();
}
}
//! [2]
@ -231,11 +236,10 @@ bool MainWindow::maybeSave()
"Do you want to save your changes?"),
QMessageBox::Save | QMessageBox::Discard
| QMessageBox::Cancel);
if (ret == QMessageBox::Save) {
if (ret == QMessageBox::Save)
return saveFile("png");
} else if (ret == QMessageBox::Cancel) {
else if (ret == QMessageBox::Cancel)
return false;
}
}
return true;
}
@ -252,10 +256,8 @@ bool MainWindow::saveFile(const QByteArray &fileFormat)
tr("%1 Files (*.%2);;All Files (*)")
.arg(QString::fromLatin1(fileFormat.toUpper()))
.arg(QString::fromLatin1(fileFormat)));
if (fileName.isEmpty()) {
if (fileName.isEmpty())
return false;
} else {
return scribbleArea->saveImage(fileName, fileFormat.constData());
}
return scribbleArea->saveImage(fileName, fileFormat.constData());
}
//! [20]

View File

@ -50,7 +50,9 @@
#include "scribblearea.h"
#include <QtWidgets>
#include <QMouseEvent>
#include <QPainter>
#if defined(QT_PRINTSUPPORT_LIB)
#include <QtPrintSupport/qtprintsupportglobal.h>
#if QT_CONFIG(printdialog)
@ -64,10 +66,6 @@ ScribbleArea::ScribbleArea(QWidget *parent)
: QWidget(parent)
{
setAttribute(Qt::WA_StaticContents);
modified = false;
scribbling = false;
myPenWidth = 1;
myPenColor = Qt::blue;
}
//! [0]
@ -98,9 +96,8 @@ bool ScribbleArea::saveImage(const QString &fileName, const char *fileFormat)
if (visibleImage.save(fileName, fileFormat)) {
modified = false;
return true;
} else {
return false;
}
return false;
}
//! [4]

View File

@ -88,10 +88,10 @@ private:
void drawLineTo(const QPoint &endPoint);
void resizeImage(QImage *image, const QSize &newSize);
bool modified;
bool scribbling;
int myPenWidth;
QColor myPenColor;
bool modified = false;
bool scribbling = false;
int myPenWidth = 1;
QColor myPenColor = Qt::blue;
QImage image;
QPoint lastPoint;
};

View File

@ -48,10 +48,15 @@
**
****************************************************************************/
#include <QtWidgets>
#include "shapedclock.h"
#include <QAction>
#include <QCoreApplication>
#include <QMouseEvent>
#include <QPainter>
#include <QTime>
#include <QTimer>
//! [0]
ShapedClock::ShapedClock(QWidget *parent)
: QWidget(parent, Qt::FramelessWindowHint | Qt::WindowSystemMenuHint)

View File

@ -50,7 +50,10 @@
#include "slidersgroup.h"
#include <QtWidgets>
#include <QBoxLayout>
#include <QDial>
#include <QScrollBar>
#include <QSlider>
//! [0]
SlidersGroup::SlidersGroup(Qt::Orientation orientation, const QString &title,

View File

@ -48,11 +48,16 @@
**
****************************************************************************/
#include <QtWidgets>
#include "slidersgroup.h"
#include "window.h"
#include <QCheckBox>
#include <QComboBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QSpinBox>
#include <QStackedWidget>
//! [0]
Window::Window(QWidget *parent)
: QWidget(parent)

View File

@ -48,10 +48,16 @@
**
****************************************************************************/
#include <QtWidgets>
#include "window.h"
#include <QCheckBox>
#include <QComboBox>
#include <QDateTimeEdit>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QSpinBox>
//! [0]
Window::Window(QWidget *parent)
: QWidget(parent)

View File

@ -50,7 +50,10 @@
#include "norwegianwoodstyle.h"
#include <QtWidgets>
#include <QComboBox>
#include <QPainter>
#include <QPushButton>
#include <QStyleFactory>
NorwegianWoodStyle::NorwegianWoodStyle() :
QProxyStyle(QStyleFactory::create("windows"))

View File

@ -51,7 +51,24 @@
#include "widgetgallery.h"
#include "norwegianwoodstyle.h"
#include <QtWidgets>
#include <QApplication>
#include <QCheckBox>
#include <QComboBox>
#include <QDateTimeEdit>
#include <QDial>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
#include <QProgressBar>
#include <QPushButton>
#include <QRadioButton>
#include <QScrollBar>
#include <QSpinBox>
#include <QStyleFactory>
#include <QTableWidget>
#include <QTextEdit>
#include <QTimer>
//! [0]
WidgetGallery::WidgetGallery(QWidget *parent)

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtWidgets>
#include <QApplication>
#include "mainwindow.h"

View File

@ -48,11 +48,11 @@
**
****************************************************************************/
#include <QtWidgets>
#include "mainwindow.h"
#include "stylesheeteditor.h"
#include <QMessageBox>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{

View File

@ -51,7 +51,7 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtWidgets>
#include <QMainWindow>
#include "ui_mainwindow.h"

View File

@ -50,7 +50,9 @@
#include "stylesheeteditor.h"
#include <QtWidgets>
#include <QFile>
#include <QRegularExpression>
#include <QStyleFactory>
StyleSheetEditor::StyleSheetEditor(QWidget *parent)
: QDialog(parent)

View File

@ -48,8 +48,6 @@
**
****************************************************************************/
#include <QtWidgets>
#include "mainwindow.h"
#include "tabletapplication.h"
#include "tabletcanvas.h"

View File

@ -48,14 +48,19 @@
**
****************************************************************************/
#include <QtWidgets>
#include "mainwindow.h"
#include "tabletcanvas.h"
#include <QApplication>
#include <QColorDialog>
#include <QDir>
#include <QFileDialog>
#include <QMenuBar>
#include <QMessageBox>
//! [0]
MainWindow::MainWindow(TabletCanvas *canvas)
: m_canvas(canvas), m_colorDialog(nullptr)
: m_canvas(canvas)
{
createMenus();
setWindowTitle(tr("Tablet Example"));

View File

@ -81,7 +81,7 @@ private:
void createMenus();
TabletCanvas *m_canvas;
QColorDialog *m_colorDialog;
QColorDialog *m_colorDialog = nullptr;
};
//! [0]

View File

@ -50,8 +50,6 @@
#include "tabletapplication.h"
#include <QtWidgets>
//! [0]
bool TabletApplication::event(QEvent *event)
{

View File

@ -48,21 +48,16 @@
**
****************************************************************************/
#include <QtWidgets>
#include <math.h>
#include "tabletcanvas.h"
#include <QCoreApplication>
#include <QPainter>
#include <QtMath>
//! [0]
TabletCanvas::TabletCanvas()
: QWidget(nullptr)
, m_alphaChannelValuator(TangentialPressureValuator)
, m_colorSaturationValuator(NoValuator)
, m_lineWidthValuator(PressureValuator)
, m_color(Qt::red)
, m_brush(m_color)
, m_pen(m_brush, 1.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)
, m_deviceDown(false)
: QWidget(nullptr), m_brush(m_color)
, m_pen(m_brush, 1.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)
{
resize(500, 500);
setAutoFillBackground(true);
@ -138,7 +133,7 @@ void TabletCanvas::tabletEvent(QTabletEvent *event)
void TabletCanvas::initPixmap()
{
qreal dpr = devicePixelRatioF();
QPixmap newPixmap = QPixmap(width() * dpr, height() * dpr);
QPixmap newPixmap = QPixmap(qRound(width() * dpr), qRound(height() * dpr));
newPixmap.setDevicePixelRatio(dpr);
newPixmap.fill(Qt::white);
QPainter painter(&newPixmap);
@ -208,7 +203,7 @@ void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
const QString error(tr("This input device is not supported by the example."));
#if QT_CONFIG(statustip)
QStatusTipEvent status(error);
QApplication::sendEvent(this, &status);
QCoreApplication::sendEvent(this, &status);
#else
qWarning() << error;
#endif
@ -219,7 +214,7 @@ void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
const QString error(tr("Unknown tablet device - treating as stylus"));
#if QT_CONFIG(statustip)
QStatusTipEvent status(error);
QApplication::sendEvent(this, &status);
QCoreApplication::sendEvent(this, &status);
#else
qWarning() << error;
#endif
@ -261,7 +256,8 @@ void TabletCanvas::updateBrush(const QTabletEvent *event)
m_color.setAlpha(255);
break;
case TiltValuator:
m_color.setAlpha(maximum(abs(vValue - 127), abs(hValue - 127)));
m_color.setAlpha(std::max(std::abs(vValue - 127),
std::abs(hValue - 127)));
break;
default:
m_color.setAlpha(255);
@ -288,7 +284,8 @@ void TabletCanvas::updateBrush(const QTabletEvent *event)
m_pen.setWidthF(pressureToWidth(event->pressure()));
break;
case TiltValuator:
m_pen.setWidthF(maximum(abs(vValue - 127), abs(hValue - 127)) / 12);
m_pen.setWidthF(std::max(std::abs(vValue - 127),
std::abs(hValue - 127)) / 12);
break;
default:
m_pen.setWidthF(1);

View File

@ -51,14 +51,13 @@
#ifndef TABLETCANVAS_H
#define TABLETCANVAS_H
#include <QWidget>
#include <QBrush>
#include <QColor>
#include <QPen>
#include <QPixmap>
#include <QPoint>
#include <QTabletEvent>
#include <QColor>
#include <QBrush>
#include <QPen>
#include <QPoint>
#include <QWidget>
QT_BEGIN_NAMESPACE
class QPaintEvent;
@ -92,8 +91,6 @@ public:
{ return m_color; }
void setTabletDevice(QTabletEvent *event)
{ updateCursor(event); }
int maximum(int a, int b)
{ return a > b ? a : b; }
protected:
void tabletEvent(QTabletEvent *event) override;
@ -108,19 +105,19 @@ private:
void updateBrush(const QTabletEvent *event);
void updateCursor(const QTabletEvent *event);
Valuator m_alphaChannelValuator;
Valuator m_colorSaturationValuator;
Valuator m_lineWidthValuator;
QColor m_color;
Valuator m_alphaChannelValuator = TangentialPressureValuator;
Valuator m_colorSaturationValuator = NoValuator;
Valuator m_lineWidthValuator = PressureValuator;
QColor m_color = Qt::red;
QPixmap m_pixmap;
QBrush m_brush;
QPen m_pen;
bool m_deviceDown;
bool m_deviceDown = false;
struct Point {
QPointF pos;
qreal pressure;
qreal rotation;
qreal pressure = 0;
qreal rotation = 0;
} lastPoint;
};
//! [0]

View File

@ -50,16 +50,16 @@
#include "tetrixboard.h"
#include <QtWidgets>
#include <QKeyEvent>
#include <QLabel>
#include <QPainter>
//! [0]
TetrixBoard::TetrixBoard(QWidget *parent)
: QFrame(parent)
: QFrame(parent), isStarted(false), isPaused(false)
{
setFrameStyle(QFrame::Panel | QFrame::Sunken);
setFocusPolicy(Qt::StrongFocus);
isStarted = false;
isPaused = false;
clearBoard();
nextPiece.setRandomShape();
@ -396,7 +396,7 @@ bool TetrixBoard::tryMove(const TetrixPiece &newPiece, int newX, int newY)
//! [36]
void TetrixBoard::drawSquare(QPainter &painter, int x, int y, TetrixShape shape)
{
static const QRgb colorTable[8] = {
static constexpr QRgb colorTable[8] = {
0x000000, 0xCC6666, 0x66CC66, 0x6666CC,
0xCCCC66, 0xCC66CC, 0x66CCCC, 0xDAAA00
};

View File

@ -62,7 +62,7 @@ void TetrixPiece::setRandomShape()
//! [1]
void TetrixPiece::setShape(TetrixShape shape)
{
static const int coordsTable[8][4][2] = {
static constexpr int coordsTable[8][4][2] = {
{ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } },
{ { 0, -1 }, { 0, 0 }, { -1, 0 }, { -1, 1 } },
{ { 0, -1 }, { 0, 0 }, { 1, 0 }, { 1, 1 } },

View File

@ -48,23 +48,24 @@
**
****************************************************************************/
#include <QtWidgets>
#include "tetrixboard.h"
#include "tetrixwindow.h"
#include <QCoreApplication>
#include <QGridLayout>
#include <QLabel>
#include <QLCDNumber>
#include <QPushButton>
//! [0]
TetrixWindow::TetrixWindow(QWidget *parent)
: QWidget(parent)
: QWidget(parent), board(new TetrixBoard)
{
board = new TetrixBoard;
//! [0]
nextPieceLabel = new QLabel;
nextPieceLabel->setFrameStyle(QFrame::Box | QFrame::Raised);
nextPieceLabel->setAlignment(Qt::AlignCenter);
board->setNextPieceLabel(nextPieceLabel);
//! [1]
scoreLcd = new QLCDNumber(5);
scoreLcd->setSegmentStyle(QLCDNumber::Filled);
@ -86,7 +87,7 @@ TetrixWindow::TetrixWindow(QWidget *parent)
connect(startButton, &QPushButton::clicked, board, &TetrixBoard::start);
//! [4] //! [5]
connect(quitButton , &QPushButton::clicked, qApp, &QApplication::quit);
connect(quitButton , &QPushButton::clicked, qApp, &QCoreApplication::quit);
connect(pauseButton, &QPushButton::clicked, board, &TetrixBoard::pause);
#if __cplusplus >= 201402L
connect(board, &TetrixBoard::scoreChanged,

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtWidgets>
#include <QApplication>
#include "sortingbox.h"

View File

@ -50,7 +50,13 @@
#include "sortingbox.h"
#include <QtWidgets>
#include <QMouseEvent>
#include <QIcon>
#include <QPainter>
#include <QRandomGenerator>
#include <QStyle>
#include <QToolButton>
#include <QToolTip>
//! [0]
SortingBox::SortingBox(QWidget *parent)
@ -277,12 +283,12 @@ QToolButton *SortingBox::createToolButton(const QString &toolTip,
QPoint SortingBox::initialItemPosition(const QPainterPath &path)
{
int x;
int y = (height() - (int)path.controlPointRect().height()) / 2;
int y = (height() - qRound(path.controlPointRect().height()) / 2);
if (shapeItems.size() == 0)
x = ((3 * width()) / 2 - (int)path.controlPointRect().width()) / 2;
x = ((3 * width()) / 2 - qRound(path.controlPointRect().width())) / 2;
else
x = (width() / shapeItems.size()
- (int)path.controlPointRect().width()) / 2;
- qRound(path.controlPointRect().width())) / 2;
return QPoint(x, y);
}

View File

@ -99,7 +99,7 @@ private:
const char *member);
//! [2]
QList<ShapeItem> shapeItems;
QVector<ShapeItem> shapeItems;
QPainterPath circlePath;
QPainterPath squarePath;
QPainterPath trianglePath;

View File

@ -50,7 +50,7 @@
#include "validatorwidget.h"
#include <QtWidgets>
#include <QIntValidator>
ValidatorWidget::ValidatorWidget(QWidget *parent)
: QWidget(parent)

View File

@ -50,11 +50,13 @@
#include "wigglywidget.h"
#include <QtWidgets>
#include <QFontMetrics>
#include <QPainter>
#include <QTimerEvent>
//! [0]
WigglyWidget::WigglyWidget(QWidget *parent)
: QWidget(parent)
: QWidget(parent), step(0)
{
setBackgroundRole(QPalette::Midlight);
setAutoFillBackground(true);
@ -63,7 +65,6 @@ WigglyWidget::WigglyWidget(QWidget *parent)
newFont.setPointSize(newFont.pointSize() + 20);
setFont(newFont);
step = 0;
timer.start(60, this);
}
//! [0]
@ -72,7 +73,7 @@ WigglyWidget::WigglyWidget(QWidget *parent)
void WigglyWidget::paintEvent(QPaintEvent * /* event */)
//! [1] //! [2]
{
static const int sineTable[16] = {
static constexpr int sineTable[16] = {
0, 38, 71, 92, 100, 92, 71, 38, 0, -38, -71, -92, -100, -92, -71, -38
};

View File

@ -48,10 +48,15 @@
**
****************************************************************************/
#include <QtWidgets>
#include "controllerwindow.h"
#include <QCheckBox>
#include <QCoreApplication>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QPushButton>
#include <QRadioButton>
//! [0]
ControllerWindow::ControllerWindow(QWidget *parent)
: QWidget(parent)
@ -63,7 +68,7 @@ ControllerWindow::ControllerWindow(QWidget *parent)
quitButton = new QPushButton(tr("&Quit"));
connect(quitButton, &QPushButton::clicked,
qApp, &QApplication::quit);
qApp, &QCoreApplication::quit);
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch();
@ -83,26 +88,25 @@ ControllerWindow::ControllerWindow(QWidget *parent)
//! [1]
void ControllerWindow::updatePreview()
{
Qt::WindowFlags flags = 0;
Qt::WindowFlags flags;
if (windowRadioButton->isChecked()) {
if (windowRadioButton->isChecked())
flags = Qt::Window;
} else if (dialogRadioButton->isChecked()) {
else if (dialogRadioButton->isChecked())
flags = Qt::Dialog;
} else if (sheetRadioButton->isChecked()) {
else if (sheetRadioButton->isChecked())
flags = Qt::Sheet;
} else if (drawerRadioButton->isChecked()) {
else if (drawerRadioButton->isChecked())
flags = Qt::Drawer;
} else if (popupRadioButton->isChecked()) {
else if (popupRadioButton->isChecked())
flags = Qt::Popup;
} else if (toolRadioButton->isChecked()) {
else if (toolRadioButton->isChecked())
flags = Qt::Tool;
} else if (toolTipRadioButton->isChecked()) {
else if (toolTipRadioButton->isChecked())
flags = Qt::ToolTip;
} else if (splashScreenRadioButton->isChecked()) {
else if (splashScreenRadioButton->isChecked())
flags = Qt::SplashScreen;
//! [1] //! [2]
}
//! [2] //! [3]
if (msWindowsFixedSizeDialogCheckBox->isChecked())

View File

@ -50,7 +50,9 @@
#include "previewwindow.h"
#include <QtWidgets>
#include <QPushButton>
#include <QTextEdit>
#include <QVBoxLayout>
//! [0]
PreviewWindow::PreviewWindow(QWidget *parent)
@ -81,23 +83,22 @@ void PreviewWindow::setWindowFlags(Qt::WindowFlags flags)
QString text;
Qt::WindowFlags type = (flags & Qt::WindowType_Mask);
if (type == Qt::Window) {
if (type == Qt::Window)
text = "Qt::Window";
} else if (type == Qt::Dialog) {
else if (type == Qt::Dialog)
text = "Qt::Dialog";
} else if (type == Qt::Sheet) {
else if (type == Qt::Sheet)
text = "Qt::Sheet";
} else if (type == Qt::Drawer) {
else if (type == Qt::Drawer)
text = "Qt::Drawer";
} else if (type == Qt::Popup) {
else if (type == Qt::Popup)
text = "Qt::Popup";
} else if (type == Qt::Tool) {
else if (type == Qt::Tool)
text = "Qt::Tool";
} else if (type == Qt::ToolTip) {
else if (type == Qt::ToolTip)
text = "Qt::ToolTip";
} else if (type == Qt::SplashScreen) {
else if (type == Qt::SplashScreen)
text = "Qt::SplashScreen";
}
if (flags & Qt::MSWindowsFixedSizeDialogHint)
text += "\n| Qt::MSWindowsFixedSizeDialogHint";

View File

@ -17,7 +17,7 @@ include(g++-base.conf)
MAKEFILE_GENERATOR = MINGW
QMAKE_PLATFORM = win32 mingw
CONFIG += debug_and_release debug_and_release_target precompile_header
CONFIG += precompile_header
DEFINES += UNICODE _UNICODE WIN32 MINGW_HAS_SECURE_API=1
QMAKE_COMPILER_DEFINES += __GNUC__ _WIN32
# can't add 'DEFINES += WIN64' and 'QMAKE_COMPILER_DEFINES += _WIN64' defines for

View File

@ -5,7 +5,7 @@ defineReplace(qtPlatformTargetSuffix) {
else: CONFIG(debug, debug|release) {
!debug_and_release|build_pass {
mac: return($${suffix}_debug)
win32: return($${suffix}d)
win32:!gcc: return($${suffix}d)
}
}
return($$suffix)

View File

@ -53,6 +53,7 @@ CONFIG(debug, debug|release) {
}
!isEmpty(BUILD_PASS): BUILDSUBDIR = $$lower($$BUILD_PASS)/
else: BUILDSUBDIR = $$PWD/
# c++11 is needed by MinGW to get support for unordered_map.
CONFIG += stl exceptions c++11 c++14

View File

@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE
# define QLIBRARY_AS_DEBUG true
#endif
#if defined(Q_OS_UNIX)
#if defined(Q_OS_UNIX) || (defined(Q_CC_MINGW) && !QT_CONFIG(debug_and_release))
// We don't use separate debug and release libs on UNIX, so we want
// to allow loading plugins, regardless of how they were built.
# define QT_NO_DEBUG_PLUGIN_CHECK

View File

@ -50,8 +50,6 @@
#include "private/qfreelist_p.h"
#include "private/qlocking_p.h"
#include <chrono>
QT_BEGIN_NAMESPACE
/*
@ -67,9 +65,6 @@ QT_BEGIN_NAMESPACE
*/
namespace {
using ms = std::chrono::milliseconds;
enum {
StateMask = 0x3,
StateLockedForRead = 0x1,
@ -279,7 +274,7 @@ bool QReadWriteLock::tryLockForRead(int timeout)
d = d_ptr.loadAcquire();
continue;
}
return d->lockForRead(lock, timeout);
return d->lockForRead(timeout);
}
}
@ -383,7 +378,7 @@ bool QReadWriteLock::tryLockForWrite(int timeout)
d = d_ptr.loadAcquire();
continue;
}
return d->lockForWrite(lock, timeout);
return d->lockForWrite(timeout);
}
}
@ -466,9 +461,9 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
}
bool QReadWriteLockPrivate::lockForRead(std::unique_lock<std::mutex> &lock, int timeout)
bool QReadWriteLockPrivate::lockForRead(int timeout)
{
Q_ASSERT(!mutex.try_lock()); // mutex must be locked when entering this function
Q_ASSERT(!mutex.tryLock()); // mutex must be locked when entering this function
QElapsedTimer t;
if (timeout > 0)
@ -482,10 +477,10 @@ bool QReadWriteLockPrivate::lockForRead(std::unique_lock<std::mutex> &lock, int
if (elapsed > timeout)
return false;
waitingReaders++;
readerCond.wait_for(lock, ms{timeout - elapsed});
readerCond.wait(&mutex, timeout - elapsed);
} else {
waitingReaders++;
readerCond.wait(lock);
readerCond.wait(&mutex);
}
waitingReaders--;
}
@ -494,9 +489,9 @@ bool QReadWriteLockPrivate::lockForRead(std::unique_lock<std::mutex> &lock, int
return true;
}
bool QReadWriteLockPrivate::lockForWrite(std::unique_lock<std::mutex> &lock, int timeout)
bool QReadWriteLockPrivate::lockForWrite(int timeout)
{
Q_ASSERT(!mutex.try_lock()); // mutex must be locked when entering this function
Q_ASSERT(!mutex.tryLock()); // mutex must be locked when entering this function
QElapsedTimer t;
if (timeout > 0)
@ -511,15 +506,15 @@ bool QReadWriteLockPrivate::lockForWrite(std::unique_lock<std::mutex> &lock, int
if (waitingReaders && !waitingWriters && !writerCount) {
// We timed out and now there is no more writers or waiting writers, but some
// readers were queueud (probably because of us). Wake the waiting readers.
readerCond.notify_all();
readerCond.wakeAll();
}
return false;
}
waitingWriters++;
writerCond.wait_for(lock, ms{timeout - elapsed});
writerCond.wait(&mutex, timeout - elapsed);
} else {
waitingWriters++;
writerCond.wait(lock);
writerCond.wait(&mutex);
}
waitingWriters--;
}
@ -532,11 +527,11 @@ bool QReadWriteLockPrivate::lockForWrite(std::unique_lock<std::mutex> &lock, int
void QReadWriteLockPrivate::unlock()
{
Q_ASSERT(!mutex.try_lock()); // mutex must be locked when entering this function
Q_ASSERT(!mutex.tryLock()); // mutex must be locked when entering this function
if (waitingWriters)
writerCond.notify_one();
writerCond.wakeOne();
else if (waitingReaders)
readerCond.notify_all();
readerCond.wakeAll();
}
bool QReadWriteLockPrivate::recursiveLockForRead(int timeout)
@ -552,7 +547,7 @@ bool QReadWriteLockPrivate::recursiveLockForRead(int timeout)
return true;
}
if (!lockForRead(lock, timeout))
if (!lockForRead(timeout))
return false;
currentReaders.insert(self, 1);
@ -570,7 +565,7 @@ bool QReadWriteLockPrivate::recursiveLockForWrite(int timeout)
return true;
}
if (!lockForWrite(lock, timeout))
if (!lockForWrite(timeout))
return false;
currentWriter = self;

View File

@ -54,9 +54,7 @@
#include <QtCore/private/qglobal_p.h>
#include <QtCore/qhash.h>
#include <mutex>
#include <condition_variable>
#include <QtCore/qwaitcondition.h>
QT_REQUIRE_CONFIG(thread);
@ -68,9 +66,9 @@ public:
explicit QReadWriteLockPrivate(bool isRecursive = false)
: recursive(isRecursive) {}
std::mutex mutex;
std::condition_variable writerCond;
std::condition_variable readerCond;
QMutex mutex;
QWaitCondition writerCond;
QWaitCondition readerCond;
int readerCount = 0;
int writerCount = 0;
int waitingReaders = 0;
@ -78,8 +76,8 @@ public:
const bool recursive;
//Called with the mutex locked
bool lockForWrite(std::unique_lock<std::mutex> &lock, int timeout);
bool lockForRead(std::unique_lock<std::mutex> &lock, int timeout);
bool lockForWrite(int timeout);
bool lockForRead(int timeout);
void unlock();
//memory management

View File

@ -931,6 +931,30 @@ QWheelEvent::~QWheelEvent()
\endlist
*/
/*!
\fn QPoint QWheelEvent::position() const
Returns the position of the mouse cursor relative to the widget
that received the event.
If you move your widgets around in response to mouse events,
use globalPosition() instead of this function.
\sa globalPosition()
*/
/*!
\fn QPoint QWheelEvent::globalPosition() const
Returns the global position of the mouse pointer \e{at the time
of the event}. This is important on asynchronous window systems
such as X11; whenever you move your widgets around in response to
mouse events, globalPosition() can differ a lot from the current
cursor position returned by QCursor::pos().
\sa position()
*/
#if QT_DEPRECATED_SINCE(5, 15)
/*!
\fn int QWheelEvent::delta() const

View File

@ -959,6 +959,7 @@ public:
friend class QGuiApplicationPrivate;
friend class QApplication;
friend class QApplicationPrivate;
friend class QQuickPointerTouchEvent;
};
#if QT_DEPRECATED_SINCE(5, 0)

View File

@ -67,7 +67,8 @@ public:
state(Qt::TouchPointReleased),
pressure(-1),
rotation(0),
ellipseDiameters(0, 0)
ellipseDiameters(0, 0),
stationaryWithModifiedProperty(false)
{ }
inline QTouchEventTouchPointPrivate *detach()
@ -91,6 +92,7 @@ public:
QSizeF ellipseDiameters;
QVector2D velocity;
QTouchEvent::TouchPoint::InfoFlags flags;
bool stationaryWithModifiedProperty : 1;
QVector<QPointF> rawScreenPositions;
};

View File

@ -2845,10 +2845,12 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
if (touchPoint.state() == Qt::TouchPointStationary) {
if (touchInfo.touchPoint.velocity() != touchPoint.velocity()) {
touchInfo.touchPoint.setVelocity(touchPoint.velocity());
touchPoint.d->stationaryWithModifiedProperty = true;
stationaryTouchPointChangedProperty = true;
}
if (!qFuzzyCompare(touchInfo.touchPoint.pressure(), touchPoint.pressure())) {
touchInfo.touchPoint.setPressure(touchPoint.pressure());
touchPoint.d->stationaryWithModifiedProperty = true;
stationaryTouchPointChangedProperty = true;
}
} else {

View File

@ -1022,7 +1022,7 @@ void QShaderDescriptionPrivate::loadDoc(const QJsonDocument &doc)
return;
}
Q_ASSERT(ref.load() == 1); // must be detached
Q_ASSERT(ref.loadRelaxed() == 1); // must be detached
inVars.clear();
outVars.clear();

View File

@ -1970,9 +1970,12 @@ void QTextDocument::print(QPagedPaintDevice *printer) const
QRectF body = QRectF(QPointF(0, 0), d->pageSize);
QPointF pageNumberPos;
qreal sourceDpiX = qt_defaultDpiX();
qreal sourceDpiY = qt_defaultDpiY();
const qreal dpiScaleX = qreal(printer->logicalDpiX()) / sourceDpiX;
const qreal dpiScaleY = qreal(printer->logicalDpiY()) / sourceDpiY;
if (documentPaginated) {
qreal sourceDpiX = qt_defaultDpi();
qreal sourceDpiY = sourceDpiX;
QPaintDevice *dev = doc->documentLayout()->paintDevice();
if (dev) {
@ -1980,9 +1983,6 @@ void QTextDocument::print(QPagedPaintDevice *printer) const
sourceDpiY = dev->logicalDpiY();
}
const qreal dpiScaleX = qreal(printer->logicalDpiX()) / sourceDpiX;
const qreal dpiScaleY = qreal(printer->logicalDpiY()) / sourceDpiY;
// scale to dpi
p.scale(dpiScaleX, dpiScaleY);
@ -2011,15 +2011,21 @@ void QTextDocument::print(QPagedPaintDevice *printer) const
// copy the custom object handlers
layout->d_func()->handlers = documentLayout()->d_func()->handlers;
int dpiy = p.device()->logicalDpiY();
int margin = (int) ((2/2.54)*dpiy); // 2 cm margins
// 2 cm margins, scaled to device in QTextDocumentLayoutPrivate::layoutFrame
const int horizontalMargin = int((2/2.54)*sourceDpiX);
const int verticalMargin = int((2/2.54)*sourceDpiY);
QTextFrameFormat fmt = doc->rootFrame()->frameFormat();
fmt.setMargin(margin);
fmt.setLeftMargin(horizontalMargin);
fmt.setRightMargin(horizontalMargin);
fmt.setTopMargin(verticalMargin);
fmt.setBottomMargin(verticalMargin);
doc->rootFrame()->setFrameFormat(fmt);
// pageNumberPos must be in device coordinates, so scale to device here
const int dpiy = p.device()->logicalDpiY();
body = QRectF(0, 0, printer->width(), printer->height());
pageNumberPos = QPointF(body.width() - margin,
body.height() - margin
pageNumberPos = QPointF(body.width() - horizontalMargin * dpiScaleX,
body.height() - verticalMargin * dpiScaleY
+ QFontMetrics(doc->defaultFont(), p.device()).ascent()
+ 5 * dpiy / 72.0);
clonedDoc->setPageSize(body.size());

View File

@ -2915,24 +2915,24 @@ QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, in
{
QTextFrameFormat fformat = f->frameFormat();
// set sizes of this frame from the format
QFixed tm = QFixed::fromReal(fformat.topMargin());
QFixed tm = QFixed::fromReal(scaleToDevice(fformat.topMargin())).round();
if (tm != fd->topMargin) {
fd->topMargin = tm;
fullLayout = true;
}
QFixed bm = QFixed::fromReal(fformat.bottomMargin());
QFixed bm = QFixed::fromReal(scaleToDevice(fformat.bottomMargin())).round();
if (bm != fd->bottomMargin) {
fd->bottomMargin = bm;
fullLayout = true;
}
fd->leftMargin = QFixed::fromReal(fformat.leftMargin());
fd->rightMargin = QFixed::fromReal(fformat.rightMargin());
QFixed b = QFixed::fromReal(fformat.border());
fd->leftMargin = QFixed::fromReal(scaleToDevice(fformat.leftMargin())).round();
fd->rightMargin = QFixed::fromReal(scaleToDevice(fformat.rightMargin())).round();
QFixed b = QFixed::fromReal(scaleToDevice(fformat.border())).round();
if (b != fd->border) {
fd->border = b;
fullLayout = true;
}
QFixed p = QFixed::fromReal(fformat.padding());
QFixed p = QFixed::fromReal(scaleToDevice(fformat.padding())).round();
if (p != fd->padding) {
fd->padding = p;
fullLayout = true;

View File

@ -81,6 +81,11 @@ void QWasmBackingStore::updateTexture()
if (m_dirty.isNull())
return;
if (m_recreateTexture && m_texture->isCreated()) {
m_recreateTexture = false;
m_texture->destroy();
}
if (!m_texture->isCreated()) {
m_texture->setMinificationFilter(QOpenGLTexture::Nearest);
m_texture->setMagnificationFilter(QOpenGLTexture::Nearest);
@ -146,9 +151,7 @@ void QWasmBackingStore::resize(const QSize &size, const QRegion &staticContents)
m_image = QImage(size * window()->devicePixelRatio(), QImage::Format_RGB32);
m_image.setDevicePixelRatio(window()->devicePixelRatio());
if (m_texture->isCreated())
m_texture->destroy();
m_recreateTexture = true;
}
QImage QWasmBackingStore::toImage() const

View File

@ -64,6 +64,7 @@ private:
QImage m_image;
QScopedPointer<QOpenGLTexture> m_texture;
QRegion m_dirty;
bool m_recreateTexture = false;
};
QT_END_NAMESPACE

View File

@ -115,7 +115,7 @@ public:
BspTreeIndex,
NoIndex = -1
};
Q_ENUM(ItemIndexMethod)
enum SceneLayer {
ItemLayer = 0x1,
BackgroundLayer = 0x2,

View File

@ -615,7 +615,7 @@ public:
public:
int features;
QBrush defaultBackground;
QFont font;
QFont font; // Be careful using this font directly. Prefer using font.resolve( )
bool hasFont;
QHash<QString, QVariant> styleHints;
@ -3211,7 +3211,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
rule.drawRule(p, opt->rect);
toolOpt.rect = rule.contentsRect(opt->rect);
if (rule.hasFont)
toolOpt.font = rule.font;
toolOpt.font = rule.font.resolve(toolOpt.font);
drawControl(CE_ToolButtonLabel, &toolOpt, p, w);
}
@ -3514,7 +3514,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
const QFont oldFont = p->font();
if (rule.hasFont)
p->setFont(rule.font);
p->setFont(rule.font.resolve(p->font()));
if (rule.hasPosition() && rule.position()->textAlignment != 0) {
Qt::Alignment textAlignment = rule.position()->textAlignment;
@ -3678,7 +3678,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
subRule.configurePalette(&mi.palette, QPalette::HighlightedText, QPalette::Highlight);
QFont oldFont = p->font();
if (subRule.hasFont)
p->setFont(subRule.font.resolve(p->font()));
p->setFont(subRule.font.resolve(mi.font));
else
p->setFont(mi.font);
@ -4084,7 +4084,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
subRule.configurePalette(&boxCopy.palette, QPalette::ButtonText, QPalette::Button);
QFont oldFont = p->font();
if (subRule.hasFont)
p->setFont(subRule.font);
p->setFont(subRule.font.resolve(p->font()));
boxCopy.rect = subRule.contentsRect(opt->rect);
if (subRule.hasImage()) {
// the image is already drawn with CE_ToolBoxTabShape, adjust rect here
@ -4171,7 +4171,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
subRule.configurePalette(&tabCopy.palette, QPalette::WindowText, QPalette::Base);
QFont oldFont = p->font();
if (subRule.hasFont)
p->setFont(subRule.font);
p->setFont(subRule.font.resolve(p->font()));
if (subRule.hasBox() || !subRule.hasNativeBorder()) {
tabCopy.rect = ce == CE_TabBarTabShape ? subRule.borderRect(r)
: subRule.contentsRect(r);
@ -5035,8 +5035,12 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
bool nullIcon = hdr->icon.isNull();
const int margin = pixelMetric(QStyle::PM_HeaderMargin, hdr, w);
int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, w);
const QSize txt = subRule.hasFont ? QFontMetrics(subRule.font).size(0, hdr->text)
: hdr->fontMetrics.size(0, hdr->text);
QFontMetrics fm = hdr->fontMetrics;
if (subRule.hasFont) {
QFont styleFont = w ? subRule.font.resolve(w->font()) : subRule.font;
fm = QFontMetrics(styleFont);
}
const QSize txt = fm.size(0, hdr->text);
nativeContentsSize.setHeight(margin + qMax(iconSize, txt.height()) + margin);
nativeContentsSize.setWidth((nullIcon ? 0 : margin) + iconSize
+ (hdr->text.isNull() ? 0 : margin) + txt.width() + margin);

View File

@ -22,7 +22,7 @@ android:!android-embedded {
RESOURCES += android_testdata.qrc
}
win32 {
win32:debug_and_release {
CONFIG(debug, debug|release): LIBS += -Lstaticplugin/debug
else: LIBS += -Lstaticplugin/release
} else {

View File

@ -12,7 +12,7 @@ msvc: DEFINES += WIN32_MSVC
target.path = $$[QT_INSTALL_TESTS]/tst_qlibrary
INSTALLS += target
win32 {
win32:debug_and_release {
CONFIG(debug, debug|release) {
DESTDIR = ../debug/
} else {

View File

@ -13,12 +13,18 @@ msvc: DEFINES += WIN32_MSVC
# We want to test if we can load a shared library with *any* filename...
win32 {
CONFIG(debug, debug|release) {
BUILD_FOLDER = debug
debug_and_release {
CONFIG(debug, debug|release)) {
BUILD_FOLDER = debug
} else {
BUILD_FOLDER = release
}
DESTDIR = ../$$BUILD_FOLDER/
} else {
BUILD_FOLDER = release
BUILD_FOLDER =
DESTDIR = ../
}
DESTDIR = ../$$BUILD_FOLDER/
# vcproj and Makefile generators refer to target differently
contains(TEMPLATE,vc.*) {

View File

@ -3,7 +3,7 @@ TARGET = ../tst_qlibrary
QT = core testlib
SOURCES = ../tst_qlibrary.cpp
win32 {
win32:debug_and_release {
CONFIG(debug, debug|release) {
TARGET = ../../debug/tst_qlibrary
} else {

View File

@ -5,7 +5,7 @@ qtConfig(private_tests): QT += core-private
SOURCES = ../tst_qpluginloader.cpp ../fakeplugin.cpp
HEADERS = ../theplugin/plugininterface.h
win32 {
win32:debug_and_release {
CONFIG(debug, debug|release) {
TARGET = ../../debug/tst_qpluginloader
LIBS += -L../staticplugin/debug

View File

@ -6,7 +6,7 @@ QT = core network testlib
MOC_DIR=tmp
win32 {
win32:debug_and_release {
CONFIG(debug, debug|release) {
DESTDIR = ../debug
} else {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -27,20 +27,19 @@
****************************************************************************/
#include <QtTest/QtTest>
#include <QTreeWidget>
#include <QTreeWidgetItemIterator>
#include <QTest>
#include <qtreewidget.h>
#include <qtreewidgetitemiterator.h>
#include <qapplication.h>
#include <qeventloop.h>
#include <qdebug.h>
Q_DECLARE_METATYPE(QTreeWidgetItemIterator::IteratorFlag)
Q_DECLARE_METATYPE(QTreeWidgetItemIterator::IteratorFlags)
class tst_QTreeWidgetItemIterator : public QObject
{
Q_OBJECT
public:
tst_QTreeWidgetItemIterator();
using QObject::QObject;
private slots:
void initTestCase();
@ -65,13 +64,9 @@ private slots:
void initializeIterator();
void sortingEnabled();
private:
QTreeWidget *testWidget;
QTreeWidget *testWidget = nullptr;
};
tst_QTreeWidgetItemIterator::tst_QTreeWidgetItemIterator(): testWidget(0)
{
}
void tst_QTreeWidgetItemIterator::initTestCase()
{
testWidget = new QTreeWidget();
@ -90,7 +85,7 @@ void tst_QTreeWidgetItemIterator::initTestCase()
* |Qt::ItemIsDropEnabled
*
*/
for (int i=0; i <= 16; ++i) {
for (int i = 0; i <= 16; ++i) {
QTreeWidgetItem *top = new QTreeWidgetItem(testWidget);
const QString topS = QLatin1String("top") + QString::number(i);
top->setText(0, topS);
@ -111,9 +106,7 @@ void tst_QTreeWidgetItemIterator::initTestCase()
case 9: top->setFlags(Qt::ItemIsEnabled);break;
case 10: top->setFlags(Qt::ItemIsEnabled);break;
case 11:
top->setFlags(0);
break;
case 11: top->setFlags({});break;
case 12: top->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);break;
case 13: top->setFlags(Qt::ItemIsEnabled);break;
@ -142,7 +135,7 @@ void tst_QTreeWidgetItemIterator::initTestCase()
case 9: child->setFlags(Qt::ItemIsEnabled);break;
case 10: child->setFlags(Qt::ItemIsEnabled);break;
case 11: child->setFlags(0);break;
case 11: child->setFlags({});break;
case 12: child->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);break;
case 13: child->setFlags(Qt::ItemIsEnabled);break;
@ -188,10 +181,10 @@ void tst_QTreeWidgetItemIterator::iteratorflags_data()
NotEditable = 0x00020000
*/
QTest::addColumn<int>("start");
QTest::addColumn<int>("iteratorflags");
QTest::addColumn<QTreeWidgetItemIterator::IteratorFlags>("iteratorflags");
QTest::addColumn<QStringList>("matches");
QTest::newRow("Match all") << 0 << (int)QTreeWidgetItemIterator::All
QTest::newRow("Match all") << 0 << QTreeWidgetItemIterator::IteratorFlags(QTreeWidgetItemIterator::All)
<< (QStringList()
<< "top0" << "top0,child0" << "top0,child1" << "top0,child2" << "top0,child3"
<< "top0,child4" << "top0,child5" << "top0,child6" << "top0,child7"
@ -279,7 +272,7 @@ void tst_QTreeWidgetItemIterator::iteratorflags_data()
<< "top16,child12" << "top16,child13" << "top16,child14" << "top16,child15"
<< "top16,child16");
QTest::newRow("Match hidden") << 0 << (int)QTreeWidgetItemIterator::Hidden
QTest::newRow("Match hidden") << 0 << QTreeWidgetItemIterator::IteratorFlags(QTreeWidgetItemIterator::Hidden)
<< (QStringList()
<< "top0" << "top0,child0" // fails due to hidden row
<< "top1,child0"
@ -299,7 +292,7 @@ void tst_QTreeWidgetItemIterator::iteratorflags_data()
<< "top15,child0"
<< "top16,child0");
QTest::newRow("Match not hidden") << 0 << (int)QTreeWidgetItemIterator::NotHidden
QTest::newRow("Match not hidden") << 0 << QTreeWidgetItemIterator::IteratorFlags(QTreeWidgetItemIterator::NotHidden)
<< (QStringList()
<< "top0,child1" << "top0,child2" << "top0,child3"
<< "top0,child4" << "top0,child5" << "top0,child6" << "top0,child7"
@ -387,7 +380,7 @@ void tst_QTreeWidgetItemIterator::iteratorflags_data()
<< "top16,child12" << "top16,child13" << "top16,child14" << "top16,child15"
<< "top16,child16");
QTest::newRow("Match selected") << 0 << (int)QTreeWidgetItemIterator::Selected
QTest::newRow("Match selected") << 0 << QTreeWidgetItemIterator::IteratorFlags(QTreeWidgetItemIterator::Selected)
<< (QStringList()
<< "top0,child2"
<< "top1,child2"
@ -407,7 +400,7 @@ void tst_QTreeWidgetItemIterator::iteratorflags_data()
<< "top15,child2"
<< "top16,child2");
QTest::newRow("Match selectable") << 0 << (int)QTreeWidgetItemIterator::Selectable
QTest::newRow("Match selectable") << 0 << QTreeWidgetItemIterator::IteratorFlags(QTreeWidgetItemIterator::Selectable)
<< (QStringList()
<< "top0" << "top0,child0" << "top0,child1" << "top0,child2" << "top0,child3"
<< "top0,child4"
@ -479,7 +472,7 @@ void tst_QTreeWidgetItemIterator::iteratorflags_data()
<< "top16,child16");
QTest::newRow("Match DragEnabled") << 0 << (int)QTreeWidgetItemIterator::DragEnabled
QTest::newRow("Match DragEnabled") << 0 << QTreeWidgetItemIterator::IteratorFlags(QTreeWidgetItemIterator::DragEnabled)
<< (QStringList()
<< "top0" << "top0,child0" << "top0,child1" << "top0,child2" << "top0,child3"
<< "top0,child6"
@ -550,7 +543,7 @@ void tst_QTreeWidgetItemIterator::iteratorflags_data()
<< "top16,child14" << "top16,child15"
<< "top16,child16");
QTest::newRow("Match DragDisabled") << 0 << (int)QTreeWidgetItemIterator::DragDisabled
QTest::newRow("Match DragDisabled") << 0 << QTreeWidgetItemIterator::IteratorFlags(QTreeWidgetItemIterator::DragDisabled)
<< (QStringList()
/* top0 */
@ -623,7 +616,7 @@ void tst_QTreeWidgetItemIterator::iteratorflags_data()
<< "top16,child13" );
QTest::newRow("Match DropEnabled") << 0 << (int)QTreeWidgetItemIterator::DropEnabled
QTest::newRow("Match DropEnabled") << 0 << QTreeWidgetItemIterator::IteratorFlags(QTreeWidgetItemIterator::DropEnabled)
<< (QStringList()
<< "top0" << "top0,child0" << "top0,child1" << "top0,child2" << "top0,child3"
<< "top0,child8"
@ -694,12 +687,12 @@ void tst_QTreeWidgetItemIterator::iteratorflags_data()
<< "top16,child14" << "top16,child15"
<< "top16,child16");
QTest::newRow("Match HasChildren") << 0 << (int)QTreeWidgetItemIterator::HasChildren
QTest::newRow("Match HasChildren") << 0 << QTreeWidgetItemIterator::IteratorFlags(QTreeWidgetItemIterator::HasChildren)
<< (QStringList() << "top0" << "top1" << "top2" << "top3" << "top4" << "top5"
<< "top6" << "top7" << "top8" << "top9" << "top10" << "top11" << "top12"
<< "top13" << "top14" << "top15" << "top16");
QTest::newRow("Match Checked") << 0 << (int)QTreeWidgetItemIterator::Checked
QTest::newRow("Match Checked") << 0 << QTreeWidgetItemIterator::IteratorFlags(QTreeWidgetItemIterator::Checked)
<< (QStringList()
<< "top0,child14" << "top0,child16"
<< "top1,child14" << "top1,child16"
@ -721,7 +714,7 @@ void tst_QTreeWidgetItemIterator::iteratorflags_data()
<< "top16"
<< "top16,child14" << "top16,child16");
QTest::newRow("Match NotChecked") << 0 << (int)QTreeWidgetItemIterator::NotChecked
QTest::newRow("Match NotChecked") << 0 << QTreeWidgetItemIterator::IteratorFlags(QTreeWidgetItemIterator::NotChecked)
<< (QStringList()
<< "top0" << "top0,child0" << "top0,child1" << "top0,child2" << "top0,child3"
<< "top0,child4" << "top0,child5" << "top0,child6" << "top0,child7"
@ -810,7 +803,7 @@ void tst_QTreeWidgetItemIterator::iteratorflags_data()
QTest::newRow("Match Disabled") << 0 << (int)QTreeWidgetItemIterator::Disabled
QTest::newRow("Match Disabled") << 0 << QTreeWidgetItemIterator::IteratorFlags(QTreeWidgetItemIterator::Disabled)
<< (QStringList()
<< "top0,child11"
<< "top1,child11"
@ -848,7 +841,7 @@ void tst_QTreeWidgetItemIterator::iteratorflags_data()
<< "top15,child11"
<< "top16,child11");
QTest::newRow("Match Editable") << 0 << (int)QTreeWidgetItemIterator::Editable
QTest::newRow("Match Editable") << 0 << QTreeWidgetItemIterator::IteratorFlags(QTreeWidgetItemIterator::Editable)
<< (QStringList()
<< "top0,child12"
<< "top1,child12"
@ -869,34 +862,34 @@ void tst_QTreeWidgetItemIterator::iteratorflags_data()
<< "top15,child12"
<< "top16,child12");
QTest::newRow("Match mutually exclusive Hidden|NotHidden") << 0 << (int)(QTreeWidgetItemIterator::Hidden|QTreeWidgetItemIterator::NotHidden)
QTest::newRow("Match mutually exclusive Hidden|NotHidden") << 0 << (QTreeWidgetItemIterator::Hidden|QTreeWidgetItemIterator::NotHidden)
<< QStringList();
QTest::newRow("Match mutually exclusive Selected|Unselected") << 0 << (int)(QTreeWidgetItemIterator::Selected|QTreeWidgetItemIterator::Unselected)
QTest::newRow("Match mutually exclusive Selected|Unselected") << 0 << (QTreeWidgetItemIterator::Selected|QTreeWidgetItemIterator::Unselected)
<< QStringList();
QTest::newRow("Match mutually exclusive Selectable|NotSelectable") << 0 << (int)(QTreeWidgetItemIterator::Selectable|QTreeWidgetItemIterator::NotSelectable)
QTest::newRow("Match mutually exclusive Selectable|NotSelectable") << 0 << (QTreeWidgetItemIterator::Selectable|QTreeWidgetItemIterator::NotSelectable)
<< QStringList();
QTest::newRow("Match mutually exclusive DragEnabled|DragDisabled") << 0 << (int)(QTreeWidgetItemIterator::DragEnabled|QTreeWidgetItemIterator::DragDisabled)
QTest::newRow("Match mutually exclusive DragEnabled|DragDisabled") << 0 << (QTreeWidgetItemIterator::DragEnabled|QTreeWidgetItemIterator::DragDisabled)
<< QStringList();
QTest::newRow("Match mutually exclusive DropEnabled|DropDisabled") << 0 << (int)(QTreeWidgetItemIterator::DropEnabled|QTreeWidgetItemIterator::DropDisabled)
QTest::newRow("Match mutually exclusive DropEnabled|DropDisabled") << 0 << (QTreeWidgetItemIterator::DropEnabled|QTreeWidgetItemIterator::DropDisabled)
<< QStringList();
QTest::newRow("Match mutually exclusive HasChildren|NoChildren") << 0 << (int)(QTreeWidgetItemIterator::HasChildren|QTreeWidgetItemIterator::NoChildren)
QTest::newRow("Match mutually exclusive HasChildren|NoChildren") << 0 << (QTreeWidgetItemIterator::HasChildren|QTreeWidgetItemIterator::NoChildren)
<< QStringList();
QTest::newRow("Match mutually exclusive Checked|NotChecked") << 0 << (int)(QTreeWidgetItemIterator::Checked|QTreeWidgetItemIterator::NotChecked)
QTest::newRow("Match mutually exclusive Checked|NotChecked") << 0 << (QTreeWidgetItemIterator::Checked|QTreeWidgetItemIterator::NotChecked)
<< QStringList();
QTest::newRow("Match mutually exclusive Disabled|Enabled") << 0 << (int)(QTreeWidgetItemIterator::Disabled|QTreeWidgetItemIterator::Enabled)
QTest::newRow("Match mutually exclusive Disabled|Enabled") << 0 << (QTreeWidgetItemIterator::Disabled|QTreeWidgetItemIterator::Enabled)
<< QStringList();
QTest::newRow("Match mutually exclusive Editable|NotEditable") << 0 << (int)(QTreeWidgetItemIterator::Editable|QTreeWidgetItemIterator::NotEditable)
QTest::newRow("Match mutually exclusive Editable|NotEditable") << 0 << (QTreeWidgetItemIterator::Editable|QTreeWidgetItemIterator::NotEditable)
<< QStringList();
}
void tst_QTreeWidgetItemIterator::iteratorflags()
{
QFETCH(int, start);
QFETCH(int, iteratorflags);
QFETCH(QTreeWidgetItemIterator::IteratorFlags, iteratorflags);
QFETCH(QStringList, matches);
QTreeWidgetItemIterator it(testWidget, QTreeWidgetItemIterator::IteratorFlags(iteratorflags));
it+=start;
QTreeWidgetItemIterator it(testWidget, iteratorflags);
it += start;
int iMatch = 0;
while (*it && iMatch < matches.count()) {
QTreeWidgetItem *item = *it;
@ -953,26 +946,26 @@ void tst_QTreeWidgetItemIterator::plus_eq_data()
{
QTest::addColumn<int>("start");
QTest::addColumn<int>("addition");
QTest::addColumn<int>("iteratorflags");
QTest::addColumn<QTreeWidgetItemIterator::IteratorFlag>("iteratorflags");
QTest::addColumn<QString>("expecteditem");
QTest::newRow("+=0") << 0 << 0 << (int)QTreeWidgetItemIterator::All << QString("top0");
QTest::newRow("+=1") << 0 << 1 << (int)QTreeWidgetItemIterator::All << QString("top0,child0");
QTest::newRow("+=2") << 0 << 2 << (int)QTreeWidgetItemIterator::All << QString("top0,child1");
QTest::newRow("+=(-1)") << 1 << -1 << (int)QTreeWidgetItemIterator::All << QString("top0");
QTest::newRow("+=(-2)") << 3 << -2 << (int)QTreeWidgetItemIterator::All << QString("top0,child0");
QTest::newRow("+=0") << 0 << 0 << QTreeWidgetItemIterator::All << QString("top0");
QTest::newRow("+=1") << 0 << 1 << QTreeWidgetItemIterator::All << QString("top0,child0");
QTest::newRow("+=2") << 0 << 2 << QTreeWidgetItemIterator::All << QString("top0,child1");
QTest::newRow("+=(-1)") << 1 << -1 << QTreeWidgetItemIterator::All << QString("top0");
QTest::newRow("+=(-2)") << 3 << -2 << QTreeWidgetItemIterator::All << QString("top0,child0");
}
void tst_QTreeWidgetItemIterator::plus_eq()
{
QFETCH(int, start);
QFETCH(int, addition);
QFETCH(int, iteratorflags);
QFETCH(QTreeWidgetItemIterator::IteratorFlag, iteratorflags);
QFETCH(QString, expecteditem);
QTreeWidgetItemIterator it(testWidget, QTreeWidgetItemIterator::IteratorFlags(iteratorflags));
it+=start;
it+=addition;
QTreeWidgetItemIterator it(testWidget, iteratorflags);
it += start;
it += addition;
QTreeWidgetItem *item = *it;
QVERIFY(item);
@ -984,28 +977,28 @@ void tst_QTreeWidgetItemIterator::minus_eq_data()
{
QTest::addColumn<int>("start");
QTest::addColumn<int>("subtraction");
QTest::addColumn<int>("iteratorflags");
QTest::addColumn<QTreeWidgetItemIterator::IteratorFlag>("iteratorflags");
QTest::addColumn<QString>("expecteditem");
QTest::newRow("0-=0") << 0 << 0 << (int)QTreeWidgetItemIterator::All << QString("top0");
QTest::newRow("2-=1") << 2 << 1 << (int)QTreeWidgetItemIterator::All << QString("top0,child0");
QTest::newRow("4-=2") << 4 << 2 << (int)QTreeWidgetItemIterator::All << QString("top0,child1");
QTest::newRow("0-=(-1)") << 0 << -1 << (int)QTreeWidgetItemIterator::All << QString("top0,child0");
QTest::newRow("0-=(-2)") << 0 << -2 << (int)QTreeWidgetItemIterator::All << QString("top0,child1");
QTest::newRow("18-=1") << 18 << 1 << (int)QTreeWidgetItemIterator::All << QString("top0,child16");
QTest::newRow("1-=1") << 1 << 1 << (int)QTreeWidgetItemIterator::All << QString("top0");
QTest::newRow("0-=0") << 0 << 0 << QTreeWidgetItemIterator::All << QString("top0");
QTest::newRow("2-=1") << 2 << 1 << QTreeWidgetItemIterator::All << QString("top0,child0");
QTest::newRow("4-=2") << 4 << 2 << QTreeWidgetItemIterator::All << QString("top0,child1");
QTest::newRow("0-=(-1)") << 0 << -1 << QTreeWidgetItemIterator::All << QString("top0,child0");
QTest::newRow("0-=(-2)") << 0 << -2 << QTreeWidgetItemIterator::All << QString("top0,child1");
QTest::newRow("18-=1") << 18 << 1 << QTreeWidgetItemIterator::All << QString("top0,child16");
QTest::newRow("1-=1") << 1 << 1 << QTreeWidgetItemIterator::All << QString("top0");
}
void tst_QTreeWidgetItemIterator::minus_eq()
{
QFETCH(int, start);
QFETCH(int, subtraction);
QFETCH(int, iteratorflags);
QFETCH(QTreeWidgetItemIterator::IteratorFlag, iteratorflags);
QFETCH(QString, expecteditem);
QTreeWidgetItemIterator it(testWidget, QTreeWidgetItemIterator::IteratorFlags(iteratorflags));
it+=start;
it-=subtraction;
QTreeWidgetItemIterator it(testWidget, iteratorflags);
it += start;
it -= subtraction;
QTreeWidgetItem *item = *it;
// should be the first one
QVERIFY(item);
@ -1017,41 +1010,41 @@ void tst_QTreeWidgetItemIterator::updateIfModifiedFromWidget_data()
QTest::addColumn<int>("topLevelItems");
QTest::addColumn<int>("childItems");
QTest::addColumn<int>("grandChildItems");
QTest::addColumn<int>("iteratorflags");
QTest::addColumn<QTreeWidgetItemIterator::IteratorFlag>("iteratorflags");
QTest::addColumn<int>("removeindex");
QTest::addColumn<int>("expecteditemindex");
QTest::addColumn<QString>("expecteditemvalue");
QTest::addColumn<QString>("expectedUpdatedCurrent");
QTest::addColumn<int>("expecteditemIsNull");
QTest::newRow("Remove 3, check 1") << 3 << 3 << 0 << (int)QTreeWidgetItemIterator::All
QTest::newRow("Remove 3, check 1") << 3 << 3 << 0 << QTreeWidgetItemIterator::All
<< 3 << 1 << QString("top0,child0") << QString("top1") << 0;
QTest::newRow("Remove 1, check 0") << 3 << 3 << 0 << (int)QTreeWidgetItemIterator::All
QTest::newRow("Remove 1, check 0") << 3 << 3 << 0 << QTreeWidgetItemIterator::All
<< 1 << 0 << QString("top0") << QString("top0,child1") << 0;
QTest::newRow("Remove 2, check 2") << 3 << 3 << 0 << (int)QTreeWidgetItemIterator::All
QTest::newRow("Remove 2, check 2") << 3 << 3 << 0 << QTreeWidgetItemIterator::All
<< 2 << 2 << QString("top0,child2") << QString("top0,child2") << 0;
QTest::newRow("Remove 0, check 0") << 3 << 3 << 3 << (int)QTreeWidgetItemIterator::All
QTest::newRow("Remove 0, check 0") << 3 << 3 << 3 << QTreeWidgetItemIterator::All
<< 0 << 0 << QString("top1") << QString("top1") << 0;
QTest::newRow("Remove top1, check top1") << 3 << 3 << 3 << (int)QTreeWidgetItemIterator::All
QTest::newRow("Remove top1, check top1") << 3 << 3 << 3 << QTreeWidgetItemIterator::All
<< 13 << 13 << QString("top2") << QString("top2") << 0;
QTest::newRow("Remove top0, check top1") << 3 << 3 << 3 << (int)QTreeWidgetItemIterator::All
QTest::newRow("Remove top0, check top1") << 3 << 3 << 3 << QTreeWidgetItemIterator::All
<< 0 << 13 << QString("top1") << QString("top1") << 0;
QTest::newRow("Remove (top0,child1), check (top0,child1)") << 3 << 3 << 3 << (int)QTreeWidgetItemIterator::All
QTest::newRow("Remove (top0,child1), check (top0,child1)") << 3 << 3 << 3 << QTreeWidgetItemIterator::All
<< 5 << 5 << QString("top0,child2") << QString("top0,child2") << 0;
QTest::newRow("Remove (t0,c0) check (t0,c0)") << 3 << 3 << 3 << (int)QTreeWidgetItemIterator::All
QTest::newRow("Remove (t0,c0) check (t0,c0)") << 3 << 3 << 3 << QTreeWidgetItemIterator::All
<< 1 << 1 << QString("top0,child1") << QString("top0,child1") << 0;
QTest::newRow("Remove (t0,c1) check (t0,c1)") << 3 << 3 << 3 << (int)QTreeWidgetItemIterator::All
QTest::newRow("Remove (t0,c1) check (t0,c1)") << 3 << 3 << 3 << QTreeWidgetItemIterator::All
<< 5 << 5 << QString("top0,child2") << QString("top0,child2") << 0;
QTest::newRow("Remove (t0) check (t0,c1)") << 3 << 3 << 0 << (int)QTreeWidgetItemIterator::All
QTest::newRow("Remove (t0) check (t0,c1)") << 3 << 3 << 0 << QTreeWidgetItemIterator::All
<< 0 << 4 << QString("top1") << QString("top1") << 0;
QTest::newRow("Remove (t0) check (t0,c0,g1)") << 3 << 3 << 3 << (int)QTreeWidgetItemIterator::All
QTest::newRow("Remove (t0) check (t0,c0,g1)") << 3 << 3 << 3 << QTreeWidgetItemIterator::All
<< 0 << 3 << QString("top1") << QString("top1") << 0;
QTest::newRow("Remove (top2), check if top2 is null") << 3 << 3 << 3 << (int)QTreeWidgetItemIterator::All
QTest::newRow("Remove (top2), check if top2 is null") << 3 << 3 << 3 << QTreeWidgetItemIterator::All
<< 2*13 << 2*13 << QString() << QString() << 1;
QTest::newRow("Remove last item, check if iterator::current returns 0")
<< 3 << 0 << 0 << (int)QTreeWidgetItemIterator::All << 2 << 2 << QString() << QString() << 1;
<< 3 << 0 << 0 << QTreeWidgetItemIterator::All << 2 << 2 << QString() << QString() << 1;
QTest::newRow("remove 1, iterator points to 3, should move to 1")
<< 3 << 3 << 3 << (int)QTreeWidgetItemIterator::All << 1 << 3 << QString("top0,child1") << QString("top0,child1") << 0;
<< 3 << 3 << 3 << QTreeWidgetItemIterator::All << 1 << 3 << QString("top0,child1") << QString("top0,child1") << 0;
}
static void populate3Levels(QTreeWidget &tw, int topLevelItems, int childItems, int grandChildItems)
@ -1077,7 +1070,7 @@ void tst_QTreeWidgetItemIterator::updateIfModifiedFromWidget()
QFETCH(int, topLevelItems);
QFETCH(int, childItems);
QFETCH(int, grandChildItems);
QFETCH(int, iteratorflags);
QFETCH(QTreeWidgetItemIterator::IteratorFlag, iteratorflags);
QFETCH(int, removeindex);
QFETCH(int, expecteditemindex);
QFETCH(QString, expecteditemvalue);
@ -1089,12 +1082,11 @@ void tst_QTreeWidgetItemIterator::updateIfModifiedFromWidget()
tw.setColumnCount(2);
populate3Levels(tw, topLevelItems, childItems, grandChildItems);
QTreeWidgetItemIterator it(&tw, QTreeWidgetItemIterator::IteratorFlags(iteratorflags));
QTreeWidgetItemIterator it(&tw, iteratorflags);
it+=expecteditemindex;
QTreeWidgetItem *item = 0;
QTreeWidgetItemIterator itRemove(&tw, QTreeWidgetItemIterator::IteratorFlags(iteratorflags));
itRemove+=removeindex;
item = *itRemove;
QTreeWidgetItem *item = *itRemove;
QVERIFY(item);
delete item;
item = *it;
@ -1104,11 +1096,10 @@ void tst_QTreeWidgetItemIterator::updateIfModifiedFromWidget()
QVERIFY(item);
QCOMPARE(item->text(0), expecteditemvalue);
item = *itRemove;
if (expectedUpdatedCurrent.isNull()) {
if (expectedUpdatedCurrent.isNull())
QVERIFY(!item);
} else {
else
QCOMPARE(item->text(0), expectedUpdatedCurrent);
}
}
}
@ -1152,38 +1143,36 @@ void tst_QTreeWidgetItemIterator::updateIteratorAfterDeletedItem_and_ContinueIte
QTreeWidgetItemIterator it(&tw, QTreeWidgetItemIterator::All);
it += iterator_initial_index;
QTreeWidgetItem *item = 0;
QTreeWidgetItemIterator itRemove(&tw, QTreeWidgetItemIterator::All);
itRemove+=removeindex;
item = *itRemove;
QTreeWidgetItem *item = *itRemove;
QVERIFY(item);
delete item;
it+=iterator_advance_after_removal;
if (iterator_new_value.isNull()) {
if (iterator_new_value.isNull())
QCOMPARE((*it), nullptr);
} else {
else
QCOMPARE((*it)->text(0), iterator_new_value);
}
}
void tst_QTreeWidgetItemIterator::constructIteratorWithItem_data()
{
QTest::addColumn<int>("indextoitem");
QTest::addColumn<int>("iteratorflags");
QTest::addColumn<QTreeWidgetItemIterator::IteratorFlag>("iteratorflags");
QTest::addColumn<QString>("expecteditem");
QTest::newRow("index 0") << 0 << 0 << QString("top0");
QTest::newRow("index 1") << 1 << 0 << QString("top0,child0");
QTest::newRow("index 2") << 2 << 0 << QString("top0,child1");
QTest::newRow("index 30") << 30 << 0 << QString("top1,child11");
QTest::newRow("305 (last item)") << 305 << 0 << QString("top16,child16");
QTest::newRow("index 0, advance to next matching node") << 0 << (int)QTreeWidgetItemIterator::NotHidden << QString("top0,child1");
QTest::newRow("index 0") << 0 << QTreeWidgetItemIterator::All << QString("top0");
QTest::newRow("index 1") << 1 << QTreeWidgetItemIterator::All << QString("top0,child0");
QTest::newRow("index 2") << 2 << QTreeWidgetItemIterator::All << QString("top0,child1");
QTest::newRow("index 30") << 30 << QTreeWidgetItemIterator::All << QString("top1,child11");
QTest::newRow("305 (last item)") << 305 << QTreeWidgetItemIterator::All << QString("top16,child16");
QTest::newRow("index 0, advance to next matching node") << 0 << QTreeWidgetItemIterator::NotHidden << QString("top0,child1");
}
void tst_QTreeWidgetItemIterator::constructIteratorWithItem()
{
QFETCH(int, indextoitem);
QFETCH(int, iteratorflags);
QFETCH(QTreeWidgetItemIterator::IteratorFlag, iteratorflags);
QFETCH(QString, expecteditem);
QTreeWidgetItemIterator it(testWidget);

View File

@ -1978,8 +1978,23 @@ void tst_QTextEdit::fullWidthSelection_data()
#endif
#ifdef QT_BUILD_INTERNAL
// With the fix for QTBUG-78318 scaling of documentMargin is added. The testing framework
// forces qt_defaultDpi() to always return 96 DPI. For systems where the actual DPI differs
// (typically 72 DPI) this would now cause scaling of the documentMargin when
// drawing QTextEdit into QImage. In order to avoid the need of multiple reference PNGs
// for comparison we disable the Qt::AA_Use96Dpi attribute for these tests.
struct ForceSystemDpiHelper {
ForceSystemDpiHelper() { QCoreApplication::setAttribute(Qt::AA_Use96Dpi, false); }
~ForceSystemDpiHelper() { QCoreApplication::setAttribute(Qt::AA_Use96Dpi, old); }
bool old = QCoreApplication::testAttribute(Qt::AA_Use96Dpi);
};
void tst_QTextEdit::fullWidthSelection()
{
ForceSystemDpiHelper useSystemDpi;
QFETCH(int, cursorFrom);
QFETCH(int, cursorTo);
QFETCH(QString, imageFileName);
@ -2048,6 +2063,8 @@ void tst_QTextEdit::fullWidthSelection()
#ifdef QT_BUILD_INTERNAL
void tst_QTextEdit::fullWidthSelection2()
{
ForceSystemDpiHelper useSystemDpi;
QPalette myPalette;
myPalette.setColor(QPalette::All, QPalette::HighlightedText, QColor(0,0,0,0));
myPalette.setColor(QPalette::All, QPalette::Highlight, QColor(239,221,85));