Commit b69648d0 authored by Frédéric Brière's avatar Frédéric Brière
Browse files

Stop creating config items for dictionaries

Creating a config item at runtime for each dictionary is not only
needlessly complex, but also deceiving; config items usually act as a
convenient shortcut (thanks to their unique name that doesn't require
messing around with groups), but the items added here are only available
to others *if* the configure dialog has been displayed beforehand.
parent 59979083
...@@ -32,30 +32,19 @@ void ConfigDictionarySelector::updateWidgets() ...@@ -32,30 +32,19 @@ void ConfigDictionarySelector::updateWidgets()
QStringList names; QStringList names;
QString groupName = "dicts_" + _dictName; QString groupName = "dicts_" + _dictName;
_config->setCurrentGroup( groupName ); KConfigGroup group = _config->config()->group( groupName );
KConfigSkeletonItem *item = _config->findItem( _dictName + "__NAMES" ); KConfigSkeletonItem *item = _config->findItem( _dictName + "__NAMES" );
if( item != nullptr ) if( item != nullptr )
{ {
names = item->property().toStringList(); names = item->property().toStringList();
} }
foreach( const QString &it, names )
{
QString name = _dictName + '_' + it;
if ( ! _config->findItem( name ) )
{
_config->addItem( new KConfigSkeleton::ItemString( groupName, it, *new QString() ), name );
//Don't touch the *new QString()... that's a reference for a reason... stupid KDE
}
}
_config->load();
fileList->clear(); fileList->clear();
foreach( const QString &it, names ) foreach( const QString &it, names )
{ {
QStringList newRow( it ); QStringList newRow( it );
newRow << _config->findItem( _dictName + '_' + it )->property().toString(); newRow << group.readEntry( it, QString() );
(void) new QTreeWidgetItem( fileList, newRow ); (void) new QTreeWidgetItem( fileList, newRow );
} }
} }
...@@ -73,12 +62,6 @@ void ConfigDictionarySelector::updateSettings() ...@@ -73,12 +62,6 @@ void ConfigDictionarySelector::updateSettings()
QString dictionaryPath = it->text( 1 ); QString dictionaryPath = it->text( 1 );
names.append( dictionaryName ); names.append( dictionaryName );
if ( ! group.hasKey( dictionaryName ) )
{
KConfigSkeletonItem *item = new KConfigSkeleton::ItemPath( group.name()
, dictionaryName, *new QString() );
_config->addItem( item, dictionaryName );
}
group.writeEntry( dictionaryName, dictionaryPath ); group.writeEntry( dictionaryName, dictionaryPath );
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment