Change examples and snippets to pass QDate and QTime by value

They're value types, so we should show them being used as such.

Change-Id: If9f0c366fac66306b7861f04e2f047540d444acc
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This commit is contained in:
Edward Welbourne 2020-01-23 18:21:58 +01:00
parent 45967dfbd8
commit 2130d282b1
8 changed files with 22 additions and 21 deletions

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the demonstration applications of the Qt Toolkit.
@ -198,7 +198,7 @@ private slots:
public slots:
void request(const QString &flightCode, const QDate &date) {
void request(const QString &flightCode, QDate date) {
setWindowTitle("Loading...");

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the demonstration applications of the Qt Toolkit.
@ -71,7 +71,7 @@ QVariant addGenre(QSqlQuery &q, const QString &name)
return q.lastInsertId();
}
QVariant addAuthor(QSqlQuery &q, const QString &name, const QDate &birthdate)
QVariant addAuthor(QSqlQuery &q, const QString &name, QDate birthdate)
{
q.addBindValue(name);
q.addBindValue(birthdate);

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@ -60,7 +60,7 @@ MySortFilterProxyModel::MySortFilterProxyModel(QObject *parent)
//! [0]
//! [1]
void MySortFilterProxyModel::setFilterMinimumDate(const QDate &date)
void MySortFilterProxyModel::setFilterMinimumDate(QDate date)
{
minDate = date;
invalidateFilter();
@ -68,7 +68,7 @@ void MySortFilterProxyModel::setFilterMinimumDate(const QDate &date)
//! [1]
//! [2]
void MySortFilterProxyModel::setFilterMaximumDate(const QDate &date)
void MySortFilterProxyModel::setFilterMaximumDate(QDate date)
{
maxDate = date;
invalidateFilter();
@ -122,7 +122,7 @@ bool MySortFilterProxyModel::lessThan(const QModelIndex &left,
//! [5] //! [6]
//! [7]
bool MySortFilterProxyModel::dateInRange(const QDate &date) const
bool MySortFilterProxyModel::dateInRange(QDate date) const
{
return (!minDate.isValid() || date > minDate)
&& (!maxDate.isValid() || date < maxDate);

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@ -63,17 +63,17 @@ public:
MySortFilterProxyModel(QObject *parent = 0);
QDate filterMinimumDate() const { return minDate; }
void setFilterMinimumDate(const QDate &date);
void setFilterMinimumDate(QDate date);
QDate filterMaximumDate() const { return maxDate; }
void setFilterMaximumDate(const QDate &date);
void setFilterMaximumDate(QDate date);
protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
private:
bool dateInRange(const QDate &date) const;
bool dateInRange(QDate date) const;
QDate minDate;
QDate maxDate;

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@ -126,7 +126,7 @@ void Window::selectedDateChanged()
//! [2]
//! [3]
void Window::minimumDateChanged(const QDate &date)
void Window::minimumDateChanged(QDate date)
{
calendar->setMinimumDate(date);
maximumDateEdit->setDate(calendar->maximumDate());
@ -134,7 +134,7 @@ void Window::minimumDateChanged(const QDate &date)
//! [3]
//! [4]
void Window::maximumDateChanged(const QDate &date)
void Window::maximumDateChanged(QDate date)
{
calendar->setMaximumDate(date);
minimumDateEdit->setDate(calendar->minimumDate());

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@ -52,6 +52,7 @@
#define WINDOW_H
#include <QWidget>
#include <QDateTime>
QT_BEGIN_NAMESPACE
class QCalendarWidget;
@ -79,8 +80,8 @@ private slots:
void horizontalHeaderChanged(int index);
void verticalHeaderChanged(int index);
void selectedDateChanged();
void minimumDateChanged(const QDate &date);
void maximumDateChanged(const QDate &date);
void minimumDateChanged(QDate date);
void maximumDateChanged(QDate date);
void weekdayFormatChanged();
void weekendFormatChanged();
void reformatHeaders();

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@ -151,7 +151,7 @@ class Employee
{
public:
Employee() {}
Employee(const QString &name, const QDate &dateOfBirth);
Employee(const QString &name, QDate dateOfBirth);
...
private:

View File

@ -151,7 +151,7 @@ class Employee
{
public:
Employee() {}
Employee(const QString &name, const QDate &dateOfBirth);
Employee(const QString &name, QDate dateOfBirth);
...
private: