1 /* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org> 2 * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ 3 4 #ifndef __EDITDICTIONARIES_HH_INCLUDED__ 5 #define __EDITDICTIONARIES_HH_INCLUDED__ 6 7 #include "dictionary.hh" 8 #include "config.hh" 9 #include "ui_editdictionaries.h" 10 #include "sources.hh" 11 #include "orderandprops.hh" 12 #include "groups.hh" 13 #include "instances.hh" 14 #include "helpwindow.hh" 15 #include <QNetworkAccessManager> 16 #include <QAction> 17 18 class EditDictionaries: public QDialog 19 { 20 Q_OBJECT 21 22 public: 23 24 EditDictionaries( QWidget * parent, Config::Class & cfg, 25 std::vector< sptr< Dictionary::Class > > & dictionaries, 26 Instances::Groups & groupInstances, // We only clear those on rescan 27 QNetworkAccessManager & dictNetMgr ); 28 ~EditDictionaries()29 ~EditDictionaries() 30 { if( helpWindow ) delete helpWindow; } 31 32 /// Instructs the dialog to position itself on editing the given group. 33 void editGroup( unsigned id ); 34 35 /// Returns true if any changes to the 'dictionaries' vector passed were done. areDictionariesChanged() const36 bool areDictionariesChanged() const 37 { return dictionariesChanged; } 38 39 /// Returns true if groups were changed. areGroupsChanged() const40 bool areGroupsChanged() const 41 { return groupsChanged; } 42 43 protected: 44 45 virtual void accept(); 46 47 private slots: 48 49 void on_tabs_currentChanged( int index ); 50 51 void buttonBoxClicked( QAbstractButton * button ); 52 53 void rescanSources(); 54 55 void helpRequested(); 56 void closeHelp(); 57 58 signals: 59 60 void showDictionaryInfo( QString const & dictId ); 61 62 void showDictionaryHeadwords( QString const & dictId ); 63 64 private: 65 66 bool isSourcesChanged() const; 67 68 void acceptChangedSources( bool rebuildGroups ); 69 70 void save(); 71 72 private: 73 74 Config::Class & cfg; 75 std::vector< sptr< Dictionary::Class > > & dictionaries; 76 Instances::Groups & groupInstances; 77 QNetworkAccessManager & dictNetMgr; 78 79 // Backed up to decide later if something was changed or not 80 Config::Class origCfg; 81 82 Ui::EditDictionaries ui; 83 Sources sources; 84 sptr< OrderAndProps > orderAndProps; 85 sptr< Groups > groups; 86 87 bool dictionariesChanged; 88 bool groupsChanged; 89 90 int lastCurrentTab; 91 92 Help::HelpWindow * helpWindow; 93 QAction helpAction; 94 }; 95 96 #endif 97