Skip to content

Commit

Permalink
KDDateTime: added conversion operator to QVariant
Browse files Browse the repository at this point in the history
This prevents implicit conversion to base QDateTime and loss of
time-zone information when passing the value as QVariant.

Fixes KDAB#123.
  • Loading branch information
rokm committed Mar 13, 2019
1 parent 15522c0 commit 5f73004
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/CHANGES_1_8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Client-side:
* Rename the missing KDSoapJob::returnHeaders() to KDSoapJob::replyHeaders(), and provide an implementation
* Make KDSoapClientInterface::soapVersion() const
* Add lastFaultCode() for error handling after sync calls. Same as lastErrorCode() but it returns a QString rather than an int.
* Add conversion operator from KDDateTime to QVariant to void implicit conversion to base QDateTime (github issue #123).

Server-side:
============
Expand Down
5 changes: 5 additions & 0 deletions src/KDSoapClient/KDDateTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ KDDateTime::~KDDateTime()
{
}

KDDateTime::operator QVariant() const
{
return QVariant::fromValue(*this);
}

QString KDDateTime::timeZone() const
{
return d->mTimeZone;
Expand Down
7 changes: 7 additions & 0 deletions src/KDSoapClient/KDDateTime.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ class KDSOAP_EXPORT KDDateTime : public QDateTime
KDDateTime &operator=(const KDDateTime &);
~KDDateTime();

/**
* Converts the KDDateTime to QVariant, to avoid implicit conversion
* to base QDateTime.
* \since 1.8
*/
operator QVariant() const;

/**
* Returns the time zone set by setTimeZone.
*/
Expand Down

0 comments on commit 5f73004

Please sign in to comment.