mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
fix: duplicated entries in epwing dictionary
This commit is contained in:
parent
f07ba75a5c
commit
efb4a84da2
|
@ -44,7 +44,7 @@ namespace {
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
Signature = 0x58575045, // EPWX on little-endian, XWPE on big-endian
|
Signature = 0x58575045, // EPWX on little-endian, XWPE on big-endian
|
||||||
CurrentFormatVersion = 5 + BtreeIndexing::FormatVersion + Folding::Version
|
CurrentFormatVersion = 6 + BtreeIndexing::FormatVersion + Folding::Version
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IdxHeader
|
struct IdxHeader
|
||||||
|
|
|
@ -846,7 +846,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 )
|
||||||
|
@ -877,13 +877,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -939,14 +951,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,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