diff options
| author | Méven Car <meven.car@enioka.com> | 2020-02-04 16:03:52 +0100 | 
|---|---|---|
| committer | Méven Car <meven29@gmail.com> | 2020-02-04 16:09:29 +0100 | 
| commit | d46739294d04c72af1e434e414e1c012d7e78a42 (patch) | |
| tree | 5a227069a6a1a110cc26b788ff8a3bd99005735e /autotests/kconfig_compiler/test4.h.ref | |
| parent | fd0e26ddb49122fa55bdc8f35e189c832cc138ad (diff) | |
| download | kconfig-d46739294d04c72af1e434e414e1c012d7e78a42.tar.gz kconfig-d46739294d04c72af1e434e414e1c012d7e78a42.tar.bz2 | |
Add an is<PropertyName>Immutable to know if a property is immutable
Summary:
Add a utility function is<Parameter>Immutable to access immutability quickly.
Generated classes uses them internally to avoid code redundance.
Sample:
```
    /**
      Set blocked-by-default
    */
    void setBlockedByDefault( bool v )
    {
      if (v != mBlockedByDefault && !isBlockedByDefaultImmutable() )  {
        mBlockedByDefault = v;
        Q_EMIT blockedByDefaultChanged();
      }
    }
    /**
      Is blocked-by-default Immutable
    */
    bool isBlockedByDefaultImmutable()
    {
      return isImmutable( QStringLiteral( "blockedByDefault" ) );
    }
```
```
    /**
      Set org.kde.ActivityManager.ResourceScoringEnabled
    */
    void setResourceScoringEnabled( bool v )
    {
      if (!isResourceScoringEnabledImmutable() )
        mResourceScoringEnabled = v;
    }
    /**
      Is org.kde.ActivityManager.ResourceScoringEnabled Immutable
    */
    bool isResourceScoringEnabledImmutable()
    {
      return isImmutable( QStringLiteral( "resourceScoringEnabled" ) );
    }
```
Reviewers: ervin, #frameworks, dfaure
Reviewed By: ervin
Subscribers: dfaure, tcanabrava, kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D26368
Diffstat (limited to 'autotests/kconfig_compiler/test4.h.ref')
| -rw-r--r-- | autotests/kconfig_compiler/test4.h.ref | 66 | 
1 files changed, 60 insertions, 6 deletions
| diff --git a/autotests/kconfig_compiler/test4.h.ref b/autotests/kconfig_compiler/test4.h.ref index 1d5d1d87..32e351ca 100644 --- a/autotests/kconfig_compiler/test4.h.ref +++ b/autotests/kconfig_compiler/test4.h.ref @@ -31,7 +31,7 @@ class Test4 : public KConfigSkeleton      static      void setColor( int i, const QColor & v )      { -      if (!self()->isImmutable( QStringLiteral( "Color%1" ).arg( i ) )) +      if (!self()->isColorImmutable( i ))          self()->mColor[i] = v;      } @@ -45,12 +45,21 @@ class Test4 : public KConfigSkeleton      }      /** +      Is Block colors. Immutable +    */ +    static +    bool isColorImmutable( int i ) +    { +      return self()->isImmutable( QStringLiteral( "Color%1" ).arg( i ) ); +    } + +    /**        Set Mouse actions.      */      static      void setMouseAction( int i, int v )      { -      if (!self()->isImmutable( QStringLiteral( "MouseAction%1" ).arg( QLatin1String( EnumButton::enumToString[i] ) ) )) +      if (!self()->isMouseActionImmutable( i ))          self()->mMouseAction[i] = v;      } @@ -64,12 +73,21 @@ class Test4 : public KConfigSkeleton      }      /** +      Is Mouse actions. Immutable +    */ +    static +    bool isMouseActionImmutable( int i ) +    { +      return self()->isImmutable( QStringLiteral( "MouseAction%1" ).arg( QLatin1String( EnumButton::enumToString[i] ) ) ); +    } + +    /**        Set Gray colors.      */      static      void setGrayColor( int i, const QColor & v )      { -      if (!self()->isImmutable( QStringLiteral( "GrayColor%1" ).arg( i ) )) +      if (!self()->isGrayColorImmutable( i ))          self()->mGrayColor[i] = v;      } @@ -83,12 +101,21 @@ class Test4 : public KConfigSkeleton      }      /** +      Is Gray colors. Immutable +    */ +    static +    bool isGrayColorImmutable( int i ) +    { +      return self()->isImmutable( QStringLiteral( "GrayColor%1" ).arg( i ) ); +    } + +    /**        Set Gray colors as string.      */      static      void setColorString( int i, const QString & v )      { -      if (!self()->isImmutable( QStringLiteral( "ColorString%1" ).arg( i ) )) +      if (!self()->isColorStringImmutable( i ))          self()->mColorString[i] = v;      } @@ -102,12 +129,21 @@ class Test4 : public KConfigSkeleton      }      /** +      Is Gray colors as string. Immutable +    */ +    static +    bool isColorStringImmutable( int i ) +    { +      return self()->isImmutable( QStringLiteral( "ColorString%1" ).arg( i ) ); +    } + +    /**        Set foo bar      */      static      void setFooBar( const QString & v )      { -      if (!self()->isImmutable( QStringLiteral( "FooBar" ) )) +      if (!self()->isFooBarImmutable())          self()->mFooBar = v;      } @@ -121,6 +157,15 @@ class Test4 : public KConfigSkeleton      }      /** +      Is foo bar Immutable +    */ +    static +    bool isFooBarImmutable() +    { +      return self()->isImmutable( QStringLiteral( "FooBar" ) ); +    } + +    /**        Set Age      */      static @@ -138,7 +183,7 @@ class Test4 : public KConfigSkeleton          v = 88;        } -      if (!self()->isImmutable( QStringLiteral( "Age" ) )) +      if (!self()->isAgeImmutable())          self()->mAge = v;      } @@ -151,6 +196,15 @@ class Test4 : public KConfigSkeleton        return self()->mAge;      } +    /** +      Is Age Immutable +    */ +    static +    bool isAgeImmutable() +    { +      return self()->isImmutable( QStringLiteral( "Age" ) ); +    } +    protected:      Test4();      friend class Test4Helper; | 
