mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
opt:remove dictMap parameter
This commit is contained in:
parent
6b15f5d466
commit
5322a6bc56
|
@ -11,19 +11,17 @@ using std::vector;
|
|||
|
||||
EditDictionaries::EditDictionaries( QWidget * parent, Config::Class & cfg_,
|
||||
vector< sptr< Dictionary::Class > > & dictionaries_,
|
||||
QMap<std::string, sptr< Dictionary::Class > > & 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 );
|
||||
|
|
|
@ -23,7 +23,6 @@ public:
|
|||
|
||||
EditDictionaries( QWidget * parent, Config::Class & cfg,
|
||||
std::vector< sptr< Dictionary::Class > > & dictionaries,
|
||||
QMap<std::string, sptr< Dictionary::Class > > & 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<std::string, sptr< Dictionary::Class > > & dictMap;
|
||||
Instances::Groups & groupInstances;
|
||||
QNetworkAccessManager & dictNetMgr;
|
||||
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ using std::set;
|
|||
using std::string;
|
||||
|
||||
Group::Group( Config::Group const & cfgGroup,
|
||||
QMap<std::string, sptr< Dictionary::Class > > 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<string, sptr< Dictionary::Class > > groupDicts;
|
||||
QVector<string> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<std::string, sptr< Dictionary::Class > > const & allDictionaries,
|
||||
std::vector< sptr< Dictionary::Class > > const & allDictionaries,
|
||||
Config::Group const & inactiveGroup );
|
||||
|
||||
/// Creates an empty group.
|
||||
|
|
|
@ -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 & ) ) );
|
||||
|
|
|
@ -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<std::string, sptr< Dictionary::Class > > 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 );
|
||||
|
||||
|
|
|
@ -16,8 +16,7 @@ public:
|
|||
|
||||
OrderAndProps( QWidget * parent, Config::Group const & dictionaryOrder,
|
||||
Config::Group const & inactiveDictionaries,
|
||||
std::vector< sptr< Dictionary::Class > > const & allDictionaries ,
|
||||
QMap<std::string, sptr< Dictionary::Class > > 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 & );
|
||||
|
||||
|
|
Loading…
Reference in a new issue