Add new variable to specify it in *.kcfgc : "CategoryLoggingName" CHANGELOG: Allow to generate file with qloggingcategories support. REVIEW: 122931wilder
parent
270b5ef5ab
commit
094c91f86b
10 changed files with 232 additions and 3 deletions
@ -0,0 +1,31 @@ |
||||
// This file is generated by kconfig_compiler_kf5 from test_qdebugcategory.kcfg. |
||||
// All changes you do to this file will be lost. |
||||
|
||||
#include "test_qdebugcategory.h" |
||||
|
||||
TestQCategory::TestQCategory( int Number ) |
||||
: KConfigSkeleton( QLatin1String( "test7rc" ) ) |
||||
, mParamNumber(Number) |
||||
{ |
||||
setCurrentGroup( QLatin1String( "Foo" ) ); |
||||
|
||||
KConfigSkeleton::ItemColor *itemColor; |
||||
itemColor = new KConfigSkeleton::ItemColor( currentGroup(), QString( QLatin1String( "color #%1" ) ).arg( mParamNumber ), mColor, QColor( "red" ) ); |
||||
addItem( itemColor, QLatin1String( "Color" ) ); |
||||
|
||||
setCurrentGroup( QString( QLatin1String( "Bar%1" ) ).arg( mParamNumber ) ); |
||||
|
||||
KConfigSkeleton::ItemString *itemFooBar; |
||||
itemFooBar = new KConfigSkeleton::ItemString( currentGroup(), QLatin1String( "foo bar" ), mFooBar ); |
||||
addItem( itemFooBar, QLatin1String( "FooBar" ) ); |
||||
KConfigSkeleton::ItemInt *itemAge; |
||||
itemAge = new KConfigSkeleton::ItemInt( currentGroup(), QLatin1String( "Age" ), mAge, 35 ); |
||||
itemAge->setMinValue(8); |
||||
itemAge->setMaxValue(88); |
||||
addItem( itemAge, QLatin1String( "Age" ) ); |
||||
} |
||||
|
||||
TestQCategory::~TestQCategory() |
||||
{ |
||||
} |
||||
|
||||
@ -0,0 +1,96 @@ |
||||
// This file is generated by kconfig_compiler_kf5 from test_qdebugcategory.kcfg. |
||||
// All changes you do to this file will be lost. |
||||
#ifndef TESTQCATEGORY_H |
||||
#define TESTQCATEGORY_H |
||||
|
||||
#include <test_qdebugcategory_debug.h> |
||||
|
||||
#include <kconfigskeleton.h> |
||||
#include <QCoreApplication> |
||||
#include <QDebug> |
||||
|
||||
class TestQCategory : public KConfigSkeleton |
||||
{ |
||||
public: |
||||
|
||||
TestQCategory( int Number ); |
||||
~TestQCategory(); |
||||
|
||||
/** |
||||
Set Block colors. |
||||
*/ |
||||
void setColor( const QColor & v ) |
||||
{ |
||||
if (!isImmutable( QString::fromLatin1( "Color" ) )) |
||||
mColor = v; |
||||
} |
||||
|
||||
/** |
||||
Get Block colors. |
||||
*/ |
||||
QColor color() const |
||||
{ |
||||
return mColor; |
||||
} |
||||
|
||||
/** |
||||
Set foo bar |
||||
*/ |
||||
void setFooBar( const QString & v ) |
||||
{ |
||||
if (!isImmutable( QString::fromLatin1( "FooBar" ) )) |
||||
mFooBar = v; |
||||
} |
||||
|
||||
/** |
||||
Get foo bar |
||||
*/ |
||||
QString fooBar() const |
||||
{ |
||||
return mFooBar; |
||||
} |
||||
|
||||
/** |
||||
Set Age |
||||
*/ |
||||
void setAge( int v ) |
||||
{ |
||||
if (v < 8) |
||||
{ |
||||
qCDebug(CATEGORY_LOG) << "setAge: value " << v << " is less than the minimum value of 8"; |
||||
v = 8; |
||||
} |
||||
|
||||
if (v > 88) |
||||
{ |
||||
qCDebug(CATEGORY_LOG) << "setAge: value " << v << " is greater than the maximum value of 88"; |
||||
v = 88; |
||||
} |
||||
|
||||
if (!isImmutable( QString::fromLatin1( "Age" ) )) |
||||
mAge = v; |
||||
} |
||||
|
||||
/** |
||||
Get Age |
||||
*/ |
||||
int age() const |
||||
{ |
||||
return mAge; |
||||
} |
||||
|
||||
protected: |
||||
int mParamNumber; |
||||
|
||||
// Foo |
||||
QColor mColor; |
||||
|
||||
// Bar$(Number) |
||||
QString mFooBar; |
||||
int mAge; |
||||
|
||||
private: |
||||
}; |
||||
|
||||
#endif |
||||
|
||||
@ -0,0 +1,25 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<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 name="test7rc"> |
||||
<parameter name="Number" type="Int"/> |
||||
</kcfgfile> |
||||
|
||||
<group name="Foo"> |
||||
<entry name="Color" type="Color" key="color #$(Number)"> |
||||
<label>Block colors.</label> |
||||
<default>red</default> |
||||
</entry> |
||||
</group> |
||||
<group name="Bar$(Number)"> |
||||
<entry name="FooBar" key="foo bar" type="String"/> |
||||
<entry name="Age" type="Int"> |
||||
<default>35</default> |
||||
<min>8</min> |
||||
<max>88</max> |
||||
</entry> |
||||
</group> |
||||
|
||||
</kcfg> |
||||
@ -0,0 +1,9 @@ |
||||
# Code generation options for kconfig_compiler_kf5 |
||||
File=test_qdebugcategory.kcfgc |
||||
ClassName=TestQCategory |
||||
Singleton=false |
||||
Mutators=true |
||||
GlobalEnums=true |
||||
ItemAccessors=false |
||||
CategoryLoggingName=CATEGORY_LOG |
||||
IncludeFiles=test_qdebugcategory_debug.h |
||||
@ -0,0 +1,4 @@ |
||||
#include "test_qdebugcategory_debug.h" |
||||
Q_LOGGING_CATEGORY(CATEGORY_LOG, "log_category") |
||||
|
||||
|
||||
@ -0,0 +1,8 @@ |
||||
#ifndef TEST_QCATEGORY_DEBUG_H |
||||
#define TEST_QCATEGORY_DEBUG_H |
||||
|
||||
#include <QLoggingCategory> |
||||
Q_DECLARE_LOGGING_CATEGORY(CATEGORY_LOG) |
||||
|
||||
#endif |
||||
|
||||
@ -0,0 +1,32 @@ |
||||
/*
|
||||
Copyright (c) 2004 Waldo Bastian <bastian@kde.org> |
||||
|
||||
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_qdebugcategory.h" |
||||
#include <QGuiApplication> |
||||
|
||||
int main(int argc, char **argv) |
||||
{ |
||||
QGuiApplication app(argc, argv); |
||||
Q_UNUSED(app); |
||||
TestQCategory *t = new TestQCategory(42); |
||||
delete t; |
||||
return 0; |
||||
} |
||||
Loading…
Reference in new issue