From d15081e723756eef053550dc9e06e31d7828dec3 Mon Sep 17 00:00:00 2001 From: shenleban tongying Date: Wed, 6 Nov 2024 00:17:19 -0500 Subject: [PATCH] clean: apply clang-tidy's `modernize-use-using` (replace most `typedef`) --- src/article_maker.hh | 4 ++-- src/audioplayerinterface.hh | 2 +- src/common/base_type.hh | 2 +- src/common/wstring.hh | 4 ++-- src/config.hh | 18 +++++++++--------- src/dict/bgl_babylon.hh | 8 ++++---- src/dict/epwing_book.hh | 2 +- src/dict/forvo.cc | 2 +- src/dict/lingualibre.cc | 2 +- src/dict/mdictparser.hh | 6 +++--- src/dict/mediawiki.cc | 2 +- src/dict/slob.cc | 4 ++-- src/hotkeywrapper.cc | 2 +- src/hotkeywrapper.hh | 2 +- src/language.hh | 2 +- src/multimediaaudioplayer.cc | 8 -------- src/wordfinder.hh | 4 ++-- 17 files changed, 33 insertions(+), 41 deletions(-) diff --git a/src/article_maker.hh b/src/article_maker.hh index 1dc678c1..d2408861 100644 --- a/src/article_maker.hh +++ b/src/article_maker.hh @@ -101,8 +101,8 @@ class ArticleRequest: public Dictionary::DataRequest /// A sequence of words and spacings between them, including the initial /// spacing before the first word and the final spacing after the last word. - typedef QList< QString > Words; - typedef QList< QString > Spacings; + using Words = QList< QString >; + using Spacings = QList< QString >; /// Splits the given string into words and spacings between them. std::pair< Words, Spacings > splitIntoWords( QString const & ); diff --git a/src/audioplayerinterface.hh b/src/audioplayerinterface.hh index a88de319..f297eb88 100644 --- a/src/audioplayerinterface.hh +++ b/src/audioplayerinterface.hh @@ -26,6 +26,6 @@ signals: void error( QString message ); }; -typedef QScopedPointer< AudioPlayerInterface > AudioPlayerPtr; +using AudioPlayerPtr = QScopedPointer< AudioPlayerInterface >; #endif // AUDIOPLAYERINTERFACE_HH_INCLUDED diff --git a/src/common/base_type.hh b/src/common/base_type.hh index c36ada7b..7df882e7 100644 --- a/src/common/base_type.hh +++ b/src/common/base_type.hh @@ -3,5 +3,5 @@ #include -typedef QMap< QString, QString > Contexts; +using Contexts = QMap< QString, QString >; #endif // BASE_TYPE_H diff --git a/src/common/wstring.hh b/src/common/wstring.hh index 47a1adb6..4ab689e1 100644 --- a/src/common/wstring.hh +++ b/src/common/wstring.hh @@ -12,6 +12,6 @@ /// namespace gd { -typedef char32_t wchar; -typedef std::u32string wstring; +using wchar = char32_t; +using wstring = std::u32string; } // namespace gd diff --git a/src/config.hh b/src/config.hh index 71aa0d61..feec887d 100644 --- a/src/config.hh +++ b/src/config.hh @@ -36,7 +36,7 @@ enum class Dark : std::uint8_t { }; /// Dictionaries which are temporarily disabled via the dictionary bar. -typedef QSet< QString > MutedDictionaries; +using MutedDictionaries = QSet< QString >; /// A path where to search for the dictionaries struct Path @@ -61,7 +61,7 @@ struct Path }; /// A list of paths where to search for the dictionaries -typedef QList< Path > Paths; +using Paths = QList< Path >; /// A directory holding bunches of audiofiles, which is indexed into a separate /// dictionary. @@ -86,7 +86,7 @@ struct SoundDir }; /// A list of SoundDirs -typedef QList< SoundDir > SoundDirs; +using SoundDirs = QList< SoundDir >; struct DictionaryRef { @@ -518,7 +518,7 @@ struct WebSite }; /// All the WebSites -typedef QList< WebSite > WebSites; +using WebSites = QList< WebSite >; /// Any DICT server struct DictServer @@ -559,14 +559,14 @@ struct DictServer }; /// All the DictServers -typedef QList< DictServer > DictServers; +using DictServers = QList< DictServer >; /// Hunspell configuration struct Hunspell { QString dictionariesPath; - typedef QList< QString > Dictionaries; + using Dictionaries = QList< QString >; Dictionaries enabledDictionaries; @@ -582,7 +582,7 @@ struct Hunspell }; /// All the MediaWikis -typedef QList< MediaWiki > MediaWikis; +using MediaWikis = QList< MediaWiki >; /// Chinese transliteration configuration @@ -775,7 +775,7 @@ struct Program } }; -typedef QList< Program > Programs; +using Programs = QList< Program >; #ifndef NO_TTS_SUPPORT struct VoiceEngine @@ -821,7 +821,7 @@ struct VoiceEngine } }; -typedef QList< VoiceEngine > VoiceEngines; +using VoiceEngines = QList< VoiceEngine >; #endif struct HeadwordsDialog diff --git a/src/dict/bgl_babylon.hh b/src/dict/bgl_babylon.hh index 565c201c..01e756b0 100644 --- a/src/dict/bgl_babylon.hh +++ b/src/dict/bgl_babylon.hh @@ -115,20 +115,20 @@ const std::vector< std::string > bgl_charset = { "WINDOWS-1252", /*Default*/ const std::array< std::string, 11 > partOfSpeech = { "n.", "adj.", "v.", "adv.", "interj.", "pron.", "prep.", "conj.", "suff.", "pref.", "art." }; -typedef struct +struct bgl_block { unsigned type; unsigned length; char * data; -} bgl_block; +}; -typedef struct +struct bgl_entry { std::string headword; std::string definition; std::string displayedHeadword; std::vector< std::string > alternates; -} bgl_entry; +}; class Babylon { diff --git a/src/dict/epwing_book.hh b/src/dict/epwing_book.hh index 403034cc..ea2f39b6 100644 --- a/src/dict/epwing_book.hh +++ b/src/dict/epwing_book.hh @@ -58,7 +58,7 @@ struct EpwingHeadword class EpwingBook { - typedef std::pair< int, int > EWPos; + using EWPos = std::pair< int, int >; void setErrorString( QString const & func, EB_Error_Code code ); diff --git a/src/dict/forvo.cc b/src/dict/forvo.cc index 529e1c15..1e010959 100644 --- a/src/dict/forvo.cc +++ b/src/dict/forvo.cc @@ -93,7 +93,7 @@ class ForvoArticleRequest: public Dictionary::DataRequest } }; - typedef std::list< NetReply > NetReplies; + using NetReplies = std::list< NetReply >; NetReplies netReplies; QString apiKey, languageCode; string dictionaryId; diff --git a/src/dict/lingualibre.cc b/src/dict/lingualibre.cc index 23d5d55b..fbf213af 100644 --- a/src/dict/lingualibre.cc +++ b/src/dict/lingualibre.cc @@ -33,7 +33,7 @@ class LinguaArticleRequest: public Dictionary::DataRequest } }; - typedef std::list< NetReply > NetReplies; + using NetReplies = std::list< NetReply >; NetReplies netReplies; QString languageCode, langWikipediaID; string dictionaryId; diff --git a/src/dict/mdictparser.hh b/src/dict/mdictparser.hh index a4d44edd..74dc4b9a 100644 --- a/src/dict/mdictparser.hh +++ b/src/dict/mdictparser.hh @@ -112,9 +112,9 @@ public: virtual void handleRecord( QString const & name, RecordInfo const & recordInfo ) = 0; }; - typedef vector< pair< qint64, qint64 > > BlockInfoVector; - typedef vector< pair< qint64, QString > > HeadWordIndex; - typedef map< qint32, pair< QString, QString > > StyleSheets; + using BlockInfoVector = vector< pair< qint64, qint64 > >; + using HeadWordIndex = vector< pair< qint64, QString > >; + using StyleSheets = map< qint32, pair< QString, QString > >; inline QString const & title() const { diff --git a/src/dict/mediawiki.cc b/src/dict/mediawiki.cc index d5b057cb..5a58e5a7 100644 --- a/src/dict/mediawiki.cc +++ b/src/dict/mediawiki.cc @@ -389,7 +389,7 @@ void MediaWikiSectionsParser::closeListTags( int currentLevel ) class MediaWikiArticleRequest: public MediaWikiDataRequestSlots { - typedef std::list< std::pair< QNetworkReply *, bool > > NetReplies; + using NetReplies = std::list< std::pair< QNetworkReply *, bool > >; NetReplies netReplies; QString url; QString lang; diff --git a/src/dict/slob.cc b/src/dict/slob.cc index 25b79861..1d7e3c41 100644 --- a/src/dict/slob.cc +++ b/src/dict/slob.cc @@ -109,8 +109,8 @@ bool indexIsOldOrBad( string const & indexFile ) class SlobFile { public: - typedef std::pair< quint64, quint32 > RefEntryOffsetItem; - typedef QList< RefEntryOffsetItem > RefOffsetsVector; + using RefEntryOffsetItem = std::pair< quint64, quint32 >; + using RefOffsetsVector = QList< RefEntryOffsetItem >; private: enum Compressions { diff --git a/src/hotkeywrapper.cc b/src/hotkeywrapper.cc index 557cb414..f9da8328 100644 --- a/src/hotkeywrapper.cc +++ b/src/hotkeywrapper.cc @@ -698,7 +698,7 @@ bool HotkeyWrapper::isKeyGrabbed( quint32 keyCode, quint32 modifiers ) const namespace { -typedef int ( *X11ErrorHandler )( Display * display, XErrorEvent * event ); +using X11ErrorHandler = int ( * )( Display * display, XErrorEvent * event ); class X11GrabUngrabErrorHandler { diff --git a/src/hotkeywrapper.hh b/src/hotkeywrapper.hh index 6d2705a0..3f9b2426 100644 --- a/src/hotkeywrapper.hh +++ b/src/hotkeywrapper.hh @@ -142,7 +142,7 @@ private: /// Holds all the keys currently grabbed. /// The first value is keycode, the second is modifiers - typedef std::set< std::pair< quint32, quint32 > > GrabbedKeys; + using GrabbedKeys = std::set< std::pair< quint32, quint32 > >; GrabbedKeys grabbedKeys; GrabbedKeys::iterator keyToUngrab; // Used for second stage grabs diff --git a/src/language.hh b/src/language.hh index bdcb5a96..bb1f7e42 100644 --- a/src/language.hh +++ b/src/language.hh @@ -11,7 +11,7 @@ namespace Language { /// This identifies any language uniquely within the program. It also has /// two special meanings - Unknown and Any. -typedef quint32 Id; +using Id = quint32; enum { /// Value for Id which signifies that the language is unknown or unspecified. diff --git a/src/multimediaaudioplayer.cc b/src/multimediaaudioplayer.cc index c117c629..cf441488 100644 --- a/src/multimediaaudioplayer.cc +++ b/src/multimediaaudioplayer.cc @@ -20,17 +20,9 @@ MultimediaAudioPlayer::MultimediaAudioPlayer() player( 0, QMediaPlayer::StreamPlayback ) #endif { - typedef void ( QMediaPlayer::*ErrorSignal )( QMediaPlayer::Error ); - #if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) - connect( &player, - static_cast< ErrorSignal >( &QMediaPlayer::error ), - this, - &MultimediaAudioPlayer::onMediaPlayerError ); - #else player.setAudioOutput( &audioOutput ); connect( &player, &QMediaPlayer::errorChanged, this, &MultimediaAudioPlayer::onMediaPlayerError ); - #endif #if ( QT_VERSION > QT_VERSION_CHECK( 6, 2, 0 ) ) connect( &mediaDevices, &QMediaDevices::audioOutputsChanged, this, &MultimediaAudioPlayer::audioOutputChange ); diff --git a/src/wordfinder.hh b/src/wordfinder.hh index 8c7fcd23..e6a7d48d 100644 --- a/src/wordfinder.hh +++ b/src/wordfinder.hh @@ -60,8 +60,8 @@ private: // Maps lowercased string to the original one. This catches all duplicates // without case sensitivity. Made as an array and a map indexing that array. - typedef std::list< OneResult > ResultsArray; - typedef std::map< gd::wstring, ResultsArray::iterator > ResultsIndex; + using ResultsArray = std::list< OneResult >; + using ResultsIndex = std::map< gd::wstring, ResultsArray::iterator >; ResultsArray resultsArray; ResultsIndex resultsIndex;