diff --git a/editdictionaries.cc b/editdictionaries.cc index 79b17a32..1da47be7 100644 --- a/editdictionaries.cc +++ b/editdictionaries.cc @@ -11,19 +11,17 @@ using std::vector; EditDictionaries::EditDictionaries( QWidget * parent, Config::Class & cfg_, vector< sptr< Dictionary::Class > > & dictionaries_, - QMap > & dictMap_, Instances::Groups & groupInstances_, QNetworkAccessManager & dictNetMgr_ ): QDialog( parent, Qt::WindowSystemMenuHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint ), cfg( cfg_ ), dictionaries( dictionaries_ ), - dictMap(dictMap_), groupInstances( groupInstances_ ), dictNetMgr( dictNetMgr_ ), origCfg( cfg ), sources( this, cfg ), orderAndProps( new OrderAndProps( this, cfg.dictionaryOrder, cfg.inactiveDictionaries, - dictionaries, dictMap ) ), + dictionaries ) ), groups( new Groups( this, dictionaries, cfg.groups, orderAndProps->getCurrentDictionaryOrder() ) ), dictionariesChanged( false ), groupsChanged( false ), @@ -216,7 +214,7 @@ void EditDictionaries::acceptChangedSources( bool rebuildGroups ) orderAndProps.clear(); loadDictionaries( this, true, cfg, dictionaries, dictNetMgr ); - dictMap = Dictionary::dictToMap(dictionaries); + // If no changes to groups were made, update the original data bool noGroupEdits = ( origCfg.groups == savedGroups ); @@ -241,7 +239,7 @@ void EditDictionaries::acceptChangedSources( bool rebuildGroups ) if ( rebuildGroups ) { - orderAndProps = new OrderAndProps( this, savedOrder, savedInactive, dictionaries, dictMap ); + orderAndProps = new OrderAndProps( this, savedOrder, savedInactive, dictionaries ); groups = new Groups( this, dictionaries, savedGroups, orderAndProps->getCurrentDictionaryOrder() ); ui.tabs->removeTab( 1 ); diff --git a/editdictionaries.hh b/editdictionaries.hh index a2488d95..fe5e93f3 100644 --- a/editdictionaries.hh +++ b/editdictionaries.hh @@ -23,7 +23,6 @@ public: EditDictionaries( QWidget * parent, Config::Class & cfg, std::vector< sptr< Dictionary::Class > > & dictionaries, - QMap > & dictMap_, Instances::Groups & groupInstances, // We only clear those on rescan QNetworkAccessManager & dictNetMgr ); @@ -78,7 +77,6 @@ private: Config::Class & cfg; std::vector< sptr< Dictionary::Class > > & dictionaries; - QMap > & dictMap; Instances::Groups & groupInstances; QNetworkAccessManager & dictNetMgr; diff --git a/groups.cc b/groups.cc index d36b9520..a0b82920 100644 --- a/groups.cc +++ b/groups.cc @@ -20,7 +20,7 @@ Groups::Groups( QWidget * parent, // Populate the dictionaries' list ui.dictionaries->setAsSource(); - ui.dictionaries->populate( Instances::Group( order, Dictionary::dictToMap(dicts), Config::Group() ).dictionaries, + ui.dictionaries->populate( Instances::Group( order, dicts, Config::Group() ).dictionaries, dicts ); ui.searchLine->applyTo( ui.dictionaries ); @@ -87,13 +87,12 @@ void Groups::editGroup( unsigned id ) void Groups::updateDictionaryOrder( Config::Group const & order ) { // Make sure it differs from what we have - auto dictMap = Dictionary::dictToMap( dicts ); - Instances::Group newOrder( order, dictMap, Config::Group() ); + Instances::Group newOrder( order, dicts, Config::Group() ); if( ui.dictionaries->getCurrentDictionaries() != newOrder.dictionaries ) { // Repopulate - ui.dictionaries->populate( Instances::Group( order, dictMap, Config::Group() ).dictionaries, dicts ); + ui.dictionaries->populate( Instances::Group( order, dicts, Config::Group() ).dictionaries, dicts ); } } diff --git a/groups_widgets.cc b/groups_widgets.cc index f1142d0b..35b158ab 100644 --- a/groups_widgets.cc +++ b/groups_widgets.cc @@ -31,8 +31,7 @@ DictGroupWidget::DictGroupWidget( QWidget * parent, groupId( group.id ) { ui.setupUi( this ); - auto dictMap = Dictionary::dictToMap(dicts); - ui.dictionaries->populate( Instances::Group( group, dictMap, Config::Group() ).dictionaries, dicts ); + ui.dictionaries->populate( Instances::Group( group, dicts, Config::Group() ).dictionaries, dicts ); // Populate icons' list @@ -329,7 +328,7 @@ bool DictListModel::setData( QModelIndex const & index, const QVariant & value, g.dictionaries.push_back( Config::DictionaryRef( value.toString(), QString() ) ); - Instances::Group i( g, Dictionary::dictToMap(*allDicts), Config::Group() ); + Instances::Group i( g, *allDicts, Config::Group() ); if ( i.dictionaries.size() == 1 ) { diff --git a/instances.cc b/instances.cc index c39cfe52..69da55d0 100644 --- a/instances.cc +++ b/instances.cc @@ -11,7 +11,7 @@ using std::set; using std::string; Group::Group( Config::Group const & cfgGroup, - QMap > const & allDictionaries, + std::vector< sptr< Dictionary::Class > > const & allDictionaries, Config::Group const & inactiveGroup ): id( cfgGroup.id ), name( cfgGroup.name ), @@ -24,13 +24,15 @@ Group::Group( Config::Group const & cfgGroup, QMap > groupDicts; QVector dictOrderList; + auto dictMap = Dictionary::dictToMap( allDictionaries ); for( unsigned x = 0; x < (unsigned)cfgGroup.dictionaries.size(); ++x ) { std::string id = cfgGroup.dictionaries[ x ].id.toStdString(); - if(allDictionaries.contains(id)){ - groupDicts.insert(id, allDictionaries[ id ] ); + if( dictMap.contains( id ) ) + { + groupDicts.insert( id, dictMap[ id ] ); dictOrderList.push_back(id); } } diff --git a/instances.hh b/instances.hh index 1ce40b18..b47e6348 100644 --- a/instances.hh +++ b/instances.hh @@ -29,7 +29,7 @@ struct Group /// Instantiates the given group from its configuration. If some dictionary /// wasn't found, it just skips it. Group( Config::Group const & cfgGroup, - QMap > const & allDictionaries, + std::vector< sptr< Dictionary::Class > > const & allDictionaries, Config::Group const & inactiveGroup ); /// Creates an empty group. diff --git a/mainwindow.cc b/mainwindow.cc index b122e409..c21e99a7 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -1398,11 +1398,11 @@ void MainWindow::updateGroupList() // Add dictionaryOrder first, as the 'All' group. { - Instances::Group g( cfg.dictionaryOrder, dictMap, Config::Group() ); + Instances::Group g( cfg.dictionaryOrder, dictionaries, Config::Group() ); // Add any missing entries to dictionary order Instances::complementDictionaryOrder( g, - Instances::Group( cfg.inactiveDictionaries, dictMap, Config::Group() ), + Instances::Group( cfg.inactiveDictionaries, dictionaries, Config::Group() ), dictionaries ); g.name = tr( "All" ); @@ -1413,7 +1413,7 @@ void MainWindow::updateGroupList() } for( int x = 0; x < cfg.groups.size(); ++x ) - groupInstances.push_back( Instances::Group( cfg.groups[ x ], dictMap, cfg.inactiveDictionaries ) ); + groupInstances.push_back( Instances::Group( cfg.groups[ x ], dictionaries, cfg.inactiveDictionaries ) ); // Update names for dictionaries that are present, so that they could be // found in case they got moved. @@ -2072,7 +2072,7 @@ void MainWindow::editDictionaries( unsigned editDictionaryGroup ) { // Limit existence of newCfg Config::Class newCfg = cfg; - EditDictionaries dicts( this, newCfg, dictionaries, dictMap, groupInstances, dictNetMgr ); + EditDictionaries dicts( this, newCfg, dictionaries, groupInstances, dictNetMgr ); connect( &dicts, SIGNAL( showDictionaryInfo( QString const & ) ), this, SLOT( showDictionaryInfo( QString const & ) ) ); diff --git a/orderandprops.cc b/orderandprops.cc index 863d596c..cb16548c 100644 --- a/orderandprops.cc +++ b/orderandprops.cc @@ -85,15 +85,12 @@ bool dictLessThan( sptr< Dictionary::Class > const & dict1, OrderAndProps::OrderAndProps( QWidget * parent, Config::Group const & dictionaryOrder, Config::Group const & inactiveDictionaries, - std::vector< sptr< Dictionary::Class > > const & - allDictionaries , - QMap > const & dictMap): + std::vector< sptr< Dictionary::Class > > const & allDictionaries): QWidget( parent ) { ui.setupUi( this ); - - Instances::Group order( dictionaryOrder, dictMap, Config::Group() ); - Instances::Group inactive( inactiveDictionaries, dictMap, Config::Group() ); + Instances::Group order( dictionaryOrder, allDictionaries, Config::Group() ); + Instances::Group inactive( inactiveDictionaries, allDictionaries, Config::Group() ); Instances::complementDictionaryOrder( order, inactive, allDictionaries ); diff --git a/orderandprops.hh b/orderandprops.hh index f7529d1e..9cabcb43 100644 --- a/orderandprops.hh +++ b/orderandprops.hh @@ -16,8 +16,7 @@ public: OrderAndProps( QWidget * parent, Config::Group const & dictionaryOrder, Config::Group const & inactiveDictionaries, - std::vector< sptr< Dictionary::Class > > const & allDictionaries , - QMap > const & dictMap); + std::vector< sptr< Dictionary::Class > > const & allDictionaries); Config::Group getCurrentDictionaryOrder() const; Config::Group getCurrentInactiveDictionaries() const; @@ -35,7 +34,6 @@ private slots: private: Ui::OrderAndProps ui; - void disableDictionaryDescription(); void describeDictionary( DictListWidget *, QModelIndex const & );