mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Merge branch 'fix/epwing-duplicate-entry' into staged
This commit is contained in:
commit
2ffd4940d0
|
@ -1054,7 +1054,8 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
||||||
|
|
||||||
for( ; ; )
|
for( ; ; )
|
||||||
{
|
{
|
||||||
if( !head.headword.isEmpty() )
|
//skip too long headword
|
||||||
|
if( !head.headword.isEmpty() && head.headword.size() < 30 )
|
||||||
{
|
{
|
||||||
uint32_t offset = chunks.startNewBlock();
|
uint32_t offset = chunks.startNewBlock();
|
||||||
chunks.addToBlock( &head.page, sizeof( head.page ) );
|
chunks.addToBlock( &head.page, sizeof( head.page ) );
|
||||||
|
|
|
@ -850,7 +850,7 @@ void EpwingBook::getFirstHeadword( EpwingHeadword & head )
|
||||||
fixHeadword( head.headword );
|
fixHeadword( head.headword );
|
||||||
|
|
||||||
EWPos epos( pos.page, pos.offset );
|
EWPos epos( pos.page, pos.offset );
|
||||||
allHeadwordPositions[ head.headword ] = epos;
|
allHeadwordPositions[ head.headword ] << epos;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EpwingBook::getNextHeadword( EpwingHeadword & head )
|
bool EpwingBook::getNextHeadword( EpwingHeadword & head )
|
||||||
|
@ -881,13 +881,25 @@ bool EpwingBook::getNextHeadword( EpwingHeadword & head )
|
||||||
|
|
||||||
if( allHeadwordPositions.contains( head.headword ) )
|
if( allHeadwordPositions.contains( head.headword ) )
|
||||||
{
|
{
|
||||||
EWPos epos = allHeadwordPositions[ head.headword ];
|
// existed position
|
||||||
if( pos.page != epos.first || abs( pos.offset - epos.second ) > 4 )
|
bool existed = false;
|
||||||
|
foreach( EWPos epos, allHeadwordPositions[ head.headword ] )
|
||||||
|
{
|
||||||
|
if( pos.page == epos.first && abs( pos.offset - epos.second ) <= 4 )
|
||||||
|
{
|
||||||
|
existed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( !existed )
|
||||||
|
{
|
||||||
|
allHeadwordPositions[ head.headword ] << EWPos( pos.page, pos.offset );
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
allHeadwordPositions[ head.headword ] = EWPos( pos.page, pos.offset );
|
allHeadwordPositions[ head.headword ]<<EWPos( pos.page, pos.offset );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -943,14 +955,26 @@ bool EpwingBook::getNextHeadword( EpwingHeadword & head )
|
||||||
|
|
||||||
if( allHeadwordPositions.contains( head.headword ) )
|
if( allHeadwordPositions.contains( head.headword ) )
|
||||||
{
|
{
|
||||||
EWPos epos = allHeadwordPositions[ head.headword ];
|
// existed position
|
||||||
if( pos.page != epos.first || abs( pos.offset - epos.second ) > 4 )
|
bool existed = false;
|
||||||
break;
|
foreach( EWPos epos, allHeadwordPositions[ head.headword ] )
|
||||||
|
{
|
||||||
|
if( pos.page == epos.first && abs( pos.offset - epos.second ) <= 4 )
|
||||||
|
{
|
||||||
|
existed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( !existed )
|
||||||
|
{
|
||||||
|
allHeadwordPositions[ head.headword ] << EWPos( pos.page, pos.offset );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
allHeadwordPositions[ head.headword ] = EWPos( pos.page, pos.offset );
|
allHeadwordPositions[ head.headword ]<<EWPos( pos.page, pos.offset );
|
||||||
break;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ class EpwingBook
|
||||||
QStringList imageCacheList, soundsCacheList, moviesCacheList, fontsCacheList;
|
QStringList imageCacheList, soundsCacheList, moviesCacheList, fontsCacheList;
|
||||||
QMap< QString, QString > baseFontsMap, customFontsMap;
|
QMap< QString, QString > baseFontsMap, customFontsMap;
|
||||||
QVector< int > refPages, refOffsets;
|
QVector< int > refPages, refOffsets;
|
||||||
QMap< QString, EWPos > allHeadwordPositions;
|
QMap< QString, QList<EWPos> > allHeadwordPositions;
|
||||||
QVector< EWPos > LinksQueue;
|
QVector< EWPos > LinksQueue;
|
||||||
int refOpenCount, refCloseCount;
|
int refOpenCount, refCloseCount;
|
||||||
static Mutex libMutex;
|
static Mutex libMutex;
|
||||||
|
|
Loading…
Reference in a new issue