From ffd56c73dcff9fe9d61bc43c3aa2eb4dbf5820a2 Mon Sep 17 00:00:00 2001 From: Abs62 Date: Mon, 20 Mar 2017 17:34:42 +0300 Subject: [PATCH] GLS: Show alternate neadwords in headword tooltip --- gls.cc | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/gls.cc b/gls.cc index 70cb6335..bdb4d21e 100644 --- a/gls.cc +++ b/gls.cc @@ -507,7 +507,7 @@ private: /// Loads the article void loadArticleText( uint32_t address, - list< string > & headwords, + vector< string > & headwords, string & articleText ); /// Process resource links (images, audios, etc) @@ -677,7 +677,7 @@ void GlsDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration } void GlsDictionary::loadArticleText( uint32_t address, - list< string > & headwords, + vector< string > & headwords, string & articleText ) { vector< char > chunk; @@ -764,7 +764,7 @@ void GlsDictionary::loadArticle( uint32_t address, string & articleText ) { string articleBody; - list< string > headwords; + vector< string > headwords; loadArticleText( address, headwords, articleBody ); QString article = QString::fromLatin1( "
" ); @@ -774,6 +774,17 @@ void GlsDictionary::loadArticle( uint32_t address, article += "
1 ) + { + QString altHeadwords; + for( vector< string >::size_type i = 1; i < headwords.size(); i++ ) + { + if( i > 1 ) + altHeadwords += ", "; + altHeadwords += QString::fromUtf8( headwords[ i ].c_str(), headwords[ i ].size() ); + } + article += " title=\"" + altHeadwords + "\""; + } article += ">"; headword = headwords.front(); @@ -851,7 +862,7 @@ void GlsDictionary::getArticleText( uint32_t articleAddress, QString & headword, { try { - list< string > headwords; + vector< string > headwords; string articleStr; loadArticleText( articleAddress, headwords, articleStr ); @@ -953,7 +964,7 @@ void GlsHeadwordsRequest::run() } string articleText; - list< string > headwords; + vector< string > headwords; dict.loadArticleText( chain[ x ].articleOffset, headwords, articleText );