*! Another fix to complete the previous commit.

This commit is contained in:
Konstantin Isakov 2009-05-15 12:39:53 +00:00
parent 2a81429d0a
commit 91c97256d3
2 changed files with 20 additions and 25 deletions

View file

@ -37,11 +37,11 @@ EditDictionaries::EditDictionaries( QWidget * parent, Config::Class & cfg_,
void EditDictionaries::accept()
{
if ( isSourcesChanged() )
acceptChangedSources();
Config::Groups newGroups = groups->getGroups();
if ( isSourcesChanged() )
acceptChangedSources( false );
if ( origCfg.groups != newGroups )
{
groupsChanged = true;
@ -77,11 +77,7 @@ void EditDictionaries::on_tabs_currentChanged( int index )
if ( question.clickedButton() == accept )
{
acceptChangedSources();
// Rebuild groups from scratch
rebuildGroups();
acceptChangedSources( true );
lastCurrentTab = index;
ui.tabs->setCurrentIndex( index );
@ -100,8 +96,7 @@ void EditDictionaries::on_tabs_currentChanged( int index )
void EditDictionaries::rescanSources()
{
acceptChangedSources();
rebuildGroups();
acceptChangedSources( true );
}
bool EditDictionaries::isSourcesChanged() const
@ -113,10 +108,12 @@ bool EditDictionaries::isSourcesChanged() const
sources.getMediaWikis() != cfg.mediawikis;
}
void EditDictionaries::acceptChangedSources()
void EditDictionaries::acceptChangedSources( bool rebuildGroups )
{
dictionariesChanged = true;
Config::Groups savedGroups = groups->getGroups();
cfg.paths = sources.getPaths();
cfg.soundDirs = sources.getSoundDirs();
cfg.hunspell = sources.getHunspell();
@ -126,17 +123,17 @@ void EditDictionaries::acceptChangedSources()
groupInstances.clear(); // Those hold pointers to dictionaries, we need to
// free them.
loadDictionaries( this, true, cfg, dictionaries, dictNetMgr );
}
void EditDictionaries::rebuildGroups()
{
Config::Groups savedGroups = groups->getGroups();
ui.tabs->setUpdatesEnabled( false );
ui.tabs->removeTab( 1 );
groups.reset();
groups = new Groups( this, dictionaries, savedGroups );
ui.tabs->insertTab( 1, groups.get(), QIcon(":/icons/bookcase.png"), tr( "&Groups" ) );
ui.tabs->setUpdatesEnabled( true );
loadDictionaries( this, true, cfg, dictionaries, dictNetMgr );
if ( rebuildGroups )
{
groups = new Groups( this, dictionaries, savedGroups );
ui.tabs->insertTab( 1, groups.get(), QIcon(":/icons/bookcase.png"), tr( "&Groups" ) );
ui.tabs->setUpdatesEnabled( true );
}
}

View file

@ -45,9 +45,7 @@ private:
bool isSourcesChanged() const;
void acceptChangedSources();
void rebuildGroups();
void acceptChangedSources( bool rebuildGroups );
private: