Merge 5.11 into 5.11.1
Change-Id: I28f48e980a9e23ddde5251608dd9d1d83df65392
This commit is contained in:
commit
fc5da399c3
@ -4,4 +4,4 @@ CONFIG += warning_clean
|
|||||||
QT_SOURCE_TREE = $$PWD
|
QT_SOURCE_TREE = $$PWD
|
||||||
QT_BUILD_TREE = $$shadowed($$PWD)
|
QT_BUILD_TREE = $$shadowed($$PWD)
|
||||||
|
|
||||||
MODULE_VERSION = 5.11.0
|
MODULE_VERSION = 5.11.1
|
||||||
|
@ -8,7 +8,8 @@ dita.metadata.default.copyrholder = The Qt Company Ltd
|
|||||||
dita.metadata.default.audience = programmer
|
dita.metadata.default.audience = programmer
|
||||||
|
|
||||||
#Set the main Qt index.html
|
#Set the main Qt index.html
|
||||||
navigation.homepage = "Qt $QT_VER"
|
navigation.homepage = index.html
|
||||||
|
navigation.hometitle = "Qt $QT_VER"
|
||||||
|
|
||||||
sourcedirs += includes $$BUILDDIR
|
sourcedirs += includes $$BUILDDIR
|
||||||
|
|
||||||
|
@ -62,15 +62,21 @@ void BookDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|||||||
{
|
{
|
||||||
if (index.column() != 5) {
|
if (index.column() != 5) {
|
||||||
QStyleOptionViewItem opt = option;
|
QStyleOptionViewItem opt = option;
|
||||||
opt.rect.adjust(0, 0, -1, -1); // since we draw the grid ourselves
|
// Since we draw the grid ourselves:
|
||||||
|
opt.rect.adjust(0, 0, -1, -1);
|
||||||
QSqlRelationalDelegate::paint(painter, opt, index);
|
QSqlRelationalDelegate::paint(painter, opt, index);
|
||||||
} else {
|
} else {
|
||||||
const QAbstractItemModel *model = index.model();
|
const QAbstractItemModel *model = index.model();
|
||||||
QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled) ?
|
QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled) ?
|
||||||
(option.state & QStyle::State_Active) ? QPalette::Normal : QPalette::Inactive : QPalette::Disabled;
|
(option.state & QStyle::State_Active) ?
|
||||||
|
QPalette::Normal :
|
||||||
|
QPalette::Inactive :
|
||||||
|
QPalette::Disabled;
|
||||||
|
|
||||||
if (option.state & QStyle::State_Selected)
|
if (option.state & QStyle::State_Selected)
|
||||||
painter->fillRect(option.rect, option.palette.color(cg, QPalette::Highlight));
|
painter->fillRect(
|
||||||
|
option.rect,
|
||||||
|
option.palette.color(cg, QPalette::Highlight));
|
||||||
|
|
||||||
int rating = model->data(index, Qt::DisplayRole).toInt();
|
int rating = model->data(index, Qt::DisplayRole).toInt();
|
||||||
int width = star.width();
|
int width = star.width();
|
||||||
@ -81,7 +87,8 @@ void BookDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|||||||
painter->drawPixmap(x, y, star);
|
painter->drawPixmap(x, y, star);
|
||||||
x += width;
|
x += width;
|
||||||
}
|
}
|
||||||
drawFocus(painter, option, option.rect.adjusted(0, 0, -1, -1)); // since we draw the grid ourselves
|
// Since we draw the grid ourselves:
|
||||||
|
drawFocus(painter, option, option.rect.adjusted(0, 0, -1, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPen pen = painter->pen();
|
QPen pen = painter->pen();
|
||||||
@ -96,8 +103,8 @@ QSize BookDelegate::sizeHint(const QStyleOptionViewItem &option,
|
|||||||
{
|
{
|
||||||
if (index.column() == 5)
|
if (index.column() == 5)
|
||||||
return QSize(5 * star.width(), star.height()) + QSize(1, 1);
|
return QSize(5 * star.width(), star.height()) + QSize(1, 1);
|
||||||
|
// Since we draw the grid ourselves:
|
||||||
return QSqlRelationalDelegate::sizeHint(option, index) + QSize(1, 1); // since we draw the grid ourselves
|
return QSqlRelationalDelegate::sizeHint(option, index) + QSize(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BookDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
|
bool BookDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
|
||||||
@ -112,19 +119,21 @@ bool BookDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
|
|||||||
int stars = qBound(0, int(0.7 + qreal(mouseEvent->pos().x()
|
int stars = qBound(0, int(0.7 + qreal(mouseEvent->pos().x()
|
||||||
- option.rect.x()) / star.width()), 5);
|
- option.rect.x()) / star.width()), 5);
|
||||||
model->setData(index, QVariant(stars));
|
model->setData(index, QVariant(stars));
|
||||||
return false; //so that the selection can change
|
// So that the selection can change:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *BookDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
QWidget *BookDelegate::createEditor(QWidget *parent,
|
||||||
|
const QStyleOptionViewItem &option,
|
||||||
const QModelIndex &index) const
|
const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (index.column() != 4)
|
if (index.column() != 4)
|
||||||
return QSqlRelationalDelegate::createEditor(parent, option, index);
|
return QSqlRelationalDelegate::createEditor(parent, option, index);
|
||||||
|
|
||||||
// for editing the year, return a spinbox with a range from -1000 to 2100.
|
// For editing the year, return a spinbox with a range from -1000 to 2100.
|
||||||
QSpinBox *sb = new QSpinBox(parent);
|
QSpinBox *sb = new QSpinBox(parent);
|
||||||
sb->setFrame(false);
|
sb->setFrame(false);
|
||||||
sb->setMaximum(2100);
|
sb->setMaximum(2100);
|
||||||
@ -132,4 +141,3 @@ QWidget *BookDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem
|
|||||||
|
|
||||||
return sb;
|
return sb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,14 +66,15 @@ public:
|
|||||||
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||||
const QModelIndex &index) const override;
|
const QModelIndex &index) const override;
|
||||||
|
|
||||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
QSize sizeHint(const QStyleOptionViewItem &option,
|
||||||
|
const QModelIndex &index) const override;
|
||||||
|
|
||||||
bool editorEvent(QEvent *event, QAbstractItemModel *model,
|
bool editorEvent(QEvent *event, QAbstractItemModel *model,
|
||||||
const QStyleOptionViewItem &option,
|
const QStyleOptionViewItem &option,
|
||||||
const QModelIndex &index) override;
|
const QModelIndex &index) override;
|
||||||
|
|
||||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||||
const QModelIndex &index) const override;
|
const QModelIndex &index) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPixmap star;
|
QPixmap star;
|
||||||
|
@ -59,53 +59,61 @@ BookWindow::BookWindow()
|
|||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
if (!QSqlDatabase::drivers().contains("QSQLITE"))
|
if (!QSqlDatabase::drivers().contains("QSQLITE"))
|
||||||
QMessageBox::critical(this, "Unable to load database", "This demo needs the SQLITE driver");
|
QMessageBox::critical(
|
||||||
|
this,
|
||||||
|
"Unable to load database",
|
||||||
|
"This demo needs the SQLITE driver"
|
||||||
|
);
|
||||||
|
|
||||||
// initialize the database
|
// Initialize the database:
|
||||||
QSqlError err = initDb();
|
QSqlError err = initDb();
|
||||||
if (err.type() != QSqlError::NoError) {
|
if (err.type() != QSqlError::NoError) {
|
||||||
showError(err);
|
showError(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the data model
|
// Create the data model:
|
||||||
model = new QSqlRelationalTableModel(ui.bookTable);
|
model = new QSqlRelationalTableModel(ui.bookTable);
|
||||||
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
|
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
|
||||||
model->setTable("books");
|
model->setTable("books");
|
||||||
|
|
||||||
// Remember the indexes of the columns
|
// Remember the indexes of the columns:
|
||||||
authorIdx = model->fieldIndex("author");
|
authorIdx = model->fieldIndex("author");
|
||||||
genreIdx = model->fieldIndex("genre");
|
genreIdx = model->fieldIndex("genre");
|
||||||
|
|
||||||
// Set the relations to the other database tables
|
// Set the relations to the other database tables:
|
||||||
model->setRelation(authorIdx, QSqlRelation("authors", "id", "name"));
|
model->setRelation(authorIdx, QSqlRelation("authors", "id", "name"));
|
||||||
model->setRelation(genreIdx, QSqlRelation("genres", "id", "name"));
|
model->setRelation(genreIdx, QSqlRelation("genres", "id", "name"));
|
||||||
|
|
||||||
// Set the localized header captions
|
// Set the localized header captions:
|
||||||
model->setHeaderData(authorIdx, Qt::Horizontal, tr("Author Name"));
|
model->setHeaderData(authorIdx, Qt::Horizontal, tr("Author Name"));
|
||||||
model->setHeaderData(genreIdx, Qt::Horizontal, tr("Genre"));
|
model->setHeaderData(genreIdx, Qt::Horizontal, tr("Genre"));
|
||||||
model->setHeaderData(model->fieldIndex("title"), Qt::Horizontal, tr("Title"));
|
model->setHeaderData(model->fieldIndex("title"),
|
||||||
|
Qt::Horizontal, tr("Title"));
|
||||||
model->setHeaderData(model->fieldIndex("year"), Qt::Horizontal, tr("Year"));
|
model->setHeaderData(model->fieldIndex("year"), Qt::Horizontal, tr("Year"));
|
||||||
model->setHeaderData(model->fieldIndex("rating"), Qt::Horizontal, tr("Rating"));
|
model->setHeaderData(model->fieldIndex("rating"),
|
||||||
|
Qt::Horizontal, tr("Rating"));
|
||||||
|
|
||||||
// Populate the model
|
// Populate the model:
|
||||||
if (!model->select()) {
|
if (!model->select()) {
|
||||||
showError(model->lastError());
|
showError(model->lastError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the model and hide the ID column
|
// Set the model and hide the ID column:
|
||||||
ui.bookTable->setModel(model);
|
ui.bookTable->setModel(model);
|
||||||
ui.bookTable->setItemDelegate(new BookDelegate(ui.bookTable));
|
ui.bookTable->setItemDelegate(new BookDelegate(ui.bookTable));
|
||||||
ui.bookTable->setColumnHidden(model->fieldIndex("id"), true);
|
ui.bookTable->setColumnHidden(model->fieldIndex("id"), true);
|
||||||
ui.bookTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
ui.bookTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
|
||||||
// Initialize the Author combo box
|
// Initialize the Author combo box:
|
||||||
ui.authorEdit->setModel(model->relationModel(authorIdx));
|
ui.authorEdit->setModel(model->relationModel(authorIdx));
|
||||||
ui.authorEdit->setModelColumn(model->relationModel(authorIdx)->fieldIndex("name"));
|
ui.authorEdit->setModelColumn(
|
||||||
|
model->relationModel(authorIdx)->fieldIndex("name"));
|
||||||
|
|
||||||
ui.genreEdit->setModel(model->relationModel(genreIdx));
|
ui.genreEdit->setModel(model->relationModel(genreIdx));
|
||||||
ui.genreEdit->setModelColumn(model->relationModel(genreIdx)->fieldIndex("name"));
|
ui.genreEdit->setModelColumn(
|
||||||
|
model->relationModel(genreIdx)->fieldIndex("name"));
|
||||||
|
|
||||||
QDataWidgetMapper *mapper = new QDataWidgetMapper(this);
|
QDataWidgetMapper *mapper = new QDataWidgetMapper(this);
|
||||||
mapper->setModel(model);
|
mapper->setModel(model);
|
||||||
@ -116,8 +124,11 @@ BookWindow::BookWindow()
|
|||||||
mapper->addMapping(ui.genreEdit, genreIdx);
|
mapper->addMapping(ui.genreEdit, genreIdx);
|
||||||
mapper->addMapping(ui.ratingEdit, model->fieldIndex("rating"));
|
mapper->addMapping(ui.ratingEdit, model->fieldIndex("rating"));
|
||||||
|
|
||||||
connect(ui.bookTable->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
|
connect(ui.bookTable->selectionModel(),
|
||||||
mapper, SLOT(setCurrentModelIndex(QModelIndex)));
|
&QItemSelectionModel::currentRowChanged,
|
||||||
|
mapper,
|
||||||
|
&QDataWidgetMapper::setCurrentModelIndex
|
||||||
|
);
|
||||||
|
|
||||||
ui.bookTable->setCurrentIndex(model->index(0, 0));
|
ui.bookTable->setCurrentIndex(model->index(0, 0));
|
||||||
}
|
}
|
||||||
@ -127,4 +138,3 @@ void BookWindow::showError(const QSqlError &err)
|
|||||||
QMessageBox::critical(this, "Unable to initialize Database",
|
QMessageBox::critical(this, "Unable to initialize Database",
|
||||||
"Error initializing database: " + err.text());
|
"Error initializing database: " + err.text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
<ui version="4.0" >
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<author></author>
|
<ui version="4.0">
|
||||||
<comment></comment>
|
|
||||||
<exportmacro></exportmacro>
|
|
||||||
<class>BookWindow</class>
|
<class>BookWindow</class>
|
||||||
<widget class="QMainWindow" name="BookWindow" >
|
<widget class="QMainWindow" name="BookWindow">
|
||||||
<property name="geometry" >
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
@ -12,117 +10,135 @@
|
|||||||
<height>420</height>
|
<height>420</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle">
|
||||||
<string>Books</string>
|
<string>Books</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralWidget" >
|
<widget class="QWidget" name="centralWidget">
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout">
|
||||||
<property name="margin" >
|
<property name="spacing">
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<property name="spacing" >
|
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox" >
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title" >
|
<property name="title">
|
||||||
<string>Books</string>
|
<string>Books</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout">
|
||||||
<property name="margin" >
|
<property name="spacing">
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<property name="spacing" >
|
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableView" name="bookTable" >
|
<widget class="QTableView" name="bookTable">
|
||||||
<property name="selectionBehavior" >
|
<property name="selectionBehavior">
|
||||||
<enum>QAbstractItemView::SelectRows</enum>
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_2" >
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
<property name="title" >
|
<property name="title">
|
||||||
<string>Details</string>
|
<string>Details</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" >
|
<layout class="QFormLayout">
|
||||||
<item row="0" column="0" >
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_5" >
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string><b>Title:</b></string>
|
<string><b>Title:</b></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" >
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="titleEdit" >
|
<widget class="QLineEdit" name="titleEdit">
|
||||||
<property name="enabled" >
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" >
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_2_2_2_2" >
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string><b>Author: </b></string>
|
<string><b>Author: </b></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" >
|
<item row="1" column="1">
|
||||||
<widget class="QComboBox" name="authorEdit" >
|
<widget class="QComboBox" name="authorEdit">
|
||||||
<property name="enabled" >
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" >
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_3" >
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string><b>Genre:</b></string>
|
<string><b>Genre:</b></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" >
|
<item row="2" column="1">
|
||||||
<widget class="QComboBox" name="genreEdit" >
|
<widget class="QComboBox" name="genreEdit">
|
||||||
<property name="enabled" >
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" >
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="label_4" >
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string><b>Year:</b></string>
|
<string><b>Year:</b></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1" >
|
<item row="3" column="1">
|
||||||
<widget class="QSpinBox" name="yearEdit" >
|
<widget class="QSpinBox" name="yearEdit">
|
||||||
<property name="enabled" >
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="prefix" >
|
<property name="prefix">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum" >
|
<property name="minimum">
|
||||||
<number>2100</number>
|
|
||||||
</property>
|
|
||||||
<property name="minimum" >
|
|
||||||
<number>-1000</number>
|
<number>-1000</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="maximum">
|
||||||
</item>
|
<number>2100</number>
|
||||||
<item row="4" column="0" >
|
|
||||||
<widget class="QLabel" name="label" >
|
|
||||||
<property name="text" >
|
|
||||||
<string><b>Rating:</b></string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1" >
|
<item row="4" column="0">
|
||||||
<widget class="QSpinBox" name="ratingEdit" >
|
<widget class="QLabel" name="label">
|
||||||
<property name="maximum" >
|
<property name="text">
|
||||||
|
<string><b>Rating:</b></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QSpinBox" name="ratingEdit">
|
||||||
|
<property name="maximum">
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
@ -136,7 +152,6 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<pixmapfunction></pixmapfunction>
|
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>bookTable</tabstop>
|
<tabstop>bookTable</tabstop>
|
||||||
<tabstop>titleEdit</tabstop>
|
<tabstop>titleEdit</tabstop>
|
||||||
|
@ -50,8 +50,9 @@
|
|||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <QtPlugin>
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QtPlugin>
|
||||||
|
|
||||||
Q_IMPORT_PLUGIN(BasicToolsPlugin)
|
Q_IMPORT_PLUGIN(BasicToolsPlugin)
|
||||||
|
|
||||||
|
@ -54,19 +54,18 @@
|
|||||||
#include "paintarea.h"
|
#include "paintarea.h"
|
||||||
#include "plugindialog.h"
|
#include "plugindialog.h"
|
||||||
|
|
||||||
#include <QPluginLoader>
|
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
#include <QScrollArea>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QActionGroup>
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
#include <QActionGroup>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QColorDialog>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QInputDialog>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
#include <QFileDialog>
|
#include <QMessageBox>
|
||||||
#include <QColorDialog>
|
#include <QPluginLoader>
|
||||||
#include <QInputDialog>
|
#include <QScrollArea>
|
||||||
#include <QApplication>
|
#include <QTimer>
|
||||||
|
|
||||||
MainWindow::MainWindow() :
|
MainWindow::MainWindow() :
|
||||||
paintArea(new PaintArea),
|
paintArea(new PaintArea),
|
||||||
@ -85,7 +84,7 @@ MainWindow::MainWindow() :
|
|||||||
if (!brushActionGroup->actions().isEmpty())
|
if (!brushActionGroup->actions().isEmpty())
|
||||||
brushActionGroup->actions().first()->trigger();
|
brushActionGroup->actions().first()->trigger();
|
||||||
|
|
||||||
QTimer::singleShot(500, this, SLOT(aboutPlugins()));
|
QTimer::singleShot(500, this, &MainWindow::aboutPlugins);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::open()
|
void MainWindow::open()
|
||||||
@ -109,11 +108,10 @@ bool MainWindow::saveAs()
|
|||||||
|
|
||||||
const QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
|
const QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
|
||||||
initialPath);
|
initialPath);
|
||||||
if (fileName.isEmpty()) {
|
if (fileName.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
return paintArea->saveImage(fileName, "png");
|
return paintArea->saveImage(fileName, "png");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::brushColor()
|
void MainWindow::brushColor()
|
||||||
@ -137,8 +135,8 @@ void MainWindow::brushWidth()
|
|||||||
//! [0]
|
//! [0]
|
||||||
void MainWindow::changeBrush()
|
void MainWindow::changeBrush()
|
||||||
{
|
{
|
||||||
QAction *action = qobject_cast<QAction *>(sender());
|
auto action = qobject_cast<QAction *>(sender());
|
||||||
BrushInterface *iBrush = qobject_cast<BrushInterface *>(action->parent());
|
auto iBrush = qobject_cast<BrushInterface *>(action->parent());
|
||||||
const QString brush = action->text();
|
const QString brush = action->text();
|
||||||
|
|
||||||
paintArea->setBrush(iBrush, brush);
|
paintArea->setBrush(iBrush, brush);
|
||||||
@ -148,8 +146,8 @@ void MainWindow::changeBrush()
|
|||||||
//! [1]
|
//! [1]
|
||||||
void MainWindow::insertShape()
|
void MainWindow::insertShape()
|
||||||
{
|
{
|
||||||
QAction *action = qobject_cast<QAction *>(sender());
|
auto action = qobject_cast<QAction *>(sender());
|
||||||
ShapeInterface *iShape = qobject_cast<ShapeInterface *>(action->parent());
|
auto iShape = qobject_cast<ShapeInterface *>(action->parent());
|
||||||
|
|
||||||
const QPainterPath path = iShape->generateShape(action->text(), this);
|
const QPainterPath path = iShape->generateShape(action->text(), this);
|
||||||
if (!path.isEmpty())
|
if (!path.isEmpty())
|
||||||
@ -160,9 +158,8 @@ void MainWindow::insertShape()
|
|||||||
//! [2]
|
//! [2]
|
||||||
void MainWindow::applyFilter()
|
void MainWindow::applyFilter()
|
||||||
{
|
{
|
||||||
QAction *action = qobject_cast<QAction *>(sender());
|
auto action = qobject_cast<QAction *>(sender());
|
||||||
FilterInterface *iFilter =
|
auto iFilter = qobject_cast<FilterInterface *>(action->parent());
|
||||||
qobject_cast<FilterInterface *>(action->parent());
|
|
||||||
|
|
||||||
const QImage image = iFilter->filterImage(action->text(), paintArea->image(),
|
const QImage image = iFilter->filterImage(action->text(), paintArea->image(),
|
||||||
this);
|
this);
|
||||||
@ -189,32 +186,32 @@ void MainWindow::createActions()
|
|||||||
{
|
{
|
||||||
openAct = new QAction(tr("&Open..."), this);
|
openAct = new QAction(tr("&Open..."), this);
|
||||||
openAct->setShortcuts(QKeySequence::Open);
|
openAct->setShortcuts(QKeySequence::Open);
|
||||||
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
|
connect(openAct, &QAction::triggered, this, &MainWindow::open);
|
||||||
|
|
||||||
saveAsAct = new QAction(tr("&Save As..."), this);
|
saveAsAct = new QAction(tr("&Save As..."), this);
|
||||||
saveAsAct->setShortcuts(QKeySequence::SaveAs);
|
saveAsAct->setShortcuts(QKeySequence::SaveAs);
|
||||||
connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
|
connect(saveAsAct, &QAction::triggered, this, &MainWindow::saveAs);
|
||||||
|
|
||||||
exitAct = new QAction(tr("E&xit"), this);
|
exitAct = new QAction(tr("E&xit"), this);
|
||||||
exitAct->setShortcuts(QKeySequence::Quit);
|
exitAct->setShortcuts(QKeySequence::Quit);
|
||||||
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
|
connect(exitAct, &QAction::triggered, this, &MainWindow::close);
|
||||||
|
|
||||||
brushColorAct = new QAction(tr("&Brush Color..."), this);
|
brushColorAct = new QAction(tr("&Brush Color..."), this);
|
||||||
connect(brushColorAct, SIGNAL(triggered()), this, SLOT(brushColor()));
|
connect(brushColorAct, &QAction::triggered, this, &MainWindow::brushColor);
|
||||||
|
|
||||||
brushWidthAct = new QAction(tr("&Brush Width..."), this);
|
brushWidthAct = new QAction(tr("&Brush Width..."), this);
|
||||||
connect(brushWidthAct, SIGNAL(triggered()), this, SLOT(brushWidth()));
|
connect(brushWidthAct, &QAction::triggered, this, &MainWindow::brushWidth);
|
||||||
|
|
||||||
brushActionGroup = new QActionGroup(this);
|
brushActionGroup = new QActionGroup(this);
|
||||||
|
|
||||||
aboutAct = new QAction(tr("&About"), this);
|
aboutAct = new QAction(tr("&About"), this);
|
||||||
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
|
connect(aboutAct, &QAction::triggered, this, &MainWindow::about);
|
||||||
|
|
||||||
aboutQtAct = new QAction(tr("About &Qt"), this);
|
aboutQtAct = new QAction(tr("About &Qt"), this);
|
||||||
connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
connect(aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt);
|
||||||
|
|
||||||
aboutPluginsAct = new QAction(tr("About &Plugins"), this);
|
aboutPluginsAct = new QAction(tr("About &Plugins"), this);
|
||||||
connect(aboutPluginsAct, SIGNAL(triggered()), this, SLOT(aboutPlugins()));
|
connect(aboutPluginsAct, &QAction::triggered, this, &MainWindow::aboutPlugins);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::createMenus()
|
void MainWindow::createMenus()
|
||||||
@ -245,7 +242,8 @@ void MainWindow::createMenus()
|
|||||||
//! [4]
|
//! [4]
|
||||||
void MainWindow::loadPlugins()
|
void MainWindow::loadPlugins()
|
||||||
{
|
{
|
||||||
foreach (QObject *plugin, QPluginLoader::staticInstances())
|
const auto staticInstances = QPluginLoader::staticInstances();
|
||||||
|
for (QObject *plugin : staticInstances)
|
||||||
populateMenus(plugin);
|
populateMenus(plugin);
|
||||||
//! [4] //! [5]
|
//! [4] //! [5]
|
||||||
|
|
||||||
@ -265,7 +263,8 @@ void MainWindow::loadPlugins()
|
|||||||
//! [5]
|
//! [5]
|
||||||
|
|
||||||
//! [6]
|
//! [6]
|
||||||
foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
|
const auto entryList = pluginsDir.entryList(QDir::Files);
|
||||||
|
for (const QString &fileName : entryList) {
|
||||||
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
|
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
|
||||||
QObject *plugin = loader.instance();
|
QObject *plugin = loader.instance();
|
||||||
if (plugin) {
|
if (plugin) {
|
||||||
@ -287,28 +286,28 @@ void MainWindow::loadPlugins()
|
|||||||
//! [10]
|
//! [10]
|
||||||
void MainWindow::populateMenus(QObject *plugin)
|
void MainWindow::populateMenus(QObject *plugin)
|
||||||
{
|
{
|
||||||
BrushInterface *iBrush = qobject_cast<BrushInterface *>(plugin);
|
auto iBrush = qobject_cast<BrushInterface *>(plugin);
|
||||||
if (iBrush)
|
if (iBrush)
|
||||||
addToMenu(plugin, iBrush->brushes(), brushMenu, SLOT(changeBrush()),
|
addToMenu(plugin, iBrush->brushes(), brushMenu, &MainWindow::changeBrush,
|
||||||
brushActionGroup);
|
brushActionGroup);
|
||||||
|
|
||||||
ShapeInterface *iShape = qobject_cast<ShapeInterface *>(plugin);
|
auto iShape = qobject_cast<ShapeInterface *>(plugin);
|
||||||
if (iShape)
|
if (iShape)
|
||||||
addToMenu(plugin, iShape->shapes(), shapesMenu, SLOT(insertShape()));
|
addToMenu(plugin, iShape->shapes(), shapesMenu, &MainWindow::insertShape);
|
||||||
|
|
||||||
FilterInterface *iFilter = qobject_cast<FilterInterface *>(plugin);
|
auto iFilter = qobject_cast<FilterInterface *>(plugin);
|
||||||
if (iFilter)
|
if (iFilter)
|
||||||
addToMenu(plugin, iFilter->filters(), filterMenu, SLOT(applyFilter()));
|
addToMenu(plugin, iFilter->filters(), filterMenu, &MainWindow::applyFilter);
|
||||||
}
|
}
|
||||||
//! [10]
|
//! [10]
|
||||||
|
|
||||||
void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
|
void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
|
||||||
QMenu *menu, const char *member,
|
QMenu *menu, Member member,
|
||||||
QActionGroup *actionGroup)
|
QActionGroup *actionGroup)
|
||||||
{
|
{
|
||||||
foreach (QString text, texts) {
|
for (const QString &text : texts) {
|
||||||
QAction *action = new QAction(text, plugin);
|
auto action = new QAction(text, plugin);
|
||||||
connect(action, SIGNAL(triggered()), this, member);
|
connect(action, &QAction::triggered, this, member);
|
||||||
menu->addAction(action);
|
menu->addAction(action);
|
||||||
|
|
||||||
if (actionGroup) {
|
if (actionGroup) {
|
||||||
|
@ -82,32 +82,34 @@ private slots:
|
|||||||
void aboutPlugins();
|
void aboutPlugins();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
typedef void (MainWindow::*Member)();
|
||||||
|
|
||||||
void createActions();
|
void createActions();
|
||||||
void createMenus();
|
void createMenus();
|
||||||
void loadPlugins();
|
void loadPlugins();
|
||||||
void populateMenus(QObject *plugin);
|
void populateMenus(QObject *plugin);
|
||||||
void addToMenu(QObject *plugin, const QStringList &texts, QMenu *menu,
|
void addToMenu(QObject *plugin, const QStringList &texts, QMenu *menu,
|
||||||
const char *member, QActionGroup *actionGroup = 0);
|
Member member, QActionGroup *actionGroup = nullptr);
|
||||||
|
|
||||||
PaintArea *paintArea;
|
PaintArea *paintArea = nullptr;
|
||||||
QScrollArea *scrollArea;
|
QScrollArea *scrollArea = nullptr;
|
||||||
QDir pluginsDir;
|
QDir pluginsDir;
|
||||||
QStringList pluginFileNames;
|
QStringList pluginFileNames;
|
||||||
|
|
||||||
QMenu *fileMenu;
|
QMenu *fileMenu = nullptr;
|
||||||
QMenu *brushMenu;
|
QMenu *brushMenu = nullptr;
|
||||||
QMenu *shapesMenu;
|
QMenu *shapesMenu = nullptr;
|
||||||
QMenu *filterMenu;
|
QMenu *filterMenu = nullptr;
|
||||||
QMenu *helpMenu;
|
QMenu *helpMenu = nullptr;
|
||||||
QActionGroup *brushActionGroup;
|
QActionGroup *brushActionGroup = nullptr;
|
||||||
QAction *openAct;
|
QAction *openAct = nullptr;
|
||||||
QAction *saveAsAct;
|
QAction *saveAsAct = nullptr;
|
||||||
QAction *exitAct;
|
QAction *exitAct = nullptr;
|
||||||
QAction *brushWidthAct;
|
QAction *brushWidthAct = nullptr;
|
||||||
QAction *brushColorAct;
|
QAction *brushColorAct = nullptr;
|
||||||
QAction *aboutAct;
|
QAction *aboutAct = nullptr;
|
||||||
QAction *aboutQtAct;
|
QAction *aboutQtAct = nullptr;
|
||||||
QAction *aboutPluginsAct;
|
QAction *aboutPluginsAct = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -52,16 +52,11 @@
|
|||||||
#include "interfaces.h"
|
#include "interfaces.h"
|
||||||
#include "paintarea.h"
|
#include "paintarea.h"
|
||||||
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
PaintArea::PaintArea(QWidget *parent) :
|
PaintArea::PaintArea(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent)
|
||||||
theImage(500, 400, QImage::Format_RGB32),
|
|
||||||
color(Qt::blue),
|
|
||||||
thickness(3),
|
|
||||||
brushInterface(0),
|
|
||||||
lastPos(-1, -1)
|
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_StaticContents);
|
setAttribute(Qt::WA_StaticContents);
|
||||||
setAttribute(Qt::WA_NoBackground);
|
setAttribute(Qt::WA_NoBackground);
|
||||||
|
@ -63,7 +63,7 @@ class PaintArea : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PaintArea(QWidget *parent = 0);
|
PaintArea(QWidget *parent = nullptr);
|
||||||
|
|
||||||
bool openImage(const QString &fileName);
|
bool openImage(const QString &fileName);
|
||||||
bool saveImage(const QString &fileName, const char *fileFormat);
|
bool saveImage(const QString &fileName, const char *fileFormat);
|
||||||
@ -87,13 +87,13 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void setupPainter(QPainter &painter);
|
void setupPainter(QPainter &painter);
|
||||||
|
|
||||||
QImage theImage;
|
QImage theImage = {500, 400, QImage::Format_RGB32};
|
||||||
QColor color;
|
QColor color = Qt::blue;
|
||||||
int thickness;
|
int thickness = 3;
|
||||||
|
|
||||||
BrushInterface *brushInterface;
|
BrushInterface *brushInterface = nullptr;
|
||||||
QString brush;
|
QString brush;
|
||||||
QPoint lastPos;
|
QPoint lastPos = {-1, -1};
|
||||||
|
|
||||||
QPainterPath pendingPath;
|
QPainterPath pendingPath;
|
||||||
};
|
};
|
||||||
|
@ -52,16 +52,15 @@
|
|||||||
#include "interfaces.h"
|
#include "interfaces.h"
|
||||||
#include "plugindialog.h"
|
#include "plugindialog.h"
|
||||||
|
|
||||||
#include <QPluginLoader>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPluginLoader>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QStringList>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
#include <QTreeWidgetItem>
|
#include <QTreeWidgetItem>
|
||||||
#include <QHeaderView>
|
|
||||||
|
|
||||||
PluginDialog::PluginDialog(const QString &path, const QStringList &fileNames,
|
PluginDialog::PluginDialog(const QString &path, const QStringList &fileNames,
|
||||||
QWidget *parent) :
|
QWidget *parent) :
|
||||||
@ -77,7 +76,7 @@ PluginDialog::PluginDialog(const QString &path, const QStringList &fileNames,
|
|||||||
|
|
||||||
okButton->setDefault(true);
|
okButton->setDefault(true);
|
||||||
|
|
||||||
connect(okButton, SIGNAL(clicked()), this, SLOT(close()));
|
connect(okButton, &QAbstractButton::clicked, this, &QWidget::close);
|
||||||
|
|
||||||
QGridLayout *mainLayout = new QGridLayout;
|
QGridLayout *mainLayout = new QGridLayout;
|
||||||
mainLayout->setColumnStretch(0, 1);
|
mainLayout->setColumnStretch(0, 1);
|
||||||
@ -107,11 +106,12 @@ void PluginDialog::findPlugins(const QString &path,
|
|||||||
|
|
||||||
const QDir dir(path);
|
const QDir dir(path);
|
||||||
|
|
||||||
foreach (QObject *plugin, QPluginLoader::staticInstances())
|
const auto staticInstances = QPluginLoader::staticInstances();
|
||||||
|
for (QObject *plugin : staticInstances)
|
||||||
populateTreeWidget(plugin, tr("%1 (Static Plugin)")
|
populateTreeWidget(plugin, tr("%1 (Static Plugin)")
|
||||||
.arg(plugin->metaObject()->className()));
|
.arg(plugin->metaObject()->className()));
|
||||||
|
|
||||||
foreach (QString fileName, fileNames) {
|
for (const QString &fileName : fileNames) {
|
||||||
QPluginLoader loader(dir.absoluteFilePath(fileName));
|
QPluginLoader loader(dir.absoluteFilePath(fileName));
|
||||||
QObject *plugin = loader.instance();
|
QObject *plugin = loader.instance();
|
||||||
if (plugin)
|
if (plugin)
|
||||||
@ -123,7 +123,7 @@ void PluginDialog::findPlugins(const QString &path,
|
|||||||
//! [1]
|
//! [1]
|
||||||
void PluginDialog::populateTreeWidget(QObject *plugin, const QString &text)
|
void PluginDialog::populateTreeWidget(QObject *plugin, const QString &text)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *pluginItem = new QTreeWidgetItem(treeWidget);
|
auto pluginItem = new QTreeWidgetItem(treeWidget);
|
||||||
pluginItem->setText(0, text);
|
pluginItem->setText(0, text);
|
||||||
treeWidget->setItemExpanded(pluginItem, true);
|
treeWidget->setItemExpanded(pluginItem, true);
|
||||||
|
|
||||||
@ -132,16 +132,15 @@ void PluginDialog::populateTreeWidget(QObject *plugin, const QString &text)
|
|||||||
pluginItem->setFont(0, boldFont);
|
pluginItem->setFont(0, boldFont);
|
||||||
|
|
||||||
if (plugin) {
|
if (plugin) {
|
||||||
BrushInterface *iBrush = qobject_cast<BrushInterface *>(plugin);
|
auto iBrush = qobject_cast<BrushInterface *>(plugin);
|
||||||
if (iBrush)
|
if (iBrush)
|
||||||
addItems(pluginItem, "BrushInterface", iBrush->brushes());
|
addItems(pluginItem, "BrushInterface", iBrush->brushes());
|
||||||
|
|
||||||
ShapeInterface *iShape = qobject_cast<ShapeInterface *>(plugin);
|
auto iShape = qobject_cast<ShapeInterface *>(plugin);
|
||||||
if (iShape)
|
if (iShape)
|
||||||
addItems(pluginItem, "ShapeInterface", iShape->shapes());
|
addItems(pluginItem, "ShapeInterface", iShape->shapes());
|
||||||
|
|
||||||
FilterInterface *iFilter =
|
auto iFilter = qobject_cast<FilterInterface *>(plugin);
|
||||||
qobject_cast<FilterInterface *>(plugin);
|
|
||||||
if (iFilter)
|
if (iFilter)
|
||||||
addItems(pluginItem, "FilterInterface", iFilter->filters());
|
addItems(pluginItem, "FilterInterface", iFilter->filters());
|
||||||
}
|
}
|
||||||
@ -152,14 +151,14 @@ void PluginDialog::addItems(QTreeWidgetItem *pluginItem,
|
|||||||
const char *interfaceName,
|
const char *interfaceName,
|
||||||
const QStringList &features)
|
const QStringList &features)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *interfaceItem = new QTreeWidgetItem(pluginItem);
|
auto interfaceItem = new QTreeWidgetItem(pluginItem);
|
||||||
interfaceItem->setText(0, interfaceName);
|
interfaceItem->setText(0, interfaceName);
|
||||||
interfaceItem->setIcon(0, interfaceIcon);
|
interfaceItem->setIcon(0, interfaceIcon);
|
||||||
|
|
||||||
foreach (QString feature, features) {
|
for (QString feature : features) {
|
||||||
if (feature.endsWith("..."))
|
if (feature.endsWith("..."))
|
||||||
feature.chop(3);
|
feature.chop(3);
|
||||||
QTreeWidgetItem *featureItem = new QTreeWidgetItem(interfaceItem);
|
auto featureItem = new QTreeWidgetItem(interfaceItem);
|
||||||
featureItem->setText(0, feature);
|
featureItem->setText(0, feature);
|
||||||
featureItem->setIcon(0, featureIcon);
|
featureItem->setIcon(0, featureIcon);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ class PluginDialog : public QDialog
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
PluginDialog(const QString &path, const QStringList &fileNames,
|
PluginDialog(const QString &path, const QStringList &fileNames,
|
||||||
QWidget *parent = 0);
|
QWidget *parent = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void findPlugins(const QString &path, const QStringList &fileNames);
|
void findPlugins(const QString &path, const QStringList &fileNames);
|
||||||
@ -76,9 +76,9 @@ private:
|
|||||||
void addItems(QTreeWidgetItem *pluginItem, const char *interfaceName,
|
void addItems(QTreeWidgetItem *pluginItem, const char *interfaceName,
|
||||||
const QStringList &features);
|
const QStringList &features);
|
||||||
|
|
||||||
QLabel *label;
|
QLabel *label = nullptr;
|
||||||
QTreeWidget *treeWidget;
|
QTreeWidget *treeWidget = nullptr;
|
||||||
QPushButton *okButton;
|
QPushButton *okButton = nullptr;
|
||||||
QIcon interfaceIcon;
|
QIcon interfaceIcon;
|
||||||
QIcon featureIcon;
|
QIcon featureIcon;
|
||||||
};
|
};
|
||||||
|
@ -48,18 +48,17 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "basictoolsplugin.h"
|
||||||
|
|
||||||
|
#include <QtMath>
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
|
||||||
#include <qmath.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "basictoolsplugin.h"
|
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
QStringList BasicToolsPlugin::brushes() const
|
QStringList BasicToolsPlugin::brushes() const
|
||||||
{
|
{
|
||||||
return QStringList() << tr("Pencil") << tr("Air Brush")
|
return {tr("Pencil"), tr("Air Brush"), tr("Random Letters")};
|
||||||
<< tr("Random Letters");
|
|
||||||
}
|
}
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
@ -132,7 +131,7 @@ QRect BasicToolsPlugin::mouseRelease(const QString & /* brush */,
|
|||||||
//! [5]
|
//! [5]
|
||||||
QStringList BasicToolsPlugin::shapes() const
|
QStringList BasicToolsPlugin::shapes() const
|
||||||
{
|
{
|
||||||
return QStringList() << tr("Circle") << tr("Star") << tr("Text...");
|
return {tr("Circle"), tr("Star"), tr("Text...")};
|
||||||
}
|
}
|
||||||
//! [5]
|
//! [5]
|
||||||
|
|
||||||
@ -169,8 +168,7 @@ QPainterPath BasicToolsPlugin::generateShape(const QString &shape,
|
|||||||
//! [7]
|
//! [7]
|
||||||
QStringList BasicToolsPlugin::filters() const
|
QStringList BasicToolsPlugin::filters() const
|
||||||
{
|
{
|
||||||
return QStringList() << tr("Invert Pixels") << tr("Swap RGB")
|
return {tr("Invert Pixels"), tr("Swap RGB"), tr("Grayscale")};
|
||||||
<< tr("Grayscale");
|
|
||||||
}
|
}
|
||||||
//! [7]
|
//! [7]
|
||||||
|
|
||||||
@ -187,7 +185,7 @@ QImage BasicToolsPlugin::filterImage(const QString &filter, const QImage &image,
|
|||||||
} else if (filter == tr("Grayscale")) {
|
} else if (filter == tr("Grayscale")) {
|
||||||
for (int y = 0; y < result.height(); ++y) {
|
for (int y = 0; y < result.height(); ++y) {
|
||||||
for (int x = 0; x < result.width(); ++x) {
|
for (int x = 0; x < result.width(); ++x) {
|
||||||
int pixel = result.pixel(x, y);
|
QRgb pixel = result.pixel(x, y);
|
||||||
int gray = qGray(pixel);
|
int gray = qGray(pixel);
|
||||||
int alpha = qAlpha(pixel);
|
int alpha = qAlpha(pixel);
|
||||||
result.setPixel(x, y, qRgba(gray, gray, gray, alpha));
|
result.setPixel(x, y, qRgba(gray, gray, gray, alpha));
|
||||||
|
@ -48,17 +48,17 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "extrafiltersplugin.h"
|
||||||
|
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "extrafiltersplugin.h"
|
|
||||||
|
|
||||||
QStringList ExtraFiltersPlugin::filters() const
|
QStringList ExtraFiltersPlugin::filters() const
|
||||||
{
|
{
|
||||||
return QStringList() << tr("Flip Horizontally") << tr("Flip Vertically")
|
return {tr("Flip Horizontally"), tr("Flip Vertically"),
|
||||||
<< tr("Smudge...") << tr("Threshold...");
|
tr("Smudge..."), tr("Threshold...")};
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage ExtraFiltersPlugin::filterImage(const QString &filter,
|
QImage ExtraFiltersPlugin::filterImage(const QString &filter,
|
||||||
@ -70,14 +70,14 @@ QImage ExtraFiltersPlugin::filterImage(const QString &filter,
|
|||||||
if (filter == tr("Flip Horizontally")) {
|
if (filter == tr("Flip Horizontally")) {
|
||||||
for (int y = 0; y < original.height(); ++y) {
|
for (int y = 0; y < original.height(); ++y) {
|
||||||
for (int x = 0; x < original.width(); ++x) {
|
for (int x = 0; x < original.width(); ++x) {
|
||||||
int pixel = original.pixel(original.width() - x - 1, y);
|
QRgb pixel = original.pixel(original.width() - x - 1, y);
|
||||||
result.setPixel(x, y, pixel);
|
result.setPixel(x, y, pixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (filter == tr("Flip Vertically")) {
|
} else if (filter == tr("Flip Vertically")) {
|
||||||
for (int y = 0; y < original.height(); ++y) {
|
for (int y = 0; y < original.height(); ++y) {
|
||||||
for (int x = 0; x < original.width(); ++x) {
|
for (int x = 0; x < original.width(); ++x) {
|
||||||
int pixel = original.pixel(x, original.height() - y - 1);
|
QRgb pixel = original.pixel(x, original.height() - y - 1);
|
||||||
result.setPixel(x, y, pixel);
|
result.setPixel(x, y, pixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,11 +90,11 @@ QImage ExtraFiltersPlugin::filterImage(const QString &filter,
|
|||||||
for (int i = 0; i < numIters; ++i) {
|
for (int i = 0; i < numIters; ++i) {
|
||||||
for (int y = 1; y < original.height() - 1; ++y) {
|
for (int y = 1; y < original.height() - 1; ++y) {
|
||||||
for (int x = 1; x < original.width() - 1; ++x) {
|
for (int x = 1; x < original.width() - 1; ++x) {
|
||||||
int p1 = original.pixel(x, y);
|
QRgb p1 = original.pixel(x, y);
|
||||||
int p2 = original.pixel(x, y + 1);
|
QRgb p2 = original.pixel(x, y + 1);
|
||||||
int p3 = original.pixel(x, y - 1);
|
QRgb p3 = original.pixel(x, y - 1);
|
||||||
int p4 = original.pixel(x + 1, y);
|
QRgb p4 = original.pixel(x + 1, y);
|
||||||
int p5 = original.pixel(x - 1, y);
|
QRgb p5 = original.pixel(x - 1, y);
|
||||||
|
|
||||||
int red = (qRed(p1) + qRed(p2) + qRed(p3) + qRed(p4)
|
int red = (qRed(p1) + qRed(p2) + qRed(p3) + qRed(p4)
|
||||||
+ qRed(p5)) / 5;
|
+ qRed(p5)) / 5;
|
||||||
@ -119,7 +119,7 @@ QImage ExtraFiltersPlugin::filterImage(const QString &filter,
|
|||||||
int factor = 256 / threshold;
|
int factor = 256 / threshold;
|
||||||
for (int y = 0; y < original.height(); ++y) {
|
for (int y = 0; y < original.height(); ++y) {
|
||||||
for (int x = 0; x < original.width(); ++x) {
|
for (int x = 0; x < original.width(); ++x) {
|
||||||
int pixel = original.pixel(x, y);
|
QRgb pixel = original.pixel(x, y);
|
||||||
result.setPixel(x, y, qRgba(qRed(pixel) / factor * factor,
|
result.setPixel(x, y, qRgba(qRed(pixel) / factor * factor,
|
||||||
qGreen(pixel) / factor * factor,
|
qGreen(pixel) / factor * factor,
|
||||||
qBlue(pixel) / factor * factor,
|
qBlue(pixel) / factor * factor,
|
||||||
|
BIN
examples/widgets/tutorials/notepad/images/bold.png
Normal file
BIN
examples/widgets/tutorials/notepad/images/bold.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 724 B |
BIN
examples/widgets/tutorials/notepad/images/italic.png
Normal file
BIN
examples/widgets/tutorials/notepad/images/italic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 471 B |
BIN
examples/widgets/tutorials/notepad/images/underline.png
Normal file
BIN
examples/widgets/tutorials/notepad/images/underline.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 520 B |
@ -191,3 +191,27 @@ void Notepad::on_actionFont_triggered()
|
|||||||
if (fontSelected)
|
if (fontSelected)
|
||||||
ui->textEdit->setFont(font);
|
ui->textEdit->setFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Notepad::on_actionUnderline_triggered()
|
||||||
|
{
|
||||||
|
ui->textEdit->setFontUnderline(ui->actionUnderline->isChecked());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Notepad::on_actionItalic_triggered()
|
||||||
|
{
|
||||||
|
ui->textEdit->setFontItalic(ui->actionItalic->isChecked());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Notepad::on_actionBold_triggered()
|
||||||
|
{
|
||||||
|
ui->actionBold->isChecked() ? ui->textEdit->setFontWeight(QFont::Bold) :
|
||||||
|
ui->textEdit->setFontWeight(QFont::Normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Notepad::on_actionAbout_triggered()
|
||||||
|
{
|
||||||
|
QMessageBox::about(this, tr("About MDI"),
|
||||||
|
tr("The <b>Notepad</b> example demonstrates how to code a basic "
|
||||||
|
"text editor using QtWidgets"));
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2017 The Qt Company Ltd.
|
** Copyright (C) 2018 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of the documentation of the Qt Toolkit.
|
** This file is part of the documentation of the Qt Toolkit.
|
||||||
@ -103,6 +103,14 @@ private slots:
|
|||||||
|
|
||||||
void on_actionFont_triggered();
|
void on_actionFont_triggered();
|
||||||
|
|
||||||
|
void on_actionBold_triggered();
|
||||||
|
|
||||||
|
void on_actionUnderline_triggered();
|
||||||
|
|
||||||
|
void on_actionItalic_triggered();
|
||||||
|
|
||||||
|
void on_actionAbout_triggered();
|
||||||
|
|
||||||
//! [6]
|
//! [6]
|
||||||
private:
|
private:
|
||||||
Ui::Notepad *ui;
|
Ui::Notepad *ui;
|
||||||
|
@ -1,12 +1,5 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>images/copy.png</file>
|
|
||||||
<file>images/create.png</file>
|
|
||||||
<file>images/cut.png</file>
|
|
||||||
<file>images/edit_redo.png</file>
|
|
||||||
<file>images/edit_undo.png</file>
|
|
||||||
<file>images/exit.png</file>
|
|
||||||
<file>images/font.png</file>
|
|
||||||
<file>images/info.png</file>
|
<file>images/info.png</file>
|
||||||
<file>images/new.png</file>
|
<file>images/new.png</file>
|
||||||
<file>images/open.png</file>
|
<file>images/open.png</file>
|
||||||
@ -15,5 +8,15 @@
|
|||||||
<file>images/print.png</file>
|
<file>images/print.png</file>
|
||||||
<file>images/save.png</file>
|
<file>images/save.png</file>
|
||||||
<file>images/save_as.png</file>
|
<file>images/save_as.png</file>
|
||||||
|
<file>images/exit.png</file>
|
||||||
|
<file>images/font.png</file>
|
||||||
|
<file>images/copy.png</file>
|
||||||
|
<file>images/create.png</file>
|
||||||
|
<file>images/cut.png</file>
|
||||||
|
<file>images/edit_redo.png</file>
|
||||||
|
<file>images/edit_undo.png</file>
|
||||||
|
<file>images/bold.png</file>
|
||||||
|
<file>images/italic.png</file>
|
||||||
|
<file>images/underline.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>524</width>
|
<width>800</width>
|
||||||
<height>300</height>
|
<height>400</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>524</width>
|
<width>800</width>
|
||||||
<height>25</height>
|
<height>25</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -74,7 +74,13 @@
|
|||||||
<addaction name="actionPaste"/>
|
<addaction name="actionPaste"/>
|
||||||
<addaction name="actionUndo"/>
|
<addaction name="actionUndo"/>
|
||||||
<addaction name="actionRedo"/>
|
<addaction name="actionRedo"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
<addaction name="actionFont"/>
|
<addaction name="actionFont"/>
|
||||||
|
<addaction name="actionBold"/>
|
||||||
|
<addaction name="actionItalic"/>
|
||||||
|
<addaction name="actionUnderline"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionAbout"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionExit"/>
|
<addaction name="actionExit"/>
|
||||||
</widget>
|
</widget>
|
||||||
@ -87,105 +93,224 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>New</string>
|
<string>New</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>New text document</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+N</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionOpen">
|
<action name="actionOpen">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset resource="notepad.qrc">
|
||||||
<normaloff>:/images/open.png</normaloff>:/images/open.png</iconset>
|
<normaloff>:/images/open.png</normaloff>:/images/open.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Open</string>
|
<string>Open</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Open file</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+O</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSave">
|
<action name="actionSave">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset resource="notepad.qrc">
|
||||||
<normaloff>:/images/save.png</normaloff>:/images/save.png</iconset>
|
<normaloff>:/images/save.png</normaloff>:/images/save.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save</string>
|
<string>Save</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Save file</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+S</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSave_as">
|
<action name="actionSave_as">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset resource="notepad.qrc">
|
||||||
<normaloff>:/images/save_as.png</normaloff>:/images/save_as.png</iconset>
|
<normaloff>:/images/save_as.png</normaloff>:/images/save_as.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save as</string>
|
<string>Save as</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Save file as</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Alt+S</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionPrint">
|
<action name="actionPrint">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset resource="notepad.qrc">
|
||||||
<normaloff>:/images/print.png</normaloff>:/images/print.png</iconset>
|
<normaloff>:/images/print.png</normaloff>:/images/print.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Print</string>
|
<string>Print</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Print file</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+P</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionExit">
|
<action name="actionExit">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset theme="exit.png" resource="notepad.qrc">
|
||||||
<normaloff>:/images/exit.png</normaloff>:/images/exit.png</iconset>
|
<normaloff>:/images/exit.png</normaloff>:/images/exit.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Exit</string>
|
<string>Exit</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Exit notepad</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionCopy">
|
<action name="actionCopy">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset resource="notepad.qrc">
|
||||||
<normaloff>:/images/copy.png</normaloff>:/images/copy.png</iconset>
|
<normaloff>:/images/copy.png</normaloff>:/images/copy.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Copy</string>
|
<string>Copy</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+C</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionCut">
|
<action name="actionCut">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset resource="notepad.qrc">
|
||||||
<normaloff>:/images/cut.png</normaloff>:/images/cut.png</iconset>
|
<normaloff>:/images/cut.png</normaloff>:/images/cut.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Cut</string>
|
<string>Cut</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+X</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionPaste">
|
<action name="actionPaste">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset resource="notepad.qrc">
|
||||||
<normaloff>:/images/paste.png</normaloff>:/images/paste.png</iconset>
|
<normaloff>:/images/paste.png</normaloff>:/images/paste.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Paste</string>
|
<string>Paste</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+V</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionUndo">
|
<action name="actionUndo">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset resource="notepad.qrc">
|
||||||
<normaloff>:/images/edit_undo.png</normaloff>:/images/edit_undo.png</iconset>
|
<normaloff>:/images/edit_undo.png</normaloff>:/images/edit_undo.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Undo</string>
|
<string>Undo</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+Z</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionRedo">
|
<action name="actionRedo">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset resource="notepad.qrc">
|
||||||
<normaloff>:/images/edit_redo.png</normaloff>:/images/edit_redo.png</iconset>
|
<normaloff>:/images/edit_redo.png</normaloff>:/images/edit_redo.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Redo</string>
|
<string>Redo</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+Y</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionFont">
|
<action name="actionFont">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset resource="notepad.qrc">
|
||||||
<normaloff>:/images/font.png</normaloff>:/images/font.png</iconset>
|
<normaloff>:/images/font.png</normaloff>:/images/font.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Font</string>
|
<string>Font</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+F</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionItalic">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="notepad.qrc">
|
||||||
|
<normaloff>:/images/italic.png</normaloff>:/images/italic.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Italic</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Italic font</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+I</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionBold">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="notepad.qrc">
|
||||||
|
<normaloff>:/images/bold.png</normaloff>:/images/bold.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>actionBold</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Bold</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+B</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionUnderline">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="notepad.qrc">
|
||||||
|
<normaloff>:/images/underline.png</normaloff>:/images/underline.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Underline</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Underline</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+U</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionAbout">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="notepad.qrc">
|
||||||
|
<normaloff>:/images/info.png</normaloff>:/images/info.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>About</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>About Notepad</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
|
@ -1951,7 +1951,8 @@ for(ever) {
|
|||||||
isEmpty(configsToProcess): \
|
isEmpty(configsToProcess): \
|
||||||
break()
|
break()
|
||||||
|
|
||||||
currentConfig = config.$$take_first(configsToProcess)
|
thisConfig = $$take_first(configsToProcess)
|
||||||
|
currentConfig = config.$$thisConfig
|
||||||
thisDir = $$eval($${currentConfig}.dir)
|
thisDir = $$eval($${currentConfig}.dir)
|
||||||
jsonFile = $$thisDir/configure.json
|
jsonFile = $$thisDir/configure.json
|
||||||
priFile = $$thisDir/configure.pri
|
priFile = $$thisDir/configure.pri
|
||||||
@ -1982,7 +1983,7 @@ for(ever) {
|
|||||||
subconfigs =
|
subconfigs =
|
||||||
for(n, $${currentConfig}.subconfigs._KEYS_) {
|
for(n, $${currentConfig}.subconfigs._KEYS_) {
|
||||||
subconfig = $$eval($${currentConfig}.subconfigs.$${n})
|
subconfig = $$eval($${currentConfig}.subconfigs.$${n})
|
||||||
name = $$basename(subconfig)
|
name = $${thisConfig}_$$basename(subconfig)
|
||||||
ex = $$eval(config.$${name}.dir)
|
ex = $$eval(config.$${name}.dir)
|
||||||
!isEmpty(ex): \
|
!isEmpty(ex): \
|
||||||
error("Basename clash between $$thisDir/$$subconfig and $${ex}.")
|
error("Basename clash between $$thisDir/$$subconfig and $${ex}.")
|
||||||
|
@ -738,7 +738,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
|
|||||||
const QString &sep = (args.count() == 2) ? args.at(1).toQString(m_tmp1) : statics.field_sep;
|
const QString &sep = (args.count() == 2) ? args.at(1).toQString(m_tmp1) : statics.field_sep;
|
||||||
const auto vars = values(map(args.at(0)));
|
const auto vars = values(map(args.at(0)));
|
||||||
for (const ProString &var : vars) {
|
for (const ProString &var : vars) {
|
||||||
const auto splits = var.toQStringRef().split(sep);
|
// FIXME: this is inconsistent with the "there are no empty strings" dogma.
|
||||||
|
const auto splits = var.toQStringRef().split(sep, QString::KeepEmptyParts);
|
||||||
for (const auto &splt : splits)
|
for (const auto &splt : splits)
|
||||||
ret << ProString(splt).setSource(var);
|
ret << ProString(splt).setSource(var);
|
||||||
}
|
}
|
||||||
@ -1445,7 +1446,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
|
|||||||
}
|
}
|
||||||
if (args.count() == 1)
|
if (args.count() == 1)
|
||||||
return returnBool(isActiveConfig(args.at(0).toQStringRef()));
|
return returnBool(isActiveConfig(args.at(0).toQStringRef()));
|
||||||
const auto mutuals = args.at(1).toQStringRef().split(QLatin1Char('|'));
|
const auto mutuals = args.at(1).toQStringRef().split(QLatin1Char('|'),
|
||||||
|
QString::SkipEmptyParts);
|
||||||
const ProStringList &configs = values(statics.strCONFIG);
|
const ProStringList &configs = values(statics.strCONFIG);
|
||||||
|
|
||||||
for (int i = configs.size() - 1; i >= 0; i--) {
|
for (int i = configs.size() - 1; i >= 0; i--) {
|
||||||
@ -1477,7 +1479,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
|
|||||||
return ReturnTrue;
|
return ReturnTrue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const auto mutuals = args.at(2).toQStringRef().split(QLatin1Char('|'));
|
const auto mutuals = args.at(2).toQStringRef().split(QLatin1Char('|'),
|
||||||
|
QString::SkipEmptyParts);
|
||||||
for (int i = l.size() - 1; i >= 0; i--) {
|
for (int i = l.size() - 1; i >= 0; i--) {
|
||||||
const ProString val = l[i];
|
const ProString val = l[i];
|
||||||
for (int mut = 0; mut < mutuals.count(); mut++) {
|
for (int mut = 0; mut < mutuals.count(); mut++) {
|
||||||
|
@ -297,6 +297,7 @@ ProStringList QMakeEvaluator::split_value_list(const QStringRef &vals, int sourc
|
|||||||
case '\'':
|
case '\'':
|
||||||
if (!quote)
|
if (!quote)
|
||||||
quote = unicode;
|
quote = unicode;
|
||||||
|
// FIXME: this is inconsistent with the "there are no empty strings" dogma.
|
||||||
hadWord = true;
|
hadWord = true;
|
||||||
break;
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
@ -879,7 +880,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProVariable(
|
|||||||
return ReturnTrue;
|
return ReturnTrue;
|
||||||
}
|
}
|
||||||
QChar sep = val.at(1);
|
QChar sep = val.at(1);
|
||||||
auto func = val.split(sep);
|
auto func = val.split(sep, QString::KeepEmptyParts);
|
||||||
if (func.count() < 3 || func.count() > 4) {
|
if (func.count() < 3 || func.count() > 4) {
|
||||||
evalError(fL1S("The s/// function expects 3 or 4 arguments."));
|
evalError(fL1S("The s/// function expects 3 or 4 arguments."));
|
||||||
return ReturnTrue;
|
return ReturnTrue;
|
||||||
@ -1018,7 +1019,7 @@ static ProString msvcArchitecture(const QString &vcInstallDir, const QString &pa
|
|||||||
QString vcBinDir = vcInstallDir;
|
QString vcBinDir = vcInstallDir;
|
||||||
if (vcBinDir.endsWith(QLatin1Char('\\')))
|
if (vcBinDir.endsWith(QLatin1Char('\\')))
|
||||||
vcBinDir.chop(1);
|
vcBinDir.chop(1);
|
||||||
const auto dirs = pathVar.split(QLatin1Char(';'));
|
const auto dirs = pathVar.split(QLatin1Char(';'), QString::SkipEmptyParts);
|
||||||
for (const QString &dir : dirs) {
|
for (const QString &dir : dirs) {
|
||||||
if (!dir.startsWith(vcBinDir, Qt::CaseInsensitive))
|
if (!dir.startsWith(vcBinDir, Qt::CaseInsensitive))
|
||||||
continue;
|
continue;
|
||||||
|
@ -261,7 +261,7 @@ QStringList QMakeGlobals::splitPathList(const QString &val) const
|
|||||||
QStringList ret;
|
QStringList ret;
|
||||||
if (!val.isEmpty()) {
|
if (!val.isEmpty()) {
|
||||||
QString cwd(QDir::currentPath());
|
QString cwd(QDir::currentPath());
|
||||||
const QStringList vals = val.split(dirlist_sep);
|
const QStringList vals = val.split(dirlist_sep, QString::SkipEmptyParts);
|
||||||
ret.reserve(vals.length());
|
ret.reserve(vals.length());
|
||||||
for (const QString &it : vals)
|
for (const QString &it : vals)
|
||||||
ret << IoUtils::resolvePath(cwd, it);
|
ret << IoUtils::resolvePath(cwd, it);
|
||||||
|
@ -3990,7 +3990,7 @@ Q_GLOBAL_STATIC(QInternal_CallBackTable, global_callback_table)
|
|||||||
|
|
||||||
bool QInternal::registerCallback(Callback cb, qInternalCallback callback)
|
bool QInternal::registerCallback(Callback cb, qInternalCallback callback)
|
||||||
{
|
{
|
||||||
if (cb >= 0 && cb < QInternal::LastCallback) {
|
if (unsigned(cb) < unsigned(QInternal::LastCallback)) {
|
||||||
QInternal_CallBackTable *cbt = global_callback_table();
|
QInternal_CallBackTable *cbt = global_callback_table();
|
||||||
cbt->callbacks.resize(cb + 1);
|
cbt->callbacks.resize(cb + 1);
|
||||||
cbt->callbacks[cb].append(callback);
|
cbt->callbacks[cb].append(callback);
|
||||||
@ -4001,7 +4001,7 @@ bool QInternal::registerCallback(Callback cb, qInternalCallback callback)
|
|||||||
|
|
||||||
bool QInternal::unregisterCallback(Callback cb, qInternalCallback callback)
|
bool QInternal::unregisterCallback(Callback cb, qInternalCallback callback)
|
||||||
{
|
{
|
||||||
if (cb >= 0 && cb < QInternal::LastCallback) {
|
if (unsigned(cb) < unsigned(QInternal::LastCallback)) {
|
||||||
if (global_callback_table.exists()) {
|
if (global_callback_table.exists()) {
|
||||||
QInternal_CallBackTable *cbt = global_callback_table();
|
QInternal_CallBackTable *cbt = global_callback_table();
|
||||||
return (bool) cbt->callbacks[cb].removeAll(callback);
|
return (bool) cbt->callbacks[cb].removeAll(callback);
|
||||||
|
@ -315,18 +315,14 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
|
|||||||
break;
|
break;
|
||||||
case Big32:
|
case Big32:
|
||||||
case Little32:
|
case Little32:
|
||||||
if (m_number <= quint32(-1)) {
|
m_number = m_type == Little32 ? qFromLittleEndian<quint32>(m_number) : qFromBigEndian<quint32>(m_number);
|
||||||
m_number = m_type == Little32 ? qFromLittleEndian<quint32>(m_number) : qFromBigEndian<quint32>(m_number);
|
if (m_numberMask != 0)
|
||||||
if (m_numberMask != 0)
|
m_numberMask = m_type == Little32 ? qFromLittleEndian<quint32>(m_numberMask) : qFromBigEndian<quint32>(m_numberMask);
|
||||||
m_numberMask = m_type == Little32 ? qFromLittleEndian<quint32>(m_numberMask) : qFromBigEndian<quint32>(m_numberMask);
|
|
||||||
}
|
|
||||||
Q_FALLTHROUGH();
|
Q_FALLTHROUGH();
|
||||||
case Host32:
|
case Host32:
|
||||||
if (m_number <= quint32(-1)) {
|
if (m_numberMask == 0)
|
||||||
if (m_numberMask == 0)
|
m_numberMask = quint32(-1);
|
||||||
m_numberMask = quint32(-1);
|
m_matchFunction = &QMimeMagicRule::matchNumber<quint32>;
|
||||||
m_matchFunction = &QMimeMagicRule::matchNumber<quint32>;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
485
src/corelib/thread/qatomic_msvc.h
Normal file
485
src/corelib/thread/qatomic_msvc.h
Normal file
@ -0,0 +1,485 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2016 The Qt Company Ltd.
|
||||||
|
** Copyright (C) 2016 Intel Corporation.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the QtCore module of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 3 requirements
|
||||||
|
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 2.0 or (at your option) the GNU General
|
||||||
|
** Public license version 3 or any later version approved by the KDE Free
|
||||||
|
** Qt Foundation. The licenses are as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||||
|
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QATOMIC_MSVC_H
|
||||||
|
#define QATOMIC_MSVC_H
|
||||||
|
|
||||||
|
#include <QtCore/qgenericatomic.h>
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// use compiler intrinsics for all atomic functions
|
||||||
|
# define QT_INTERLOCKED_PREFIX _
|
||||||
|
# define QT_INTERLOCKED_PROTOTYPE
|
||||||
|
# define QT_INTERLOCKED_DECLARE_PROTOTYPES
|
||||||
|
# define QT_INTERLOCKED_INTRINSIC
|
||||||
|
# define Q_ATOMIC_INT16_IS_SUPPORTED
|
||||||
|
|
||||||
|
# ifdef _WIN64
|
||||||
|
# define Q_ATOMIC_INT64_IS_SUPPORTED
|
||||||
|
# endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Prototype declaration
|
||||||
|
|
||||||
|
#define QT_INTERLOCKED_CONCAT_I(prefix, suffix) \
|
||||||
|
prefix ## suffix
|
||||||
|
#define QT_INTERLOCKED_CONCAT(prefix, suffix) \
|
||||||
|
QT_INTERLOCKED_CONCAT_I(prefix, suffix)
|
||||||
|
|
||||||
|
// MSVC intrinsics prefix function names with an underscore. Also, if platform
|
||||||
|
// SDK headers have been included, the Interlocked names may be defined as
|
||||||
|
// macros.
|
||||||
|
// To avoid double underscores, we paste the prefix with Interlocked first and
|
||||||
|
// then the remainder of the function name.
|
||||||
|
#define QT_INTERLOCKED_FUNCTION(name) \
|
||||||
|
QT_INTERLOCKED_CONCAT( \
|
||||||
|
QT_INTERLOCKED_CONCAT(QT_INTERLOCKED_PREFIX, Interlocked), name)
|
||||||
|
|
||||||
|
#ifndef QT_INTERLOCKED_VOLATILE
|
||||||
|
# define QT_INTERLOCKED_VOLATILE volatile
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef QT_INTERLOCKED_PREFIX
|
||||||
|
#define QT_INTERLOCKED_PREFIX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef QT_INTERLOCKED_PROTOTYPE
|
||||||
|
#define QT_INTERLOCKED_PROTOTYPE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef QT_INTERLOCKED_DECLARE_PROTOTYPES
|
||||||
|
#undef QT_INTERLOCKED_DECLARE_PROTOTYPES
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Increment )(long QT_INTERLOCKED_VOLATILE *);
|
||||||
|
long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Decrement )(long QT_INTERLOCKED_VOLATILE *);
|
||||||
|
long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( CompareExchange )(long QT_INTERLOCKED_VOLATILE *, long, long);
|
||||||
|
long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange )(long QT_INTERLOCKED_VOLATILE *, long);
|
||||||
|
long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd )(long QT_INTERLOCKED_VOLATILE *, long);
|
||||||
|
|
||||||
|
# if !defined(__i386__) && !defined(_M_IX86)
|
||||||
|
void * QT_INTERLOCKED_FUNCTION( CompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *);
|
||||||
|
void * QT_INTERLOCKED_FUNCTION( ExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *);
|
||||||
|
__int64 QT_INTERLOCKED_FUNCTION( ExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef Q_ATOMIC_INT16_IS_SUPPORTED
|
||||||
|
short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Increment16 )(short QT_INTERLOCKED_VOLATILE *);
|
||||||
|
short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Decrement16 )(short QT_INTERLOCKED_VOLATILE *);
|
||||||
|
short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( CompareExchange16 )(short QT_INTERLOCKED_VOLATILE *, short, short);
|
||||||
|
short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange16 )(short QT_INTERLOCKED_VOLATILE *, short);
|
||||||
|
short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd16 )(short QT_INTERLOCKED_VOLATILE *, short);
|
||||||
|
# endif
|
||||||
|
# ifdef Q_ATOMIC_INT64_IS_SUPPORTED
|
||||||
|
__int64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Increment64 )(__int64 QT_INTERLOCKED_VOLATILE *);
|
||||||
|
__int64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Decrement64 )(__int64 QT_INTERLOCKED_VOLATILE *);
|
||||||
|
__int64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( CompareExchange64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64, __int64);
|
||||||
|
__int64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64);
|
||||||
|
//above already: qint64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd64 )(qint64 QT_INTERLOCKED_VOLATILE *, qint64);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // QT_INTERLOCKED_DECLARE_PROTOTYPES
|
||||||
|
|
||||||
|
#undef QT_INTERLOCKED_PROTOTYPE
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef QT_INTERLOCKED_INTRINSIC
|
||||||
|
#undef QT_INTERLOCKED_INTRINSIC
|
||||||
|
|
||||||
|
# pragma intrinsic (_InterlockedIncrement)
|
||||||
|
# pragma intrinsic (_InterlockedDecrement)
|
||||||
|
# pragma intrinsic (_InterlockedExchange)
|
||||||
|
# pragma intrinsic (_InterlockedCompareExchange)
|
||||||
|
# pragma intrinsic (_InterlockedExchangeAdd)
|
||||||
|
|
||||||
|
# if !defined(_M_IX86)
|
||||||
|
# pragma intrinsic (_InterlockedCompareExchangePointer)
|
||||||
|
# pragma intrinsic (_InterlockedExchangePointer)
|
||||||
|
# pragma intrinsic (_InterlockedExchangeAdd64)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif // QT_INTERLOCKED_INTRINSIC
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Interlocked* replacement macros
|
||||||
|
|
||||||
|
#if defined(__i386__) || defined(_M_IX86)
|
||||||
|
|
||||||
|
# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \
|
||||||
|
reinterpret_cast<void *>( \
|
||||||
|
QT_INTERLOCKED_FUNCTION(CompareExchange)( \
|
||||||
|
reinterpret_cast<long QT_INTERLOCKED_VOLATILE *>(value), \
|
||||||
|
long(newValue), \
|
||||||
|
long(expectedValue)))
|
||||||
|
|
||||||
|
# define QT_INTERLOCKED_EXCHANGE_POINTER(value, newValue) \
|
||||||
|
QT_INTERLOCKED_FUNCTION(Exchange)( \
|
||||||
|
reinterpret_cast<long QT_INTERLOCKED_VOLATILE *>(value), \
|
||||||
|
long(newValue))
|
||||||
|
|
||||||
|
# define QT_INTERLOCKED_EXCHANGE_ADD_POINTER(value, valueToAdd) \
|
||||||
|
QT_INTERLOCKED_FUNCTION(ExchangeAdd)( \
|
||||||
|
reinterpret_cast<long QT_INTERLOCKED_VOLATILE *>(value), \
|
||||||
|
(valueToAdd))
|
||||||
|
|
||||||
|
#else // !defined(__i386__) && !defined(_M_IX86)
|
||||||
|
|
||||||
|
# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \
|
||||||
|
QT_INTERLOCKED_FUNCTION(CompareExchangePointer)( \
|
||||||
|
(void * QT_INTERLOCKED_VOLATILE *)(value), \
|
||||||
|
(void *) (newValue), \
|
||||||
|
(void *) (expectedValue))
|
||||||
|
|
||||||
|
# define QT_INTERLOCKED_EXCHANGE_POINTER(value, newValue) \
|
||||||
|
QT_INTERLOCKED_FUNCTION(ExchangePointer)( \
|
||||||
|
(void * QT_INTERLOCKED_VOLATILE *)(value), \
|
||||||
|
(void *) (newValue))
|
||||||
|
|
||||||
|
# define QT_INTERLOCKED_EXCHANGE_ADD_POINTER(value, valueToAdd) \
|
||||||
|
QT_INTERLOCKED_FUNCTION(ExchangeAdd64)( \
|
||||||
|
reinterpret_cast<qint64 QT_INTERLOCKED_VOLATILE *>(value), \
|
||||||
|
(valueToAdd))
|
||||||
|
|
||||||
|
#endif // !defined(__i386__) && !defined(_M_IX86)
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// silence syncqt warnings
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
#pragma qt_sync_skip_header_check
|
||||||
|
#pragma qt_sync_stop_processing
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
|
||||||
|
#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_WAIT_FREE
|
||||||
|
|
||||||
|
#define Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE
|
||||||
|
#define Q_ATOMIC_INT_TEST_AND_SET_IS_WAIT_FREE
|
||||||
|
|
||||||
|
#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE
|
||||||
|
#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_WAIT_FREE
|
||||||
|
|
||||||
|
#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE
|
||||||
|
#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_WAIT_FREE
|
||||||
|
|
||||||
|
#define Q_ATOMIC_INT32_IS_SUPPORTED
|
||||||
|
|
||||||
|
#define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
|
||||||
|
#define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_WAIT_FREE
|
||||||
|
|
||||||
|
#define Q_ATOMIC_INT32_TEST_AND_SET_IS_ALWAYS_NATIVE
|
||||||
|
#define Q_ATOMIC_INT32_TEST_AND_SET_IS_WAIT_FREE
|
||||||
|
|
||||||
|
#define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_ALWAYS_NATIVE
|
||||||
|
#define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_WAIT_FREE
|
||||||
|
|
||||||
|
#define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_ALWAYS_NATIVE
|
||||||
|
#define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_WAIT_FREE
|
||||||
|
|
||||||
|
#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE
|
||||||
|
#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_WAIT_FREE
|
||||||
|
|
||||||
|
#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE
|
||||||
|
#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_WAIT_FREE
|
||||||
|
|
||||||
|
#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE
|
||||||
|
#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_WAIT_FREE
|
||||||
|
|
||||||
|
#ifdef Q_ATOMIC_INT16_IS_SUPPORTED
|
||||||
|
# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
|
||||||
|
# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_WAIT_FREE
|
||||||
|
|
||||||
|
# define Q_ATOMIC_INT16_TEST_AND_SET_IS_ALWAYS_NATIVE
|
||||||
|
# define Q_ATOMIC_INT16_TEST_AND_SET_IS_WAIT_FREE
|
||||||
|
|
||||||
|
# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_ALWAYS_NATIVE
|
||||||
|
# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_WAIT_FREE
|
||||||
|
|
||||||
|
# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_ALWAYS_NATIVE
|
||||||
|
# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_WAIT_FREE
|
||||||
|
|
||||||
|
template<> struct QAtomicOpsSupport<2> { enum { IsSupported = 1 }; };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_ATOMIC_INT64_IS_SUPPORTED
|
||||||
|
# define Q_ATOMIC_INT64_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
|
||||||
|
# define Q_ATOMIC_INT64_REFERENCE_COUNTING_IS_WAIT_FREE
|
||||||
|
|
||||||
|
# define Q_ATOMIC_INT64_TEST_AND_SET_IS_ALWAYS_NATIVE
|
||||||
|
# define Q_ATOMIC_INT64_TEST_AND_SET_IS_WAIT_FREE
|
||||||
|
|
||||||
|
# define Q_ATOMIC_INT64_FETCH_AND_STORE_IS_ALWAYS_NATIVE
|
||||||
|
# define Q_ATOMIC_INT64_FETCH_AND_STORE_IS_WAIT_FREE
|
||||||
|
|
||||||
|
# define Q_ATOMIC_INT64_FETCH_AND_ADD_IS_ALWAYS_NATIVE
|
||||||
|
# define Q_ATOMIC_INT64_FETCH_AND_ADD_IS_WAIT_FREE
|
||||||
|
|
||||||
|
template<> struct QAtomicOpsSupport<8> { enum { IsSupported = 1 }; };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template <int N> struct QAtomicWindowsType { typedef typename QIntegerForSize<N>::Signed Type; };
|
||||||
|
template <> struct QAtomicWindowsType<4> { typedef long Type; };
|
||||||
|
|
||||||
|
|
||||||
|
template <int N> struct QAtomicOpsBySize : QGenericAtomicOps<QAtomicOpsBySize<N> >
|
||||||
|
{
|
||||||
|
static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; }
|
||||||
|
static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return true; }
|
||||||
|
template <typename T> static bool ref(T &_q_value) Q_DECL_NOTHROW;
|
||||||
|
template <typename T> static bool deref(T &_q_value) Q_DECL_NOTHROW;
|
||||||
|
|
||||||
|
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
|
||||||
|
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; }
|
||||||
|
template <typename T> static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW;
|
||||||
|
template <typename T>
|
||||||
|
static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW;
|
||||||
|
|
||||||
|
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; }
|
||||||
|
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; }
|
||||||
|
template <typename T> static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW;
|
||||||
|
|
||||||
|
static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; }
|
||||||
|
static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; }
|
||||||
|
template <typename T> static T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW;
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef typename QAtomicWindowsType<N>::Type Type;
|
||||||
|
template <typename T> static inline Type *atomic(T *t)
|
||||||
|
{ Q_STATIC_ASSERT(sizeof(T) == sizeof(Type)); return reinterpret_cast<Type *>(t); }
|
||||||
|
template <typename T> static inline Type value(T t)
|
||||||
|
{ Q_STATIC_ASSERT(sizeof(T) == sizeof(Type)); return Type(t); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct QAtomicOps : QAtomicOpsBySize<sizeof(T)>
|
||||||
|
{
|
||||||
|
typedef T Type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> template<typename T>
|
||||||
|
inline bool QAtomicOpsBySize<4>::ref(T &_q_value) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QT_INTERLOCKED_FUNCTION(Increment)(atomic(&_q_value)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> template<typename T>
|
||||||
|
inline bool QAtomicOpsBySize<4>::deref(T &_q_value) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QT_INTERLOCKED_FUNCTION(Decrement)(atomic(&_q_value)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> template<typename T>
|
||||||
|
inline bool QAtomicOpsBySize<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QT_INTERLOCKED_FUNCTION(CompareExchange)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> template <typename T>
|
||||||
|
inline bool QAtomicOpsBySize<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
*currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange)(atomic(&_q_value), newValue, expectedValue));
|
||||||
|
return *currentValue == expectedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> template<typename T>
|
||||||
|
inline T QAtomicOpsBySize<4>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QT_INTERLOCKED_FUNCTION(Exchange)(atomic(&_q_value), value(newValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> template<typename T>
|
||||||
|
inline T QAtomicOpsBySize<4>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QT_INTERLOCKED_FUNCTION(ExchangeAdd)(atomic(&_q_value), value<T>(valueToAdd * QAtomicAdditiveType<T>::AddScale));
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef Q_ATOMIC_INT16_IS_SUPPORTED
|
||||||
|
template<> template<typename T>
|
||||||
|
inline bool QAtomicOpsBySize<2>::ref(T &_q_value) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QT_INTERLOCKED_FUNCTION(Increment16)(atomic(&_q_value)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> template<typename T>
|
||||||
|
inline bool QAtomicOpsBySize<2>::deref(T &_q_value) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QT_INTERLOCKED_FUNCTION(Decrement16)(atomic(&_q_value)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> template<typename T>
|
||||||
|
inline bool QAtomicOpsBySize<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QT_INTERLOCKED_FUNCTION(CompareExchange16)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> template <typename T>
|
||||||
|
inline bool QAtomicOpsBySize<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
*currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange16)(atomic(&_q_value), newValue, expectedValue));
|
||||||
|
return *currentValue == expectedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> template<typename T>
|
||||||
|
inline T QAtomicOpsBySize<2>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QT_INTERLOCKED_FUNCTION(Exchange16)(atomic(&_q_value), value(newValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> template<typename T>
|
||||||
|
inline T QAtomicOpsBySize<2>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QT_INTERLOCKED_FUNCTION(ExchangeAdd16)(atomic(&_q_value), value<T>(valueToAdd * QAtomicAdditiveType<T>::AddScale));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_ATOMIC_INT64_IS_SUPPORTED
|
||||||
|
template<> template<typename T>
|
||||||
|
inline bool QAtomicOpsBySize<8>::ref(T &_q_value) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QT_INTERLOCKED_FUNCTION(Increment64)(atomic(&_q_value)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> template<typename T>
|
||||||
|
inline bool QAtomicOpsBySize<8>::deref(T &_q_value) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QT_INTERLOCKED_FUNCTION(Decrement64)(atomic(&_q_value)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> template<typename T>
|
||||||
|
inline bool QAtomicOpsBySize<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QT_INTERLOCKED_FUNCTION(CompareExchange64)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> template <typename T>
|
||||||
|
inline bool QAtomicOpsBySize<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
*currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange64)(atomic(&_q_value), newValue, expectedValue));
|
||||||
|
return *currentValue == expectedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> template<typename T>
|
||||||
|
inline T QAtomicOpsBySize<8>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QT_INTERLOCKED_FUNCTION(Exchange64)(atomic(&_q_value), value(newValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> template<typename T>
|
||||||
|
inline T QAtomicOpsBySize<8>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QT_INTERLOCKED_FUNCTION(ExchangeAdd64)(atomic(&_q_value), value<T>(valueToAdd * QAtomicAdditiveType<T>::AddScale));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Specialization for pointer types, since we have Interlocked*Pointer() variants in some configurations
|
||||||
|
template <typename T>
|
||||||
|
struct QAtomicOps<T *> : QGenericAtomicOps<QAtomicOps<T *> >
|
||||||
|
{
|
||||||
|
typedef T *Type;
|
||||||
|
|
||||||
|
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
|
||||||
|
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; }
|
||||||
|
static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) Q_DECL_NOTHROW;
|
||||||
|
static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue, T **currentValue) Q_DECL_NOTHROW;
|
||||||
|
|
||||||
|
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; }
|
||||||
|
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; }
|
||||||
|
static T *fetchAndStoreRelaxed(T *&_q_value, T *newValue) Q_DECL_NOTHROW;
|
||||||
|
|
||||||
|
static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; }
|
||||||
|
static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; }
|
||||||
|
static T *fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) Q_DECL_NOTHROW;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline bool QAtomicOps<T *>::testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(&_q_value, newValue, expectedValue) == expectedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline bool QAtomicOps<T *>::testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue, T **currentValue) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
*currentValue = reinterpret_cast<T *>(QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(&_q_value, newValue, expectedValue));
|
||||||
|
return *currentValue == expectedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline T *QAtomicOps<T *>::fetchAndStoreRelaxed(T *&_q_value, T *newValue) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return reinterpret_cast<T *>(QT_INTERLOCKED_EXCHANGE_POINTER(&_q_value, newValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline T *QAtomicOps<T *>::fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return reinterpret_cast<T *>(QT_INTERLOCKED_EXCHANGE_ADD_POINTER(&_q_value, valueToAdd * sizeof(T)));
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Cleanup
|
||||||
|
|
||||||
|
#undef QT_INTERLOCKED_CONCAT_I
|
||||||
|
#undef QT_INTERLOCKED_CONCAT
|
||||||
|
#undef QT_INTERLOCKED_FUNCTION
|
||||||
|
#undef QT_INTERLOCKED_PREFIX
|
||||||
|
|
||||||
|
#undef QT_INTERLOCKED_VOLATILE
|
||||||
|
|
||||||
|
#undef QT_INTERLOCKED_INCREMENT
|
||||||
|
#undef QT_INTERLOCKED_DECREMENT
|
||||||
|
#undef QT_INTERLOCKED_COMPARE_EXCHANGE
|
||||||
|
#undef QT_INTERLOCKED_EXCHANGE
|
||||||
|
#undef QT_INTERLOCKED_EXCHANGE_ADD
|
||||||
|
#undef QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER
|
||||||
|
#undef QT_INTERLOCKED_EXCHANGE_POINTER
|
||||||
|
#undef QT_INTERLOCKED_EXCHANGE_ADD_POINTER
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
#endif // QATOMIC_MSVC_H
|
@ -45,8 +45,20 @@
|
|||||||
|
|
||||||
#if defined(QT_BOOTSTRAPPED)
|
#if defined(QT_BOOTSTRAPPED)
|
||||||
# include <QtCore/qatomic_bootstrap.h>
|
# include <QtCore/qatomic_bootstrap.h>
|
||||||
#else
|
|
||||||
|
// If C++11 atomics are supported, use them!
|
||||||
|
// Note that constexpr support is sometimes disabled in QNX builds but its
|
||||||
|
// library has <atomic>.
|
||||||
|
#elif defined(Q_COMPILER_ATOMICS) && (defined(Q_COMPILER_CONSTEXPR) || defined(Q_OS_QNX))
|
||||||
# include <QtCore/qatomic_cxx11.h>
|
# include <QtCore/qatomic_cxx11.h>
|
||||||
|
|
||||||
|
// We only support one fallback: MSVC, because even on version 2015, it lacks full constexpr support
|
||||||
|
#elif defined(Q_CC_MSVC)
|
||||||
|
# include <QtCore/qatomic_msvc.h>
|
||||||
|
|
||||||
|
// No fallback
|
||||||
|
#else
|
||||||
|
# error "Qt requires C++11 support"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
|
@ -219,14 +219,17 @@ QThreadPrivate::~QThreadPrivate()
|
|||||||
It is important to remember that a QThread instance \l{QObject#Thread
|
It is important to remember that a QThread instance \l{QObject#Thread
|
||||||
Affinity}{lives in} the old thread that instantiated it, not in the
|
Affinity}{lives in} the old thread that instantiated it, not in the
|
||||||
new thread that calls run(). This means that all of QThread's queued
|
new thread that calls run(). This means that all of QThread's queued
|
||||||
slots will execute in the old thread. Thus, a developer who wishes to
|
slots and \l {QMetaObject::invokeMethod()}{invoked methods} will execute
|
||||||
invoke slots in the new thread must use the worker-object approach; new
|
in the old thread. Thus, a developer who wishes to invoke slots in the
|
||||||
slots should not be implemented directly into a subclassed QThread.
|
new thread must use the worker-object approach; new slots should not be
|
||||||
|
implemented directly into a subclassed QThread.
|
||||||
|
|
||||||
When subclassing QThread, keep in mind that the constructor executes in
|
Unlike queued slots or invoked methods, methods called directly on the
|
||||||
the old thread while run() executes in the new thread. If a member
|
QThread object will execute in the thread that calls the method. When
|
||||||
variable is accessed from both functions, then the variable is accessed
|
subclassing QThread, keep in mind that the constructor executes in the
|
||||||
from two different threads. Check that it is safe to do so.
|
old thread while run() executes in the new thread. If a member variable
|
||||||
|
is accessed from both functions, then the variable is accessed from two
|
||||||
|
different threads. Check that it is safe to do so.
|
||||||
|
|
||||||
\note Care must be taken when interacting with objects across different
|
\note Care must be taken when interacting with objects across different
|
||||||
threads. See \l{Synchronizing Threads} for details.
|
threads. See \l{Synchronizing Threads} for details.
|
||||||
|
@ -53,6 +53,8 @@ qtConfig(future) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
|
HEADERS += thread/qatomic_msvc.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
thread/qmutex_win.cpp \
|
thread/qmutex_win.cpp \
|
||||||
thread/qthread_win.cpp \
|
thread/qthread_win.cpp \
|
||||||
|
@ -549,7 +549,7 @@ void QPlatformCursorImage::createSystemCursor(int id)
|
|||||||
void QPlatformCursorImage::set(Qt::CursorShape id)
|
void QPlatformCursorImage::set(Qt::CursorShape id)
|
||||||
{
|
{
|
||||||
QPlatformCursorImage *cursor = 0;
|
QPlatformCursorImage *cursor = 0;
|
||||||
if (id >= 0 && id <= Qt::LastCursor) {
|
if (unsigned(id) <= unsigned(Qt::LastCursor)) {
|
||||||
if (!systemCursorTable[id])
|
if (!systemCursorTable[id])
|
||||||
createSystemCursor(id);
|
createSystemCursor(id);
|
||||||
cursor = systemCursorTable[id];
|
cursor = systemCursorTable[id];
|
||||||
|
@ -664,18 +664,18 @@ QStringList QFileDialogOptions::history() const
|
|||||||
|
|
||||||
void QFileDialogOptions::setLabelText(QFileDialogOptions::DialogLabel label, const QString &text)
|
void QFileDialogOptions::setLabelText(QFileDialogOptions::DialogLabel label, const QString &text)
|
||||||
{
|
{
|
||||||
if (label >= 0 && label < DialogLabelCount)
|
if (unsigned(label) < unsigned(DialogLabelCount))
|
||||||
d->labels[label] = text;
|
d->labels[label] = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QFileDialogOptions::labelText(QFileDialogOptions::DialogLabel label) const
|
QString QFileDialogOptions::labelText(QFileDialogOptions::DialogLabel label) const
|
||||||
{
|
{
|
||||||
return (label >= 0 && label < DialogLabelCount) ? d->labels[label] : QString();
|
return (unsigned(label) < unsigned(DialogLabelCount)) ? d->labels[label] : QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QFileDialogOptions::isLabelExplicitlySet(DialogLabel label)
|
bool QFileDialogOptions::isLabelExplicitlySet(DialogLabel label)
|
||||||
{
|
{
|
||||||
return label >= 0 && label < DialogLabelCount && !d->labels[label].isEmpty();
|
return unsigned(label) < unsigned(DialogLabelCount) && !d->labels[label].isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl QFileDialogOptions::initialDirectory() const
|
QUrl QFileDialogOptions::initialDirectory() const
|
||||||
|
@ -1424,14 +1424,17 @@ QImage QOpenGLFramebufferObject::toImage(bool flipped, int colorAttachmentIndex)
|
|||||||
// qt_gl_read_framebuffer doesn't work on a multisample FBO
|
// qt_gl_read_framebuffer doesn't work on a multisample FBO
|
||||||
if (format().samples() != 0) {
|
if (format().samples() != 0) {
|
||||||
QRect rect(QPoint(0, 0), size());
|
QRect rect(QPoint(0, 0), size());
|
||||||
|
QOpenGLFramebufferObjectFormat fmt;
|
||||||
if (extraFuncs->hasOpenGLFeature(QOpenGLFunctions::MultipleRenderTargets)) {
|
if (extraFuncs->hasOpenGLFeature(QOpenGLFunctions::MultipleRenderTargets)) {
|
||||||
QOpenGLFramebufferObject temp(d->colorAttachments[colorAttachmentIndex].size, QOpenGLFramebufferObjectFormat());
|
fmt.setInternalTextureFormat(d->colorAttachments[colorAttachmentIndex].internalFormat);
|
||||||
|
QOpenGLFramebufferObject temp(d->colorAttachments[colorAttachmentIndex].size, fmt);
|
||||||
blitFramebuffer(&temp, rect, const_cast<QOpenGLFramebufferObject *>(this), rect,
|
blitFramebuffer(&temp, rect, const_cast<QOpenGLFramebufferObject *>(this), rect,
|
||||||
GL_COLOR_BUFFER_BIT, GL_NEAREST,
|
GL_COLOR_BUFFER_BIT, GL_NEAREST,
|
||||||
colorAttachmentIndex, 0);
|
colorAttachmentIndex, 0);
|
||||||
image = temp.toImage(flipped);
|
image = temp.toImage(flipped);
|
||||||
} else {
|
} else {
|
||||||
QOpenGLFramebufferObject temp(size(), QOpenGLFramebufferObjectFormat());
|
fmt.setInternalTextureFormat(d->colorAttachments[0].internalFormat);
|
||||||
|
QOpenGLFramebufferObject temp(size(), fmt);
|
||||||
blitFramebuffer(&temp, rect, const_cast<QOpenGLFramebufferObject *>(this), rect);
|
blitFramebuffer(&temp, rect, const_cast<QOpenGLFramebufferObject *>(this), rect);
|
||||||
image = temp.toImage(flipped);
|
image = temp.toImage(flipped);
|
||||||
}
|
}
|
||||||
|
@ -762,7 +762,7 @@ QPageSizePrivate::QPageSizePrivate(QPageSize::PageSizeId pageSizeId)
|
|||||||
m_windowsId(0),
|
m_windowsId(0),
|
||||||
m_units(QPageSize::Point)
|
m_units(QPageSize::Point)
|
||||||
{
|
{
|
||||||
if (pageSizeId >= QPageSize::PageSizeId(0) && pageSizeId <= QPageSize::LastPageSize)
|
if (unsigned(pageSizeId) <= unsigned(QPageSize::LastPageSize))
|
||||||
init(pageSizeId, QString());
|
init(pageSizeId, QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1478,7 +1478,7 @@ QRect QPageSize::rectPixels(int resolution) const
|
|||||||
|
|
||||||
QString QPageSize::key(PageSizeId pageSizeId)
|
QString QPageSize::key(PageSizeId pageSizeId)
|
||||||
{
|
{
|
||||||
if (pageSizeId < PageSizeId(0) || pageSizeId > LastPageSize)
|
if (unsigned(pageSizeId) > unsigned(LastPageSize))
|
||||||
return QString();
|
return QString();
|
||||||
return QString::fromUtf8(qt_pageSizes[pageSizeId].mediaOption);
|
return QString::fromUtf8(qt_pageSizes[pageSizeId].mediaOption);
|
||||||
}
|
}
|
||||||
@ -1497,7 +1497,7 @@ static QString msgImperialPageSizeInch(int width, int height)
|
|||||||
|
|
||||||
QString QPageSize::name(PageSizeId pageSizeId)
|
QString QPageSize::name(PageSizeId pageSizeId)
|
||||||
{
|
{
|
||||||
if (pageSizeId < PageSizeId(0) || pageSizeId > LastPageSize)
|
if (unsigned(pageSizeId) > unsigned(LastPageSize))
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
switch (pageSizeId) {
|
switch (pageSizeId) {
|
||||||
|
@ -352,8 +352,6 @@ QTransform QTransform::transposed() const
|
|||||||
QTransform t(affine._m11, affine._m21, affine._dx,
|
QTransform t(affine._m11, affine._m21, affine._dx,
|
||||||
affine._m12, affine._m22, affine._dy,
|
affine._m12, affine._m22, affine._dy,
|
||||||
m_13, m_23, m_33, true);
|
m_13, m_23, m_33, true);
|
||||||
t.m_type = m_type;
|
|
||||||
t.m_dirty = m_dirty;
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,8 +64,6 @@ HeaderSize entry_size(const QByteArray &name, const QByteArray &value)
|
|||||||
const unsigned sum = unsigned(name.size()) + value.size();
|
const unsigned sum = unsigned(name.size()) + value.size();
|
||||||
if (std::numeric_limits<unsigned>::max() - 32 < sum)
|
if (std::numeric_limits<unsigned>::max() - 32 < sum)
|
||||||
return HeaderSize();
|
return HeaderSize();
|
||||||
if (sum + 32 > std::numeric_limits<quint32>::max())
|
|
||||||
return HeaderSize();
|
|
||||||
return HeaderSize(true, quint32(sum + 32));
|
return HeaderSize(true, quint32(sum + 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ bool QNetmask::setAddress(const QHostAddress &address)
|
|||||||
int netmask = 0;
|
int netmask = 0;
|
||||||
quint8 *ptr = ip.v6;
|
quint8 *ptr = ip.v6;
|
||||||
quint8 *end;
|
quint8 *end;
|
||||||
length = -1;
|
length = 255;
|
||||||
|
|
||||||
if (address.protocol() == QAbstractSocket::IPv4Protocol) {
|
if (address.protocol() == QAbstractSocket::IPv4Protocol) {
|
||||||
ip.v4 = qToBigEndian(address.toIPv4Address());
|
ip.v4 = qToBigEndian(address.toIPv4Address());
|
||||||
|
@ -1005,7 +1005,7 @@ QSslConfiguration::NextProtocolNegotiationStatus QSslConfiguration::nextProtocol
|
|||||||
|
|
||||||
\list
|
\list
|
||||||
\li no local certificate and no private key
|
\li no local certificate and no private key
|
||||||
\li protocol SecureProtocols (meaning either TLS 1.0 or SSL 3 will be used)
|
\li protocol \l{QSsl::SecureProtocols}{SecureProtocols}
|
||||||
\li the system's default CA certificate list
|
\li the system's default CA certificate list
|
||||||
\li the cipher list equal to the list of the SSL libraries'
|
\li the cipher list equal to the list of the SSL libraries'
|
||||||
supported SSL ciphers that are 128 bits or more
|
supported SSL ciphers that are 128 bits or more
|
||||||
|
@ -278,6 +278,8 @@ QFunctionPointer QWindowsNativeInterface::platformFunction(const QByteArray &fun
|
|||||||
return QFunctionPointer(QWindowsWindow::setTouchWindowTouchTypeStatic);
|
return QFunctionPointer(QWindowsWindow::setTouchWindowTouchTypeStatic);
|
||||||
else if (function == QWindowsWindowFunctions::setHasBorderInFullScreenIdentifier())
|
else if (function == QWindowsWindowFunctions::setHasBorderInFullScreenIdentifier())
|
||||||
return QFunctionPointer(QWindowsWindow::setHasBorderInFullScreenStatic);
|
return QFunctionPointer(QWindowsWindow::setHasBorderInFullScreenStatic);
|
||||||
|
else if (function == QWindowsWindowFunctions::setWindowActivationBehaviorIdentifier())
|
||||||
|
return QFunctionPointer(QWindowsNativeInterface::setWindowActivationBehavior);
|
||||||
else if (function == QWindowsWindowFunctions::isTabletModeIdentifier())
|
else if (function == QWindowsWindowFunctions::isTabletModeIdentifier())
|
||||||
return QFunctionPointer(QWindowsNativeInterface::isTabletMode);
|
return QFunctionPointer(QWindowsNativeInterface::isTabletMode);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -2201,6 +2201,15 @@ void QWindowsWindow::requestActivateWindow()
|
|||||||
foregroundThread = GetWindowThreadProcessId(foregroundWindow, NULL);
|
foregroundThread = GetWindowThreadProcessId(foregroundWindow, NULL);
|
||||||
if (foregroundThread && foregroundThread != currentThread)
|
if (foregroundThread && foregroundThread != currentThread)
|
||||||
attached = AttachThreadInput(foregroundThread, currentThread, TRUE) == TRUE;
|
attached = AttachThreadInput(foregroundThread, currentThread, TRUE) == TRUE;
|
||||||
|
if (attached) {
|
||||||
|
if (!window()->flags().testFlag(Qt::WindowStaysOnBottomHint)
|
||||||
|
&& !window()->flags().testFlag(Qt::WindowStaysOnTopHint)
|
||||||
|
&& window()->type() != Qt::ToolTip) {
|
||||||
|
const UINT swpFlags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER;
|
||||||
|
SetWindowPos(m_data.hwnd, HWND_TOPMOST, 0, 0, 0, 0, swpFlags);
|
||||||
|
SetWindowPos(m_data.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, swpFlags);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetForegroundWindow(m_data.hwnd);
|
SetForegroundWindow(m_data.hwnd);
|
||||||
|
@ -1845,9 +1845,9 @@ bool QIBaseDriver::subscribeToNotification(const QString &name)
|
|||||||
eBuffer->bufferLength,
|
eBuffer->bufferLength,
|
||||||
eBuffer->eventBuffer,
|
eBuffer->eventBuffer,
|
||||||
#if defined (FB_API_VER) && FB_API_VER >= 20
|
#if defined (FB_API_VER) && FB_API_VER >= 20
|
||||||
(ISC_EVENT_CALLBACK)qEventCallback,
|
reinterpret_cast<ISC_EVENT_CALLBACK>(qEventCallback),
|
||||||
#else
|
#else
|
||||||
(isc_callback)qEventCallback,
|
reinterpret_cast<isc_callback>(qEventCallback),
|
||||||
#endif
|
#endif
|
||||||
eBuffer->resultBuffer);
|
eBuffer->resultBuffer);
|
||||||
|
|
||||||
@ -1925,9 +1925,9 @@ void QIBaseDriver::qHandleEventNotification(void *updatedResultBuffer)
|
|||||||
eBuffer->bufferLength,
|
eBuffer->bufferLength,
|
||||||
eBuffer->eventBuffer,
|
eBuffer->eventBuffer,
|
||||||
#if defined (FB_API_VER) && FB_API_VER >= 20
|
#if defined (FB_API_VER) && FB_API_VER >= 20
|
||||||
(ISC_EVENT_CALLBACK)qEventCallback,
|
reinterpret_cast<ISC_EVENT_CALLBACK>(qEventCallback),
|
||||||
#else
|
#else
|
||||||
(isc_callback)qEventCallback,
|
reinterpret_cast<isc_callback>(qEventCallback),
|
||||||
#endif
|
#endif
|
||||||
eBuffer->resultBuffer);
|
eBuffer->resultBuffer);
|
||||||
if (Q_UNLIKELY(status[0] == 1 && status[1])) {
|
if (Q_UNLIKELY(status[0] == 1 && status[1])) {
|
||||||
|
@ -1675,13 +1675,13 @@ QRectF QMacStylePrivate::comboboxEditBounds(const QRectF &outerBounds, const Coc
|
|||||||
} else if (cw.type == Button_PopupButton) {
|
} else if (cw.type == Button_PopupButton) {
|
||||||
switch (cw.size) {
|
switch (cw.size) {
|
||||||
case QStyleHelper::SizeLarge:
|
case QStyleHelper::SizeLarge:
|
||||||
ret.adjust(14, 1, -23, -4);
|
ret.adjust(10, 1, -23, -4);
|
||||||
break;
|
break;
|
||||||
case QStyleHelper::SizeSmall:
|
case QStyleHelper::SizeSmall:
|
||||||
ret.adjust(13, 4, -20, -3);
|
ret.adjust(10, 4, -20, -3);
|
||||||
break;
|
break;
|
||||||
case QStyleHelper::SizeMini:
|
case QStyleHelper::SizeMini:
|
||||||
ret.adjust(12, 0, -19, 0);
|
ret.adjust(9, 0, -19, 0);
|
||||||
ret.setHeight(13);
|
ret.setHeight(13);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -2826,7 +2826,8 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
|
|||||||
#if QT_CONFIG(toolbutton)
|
#if QT_CONFIG(toolbutton)
|
||||||
if (const QToolButton *tb = qobject_cast<const QToolButton *>(w)) {
|
if (const QToolButton *tb = qobject_cast<const QToolButton *>(w)) {
|
||||||
// When stroking the arrow, make sure it fits in the tool button
|
// When stroking the arrow, make sure it fits in the tool button
|
||||||
if (tb->arrowType() != Qt::NoArrow)
|
if (tb->arrowType() != Qt::NoArrow
|
||||||
|
|| tb->popupMode() == QToolButton::MenuButtonPopup)
|
||||||
halfSize -= penWidth;
|
halfSize -= penWidth;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -5865,11 +5866,11 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
|
|||||||
#endif
|
#endif
|
||||||
case CC_ToolButton:
|
case CC_ToolButton:
|
||||||
ret = QCommonStyle::subControlRect(cc, opt, sc, widget);
|
ret = QCommonStyle::subControlRect(cc, opt, sc, widget);
|
||||||
if (sc == SC_ToolButtonMenu
|
if (sc == SC_ToolButtonMenu) {
|
||||||
#ifndef QT_NO_ACCESSIBILITY
|
#ifndef QT_NO_ACCESSIBILITY
|
||||||
&& !QStyleHelper::hasAncestor(opt->styleObject, QAccessible::ToolBar)
|
if (QStyleHelper::hasAncestor(opt->styleObject, QAccessible::ToolBar))
|
||||||
|
ret.adjust(-toolButtonArrowMargin, 0, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
) {
|
|
||||||
ret.adjust(-1, 0, 0, 0);
|
ret.adjust(-1, 0, 0, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -6107,6 +6108,9 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
|
|||||||
case CT_ToolButton:
|
case CT_ToolButton:
|
||||||
sz.rwidth() += 10;
|
sz.rwidth() += 10;
|
||||||
sz.rheight() += 10;
|
sz.rheight() += 10;
|
||||||
|
if (const auto *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt))
|
||||||
|
if (tb->features & QStyleOptionToolButton::Menu)
|
||||||
|
sz.rwidth() += toolButtonArrowMargin;
|
||||||
return sz;
|
return sz;
|
||||||
case CT_ComboBox:
|
case CT_ComboBox:
|
||||||
if (const auto *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
|
if (const auto *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
|
||||||
|
@ -139,7 +139,7 @@ static const int NumEntries = sizeof(entries) / sizeof(entries[0]);
|
|||||||
*/
|
*/
|
||||||
const char * QTest::benchmarkMetricName(QBenchmarkMetric metric)
|
const char * QTest::benchmarkMetricName(QBenchmarkMetric metric)
|
||||||
{
|
{
|
||||||
if (metric >= 0 && metric < QTest::NumEntries)
|
if (unsigned(metric) < unsigned(QTest::NumEntries))
|
||||||
return entries[metric].name;
|
return entries[metric].name;
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
@ -151,7 +151,7 @@ const char * QTest::benchmarkMetricName(QBenchmarkMetric metric)
|
|||||||
*/
|
*/
|
||||||
const char * QTest::benchmarkMetricUnit(QBenchmarkMetric metric)
|
const char * QTest::benchmarkMetricUnit(QBenchmarkMetric metric)
|
||||||
{
|
{
|
||||||
if (metric >= 0 && metric < QTest::NumEntries)
|
if (unsigned(metric) < unsigned(QTest::NumEntries))
|
||||||
return entries[metric].unit;
|
return entries[metric].unit;
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
@ -162,6 +162,7 @@
|
|||||||
#if QT_CONFIG(lineedit)
|
#if QT_CONFIG(lineedit)
|
||||||
#include "QtWidgets/qlineedit.h"
|
#include "QtWidgets/qlineedit.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "QtCore/qdir.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
@ -619,6 +619,8 @@ void QAbstractSpinBox::stepDown()
|
|||||||
function. Note that this function is called even if the resulting
|
function. Note that this function is called even if the resulting
|
||||||
value will be outside the bounds of minimum and maximum. It's this
|
value will be outside the bounds of minimum and maximum. It's this
|
||||||
function's job to handle these situations.
|
function's job to handle these situations.
|
||||||
|
|
||||||
|
\sa stepUp(), stepDown(), keyPressEvent()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void QAbstractSpinBox::stepBy(int steps)
|
void QAbstractSpinBox::stepBy(int steps)
|
||||||
@ -970,6 +972,8 @@ void QAbstractSpinBox::paintEvent(QPaintEvent *)
|
|||||||
\row \li Page down
|
\row \li Page down
|
||||||
\li This will invoke stepBy(-10)
|
\li This will invoke stepBy(-10)
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
|
\sa stepBy()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -1005,7 +1005,7 @@ Qt::DayOfWeek QCalendarModel::dayOfWeekForColumn(int column) const
|
|||||||
|
|
||||||
int QCalendarModel::columnForDayOfWeek(Qt::DayOfWeek day) const
|
int QCalendarModel::columnForDayOfWeek(Qt::DayOfWeek day) const
|
||||||
{
|
{
|
||||||
if (day < 1 || day > 7)
|
if (day < 1 || unsigned(day) > unsigned(7))
|
||||||
return -1;
|
return -1;
|
||||||
int column = (int)day - (int)m_firstDay;
|
int column = (int)day - (int)m_firstDay;
|
||||||
if (column < 0)
|
if (column < 0)
|
||||||
|
4594
tests/auto/bic/data/QtConcurrent.5.11.0.linux-gcc-amd64.txt
Normal file
4594
tests/auto/bic/data/QtConcurrent.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
4542
tests/auto/bic/data/QtCore.5.11.0.linux-gcc-amd64.txt
Normal file
4542
tests/auto/bic/data/QtCore.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
4881
tests/auto/bic/data/QtDBus.5.11.0.linux-gcc-amd64.txt
Normal file
4881
tests/auto/bic/data/QtDBus.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
8357
tests/auto/bic/data/QtGui.5.11.0.linux-gcc-amd64.txt
Normal file
8357
tests/auto/bic/data/QtGui.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
5379
tests/auto/bic/data/QtNetwork.5.11.0.linux-gcc-amd64.txt
Normal file
5379
tests/auto/bic/data/QtNetwork.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
19376
tests/auto/bic/data/QtOpenGL.5.11.0.linux-gcc-amd64.txt
Normal file
19376
tests/auto/bic/data/QtOpenGL.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
19627
tests/auto/bic/data/QtPrintSupport.5.11.0.linux-gcc-amd64.txt
Normal file
19627
tests/auto/bic/data/QtPrintSupport.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
4969
tests/auto/bic/data/QtSql.5.11.0.linux-gcc-amd64.txt
Normal file
4969
tests/auto/bic/data/QtSql.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
4639
tests/auto/bic/data/QtTest.5.11.0.linux-gcc-amd64.txt
Normal file
4639
tests/auto/bic/data/QtTest.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
19126
tests/auto/bic/data/QtWidgets.5.11.0.linux-gcc-amd64.txt
Normal file
19126
tests/auto/bic/data/QtWidgets.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
4982
tests/auto/bic/data/QtXml.5.11.0.linux-gcc-amd64.txt
Normal file
4982
tests/auto/bic/data/QtXml.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -49,6 +49,8 @@ private slots:
|
|||||||
void matrix();
|
void matrix();
|
||||||
void testOffset();
|
void testOffset();
|
||||||
void types();
|
void types();
|
||||||
|
void types2_data();
|
||||||
|
void types2();
|
||||||
void scalarOps();
|
void scalarOps();
|
||||||
void transform();
|
void transform();
|
||||||
void mapEmptyPath();
|
void mapEmptyPath();
|
||||||
@ -65,6 +67,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QTransform)
|
Q_DECLARE_METATYPE(QTransform)
|
||||||
|
Q_DECLARE_METATYPE(QTransform::TransformationType)
|
||||||
|
|
||||||
void tst_QTransform::mapRect_data()
|
void tst_QTransform::mapRect_data()
|
||||||
{
|
{
|
||||||
@ -568,6 +571,38 @@ void tst_QTransform::types()
|
|||||||
QCOMPARE(m5.type(), QTransform::TxScale);
|
QCOMPARE(m5.type(), QTransform::TxScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QTransform::types2_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<QTransform>("t1");
|
||||||
|
QTest::addColumn<QTransform::TransformationType>("type");
|
||||||
|
|
||||||
|
QTest::newRow( "identity" ) << QTransform() << QTransform::TxNone;
|
||||||
|
QTest::newRow( "translate" ) << QTransform().translate(10, -0.1) << QTransform::TxTranslate;
|
||||||
|
QTest::newRow( "scale" ) << QTransform().scale(10, -0.1) << QTransform::TxScale;
|
||||||
|
QTest::newRow( "rotate" ) << QTransform().rotate(10) << QTransform::TxRotate;
|
||||||
|
QTest::newRow( "shear" ) << QTransform().shear(10, -0.1) << QTransform::TxShear;
|
||||||
|
QTest::newRow( "project" ) << QTransform().rotate(10, Qt::XAxis) << QTransform::TxProject;
|
||||||
|
QTest::newRow( "combined" ) << QTransform().translate(10, -0.1).scale(10, -0.1).rotate(10, Qt::YAxis) << QTransform::TxProject;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QTransform::types2()
|
||||||
|
{
|
||||||
|
#define CHECKTXTYPE(func) { QTransform t2(func); \
|
||||||
|
QTransform t3(t2.m11(), t2.m12(), t2.m13(), t2.m21(), t2.m22(), t2.m23(), t2.m31(), t2.m32(), t2.m33()); \
|
||||||
|
QVERIFY2(t3.type() == t2.type(), #func); \
|
||||||
|
}
|
||||||
|
|
||||||
|
QFETCH( QTransform, t1 );
|
||||||
|
QFETCH( QTransform::TransformationType, type );
|
||||||
|
|
||||||
|
Q_ASSERT(t1.type() == type);
|
||||||
|
|
||||||
|
CHECKTXTYPE(t1.adjoint());
|
||||||
|
CHECKTXTYPE(t1.inverted());
|
||||||
|
CHECKTXTYPE(t1.transposed());
|
||||||
|
|
||||||
|
#undef CHECKTXTYPE
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QTransform::scalarOps()
|
void tst_QTransform::scalarOps()
|
||||||
{
|
{
|
||||||
|
@ -39,6 +39,10 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#ifndef GL_RGB10
|
||||||
|
#define GL_RGB10 0x8052
|
||||||
|
#endif
|
||||||
|
|
||||||
class tst_Lancelot : public QObject
|
class tst_Lancelot : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -85,6 +89,8 @@ private slots:
|
|||||||
#ifndef QT_NO_OPENGL
|
#ifndef QT_NO_OPENGL
|
||||||
void testOpenGL_data();
|
void testOpenGL_data();
|
||||||
void testOpenGL();
|
void testOpenGL();
|
||||||
|
void testOpenGLBGR30_data();
|
||||||
|
void testOpenGLBGR30();
|
||||||
void testCoreOpenGL_data();
|
void testCoreOpenGL_data();
|
||||||
void testCoreOpenGL();
|
void testCoreOpenGL();
|
||||||
private:
|
private:
|
||||||
@ -279,6 +285,16 @@ void tst_Lancelot::testOpenGL()
|
|||||||
runTestSuite(OpenGL, QImage::Format_RGB32);
|
runTestSuite(OpenGL, QImage::Format_RGB32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_Lancelot::testOpenGLBGR30_data()
|
||||||
|
{
|
||||||
|
tst_Lancelot::testOpenGL_data();
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_Lancelot::testOpenGLBGR30()
|
||||||
|
{
|
||||||
|
runTestSuite(OpenGL, QImage::Format_BGR30);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_Lancelot::testCoreOpenGL_data()
|
void tst_Lancelot::testCoreOpenGL_data()
|
||||||
{
|
{
|
||||||
if (!checkSystemCoreGLSupport())
|
if (!checkSystemCoreGLSupport())
|
||||||
@ -329,6 +345,8 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co
|
|||||||
QOpenGLFramebufferObjectFormat fmt;
|
QOpenGLFramebufferObjectFormat fmt;
|
||||||
fmt.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
|
fmt.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
|
||||||
fmt.setSamples(4);
|
fmt.setSamples(4);
|
||||||
|
if (format == QImage::Format_BGR30)
|
||||||
|
fmt.setInternalTextureFormat(GL_RGB10);
|
||||||
QOpenGLContext ctx;
|
QOpenGLContext ctx;
|
||||||
ctx.setFormat(contextFormat);
|
ctx.setFormat(contextFormat);
|
||||||
QVERIFY(ctx.create());
|
QVERIFY(ctx.create());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user