mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 08:34:08 +00:00
Merge branch 'staged' into dev
This commit is contained in:
commit
49fab235b9
|
@ -131,22 +131,11 @@ using std::string;
|
||||||
emit errorOccurred( code );
|
emit errorOccurred( code );
|
||||||
}
|
}
|
||||||
|
|
||||||
// void AllowFrameReply::readDataFromBase()
|
|
||||||
// {
|
|
||||||
//// QByteArray data;
|
|
||||||
//// data.resize( baseReply->bytesAvailable() );
|
|
||||||
//// baseReply->read( data.data(), data.size() );
|
|
||||||
//// buffer += data;
|
|
||||||
// emit readyRead();
|
|
||||||
// }
|
|
||||||
|
|
||||||
qint64 AllowFrameReply::readData( char * data, qint64 maxSize )
|
qint64 AllowFrameReply::readData( char * data, qint64 maxSize )
|
||||||
{
|
{
|
||||||
auto bytesAvailable= baseReply->bytesAvailable();
|
auto bytesAvailable= baseReply->bytesAvailable();
|
||||||
qint64 size = qMin( maxSize, bytesAvailable );
|
qint64 size = qMin( maxSize, bytesAvailable );
|
||||||
baseReply->read( data, size );
|
baseReply->read( data, size );
|
||||||
// memcpy( data, buffer.data(), size );
|
|
||||||
// buffer.remove( 0, size );
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2570,11 +2570,9 @@ void ArticleView::highlightFTSResults()
|
||||||
if( ftsSearchMatchCase )
|
if( ftsSearchMatchCase )
|
||||||
flags |= QWebEnginePage::FindCaseSensitively;
|
flags |= QWebEnginePage::FindCaseSensitively;
|
||||||
|
|
||||||
for( int x = 0; x < allMatches.size(); x++ )
|
|
||||||
ui.definition->findText( allMatches.at( x ), flags );
|
|
||||||
|
|
||||||
if( !allMatches.isEmpty() )
|
if( !allMatches.isEmpty() )
|
||||||
{
|
{
|
||||||
|
highlightAllFtsOccurences( flags );
|
||||||
ui.definition->findText( allMatches.at( 0 ), flags );
|
ui.definition->findText( allMatches.at( 0 ), flags );
|
||||||
// if( ui.definition->findText( allMatches.at( 0 ), flags ) )
|
// if( ui.definition->findText( allMatches.at( 0 ), flags ) )
|
||||||
{
|
{
|
||||||
|
@ -2591,6 +2589,25 @@ void ArticleView::highlightFTSResults()
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArticleView::highlightAllFtsOccurences( QWebEnginePage::FindFlags flags )
|
||||||
|
{
|
||||||
|
// Usually allMatches contains mostly duplicates. Thus searching for each element of
|
||||||
|
// allMatches to highlight them takes a long time => collect unique elements into a
|
||||||
|
// set and search for them instead.
|
||||||
|
// Don't use QList::toSet() or QSet's range constructor because they reserve space
|
||||||
|
// for QList::size() elements, whereas the final QSet size is likely 1 or 2.
|
||||||
|
QSet< QString > uniqueMatches;
|
||||||
|
for( int x = 0; x < allMatches.size(); ++x )
|
||||||
|
{
|
||||||
|
QString const & match = allMatches.at( x );
|
||||||
|
// Consider words that differ only in case equal if the search is case-insensitive.
|
||||||
|
uniqueMatches.insert( ftsSearchMatchCase ? match : match.toLower() );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( QSet< QString >::const_iterator it = uniqueMatches.constBegin(); it != uniqueMatches.constEnd(); ++it )
|
||||||
|
ui.definition->findText( *it, flags );
|
||||||
|
}
|
||||||
|
|
||||||
void ArticleView::setActiveDictIds(ActiveDictIds ad) {
|
void ArticleView::setActiveDictIds(ActiveDictIds ad) {
|
||||||
// ignore all other signals.
|
// ignore all other signals.
|
||||||
qDebug() << "receive dicts, current word:" << currentWord << ad.word << ":" << ad.dictIds;
|
qDebug() << "receive dicts, current word:" << currentWord << ad.word << ":" << ad.dictIds;
|
||||||
|
|
|
@ -80,8 +80,8 @@ class ArticleView: public QFrame
|
||||||
int ftsPosition;
|
int ftsPosition;
|
||||||
|
|
||||||
void highlightFTSResults();
|
void highlightFTSResults();
|
||||||
|
void highlightAllFtsOccurences( QWebEnginePage::FindFlags flags );
|
||||||
void performFtsFindOperation( bool backwards );
|
void performFtsFindOperation( bool backwards );
|
||||||
void showFindButtons();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// The popupView flag influences contents of the context menus to be
|
/// The popupView flag influences contents of the context menus to be
|
||||||
|
|
|
@ -1054,8 +1054,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
||||||
|
|
||||||
for( ; ; )
|
for( ; ; )
|
||||||
{
|
{
|
||||||
//skip too long headword
|
if( !head.headword.isEmpty() )
|
||||||
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 ) );
|
||||||
|
|
|
@ -899,7 +899,7 @@ bool EpwingBook::getNextHeadword( EpwingHeadword & head )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
allHeadwordPositions[ head.headword ]<<EWPos( pos.page, pos.offset );
|
allHeadwordPositions[ head.headword ] << EWPos( pos.page, pos.offset );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -973,7 +973,7 @@ bool EpwingBook::getNextHeadword( EpwingHeadword & head )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
allHeadwordPositions[ head.headword ]<<EWPos( pos.page, pos.offset );
|
allHeadwordPositions[ head.headword ] << EWPos( pos.page, pos.offset );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1128,6 +1128,9 @@ void EpwingBook::getArticle( QString & headword, QString & articleText,
|
||||||
headword = QString::fromUtf8( buffer, length );
|
headword = QString::fromUtf8( buffer, length );
|
||||||
finalizeText( headword );
|
finalizeText( headword );
|
||||||
|
|
||||||
|
if( text_only )
|
||||||
|
fixHeadword( headword );
|
||||||
|
|
||||||
articleText = getText( pos.page, pos.offset, text_only );
|
articleText = getText( pos.page, pos.offset, text_only );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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, QList<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;
|
||||||
|
|
|
@ -1244,6 +1244,10 @@ void MainWindow::closeEvent( QCloseEvent * ev )
|
||||||
|
|
||||||
void MainWindow::quitApp()
|
void MainWindow::quitApp()
|
||||||
{
|
{
|
||||||
|
if( inspector && inspector->isVisible() )
|
||||||
|
{
|
||||||
|
inspector->hide();
|
||||||
|
}
|
||||||
commitData();
|
commitData();
|
||||||
qApp->quit();
|
qApp->quit();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue