From 743258b438783a2000ad98019c343e3945fafd96 Mon Sep 17 00:00:00 2001 From: Konstantin Isakov Date: Tue, 5 May 2009 08:57:37 +0000 Subject: [PATCH] + Add a 'Rescan now' button in Sources. --- src/editdictionaries.cc | 25 +++++++++++++++---------- src/editdictionaries.hh | 2 ++ src/sources.cc | 6 ++++++ src/sources.hh | 7 +++++++ src/sources.ui | 7 +++++++ 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/editdictionaries.cc b/src/editdictionaries.cc index 581c8ca6..d53be392 100644 --- a/src/editdictionaries.cc +++ b/src/editdictionaries.cc @@ -27,12 +27,15 @@ EditDictionaries::EditDictionaries( QWidget * parent, Config::Class & cfg_, ui.tabs->addTab( &sources, QIcon(":/icons/book.png"), tr( "&Sources" ) ); ui.tabs->addTab( groups.get(), QIcon(":/icons/bookcase.png"), tr( "&Groups" ) ); + + connect( &sources, SIGNAL( rescan() ), this, SLOT( rescanSources() ) ); } void EditDictionaries::accept() { - acceptChangedSources(); + if ( isSourcesChanged() ) + acceptChangedSources(); Config::Groups newGroups = groups->getGroups(); @@ -99,6 +102,11 @@ void EditDictionaries::on_tabs_currentChanged( int index ) lastCurrentTab = index; } +void EditDictionaries::rescanSources() +{ + acceptChangedSources(); +} + bool EditDictionaries::isSourcesChanged() const { return sources.getPaths() != cfg.paths || @@ -109,15 +117,12 @@ bool EditDictionaries::isSourcesChanged() const void EditDictionaries::acceptChangedSources() { - if ( isSourcesChanged() ) - { - dictionariesChanged = true; + dictionariesChanged = true; - cfg.paths = sources.getPaths(); - cfg.soundDirs = sources.getSoundDirs(); - cfg.hunspell = sources.getHunspell(); - cfg.mediawikis = sources.getMediaWikis(); + cfg.paths = sources.getPaths(); + cfg.soundDirs = sources.getSoundDirs(); + cfg.hunspell = sources.getHunspell(); + cfg.mediawikis = sources.getMediaWikis(); - loadDictionaries( this, true, cfg, dictionaries, dictNetMgr ); - } + loadDictionaries( this, true, cfg, dictionaries, dictNetMgr ); } diff --git a/src/editdictionaries.hh b/src/editdictionaries.hh index 3c87e0d6..b5ed579a 100644 --- a/src/editdictionaries.hh +++ b/src/editdictionaries.hh @@ -37,6 +37,8 @@ private slots: void on_tabs_currentChanged( int index ); + void rescanSources(); + private: bool isSourcesChanged() const; diff --git a/src/sources.cc b/src/sources.cc index aa21e4a3..a9ea7890 100644 --- a/src/sources.cc +++ b/src/sources.cc @@ -648,3 +648,9 @@ bool HunspellDictsModel::setData( QModelIndex const & index, const QVariant & /* return false; } + +void Sources::on_rescan_clicked() +{ + emit rescan(); +} + diff --git a/src/sources.hh b/src/sources.hh index 939dc0d4..f092829a 100644 --- a/src/sources.hh +++ b/src/sources.hh @@ -151,6 +151,11 @@ public: Config::Hunspell getHunspell() const; +signals: + + /// Emitted when a 'Rescan' button is clicked. + void rescan(); + private: Ui::Sources ui; MediaWikisModel mediawikisModel; @@ -174,6 +179,8 @@ private slots: void on_addMediaWiki_clicked(); void on_removeMediaWiki_clicked(); + + void on_rescan_clicked(); }; #endif diff --git a/src/sources.ui b/src/sources.ui index a707ccf8..7eedf925 100644 --- a/src/sources.ui +++ b/src/sources.ui @@ -75,6 +75,13 @@ + + + + Re&scan now + + +