mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Merge 3c5233f2a1
into 0c42c300e1
This commit is contained in:
commit
c85dd66637
|
@ -224,7 +224,7 @@ void loadDictionaries( QWidget * parent,
|
||||||
|
|
||||||
loadDicts.wait();
|
loadDicts.wait();
|
||||||
|
|
||||||
if ( loadDicts.getExceptionText().size() ) {
|
if ( !loadDicts.getExceptionText().empty() ) {
|
||||||
QMessageBox::critical( parent,
|
QMessageBox::critical( parent,
|
||||||
QCoreApplication::translate( "LoadDictionaries", "Error loading dictionaries" ),
|
QCoreApplication::translate( "LoadDictionaries", "Error loading dictionaries" ),
|
||||||
QString::fromUtf8( loadDicts.getExceptionText().c_str() ) );
|
QString::fromUtf8( loadDicts.getExceptionText().c_str() ) );
|
||||||
|
|
|
@ -204,26 +204,11 @@ void EditDictionaries::acceptChangedSources( bool rebuildGroups )
|
||||||
// Those hold pointers to dictionaries, we need to free them.
|
// Those hold pointers to dictionaries, we need to free them.
|
||||||
groupInstances.clear();
|
groupInstances.clear();
|
||||||
|
|
||||||
groups.clear();
|
|
||||||
orderAndProps.clear();
|
|
||||||
|
|
||||||
loadDictionaries( this, cfg, dictionaries, dictNetMgr );
|
loadDictionaries( this, cfg, dictionaries, dictNetMgr );
|
||||||
|
|
||||||
Instances::updateNames( savedGroups, dictionaries );
|
|
||||||
Instances::updateNames( savedOrder, dictionaries );
|
|
||||||
Instances::updateNames( savedInactive, dictionaries );
|
|
||||||
|
|
||||||
if ( rebuildGroups ) {
|
if ( rebuildGroups ) {
|
||||||
ui.tabs->removeTab( 1 );
|
orderAndProps->rebuild( savedOrder, savedInactive, dictionaries );
|
||||||
ui.tabs->removeTab( 1 );
|
groups->rebuild( dictionaries, savedGroups, orderAndProps->getCurrentDictionaryOrder() );
|
||||||
|
|
||||||
orderAndProps = new OrderAndProps( this, savedOrder, savedInactive, dictionaries );
|
|
||||||
groups = new Groups( this, dictionaries, savedGroups, orderAndProps->getCurrentDictionaryOrder() );
|
|
||||||
|
|
||||||
ui.tabs->insertTab( 1, orderAndProps, QIcon( ":/icons/book.svg" ), tr( "&Dictionaries" ) );
|
|
||||||
ui.tabs->insertTab( 2, groups, QIcon( ":/icons/bookcase.svg" ), tr( "&Groups" ) );
|
|
||||||
connect( groups, &Groups::showDictionaryInfo, this, &EditDictionaries::showDictionaryInfo );
|
|
||||||
connect( orderAndProps, &OrderAndProps::showDictionaryHeadwords, this, &EditDictionaries::showDictionaryHeadwords );
|
|
||||||
}
|
}
|
||||||
setUpdatesEnabled( true );
|
setUpdatesEnabled( true );
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,24 @@ Groups::Groups( QWidget * parent,
|
||||||
countChanged();
|
countChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Groups::rebuild( vector< sptr< Dictionary::Class > > const & dicts_,
|
||||||
|
Config::Groups const & groups_,
|
||||||
|
Config::Group const & order )
|
||||||
|
{
|
||||||
|
this->setUpdatesEnabled( false );
|
||||||
|
dicts = dicts_;
|
||||||
|
groups = groups_;
|
||||||
|
|
||||||
|
ui.dictionaries->setAsSource();
|
||||||
|
ui.dictionaries->populate( Instances::Group( order, dicts, Config::Group() ).dictionaries, dicts );
|
||||||
|
|
||||||
|
// Populate groups' widget
|
||||||
|
ui.groups->populate( groups, dicts, ui.dictionaries->getCurrentDictionaries() );
|
||||||
|
|
||||||
|
countChanged();
|
||||||
|
this->setUpdatesEnabled( true );
|
||||||
|
}
|
||||||
|
|
||||||
void Groups::editGroup( unsigned id )
|
void Groups::editGroup( unsigned id )
|
||||||
{
|
{
|
||||||
for ( int x = 0; x < groups.size(); ++x ) {
|
for ( int x = 0; x < groups.size(); ++x ) {
|
||||||
|
|
|
@ -18,7 +18,9 @@ public:
|
||||||
std::vector< sptr< Dictionary::Class > > const &,
|
std::vector< sptr< Dictionary::Class > > const &,
|
||||||
Config::Groups const &,
|
Config::Groups const &,
|
||||||
Config::Group const & order );
|
Config::Group const & order );
|
||||||
|
void rebuild( std::vector< sptr< Dictionary::Class > > const & dicts_,
|
||||||
|
Config::Groups const & groups_,
|
||||||
|
Config::Group const & order );
|
||||||
/// Instructs the dialog to position itself on editing the given group.
|
/// Instructs the dialog to position itself on editing the given group.
|
||||||
void editGroup( unsigned id );
|
void editGroup( unsigned id );
|
||||||
|
|
||||||
|
@ -31,7 +33,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Groups ui;
|
Ui::Groups ui;
|
||||||
std::vector< sptr< Dictionary::Class > > const & dicts;
|
std::vector< sptr< Dictionary::Class > > dicts;
|
||||||
Config::Groups groups;
|
Config::Groups groups;
|
||||||
|
|
||||||
QToolButton * groupsListButton;
|
QToolButton * groupsListButton;
|
||||||
|
|
|
@ -133,6 +133,25 @@ OrderAndProps::OrderAndProps( QWidget * parent,
|
||||||
showDictNumbers();
|
showDictNumbers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OrderAndProps::rebuild( Config::Group const & dictionaryOrder,
|
||||||
|
Config::Group const & inactiveDictionaries,
|
||||||
|
std::vector< sptr< Dictionary::Class > > const & allDictionaries )
|
||||||
|
{
|
||||||
|
Instances::Group order( dictionaryOrder, allDictionaries, Config::Group() );
|
||||||
|
Instances::Group inactive( inactiveDictionaries, allDictionaries, Config::Group() );
|
||||||
|
|
||||||
|
Instances::complementDictionaryOrder( order, inactive, allDictionaries );
|
||||||
|
|
||||||
|
setUpdatesEnabled( false );
|
||||||
|
ui.dictionaryOrder->populate( order.dictionaries, allDictionaries );
|
||||||
|
ui.inactiveDictionaries->populate( inactive.dictionaries, allDictionaries );
|
||||||
|
|
||||||
|
disableDictionaryDescription();
|
||||||
|
|
||||||
|
showDictNumbers();
|
||||||
|
setUpdatesEnabled( true );
|
||||||
|
}
|
||||||
|
|
||||||
Config::Group OrderAndProps::getCurrentDictionaryOrder() const
|
Config::Group OrderAndProps::getCurrentDictionaryOrder() const
|
||||||
{
|
{
|
||||||
Instances::Group g;
|
Instances::Group g;
|
||||||
|
|
|
@ -17,7 +17,9 @@ public:
|
||||||
Config::Group const & dictionaryOrder,
|
Config::Group const & dictionaryOrder,
|
||||||
Config::Group const & inactiveDictionaries,
|
Config::Group const & inactiveDictionaries,
|
||||||
std::vector< sptr< Dictionary::Class > > const & allDictionaries );
|
std::vector< sptr< Dictionary::Class > > const & allDictionaries );
|
||||||
|
void rebuild( Config::Group const & dictionaryOrder,
|
||||||
|
Config::Group const & inactiveDictionaries,
|
||||||
|
std::vector< sptr< Dictionary::Class > > const & allDictionaries );
|
||||||
Config::Group getCurrentDictionaryOrder() const;
|
Config::Group getCurrentDictionaryOrder() const;
|
||||||
Config::Group getCurrentInactiveDictionaries() const;
|
Config::Group getCurrentInactiveDictionaries() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue