Skip to content

Commit

Permalink
opt:favorite global data structure adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyifang committed Feb 19, 2025
1 parent 7f9a23f commit 42161e2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/common/globalbroadcaster.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public:
QString translateLineText{};
//hold the dictionary id;
QSet< QString > collapsedDicts;
//key hold the headword, value holds the folders.
QMap< QString, QSet< QString > > folderFavoritesMap;
QMap< unsigned, QString > groupFolderMap;
PronounceEngine pronounce_engine;
Expand Down
6 changes: 3 additions & 3 deletions src/ui/favoritespanewidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,12 @@ void FavoritesPaneWidget::clearAllItems()
void FavoritesPaneWidget::addHeadword( QString const & path, QString const & headword )
{
m_favoritesModel->addNewHeadword( path, headword );
GlobalBroadcaster::instance()->folderFavoritesMap[ path ].insert( headword );
GlobalBroadcaster::instance()->folderFavoritesMap[ headword ].insert( path );
}

bool FavoritesPaneWidget::removeHeadword( QString const & path, QString const & headword )
{
GlobalBroadcaster::instance()->folderFavoritesMap[ path ].remove( headword );
GlobalBroadcaster::instance()->folderFavoritesMap[ headword ].remove( path );

return m_favoritesModel->removeHeadword( path, headword );
}
Expand Down Expand Up @@ -761,7 +761,7 @@ void FavoritesModel::addFolder( TreeItem * parent, QDomNode & node )
}
parent->appendChild( new TreeItem( word, parent, TreeItem::Word ) );

GlobalBroadcaster::instance()->folderFavoritesMap[ parent->data().toString() ].insert( word );
GlobalBroadcaster::instance()->folderFavoritesMap[ word ].insert( parent->data().toString() );
}
}
dirty = true;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/scanpopup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ bool ScanPopup::isWordPresentedInFavorites( QString const & word, unsigned group
{
QString folder = GlobalBroadcaster::instance()->groupFolderMap[ groupId ];

return GlobalBroadcaster::instance()->folderFavoritesMap[ folder ].contains( word );
return GlobalBroadcaster::instance()->folderFavoritesMap[ word ].contains( folder );
}

#ifdef HAVE_X11
Expand Down

0 comments on commit 42161e2

Please sign in to comment.