Summary: - When GenerateProperties and Mutators are activated, the generated code did not handle min/max properly - In the case of a parameterized entry, generated code also did not handle min/max BUG: 418146 Test Plan: - auto tests included Reviewers: meven, crossi, ervin, bport, tcanabrava Reviewed By: meven, ervin Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D27497wilder
parent
c8bf5e96cf
commit
d218b93a53
18 changed files with 445 additions and 42 deletions
@ -0,0 +1,41 @@ |
||||
// This file is generated by kconfig_compiler_kf5 from test_param_minmax.kcfg. |
||||
// All changes you do to this file will be lost. |
||||
|
||||
#include "test_param_minmax.h" |
||||
|
||||
TestParamMinMax::TestParamMinMax( KSharedConfig::Ptr config ) |
||||
: KConfigSkeleton( std::move( config ) ) |
||||
{ |
||||
setCurrentGroup( QStringLiteral( "Something" ) ); |
||||
|
||||
KConfigSkeleton::ItemDouble *itemFoo[6]; |
||||
itemFoo[0] = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "foo_#0" ), mFoo[0], 1.23 ); |
||||
itemFoo[0]->setMinValue(0.01); |
||||
itemFoo[0]->setMaxValue(89898.23); |
||||
addItem( itemFoo[0], QStringLiteral( "Foo0" ) ); |
||||
itemFoo[1] = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "foo_#1" ), mFoo[1], 1.23 ); |
||||
itemFoo[1]->setMinValue(0.01); |
||||
itemFoo[1]->setMaxValue(89898.23); |
||||
addItem( itemFoo[1], QStringLiteral( "Foo1" ) ); |
||||
itemFoo[2] = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "foo_#2" ), mFoo[2], 1.23 ); |
||||
itemFoo[2]->setMinValue(0.01); |
||||
itemFoo[2]->setMaxValue(89898.23); |
||||
addItem( itemFoo[2], QStringLiteral( "Foo2" ) ); |
||||
itemFoo[3] = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "foo_#3" ), mFoo[3], 1.23 ); |
||||
itemFoo[3]->setMinValue(0.01); |
||||
itemFoo[3]->setMaxValue(89898.23); |
||||
addItem( itemFoo[3], QStringLiteral( "Foo3" ) ); |
||||
itemFoo[4] = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "foo_#4" ), mFoo[4], 1.23 ); |
||||
itemFoo[4]->setMinValue(0.01); |
||||
itemFoo[4]->setMaxValue(89898.23); |
||||
addItem( itemFoo[4], QStringLiteral( "Foo4" ) ); |
||||
itemFoo[5] = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "foo_#5" ), mFoo[5], 1.23 ); |
||||
itemFoo[5]->setMinValue(0.01); |
||||
itemFoo[5]->setMaxValue(89898.23); |
||||
addItem( itemFoo[5], QStringLiteral( "Foo5" ) ); |
||||
} |
||||
|
||||
TestParamMinMax::~TestParamMinMax() |
||||
{ |
||||
} |
||||
|
||||
@ -0,0 +1,64 @@ |
||||
// This file is generated by kconfig_compiler_kf5 from test_param_minmax.kcfg. |
||||
// All changes you do to this file will be lost. |
||||
#ifndef TESTPARAMMINMAX_H |
||||
#define TESTPARAMMINMAX_H |
||||
|
||||
#include <qglobal.h> |
||||
#include <kconfigskeleton.h> |
||||
#include <QCoreApplication> |
||||
#include <QDebug> |
||||
|
||||
class TestParamMinMax : public KConfigSkeleton |
||||
{ |
||||
public: |
||||
|
||||
TestParamMinMax( KSharedConfig::Ptr config = KSharedConfig::openConfig() ); |
||||
~TestParamMinMax(); |
||||
|
||||
/** |
||||
Set foo_#$(myparam) |
||||
*/ |
||||
void setFoo( int i, double v ) |
||||
{ |
||||
if (v < 0.01) |
||||
{ |
||||
qDebug() << "setFoo: value " << v << " is less than the minimum value of 0.01"; |
||||
v = 0.01; |
||||
} |
||||
|
||||
if (v > 89898.23) |
||||
{ |
||||
qDebug() << "setFoo: value " << v << " is greater than the maximum value of 89898.23"; |
||||
v = 89898.23; |
||||
} |
||||
|
||||
if (!isFooImmutable( i )) |
||||
mFoo[i] = v; |
||||
} |
||||
|
||||
/** |
||||
Get foo_#$(myparam) |
||||
*/ |
||||
double foo( int i ) const |
||||
{ |
||||
return mFoo[i]; |
||||
} |
||||
|
||||
/** |
||||
Is foo_#$(myparam) Immutable |
||||
*/ |
||||
bool isFooImmutable( int i ) const |
||||
{ |
||||
return isImmutable( QStringLiteral( "Foo%1" ).arg( i ) ); |
||||
} |
||||
|
||||
protected: |
||||
|
||||
// Something |
||||
double mFoo[6]; |
||||
|
||||
private: |
||||
}; |
||||
|
||||
#endif |
||||
|
||||
@ -0,0 +1,17 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- Author: Henri Chain --> |
||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 |
||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > |
||||
<kcfgfile arg="true"/> |
||||
<group name="Something"> |
||||
<entry name="Foo$(myparam)" type="double" key="foo_#$(myparam)"> |
||||
<parameter name="myparam" type="Int" max="5"/> |
||||
<default>1.23</default> |
||||
<min>0.01</min> |
||||
<max>89898.23</max> |
||||
</entry> |
||||
</group> |
||||
</kcfg> |
||||
|
||||
@ -0,0 +1,4 @@ |
||||
ClassName=TestParamMinMax |
||||
File=test_param_minmax.kcfgc |
||||
Mutators=true |
||||
|
||||
@ -0,0 +1,29 @@ |
||||
/*
|
||||
Copyright (c) 2020 Henri chain <henri.chain@enioka.com> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
#include "test_param_minmax.h" |
||||
|
||||
int main(int, char **) |
||||
{ |
||||
TestParamMinMax *t = new TestParamMinMax(); |
||||
delete t; |
||||
return 0; |
||||
} |
||||
|
||||
@ -0,0 +1,35 @@ |
||||
// This file is generated by kconfig_compiler_kf5 from test_properties_minmax.kcfg. |
||||
// All changes you do to this file will be lost. |
||||
|
||||
#include "test_properties_minmax.h" |
||||
|
||||
TestPropertiesMinMax::TestPropertiesMinMax( KSharedConfig::Ptr config ) |
||||
: KConfigSkeleton( std::move( config ) ) |
||||
{ |
||||
KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&TestPropertiesMinMax::itemChanged); |
||||
|
||||
setCurrentGroup( QStringLiteral( "Something" ) ); |
||||
|
||||
KConfigCompilerSignallingItem *itemBar; |
||||
KConfigSkeleton::ItemInt *innerItemBar; |
||||
innerItemBar = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "bar" ), mBar, 42 ); |
||||
itemBar = new KConfigCompilerSignallingItem(innerItemBar, this, notifyFunction, signalBarChanged); |
||||
innerItemBar->setMinValue(36); |
||||
innerItemBar->setMaxValue(102); |
||||
addItem( itemBar, QStringLiteral( "bar" ) ); |
||||
} |
||||
|
||||
TestPropertiesMinMax::~TestPropertiesMinMax() |
||||
{ |
||||
} |
||||
|
||||
|
||||
void TestPropertiesMinMax::itemChanged(quint64 flags) { |
||||
|
||||
if ( flags & signalBarChanged ) { |
||||
Q_EMIT barChanged(); |
||||
} |
||||
} |
||||
|
||||
#include "test_properties_minmax.moc" |
||||
|
||||
@ -0,0 +1,80 @@ |
||||
// This file is generated by kconfig_compiler_kf5 from test_properties_minmax.kcfg. |
||||
// All changes you do to this file will be lost. |
||||
#ifndef TESTPROPERTIESMINMAX_H |
||||
#define TESTPROPERTIESMINMAX_H |
||||
|
||||
#include <qglobal.h> |
||||
#include <kconfigskeleton.h> |
||||
#include <QCoreApplication> |
||||
#include <QDebug> |
||||
|
||||
class TestPropertiesMinMax : public KConfigSkeleton |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
|
||||
TestPropertiesMinMax( KSharedConfig::Ptr config = KSharedConfig::openConfig() ); |
||||
~TestPropertiesMinMax(); |
||||
|
||||
/** |
||||
Set bar |
||||
*/ |
||||
void setBar( int v ) |
||||
{ |
||||
if (v < 36) |
||||
{ |
||||
qDebug() << "setBar: value " << v << " is less than the minimum value of 36"; |
||||
v = 36; |
||||
} |
||||
|
||||
if (v > 102) |
||||
{ |
||||
qDebug() << "setBar: value " << v << " is greater than the maximum value of 102"; |
||||
v = 102; |
||||
} |
||||
|
||||
if (v != mBar && !isBarImmutable()) { |
||||
mBar = v; |
||||
Q_EMIT barChanged(); |
||||
} |
||||
} |
||||
|
||||
Q_PROPERTY(int bar READ bar WRITE setBar NOTIFY barChanged) |
||||
Q_PROPERTY(bool isBarImmutable CONSTANT) |
||||
/** |
||||
Get bar |
||||
*/ |
||||
int bar() const |
||||
{ |
||||
return mBar; |
||||
} |
||||
|
||||
/** |
||||
Is bar Immutable |
||||
*/ |
||||
bool isBarImmutable() const |
||||
{ |
||||
return isImmutable( QStringLiteral( "bar" ) ); |
||||
} |
||||
|
||||
|
||||
enum { |
||||
signalBarChanged = 0x1 |
||||
}; |
||||
|
||||
Q_SIGNALS: |
||||
void barChanged(); |
||||
|
||||
private: |
||||
void itemChanged(quint64 flags); |
||||
|
||||
protected: |
||||
|
||||
// Something |
||||
int mBar; |
||||
|
||||
private: |
||||
}; |
||||
|
||||
#endif |
||||
|
||||
@ -0,0 +1,15 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- Author: Henri Chain --> |
||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 |
||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > |
||||
<kcfgfile arg="true"/> |
||||
<group name="Something"> |
||||
<entry name="bar" type="Int"> |
||||
<default>42</default> |
||||
<min>36</min> |
||||
<max>102</max> |
||||
</entry> |
||||
</group> |
||||
</kcfg> |
||||
@ -0,0 +1,5 @@ |
||||
ClassName=TestPropertiesMinMax |
||||
GenerateProperties=true |
||||
File=test_properties_minmax.kcfgc |
||||
Mutators=true |
||||
|
||||
@ -0,0 +1,28 @@ |
||||
/*
|
||||
Copyright (c) 2020 Henri Chain <henri.chain@enioka.com> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
#include "test_properties_minmax.h" |
||||
|
||||
int main(int, char **) |
||||
{ |
||||
TestPropertiesMinMax *t = new TestPropertiesMinMax(); |
||||
delete t; |
||||
return 0; |
||||
} |
||||
Loading…
Reference in new issue