This commit is contained in:
YiFang Xiao 2024-11-04 21:04:46 +08:00 committed by xiaoyifang
parent 5ef4190b75
commit 5954a5ce2a
2 changed files with 4 additions and 8 deletions

View file

@ -648,6 +648,7 @@ int DictGroupsWidget::addNewGroup( QString const & name )
Config::Group newGroup; Config::Group newGroup;
newGroup.id = nextId++; newGroup.id = nextId++;
newGroup.name = name;
const auto gr = new DictGroupWidget( this, *allDicts, newGroup ); const auto gr = new DictGroupWidget( this, *allDicts, newGroup );
const int idx = insertTab( currentIndex() + 1, gr, Utils::escapeAmps( name ) ); const int idx = insertTab( currentIndex() + 1, gr, Utils::escapeAmps( name ) );
@ -909,15 +910,13 @@ void DictGroupsWidget::groupsByMetadata()
addGroupBasedOnMap( groupToDicts ); addGroupBasedOnMap( groupToDicts );
} }
QString DictGroupsWidget::getCurrentGroupName() const QString DictGroupsWidget::getCurrentGroupName() const
{ {
const int current = currentIndex(); const int current = currentIndex();
if ( current >= 0 ) { if ( current >= 0 ) {
auto w = dynamic_cast< DictGroupWidget & >( *widget( current ) ); auto * w = dynamic_cast< DictGroupWidget * >( widget( current ) );
return w->name();
return w.name();
} }
return {}; return {};
@ -928,7 +927,7 @@ void DictGroupsWidget::renameCurrentGroup( QString const & name )
const int current = currentIndex(); const int current = currentIndex();
if ( current >= 0 ) { if ( current >= 0 ) {
auto w = dynamic_cast< DictGroupWidget & >( *widget( current ) ); auto * w = dynamic_cast< DictGroupWidget * >( widget( current ) );
w->setName( name ); w->setName( name );
setTabText( current, Utils::escapeAmps( name ) ); setTabText( current, Utils::escapeAmps( name ) );
} }

View file

@ -121,9 +121,6 @@ class DictGroupWidget: public QWidget
public: public:
DictGroupWidget( QWidget * parent, std::vector< sptr< Dictionary::Class > > const &, Config::Group const & ); DictGroupWidget( QWidget * parent, std::vector< sptr< Dictionary::Class > > const &, Config::Group const & );
/// Makes the group's configuration out of the data currently held.
/// Since the group's name is not part of the widget by design right now
/// (it is known by the containing tab widget only), it is returned as empty.
Config::Group makeGroup() const; Config::Group makeGroup() const;
DictListModel * getModel() const DictListModel * getModel() const