kdecore: deal with TODO related to KConfigSkeleton::ItemEnum

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-09-23 11:28:46 +03:00
parent 86b867fc0c
commit 40a0937006
13 changed files with 60 additions and 112 deletions

View file

@ -77,7 +77,7 @@ macro(KDE4_ADD_KCFG_FILES _sources )
)
if(_kcfg_generatemoc)
qt4_generate_moc(${_header_FILE} ${_moc_FILE} )
qt4_generate_moc(${_header_FILE} ${_moc_FILE})
set_source_files_properties(${_src_FILE} PROPERTIES SKIP_AUTOMOC TRUE)
list(APPEND ${_sources} ${_moc_FILE})
endif()

View file

@ -436,18 +436,7 @@ KCoreConfigSkeleton::ItemEnum::ItemEnum( const QString &_group, const QString &_
qint32 defaultValue )
: ItemInt( _group, _key, reference, defaultValue )
{
foreach (const ItemEnum::Choice &c, choices) {
ItemEnum::Choice2 cc = { c.name, c.label, QString(), c.whatsThis };
mChoices.append(cc);
}
}
KCoreConfigSkeleton::ItemEnum::ItemEnum( const QString &_group, const QString &_key,
qint32 &reference,
const QList<Choice2> &choices,
qint32 defaultValue )
: ItemInt( _group, _key, reference, defaultValue ), mChoices(choices)
{
mChoices = choices;
}
void KCoreConfigSkeleton::ItemEnum::readConfig( KConfig *config )
@ -462,7 +451,7 @@ void KCoreConfigSkeleton::ItemEnum::readConfig( KConfig *config )
int i = 0;
mReference = -1;
QString tmp = cg.readEntry( mKey, QString() ).toLower();
for(QList<Choice2>::ConstIterator it = mChoices.constBegin();
for(QList<Choice>::ConstIterator it = mChoices.constBegin();
it != mChoices.constEnd(); ++it, ++i)
{
if ((*it).name.toLower() == tmp)
@ -494,16 +483,6 @@ void KCoreConfigSkeleton::ItemEnum::writeConfig( KConfig *config )
}
QList<KCoreConfigSkeleton::ItemEnum::Choice> KCoreConfigSkeleton::ItemEnum::choices() const
{
QList<KCoreConfigSkeleton::ItemEnum::Choice> r;
foreach (const KCoreConfigSkeleton::ItemEnum::Choice2 &c, mChoices) {
KCoreConfigSkeleton::ItemEnum::Choice cc = { c.name, c.label, c.whatsThis };
r.append(cc);
}
return r;
}
QList<KCoreConfigSkeleton::ItemEnum::Choice2> KCoreConfigSkeleton::ItemEnum::choices2() const
{
return mChoices;
}

View file

@ -601,7 +601,6 @@ public:
class KDECORE_EXPORT ItemEnum:public ItemInt
{
public:
//KDE5: remove the old Choice struct, rename Choice2 to Choice
struct Choice
{
QString name;
@ -609,28 +608,13 @@ public:
QString whatsThis;
};
struct Choice2
{
QString name;
QString label;
QString toolTip;
QString whatsThis;
};
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem
@param choices The list of enums that can be stored in this item
*/
ItemEnum(const QString & _group, const QString & _key, qint32 &reference,
const QList<Choice> &choices, qint32 defaultValue = 0);
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem
@param choices The list of enums that can be stored in this item
*/
ItemEnum(const QString & _group, const QString & _key, qint32 &reference,
const QList<Choice2> &choices, qint32 defaultValue = 0);
QList<Choice> choices() const;
QList<Choice2> choices2() const;
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
void readConfig(KConfig * config);
@ -639,7 +623,7 @@ public:
void writeConfig(KConfig * config);
private:
QList<Choice2> mChoices;
QList<Choice> mChoices;
};

View file

@ -81,7 +81,6 @@
<xsd:element name="parameter" minOccurs="0" type="kcfg:parameter"/>
<xsd:element name="label" minOccurs="0" type="kcfg:translatableString"/>
<xsd:element name="whatsthis" minOccurs="0" type="kcfg:translatableString"/>
<xsd:element name="tooltip" minOccurs="0" type="kcfg:translatableString"/>
<xsd:element name="choices" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
@ -90,7 +89,6 @@
<xsd:all>
<xsd:element minOccurs="0" name="label" type="kcfg:translatableString"/>
<xsd:element minOccurs="0" name="whatsthis" type="kcfg:translatableString"/>
<xsd:element minOccurs="0" name="tooltip" type="kcfg:translatableString"/>
</xsd:all>
<xsd:attribute name="name" use="required" type="xsd:string"/>
</xsd:complexType>

View file

@ -190,7 +190,6 @@ class CfgEntry
QString name;
QString context;
QString label;
QString toolTip;
QString whatsThis;
};
class Choices
@ -718,10 +717,6 @@ CfgEntry *parseEntry( const QString &group, const QDomElement &element, const Cf
choice.label = e3.text();
choice.context = e3.attribute( "context" );
}
if ( e3.tagName() == "tooltip" ) {
choice.toolTip = e3.text();
choice.context = e3.attribute( "context" );
}
if ( e3.tagName() == "whatsthis" ) {
choice.whatsThis = e3.text();
choice.context = e3.attribute( "context" );
@ -2072,13 +2067,13 @@ int main( int argc, char **argv )
cpp << (*itEntry)->code() << endl;
}
if ( (*itEntry)->type() == "Enum" ) {
cpp << " QList<"+cfg.inherits+"::ItemEnum::Choice2> values"
cpp << " QList<"+cfg.inherits+"::ItemEnum::Choice> values"
<< (*itEntry)->name() << ";" << endl;
const QList<CfgEntry::Choice> choices = (*itEntry)->choices().choices;
QList<CfgEntry::Choice>::ConstIterator it;
for( it = choices.constBegin(); it != choices.constEnd(); ++it ) {
cpp << " {" << endl;
cpp << " "+cfg.inherits+"::ItemEnum::Choice2 choice;" << endl;
cpp << " "+cfg.inherits+"::ItemEnum::Choice choice;" << endl;
cpp << " choice.name = QLatin1String(\"" << (*it).name << "\");" << endl;
if ( cfg.setUserTexts ) {
if ( !(*it).label.isEmpty() ) {
@ -2089,14 +2084,6 @@ int main( int argc, char **argv )
cpp << "i18n(";
cpp << quoteString((*it).label) << ");" << endl;
}
if ( !(*it).toolTip.isEmpty() ) {
cpp << " choice.toolTip = ";
if ( !(*it).context.isEmpty() )
cpp << "i18nc(" + quoteString((*it).context) + ", ";
else
cpp << "i18n(";
cpp << quoteString((*it).toolTip) << ");" << endl;
}
if ( !(*it).whatsThis.isEmpty() ) {
cpp << " choice.whatsThis = ";
if ( !(*it).context.isEmpty() )

View file

@ -16,19 +16,19 @@ Test1::Test1( const QString & transport, const QString & folder )
KConfigSkeleton::ItemInt *itemAnotherOption;
itemAnotherOption = new KConfigSkeleton::ItemInt( currentGroup(), QLatin1String( "Another Option" ), mAnotherOption, 5 );
addItem( itemAnotherOption, QLatin1String( "AnotherOption" ) );
QList<KConfigSkeleton::ItemEnum::Choice2> valuesListOption;
QList<KConfigSkeleton::ItemEnum::Choice> valuesListOption;
{
KConfigSkeleton::ItemEnum::Choice2 choice;
KConfigSkeleton::ItemEnum::Choice choice;
choice.name = QLatin1String("One");
valuesListOption.append( choice );
}
{
KConfigSkeleton::ItemEnum::Choice2 choice;
KConfigSkeleton::ItemEnum::Choice choice;
choice.name = QLatin1String("Two");
valuesListOption.append( choice );
}
{
KConfigSkeleton::ItemEnum::Choice2 choice;
KConfigSkeleton::ItemEnum::Choice choice;
choice.name = QLatin1String("Three");
valuesListOption.append( choice );
}

View file

@ -23,31 +23,31 @@ Test11::Test11( )
mArchiveFileItem = new MyPrefs::ItemString( currentGroup(), QLatin1String( "Archive File" ), mArchiveFile );
mArchiveFileItem->setLabel( i18n("Archive File") );
addItem( mArchiveFileItem, QLatin1String( "ArchiveFile" ) );
QList<MyPrefs::ItemEnum::Choice2> valuesDestination;
QList<MyPrefs::ItemEnum::Choice> valuesDestination;
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("standardDestination");
valuesDestination.append( choice );
}
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("askDestination");
valuesDestination.append( choice );
}
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("argl1");
choice.label = i18n("Argl1 Label");
valuesDestination.append( choice );
}
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("argl2");
choice.whatsThis = i18n("Argl2 Whatsthis");
valuesDestination.append( choice );
}
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("argl3");
choice.label = i18n("Argl3 Label");
choice.whatsThis = i18n("Argl3 Whatsthis");
@ -93,15 +93,15 @@ Test11::Test11( )
setCurrentGroup( QLatin1String( "Email" ) );
QList<MyPrefs::ItemEnum::Choice2> valuesEmailClient;
QList<MyPrefs::ItemEnum::Choice> valuesEmailClient;
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("sendmail");
choice.label = i18nc("@option", "Sendmail");
valuesEmailClient.append( choice );
}
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("kmail");
choice.label = i18nc("@option", "KMail");
valuesEmailClient.append( choice );
@ -110,14 +110,14 @@ Test11::Test11( )
mEmailClientItem->setLabel( i18nc("@label", "Email client") );
mEmailClientItem->setWhatsThis( i18nc("@info:whatsthis", "<para>How to send email when an email alarm is triggered.<list><item>KMail: The email is sent automatically via <application>KMail</application>. <application>KMail</application> is started first if necessary.</item><item>Sendmail: The email is sent automatically. This option will only work if your system is configured to use <application>sendmail</application> or a sendmail compatible mail transport agent.</item></list></para>") );
addItem( mEmailClientItem, QLatin1String( "EmailClient" ) );
QList<MyPrefs::ItemEnum::Choice2> valuesDefaultReminderUnits;
QList<MyPrefs::ItemEnum::Choice> valuesDefaultReminderUnits;
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("Minutes");
valuesDefaultReminderUnits.append( choice );
}
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("HoursMinutes");
choice.label = i18nc("@option", "Hours/Minutes");
valuesDefaultReminderUnits.append( choice );

View file

@ -23,31 +23,31 @@ Test11a::Test11a( )
mArchiveFileItem = new MyPrefs::ItemString( currentGroup(), QLatin1String( "Archive File" ), mArchiveFile );
mArchiveFileItem->setLabel( i18n("Archive File") );
addItem( mArchiveFileItem, QLatin1String( "ArchiveFile" ) );
QList<MyPrefs::ItemEnum::Choice2> valuesDestination;
QList<MyPrefs::ItemEnum::Choice> valuesDestination;
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("standardDestination");
valuesDestination.append( choice );
}
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("askDestination");
valuesDestination.append( choice );
}
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("argl1");
choice.label = i18n("Argl1 Label");
valuesDestination.append( choice );
}
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("argl2");
choice.whatsThis = i18n("Argl2 Whatsthis");
valuesDestination.append( choice );
}
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("argl3");
choice.label = i18n("Argl3 Label");
choice.whatsThis = i18n("Argl3 Whatsthis");
@ -93,15 +93,15 @@ Test11a::Test11a( )
setCurrentGroup( QLatin1String( "Email" ) );
QList<MyPrefs::ItemEnum::Choice2> valuesEmailClient;
QList<MyPrefs::ItemEnum::Choice> valuesEmailClient;
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("sendmail");
choice.label = i18nc("@option", "Sendmail");
valuesEmailClient.append( choice );
}
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("kmail");
choice.label = i18nc("@option", "KMail");
valuesEmailClient.append( choice );
@ -110,14 +110,14 @@ Test11a::Test11a( )
mEmailClientItem->setLabel( i18nc("@label", "Email client") );
mEmailClientItem->setWhatsThis( i18nc("@info:whatsthis", "<para>How to send email when an email alarm is triggered.<list><item>KMail: The email is sent automatically via <application>KMail</application>. <application>KMail</application> is started first if necessary.</item><item>Sendmail: The email is sent automatically. This option will only work if your system is configured to use <application>sendmail</application> or a sendmail compatible mail transport agent.</item></list></para>") );
addItem( mEmailClientItem, QLatin1String( "EmailClient" ) );
QList<MyPrefs::ItemEnum::Choice2> valuesDefaultReminderUnits;
QList<MyPrefs::ItemEnum::Choice> valuesDefaultReminderUnits;
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("Minutes");
valuesDefaultReminderUnits.append( choice );
}
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("HoursMinutes");
choice.label = i18nc("@option", "Hours/Minutes");
valuesDefaultReminderUnits.append( choice );

View file

@ -23,31 +23,31 @@ Test2::Test2( )
mArchiveFileItem = new MyPrefs::ItemString( currentGroup(), QLatin1String( "Archive File" ), mArchiveFile );
mArchiveFileItem->setLabel( i18n("Archive File") );
addItem( mArchiveFileItem, QLatin1String( "ArchiveFile" ) );
QList<MyPrefs::ItemEnum::Choice2> valuesDestination;
QList<MyPrefs::ItemEnum::Choice> valuesDestination;
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("standardDestination");
valuesDestination.append( choice );
}
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("askDestination");
valuesDestination.append( choice );
}
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("argl1");
choice.label = i18n("Argl1 Label");
valuesDestination.append( choice );
}
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("argl2");
choice.whatsThis = i18n("Argl2 Whatsthis");
valuesDestination.append( choice );
}
{
MyPrefs::ItemEnum::Choice2 choice;
MyPrefs::ItemEnum::Choice choice;
choice.name = QLatin1String("argl3");
choice.label = i18n("Argl3 Label");
choice.whatsThis = i18n("Argl3 Whatsthis");

View file

@ -43,24 +43,24 @@ QColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black };
addItem( itemColor[2], QLatin1String( "Color2" ) );
itemColor[3] = new KConfigSkeleton::ItemColor( currentGroup(), QLatin1String( "color #3" ), mColor[3], defaultColor[3] );
addItem( itemColor[3], QLatin1String( "Color3" ) );
QList<KConfigSkeleton::ItemEnum::Choice2> valuesMouseAction;
QList<KConfigSkeleton::ItemEnum::Choice> valuesMouseAction;
{
KConfigSkeleton::ItemEnum::Choice2 choice;
KConfigSkeleton::ItemEnum::Choice choice;
choice.name = QLatin1String("Encrypt");
valuesMouseAction.append( choice );
}
{
KConfigSkeleton::ItemEnum::Choice2 choice;
KConfigSkeleton::ItemEnum::Choice choice;
choice.name = QLatin1String("Decrypt");
valuesMouseAction.append( choice );
}
{
KConfigSkeleton::ItemEnum::Choice2 choice;
KConfigSkeleton::ItemEnum::Choice choice;
choice.name = QLatin1String("CrashNBurn");
valuesMouseAction.append( choice );
}
{
KConfigSkeleton::ItemEnum::Choice2 choice;
KConfigSkeleton::ItemEnum::Choice choice;
choice.name = QLatin1String("PumpNDump");
valuesMouseAction.append( choice );
}

View file

@ -43,24 +43,24 @@ QColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black };
addItem( itemColor[2], QLatin1String( "Color2" ) );
itemColor[3] = new KConfigSkeleton::ItemColor( currentGroup(), QLatin1String( "color #3" ), mColor[3], defaultColor[3] );
addItem( itemColor[3], QLatin1String( "Color3" ) );
QList<KConfigSkeleton::ItemEnum::Choice2> valuesMouseAction;
QList<KConfigSkeleton::ItemEnum::Choice> valuesMouseAction;
{
KConfigSkeleton::ItemEnum::Choice2 choice;
KConfigSkeleton::ItemEnum::Choice choice;
choice.name = QLatin1String("Encrypt");
valuesMouseAction.append( choice );
}
{
KConfigSkeleton::ItemEnum::Choice2 choice;
KConfigSkeleton::ItemEnum::Choice choice;
choice.name = QLatin1String("Decrypt");
valuesMouseAction.append( choice );
}
{
KConfigSkeleton::ItemEnum::Choice2 choice;
KConfigSkeleton::ItemEnum::Choice choice;
choice.name = QLatin1String("CrashNBurn");
valuesMouseAction.append( choice );
}
{
KConfigSkeleton::ItemEnum::Choice2 choice;
KConfigSkeleton::ItemEnum::Choice choice;
choice.name = QLatin1String("PumpNDump");
valuesMouseAction.append( choice );
}

View file

@ -86,31 +86,31 @@ TestDPointer::TestDPointer( )
d->archiveFileItem = new KConfigSkeleton::ItemString( currentGroup(), QLatin1String( "Archive File" ), d->archiveFile );
d->archiveFileItem->setLabel( i18n("Archive File") );
addItem( d->archiveFileItem, QLatin1String( "ArchiveFile" ) );
QList<KConfigSkeleton::ItemEnum::Choice2> valuesDestination;
QList<KConfigSkeleton::ItemEnum::Choice> valuesDestination;
{
KConfigSkeleton::ItemEnum::Choice2 choice;
KConfigSkeleton::ItemEnum::Choice choice;
choice.name = QLatin1String("standardDestination");
valuesDestination.append( choice );
}
{
KConfigSkeleton::ItemEnum::Choice2 choice;
KConfigSkeleton::ItemEnum::Choice choice;
choice.name = QLatin1String("askDestination");
valuesDestination.append( choice );
}
{
KConfigSkeleton::ItemEnum::Choice2 choice;
KConfigSkeleton::ItemEnum::Choice choice;
choice.name = QLatin1String("argl1");
choice.label = i18n("Argl1 Label");
valuesDestination.append( choice );
}
{
KConfigSkeleton::ItemEnum::Choice2 choice;
KConfigSkeleton::ItemEnum::Choice choice;
choice.name = QLatin1String("argl2");
choice.whatsThis = i18n("Argl2 Whatsthis");
valuesDestination.append( choice );
}
{
KConfigSkeleton::ItemEnum::Choice2 choice;
KConfigSkeleton::ItemEnum::Choice choice;
choice.name = QLatin1String("argl3");
choice.label = i18n("Argl3 Label");
choice.whatsThis = i18n("Argl3 Whatsthis");

View file

@ -58,19 +58,19 @@ public:
colorItem = new ItemColor( currentGroup(), QLatin1String( "Color" ), color, Qt::white );
addItem( colorItem, QLatin1String( "Color" ) );
QList<ItemEnum::Choice2> textValues;
QList<ItemEnum::Choice> textValues;
{
ItemEnum::Choice2 choice;
ItemEnum::Choice choice;
choice.name = QLatin1String("A");
textValues.append( choice );
}
{
ItemEnum::Choice2 choice;
ItemEnum::Choice choice;
choice.name = QLatin1String("B");
textValues.append( choice );
}
{
ItemEnum::Choice2 choice;
ItemEnum::Choice choice;
choice.name = QLatin1String("C");
textValues.append( choice );
}