diff --git a/src/editors/KPropertyRectFEditor.cpp b/src/editors/KPropertyRectFEditor.cpp index 37185ec..0e79f26 100644 --- a/src/editors/KPropertyRectFEditor.cpp +++ b/src/editors/KPropertyRectFEditor.cpp @@ -1,99 +1,93 @@ /* This file is part of the KDE project Copyright (C) 2015-2017 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KPropertyRectFEditor.h" #include "KPropertyUtils_p.h" #include KPropertyRectFDelegate::KPropertyRectFDelegate() { } QString KPropertyRectFDelegate::propertyValueToString(const KProperty *property, const QLocale &locale) const { const KPropertyUtilsPrivate::ValueOptionsHandler options(*property); return options.valueWithPrefixAndSuffix(valueToString(property->value(), locale), locale); } QString KPropertyRectFDelegate::valueToString(const QVariant& value, const QLocale &locale) const { const QRectF r(value.toRectF()); - if (r.isNull()) { - if (locale.language() == QLocale::C) { - return QString(); - } - return QObject::tr("None", "Null value"); - } if (locale.language() == QLocale::C) { return QString::fromLatin1("%1, %2, %3x%4").arg(r.x()).arg(r.y()).arg(r.width()).arg(r.height()); } return QObject::tr("%1, %2, %3x%4", "Rectangle") .arg(locale.toString(r.x())) .arg(locale.toString(r.y())) .arg(locale.toString(r.width())) .arg(locale.toString(r.height())); } //------------ KRectFComposedProperty::KRectFComposedProperty(KProperty *property) : KComposedPropertyInterface(property) { (void)new KProperty("x", QVariant(), QObject::tr("X", "Property: X coordinate"), QObject::tr("X Coordinate", "Property: X coordinate"), KProperty::Double, property); (void)new KProperty("y", QVariant(), QObject::tr("Y", "Property: Y coordinate"), QObject::tr("Y Coordinate", "Property: Y coordinate"), KProperty::Double, property); (void)new KProperty("width", QVariant(), QObject::tr("Width", "Property: width of rectangle"), QObject::tr("Width", "Property: width of rectangle"), KProperty::Double, property); (void)new KProperty("height", QVariant(), QObject::tr("Height", "Property: height of rectangle"), QObject::tr("Height", "Property: height of rectangle"), KProperty::Double, property); } void KRectFComposedProperty::setValue(KProperty *property, const QVariant &value, KProperty::ValueOptions valueOptions) { const QRectF r(value.toRectF()); property->child("x")->setValue(r.x(), valueOptions); property->child("y")->setValue(r.y(), valueOptions); property->child("width")->setValue(r.width(), valueOptions); property->child("height")->setValue(r.height(), valueOptions); } void KRectFComposedProperty::childValueChanged(KProperty *child, const QVariant &value, KProperty::ValueOptions valueOptions) { QRectF r(child->parent()->value().toRectF()); if (child->name() == "x") r.moveLeft(value.toReal()); else if (child->name() == "y") r.moveTop(value.toReal()); else if (child->name() == "width") r.setWidth(value.toReal()); else if (child->name() == "height") r.setHeight(value.toReal()); child->parent()->setValue(r, valueOptions); } diff --git a/src/editors/pointedit.cpp b/src/editors/pointedit.cpp index d539cc2..55b1963 100644 --- a/src/editors/pointedit.cpp +++ b/src/editors/pointedit.cpp @@ -1,79 +1,73 @@ /* This file is part of the KDE project Copyright (C) 2004 Cedric Pasteur Copyright (C) 2004 Alexander Dymo Copyright (C) 2008-2015 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "pointedit.h" #include KPropertyPointDelegate::KPropertyPointDelegate() { } QString KPropertyPointDelegate::valueToString(const QVariant& value, const QLocale &locale) const { const QPoint p(value.toPoint()); - if (p.isNull()) { - if (locale.language() == QLocale::C) { - return QString(); - } - return QObject::tr("None", "Null value"); - } if (locale.language() == QLocale::C) { return QString::fromLatin1("%1, %2").arg(p.x()).arg(p.y()); } return QObject::tr("%1, %2", "Point") .arg(locale.toString(p.x())) .arg(locale.toString(p.y())); } //------------ KPointComposedProperty::KPointComposedProperty(KProperty *property) : KComposedPropertyInterface(property) { (void)new KProperty("x", QVariant(), QObject::tr("X", "Property: X coordinate"), QObject::tr("X Coordinate", "Property: X coordinate"), KProperty::Int, property); (void)new KProperty("y", QVariant(), QObject::tr("Y", "Property: Y coordinate"), QObject::tr("Y Coordinate", "Property: Y coordinate"), KProperty::Int, property); } void KPointComposedProperty::setValue(KProperty *property, const QVariant &value, KProperty::ValueOptions valueOptions) { const QPoint p( value.toPoint() ); property->child("x")->setValue(p.x(), valueOptions); property->child("y")->setValue(p.y(), valueOptions); } void KPointComposedProperty::childValueChanged(KProperty *child, const QVariant &value, KProperty::ValueOptions valueOptions) { QPoint p( child->parent()->value().toPoint() ); if (child->name() == "x") p.setX(value.toInt()); else if (child->name() == "y") p.setY(value.toInt()); child->parent()->setValue(p, valueOptions); } diff --git a/src/editors/pointfedit.cpp b/src/editors/pointfedit.cpp index 1b16a45..a03064b 100644 --- a/src/editors/pointfedit.cpp +++ b/src/editors/pointfedit.cpp @@ -1,88 +1,82 @@ /* This file is part of the KDE project Copyright (C) 2004 Cedric Pasteur Copyright (C) 2004 Alexander Dymo Copyright (C) 2008-2017 Jarosław Staniek Copyright (C) 2010 Adam Pigg This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "pointfedit.h" #include "KPropertyUtils_p.h" #include KPropertyPointFDelegate::KPropertyPointFDelegate() { } QString KPropertyPointFDelegate::propertyValueToString(const KProperty *property, const QLocale &locale) const { const KPropertyUtilsPrivate::ValueOptionsHandler options(*property); return options.valueWithPrefixAndSuffix(valueToString(property->value(), locale), locale); } QString KPropertyPointFDelegate::valueToString(const QVariant& value, const QLocale &locale) const { const QPointF p(value.toPointF()); - if (p.isNull()) { - if (locale.language() == QLocale::C) { - return QString(); - } - return QObject::tr("None", "Null value"); - } if (locale.language() == QLocale::C) { return QString::fromLatin1("%1, %2").arg(p.x()).arg(p.y()); } return QObject::tr("%1, %2", "Point") .arg(locale.toString(p.x())) .arg(locale.toString(p.y())); } //------------ KPointFComposedProperty::KPointFComposedProperty(KProperty *property) : KComposedPropertyInterface(property) { (void)new KProperty("x", QVariant(), QObject::tr("X", "Property: X coordinate"), QObject::tr("X Coordinate", "Property: X coordinate"), KProperty::Double, property); (void)new KProperty("y", QVariant(), QObject::tr("Y", "Property: Y coordinate"), QObject::tr("Y Coordinate", "Property: Y coordinate"), KProperty::Double, property); } void KPointFComposedProperty::setValue(KProperty *property, const QVariant &value, KProperty::ValueOptions valueOptions) { const QPointF p( value.toPointF() ); property->child("x")->setValue(p.x(), valueOptions); property->child("y")->setValue(p.y(), valueOptions); } void KPointFComposedProperty::childValueChanged(KProperty *child, const QVariant &value, KProperty::ValueOptions valueOptions) { QPointF p( child->parent()->value().toPointF() ); if (child->name() == "x") p.setX(value.toDouble()); else if (child->name() == "y") p.setY(value.toDouble()); child->parent()->setValue(p, valueOptions); } diff --git a/src/editors/rectedit.cpp b/src/editors/rectedit.cpp index a52d347..f97eb8b 100644 --- a/src/editors/rectedit.cpp +++ b/src/editors/rectedit.cpp @@ -1,91 +1,85 @@ /* This file is part of the KDE project Copyright (C) 2008-2015 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "rectedit.h" #include KPropertyRectDelegate::KPropertyRectDelegate() { } QString KPropertyRectDelegate::valueToString(const QVariant& value, const QLocale &locale) const { const QRect r(value.toRect()); - if (r.isNull()) { - if (locale.language() == QLocale::C) { - return QString(); - } - return QObject::tr("None", "Null value"); - } if (locale.language() == QLocale::C) { return QString::fromLatin1("%1, %2, %3x%4").arg(r.x()).arg(r.y()).arg(r.width()).arg(r.height()); } return QObject::tr("%1, %2, %3x%4", "Rectangle") .arg(locale.toString(r.x())) .arg(locale.toString(r.y())) .arg(locale.toString(r.width())) .arg(locale.toString(r.height())); } //------------ KRectComposedProperty::KRectComposedProperty(KProperty *property) : KComposedPropertyInterface(property) { (void)new KProperty("x", QVariant(), QObject::tr("X", "Property: X coordinate"), QObject::tr("X Coordinate", "Property: X coordinate"), KProperty::Int, property); (void)new KProperty("y", QVariant(), QObject::tr("Y", "Property: Y coordinate"), QObject::tr("Y Coordinate", "Property: Y coordinate"), KProperty::Int, property); (void)new KProperty("width", QVariant(), QObject::tr("Width", "Property: width of rectangle"), QObject::tr("Width", "Property: width of rectangle"), KProperty::UInt, property); (void)new KProperty("height", QVariant(), QObject::tr("Height", "Property: height of rectangle"), QObject::tr("Height", "Property: height of rectangle"), KProperty::UInt, property); } void KRectComposedProperty::setValue(KProperty *property, const QVariant &value, KProperty::ValueOptions valueOptions) { const QRect r( value.toRect() ); property->child("x")->setValue(r.x(), valueOptions); property->child("y")->setValue(r.y(), valueOptions); property->child("width")->setValue(r.width(), valueOptions); property->child("height")->setValue(r.height(), valueOptions); } void KRectComposedProperty::childValueChanged(KProperty *child, const QVariant &value, KProperty::ValueOptions valueOptions) { QRect r( child->parent()->value().toRect() ); if (child->name() == "x") r.moveLeft(value.toInt()); else if (child->name() == "y") r.moveTop(value.toInt()); else if (child->name() == "width") r.setWidth(value.toInt()); else if (child->name() == "height") r.setHeight(value.toInt()); child->parent()->setValue(r, valueOptions); } diff --git a/src/editors/sizeedit.cpp b/src/editors/sizeedit.cpp index f324443..277a67b 100644 --- a/src/editors/sizeedit.cpp +++ b/src/editors/sizeedit.cpp @@ -1,74 +1,68 @@ /* This file is part of the KDE project Copyright (C) 2008-2015 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "sizeedit.h" #include KPropertySizeDelegate::KPropertySizeDelegate() { } QString KPropertySizeDelegate::valueToString(const QVariant& value, const QLocale &locale) const { const QSize s(value.toSize()); - if (s.isNull()) { - if (locale.language() == QLocale::C) { - return QString(); - } - return QObject::tr("None", "Null value"); - } if (locale.language() == QLocale::C) { return QString::fromLatin1("%1x%2").arg(s.width()).arg(s.height()); } return QObject::tr("%1x%2", "Size") .arg(locale.toString(s.width())) .arg(locale.toString(s.height())); } //------------ KSizeComposedProperty::KSizeComposedProperty(KProperty *property) : KComposedPropertyInterface(property) { (void)new KProperty("width", QVariant(), QObject::tr("Width"), QObject::tr("Width"), KProperty::UInt, property); (void)new KProperty("height", QVariant(), QObject::tr("Height"), QObject::tr("Height"), KProperty::UInt, property); } void KSizeComposedProperty::setValue(KProperty *property, const QVariant &value, KProperty::ValueOptions valueOptions) { const QSize s( value.toSize() ); property->child("width")->setValue(s.width(), valueOptions); property->child("height")->setValue(s.height(), valueOptions); } void KSizeComposedProperty::childValueChanged(KProperty *child, const QVariant &value, KProperty::ValueOptions valueOptions) { QSize s( child->parent()->value().toSize() ); if (child->name() == "width") s.setWidth(value.toInt()); else if (child->name() == "height") s.setHeight(value.toInt()); child->parent()->setValue(s, valueOptions); } diff --git a/src/editors/sizefedit.cpp b/src/editors/sizefedit.cpp index 8157a33..1107d1c 100644 --- a/src/editors/sizefedit.cpp +++ b/src/editors/sizefedit.cpp @@ -1,82 +1,76 @@ /* This file is part of the KDE project Copyright (C) 2008-2017 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "sizefedit.h" #include "KPropertyUtils_p.h" #include KPropertySizeFDelegate::KPropertySizeFDelegate() { } QString KPropertySizeFDelegate::propertyValueToString(const KProperty *property, const QLocale &locale) const { const KPropertyUtilsPrivate::ValueOptionsHandler options(*property); return options.valueWithPrefixAndSuffix(valueToString(property->value(), locale), locale); } QString KPropertySizeFDelegate::valueToString(const QVariant& value, const QLocale &locale) const { const QSizeF s(value.toSizeF()); - if (s.isNull()) { - if (locale.language() == QLocale::C) { - return QString(); - } - return QObject::tr("None", "Null value"); - } if (locale.language() == QLocale::C) { return QString::fromLatin1("%1x%2").arg(s.width()).arg(s.height()); } return QObject::tr("%1x%2", "Size") .arg(locale.toString(s.width())) .arg(locale.toString(s.height())); } //------------ KSizeFComposedProperty::KSizeFComposedProperty(KProperty *property) : KComposedPropertyInterface(property) { (void)new KProperty("width", QVariant(), QObject::tr("Width"), QObject::tr("Width"), KProperty::Double, property); (void)new KProperty("height", QVariant(), QObject::tr("Height"), QObject::tr("Height"), KProperty::Double, property); } void KSizeFComposedProperty::setValue(KProperty *property, const QVariant &value, KProperty::ValueOptions valueOptions) { const QSizeF s( value.toSizeF() ); property->child("width")->setValue(s.width(), valueOptions); property->child("height")->setValue(s.height(), valueOptions); } void KSizeFComposedProperty::childValueChanged(KProperty *child, const QVariant &value, KProperty::ValueOptions valueOptions) { QSizeF s( child->parent()->value().toSizeF() ); if (child->name() == "width") s.setWidth(value.toDouble()); else if (child->name() == "height") s.setHeight(value.toDouble()); child->parent()->setValue(s, valueOptions); }