From 5954a5ce2a841c9c565e91cdad96edb9559edd13 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Mon, 4 Nov 2024 21:04:46 +0800 Subject: [PATCH] 1 --- src/ui/groups_widgets.cc | 9 ++++----- src/ui/groups_widgets.hh | 3 --- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/ui/groups_widgets.cc b/src/ui/groups_widgets.cc index 824e9330..a50612f2 100644 --- a/src/ui/groups_widgets.cc +++ b/src/ui/groups_widgets.cc @@ -648,6 +648,7 @@ int DictGroupsWidget::addNewGroup( QString const & name ) Config::Group newGroup; newGroup.id = nextId++; + newGroup.name = name; const auto gr = new DictGroupWidget( this, *allDicts, newGroup ); const int idx = insertTab( currentIndex() + 1, gr, Utils::escapeAmps( name ) ); @@ -909,15 +910,13 @@ void DictGroupsWidget::groupsByMetadata() addGroupBasedOnMap( groupToDicts ); } - QString DictGroupsWidget::getCurrentGroupName() const { const int current = currentIndex(); if ( current >= 0 ) { - auto w = dynamic_cast< DictGroupWidget & >( *widget( current ) ); - - return w.name(); + auto * w = dynamic_cast< DictGroupWidget * >( widget( current ) ); + return w->name(); } return {}; @@ -928,7 +927,7 @@ void DictGroupsWidget::renameCurrentGroup( QString const & name ) const int current = currentIndex(); if ( current >= 0 ) { - auto w = dynamic_cast< DictGroupWidget & >( *widget( current ) ); + auto * w = dynamic_cast< DictGroupWidget * >( widget( current ) ); w->setName( name ); setTabText( current, Utils::escapeAmps( name ) ); } diff --git a/src/ui/groups_widgets.hh b/src/ui/groups_widgets.hh index 9d4fc099..d41c6c59 100644 --- a/src/ui/groups_widgets.hh +++ b/src/ui/groups_widgets.hh @@ -121,9 +121,6 @@ class DictGroupWidget: public QWidget public: 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; DictListModel * getModel() const