Merge branch 'staged' into dev
Some checks failed
Release AutoTag / Build (push) Has been cancelled
Release macOS / Build (macos-12, clang_64, 6.6.3) (push) Has been cancelled
Release macOS / Build (macos-12, clang_64, 6.7.2) (push) Has been cancelled
Release macOS / Build (macos-14, clang_64, 6.6.3) (push) Has been cancelled
Release macOS / Build (macos-14, clang_64, 6.7.2) (push) Has been cancelled
Release Windows CMake / Build (windows-2022, win64_msvc2019_64, 6.6.3) (push) Has been cancelled
Release Windows CMake / Build (windows-2022, win64_msvc2019_64, 6.7.2) (push) Has been cancelled

This commit is contained in:
Xiao Yi Fang 2024-09-02 12:03:29 +08:00
commit 4b7ae255f7
44 changed files with 195 additions and 222 deletions

View file

@ -1,15 +1,18 @@
# https://clang.llvm.org/extra/clang-tidy/
---
Checks: >
-*
-*,
bugprone-*,
cert-*,
clang-analyzer-*,
clang-diagnostic-*,
concurrency-*,
cppcoreguidelines-*,
google-*,
hicpp-*,
misc-*,
modernize-*,
objc-*,
performance-*,
portability-*,
readability-*,
@ -17,18 +20,22 @@ Checks: >
-bugprone-reserved-identifier,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-prefer-member-initializer,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-type-cstyle-cast,
-cppcoreguidelines-pro-type-reinterpret-cast,
-google-default-arguments,
-misc-non-private-member-variables-in-classes,
-google-readability-casting,
-hicpp-deprecated-headers,
-misc-const-correctness,
-misc-non-private-member-variables-in-classes,
-modernize-avoid-c-arrays,
# -modernize-use-auto,
-modernize-deprecated-headers,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-readability-magic-numbers,
-google-readability-braces-around-statements,
-readability-braces-around-statements,
-readability-identifier-length,
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-magic-numbers,
CheckOptions:
- key: modernize-loop-convert.MinConfidence
value: reasonable

5
.editorconfig Normal file
View file

@ -0,0 +1,5 @@
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

View file

@ -5,3 +5,7 @@ b5349478cfb0dc2dd0de8c8e8aeebdd24cf7ac6b
# reformat every .js .css
534d8c2e96ef00ae03650c2185d7b240ea5a1114
# replace QVector & QPair
3273f39dd73f4dba07fa95be2be74061f2690b2c
44853544f850e1de90b341780168c04d089c37a1

1
.gitattributes vendored Normal file
View file

@ -0,0 +1 @@
* text=auto eol=lf

2
.gitignore vendored
View file

@ -21,8 +21,6 @@ object_script.goldendict.Release
version.txt
.gitattributes
*.dmg
.DS_Store

View file

@ -186,7 +186,6 @@ endif ()
target_compile_definitions(${GOLDENDICT} PUBLIC
CMAKE_USED_HACK # temporal hack to avoid breaking qmake build
USE_ICONV
MAKE_QTMULTIMEDIA_PLAYER
MAKE_CHINESE_CONVERSION_SUPPORT
)

View file

@ -998,9 +998,9 @@ void ArticleRequest::individualWordFinished()
compoundSearchNextStep( false );
}
QPair< ArticleRequest::Words, ArticleRequest::Spacings > ArticleRequest::splitIntoWords( QString const & input )
std::pair< ArticleRequest::Words, ArticleRequest::Spacings > ArticleRequest::splitIntoWords( QString const & input )
{
QPair< Words, Spacings > result;
std::pair< Words, Spacings > result;
QChar const * ptr = input.data();

View file

@ -105,9 +105,9 @@ class ArticleRequest: public Dictionary::DataRequest
typedef QList< QString > Spacings;
/// Splits the given string into words and spacings between them.
QPair< Words, Spacings > splitIntoWords( QString const & );
std::pair< Words, Spacings > splitIntoWords( QString const & );
QPair< Words, Spacings > splittedWords;
std::pair< Words, Spacings > splittedWords;
int currentSplittedWordStart;
int currentSplittedWordEnd;
QString currentSplittedWordCompound;

View file

@ -5,14 +5,14 @@
#define __ARTICLE_NETMGR_HH_INCLUDED__
#include <QtNetwork>
#include <QSet>
#include <QMap>
#include <QPair>
#include <QWebEngineUrlSchemeHandler>
#include <QWebEngineUrlRequestJob>
#include <QNetworkAccessManager>
#include <utility>
#include "dict/dictionary.hh"
#include "article_maker.hh"

View file

@ -1028,7 +1028,7 @@ void BtreeIndex::getAllHeadwords( QSet< QString > & headwords )
findArticleLinks( nullptr, nullptr, &headwords );
}
void BtreeIndex::findAllArticleLinks( QVector< WordArticleLink > & articleLinks )
void BtreeIndex::findAllArticleLinks( QList< WordArticleLink > & articleLinks )
{
if ( !idxFile )
throw exIndexWasNotOpened();
@ -1038,7 +1038,7 @@ void BtreeIndex::findAllArticleLinks( QVector< WordArticleLink > & articleLinks
findArticleLinks( &articleLinks, &offsets, nullptr );
}
void BtreeIndex::findArticleLinks( QVector< WordArticleLink > * articleLinks,
void BtreeIndex::findArticleLinks( QList< WordArticleLink > * articleLinks,
QSet< uint32_t > * offsets,
QSet< QString > * headwords,
QAtomicInt * isCancelled )
@ -1217,7 +1217,7 @@ QList< uint32_t > BtreeIndex::findNodes()
}
void BtreeIndex::getHeadwordsFromOffsets( QList< uint32_t > & offsets,
QVector< QString > & headwords,
QList< QString > & headwords,
QAtomicInt * isCancelled )
{
uint32_t currentNodeOffset = rootOffset;

View file

@ -16,7 +16,7 @@
#include <QFuture>
#include <QList>
#include <QSet>
#include <QVector>
#include <QList>
/// A base for the dictionary which creates a btree index to look up
@ -89,13 +89,13 @@ public:
vector< WordArticleLink > findArticles( wstring const &, bool ignoreDiacritics = false, uint32_t maxMatchCount = -1 );
/// Find all unique article links in the index
void findAllArticleLinks( QVector< WordArticleLink > & articleLinks );
void findAllArticleLinks( QList< WordArticleLink > & articleLinks );
/// Retrieve all unique headwords from index
void getAllHeadwords( QSet< QString > & headwords );
/// Find all article links and/or headwords in the index
void findArticleLinks( QVector< WordArticleLink > * articleLinks,
void findArticleLinks( QList< WordArticleLink > * articleLinks,
QSet< uint32_t > * offsets,
QSet< QString > * headwords,
QAtomicInt * isCancelled = 0 );
@ -106,7 +106,7 @@ public:
/// Retrieve headwords for presented article addresses
void
getHeadwordsFromOffsets( QList< uint32_t > & offsets, QVector< QString > & headwords, QAtomicInt * isCancelled = 0 );
getHeadwordsFromOffsets( QList< uint32_t > & offsets, QList< QString > & headwords, QAtomicInt * isCancelled = 0 );
protected:

View file

@ -11,33 +11,20 @@ char const * const Iconv::GdWchar = "UTF-32LE";
char const * const Iconv::Utf16Le = "UTF-16LE";
char const * const Iconv::Utf8 = "UTF-8";
using gd::wchar;
Iconv::Iconv( char const * from )
#ifdef USE_ICONV
// the to encoding must be UTF8
:
Iconv::Iconv( char const * from ):
state( iconv_open( Utf8, from ) )
#endif
{
#ifdef USE_ICONV
if ( state == (iconv_t)-1 )
throw exCantInit( strerror( errno ) );
#else
codec = QTextCodec::codecForName( from );
#endif
}
Iconv::~Iconv()
{
#ifdef USE_ICONV
iconv_close( state );
#endif
}
QString Iconv::convert( void const *& inBuf, size_t & inBytesLeft )
{
#ifdef USE_ICONV
size_t dsz = inBytesLeft;
//avoid most realloc
std::vector< char > outBuf( dsz + 32 );
@ -90,12 +77,6 @@ QString Iconv::convert( void const *& inBuf, size_t & inBytesLeft )
size_t datasize = outBuf.size() - outBufLeft;
// QByteArray ba( &outBuf.front(), datasize );
return QString::fromUtf8( &outBuf.front(), datasize );
#else
if ( codec )
return codec->toUnicode( static_cast< const char * >( inBuf ), inBytesLeft );
QByteArray ba( static_cast< const char * >( inBuf ), inBytesLeft );
return QString( ba );
#endif
}
gd::wstring Iconv::toWstring( char const * fromEncoding, void const * fromData, size_t dataSize )
@ -104,8 +85,9 @@ gd::wstring Iconv::toWstring( char const * fromEncoding, void const * fromData,
/// Special-case the dataSize == 0 to avoid any kind of iconv-specific
/// behaviour in that regard.
if ( !dataSize )
if ( dataSize == 0 ) {
return {};
}
Iconv ic( fromEncoding );
@ -118,11 +100,22 @@ std::string Iconv::toUtf8( char const * fromEncoding, void const * fromData, siz
{
// Similar to toWstring
if ( !dataSize )
if ( dataSize == 0 ) {
return {};
}
Iconv ic( fromEncoding );
const QString outStr = ic.convert( fromData, dataSize );
return outStr.toStdString();
}
QString Iconv::toQString( char const * fromEncoding, void const * fromData, size_t dataSize )
{
if ( dataSize == 0 ) {
return {};
}
Iconv ic( fromEncoding );
return ic.convert( fromData, dataSize );
}

View file

@ -4,24 +4,19 @@
#ifndef __ICONV_HH_INCLUDED__
#define __ICONV_HH_INCLUDED__
#include <QTextCodec>
#include <QString>
#include "wstring.hh"
#include "ex.hh"
#ifdef USE_ICONV
#include <iconv.h>
#endif
#include <iconv.h>
/// A wrapper for the iconv() character set conversion functions
/// "Internationalization conversion" for char encoding conversion, currently implemented with iconv()
/// Only supports converting from a known "from" to UTF8
class Iconv
{
#ifdef USE_ICONV
iconv_t state;
#else
QTextCodec * codec;
#endif
public:
@ -34,7 +29,7 @@ public:
static char const * const Utf16Le;
static char const * const Utf8;
Iconv( char const * from );
explicit Iconv( char const * from );
~Iconv();
@ -47,11 +42,10 @@ public:
// string.
static std::string toUtf8( char const * fromEncoding, void const * fromData, size_t dataSize );
private:
static QString toQString( char const * fromEncoding, void const * fromData, size_t dataSize );
// Copying/assigning not supported
Iconv( Iconv const & );
Iconv & operator=( Iconv const & );
// Copying/assigning isn't supported
Q_DISABLE_COPY_MOVE( Iconv );
};
#endif

View file

@ -194,7 +194,7 @@ inline void removeQueryItem( QUrl & url, QString const & key )
url.setQuery( urlQuery );
}
inline void setQueryItems( QUrl & url, QList< QPair< QString, QString > > const & query )
inline void setQueryItems( QUrl & url, QList< std::pair< QString, QString > > const & query )
{
QUrlQuery urlQuery( url );
urlQuery.setQueryItems( query );

View file

@ -1,5 +1,5 @@
#include "wstring_qt.hh"
#include <QVector>
#include <QList>
namespace gd {
wstring toWString( QString const & in )
@ -19,7 +19,7 @@ wstring removeTrailingZero( wstring const & v )
wstring removeTrailingZero( QString const & in )
{
QVector< unsigned int > v = in.toUcs4();
QList< unsigned int > v = in.toUcs4();
int n = v.size();
while ( n > 0 && v[ n - 1 ] == 0 )

View file

@ -5,7 +5,7 @@
#define __CONFIG_HH_INCLUDED__
#include <QObject>
#include <QVector>
#include <QList>
#include <QString>
#include <QSize>
#include <QDateTime>
@ -47,7 +47,7 @@ struct Path
};
/// A list of paths where to search for the dictionaries
typedef QVector< Path > Paths;
typedef QList< Path > Paths;
/// A directory holding bunches of audiofiles, which is indexed into a separate
/// dictionary.
@ -72,7 +72,7 @@ struct SoundDir
};
/// A list of SoundDirs
typedef QVector< SoundDir > SoundDirs;
typedef QList< SoundDir > SoundDirs;
struct DictionaryRef
{
@ -101,7 +101,7 @@ struct Group
QByteArray iconData;
QKeySequence shortcut;
QString favoritesFolder;
QVector< DictionaryRef > dictionaries;
QList< DictionaryRef > dictionaries;
Config::MutedDictionaries mutedDictionaries; // Disabled via dictionary bar
Config::MutedDictionaries popupMutedDictionaries; // Disabled via dictionary bar in popup
@ -125,7 +125,7 @@ struct Group
};
/// All the groups
struct Groups: public QVector< Group >
struct Groups: public QList< Group >
{
unsigned nextId; // Id to use to create the group next time
@ -498,7 +498,7 @@ struct WebSite
};
/// All the WebSites
typedef QVector< WebSite > WebSites;
typedef QList< WebSite > WebSites;
/// Any DICT server
struct DictServer
@ -539,14 +539,14 @@ struct DictServer
};
/// All the DictServers
typedef QVector< DictServer > DictServers;
typedef QList< DictServer > DictServers;
/// Hunspell configuration
struct Hunspell
{
QString dictionariesPath;
typedef QVector< QString > Dictionaries;
typedef QList< QString > Dictionaries;
Dictionaries enabledDictionaries;
@ -562,7 +562,7 @@ struct Hunspell
};
/// All the MediaWikis
typedef QVector< MediaWiki > MediaWikis;
typedef QList< MediaWiki > MediaWikis;
/// Chinese transliteration configuration
@ -755,7 +755,7 @@ struct Program
}
};
typedef QVector< Program > Programs;
typedef QList< Program > Programs;
#ifndef NO_TTS_SUPPORT
struct VoiceEngine
@ -801,7 +801,7 @@ struct VoiceEngine
}
};
typedef QVector< VoiceEngine > VoiceEngines;
typedef QList< VoiceEngine > VoiceEngines;
#endif
struct HeadwordsDialog

View file

@ -259,7 +259,7 @@ public:
getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override;
void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
@ -544,7 +544,7 @@ QString const & AardDictionary::getDescription()
return dictionaryDescription;
}
void AardDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration )
void AardDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -556,8 +556,6 @@ void AardDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
if ( ensureInitDone().size() )
return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "Aard: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -215,7 +215,7 @@ public:
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override;
void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
@ -414,7 +414,7 @@ void BglDictionary::getArticleText( uint32_t articleAddress, QString & headword,
}
}
void BglDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration )
void BglDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -423,8 +423,6 @@ void BglDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
if ( haveFTSIndex() )
return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "Bgl: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -136,7 +136,7 @@ public:
getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override;
void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
@ -435,7 +435,7 @@ QString const & DictdDictionary::getDescription()
return dictionaryDescription;
}
void DictdDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration )
void DictdDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -447,8 +447,6 @@ void DictdDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteratio
if ( ensureInitDone().size() )
return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "DictD: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -523,7 +523,7 @@ public:
}
/// Make index for full-text search
virtual void makeFTSIndex( QAtomicInt &, bool ) {}
virtual void makeFTSIndex( QAtomicInt & ) {}
/// Set full-text search parameters
virtual void setFTSParameters( Config::FullTextSearch const & ) {}

View file

@ -119,8 +119,8 @@ struct InsidedCard
{
uint32_t offset;
uint32_t size;
QVector< wstring > headwords;
InsidedCard( uint32_t _offset, uint32_t _size, QVector< wstring > const & words ):
QList< wstring > headwords;
InsidedCard( uint32_t _offset, uint32_t _size, QList< wstring > const & words ):
offset( _offset ),
size( _size ),
headwords( words )
@ -229,7 +229,7 @@ public:
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override;
void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
@ -950,8 +950,8 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
QString attr = QString::fromStdU32String( node.tagAttrs ).remove( '\"' );
int n = attr.indexOf( '=' );
if ( n > 0 ) {
QList< QPair< QString, QString > > query;
query.append( QPair< QString, QString >( attr.left( n ), attr.mid( n + 1 ) ) );
QList< std::pair< QString, QString > > query;
query.append( std::pair< QString, QString >( attr.left( n ), attr.mid( n + 1 ) ) );
Utils::Url::setQueryItems( url, query );
}
}
@ -1072,7 +1072,7 @@ QString DslDictionary::getMainFilename()
return getDictionaryFilenames()[ 0 ].c_str();
}
void DslDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration )
void DslDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) {
@ -1086,8 +1086,6 @@ void DslDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
if ( !ensureInitDone().empty() )
return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "Dsl: Building the full-text index for dictionary: %s\n", getName().c_str() );
@ -1922,9 +1920,9 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f
int insideInsided = 0;
wstring headword;
QVector< InsidedCard > insidedCards;
QList< InsidedCard > insidedCards;
uint32_t offset = curOffset;
QVector< wstring > insidedHeadwords;
QList< wstring > insidedHeadwords;
unsigned linesInsideCard = 0;
int dogLine = 0;
bool wasEmptyLine = false;

View file

@ -137,7 +137,7 @@ public:
QString const & getDescription() override;
void getHeadwordPos( wstring const & word_, QVector< int > & pg, QVector< int > & off );
void getHeadwordPos( wstring const & word_, QList< int > & pg, QList< int > & off );
sptr< Dictionary::DataRequest >
getArticle( wstring const &, vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) override;
@ -148,7 +148,7 @@ public:
getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override;
void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
@ -425,7 +425,7 @@ QString const & EpwingDictionary::getDescription()
return dictionaryDescription;
}
void EpwingDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration )
void EpwingDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -435,8 +435,6 @@ void EpwingDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIterati
if ( haveFTSIndex() )
return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "Epwing: Building the full-text index for dictionary: %s\n", getName().c_str() );
@ -545,8 +543,8 @@ void EpwingHeadwordsRequest::run()
}
QVector< int > pg;
QVector< int > off;
QList< int > pg;
QList< int > off;
dict.getHeadwordPos( parts[ 0 ].toStdU32String(), pg, off );
for ( unsigned i = 0; i < pg.size(); ++i ) {
@ -602,8 +600,8 @@ public:
void run();
void getBuiltInArticle( wstring const & word_,
QVector< int > & pages,
QVector< int > & offsets,
QList< int > & pages,
QList< int > & offsets,
multimap< wstring, pair< string, string > > & mainArticles );
void cancel() override
@ -644,7 +642,7 @@ void EpwingArticleRequest::run()
if ( ignoreDiacritics )
wordCaseFolded = Folding::applyDiacriticsOnly( wordCaseFolded );
QVector< int > pages, offsets;
QList< int > pages, offsets;
for ( auto & x : chain ) {
if ( Utils::AtomicInt::loadAcquire( isCancelled ) ) {
@ -753,14 +751,14 @@ void EpwingArticleRequest::run()
}
void EpwingArticleRequest::getBuiltInArticle( wstring const & word_,
QVector< int > & pages,
QVector< int > & offsets,
QList< int > & pages,
QList< int > & offsets,
multimap< wstring, pair< string, string > > & mainArticles )
{
try {
string headword, articleText;
QVector< int > pg, off;
QList< int > pg, off;
{
QMutexLocker _( &dict.eBook.getLibMutex() );
dict.eBook.getArticlePos( QString::fromStdU32String( word_ ), pg, off );
@ -789,7 +787,7 @@ void EpwingArticleRequest::getBuiltInArticle( wstring const & word_,
}
}
void EpwingDictionary::getHeadwordPos( wstring const & word_, QVector< int > & pg, QVector< int > & off )
void EpwingDictionary::getHeadwordPos( wstring const & word_, QList< int > & pg, QList< int > & off )
{
try {
QMutexLocker _( &eBook.getLibMutex() );
@ -988,7 +986,7 @@ void EpwingWordSearchRequest::findMatches()
}
while ( matches.size() < maxResults ) {
QVector< QString > headwords;
QList< QString > headwords;
{
QMutexLocker _( &edict.eBook.getLibMutex() );
if ( Utils::AtomicInt::loadAcquire( isCancelled ) )

View file

@ -1857,7 +1857,7 @@ QString EpwingBook::currentCandidate()
return QString{};
}
bool EpwingBook::getMatches( QString word, QVector< QString > & matches )
bool EpwingBook::getMatches( QString word, QList< QString > & matches )
{
QByteArray bword, bword2;
EB_Hit hits[ HitsBufferSize ];
@ -1904,7 +1904,7 @@ bool EpwingBook::getMatches( QString word, QVector< QString > & matches )
}
}
QVector< int > pages, offsets;
QList< int > pages, offsets;
for ( int i = 0; i < hitCount; i++ ) {
bool same_article = false;
@ -1928,7 +1928,7 @@ bool EpwingBook::getMatches( QString word, QVector< QString > & matches )
return true;
}
bool EpwingBook::getArticlePos( QString word, QVector< int > & pages, QVector< int > & offsets )
bool EpwingBook::getArticlePos( QString word, QList< int > & pages, QList< int > & offsets )
{
QByteArray bword, bword2;
EB_Hit hits[ HitsBufferSize ];

View file

@ -6,7 +6,7 @@
#include <QMap>
#include <QStack>
#include <QVector>
#include <QList>
#include <QtGlobal>
#include <string>
@ -58,7 +58,7 @@ struct EpwingHeadword
class EpwingBook
{
typedef QPair< int, int > EWPos;
typedef std::pair< int, int > EWPos;
void setErrorString( QString const & func, EB_Error_Code code );
@ -79,10 +79,10 @@ class EpwingBook
int monoWidth, monoHeight;
QStringList imageCacheList, soundsCacheList, moviesCacheList, fontsCacheList;
QMap< QString, QString > baseFontsMap, customFontsMap;
QVector< int > refPages, refOffsets;
QList< int > refPages, refOffsets;
QMap< uint64_t, bool > allHeadwordPositions;
QMap< uint64_t, bool > allRefPositions;
QVector< EWPos > LinksQueue;
QList< EWPos > LinksQueue;
int refOpenCount, refCloseCount;
static QMutex libMutex;
QList< EpwingHeadword > candidateItems;
@ -242,9 +242,9 @@ public:
QByteArray handleReference( EB_Hook_Code code, const unsigned int * argv );
bool getMatches( QString word, QVector< QString > & matches );
bool getMatches( QString word, QList< QString > & matches );
bool getArticlePos( QString word, QVector< int > & pages, QVector< int > & offsets );
bool getArticlePos( QString word, QList< int > & pages, QList< int > & offsets );
QString repairSubBookDirectory( QString subBookDir );
};

View file

@ -404,7 +404,7 @@ public:
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override;
void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
@ -546,7 +546,7 @@ QString GlsDictionary::getMainFilename()
return getDictionaryFilenames()[ 0 ].c_str();
}
void GlsDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration )
void GlsDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -558,8 +558,6 @@ void GlsDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
if ( ensureInitDone().size() )
return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "Gls: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -126,7 +126,7 @@ string encodeToHunspell( Hunspell &, wstring const & );
wstring decodeFromHunspell( Hunspell &, char const * );
/// Generates suggestions via hunspell
QVector< wstring > suggest( wstring & word, QMutex & hunspellMutex, Hunspell & hunspell );
QList< wstring > suggest( wstring & word, QMutex & hunspellMutex, Hunspell & hunspell );
/// Generates suggestions for compound expression
void getSuggestionsForExpression( wstring const & expression,
@ -362,7 +362,7 @@ void HunspellHeadwordsRequest::run()
matches.push_back( result );
}
else {
QVector< wstring > suggestions = suggest( trimmedWord, hunspellMutex, hunspell );
QList< wstring > suggestions = suggest( trimmedWord, hunspellMutex, hunspell );
if ( !suggestions.empty() ) {
QMutexLocker _( &dataMutex );
@ -375,9 +375,9 @@ void HunspellHeadwordsRequest::run()
finish();
}
QVector< wstring > suggest( wstring & word, QMutex & hunspellMutex, Hunspell & hunspell )
QList< wstring > suggest( wstring & word, QMutex & hunspellMutex, Hunspell & hunspell )
{
QVector< wstring > result;
QList< wstring > result;
vector< string > suggestions;
@ -522,7 +522,7 @@ void getSuggestionsForExpression( wstring const & expression,
wstring trimmedWord = Folding::trimWhitespaceOrPunct( expression );
wstring word, punct;
QVector< wstring > words;
QList< wstring > words;
suggestions.clear();
@ -556,7 +556,7 @@ void getSuggestionsForExpression( wstring const & expression,
// Combine result strings from suggestions
QVector< wstring > results;
QList< wstring > results;
for ( const auto & i : words ) {
word = i;
@ -565,7 +565,7 @@ void getSuggestionsForExpression( wstring const & expression,
result.append( word );
}
else {
QVector< wstring > sugg = suggest( word, hunspellMutex, hunspell );
QList< wstring > sugg = suggest( word, hunspellMutex, hunspell );
int suggNum = sugg.size() + 1;
if ( suggNum > 3 )
suggNum = 3;

View file

@ -254,7 +254,7 @@ public:
getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override;
void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
@ -438,7 +438,7 @@ void MdxDictionary::doDeferredInit()
}
}
void MdxDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration )
void MdxDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -450,8 +450,6 @@ void MdxDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
// if( !ensureInitDone().empty() )
// return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "MDict: Building the full-text index for dictionary: %s", getName().c_str() );

View file

@ -173,7 +173,7 @@ public:
getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override;
void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
@ -379,7 +379,7 @@ void SdictDictionary::loadArticle( uint32_t address, string & articleText )
articleText.append( "</div>" );
}
void SdictDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration )
void SdictDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -391,8 +391,6 @@ void SdictDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteratio
if ( ensureInitDone().size() )
return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "SDict: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -21,20 +21,21 @@
#include <stub_msvc.h>
#endif
#include "iconv.hh"
#include <QString>
#include <QFile>
#include <QFileInfo>
#include <QDir>
#include <QTextCodec>
#include <QMap>
#include <QPair>
#include <QProcess>
#include <QVector>
#include <QList>
#include <QRegularExpression>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <algorithm>
@ -112,8 +113,8 @@ bool indexIsOldOrBad( string const & indexFile )
class SlobFile
{
public:
typedef QPair< quint64, quint32 > RefEntryOffsetItem;
typedef QVector< RefEntryOffsetItem > RefOffsetsVector;
typedef std::pair< quint64, quint32 > RefEntryOffsetItem;
typedef QList< RefEntryOffsetItem > RefOffsetsVector;
private:
enum Compressions {
@ -127,11 +128,10 @@ private:
QFile file;
QString fileName, dictionaryName;
Compressions compression;
QString encoding;
std::string encoding;
unsigned char uuid[ 16 ];
QTextCodec * codec;
QMap< QString, QString > tags;
QVector< QString > contentTypes;
QList< QString > contentTypes;
quint32 blobCount;
quint64 storeOffset, fileSize, refsOffset;
quint32 refsCount, itemsCount;
@ -149,7 +149,6 @@ private:
public:
SlobFile():
compression( UNKNOWN ),
codec( 0 ),
blobCount( 0 ),
storeOffset( 0 ),
fileSize( 0 ),
@ -170,7 +169,7 @@ public:
return compression;
}
QString const & getEncoding() const
std::string const & getEncoding() const
{
return encoding;
}
@ -200,11 +199,6 @@ public:
return contentTypesCount;
}
QTextCodec * getCodec() const
{
return codec;
}
const RefOffsetsVector & getSortedRefOffsets();
void clearRefOffsets()
@ -241,10 +235,17 @@ QString SlobFile::readString( unsigned length )
QByteArray data = file.read( length );
QString str;
if ( codec != 0 && !data.isEmpty() )
str = codec->toUnicode( data );
else
if ( !encoding.empty() && !data.isEmpty() ) {
try {
str = Iconv::toQString( encoding.c_str(), data.data(), data.size() );
}
catch ( Iconv::Ex & e ) {
qDebug() << QString( R"(slob decoding failed: %1)" ).arg( e.what() );
}
}
else {
str = QString( data );
}
char term = 0;
int n = str.indexOf( term );
@ -317,13 +318,7 @@ void SlobFile::open( const QString & name )
// Read encoding
encoding = readTinyText();
codec = QTextCodec::codecForName( encoding.toLatin1() );
if ( codec == nullptr ) {
error = QString( R"(for encoding "%1")" ).arg( encoding );
throw exNoCodecFound( string( error.toUtf8().data() ) );
}
encoding = readTinyText().toStdString();
// Read compression type
@ -504,7 +499,7 @@ quint8 SlobFile::getItem( RefEntry const & entry, string * data )
if ( entry.binIndex >= bins )
return 0xFF;
QVector< quint8 > ids;
QList< quint8 > ids;
ids.resize( bins );
if ( file.read( (char *)ids.data(), bins ) != bins )
break;
@ -636,7 +631,7 @@ public:
quint64 getArticlePos( uint32_t articleNumber );
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override;
void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
@ -726,14 +721,8 @@ QString const & SlobDictionary::getDescription()
if ( !dictionaryDescription.isEmpty() )
return dictionaryDescription;
QMap< QString, QString > const & tags = sf.getTags();
QMap< QString, QString >::const_iterator it;
for ( it = tags.begin(); it != tags.end(); ++it ) {
if ( it != tags.begin() )
dictionaryDescription += "\n\n";
dictionaryDescription += it.key() + ": " + it.value();
for ( auto [ key, value ] : sf.getTags().asKeyValueRange() ) {
dictionaryDescription += "<b>" % key % "</b>" % ": " % value % "<br>";
}
return dictionaryDescription;
@ -871,9 +860,15 @@ quint32 SlobDictionary::readArticle( quint32 articleNumber, std::string & result
|| contentType.contains( "/css", Qt::CaseInsensitive )
|| contentType.contains( "/javascript", Qt::CaseInsensitive )
|| contentType.contains( "/json", Qt::CaseInsensitive ) ) {
QTextCodec * codec = sf.getCodec();
QString content = codec->toUnicode( data.c_str(), data.size() );
result = string( content.toUtf8().data() );
QString content;
try {
content = Iconv::toQString( sf.getEncoding().c_str(), data.data(), data.size() );
}
catch ( Iconv::Ex & e ) {
qDebug() << QString( R"(slob decoding failed: %1)" ).arg( e.what() );
}
result = string( content.toUtf8().data() );
}
else
result = data;
@ -891,7 +886,7 @@ quint64 SlobDictionary::getArticlePos( uint32_t articleNumber )
return ( ( (quint64)( entry.binIndex ) ) << 32 ) | entry.itemIndex;
}
void SlobDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration )
void SlobDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -903,8 +898,6 @@ void SlobDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
if ( !ensureInitDone().empty() )
return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "Slob: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -196,7 +196,7 @@ public:
getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override;
void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
@ -1085,7 +1085,7 @@ QString StardictDictionary::getMainFilename()
return getDictionaryFilenames()[ 0 ].c_str();
}
void StardictDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration )
void StardictDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -1097,8 +1097,6 @@ void StardictDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstItera
if ( ensureInitDone().size() )
return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "Stardict: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -92,8 +92,8 @@ VoiceEnginesDictionary::getArticle( wstring const & word, vector< wstring > cons
url.setScheme( "gdtts" );
url.setHost( "localhost" );
url.setPath( Utils::Url::ensureLeadingSlash( QString::fromUtf8( wordUtf8.c_str() ) ) );
QList< QPair< QString, QString > > query;
query.push_back( QPair< QString, QString >( "engine", QString::fromStdString( getId() ) ) );
QList< std::pair< QString, QString > > query;
query.push_back( std::pair< QString, QString >( "engine", QString::fromStdString( getId() ) ) );
Utils::Url::setQueryItems( url, query );
string encodedUrl = url.toEncoded().data();

View file

@ -196,7 +196,7 @@ public:
getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override;
void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
@ -369,7 +369,7 @@ QString XdxfDictionary::getMainFilename()
return getDictionaryFilenames()[ 0 ].c_str();
}
void XdxfDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration )
void XdxfDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -381,8 +381,6 @@ void XdxfDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
if ( ensureInitDone().size() )
return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "Xdxf: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -217,7 +217,7 @@ public:
getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override;
void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
@ -480,7 +480,7 @@ QString const & ZimDictionary::getDescription()
return dictionaryDescription;
}
void ZimDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration )
void ZimDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -492,9 +492,6 @@ void ZimDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
if ( !ensureInitDone().empty() )
return;
if ( firstIteration )
return;
gdDebug( "Zim: Building the full-text index for dictionary: %s\n", getName().c_str() );
try {
FtsHelpers::makeFTSIndex( this, isCancelled );

View file

@ -76,7 +76,7 @@ void makeFTSIndex( BtreeIndexing::BtreeDictionary * dict, QAtomicInt & isCancell
if ( Utils::AtomicInt::loadAcquire( isCancelled ) )
throw exUserAbort();
QVector< uint32_t > offsets;
QList< uint32_t > offsets;
offsets.resize( setOfOffsets.size() );
uint32_t * ptr = offsets.data();
@ -220,7 +220,7 @@ void FTSResultsRequest::run()
}
if ( !offsetsForHeadwords.isEmpty() ) {
QVector< QString > headwords;
QList< QString > headwords;
QMutexLocker _( &dataMutex );
QString id = QString::fromUtf8( dict.getId().c_str() );
dict.getHeadwordsFromOffsets( offsetsForHeadwords, headwords, &isCancelled );

View file

@ -34,7 +34,7 @@ void Indexing::run()
const QString & dictionaryName = QString::fromUtf8( dictionary->getName().c_str() );
qDebug() << "[FULLTEXT] checking fts for the dictionary:" << dictionaryName;
emit sendNowIndexingName( dictionaryName );
dictionary->makeFTSIndex( isCancelled, false );
dictionary->makeFTSIndex( isCancelled );
} );
synchronizer.addFuture( f );
}

View file

@ -24,7 +24,7 @@ Group::Group( Config::Group const & cfgGroup,
iconData = iconFromData( cfgGroup.iconData );
QMap< string, sptr< Dictionary::Class > > groupDicts;
QVector< string > dictOrderList;
QList< string > dictOrderList;
auto dictMap = Dictionary::dictToMap( allDictionaries );
for ( auto const & dict : cfgGroup.dictionaries ) {

View file

@ -283,7 +283,7 @@ quint32 LangCoder::guessId( const QString & lang )
}
QPair< quint32, quint32 > LangCoder::findLangIdPairFromName( QString const & name )
std::pair< quint32, quint32 > LangCoder::findLangIdPairFromName( QString const & name )
{
static QRegularExpression reg( "(?=([a-z]{2,3})-([a-z]{2,3}))", QRegularExpression::CaseInsensitiveOption );
@ -301,7 +301,7 @@ QPair< quint32, quint32 > LangCoder::findLangIdPairFromName( QString const & nam
return { 0, 0 };
}
QPair< quint32, quint32 > LangCoder::findLangIdPairFromPath( std::string const & p )
std::pair< quint32, quint32 > LangCoder::findLangIdPairFromPath( std::string const & p )
{
return findLangIdPairFromName( QFileInfo( QString::fromStdString( p ) ).fileName() );
}

View file

@ -40,8 +40,8 @@ public:
static quint32 findIdForLanguageCode3( std::string const & );
/// find id pairs like en-zh in dictioanry name
static QPair< quint32, quint32 > findLangIdPairFromName( QString const & );
static QPair< quint32, quint32 > findLangIdPairFromPath( std::string const & );
static std::pair< quint32, quint32 > findLangIdPairFromName( QString const & );
static std::pair< quint32, quint32 > findLangIdPairFromPath( std::string const & );
static quint32 guessId( const QString & lang );

View file

@ -30,7 +30,7 @@ SpeechClient::Engines SpeechClient::availableEngines()
qDebug() << engine_name << sp->state();
// const QVector< QLocale > locales = sp->availableLocales();
// const QList< QLocale > locales = sp->availableLocales();
// for ( const QLocale & locale : locales )
{
QLocale locale;

View file

@ -27,7 +27,7 @@ void SplitFile::appendFile( const QString & name )
void SplitFile::close()
{
for ( QVector< QFile * >::const_iterator i = files.begin(); i != files.end(); ++i ) {
for ( QList< QFile * >::const_iterator i = files.begin(); i != files.end(); ++i ) {
( *i )->close();
delete ( *i );
}
@ -40,7 +40,7 @@ void SplitFile::close()
void SplitFile::getFilenames( vector< string > & names ) const
{
for ( QVector< QFile * >::const_iterator i = files.begin(); i != files.end(); ++i )
for ( QList< QFile * >::const_iterator i = files.begin(); i != files.end(); ++i )
names.push_back( ( *i )->fileName().toStdString() );
}
@ -51,7 +51,7 @@ int SplitFile::getCurrentFile() const
bool SplitFile::open( QFile::OpenMode mode )
{
for ( QVector< QFile * >::iterator i = files.begin(); i != files.end(); ++i )
for ( QList< QFile * >::iterator i = files.begin(); i != files.end(); ++i )
if ( !( *i )->open( mode ) ) {
close();
return false;

View file

@ -2,7 +2,7 @@
#define __SPLITFILE_HH_INCLUDED__
#include <QFile>
#include <QVector>
#include <QList>
#include <QString>
#include <vector>
@ -19,8 +19,8 @@ class SplitFile
{
protected:
QVector< QFile * > files;
QVector< quint64 > offsets;
QList< QFile * > files;
QList< quint64 > offsets;
int currentFile;
void appendFile( const QString & name );

View file

@ -19,7 +19,7 @@
#include <QMenu>
#include <QMessageBox>
#include <QTimer>
#include <QVector>
#include <QList>
using std::vector;
@ -374,8 +374,8 @@ void DictListModel::addSelectedUniqueFromModel( QItemSelectionModel * source )
if ( !baseModel )
return;
QVector< std::string > list;
QVector< std::string > dicts;
QList< std::string > list;
QList< std::string > dicts;
for ( const auto & dictionarie : dictionaries )
dicts.append( dictionarie->getId() );
@ -649,8 +649,8 @@ void DictGroupsWidget::addAutoGroups()
!= QMessageBox::Yes )
return;
QMap< QString, QVector< sptr< Dictionary::Class > > > dictMap;
QMap< QString, QVector< sptr< Dictionary::Class > > > morphoMap;
QMap< QString, QList< sptr< Dictionary::Class > > > dictMap;
QMap< QString, QList< sptr< Dictionary::Class > > > morphoMap;
// Put active dictionaries into lists
@ -660,7 +660,7 @@ void DictGroupsWidget::addAutoGroups()
if ( idFrom == 0 ) {
// Attempt to find language pair in dictionary name
const QPair< quint32, quint32 > ids =
const std::pair< quint32, quint32 > ids =
LangCoder::findLangIdPairFromName( QString::fromUtf8( dict->getName().c_str() ) );
idFrom = ids.first;
idTo = ids.second;
@ -693,7 +693,7 @@ void DictGroupsWidget::addAutoGroups()
// Insert morphology dictionaries into corresponding lists
for ( const auto & gr : groupList ) {
if ( auto morpho_key = gr.left( 2 ).toLower(); morphoMap.contains( morpho_key ) ) {
QVector< sptr< Dictionary::Class > > vdg = dictMap[ gr ];
QList< sptr< Dictionary::Class > > vdg = dictMap[ gr ];
vdg += morphoMap[ morpho_key ];
dictMap[ gr ] = vdg;
}
@ -704,7 +704,7 @@ void DictGroupsWidget::addAutoGroups()
const auto idx = addUniqueGroup( gr );
// add dictionaries into the current group
QVector< sptr< Dictionary::Class > > const vd = dictMap[ gr ];
QList< sptr< Dictionary::Class > > const vd = dictMap[ gr ];
DictListModel * model = getModelAt( idx );
if ( !model )
continue;

View file

@ -7,9 +7,9 @@
#include "language.hh"
#include <algorithm>
#include <utility>
#include <QMenu>
#include <QPair>
using std::vector;
using std::sort;
@ -33,7 +33,8 @@ bool dictLessThan( sptr< Dictionary::Class > const & dict1, sptr< Dictionary::Cl
int idFrom1 = dict1->getLangFrom();
int idTo1 = dict1->getLangTo();
if ( idFrom1 == 0 ) {
QPair< quint32, quint32 > ids = LangCoder::findLangIdPairFromName( QString::fromUtf8( dict1->getName().c_str() ) );
std::pair< quint32, quint32 > ids =
LangCoder::findLangIdPairFromName( QString::fromUtf8( dict1->getName().c_str() ) );
idFrom1 = ids.first;
idTo1 = ids.second;
}
@ -41,7 +42,8 @@ bool dictLessThan( sptr< Dictionary::Class > const & dict1, sptr< Dictionary::Cl
int idFrom2 = dict2->getLangFrom();
int idTo2 = dict2->getLangTo();
if ( idFrom2 == 0 ) {
QPair< quint32, quint32 > ids = LangCoder::findLangIdPairFromName( QString::fromUtf8( dict2->getName().c_str() ) );
std::pair< quint32, quint32 > ids =
LangCoder::findLangIdPairFromName( QString::fromUtf8( dict2->getName().c_str() ) );
idFrom2 = ids.first;
idTo2 = ids.second;
}

View file

@ -230,7 +230,7 @@ void SplitZipFile::setFileName( const QString & name )
QDateTime SplitZipFile::lastModified() const
{
unsigned long ts = 0;
for ( QVector< QFile * >::const_iterator i = files.begin(); i != files.end(); ++i ) {
for ( QList< QFile * >::const_iterator i = files.begin(); i != files.end(); ++i ) {
unsigned long t = QFileInfo( ( *i )->fileName() ).lastModified().toSecsSinceEpoch();
if ( t > ts )
ts = t;