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

@ -29,7 +29,11 @@ Checks: >
-readability-identifier-length, -readability-identifier-length,
-readability-function-cognitive-complexity, -readability-function-cognitive-complexity,
CheckOptions: CheckOptions:
- key: modernize-loop-convert.MinConfidence - key: modernize-loop-convert.MinConfidence
value: reasonable 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(); ~AardDictionary();
virtual string getName() noexcept string getName() noexcept override
{ return dictionaryName; } { return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() noexcept map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept unsigned long getArticleCount() noexcept override
{ return idxHeader.articleCount; } { return idxHeader.articleCount; }
virtual unsigned long getWordCount() noexcept unsigned long getWordCount() noexcept override
{ return idxHeader.wordCount; } { return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const inline quint32 getLangFrom() const override
{ return idxHeader.langFrom; } { return idxHeader.langFrom; }
inline virtual quint32 getLangTo() const inline quint32 getLangTo() const override
{ return idxHeader.langTo; } { return idxHeader.langTo; }
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &, sptr< Dictionary::DataRequest > getArticle( wstring const &,
vector< wstring > const & alts, vector< wstring > const & alts,
wstring const &, 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 searchMode, bool matchCase,
int distanceBetweenWords, int distanceBetweenWords,
int maxResults, int maxResults,
bool ignoreWordsOrder, 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 can_FTS = fts.enabled
&& !fts.disabledTypes.contains( "AARD", Qt::CaseInsensitive ) && !fts.disabledTypes.contains( "AARD", Qt::CaseInsensitive )
@ -284,7 +284,7 @@ class AardDictionary: public BtreeIndexing::BtreeDictionary
protected: protected:
virtual void loadIcon() noexcept; void loadIcon() noexcept override;
private: private:
@ -666,7 +666,7 @@ public:
hasExited.release(); hasExited.release();
} }
virtual void run(); void run() override;
}; };
class AardArticleRequest: public Dictionary::DataRequest class AardArticleRequest: public Dictionary::DataRequest
@ -694,7 +694,7 @@ public:
void run(); // Run from another thread by DslArticleRequestRunnable void run(); // Run from another thread by DslArticleRequestRunnable
virtual void cancel() void cancel() override
{ {
isCancelled.ref(); isCancelled.ref();
} }

View file

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

50
bgl.cc
View file

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

View file

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

View file

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

View file

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

View file

@ -157,8 +157,12 @@ struct HotKey
HotKey(); HotKey();
/// We use the first two keys of QKeySequence, with modifiers being stored /// Hotkey's constructor, take a QKeySequence's first two keys
/// in the first one. /// 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 & ); HotKey( QKeySequence const & );
QKeySequence toKeySequence() const; QKeySequence toKeySequence() const;
@ -316,9 +320,9 @@ struct Preferences
bool searchInDock; bool searchInDock;
bool enableMainWindowHotkey; bool enableMainWindowHotkey;
HotKey mainWindowHotkey; QKeySequence mainWindowHotkey;
bool enableClipboardHotkey; bool enableClipboardHotkey;
HotKey clipboardHotkey; QKeySequence clipboardHotkey;
bool startWithScanPopupOn; bool startWithScanPopupOn;
bool enableScanPopupModifiers; bool enableScanPopupModifiers;

View file

@ -100,45 +100,45 @@ public:
~DictdDictionary(); ~DictdDictionary();
virtual string getName() noexcept string getName() noexcept override
{ return dictionaryName; } { return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() noexcept map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept unsigned long getArticleCount() noexcept override
{ return idxHeader.articleCount; } { return idxHeader.articleCount; }
virtual unsigned long getWordCount() noexcept unsigned long getWordCount() noexcept override
{ return idxHeader.wordCount; } { return idxHeader.wordCount; }
virtual void loadIcon() noexcept; void loadIcon() noexcept override;
inline virtual quint32 getLangFrom() const inline quint32 getLangFrom() const override
{ return idxHeader.langFrom; } { return idxHeader.langFrom; }
inline virtual quint32 getLangTo() const inline quint32 getLangTo() const override
{ return idxHeader.langTo; } { return idxHeader.langTo; }
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &, sptr< Dictionary::DataRequest > getArticle( wstring const &,
vector< wstring > const & alts, vector< wstring > const & alts,
wstring const &, 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 searchMode, bool matchCase,
int distanceBetweenWords, int distanceBetweenWords,
int maxResults, int maxResults,
bool ignoreWordsOrder, bool ignoreWordsOrder,
bool ignoreDiacritics ); bool ignoreDiacritics ) override;
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 can_FTS = fts.enabled
&& !fts.disabledTypes.contains( "DICTD", Qt::CaseInsensitive ) && !fts.disabledTypes.contains( "DICTD", Qt::CaseInsensitive )

View file

@ -19,6 +19,9 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>3</number>
</property>
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
@ -75,7 +78,37 @@
</widget> </widget>
</item> </item>
<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> </item>
</layout> </layout>
</item> </item>
@ -101,14 +134,16 @@
<extends>QListWidget</extends> <extends>QListWidget</extends>
<header>groups_widgets.hh</header> <header>groups_widgets.hh</header>
</customwidget> </customwidget>
<customwidget>
<class>HotKeyEdit</class>
<extends>QLineEdit</extends>
<header>hotkeyedit.hh</header>
</customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="resources.qrc"/> <include location="resources.qrc"/>
</resources> </resources>
<connections/> <connections>
<connection>
<sender>clearShortCut</sender>
<signal>clicked()</signal>
<receiver>shortcut</receiver>
<slot>clear()</slot>
</connection>
</connections>
</ui> </ui>

View file

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

44
dsl.cc
View file

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

View file

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

View file

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

48
gls.cc
View file

@ -372,52 +372,52 @@ public:
~GlsDictionary(); ~GlsDictionary();
virtual string getName() noexcept string getName() noexcept override
{ return dictionaryName; } { return dictionaryName; }
virtual map< Dictionary::Property, string > getProperties() noexcept map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept unsigned long getArticleCount() noexcept override
{ return idxHeader.articleCount; } { return idxHeader.articleCount; }
virtual unsigned long getWordCount() noexcept unsigned long getWordCount() noexcept override
{ return idxHeader.wordCount; } { return idxHeader.wordCount; }
inline virtual quint32 getLangFrom() const inline quint32 getLangFrom() const override
{ return idxHeader.langFrom; } { return idxHeader.langFrom; }
inline virtual quint32 getLangTo() const inline quint32 getLangTo() const override
{ return idxHeader.langTo; } { 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, vector< wstring > const & alts,
wstring const &, 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 searchMode, bool matchCase,
int distanceBetweenWords, int distanceBetweenWords,
int maxResults, int maxResults,
bool ignoreWordsOrder, 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 can_FTS = fts.enabled
&& !fts.disabledTypes.contains( "GLS", Qt::CaseInsensitive ) && !fts.disabledTypes.contains( "GLS", Qt::CaseInsensitive )
@ -425,7 +425,7 @@ public:
} }
protected: protected:
void loadIcon() noexcept; void loadIcon() noexcept override;
private: private:
@ -886,7 +886,7 @@ public:
hasExited.release(); hasExited.release();
} }
virtual void run(); void run() override;
}; };
class GlsHeadwordsRequest: public Dictionary::WordSearchRequest class GlsHeadwordsRequest: public Dictionary::WordSearchRequest
@ -910,7 +910,7 @@ public:
void run(); // Run from another thread by StardictHeadwordsRequestRunnable void run(); // Run from another thread by StardictHeadwordsRequestRunnable
virtual void cancel() void cancel() override
{ {
isCancelled.ref(); isCancelled.ref();
} }
@ -1005,7 +1005,7 @@ public:
hasExited.release(); hasExited.release();
} }
virtual void run(); void run() override;
}; };
class GlsArticleRequest: public Dictionary::DataRequest class GlsArticleRequest: public Dictionary::DataRequest
@ -1033,7 +1033,7 @@ public:
void run(); // Run from another thread by GlsArticleRequestRunnable void run(); // Run from another thread by GlsArticleRequestRunnable
virtual void cancel() void cancel() override
{ {
isCancelled.ref(); isCancelled.ref();
} }
@ -1185,7 +1185,7 @@ public:
hasExited.release(); hasExited.release();
} }
virtual void run(); void run() override;
}; };
class GlsResourceRequest: public Dictionary::DataRequest class GlsResourceRequest: public Dictionary::DataRequest
@ -1212,7 +1212,7 @@ public:
void run(); // Run from another thread by GlsResourceRequestRunnable void run(); // Run from another thread by GlsResourceRequestRunnable
virtual void cancel() void cancel() override
{ {
isCancelled.ref(); isCancelled.ref();
} }

View file

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

View file

@ -33,6 +33,11 @@ DictGroupWidget::DictGroupWidget( QWidget * parent,
ui.setupUi( this ); ui.setupUi( this );
ui.dictionaries->populate( Instances::Group( group, dicts, Config::Group() ).dictionaries, dicts ); 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 // Populate icons' list
QStringList icons = QDir( ":/flags/" ).entryList( QDir::Files, QDir::NoSort ); QStringList icons = QDir( ":/flags/" ).entryList( QDir::Files, QDir::NoSort );
@ -61,7 +66,7 @@ DictGroupWidget::DictGroupWidget( QWidget * parent,
if ( usesIconData ) if ( usesIconData )
ui.groupIcon->setCurrentIndex( 1 ); ui.groupIcon->setCurrentIndex( 1 );
ui.shortcut->setHotKey( Config::HotKey( group.shortcut ) ); ui.shortcut->setKeySequence( group.shortcut );
ui.favoritesFolder->setText( group.favoritesFolder ); ui.favoritesFolder->setText( group.favoritesFolder );
@ -126,7 +131,7 @@ Config::Group DictGroupWidget::makeGroup() const
g.icon = ui.groupIcon->itemData( currentIndex ).toString(); g.icon = ui.groupIcon->itemData( currentIndex ).toString();
g.shortcut = ui.shortcut->getHotKey().toKeySequence(); g.shortcut = ui.shortcut->keySequence();
g.favoritesFolder = ui.favoritesFolder->text().replace( '\\', '/' ); 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(); 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, bool HotkeyWrapper::setGlobalKey( int key, int key2,
Qt::KeyboardModifiers modifier, int handle ) Qt::KeyboardModifiers modifier, int handle )
{ {
@ -622,6 +628,12 @@ void HotkeyWrapper::handleRecordEvent( XRecordInterceptData * data )
XRecordFreeData( 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, bool HotkeyWrapper::setGlobalKey( int key, int key2,
Qt::KeyboardModifiers modifier, int handle ) Qt::KeyboardModifiers modifier, int handle )
{ {

View file

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

View file

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

16
lsa.cc
View file

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

View file

@ -180,6 +180,12 @@ void HotkeyWrapper::unregister()
(static_cast< QHotkeyApplication * >( qApp ))->unregisterWrapper( this ); (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 ) bool HotkeyWrapper::setGlobalKey( int key, int key2, Qt::KeyboardModifiers modifier, int handle )
{ {
if ( !key ) if ( !key )

View file

@ -86,7 +86,7 @@ using std::pair;
class InitSSLRunnable : public QRunnable class InitSSLRunnable : public QRunnable
{ {
virtual void run() void run() override
{ {
/// This action force SSL library initialisation which may continue a few seconds /// This action force SSL library initialisation which may continue a few seconds
QSslConfiguration::setDefaultConfiguration( QSslConfiguration::defaultConfiguration() ); QSslConfiguration::setDefaultConfiguration( QSslConfiguration::defaultConfiguration() );
@ -890,11 +890,18 @@ void MainWindow::clipboardChange( QClipboard::Mode m)
if(m == QClipboard::Selection){ 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; 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 // Keyboard Modifier
if(cfg.preferences.enableScanPopupModifiers && if(cfg.preferences.enableScanPopupModifiers &&
!KeyboardState::checkModifiersPressed(cfg.preferences.scanPopupModifiers)){ !KeyboardState::checkModifiersPressed(cfg.preferences.scanPopupModifiers)){
@ -908,7 +915,8 @@ void MainWindow::clipboardChange( QClipboard::Mode m)
return; return;
} }
scanPopup->translateWordFromSelection(); // Use delay show to prevent multiple popups while selection in progress
scanPopup->selectionDelayTimer.start();
} }
#else #else
scanPopup ->translateWordFromClipboard(); scanPopup ->translateWordFromClipboard();
@ -1521,9 +1529,6 @@ void MainWindow::makeScanPopup()
scanPopup->setStyleSheet( styleSheet() ); scanPopup->setStyleSheet( styleSheet() );
if ( enableScanningAction->isChecked() )
scanPopup->enableScanning();
connect( scanPopup.get(), SIGNAL(editGroupRequested( unsigned ) ), connect( scanPopup.get(), SIGNAL(editGroupRequested( unsigned ) ),
this, SLOT(editDictionaries( unsigned )), Qt::QueuedConnection ); this, SLOT(editDictionaries( unsigned )), Qt::QueuedConnection );
@ -2206,9 +2211,16 @@ void MainWindow::editPreferences()
bool needReload = false; bool needReload = false;
// See if we need to reapply Qt stylesheets // 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 ); 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 ); articleMaker.setDisplayStyle( p.displayStyle, p.addonStyle );
needReload = true; needReload = true;
} }
@ -2910,10 +2922,23 @@ void MainWindow::toggleMainWindow( bool onlyShow )
else else
if ( !onlyShow ) 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) if (cfg.preferences.enableTrayIcon)
hide(); hide();
else else
showMinimized(); showMinimized();
#endif
if( headwordsDlg ) if( headwordsDlg )
headwordsDlg->hide(); headwordsDlg->hide();
@ -2959,17 +2984,11 @@ void MainWindow::installHotKeys()
} }
if ( cfg.preferences.enableMainWindowHotkey ) if ( cfg.preferences.enableMainWindowHotkey )
hotkeyWrapper->setGlobalKey( cfg.preferences.mainWindowHotkey.key1, hotkeyWrapper->setGlobalKey( cfg.preferences.mainWindowHotkey,0 );
cfg.preferences.mainWindowHotkey.key2,
cfg.preferences.mainWindowHotkey.modifiers,
0 );
if ( cfg.preferences.enableClipboardHotkey && scanPopup.get() ) if ( cfg.preferences.enableClipboardHotkey && scanPopup.get() )
{ {
hotkeyWrapper->setGlobalKey( cfg.preferences.clipboardHotkey.key1, hotkeyWrapper->setGlobalKey( cfg.preferences.clipboardHotkey,1 );
cfg.preferences.clipboardHotkey.key2,
cfg.preferences.clipboardHotkey.modifiers,
1 );
} }
connect( hotkeyWrapper.get(), connect( hotkeyWrapper.get(),
@ -3164,7 +3183,6 @@ void MainWindow::scanEnableToggled( bool on )
{ {
if ( on ) if ( on )
{ {
scanPopup->enableScanning();
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
if( !MacMouseOver::isAXAPIEnabled() ) if( !MacMouseOver::isAXAPIEnabled() )
mainStatusBar->showMessage( tr( "Accessibility API is not enabled" ), 10000, mainStatusBar->showMessage( tr( "Accessibility API is not enabled" ), 10000,
@ -3174,7 +3192,6 @@ void MainWindow::scanEnableToggled( bool on )
} }
else else
{ {
scanPopup->disableScanning();
enableScanningAction->setIcon(QIcon(":/icons/wizard.svg")); enableScanningAction->setIcon(QIcon(":/icons/wizard.svg"));
} }
} }

44
mdx.cc
View file

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

View file

@ -48,33 +48,33 @@ public:
langId = LangCoder::code2toInt( url.mid( n - 2, 2 ).toLatin1().data() ); langId = LangCoder::code2toInt( url.mid( n - 2, 2 ).toLatin1().data() );
} }
virtual string getName() noexcept string getName() noexcept override
{ return name; } { return name; }
virtual map< Property, string > getProperties() noexcept map< Property, string > getProperties() noexcept override
{ return map< Property, string >(); } { return map< Property, string >(); }
virtual unsigned long getArticleCount() noexcept unsigned long getArticleCount() noexcept override
{ return 0; } { return 0; }
virtual unsigned long getWordCount() noexcept unsigned long getWordCount() noexcept override
{ return 0; } { return 0; }
virtual sptr< WordSearchRequest > prefixMatch( wstring const &, sptr< WordSearchRequest > prefixMatch( wstring const &,
unsigned long maxResults ) ; unsigned long maxResults ) override ;
virtual sptr< DataRequest > getArticle( wstring const &, vector< wstring > const & alts, sptr< DataRequest > getArticle( wstring const &, vector< wstring > const & alts,
wstring const &, bool ); wstring const &, bool ) override;
virtual quint32 getLangFrom() const quint32 getLangFrom() const override
{ return langId; } { return langId; }
virtual quint32 getLangTo() const quint32 getLangTo() const override
{ return langId; } { return langId; }
protected: protected:
virtual void loadIcon() noexcept; void loadIcon() noexcept override;
}; };
@ -111,11 +111,11 @@ public:
~MediaWikiWordSearchRequest(); ~MediaWikiWordSearchRequest();
virtual void cancel(); void cancel() override;
private: private:
virtual void downloadFinished(); void downloadFinished() override;
}; };
MediaWikiWordSearchRequest::MediaWikiWordSearchRequest( wstring const & str, MediaWikiWordSearchRequest::MediaWikiWordSearchRequest( wstring const & str,
@ -212,13 +212,13 @@ public:
QString const & url, QNetworkAccessManager & mgr, QString const & url, QNetworkAccessManager & mgr,
Class * dictPtr_ ); Class * dictPtr_ );
virtual void cancel(); void cancel() override;
private: private:
void addQuery( QNetworkAccessManager & mgr, wstring const & word ); 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- /// This simple set implementation should be much more efficient than tree-
/// and hash-based standard/Qt containers when there are very few elements. /// 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 #endif
ui.enableMainWindowHotkey->setChecked( p.enableMainWindowHotkey ); ui.enableMainWindowHotkey->setChecked( p.enableMainWindowHotkey );
ui.mainWindowHotkey->setHotKey( p.mainWindowHotkey ); ui.mainWindowHotkey->setKeySequence( p.mainWindowHotkey );
ui.enableClipboardHotkey->setChecked( p.enableClipboardHotkey ); ui.enableClipboardHotkey->setChecked( p.enableClipboardHotkey );
ui.clipboardHotkey->setHotKey( p.clipboardHotkey ); ui.clipboardHotkey->setKeySequence( p.clipboardHotkey );
ui.startWithScanPopupOn->setChecked( p.startWithScanPopupOn ); ui.startWithScanPopupOn->setChecked( p.startWithScanPopupOn );
ui.enableScanPopupModifiers->setChecked( p.enableScanPopupModifiers ); ui.enableScanPopupModifiers->setChecked( p.enableScanPopupModifiers );
@ -398,9 +398,9 @@ Config::Preferences Preferences::getPreferences()
p.darkMode = ui.darkMode->isChecked(); p.darkMode = ui.darkMode->isChecked();
p.darkReaderMode = ui.darkReaderMode->isChecked(); p.darkReaderMode = ui.darkReaderMode->isChecked();
p.enableMainWindowHotkey = ui.enableMainWindowHotkey->isChecked(); p.enableMainWindowHotkey = ui.enableMainWindowHotkey->isChecked();
p.mainWindowHotkey = ui.mainWindowHotkey->getHotKey(); p.mainWindowHotkey = ui.mainWindowHotkey->keySequence();
p.enableClipboardHotkey = ui.enableClipboardHotkey->isChecked(); p.enableClipboardHotkey = ui.enableClipboardHotkey->isChecked();
p.clipboardHotkey = ui.clipboardHotkey->getHotKey(); p.clipboardHotkey = ui.clipboardHotkey->keySequence();
p.startWithScanPopupOn = ui.startWithScanPopupOn->isChecked(); p.startWithScanPopupOn = ui.startWithScanPopupOn->isChecked();
p.enableScanPopupModifiers = ui.enableScanPopupModifiers->isChecked(); p.enableScanPopupModifiers = ui.enableScanPopupModifiers->isChecked();

View file

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

View file

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

View file

@ -71,7 +71,6 @@ ScanPopup::ScanPopup( QWidget * parent,
History & history_ ): History & history_ ):
QMainWindow( parent ), QMainWindow( parent ),
cfg( cfg_ ), cfg( cfg_ ),
isScanningEnabled( false ),
allDictionaries( allDictionaries_ ), allDictionaries( allDictionaries_ ),
groups( groups_ ), groups( groups_ ),
history( history_ ), history( history_ ),
@ -288,10 +287,11 @@ ScanPopup::ScanPopup( QWidget * parent,
translateWordFromSelection(); translateWordFromSelection();
}); });
delayTimer.setSingleShot( true ); // Use delay show to prevent multiple popups while selection in progress
delayTimer.setInterval( 200 ); selectionDelayTimer.setSingleShot( true );
selectionDelayTimer.setInterval( 200 );
connect( &delayTimer, &QTimer::timeout, this, &ScanPopup::delayShow ); connect( &selectionDelayTimer, &QTimer::timeout, this, &ScanPopup::translateWordFromSelection );
#endif #endif
applyZoomFactor(); applyZoomFactor();
@ -302,8 +302,6 @@ ScanPopup::~ScanPopup()
{ {
saveConfigData(); saveConfigData();
disableScanning();
ungrabGesture( Gestures::GDPinchGestureType ); ungrabGesture( Gestures::GDPinchGestureType );
ungrabGesture( Gestures::GDSwipeGestureType ); ungrabGesture( Gestures::GDSwipeGestureType );
} }
@ -317,22 +315,6 @@ void ScanPopup::saveConfigData()
cfg.popupWindowAlwaysOnTop = ui.onTopButton->isChecked(); cfg.popupWindowAlwaysOnTop = ui.onTopButton->isChecked();
} }
void ScanPopup::enableScanning()
{
if ( !isScanningEnabled )
{
isScanningEnabled = true;
}
}
void ScanPopup::disableScanning()
{
if ( isScanningEnabled )
{
isScanningEnabled = false;
}
}
void ScanPopup::inspectElementWhenPinned( QWebEnginePage * page ){ void ScanPopup::inspectElementWhenPinned( QWebEnginePage * page ){
if(cfg.pinPopupWindow) if(cfg.pinPopupWindow)
emit inspectSignal(page); 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 ) void ScanPopup::mouseHovered( QString const & str, bool forcePopup )
{ {
handleInputWord( str, forcePopup ); handleInputWord( str, forcePopup );

View file

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

View file

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

42
slob.cc
View file

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

View file

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

View file

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

View file

@ -158,51 +158,51 @@ public:
~StardictDictionary(); ~StardictDictionary();
virtual string getName() noexcept string getName() noexcept override
{ return bookName; } { return bookName; }
virtual map< Dictionary::Property, string > getProperties() noexcept map< Dictionary::Property, string > getProperties() noexcept override
{ return map< Dictionary::Property, string >(); } { return map< Dictionary::Property, string >(); }
virtual unsigned long getArticleCount() noexcept unsigned long getArticleCount() noexcept override
{ return idxHeader.wordCount; } { return idxHeader.wordCount; }
virtual unsigned long getWordCount() noexcept unsigned long getWordCount() noexcept override
{ return idxHeader.wordCount + idxHeader.synWordCount; } { return idxHeader.wordCount + idxHeader.synWordCount; }
inline virtual quint32 getLangFrom() const inline quint32 getLangFrom() const override
{ return idxHeader.langFrom; } { return idxHeader.langFrom; }
inline virtual quint32 getLangTo() const inline quint32 getLangTo() const override
{ return idxHeader.langTo; } { 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, vector< wstring > const & alts,
wstring const &, 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 searchMode, bool matchCase,
int distanceBetweenWords, int distanceBetweenWords,
int maxResults, int maxResults,
bool ignoreWordsOrder, 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 can_FTS = fts.enabled
&& !fts.disabledTypes.contains( "STARDICT", Qt::CaseInsensitive ) && !fts.disabledTypes.contains( "STARDICT", Qt::CaseInsensitive )
@ -210,7 +210,7 @@ public:
} }
protected: protected:
void loadIcon() noexcept; void loadIcon() noexcept override;
private: private:
@ -1226,7 +1226,7 @@ public:
hasExited.release(); hasExited.release();
} }
virtual void run(); void run() override;
}; };
class StardictHeadwordsRequest: public Dictionary::WordSearchRequest class StardictHeadwordsRequest: public Dictionary::WordSearchRequest
@ -1251,7 +1251,7 @@ public:
void run(); // Run from another thread by StardictHeadwordsRequestRunnable void run(); // Run from another thread by StardictHeadwordsRequestRunnable
virtual void cancel() void cancel() override
{ {
isCancelled.ref(); isCancelled.ref();
} }
@ -1345,7 +1345,7 @@ public:
hasExited.release(); hasExited.release();
} }
virtual void run(); void run() override;
}; };
class StardictArticleRequest: public Dictionary::DataRequest class StardictArticleRequest: public Dictionary::DataRequest
@ -1374,7 +1374,7 @@ public:
void run(); // Run from another thread by StardictArticleRequestRunnable void run(); // Run from another thread by StardictArticleRequestRunnable
virtual void cancel() void cancel() override
{ {
isCancelled.ref(); isCancelled.ref();
} }
@ -1639,7 +1639,7 @@ public:
hasExited.release(); hasExited.release();
} }
virtual void run(); void run() override;
}; };
class StardictResourceRequest: public Dictionary::DataRequest class StardictResourceRequest: public Dictionary::DataRequest
@ -1666,7 +1666,7 @@ public:
void run(); // Run from another thread by StardictResourceRequestRunnable void run(); // Run from another thread by StardictResourceRequestRunnable
virtual void cancel() void cancel() override
{ {
isCancelled.ref(); isCancelled.ref();
} }

View file

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

View file

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

56
xdxf.cc
View file

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

40
zim.cc
View file

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

View file

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