~neon/kiten/master

« back to all changes in this revision

Viewing changes to app/configdictionaryselector.cpp

  • Committer: Frédéric Brière
  • Date: 2021-01-20 03:56:48 UTC
  • Revision ID: git-v1:b69648d093c43792d2c5d8089ad8931e73d4e475
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.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
  QStringList names;
33
33
 
34
34
  QString groupName = "dicts_" + _dictName;
35
 
  _config->setCurrentGroup( groupName );
 
35
  KConfigGroup group = _config->config()->group( groupName );
36
36
  KConfigSkeletonItem *item = _config->findItem( _dictName + "__NAMES" );
37
37
  if( item != nullptr )
38
38
  {
39
39
    names = item->property().toStringList();
40
40
  }
41
41
 
42
 
  foreach( const QString &it, names )
43
 
  {
44
 
    QString name = _dictName + '_' + it;
45
 
    if ( ! _config->findItem( name ) )
46
 
    {
47
 
      _config->addItem( new KConfigSkeleton::ItemString( groupName, it, *new QString() ), name );
48
 
      //Don't touch the *new QString()... that's a reference for a reason... stupid KDE
49
 
    }
50
 
  }
51
 
 
52
 
  _config->load();
53
42
  fileList->clear();
54
43
 
55
44
  foreach( const QString &it, names )
56
45
  {
57
46
    QStringList newRow( it );
58
 
    newRow << _config->findItem( _dictName + '_' + it )->property().toString();
 
47
    newRow << group.readEntry( it, QString() );
59
48
    (void) new QTreeWidgetItem( fileList, newRow );
60
49
  }
61
50
}
73
62
    QString dictionaryPath = it->text( 1 );
74
63
    names.append( dictionaryName );
75
64
 
76
 
    if ( ! group.hasKey( dictionaryName ) )
77
 
    {
78
 
      KConfigSkeletonItem *item = new KConfigSkeleton::ItemPath( group.name()
79
 
                                                , dictionaryName, *new QString() );
80
 
      _config->addItem( item, dictionaryName );
81
 
    }
82
65
    group.writeEntry( dictionaryName, dictionaryPath );
83
66
  }
84
67