mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-05 00:24:06 +00:00
Merge branch 'staged' into dev
This commit is contained in:
commit
2a743b786c
|
@ -601,8 +601,7 @@ win32{
|
|||
RESOURCES += resources.qrc \
|
||||
src/scripts/scripts.qrc \
|
||||
icons/flags.qrc \
|
||||
src/stylesheets/css.qrc \
|
||||
src/ui/resources.qrc
|
||||
src/stylesheets/css.qrc
|
||||
#EXTRA_TRANSLATIONS += thirdparty/qwebengine_ts/qtwebengine_zh_CN.ts
|
||||
TRANSLATIONS += $$files(locale/*.ts)
|
||||
|
||||
|
|
|
@ -553,7 +553,7 @@ bool needToRebuildIndex( vector< string > const & dictionaryFiles, string const
|
|||
}
|
||||
else {
|
||||
if ( !fileInfo.exists() )
|
||||
return true;
|
||||
continue;
|
||||
ts = fileInfo.lastModified().toSecsSinceEpoch();
|
||||
}
|
||||
|
||||
|
|
|
@ -1175,6 +1175,10 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
dict.setSubBook( sb );
|
||||
|
||||
dir = QString::fromStdString( mainDirectory ) + Utils::Fs::separator() + dict.getCurrentSubBookDirectory();
|
||||
QDir _dir( dir );
|
||||
if ( !_dir.exists() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Epwing::Book::EpwingBook::collectFilenames( dir, dictFiles );
|
||||
|
||||
|
@ -1183,12 +1187,8 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
QFileInfo info( fontSubName );
|
||||
if ( info.exists() && info.isFile() )
|
||||
dictFiles.push_back( fontSubName.toStdString() );
|
||||
else {
|
||||
//to make the subbook in different index.
|
||||
dictFiles.push_back( QString::number( sb ).toStdString() );
|
||||
}
|
||||
|
||||
// Check if we need to rebuid the index
|
||||
// Check if we need to rebuild the index
|
||||
|
||||
string dictId = Dictionary::makeDictionaryId( dictFiles );
|
||||
|
||||
|
@ -1203,7 +1203,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
|
||||
File::Class idx( indexFile, "wb" );
|
||||
|
||||
IdxHeader idxHeader;
|
||||
IdxHeader idxHeader{};
|
||||
|
||||
memset( &idxHeader, 0, sizeof( idxHeader ) );
|
||||
|
||||
|
@ -1275,4 +1275,4 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
|
|||
|
||||
} // namespace Epwing
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -596,7 +596,36 @@ QString EpwingBook::getCurrentSubBookDirectory()
|
|||
throw exEbLibrary( error_string.toUtf8().data() );
|
||||
}
|
||||
|
||||
return QString::fromLocal8Bit( buffer );
|
||||
QString subDir = QString::fromLocal8Bit( buffer );
|
||||
|
||||
return repairSubBookDirectory( subDir );
|
||||
}
|
||||
|
||||
QString EpwingBook::repairSubBookDirectory( QString subBookDir )
|
||||
{
|
||||
char path[ EB_MAX_PATH_LENGTH + 1 ];
|
||||
EB_Error_Code error_code = eb_path( &book, path );
|
||||
if ( error_code != EB_SUCCESS )
|
||||
return subBookDir;
|
||||
|
||||
const QString & mainDirectory = QString::fromLocal8Bit( path );
|
||||
QDir mainDir( mainDirectory );
|
||||
QStringList allIdxFiles = mainDir.entryList( QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks );
|
||||
|
||||
if ( allIdxFiles.contains( subBookDir ) ) {
|
||||
return subBookDir;
|
||||
}
|
||||
|
||||
qDebug() << "Epwing: can not found subbook directory,try to fix automatically, dir=>" << subBookDir;
|
||||
|
||||
for ( const auto & file : allIdxFiles ) {
|
||||
if ( file.compare( subBookDir, Qt::CaseInsensitive ) == 0 ) {
|
||||
qDebug() << "Epwing: found " << file;
|
||||
return file;
|
||||
}
|
||||
}
|
||||
//return original subbook directory
|
||||
return subBookDir;
|
||||
}
|
||||
|
||||
QString EpwingBook::makeFName( QString const & ext, int page, int offset ) const
|
||||
|
|
|
@ -239,6 +239,7 @@ public:
|
|||
bool getMatches( QString word, QVector< QString > & matches );
|
||||
|
||||
bool getArticlePos( QString word, QVector< int > & pages, QVector< int > & offsets );
|
||||
QString repairSubBookDirectory( QString subBookDir );
|
||||
};
|
||||
|
||||
struct EContainer
|
||||
|
|
|
@ -294,24 +294,6 @@ void loadDictionaries( QWidget * parent,
|
|||
}
|
||||
}
|
||||
|
||||
QDir indexDir( Config::getIndexDir() );
|
||||
|
||||
QStringList allIdxFiles = indexDir.entryList( QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks );
|
||||
|
||||
for ( const auto & file : allIdxFiles ) {
|
||||
if ( file.size() >= 32 && ids.find( file.left( 32 ).toStdString() ) == ids.end() ) {
|
||||
if ( QFile::exists( file ) ) {
|
||||
indexDir.remove( file );
|
||||
}
|
||||
else {
|
||||
// must be folder .
|
||||
auto dirPath = Utils::Path::combine( Config::getIndexDir(), file );
|
||||
QDir t( dirPath );
|
||||
t.removeRecursively();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Run deferred inits
|
||||
|
||||
if ( doDeferredInit_ )
|
||||
|
|
2
thirdparty/eb
vendored
2
thirdparty/eb
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 77bc36513d7a1555a7b39b7d2cb0da0e85b9dc18
|
||||
Subproject commit d5bd52b581fb036ac075bac257ab76a0f8c1de19
|
Loading…
Reference in a new issue