Merge branch 'Original' into Qt4x5

This commit is contained in:
Abs62 2015-02-09 18:57:32 +03:00
commit 40de8fcdd1
15 changed files with 1647 additions and 10 deletions

View file

@ -37,7 +37,7 @@ Alternatively, you might want to load `goldendict.pro` file from within Qt Creat
### Building with Zim dictionaries support
To add Zim format support you need at first install lzma-dev package:
To add Zim and Slob formats support you need at first install lzma-dev package:
sudo apt-get liblzma-dev

View file

@ -2876,3 +2876,11 @@ in bg url to hide it from iemac */
vertical-align: text-bottom;
background-image:url('qrcx://localhost/icons/downarrow.png');
}
/********** Slob dictionaries ***********/
.slobdict img.imgtex
{
vertical-align: baseline !important;
}

View file

@ -82,7 +82,8 @@ int res;
#define BUFSIZE 0xFFFF
string decompressLzma2( const char * bufptr, unsigned length )
string decompressLzma2( const char * bufptr, unsigned length,
bool raw_decoder )
{
string str;
lzma_ret res;
@ -92,9 +93,25 @@ char buf[BUFSIZE];
strm.next_in = reinterpret_cast< const uint8_t * >( bufptr );
strm.avail_in = length;
lzma_options_lzma opt;
lzma_filter filters[ 2 ];
if( raw_decoder )
{
lzma_lzma_preset(&opt, LZMA_PRESET_DEFAULT);
filters[ 0 ].id = LZMA_FILTER_LZMA2;
filters[ 0 ].options = &opt;
filters[ 1 ].id = LZMA_VLI_UNKNOWN;
}
while( 1 )
{
res = lzma_stream_decoder( &strm, UINT64_MAX, 0 );
if( raw_decoder )
res = lzma_raw_decoder( &strm, filters );
else
res = lzma_stream_decoder( &strm, UINT64_MAX, 0 );
if( res != LZMA_OK )
break;

View file

@ -14,7 +14,8 @@ string decompressBzip2( const char * bufptr, unsigned length );
#ifdef MAKE_ZIM_SUPPORT
string decompressLzma2( const char * bufptr, unsigned length );
string decompressLzma2( const char * bufptr, unsigned length,
bool raw_decoder = false );
#endif

View file

@ -329,7 +329,8 @@ HEADERS += folding.hh \
fulltextsearch.hh \
ftshelpers.hh \
dictserver.hh \
helpwindow.hh
helpwindow.hh \
slob.hh
FORMS += groups.ui \
dictgroupwidget.ui \
@ -347,6 +348,7 @@ FORMS += groups.ui \
dictheadwords.ui \
authentication.ui \
fulltextsearch.ui
SOURCES += folding.cc \
main.cc \
dictionary.cc \
@ -450,7 +452,8 @@ SOURCES += folding.cc \
fulltextsearch.cc \
ftshelpers.cc \
dictserver.cc \
helpwindow.cc
helpwindow.cc \
slob.cc
win32 {
FORMS += texttospeechsource.ui

Binary file not shown.

Binary file not shown.

BIN
icons/icon32_slob.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -29,6 +29,7 @@
#include "mdx.hh"
#include "zim.hh"
#include "dictserver.hh"
#include "slob.hh"
#ifndef NO_EPWING_SUPPORT
#include "epwing.hh"
@ -58,7 +59,7 @@ LoadDictionaries::LoadDictionaries( Config::Class const & cfg ):
<< "*.xdxf.dz" << "*.dct" << "*.aar" << "*.zips"
<< "*.mdx"
#ifdef MAKE_ZIM_SUPPORT
<< "*.zim" << "*.zimaa"
<< "*.zim" << "*.zimaa" << "*.slob"
#endif
#ifndef NO_EPWING_SUPPORT
<< "*catalogs"
@ -207,6 +208,13 @@ void LoadDictionaries::handlePath( Config::Path const & path )
dictionaries.insert( dictionaries.end(), zimDictionaries.begin(),
zimDictionaries.end() );
}
{
vector< sptr< Dictionary::Class > > slobDictionaries =
Slob::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this );
dictionaries.insert( dictionaries.end(), slobDictionaries.begin(),
slobDictionaries.end() );
}
#endif
#ifndef NO_EPWING_SUPPORT
{

View file

@ -294,12 +294,14 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
ui.allowDSL->setChecked( !p.fts.disabledTypes.contains( "DSL", Qt::CaseInsensitive ) );
ui.allowMDict->setChecked( !p.fts.disabledTypes.contains( "MDICT", Qt::CaseInsensitive ) );
ui.allowSDict->setChecked( !p.fts.disabledTypes.contains( "SDICT", Qt::CaseInsensitive ) );
ui.allowSlob->setChecked( !p.fts.disabledTypes.contains( "SLOB", Qt::CaseInsensitive ) );
ui.allowStardict->setChecked( !p.fts.disabledTypes.contains( "STARDICT", Qt::CaseInsensitive ) );
ui.allowXDXF->setChecked( !p.fts.disabledTypes.contains( "XDXF", Qt::CaseInsensitive ) );
ui.allowZim->setChecked( !p.fts.disabledTypes.contains( "ZIM", Qt::CaseInsensitive ) );
ui.allowEpwing->setChecked( !p.fts.disabledTypes.contains( "EPWING", Qt::CaseInsensitive ) );
#ifndef MAKE_ZIM_SUPPORT
ui.allowZim->hide();
ui.allowSlob->hide();
#endif
#ifdef NO_EPWING_SUPPORT
ui.allowEpwing->hide();
@ -441,6 +443,13 @@ Config::Preferences Preferences::getPreferences()
p.fts.disabledTypes += "SDICT";
}
if( !ui.allowSlob->isChecked() )
{
if( !p.fts.disabledTypes.isEmpty() )
p.fts.disabledTypes += ',';
p.fts.disabledTypes += "SLOB";
}
if( !ui.allowStardict->isChecked() )
{
if( !p.fts.disabledTypes.isEmpty() )

View file

@ -1240,13 +1240,20 @@ download page.</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="5" column="0">
<widget class="QCheckBox" name="allowSDict">
<property name="text">
<string notr="true">SDict</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="allowSlob">
<property name="text">
<string notr="true">Slob</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="allowStardict">
<property name="text">
@ -1268,7 +1275,7 @@ download page.</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QLabel" name="label_14">

View file

@ -78,5 +78,6 @@
<file>icons/playsound_full.png</file>
<file>icons/icon32_zim.png</file>
<file>icons/icon32_epwing.png</file>
<file>icons/icon32_slob.png</file>
</qresource>
</RCC>

1559
slob.cc Normal file

File diff suppressed because it is too large Load diff

24
slob.hh Normal file
View file

@ -0,0 +1,24 @@
#ifndef __SLOB_HH_INCLUDED__
#define __SLOB_HH_INCLUDED__
#ifdef MAKE_ZIM_SUPPORT
#include "dictionary.hh"
/// Support for the Slob dictionaries.
namespace Slob {
using std::vector;
using std::string;
vector< sptr< Dictionary::Class > > makeDictionaries(
vector< string > const & fileNames,
string const & indicesDir,
Dictionary::Initializing & )
throw( std::exception );
}
#endif
#endif // __SLOB_HH_INCLUDED__

2
zim.cc
View file

@ -840,7 +840,7 @@ void ZimDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
ftsIdxHeader.indexRootOffset = ftsIdxInfo.rootOffset;
ftsIdxHeader.signature = FtsHelpers::FtsSignature;
ftsIdxHeader.formatVersion = FtsHelpers::CurrentFtsFormatVersion;
ftsIdxHeader.formatVersion = FtsHelpers::CurrentFtsFormatVersion + getFtsIndexVersion();
ftsIdx.rewind();
ftsIdx.writeRecords( &ftsIdxHeader, sizeof(ftsIdxHeader), 1 );