Mark some methods in test code as overrides

CustomTextWidgetIface marked its text() method as an override;
DropOnOddRows marked its canDropMimeData() as an override; each
neglected some other methods that are overrides.  Convert
Q_DECL_OVERRIDE to the keyword in affected classes, to match.

Change-Id: I78b38e20a81e3e6aab282a1cb3d70cdf8a5f4135
Reviewed-by: Alexander Volkov <a.volkov@rusbitech.ru>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
This commit is contained in:
Edward Welbourne 2016-12-02 18:14:45 +01:00 committed by Frederik Gladhorn
parent ee84af00d1
commit c587036dc6
2 changed files with 22 additions and 21 deletions

View File

@ -3994,21 +3994,21 @@ class DropOnOddRows : public QAbstractListModel
public:
DropOnOddRows(QObject *parent = 0) : QAbstractListModel(parent) {}
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override
{
if (role == Qt::DisplayRole)
return (index.row() % 2 == 0) ? "A" : "B";
return QVariant();
}
int rowCount(const QModelIndex &parent = QModelIndex()) const
int rowCount(const QModelIndex &parent = QModelIndex()) const override
{
Q_UNUSED(parent);
return 10;
}
bool canDropMimeData(const QMimeData *, Qt::DropAction,
int row, int column, const QModelIndex &parent) const Q_DECL_OVERRIDE
int row, int column, const QModelIndex &parent) const override
{
Q_UNUSED(row);
Q_UNUSED(column);

View File

@ -98,53 +98,54 @@ public:
return 0;
}
CustomTextWidgetIface(CustomTextWidget *w): QAccessibleWidget(w) {}
void *interface_cast(QAccessible::InterfaceType t) {
void *interface_cast(QAccessible::InterfaceType t) override
{
if (t == QAccessible::TextInterface)
return static_cast<QAccessibleTextInterface*>(this);
return 0;
}
// this is mostly to test the base implementation for textBefore/At/After
QString text(QAccessible::Text t) const Q_DECL_OVERRIDE
QString text(QAccessible::Text t) const override
{
if (t == QAccessible::Value)
return textWidget()->text;
return QAccessibleWidget::text(t);
}
QString textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const
QString textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const override
{
if (offset == -2)
offset = textWidget()->cursorPosition;
return QAccessibleTextInterface::textBeforeOffset(offset, boundaryType, startOffset, endOffset);
}
QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const
QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const override
{
if (offset == -2)
offset = textWidget()->cursorPosition;
return QAccessibleTextInterface::textAtOffset(offset, boundaryType, startOffset, endOffset);
}
QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const
QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const override
{
if (offset == -2)
offset = textWidget()->cursorPosition;
return QAccessibleTextInterface::textAfterOffset(offset, boundaryType, startOffset, endOffset);
}
void selection(int, int *startOffset, int *endOffset) const Q_DECL_OVERRIDE
void selection(int, int *startOffset, int *endOffset) const override
{ *startOffset = *endOffset = -1; }
int selectionCount() const Q_DECL_OVERRIDE { return 0; }
void addSelection(int, int) Q_DECL_OVERRIDE {}
void removeSelection(int) Q_DECL_OVERRIDE {}
void setSelection(int, int, int) Q_DECL_OVERRIDE {}
int cursorPosition() const Q_DECL_OVERRIDE { return textWidget()->cursorPosition; }
void setCursorPosition(int position) Q_DECL_OVERRIDE { textWidget()->cursorPosition = position; }
QString text(int startOffset, int endOffset) const Q_DECL_OVERRIDE { return textWidget()->text.mid(startOffset, endOffset); }
int characterCount() const Q_DECL_OVERRIDE { return textWidget()->text.length(); }
QRect characterRect(int) const Q_DECL_OVERRIDE { return QRect(); }
int offsetAtPoint(const QPoint &) const Q_DECL_OVERRIDE { return 0; }
void scrollToSubstring(int, int) Q_DECL_OVERRIDE {}
QString attributes(int, int *, int *) const Q_DECL_OVERRIDE
int selectionCount() const override { return 0; }
void addSelection(int, int) override {}
void removeSelection(int) override {}
void setSelection(int, int, int) override {}
int cursorPosition() const override { return textWidget()->cursorPosition; }
void setCursorPosition(int position) override { textWidget()->cursorPosition = position; }
QString text(int startOffset, int endOffset) const override { return textWidget()->text.mid(startOffset, endOffset); }
int characterCount() const override { return textWidget()->text.length(); }
QRect characterRect(int) const override { return QRect(); }
int offsetAtPoint(const QPoint &) const override { return 0; }
void scrollToSubstring(int, int) override {}
QString attributes(int, int *, int *) const override
{ return QString(); }
private: