Merge branch 'staged' into dev

This commit is contained in:
Xiao YiFang 2022-12-31 00:37:22 +08:00
commit 4b9906dc52
42 changed files with 517 additions and 773 deletions

View file

@ -31,5 +31,9 @@ Checks: >
CheckOptions:
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-use-override.IgnoreDestructors
value: 1
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: 1
...

34
aard.cc
View file

@ -239,43 +239,43 @@ class AardDictionary: public BtreeIndexing::BtreeDictionary
~AardDictionary();
virtual string getName() noexcept
string getName() noexcept override
{ return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() noexcept
map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return idxHeader.articleCount; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const
inline quint32 getLangFrom() const override
{ return idxHeader.langFrom; }
inline virtual quint32 getLangTo() const
inline quint32 getLangTo() const override
{ return idxHeader.langTo; }
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
sptr< Dictionary::DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &,
bool ignoreDiacritics )
bool ignoreDiacritics ) override
;
virtual QString const& getDescription();
QString const& getDescription() override;
virtual sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
int searchMode, bool matchCase,
int distanceBetweenWords,
int maxResults,
bool ignoreWordsOrder,
bool ignoreDiacritics );
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration ) override;
virtual void setFTSParameters( Config::FullTextSearch const & fts )
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = fts.enabled
&& !fts.disabledTypes.contains( "AARD", Qt::CaseInsensitive )
@ -284,7 +284,7 @@ class AardDictionary: public BtreeIndexing::BtreeDictionary
protected:
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
private:
@ -666,7 +666,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class AardArticleRequest: public Dictionary::DataRequest
@ -694,7 +694,7 @@ public:
void run(); // Run from another thread by DslArticleRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}

View file

@ -127,7 +127,7 @@ public:
/// Create text without diacriticss
/// and store diacritic marks positions
virtual void setText( QString const & baseString )
void setText( QString const & baseString ) override
{
accentMarkPos.clear();
normalizedString.clear();

50
bgl.cc
View file

@ -198,49 +198,49 @@ namespace
BglDictionary( string const & id, string const & indexFile,
string const & dictionaryFile );
virtual string getName() noexcept
string getName() noexcept override
{ return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() noexcept
map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return idxHeader.articleCount; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const
inline quint32 getLangFrom() const override
{ return idxHeader.langFrom; }
inline virtual quint32 getLangTo() const
inline quint32 getLangTo() const override
{ return idxHeader.langTo; }
virtual sptr< Dictionary::WordSearchRequest > findHeadwordsForSynonym( wstring const & )
sptr< Dictionary::WordSearchRequest > findHeadwordsForSynonym( wstring const & ) override
;
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
sptr< Dictionary::DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &,
bool ignoreDiacritics )
bool ignoreDiacritics ) override
;
virtual sptr< Dictionary::DataRequest > getResource( string const & name )
sptr< Dictionary::DataRequest > getResource( string const & name ) override
;
virtual sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
int searchMode, bool matchCase,
int distanceBetweenWords,
int maxResults,
bool ignoreWordsOrder,
bool ignoreDiacritics );
virtual QString const& getDescription();
bool ignoreDiacritics ) override;
QString const& getDescription() override;
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration ) override;
virtual void setFTSParameters( Config::FullTextSearch const & fts )
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = fts.enabled
&& !fts.disabledTypes.contains( "BGL", Qt::CaseInsensitive )
@ -249,7 +249,7 @@ namespace
protected:
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
private:
@ -509,7 +509,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class BglHeadwordsRequest: public Dictionary::WordSearchRequest
@ -534,7 +534,7 @@ public:
void run(); // Run from another thread by BglHeadwordsRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -656,7 +656,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class BglArticleRequest: public Dictionary::DataRequest
@ -684,7 +684,7 @@ public:
void run(); // Run from another thread by BglArticleRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -951,7 +951,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class BglResourceRequest: public Dictionary::DataRequest
@ -985,7 +985,7 @@ public:
void run(); // Run from another thread by BglResourceRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -1126,8 +1126,8 @@ sptr< Dictionary::DataRequest > BglDictionary::getResource( string const & name
{ return resources; }
protected:
virtual void handleBabylonResource( string const & filename,
char const * data, size_t size );
void handleBabylonResource( string const & filename,
char const * data, size_t size ) override;
};
void ResourceHandler::handleBabylonResource( string const & filename,

View file

@ -126,7 +126,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
void BtreeWordSearchRunnable::run()

View file

@ -31,7 +31,7 @@ public:
~CharacterConversionDictionary();
std::vector< gd::wstring > getAlternateWritings( gd::wstring const & )
noexcept;
noexcept override;
};
CharacterConversionDictionary::CharacterConversionDictionary( std::string const & id,

View file

@ -1782,7 +1782,7 @@ void save( Class const & c )
preferences.appendChild( opt );
opt = dd.createElement( "mainWindowHotkey" );
opt.appendChild( dd.createTextNode( c.preferences.mainWindowHotkey.toKeySequence().toString() ) );
opt.appendChild( dd.createTextNode( c.preferences.mainWindowHotkey.toString() ) );
preferences.appendChild( opt );
opt = dd.createElement( "enableClipboardHotkey" );
@ -1790,7 +1790,7 @@ void save( Class const & c )
preferences.appendChild( opt );
opt = dd.createElement( "clipboardHotkey" );
opt.appendChild( dd.createTextNode( c.preferences.clipboardHotkey.toKeySequence().toString() ) );
opt.appendChild( dd.createTextNode( c.preferences.clipboardHotkey.toString() ) );
preferences.appendChild( opt );
opt = dd.createElement( "startWithScanPopupOn" );

View file

@ -157,8 +157,12 @@ struct HotKey
HotKey();
/// We use the first two keys of QKeySequence, with modifiers being stored
/// in the first one.
/// Hotkey's constructor, take a QKeySequence's first two keys
/// 1st key's modifier will be the `modifiers` above
/// 1st key without modifier will becomes `key1`
/// 2nd key without modifier will becomes `key2`
/// The relation between the int and qt's KeyCode should consult qt's doc
HotKey( QKeySequence const & );
QKeySequence toKeySequence() const;
@ -316,9 +320,9 @@ struct Preferences
bool searchInDock;
bool enableMainWindowHotkey;
HotKey mainWindowHotkey;
QKeySequence mainWindowHotkey;
bool enableClipboardHotkey;
HotKey clipboardHotkey;
QKeySequence clipboardHotkey;
bool startWithScanPopupOn;
bool enableScanPopupModifiers;

View file

@ -100,45 +100,45 @@ public:
~DictdDictionary();
virtual string getName() noexcept
string getName() noexcept override
{ return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() noexcept
map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return idxHeader.articleCount; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return idxHeader.wordCount; }
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
inline virtual quint32 getLangFrom() const
inline quint32 getLangFrom() const override
{ return idxHeader.langFrom; }
inline virtual quint32 getLangTo() const
inline quint32 getLangTo() const override
{ return idxHeader.langTo; }
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
sptr< Dictionary::DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &,
bool ignoreDiacritics )
bool ignoreDiacritics ) override
;
virtual QString const& getDescription();
QString const& getDescription() override;
virtual sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
int searchMode, bool matchCase,
int distanceBetweenWords,
int maxResults,
bool ignoreWordsOrder,
bool ignoreDiacritics );
void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration ) override;
virtual void setFTSParameters( Config::FullTextSearch const & fts )
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = fts.enabled
&& !fts.disabledTypes.contains( "DICTD", Qt::CaseInsensitive )

View file

@ -19,6 +19,9 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>3</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
@ -75,7 +78,37 @@
</widget>
</item>
<item>
<widget class="HotKeyEdit" name="shortcut"/>
<widget class="QKeySequenceEdit" name="shortcut">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearShortCut">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/clear.png</normaloff>:/icons/clear.png</iconset>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</item>
@ -101,14 +134,16 @@
<extends>QListWidget</extends>
<header>groups_widgets.hh</header>
</customwidget>
<customwidget>
<class>HotKeyEdit</class>
<extends>QLineEdit</extends>
<header>hotkeyedit.hh</header>
</customwidget>
</customwidgets>
<resources>
<include location="resources.qrc"/>
</resources>
<connections/>
<connections>
<connection>
<sender>clearShortCut</sender>
<signal>clicked()</signal>
<receiver>shortcut</receiver>
<slot>clear()</slot>
</connection>
</connections>
</ui>

View file

@ -209,35 +209,35 @@ public:
strategies.append( "prefix" );
}
virtual string getName() noexcept
string getName() noexcept override
{ return name; }
virtual map< Property, string > getProperties() noexcept
map< Property, string > getProperties() noexcept override
{ return map< Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return 0; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return 0; }
virtual sptr< WordSearchRequest > prefixMatch( wstring const &,
unsigned long maxResults ) ;
sptr< WordSearchRequest > prefixMatch( wstring const &,
unsigned long maxResults ) override ;
virtual sptr< DataRequest > getArticle( wstring const &, vector< wstring > const & alts,
wstring const &, bool )
sptr< DataRequest > getArticle( wstring const &, vector< wstring > const & alts,
wstring const &, bool ) override
;
virtual quint32 getLangFrom() const
quint32 getLangFrom() const override
{ return langId; }
virtual quint32 getLangTo() const
quint32 getLangTo() const override
{ return langId; }
virtual QString const & getDescription();
QString const & getDescription() override;
protected:
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
void getServerDatabases();
@ -366,7 +366,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class DictServerWordSearchRequest: public Dictionary::WordSearchRequest
@ -397,7 +397,7 @@ public:
hasExited.acquire();
}
virtual void cancel();
void cancel() override;
};
@ -580,7 +580,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class DictServerArticleRequest: public Dictionary::DataRequest
@ -611,7 +611,7 @@ public:
hasExited.acquire();
}
virtual void cancel();
void cancel() override;
};

44
dsl.cc
View file

@ -181,26 +181,26 @@ public:
vector< string > const & dictionaryFiles,
int maxPictureWidth_ );
virtual void deferredInit();
void deferredInit() override;
~DslDictionary();
virtual string getName() noexcept
string getName() noexcept override
{ return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() noexcept
map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return idxHeader.articleCount; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const
inline quint32 getLangFrom() const override
{ return idxHeader.langFrom; }
inline virtual quint32 getLangTo() const
inline quint32 getLangTo() const override
{ return idxHeader.langTo; }
inline virtual string getResourceDir1() const
@ -211,30 +211,30 @@ public:
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
sptr< Dictionary::DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &,
bool ignoreDiacritics )
bool ignoreDiacritics ) override
;
virtual sptr< Dictionary::DataRequest > getResource( string const & name )
sptr< Dictionary::DataRequest > getResource( string const & name ) override
;
virtual sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
int searchMode, bool matchCase,
int distanceBetweenWords,
int maxResults,
bool ignoreWordsOrder,
bool ignoreDiacritics );
virtual QString const& getDescription();
bool ignoreDiacritics ) override;
QString const& getDescription() override;
virtual QString getMainFilename();
QString getMainFilename() override;
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration ) override;
virtual void setFTSParameters( Config::FullTextSearch const & fts )
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
if( ensureInitDone().size() )
return;
@ -244,16 +244,16 @@ public:
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize );
}
virtual uint32_t getFtsIndexVersion()
uint32_t getFtsIndexVersion() override
{ return CurrentFtsIndexVersion; }
protected:
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
private:
virtual string const & ensureInitDone();
string const & ensureInitDone() override;
void doDeferredInit();
/// Loads the article. Does not process the DSL language.
@ -1588,7 +1588,7 @@ public:
void run();
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -1763,7 +1763,7 @@ public:
void run();
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}

View file

@ -97,46 +97,46 @@ public:
~EpwingDictionary();
virtual string getName() noexcept
string getName() noexcept override
{ return bookName; }
virtual map< Dictionary::Property, string > getProperties() noexcept
map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return idxHeader.articleCount; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const
inline quint32 getLangFrom() const override
{ return idxHeader.langFrom; }
inline virtual quint32 getLangTo() const
inline quint32 getLangTo() const override
{ return idxHeader.langTo; }
virtual QString const& getDescription();
QString const& getDescription() override;
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
sptr< Dictionary::DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &,
bool ignoreDiacritics )
bool ignoreDiacritics ) override
;
virtual sptr< Dictionary::DataRequest > getResource( string const & name )
sptr< Dictionary::DataRequest > getResource( string const & name ) override
;
virtual sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
int searchMode, bool matchCase,
int distanceBetweenWords,
int maxResults,
bool ignoreWordsOrder,
bool ignoreDiacritics );
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration ) override;
virtual void setFTSParameters( Config::FullTextSearch const & fts )
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
if( ensureInitDone().size() )
return;
@ -152,19 +152,19 @@ public:
static bool isJapanesePunctiation( gd::wchar ch );
virtual sptr< Dictionary::WordSearchRequest > prefixMatch( wstring const &,
unsigned long )
sptr< Dictionary::WordSearchRequest > prefixMatch( wstring const &,
unsigned long ) override
;
virtual sptr< Dictionary::WordSearchRequest > stemmedMatch( wstring const &,
sptr< Dictionary::WordSearchRequest > stemmedMatch( wstring const &,
unsigned minLength,
unsigned maxSuffixVariation,
unsigned long maxResults )
unsigned long maxResults ) override
;
protected:
void loadIcon() noexcept;
void loadIcon() noexcept override;
private:
@ -460,7 +460,7 @@ public:
QVector< int > & offsets,
multimap< wstring, pair< string, string > > & mainArticles );
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -677,7 +677,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class EpwingResourceRequest: public Dictionary::DataRequest
@ -704,7 +704,7 @@ public:
void run(); // Run from another thread by EpwingResourceRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -860,7 +860,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class EpwingWordSearchRequest: public BtreeIndexing::BtreeWordSearchRequest
@ -884,7 +884,7 @@ public:
new EpwingWordSearchRunnable( *this, hasExited ) );
}
virtual void findMatches();
void findMatches() override;
};
void EpwingWordSearchRunnable::run()

View file

@ -42,20 +42,20 @@ public:
{
}
virtual string getName() noexcept
string getName() noexcept override
{ return name; }
virtual map< Property, string > getProperties() noexcept
map< Property, string > getProperties() noexcept override
{ return map< Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return 0; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return 0; }
virtual sptr< WordSearchRequest > prefixMatch( wstring const & /*word*/,
unsigned long /*maxResults*/ )
sptr< WordSearchRequest > prefixMatch( wstring const & /*word*/,
unsigned long /*maxResults*/ ) override
{
sptr< WordSearchRequestInstant > sr = std::make_shared<WordSearchRequestInstant>();
@ -64,13 +64,13 @@ public:
return sr;
}
virtual sptr< DataRequest > getArticle( wstring const &, vector< wstring > const & alts,
wstring const &, bool )
sptr< DataRequest > getArticle( wstring const &, vector< wstring > const & alts,
wstring const &, bool ) override
;
protected:
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
};

48
gls.cc
View file

@ -372,52 +372,52 @@ public:
~GlsDictionary();
virtual string getName() noexcept
string getName() noexcept override
{ return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() noexcept
map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return idxHeader.articleCount; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const
inline quint32 getLangFrom() const override
{ return idxHeader.langFrom; }
inline virtual quint32 getLangTo() const
inline quint32 getLangTo() const override
{ return idxHeader.langTo; }
virtual sptr< Dictionary::WordSearchRequest > findHeadwordsForSynonym( wstring const & )
sptr< Dictionary::WordSearchRequest > findHeadwordsForSynonym( wstring const & ) override
;
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
sptr< Dictionary::DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &,
bool ignoreDiacritics )
bool ignoreDiacritics ) override
;
virtual sptr< Dictionary::DataRequest > getResource( string const & name )
sptr< Dictionary::DataRequest > getResource( string const & name ) override
;
virtual QString const& getDescription();
QString const& getDescription() override;
virtual QString getMainFilename();
QString getMainFilename() override;
virtual sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
int searchMode, bool matchCase,
int distanceBetweenWords,
int maxResults,
bool ignoreWordsOrder,
bool ignoreDiacritics );
bool ignoreDiacritics ) override;
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration ) override;
virtual void setFTSParameters( Config::FullTextSearch const & fts )
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = fts.enabled
&& !fts.disabledTypes.contains( "GLS", Qt::CaseInsensitive )
@ -425,7 +425,7 @@ public:
}
protected:
void loadIcon() noexcept;
void loadIcon() noexcept override;
private:
@ -886,7 +886,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class GlsHeadwordsRequest: public Dictionary::WordSearchRequest
@ -910,7 +910,7 @@ public:
void run(); // Run from another thread by StardictHeadwordsRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -1005,7 +1005,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class GlsArticleRequest: public Dictionary::DataRequest
@ -1033,7 +1033,7 @@ public:
void run(); // Run from another thread by GlsArticleRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -1185,7 +1185,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class GlsResourceRequest: public Dictionary::DataRequest
@ -1212,7 +1212,7 @@ public:
void run(); // Run from another thread by GlsResourceRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}

View file

@ -327,7 +327,6 @@ HEADERS += folding.hh \
processwrapper.hh \
hotkeywrapper.hh \
searchpanewidget.hh \
hotkeyedit.hh \
langcoder.hh \
editdictionaries.hh \
loaddictionaries.hh \
@ -467,7 +466,6 @@ SOURCES += folding.cc \
wstring_qt.cc \
processwrapper.cc \
hotkeywrapper.cc \
hotkeyedit.cc \
langcoder.cc \
editdictionaries.cc \
loaddictionaries.cc \

View file

@ -33,6 +33,11 @@ DictGroupWidget::DictGroupWidget( QWidget * parent,
ui.setupUi( this );
ui.dictionaries->populate( Instances::Group( group, dicts, Config::Group() ).dictionaries, dicts );
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
ui.shortcut->setClearButtonEnabled(true);
ui.clearShortCut->hide();
#endif
// Populate icons' list
QStringList icons = QDir( ":/flags/" ).entryList( QDir::Files, QDir::NoSort );
@ -61,7 +66,7 @@ DictGroupWidget::DictGroupWidget( QWidget * parent,
if ( usesIconData )
ui.groupIcon->setCurrentIndex( 1 );
ui.shortcut->setHotKey( Config::HotKey( group.shortcut ) );
ui.shortcut->setKeySequence( group.shortcut );
ui.favoritesFolder->setText( group.favoritesFolder );
@ -126,7 +131,7 @@ Config::Group DictGroupWidget::makeGroup() const
g.icon = ui.groupIcon->itemData( currentIndex ).toString();
g.shortcut = ui.shortcut->getHotKey().toKeySequence();
g.shortcut = ui.shortcut->keySequence();
g.favoritesFolder = ui.favoritesFolder->text().replace( '\\', '/' );

View file

@ -1,220 +0,0 @@
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#include "hotkeyedit.hh"
#include <QKeyEvent>
#ifdef Q_OS_WIN
#include <windows.h>
#endif
HotKeyEdit::HotKeyEdit( QWidget * parent ):
QLineEdit( parent ),
currentModifiers( 0 ), currentKey1( 0 ), currentKey2( 0 ),
continuingCombo( false )
{
renderCurrentValue();
installEventFilter( this );
}
void HotKeyEdit::setHotKey( Config::HotKey const & hk )
{
currentModifiers = hk.modifiers;
currentKey1 = hk.key1;
currentKey2 = hk.key2;
renderCurrentValue();
}
Config::HotKey HotKeyEdit::getHotKey() const
{
Config::HotKey hk;
hk.modifiers = currentModifiers;
hk.key1 = currentKey1;
hk.key2 = currentKey2;
return hk;
}
void HotKeyEdit::renderCurrentValue()
{
QString result;
if ( currentKey1 )
{
result = QKeySequence( currentKey1 | currentModifiers ).toString( QKeySequence::NativeText );
if ( currentKey2 )
result += "+" + QKeySequence( currentKey2 ).toString( QKeySequence::NativeText );
}
setText( result );
}
void HotKeyEdit::keyPressEvent( QKeyEvent * event )
{
int key = event->key();
Qt::KeyboardModifiers modifiers = event->modifiers() & ~Qt::KeypadModifier;
#ifdef Q_OS_WIN
if( objectName() == "mainWindowHotkey" || objectName() == "clipboardHotkey" )
{
int newkey = VkeyToQTkey( event->nativeVirtualKey() );
if( newkey )
key = newkey;
}
#endif
switch( key )
{
case 0:
case Qt::Key_unknown:
case Qt::Key_Shift:
case Qt::Key_Control:
case Qt::Key_Meta:
case Qt::Key_Alt:
case Qt::Key_AltGr:
continuingCombo = false;
QLineEdit::keyPressEvent( event );
break;
default:
{
if ( !modifiers &&
( ( key == Qt::Key_Backspace ) || ( key == Qt::Key_Delete ) ) )
{
// Delete current combo
currentKey1 = 0;
currentKey2 = 0;
currentModifiers = Qt::NoModifier;
continuingCombo = false;
}
else
if ( !continuingCombo )
{
if ( modifiers || event->text().isEmpty() ) // Don't allow plain letters
{
currentKey2 = 0;
currentKey1 = key;
currentModifiers = modifiers;
continuingCombo = true;
}
}
else
{
currentKey2 = key;
continuingCombo = false;
}
renderCurrentValue();
}
break;
}
}
void HotKeyEdit::keyReleaseEvent( QKeyEvent * event )
{
switch( event->key() )
{
case 0:
case Qt::Key_unknown:
case Qt::Key_Shift:
case Qt::Key_Control:
case Qt::Key_Meta:
case Qt::Key_Alt:
case Qt::Key_AltGr:
continuingCombo = false;
break;
}
QLineEdit::keyReleaseEvent( event );
}
bool HotKeyEdit::eventFilter( QObject *, QEvent * event )
{
if( event->type() == QEvent::ShortcutOverride )
{
event->accept();
return true;
}
return false;
}
#ifdef Q_OS_WIN
int HotKeyEdit::VkeyToQTkey( quint32 vkey )
{
if ( vkey >= Qt::Key_A && vkey <= Qt::Key_Z)
return vkey;
switch( vkey )
{
case VK_NUMPAD0: return Qt::Key_0;
case VK_NUMPAD1: return Qt::Key_1;
case VK_NUMPAD2: return Qt::Key_2;
case VK_NUMPAD3: return Qt::Key_3;
case VK_NUMPAD4: return Qt::Key_4;
case VK_NUMPAD5: return Qt::Key_5;
case VK_NUMPAD6: return Qt::Key_6;
case VK_NUMPAD7: return Qt::Key_7;
case VK_NUMPAD8: return Qt::Key_8;
case VK_NUMPAD9: return Qt::Key_9;
case VK_DIVIDE: return Qt::Key_Slash;
case VK_MULTIPLY: return Qt::Key_Asterisk;
case VK_SUBTRACT: return Qt::Key_Minus;
case VK_ADD: return Qt::Key_Plus;
case VK_DECIMAL: return Qt::Key_Period;
case VK_F1: return Qt::Key_F1;
case VK_F2: return Qt::Key_F2;
case VK_F3: return Qt::Key_F3;
case VK_F4: return Qt::Key_F4;
case VK_F5: return Qt::Key_F5;
case VK_F6: return Qt::Key_F6;
case VK_F7: return Qt::Key_F7;
case VK_F8: return Qt::Key_F8;
case VK_F9: return Qt::Key_F9;
case VK_F10: return Qt::Key_F10;
case VK_F11: return Qt::Key_F11;
case VK_F12: return Qt::Key_F12;
case VK_F13: return Qt::Key_F13;
case VK_F14: return Qt::Key_F14;
case VK_F15: return Qt::Key_F15;
case VK_F16: return Qt::Key_F16;
case VK_F17: return Qt::Key_F17;
case VK_F18: return Qt::Key_F18;
case VK_F19: return Qt::Key_F19;
case VK_F20: return Qt::Key_F20;
case VK_F21: return Qt::Key_F21;
case VK_F22: return Qt::Key_F22;
case VK_F23: return Qt::Key_F23;
case VK_F24: return Qt::Key_F24;
case 0x30: return Qt::Key_ParenRight;
case 0x31: return Qt::Key_Exclam;
case 0x32: return Qt::Key_At;
case 0x33: return Qt::Key_NumberSign;
case 0x34: return Qt::Key_Dollar;
case 0x35: return Qt::Key_Percent;
case 0x36: return Qt::Key_AsciiCircum;
case 0x37: return Qt::Key_Ampersand;
case 0x38: return Qt::Key_copyright;
case 0x39: return Qt::Key_ParenLeft;
case VK_OEM_MINUS: return Qt::Key_Underscore;
case VK_OEM_PLUS: return Qt::Key_Equal;
case VK_OEM_1: return Qt::Key_Semicolon;
case VK_OEM_2: return Qt::Key_Question;
case VK_OEM_3: return Qt::Key_QuoteLeft;
case VK_OEM_4: return Qt::Key_BracketLeft;
case VK_OEM_5: return Qt::Key_Backslash;
case VK_OEM_6: return Qt::Key_BracketRight;
case VK_OEM_7: return Qt::Key_Apostrophe;
case VK_OEM_COMMA: return Qt::Key_Less;
case VK_OEM_PERIOD: return Qt::Key_Greater;
default:;
}
return 0;
}
#endif

View file

@ -1,41 +0,0 @@
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef __HOTKEYEDIT_HH_INCLUDED__
#define __HOTKEYEDIT_HH_INCLUDED__
#include "config.hh"
#include <QLineEdit>
// This widget allows grabbing a hotkey
class HotKeyEdit: public QLineEdit
{
Q_OBJECT
Qt::KeyboardModifiers currentModifiers;
int currentKey1, currentKey2;
bool continuingCombo;
public:
HotKeyEdit( QWidget * parent = 0 );
void setHotKey( Config::HotKey const & );
Config::HotKey getHotKey() const;
protected:
void keyPressEvent( QKeyEvent * event );
void keyReleaseEvent( QKeyEvent * event );
private:
void renderCurrentValue();
bool eventFilter( QObject *, QEvent * event );
#ifdef Q_OS_WIN
int VkeyToQTkey( quint32 vkey );
#endif
};
#endif

View file

@ -295,6 +295,12 @@ void HotkeyWrapper::init()
hwnd = (HWND)root->winId();
}
bool HotkeyWrapper::setGlobalKey( QKeySequence const & seq, int handle )
{
Config::HotKey hk(seq);
return setGlobalKey(hk.key1,hk.key2,hk.modifiers,handle);
}
bool HotkeyWrapper::setGlobalKey( int key, int key2,
Qt::KeyboardModifiers modifier, int handle )
{
@ -622,6 +628,12 @@ void HotkeyWrapper::handleRecordEvent( XRecordInterceptData * data )
XRecordFreeData( data );
}
bool HotkeyWrapper::setGlobalKey( QKeySequence const & seq, int handle )
{
Config::HotKey hk(seq);
return setGlobalKey(hk.key1,hk.key2,hk.modifiers,handle);
}
bool HotkeyWrapper::setGlobalKey( int key, int key2,
Qt::KeyboardModifiers modifier, int handle )
{

View file

@ -30,6 +30,7 @@
#include "ex.hh"
#include "qtsingleapplication.h"
#include "utils.hh"
#include "config.hh"
//////////////////////////////////////////////////////////////////////////
@ -68,6 +69,8 @@ public:
bool setGlobalKey( int key, int key2, Qt::KeyboardModifiers modifier,
int handle );
bool setGlobalKey( QKeySequence const & , int );
/// Unregisters everything
void unregister();
@ -181,6 +184,8 @@ public:
int handle )
{ return true; }
bool setGlobalKey( QKeySequence const &, int ) { return true; }
void unregister()
{}

View file

@ -67,39 +67,39 @@ public:
{
}
virtual string getName() noexcept
string getName() noexcept override
{ return name; }
virtual map< Property, string > getProperties() noexcept
map< Property, string > getProperties() noexcept override
{ return map< Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return 0; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return 0; }
virtual sptr< WordSearchRequest > prefixMatch( wstring const &,
unsigned long maxResults )
sptr< WordSearchRequest > prefixMatch( wstring const &,
unsigned long maxResults ) override
;
virtual sptr< WordSearchRequest > findHeadwordsForSynonym( wstring const & )
sptr< WordSearchRequest > findHeadwordsForSynonym( wstring const & ) override
;
virtual sptr< DataRequest > getArticle( wstring const &,
sptr< DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &,
bool )
bool ) override
;
virtual bool isLocalDictionary()
bool isLocalDictionary() override
{ return true; }
virtual vector< wstring > getAlternateWritings( const wstring & word ) noexcept;
vector< wstring > getAlternateWritings( const wstring & word ) noexcept override;
protected:
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
private:
@ -199,7 +199,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class HunspellArticleRequest: public Dictionary::DataRequest
@ -228,7 +228,7 @@ public:
void run(); // Run from another thread by HunspellArticleRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -363,7 +363,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class HunspellHeadwordsRequest: public Dictionary::WordSearchRequest
@ -392,7 +392,7 @@ public:
void run(); // Run from another thread by HunspellHeadwordsRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -538,7 +538,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class HunspellPrefixMatchRequest: public Dictionary::WordSearchRequest
@ -567,7 +567,7 @@ public:
void run(); // Run from another thread by HunspellPrefixMatchRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}

16
lsa.cc
View file

@ -164,29 +164,29 @@ public:
LsaDictionary( string const & id, string const & indexFile,
vector< string > const & dictionaryFiles );
virtual string getName() noexcept;
string getName() noexcept override;
virtual map< Dictionary::Property, string > getProperties() noexcept
map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return idxHeader.soundsCount; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return getArticleCount(); }
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
sptr< Dictionary::DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &,
bool ignoreDiacritics )
bool ignoreDiacritics ) override
;
virtual sptr< Dictionary::DataRequest > getResource( string const & name )
sptr< Dictionary::DataRequest > getResource( string const & name ) override
;
protected:
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
};
string LsaDictionary::getName() noexcept

View file

@ -180,6 +180,12 @@ void HotkeyWrapper::unregister()
(static_cast< QHotkeyApplication * >( qApp ))->unregisterWrapper( this );
}
bool HotkeyWrapper::setGlobalKey( QKeySequence const & seq, int handle )
{
Config::HotKey hk(seq);
return setGlobalKey(hk.key1,hk.key2,hk.modifiers,handle);
}
bool HotkeyWrapper::setGlobalKey( int key, int key2, Qt::KeyboardModifiers modifier, int handle )
{
if ( !key )

View file

@ -86,7 +86,7 @@ using std::pair;
class InitSSLRunnable : public QRunnable
{
virtual void run()
void run() override
{
/// This action force SSL library initialisation which may continue a few seconds
QSslConfiguration::setDefaultConfiguration( QSslConfiguration::defaultConfiguration() );
@ -890,11 +890,18 @@ void MainWindow::clipboardChange( QClipboard::Mode m)
if(m == QClipboard::Selection){
// Multiple ways to stoping a word from showing up when selecting
// Multiple ways to stopping a word from showing up when selecting
// Explictly disabled on preferences
// Explicitly disabled on preferences
if(!cfg.preferences.trackSelectionScan) return;
// Explicitly disabled on preferences to ignore gd's own selection
if( cfg.preferences.ignoreOwnClipboardChanges
&& QApplication::clipboard()->ownsSelection() ){
return ;
}
// Keyboard Modifier
if(cfg.preferences.enableScanPopupModifiers &&
!KeyboardState::checkModifiersPressed(cfg.preferences.scanPopupModifiers)){
@ -908,7 +915,8 @@ void MainWindow::clipboardChange( QClipboard::Mode m)
return;
}
scanPopup->translateWordFromSelection();
// Use delay show to prevent multiple popups while selection in progress
scanPopup->selectionDelayTimer.start();
}
#else
scanPopup ->translateWordFromClipboard();
@ -1521,9 +1529,6 @@ void MainWindow::makeScanPopup()
scanPopup->setStyleSheet( styleSheet() );
if ( enableScanningAction->isChecked() )
scanPopup->enableScanning();
connect( scanPopup.get(), SIGNAL(editGroupRequested( unsigned ) ),
this, SLOT(editDictionaries( unsigned )), Qt::QueuedConnection );
@ -2206,9 +2211,16 @@ void MainWindow::editPreferences()
bool needReload = false;
// See if we need to reapply Qt stylesheets
if ( cfg.preferences.addonStyle != p.addonStyle || cfg.preferences.darkMode != p.darkMode)
if( cfg.preferences.darkMode != p.darkMode )
{
applyQtStyleSheet( p.addonStyle, p.darkMode );
}
// see if we need to reapply articleview style
if( cfg.preferences.displayStyle != p.displayStyle ||
cfg.preferences.addonStyle != p.addonStyle ||
cfg.preferences.darkReaderMode != p.darkReaderMode )
{
articleMaker.setDisplayStyle( p.displayStyle, p.addonStyle );
needReload = true;
}
@ -2910,10 +2922,23 @@ void MainWindow::toggleMainWindow( bool onlyShow )
else
if ( !onlyShow )
{
// On Windows and Linux, a hidden window won't show a task bar icon
// When trayicon is enabled, the duplication is unneeded
// On macOS, a hidden window will still show on the Dock,
// but click it won't bring it back, thus we can only minimize it.
#ifdef Q_OS_MAC
if (cfg.preferences.enableTrayIcon)
showMinimized();
#else
if (cfg.preferences.enableTrayIcon)
hide();
else
showMinimized();
#endif
if( headwordsDlg )
headwordsDlg->hide();
@ -2959,17 +2984,11 @@ void MainWindow::installHotKeys()
}
if ( cfg.preferences.enableMainWindowHotkey )
hotkeyWrapper->setGlobalKey( cfg.preferences.mainWindowHotkey.key1,
cfg.preferences.mainWindowHotkey.key2,
cfg.preferences.mainWindowHotkey.modifiers,
0 );
hotkeyWrapper->setGlobalKey( cfg.preferences.mainWindowHotkey,0 );
if ( cfg.preferences.enableClipboardHotkey && scanPopup.get() )
{
hotkeyWrapper->setGlobalKey( cfg.preferences.clipboardHotkey.key1,
cfg.preferences.clipboardHotkey.key2,
cfg.preferences.clipboardHotkey.modifiers,
1 );
hotkeyWrapper->setGlobalKey( cfg.preferences.clipboardHotkey,1 );
}
connect( hotkeyWrapper.get(),
@ -3164,7 +3183,6 @@ void MainWindow::scanEnableToggled( bool on )
{
if ( on )
{
scanPopup->enableScanning();
#ifdef Q_OS_MAC
if( !MacMouseOver::isAXAPIEnabled() )
mainStatusBar->showMessage( tr( "Accessibility API is not enabled" ), 10000,
@ -3174,7 +3192,6 @@ void MainWindow::scanEnableToggled( bool on )
}
else
{
scanPopup->disableScanning();
enableScanningAction->setIcon(QIcon(":/icons/wizard.svg"));
}
}

44
mdx.cc
View file

@ -225,56 +225,56 @@ public:
~MdxDictionary();
virtual void deferredInit();
void deferredInit() override;
virtual string getName() noexcept
string getName() noexcept override
{
return dictionaryName;
}
virtual map< Dictionary::Property, string > getProperties() noexcept
map< Dictionary::Property, string > getProperties() noexcept override
{
return map< Dictionary::Property, string >();
}
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{
return idxHeader.articleCount;
}
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{
return idxHeader.wordCount;
}
inline virtual quint32 getLangFrom() const
inline quint32 getLangFrom() const override
{
return idxHeader.langFrom;
}
inline virtual quint32 getLangTo() const
inline quint32 getLangTo() const override
{
return idxHeader.langTo;
}
virtual sptr< Dictionary::DataRequest > getArticle( wstring const & word,
sptr< Dictionary::DataRequest > getArticle( wstring const & word,
vector< wstring > const & alts,
wstring const &,
bool ignoreDiacritics ) ;
virtual sptr< Dictionary::DataRequest > getResource( string const & name ) ;
virtual QString const & getDescription();
bool ignoreDiacritics ) override ;
sptr< Dictionary::DataRequest > getResource( string const & name ) override ;
QString const & getDescription() override;
virtual sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
int searchMode, bool matchCase,
int distanceBetweenWords,
int maxResults,
bool ignoreWordsOrder,
bool ignoreDiacritics );
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration ) override;
virtual void setFTSParameters( Config::FullTextSearch const & fts )
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
if( ensureInitDone().size() )
return;
@ -288,11 +288,11 @@ public:
protected:
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
private:
virtual string const & ensureInitDone();
string const & ensureInitDone() override;
void doDeferredInit();
/// Loads an article with the given offset, filling the given strings.
@ -558,7 +558,7 @@ public:
void run();
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -709,7 +709,7 @@ public:
void run();
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -1338,7 +1338,7 @@ public:
{
}
virtual void handleRecord( QString const & headWord, MdictParser::RecordInfo const & recordInfo )
void handleRecord( QString const & headWord, MdictParser::RecordInfo const & recordInfo ) override
{
// Save the article's record info
uint32_t articleAddress = chunks.startNewBlock();
@ -1361,7 +1361,7 @@ public:
{
}
virtual void handleRecord( QString const & fileName, MdictParser::RecordInfo const & recordInfo )
void handleRecord( QString const & fileName, MdictParser::RecordInfo const & recordInfo ) override
{
uint32_t resourceInfoAddress = chunks.startNewBlock();
chunks.addToBlock( &recordInfo, sizeof( recordInfo ) );

View file

@ -48,33 +48,33 @@ public:
langId = LangCoder::code2toInt( url.mid( n - 2, 2 ).toLatin1().data() );
}
virtual string getName() noexcept
string getName() noexcept override
{ return name; }
virtual map< Property, string > getProperties() noexcept
map< Property, string > getProperties() noexcept override
{ return map< Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return 0; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return 0; }
virtual sptr< WordSearchRequest > prefixMatch( wstring const &,
unsigned long maxResults ) ;
sptr< WordSearchRequest > prefixMatch( wstring const &,
unsigned long maxResults ) override ;
virtual sptr< DataRequest > getArticle( wstring const &, vector< wstring > const & alts,
wstring const &, bool );
sptr< DataRequest > getArticle( wstring const &, vector< wstring > const & alts,
wstring const &, bool ) override;
virtual quint32 getLangFrom() const
quint32 getLangFrom() const override
{ return langId; }
virtual quint32 getLangTo() const
quint32 getLangTo() const override
{ return langId; }
protected:
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
};
@ -111,11 +111,11 @@ public:
~MediaWikiWordSearchRequest();
virtual void cancel();
void cancel() override;
private:
virtual void downloadFinished();
void downloadFinished() override;
};
MediaWikiWordSearchRequest::MediaWikiWordSearchRequest( wstring const & str,
@ -212,13 +212,13 @@ public:
QString const & url, QNetworkAccessManager & mgr,
Class * dictPtr_ );
virtual void cancel();
void cancel() override;
private:
void addQuery( QNetworkAccessManager & mgr, wstring const & word );
virtual void requestFinished( QNetworkReply * );
void requestFinished( QNetworkReply * ) override;
/// This simple set implementation should be much more efficient than tree-
/// and hash-based standard/Qt containers when there are very few elements.

View file

@ -178,9 +178,9 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
#endif
ui.enableMainWindowHotkey->setChecked( p.enableMainWindowHotkey );
ui.mainWindowHotkey->setHotKey( p.mainWindowHotkey );
ui.mainWindowHotkey->setKeySequence( p.mainWindowHotkey );
ui.enableClipboardHotkey->setChecked( p.enableClipboardHotkey );
ui.clipboardHotkey->setHotKey( p.clipboardHotkey );
ui.clipboardHotkey->setKeySequence( p.clipboardHotkey );
ui.startWithScanPopupOn->setChecked( p.startWithScanPopupOn );
ui.enableScanPopupModifiers->setChecked( p.enableScanPopupModifiers );
@ -398,9 +398,9 @@ Config::Preferences Preferences::getPreferences()
p.darkMode = ui.darkMode->isChecked();
p.darkReaderMode = ui.darkReaderMode->isChecked();
p.enableMainWindowHotkey = ui.enableMainWindowHotkey->isChecked();
p.mainWindowHotkey = ui.mainWindowHotkey->getHotKey();
p.mainWindowHotkey = ui.mainWindowHotkey->keySequence();
p.enableClipboardHotkey = ui.enableClipboardHotkey->isChecked();
p.clipboardHotkey = ui.clipboardHotkey->getHotKey();
p.clipboardHotkey = ui.clipboardHotkey->keySequence();
p.startWithScanPopupOn = ui.startWithScanPopupOn->isChecked();
p.enableScanPopupModifiers = ui.enableScanPopupModifiers->isChecked();

View file

@ -709,11 +709,7 @@ in the pressed state when the word selection changes.</string>
</spacer>
</item>
<item>
<widget class="HotKeyEdit" name="mainWindowHotkey">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
<widget class="QKeySequenceEdit" name="mainWindowHotkey"/>
</item>
</layout>
</item>
@ -740,11 +736,7 @@ in the pressed state when the word selection changes.</string>
</spacer>
</item>
<item>
<widget class="HotKeyEdit" name="clipboardHotkey">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
<widget class="QKeySequenceEdit" name="clipboardHotkey"/>
</item>
</layout>
</item>
@ -1760,11 +1752,6 @@ from Stardict, Babylon and GLS dictionaries</string>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HotKeyEdit</class>
<extends>QLineEdit</extends>
<header>hotkeyedit.hh</header>
</customwidget>
<customwidget>
<class>StylesComboBox</class>
<extends>QComboBox</extends>

View file

@ -30,30 +30,30 @@ public:
{
}
virtual string getName() noexcept
string getName() noexcept override
{ return prg.name.toUtf8().data(); }
virtual map< Property, string > getProperties() noexcept
map< Property, string > getProperties() noexcept override
{ return map< Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return 0; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return 0; }
virtual sptr< WordSearchRequest > prefixMatch( wstring const & word,
unsigned long maxResults )
sptr< WordSearchRequest > prefixMatch( wstring const & word,
unsigned long maxResults ) override
;
virtual sptr< DataRequest > getArticle( wstring const &,
sptr< DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &, bool )
wstring const &, bool ) override
;
protected:
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
};
sptr< WordSearchRequest > ProgramsDictionary::prefixMatch( wstring const & word,

View file

@ -71,7 +71,6 @@ ScanPopup::ScanPopup( QWidget * parent,
History & history_ ):
QMainWindow( parent ),
cfg( cfg_ ),
isScanningEnabled( false ),
allDictionaries( allDictionaries_ ),
groups( groups_ ),
history( history_ ),
@ -288,10 +287,11 @@ ScanPopup::ScanPopup( QWidget * parent,
translateWordFromSelection();
});
delayTimer.setSingleShot( true );
delayTimer.setInterval( 200 );
// Use delay show to prevent multiple popups while selection in progress
selectionDelayTimer.setSingleShot( true );
selectionDelayTimer.setInterval( 200 );
connect( &delayTimer, &QTimer::timeout, this, &ScanPopup::delayShow );
connect( &selectionDelayTimer, &QTimer::timeout, this, &ScanPopup::translateWordFromSelection );
#endif
applyZoomFactor();
@ -302,8 +302,6 @@ ScanPopup::~ScanPopup()
{
saveConfigData();
disableScanning();
ungrabGesture( Gestures::GDPinchGestureType );
ungrabGesture( Gestures::GDSwipeGestureType );
}
@ -317,22 +315,6 @@ void ScanPopup::saveConfigData()
cfg.popupWindowAlwaysOnTop = ui.onTopButton->isChecked();
}
void ScanPopup::enableScanning()
{
if ( !isScanningEnabled )
{
isScanningEnabled = true;
}
}
void ScanPopup::disableScanning()
{
if ( isScanningEnabled )
{
isScanningEnabled = false;
}
}
void ScanPopup::inspectElementWhenPinned( QWebEnginePage * page ){
if(cfg.pinPopupWindow)
emit inspectSignal(page);
@ -457,46 +439,6 @@ void ScanPopup::translateWord( QString const & word )
);
}
#ifdef HAVE_X11
void ScanPopup::delayShow()
{
QString subtype = "plain";
handleInputWord( QApplication::clipboard()->text( subtype, QClipboard::Selection ) );
}
#endif
[[deprecated("Favor the mainWindow's clipboardChanged ones")]]
void ScanPopup::clipboardChanged( QClipboard::Mode m )
{
if( !isScanningEnabled )
return;
#ifdef HAVE_X11
if( cfg.preferences.ignoreOwnClipboardChanges && ownsClipboardMode( m ) )
return;
if(m == QClipboard::Clipboard && !cfg.preferences.trackClipboardScan){
return;
}
if(m == QClipboard::Selection && !cfg.preferences.trackSelectionScan){
return;
}
if( m == QClipboard::Selection )
{
// Use delay show to prevent multiple popups while selection in progress
delayTimer.start();
return;
}
#endif
QString subtype = "plain";
handleInputWord( QApplication::clipboard()->text( subtype, m ) );
}
void ScanPopup::mouseHovered( QString const & str, bool forcePopup )
{
handleInputWord( str, forcePopup );

View file

@ -37,12 +37,6 @@ public:
~ScanPopup();
/// Enables scanning. When the object is created, the scanning is disabled
/// initially.
void enableScanning();
/// Disables scanning.
void disableScanning();
/// Applies current zoom factor to the popup's view. Should be called when
/// it's changed.
void applyZoomFactor();
@ -58,6 +52,8 @@ public:
/// Interaction with scan flag window
void showScanFlag();
void hideScanFlag();
QTimer selectionDelayTimer;
#endif
signals:
@ -126,7 +122,6 @@ private:
void updateDictionaryBar();
Config::Class & cfg;
bool isScanningEnabled;
std::vector< sptr< Dictionary::Class > > const & allDictionaries;
std::vector< sptr< Dictionary::Class > > dictionariesUnmuted;
Instances::Groups const & groups;
@ -146,7 +141,6 @@ private:
#ifdef HAVE_X11
ScanFlag * scanFlag;
QTimer delayTimer;
#endif
bool mouseEnteredOnce;
@ -194,7 +188,6 @@ private:
void updateSuggestionList();
void updateSuggestionList( QString const & text );
private slots:
void clipboardChanged( QClipboard::Mode );
void mouseHovered( QString const & , bool forcePopup);
void currentGroupChanged( int );
void prefixMatchFinished();
@ -235,9 +228,6 @@ private slots:
void titleChanged( ArticleView *, QString const & title );
#ifdef HAVE_X11
void delayShow();
#endif
};
#endif

View file

@ -143,43 +143,43 @@ class SdictDictionary: public BtreeIndexing::BtreeDictionary
~SdictDictionary();
virtual string getName() noexcept
string getName() noexcept override
{ return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() noexcept
map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return idxHeader.articleCount; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const
inline quint32 getLangFrom() const override
{ return idxHeader.langFrom; }
inline virtual quint32 getLangTo() const
inline quint32 getLangTo() const override
{ return idxHeader.langTo; }
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
sptr< Dictionary::DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &,
bool ignoreDiacritics )
bool ignoreDiacritics ) override
;
virtual QString const & getDescription();
QString const & getDescription() override;
virtual sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
int searchMode, bool matchCase,
int distanceBetweenWords,
int maxResults,
bool ignoreWordsOrder,
bool ignoreDiacritics );
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration ) override;
virtual void setFTSParameters( Config::FullTextSearch const & fts )
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = fts.enabled
&& !fts.disabledTypes.contains( "SDICT", Qt::CaseInsensitive )
@ -187,7 +187,7 @@ class SdictDictionary: public BtreeIndexing::BtreeDictionary
}
protected:
void loadIcon() noexcept;
void loadIcon() noexcept override;
private:
@ -500,7 +500,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class SdictArticleRequest: public Dictionary::DataRequest
@ -528,7 +528,7 @@ public:
void run(); // Run from another thread by DslArticleRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}

42
slob.cc
View file

@ -587,63 +587,63 @@ class SlobDictionary: public BtreeIndexing::BtreeDictionary
~SlobDictionary();
virtual string getName() noexcept
string getName() noexcept override
{ return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() noexcept
map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return idxHeader.articleCount; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const
inline quint32 getLangFrom() const override
{ return idxHeader.langFrom; }
inline virtual quint32 getLangTo() const
inline quint32 getLangTo() const override
{ return idxHeader.langTo; }
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
sptr< Dictionary::DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &,
bool ignoreDiacritics )
bool ignoreDiacritics ) override
;
virtual sptr< Dictionary::DataRequest > getResource( string const & name )
sptr< Dictionary::DataRequest > getResource( string const & name ) override
;
virtual QString const& getDescription();
QString const& getDescription() override;
/// Loads the resource.
void loadResource( std::string &resourceName, string & data );
virtual sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
int searchMode, bool matchCase,
int distanceBetweenWords,
int maxResults,
bool ignoreWordsOrder,
bool ignoreDiacritics );
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
quint64 getArticlePos(uint32_t articleNumber );
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration ) override;
virtual void setFTSParameters( Config::FullTextSearch const & fts )
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = fts.enabled
&& !fts.disabledTypes.contains( "SLOB", Qt::CaseInsensitive )
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize );
}
virtual uint32_t getFtsIndexVersion()
uint32_t getFtsIndexVersion() override
{ return 2; }
protected:
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
private:
@ -1329,7 +1329,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class SlobArticleRequest: public Dictionary::DataRequest
@ -1357,7 +1357,7 @@ public:
void run(); // Run from another thread by DslArticleRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -1518,7 +1518,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class SlobResourceRequest: public Dictionary::DataRequest
@ -1545,7 +1545,7 @@ public:
void run(); // Run from another thread by ZimResourceRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}

View file

@ -79,30 +79,30 @@ public:
vector< string > const & dictionaryFiles,
QString const & iconFilename_ );
virtual string getName() noexcept
string getName() noexcept override
{ return name; }
virtual map< Dictionary::Property, string > getProperties() noexcept
map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return idxHeader.soundsCount; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return getArticleCount(); }
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
sptr< Dictionary::DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &,
bool ignoreDiacritics )
bool ignoreDiacritics ) override
;
virtual sptr< Dictionary::DataRequest > getResource( string const & name )
sptr< Dictionary::DataRequest > getResource( string const & name ) override
;
protected:
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
};
SoundDirDictionary::SoundDirDictionary( string const & id,

View file

@ -468,10 +468,10 @@ void LinguaArticleRequest::requestFinished( QNetworkReply * r )
string title = pageJsonObj[ "title" ].toString().toHtmlEscaped().toStdString();
string audiolink =
pageJsonObj[ "imageinfo" ].toArray().at( 0 ).toObject()[ "url" ].toString().toHtmlEscaped().toStdString();
articleBody += addAudioLink( audiolink, dictionaryId );
articleBody += "<a href=";
articleBody += addAudioLink( "\""+audiolink+"\"", dictionaryId );
articleBody += R"(<a href=")";
articleBody += audiolink;
articleBody += ">";
articleBody += R"(">)";
articleBody += R"(<img src="qrcx://localhost/icons/playsound.png" border="0" alt="Play"/>)";
articleBody += title;
articleBody += "</a><br>";

View file

@ -158,51 +158,51 @@ public:
~StardictDictionary();
virtual string getName() noexcept
string getName() noexcept override
{ return bookName; }
virtual map< Dictionary::Property, string > getProperties() noexcept
map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return idxHeader.wordCount; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return idxHeader.wordCount + idxHeader.synWordCount; }
inline virtual quint32 getLangFrom() const
inline quint32 getLangFrom() const override
{ return idxHeader.langFrom; }
inline virtual quint32 getLangTo() const
inline quint32 getLangTo() const override
{ return idxHeader.langTo; }
virtual sptr< Dictionary::WordSearchRequest > findHeadwordsForSynonym( wstring const & )
sptr< Dictionary::WordSearchRequest > findHeadwordsForSynonym( wstring const & ) override
;
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
sptr< Dictionary::DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &,
bool ignoreDiacritics )
bool ignoreDiacritics ) override
;
virtual sptr< Dictionary::DataRequest > getResource( string const & name )
sptr< Dictionary::DataRequest > getResource( string const & name ) override
;
virtual QString const& getDescription();
QString const& getDescription() override;
virtual QString getMainFilename();
QString getMainFilename() override;
virtual sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
int searchMode, bool matchCase,
int distanceBetweenWords,
int maxResults,
bool ignoreWordsOrder,
bool ignoreDiacritics );
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration ) override;
virtual void setFTSParameters( Config::FullTextSearch const & fts )
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = fts.enabled
&& !fts.disabledTypes.contains( "STARDICT", Qt::CaseInsensitive )
@ -210,7 +210,7 @@ public:
}
protected:
void loadIcon() noexcept;
void loadIcon() noexcept override;
private:
@ -1226,7 +1226,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class StardictHeadwordsRequest: public Dictionary::WordSearchRequest
@ -1251,7 +1251,7 @@ public:
void run(); // Run from another thread by StardictHeadwordsRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -1345,7 +1345,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class StardictArticleRequest: public Dictionary::DataRequest
@ -1374,7 +1374,7 @@ public:
void run(); // Run from another thread by StardictArticleRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -1639,7 +1639,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class StardictResourceRequest: public Dictionary::DataRequest
@ -1666,7 +1666,7 @@ public:
void run(); // Run from another thread by StardictResourceRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}

View file

@ -44,30 +44,30 @@ public:
{
}
virtual string getName() noexcept
string getName() noexcept override
{ return voiceEngine.name.toUtf8().data(); }
virtual map< Property, string > getProperties() noexcept
map< Property, string > getProperties() noexcept override
{ return map< Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return 0; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return 0; }
virtual sptr< WordSearchRequest > prefixMatch( wstring const & word,
unsigned long maxResults )
sptr< WordSearchRequest > prefixMatch( wstring const & word,
unsigned long maxResults ) override
;
virtual sptr< DataRequest > getArticle( wstring const &,
sptr< DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &, bool )
wstring const &, bool ) override
;
protected:
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
};
sptr< WordSearchRequest > VoiceEnginesDictionary::prefixMatch( wstring const & /*word*/,

View file

@ -54,33 +54,33 @@ public:
dictionaryDescription = temp;
}
virtual string getName() noexcept
string getName() noexcept override
{ return name; }
virtual map< Property, string > getProperties() noexcept
map< Property, string > getProperties() noexcept override
{ return map< Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return 0; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return 0; }
virtual sptr< WordSearchRequest > prefixMatch( wstring const & word,
unsigned long ) ;
sptr< WordSearchRequest > prefixMatch( wstring const & word,
unsigned long ) override ;
virtual sptr< DataRequest > getArticle( wstring const &,
sptr< DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const & context, bool )
wstring const & context, bool ) override
;
virtual sptr< Dictionary::DataRequest > getResource( string const & name ) ;
sptr< Dictionary::DataRequest > getResource( string const & name ) override ;
void isolateWebCSS( QString & css );
protected:
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
};
sptr< WordSearchRequest > WebSiteDictionary::prefixMatch( wstring const & /*word*/,
@ -112,11 +112,11 @@ public:
~WebSiteArticleRequest()
{}
virtual void cancel();
void cancel() override;
private:
virtual void requestFinished( QNetworkReply * );
void requestFinished( QNetworkReply * ) override;
static QTextCodec * codecForHtml( QByteArray const & ba );
};
@ -429,11 +429,11 @@ public:
~WebSiteResourceRequest()
{}
virtual void cancel();
void cancel() override;
private:
virtual void requestFinished( QNetworkReply * );
void requestFinished( QNetworkReply * ) override;
};
WebSiteResourceRequest::WebSiteResourceRequest( QString const & url_,

56
xdxf.cc
View file

@ -147,60 +147,60 @@ public:
~XdxfDictionary();
virtual string getName() noexcept
string getName() noexcept override
{ return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() noexcept
map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return idxHeader.articleCount; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const
inline quint32 getLangFrom() const override
{ return idxHeader.langFrom; }
inline virtual quint32 getLangTo() const
inline quint32 getLangTo() const override
{ return idxHeader.langTo; }
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
sptr< Dictionary::DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &,
bool ignoreDiacritics )
bool ignoreDiacritics ) override
;
virtual sptr< Dictionary::DataRequest > getResource( string const & name )
sptr< Dictionary::DataRequest > getResource( string const & name ) override
;
virtual QString const& getDescription();
QString const& getDescription() override;
virtual QString getMainFilename();
QString getMainFilename() override;
virtual sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
int searchMode, bool matchCase,
int distanceBetweenWords,
int maxResults,
bool ignoreWordsOrder,
bool ignoreDiacritics );
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration ) override;
virtual void setFTSParameters( Config::FullTextSearch const & fts )
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = fts.enabled
&& !fts.disabledTypes.contains( "XDXF", Qt::CaseInsensitive )
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize );
}
virtual uint32_t getFtsIndexVersion()
uint32_t getFtsIndexVersion() override
{ return 1; }
protected:
void loadIcon() noexcept;
void loadIcon() noexcept override;
private:
@ -454,7 +454,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class XdxfArticleRequest: public Dictionary::DataRequest
@ -482,7 +482,7 @@ public:
void run(); // Run from another thread by XdxfArticleRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -700,22 +700,22 @@ protected:
dictData *dz;
virtual bool isSequential () const
bool isSequential () const override
{ return false; } // Which is a lie, but else pos() won't work
bool waitForReadyRead ( int )
bool waitForReadyRead ( int ) override
{ return !gzeof( gz ); }
qint64 bytesAvailable() const
qint64 bytesAvailable() const override
{
return ( gzeof( gz ) ? 0 : 1 ) + QIODevice::bytesAvailable();
}
virtual qint64 readData( char * data, qint64 maxSize );
qint64 readData( char * data, qint64 maxSize ) override;
virtual bool atEnd() const;
bool atEnd() const override;
virtual qint64 writeData ( const char * /*data*/, qint64 /*maxSize*/ )
qint64 writeData ( const char * /*data*/, qint64 /*maxSize*/ ) override
{ return -1; }
};
@ -983,7 +983,7 @@ public:
hasExited.release();
}
virtual void run();
void run() override;
};
class XdxfResourceRequest: public Dictionary::DataRequest
@ -1010,7 +1010,7 @@ public:
void run(); // Run from another thread by XdxfResourceRequestRunnable
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}

40
zim.cc
View file

@ -180,7 +180,7 @@ public:
ZimFile( const QString & name );
~ZimFile();
virtual void setFileName( const QString & name );
void setFileName( const QString & name ) override;
bool open();
void close()
{
@ -671,63 +671,63 @@ class ZimDictionary: public BtreeIndexing::BtreeDictionary
~ZimDictionary();
virtual string getName() noexcept
string getName() noexcept override
{ return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() noexcept
map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return idxHeader.articleCount; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const
inline quint32 getLangFrom() const override
{ return idxHeader.langFrom; }
inline virtual quint32 getLangTo() const
inline quint32 getLangTo() const override
{ return idxHeader.langTo; }
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
sptr< Dictionary::DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &,
bool ignoreDiacritics )
bool ignoreDiacritics ) override
;
virtual sptr< Dictionary::DataRequest > getResource( string const & name )
sptr< Dictionary::DataRequest > getResource( string const & name ) override
;
virtual QString const& getDescription();
QString const& getDescription() override;
/// Loads the resource.
void loadResource( std::string &resourceName, string & data );
virtual sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString,
int searchMode, bool matchCase,
int distanceBetweenWords,
int maxResults,
bool ignoreWordsOrder,
bool ignoreDiacritics );
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
quint32 getArticleText( uint32_t articleAddress, QString & headword, QString & text,
set< quint32 > * loadedArticles );
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration ) override;
virtual void setFTSParameters( Config::FullTextSearch const & fts )
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = fts.enabled
&& !fts.disabledTypes.contains( "ZIM", Qt::CaseInsensitive )
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize );
}
virtual void sortArticlesOffsetsForFTS( QVector< uint32_t > & offsets, QAtomicInt & isCancelled );
void sortArticlesOffsetsForFTS( QVector< uint32_t > & offsets, QAtomicInt & isCancelled ) override;
protected:
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
private:
@ -1280,7 +1280,7 @@ public:
void run();
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}
@ -1452,7 +1452,7 @@ public:
void run();
virtual void cancel()
void cancel() override
{
isCancelled.ref();
}

View file

@ -114,29 +114,29 @@ public:
ZipSoundsDictionary( string const & id, string const & indexFile,
vector< string > const & dictionaryFiles );
virtual string getName() noexcept;
string getName() noexcept override;
virtual map< Dictionary::Property, string > getProperties() noexcept
map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept
unsigned long getArticleCount() noexcept override
{ return idxHeader.soundsCount; }
virtual unsigned long getWordCount() noexcept
unsigned long getWordCount() noexcept override
{ return getArticleCount(); }
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
sptr< Dictionary::DataRequest > getArticle( wstring const &,
vector< wstring > const & alts,
wstring const &,
bool ignoreDiacritics )
bool ignoreDiacritics ) override
;
virtual sptr< Dictionary::DataRequest > getResource( string const & name )
sptr< Dictionary::DataRequest > getResource( string const & name ) override
;
protected:
virtual void loadIcon() noexcept;
void loadIcon() noexcept override;
};
ZipSoundsDictionary::ZipSoundsDictionary( string const & id,