Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Internal/TargetConfig.pri
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ isEmpty(QTNPROPERTY_BIN) {

DESTDIR = $$QTNPROPERTY_BIN

CONFIG += c++11
CONFIG += c++17

msvc {
DEFINES += _CRT_SECURE_NO_WARNINGS
Expand Down
1 change: 1 addition & 0 deletions QtnProperty/Auxiliary/PropertyAux.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ enum QtnPropertyChangeReasonFlag
QtnPropertyChangeReasonMultiEdit = 0x1000,
QtnPropertyChangeReasonLockToggled = 0x2000,
QtnPropertyChangeReasonUpdateDelegate = 0x4000,
QtnPropertyChangeReasonNewAttribute = 0x8000,
QtnPropertyChangeReasonState = QtnPropertyChangeReasonStateLocal |
QtnPropertyChangeReasonStateInherited,
QtnPropertyChangeReasonChildren = QtnPropertyChangeReasonChildPropertyAdd |
Expand Down
2 changes: 1 addition & 1 deletion QtnProperty/Auxiliary/PropertyTemplates.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class QtnSinglePropertyBase : public QtnProperty

virtual bool toVariantImpl(QVariant &var) const override
{
var.setValue<ValueTypeStore>(value());
var.setValue(value());
return var.isValid();
}

Expand Down
11 changes: 7 additions & 4 deletions QtnProperty/Core/PropertyEnumFlags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.
*******************************************************************************/

#include "PropertyEnumFlags.h"
#include <QRegularExpression>

QtnPropertyEnumFlagsBase::QtnPropertyEnumFlagsBase(QObject *parent)
: QtnSinglePropertyBase<QtnEnumFlagsValueType>(parent)
Expand All @@ -34,12 +35,13 @@ bool QtnPropertyEnumFlagsBase::fromStrImpl(

if (!enumStr.isEmpty() && enumStr != "0")
{
static QRegExp parserEnumFlags(
QStringLiteral("^\\s*([^|\\s]+)\\s*\\|(.+)$"), Qt::CaseInsensitive);
static QRegularExpression parserEnumFlags(
QStringLiteral("^\\s*([^|\\s]+)\\s*\\|(.+)$"), QRegularExpression::CaseInsensitiveOption);

while (parserEnumFlags.exactMatch(enumStr))
QRegularExpressionMatch match = parserEnumFlags.match(enumStr);
while (match.hasMatch())
{
QStringList params = parserEnumFlags.capturedTexts();
QStringList params = match.capturedTexts();

if (params.size() != 3)
return false;
Expand All @@ -52,6 +54,7 @@ bool QtnPropertyEnumFlagsBase::fromStrImpl(
val = val | enumValue->value();

enumStr = params[2];
match = parserEnumFlags.match(enumStr);
}

const QtnEnumValueInfo *enumValue = m_enumInfo->fromStr(enumStr);
Expand Down
19 changes: 11 additions & 8 deletions QtnProperty/Core/PropertyQPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.
*******************************************************************************/

#include "PropertyQPoint.h"
#include <QRegularExpression>

QtnPropertyQPointBase::QtnPropertyQPointBase(QObject *parent)
: ParentClass(parent)
Expand All @@ -39,24 +40,26 @@ QtnProperty *QtnPropertyQPointBase::createYProperty()
bool QtnPropertyQPointBase::fromStrImpl(
const QString &str, QtnPropertyChangeReason reason)
{
static QRegExp parserPoint(
"^\\s*QPoint\\s*\\(([^\\)]+)\\)\\s*$", Qt::CaseInsensitive);
static QRegularExpression parserPoint(
"^\\s*QPoint\\s*\\(([^\\)]+)\\)\\s*$", QRegularExpression::CaseInsensitiveOption);

if (!parserPoint.exactMatch(str))
QRegularExpressionMatch match = parserPoint.match(str);
if (!match.hasMatch())
return false;

QStringList params = parserPoint.capturedTexts();
QStringList params = match.capturedTexts();

if (params.size() != 2)
return false;

static QRegExp parserParams(
"^\\s*(-?\\d+)\\s*,\\s*(-?\\d+)\\s*$", Qt::CaseInsensitive);
static QRegularExpression parserParams(
"^\\s*(-?\\d+)\\s*,\\s*(-?\\d+)\\s*$", QRegularExpression::CaseInsensitiveOption);

if (!parserParams.exactMatch(params[1]))
match = parserPoint.match(params[1]);
if (!match.hasMatch())
return false;

params = parserParams.capturedTexts();
params = match.capturedTexts();

if (params.size() != 3)
return false;
Expand Down
20 changes: 11 additions & 9 deletions QtnProperty/Core/PropertyQPointF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ limitations under the License.
*******************************************************************************/

#include "PropertyQPointF.h"

#include "PropertyQPoint.h"
#include <QRegularExpression>

QtnPropertyQPointFBase::QtnPropertyQPointFBase(QObject *parent)
: ParentClass(parent)
Expand Down Expand Up @@ -59,26 +59,28 @@ QString QtnPropertyQPointFBase::getYDescriptionFormat() const
bool QtnPropertyQPointFBase::fromStrImpl(
const QString &str, QtnPropertyChangeReason reason)
{
static QRegExp parserPoint(
static QRegularExpression parserPoint(
QLatin1String("^\\s*QPointF\\s*\\(([^\\)]+)\\)\\s*$"),
Qt::CaseInsensitive);
QRegularExpression::CaseInsensitiveOption);

if (!parserPoint.exactMatch(str))
QRegularExpressionMatch match = parserPoint.match(str);
if (!match.hasMatch())
return false;

QStringList params = parserPoint.capturedTexts();
QStringList params = match.capturedTexts();

if (params.size() != 2)
return false;

static QRegExp parserParams(
static QRegularExpression parserParams(
"^\\s*(\\-?\\d+(\\.\\d{0,})?)\\s*,\\s*(\\-?\\d+(\\.\\d{0,})?)\\s*$",
Qt::CaseInsensitive);
QRegularExpression::CaseInsensitiveOption);

if (!parserParams.exactMatch(params[1]))
match = parserPoint.match(params[1]);
if (!match.hasMatch())
return false;

params = parserParams.capturedTexts();
params = match.capturedTexts();

if (params.size() != 5)
return false;
Expand Down
23 changes: 13 additions & 10 deletions QtnProperty/Core/PropertyQRect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ limitations under the License.
*******************************************************************************/

#include "PropertyQRect.h"

#include "PropertyQSize.h"
#include <QRegularExpression>

QtnProperty *QtnPropertyQRectBase::createLeftProperty(bool move)
{
Expand Down Expand Up @@ -82,23 +82,26 @@ QtnPropertyQRectBase::QtnPropertyQRectBase(QObject *parent)
bool QtnPropertyQRectBase::fromStrImpl(
const QString &str, QtnPropertyChangeReason reason)
{
static QRegExp parserRect(
"^\\s*QRect\\s*\\(([^\\)]+)\\)\\s*$", Qt::CaseInsensitive);
static QRegExp parserParams(
"^\\s*(-?\\d+)\\s*,\\s*(-?\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*$",
Qt::CaseInsensitive);
static QRegularExpression parserRect(
"^\\s*QRect\\s*\\(([^\\)]+)\\)\\s*$", QRegularExpression::CaseInsensitiveOption);

if (!parserRect.exactMatch(str))
QRegularExpressionMatch match = parserRect.match(str);
if (!match.hasMatch())
return false;

QStringList params = parserRect.capturedTexts();
QStringList params = match.capturedTexts();
if (params.size() != 2)
return false;

if (!parserParams.exactMatch(params[1]))
static QRegularExpression parserParams(
"^\\s*(-?\\d+)\\s*,\\s*(-?\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*$",
QRegularExpression::CaseInsensitiveOption);

match = parserParams.match(params[1]);
if (!match.hasMatch())
return false;

params = parserParams.capturedTexts();
params = match.capturedTexts();
if (params.size() != 5)
return false;

Expand Down
27 changes: 15 additions & 12 deletions QtnProperty/Core/PropertyQRectF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ limitations under the License.
*******************************************************************************/

#include "PropertyQRectF.h"

#include "PropertyQRect.h"
#include "PropertyQSize.h"
#include <QRegularExpression>

QtnProperty *QtnPropertyQRectFBase::createLeftProperty(bool move)
{
Expand Down Expand Up @@ -73,24 +73,27 @@ QtnPropertyQRectFBase::QtnPropertyQRectFBase(QObject *parent)
bool QtnPropertyQRectFBase::fromStrImpl(
const QString &str, QtnPropertyChangeReason reason)
{
static QRegExp parserRect(
"^\\s*QRectF\\s*\\(([^\\)]+)\\)\\s*$", Qt::CaseInsensitive);
static QRegExp parserParams("^\\s*(\\-?\\d+(\\.\\d{0,})?)\\s*,\\s*(\\-?\\d+"
"(\\.\\d{0,})?)\\s*,\\s*(\\d+(\\.\\d{0,})?)\\s*"
",\\s*(\\d+(\\.\\d{0,})?)\\s*$",
Qt::CaseInsensitive);

if (!parserRect.exactMatch(str))
static QRegularExpression parserRect(
"^\\s*QRectF\\s*\\(([^\\)]+)\\)\\s*$", QRegularExpression::CaseInsensitiveOption);

QRegularExpressionMatch match = parserRect.match(str);
if (!match.hasMatch())
return false;

QStringList params = parserRect.capturedTexts();
QStringList params = match.capturedTexts();
if (params.size() != 2)
return false;

if (!parserParams.exactMatch(params[1]))
static QRegularExpression parserParams("^\\s*(\\-?\\d+(\\.\\d{0,})?)\\s*,\\s*(\\-?\\d+"
"(\\.\\d{0,})?)\\s*,\\s*(\\d+(\\.\\d{0,})?)\\s*"
",\\s*(\\d+(\\.\\d{0,})?)\\s*$",
QRegularExpression::CaseInsensitiveOption);

match = parserParams.match(params[1]);
if (!match.hasMatch())
return false;

params = parserParams.capturedTexts();
params = match.capturedTexts();
if (params.size() != 9)
return false;

Expand Down
19 changes: 11 additions & 8 deletions QtnProperty/Core/PropertyQSize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.

#include "PropertyQSize.h"
#include "PropertyInt.h"
#include <QRegularExpression>

QtnPropertyQSizeBase::QtnPropertyQSizeBase(QObject *parent)
: ParentClass(parent)
Expand All @@ -40,24 +41,26 @@ QtnProperty *QtnPropertyQSizeBase::createHeightProperty()
bool QtnPropertyQSizeBase::fromStrImpl(
const QString &str, QtnPropertyChangeReason reason)
{
static QRegExp parserSize(
"^\\s*QSize\\s*\\(([^\\)]+)\\)\\s*$", Qt::CaseInsensitive);
static QRegularExpression parserSize(
"^\\s*QSize\\s*\\(([^\\)]+)\\)\\s*$", QRegularExpression::CaseInsensitiveOption);

if (!parserSize.exactMatch(str))
QRegularExpressionMatch match = parserSize.match(str);
if (!match.hasMatch())
return false;

QStringList params = parserSize.capturedTexts();
QStringList params = match.capturedTexts();

if (params.size() != 2)
return false;

static QRegExp parserParams(
"^\\s*(-?\\d+)\\s*,\\s*(-?\\d+)\\s*$", Qt::CaseInsensitive);
static QRegularExpression parserParams(
"^\\s*(-?\\d+)\\s*,\\s*(-?\\d+)\\s*$", QRegularExpression::CaseInsensitiveOption);

if (!parserParams.exactMatch(params[1]))
match = parserParams.match(params[1]);
if (!match.hasMatch())
return false;

params = parserParams.capturedTexts();
params = match.capturedTexts();

if (params.size() != 3)
return false;
Expand Down
20 changes: 11 additions & 9 deletions QtnProperty/Core/PropertyQSizeF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ limitations under the License.
*******************************************************************************/

#include "PropertyQSizeF.h"

#include "PropertyQSize.h"
#include <QRegularExpression>

QtnPropertyQSizeFBase::QtnPropertyQSizeFBase(QObject *parent)
: ParentClass(parent)
Expand All @@ -41,25 +41,27 @@ QtnProperty *QtnPropertyQSizeFBase::createHeightProperty()
bool QtnPropertyQSizeFBase::fromStrImpl(
const QString &str, QtnPropertyChangeReason reason)
{
static QRegExp parserSize(
"^\\s*QSizeF\\s*\\(([^\\)]+)\\)\\s*$", Qt::CaseInsensitive);
static QRegularExpression parserSize(
"^\\s*QSizeF\\s*\\(([^\\)]+)\\)\\s*$", QRegularExpression::CaseInsensitiveOption);

if (!parserSize.exactMatch(str))
QRegularExpressionMatch match = parserSize.match(str);
if (!match.hasMatch())
return false;

QStringList params = parserSize.capturedTexts();
QStringList params = match.capturedTexts();

if (params.size() != 2)
return false;

static QRegExp parserParams(
static QRegularExpression parserParams(
"^\\s*(\\-?\\d+(\\.\\d{0,})?)\\s*,\\s*(\\-?\\d+(\\.\\d{0,})?)\\s*$",
Qt::CaseInsensitive);
QRegularExpression::CaseInsensitiveOption);

if (!parserParams.exactMatch(params[1]))
match = parserParams.match(params[1]);
if (!match.hasMatch())
return false;

params = parserParams.capturedTexts();
params = match.capturedTexts();

if (params.size() != 5)
return false;
Expand Down
4 changes: 2 additions & 2 deletions QtnProperty/CustomPropertyWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ QMimeData *QtnCustomPropertyWidget::getPropertyDataForAction(
QString::fromUtf8(&json.constData()[start], end - start)
.trimmed());

mime->setData(kCustomPropertyData, doc.toBinaryData());
mime->setData(kCustomPropertyData, doc.toJson());

return mime;
}
Expand Down Expand Up @@ -566,7 +566,7 @@ bool QtnCustomPropertyWidget::applyPropertyData(const QMimeData *data,
if (data->hasFormat(kCustomPropertyData))
{
auto doc =
QJsonDocument::fromBinaryData(data->data(kCustomPropertyData));
QJsonDocument::fromJson(data->data(kCustomPropertyData));

if (doc.isObject())
{
Expand Down
3 changes: 1 addition & 2 deletions QtnProperty/Delegates/Core/PropertyDelegateQString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ bool QtnPropertyDelegateQStringFile::isPropertyValid() const
return QFileInfo(filePath).isFile();

case QFileDialog::Directory:
case QFileDialog::DirectoryOnly:
return QFileInfo(filePath).isDir();
}

Expand Down Expand Up @@ -524,7 +523,7 @@ QtnPropertyQStringListComboBoxHandler::QtnPropertyQStringListComboBoxHandler(
editor.clear();
editor.addItems(items);
editor.setEditable(editable);
editor.setAutoCompletion(false);
editor.setCompleter(nullptr);

if (editable)
editor.installEventFilter(this);
Expand Down
2 changes: 1 addition & 1 deletion QtnProperty/Delegates/GUI/PropertyDelegateButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void QtnPropertyDelegateButtonLink::createSubItemsImpl(
QtnDrawContext &context, QList<QtnSubItem> &subItems)
{
QtnSubItem linkItem(context.rect.marginsRemoved(context.margins));
linkItem.rect.setWidth(context.painter->fontMetrics().width(m_title));
linkItem.rect.setWidth(context.painter->fontMetrics().boundingRect(m_title).width());
linkItem.setPropertyDescriptionAsTooltip(owner());
linkItem.trackState();

Expand Down
Loading