QtGui: Pass types with copy-ctor or dtor by const-ref

... except if the function is a ctor, callers pass rvalues,
and the type has a fast move ctor. In that case, keep passing
by-value and qMove() into place.

Change-Id: I2c0be7d4436327834ddee0531c51c5af352ac74c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Sérgio Martins 2015-07-16 22:17:47 +01:00
parent aa2efdfa97
commit 1236b1827c
8 changed files with 13 additions and 13 deletions

View File

@ -61,7 +61,7 @@ class QStandardItemData
{
public:
inline QStandardItemData() : role(-1) {}
inline QStandardItemData(int r, QVariant v) : role(r), value(v) {}
inline QStandardItemData(int r, const QVariant &v) : role(r), value(v) {}
int role;
QVariant value;
inline bool operator==(const QStandardItemData &other) const { return role == other.role && value == other.value; }

View File

@ -522,7 +522,7 @@ public:
};
class Attribute {
public:
Attribute(AttributeType t, int s, int l, QVariant val) : type(t), start(s), length(l), value(val) {}
Attribute(AttributeType t, int s, int l, QVariant val) : type(t), start(s), length(l), value(qMove(val)) {}
AttributeType type;
int start;

View File

@ -82,7 +82,7 @@ public:
QLocale locale() const;
Qt::LayoutDirection inputDirection() const;
static QVariant queryFocusObject(Qt::InputMethodQuery query, QVariant argument);
static QVariant queryFocusObject(Qt::InputMethodQuery query, QVariant argument); // ### Qt 6: QVariant by const-ref
public Q_SLOTS:
void show();

View File

@ -59,7 +59,7 @@ class QOpenGL2GradientCache : public QOpenGLSharedResource
struct CacheInfo
{
inline CacheInfo(QGradientStops s, qreal op, QGradient::InterpolationMode mode) :
stops(s), opacity(op), interpolationMode(mode) {}
stops(qMove(s)), opacity(op), interpolationMode(mode) {}
GLuint texId;
QGradientStops stops;

View File

@ -4132,7 +4132,7 @@ class QGradientCache
struct CacheInfo
{
inline CacheInfo(QGradientStops s, int op, QGradient::InterpolationMode mode) :
stops(s), opacity(op), interpolationMode(mode) {}
stops(qMove(s)), opacity(op), interpolationMode(mode) {}
QRgba64 buffer[GRADIENT_STOPTABLE_SIZE];
QGradientStops stops;
int opacity;

View File

@ -467,9 +467,9 @@ public:
void drawFlow(const QPointF &offset, QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &context,
QTextFrame::Iterator it, const QList<QTextFrame *> &floats, QTextBlock *cursorBlockNeedingRepaint) const;
void drawBlock(const QPointF &offset, QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &context,
QTextBlock bl, bool inRootFrame) const;
const QTextBlock &bl, bool inRootFrame) const;
void drawListItem(const QPointF &offset, QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &context,
QTextBlock bl, const QTextCharFormat *selectionFormat) const;
const QTextBlock &bl, const QTextCharFormat *selectionFormat) const;
void drawTableCell(const QRectF &cellRect, QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &cell_context,
QTextTable *table, QTextTableData *td, int r, int c,
QTextBlock *cursorBlockNeedingRepaint, QPointF *cursorBlockOffset) const;
@ -487,7 +487,7 @@ public:
HitPoint hitTest(QTextFrame::Iterator it, HitPoint hit, const QFixedPoint &p,
int *position, QTextLayout **l, Qt::HitTestAccuracy accuracy) const;
HitPoint hitTest(QTextTable *table, const QFixedPoint &point, int *position, QTextLayout **l, Qt::HitTestAccuracy accuracy) const;
HitPoint hitTest(QTextBlock bl, const QFixedPoint &point, int *position, QTextLayout **l, Qt::HitTestAccuracy accuracy) const;
HitPoint hitTest(const QTextBlock &bl, const QFixedPoint &point, int *position, QTextLayout **l, Qt::HitTestAccuracy accuracy) const;
QTextLayoutStruct layoutCell(QTextTable *t, const QTextTableCell &cell, QFixed width,
int layoutFrom, int layoutTo, QTextTableData *tableData, QFixed absoluteTableY,
@ -749,7 +749,7 @@ QTextDocumentLayoutPrivate::hitTest(QTextTable *table, const QFixedPoint &point,
}
QTextDocumentLayoutPrivate::HitPoint
QTextDocumentLayoutPrivate::hitTest(QTextBlock bl, const QFixedPoint &point, int *position, QTextLayout **l,
QTextDocumentLayoutPrivate::hitTest(const QTextBlock &bl, const QFixedPoint &point, int *position, QTextLayout **l,
Qt::HitTestAccuracy accuracy) const
{
QTextLayout *tl = bl.layout();
@ -1285,7 +1285,7 @@ void QTextDocumentLayoutPrivate::drawFlow(const QPointF &offset, QPainter *paint
void QTextDocumentLayoutPrivate::drawBlock(const QPointF &offset, QPainter *painter,
const QAbstractTextDocumentLayout::PaintContext &context,
QTextBlock bl, bool inRootFrame) const
const QTextBlock &bl, bool inRootFrame) const
{
const QTextLayout *tl = bl.layout();
QRectF r = tl->boundingRect();
@ -1379,7 +1379,7 @@ void QTextDocumentLayoutPrivate::drawBlock(const QPointF &offset, QPainter *pain
void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *painter,
const QAbstractTextDocumentLayout::PaintContext &context,
QTextBlock bl, const QTextCharFormat *selectionFormat) const
const QTextBlock &bl, const QTextCharFormat *selectionFormat) const
{
Q_Q(const QTextDocumentLayout);
const QTextBlockFormat blockFormat = bl.blockFormat();

View File

@ -396,7 +396,7 @@ void QTextOdfWriter::writeInlineCharacter(QXmlStreamWriter &writer, const QTextF
writer.writeEndElement(); // frame
}
void QTextOdfWriter::writeFormats(QXmlStreamWriter &writer, QSet<int> formats) const
void QTextOdfWriter::writeFormats(QXmlStreamWriter &writer, const QSet<int> &formats) const
{
writer.writeStartElement(officeNS, QString::fromLatin1("automatic-styles"));
QVector<QTextFormat> allStyles = m_document->allFormats();

View File

@ -83,7 +83,7 @@ public:
bool createArchive() const { return m_createArchive; }
void writeBlock(QXmlStreamWriter &writer, const QTextBlock &block);
void writeFormats(QXmlStreamWriter &writer, QSet<int> formatIds) const;
void writeFormats(QXmlStreamWriter &writer, const QSet<int> &formatIds) const;
void writeBlockFormat(QXmlStreamWriter &writer, QTextBlockFormat format, int formatIndex) const;
void writeCharacterFormat(QXmlStreamWriter &writer, QTextCharFormat format, int formatIndex) const;
void writeListFormat(QXmlStreamWriter &writer, QTextListFormat format, int formatIndex) const;