Skip to content

Commit

Permalink
tidy: Fix a bunch of new warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdude42 committed Oct 2, 2020
1 parent cbcad7f commit ec09218
Show file tree
Hide file tree
Showing 21 changed files with 96 additions and 147 deletions.
11 changes: 4 additions & 7 deletions mythplugins/mythgame/mythgame/rominfo.cpp
Expand Up @@ -160,13 +160,10 @@ bool RomInfo::FindImage(QString BaseFileName, QString *result)


BaseFileName.truncate(dotLocation + 1);
for (const auto & format : qAsConst(graphic_formats))
{
*result = BaseFileName + format;
if (QFile::exists(*result))
return true;
}
return false;
return std::any_of(graphic_formats.cbegin(), graphic_formats.cend(),
[BaseFileName,result](const auto & format)
{ *result = BaseFileName + format;
return QFile::exists(*result); } );
}

void RomInfo::setField(const QString& field, const QString& data)
Expand Down
10 changes: 3 additions & 7 deletions mythplugins/mythmusic/mythmusic/avfdecoder.cpp
Expand Up @@ -585,13 +585,9 @@ bool avfDecoderFactory::supports(const QString &source) const
#else
QStringList list = extension().split("|", Qt::SkipEmptyParts);
#endif
for (const auto& str : qAsConst(list))
{
if (str == source.right(str.length()).toLower())
return true;
}

return false;
return std::any_of(list.cbegin(), list.cend(),
[source](const auto& str)
{ return str == source.right(str.length()).toLower(); } );
}

const QString &avfDecoderFactory::extension() const
Expand Down
20 changes: 7 additions & 13 deletions mythplugins/mythmusic/mythmusic/decoder.cpp
Expand Up @@ -77,25 +77,19 @@ QStringList Decoder::all()
{
checkFactories();

QStringList l;

for (const auto & factory : qAsConst(*factories))
l += factory->description();

return l;
return std::accumulate(factories->cbegin(), factories->cend(),
QStringList(),
[](QStringList l, const auto & factory)
{ return l += factory->description(); } );
}

bool Decoder::supports(const QString &source)
{
checkFactories();

for (const auto & factory : qAsConst(*factories))
{
if (factory->supports(source))
return true;
}

return false;
return std::any_of(factories->cbegin(), factories->cend(),
[source](const auto & factory)
{return factory->supports(source); } );
}

void Decoder::registerFactory(DecoderFactory *fact)
Expand Down
17 changes: 7 additions & 10 deletions mythtv/libs/libmyth/audio/audiooutputsettings.cpp
Expand Up @@ -103,11 +103,10 @@ int AudioOutputSettings::NearestSupportedRate(int rate)
return 48000;

// Assume rates vector is sorted
for (const auto entry : m_rates)
{
if (entry >= rate)
return entry;
}
auto it = std::find_if(m_rates.cbegin(), m_rates.cend(),
[rate](const auto entry){ return entry >= rate; } );
if (it != m_rates.cend())
return *it;

// Not found, so return highest available rate
return m_rates.back();
Expand Down Expand Up @@ -246,11 +245,9 @@ bool AudioOutputSettings::IsSupportedChannels(int channels)
if (m_channels.empty() && channels == 2)
return true;

for (const auto entry : m_channels)
if (entry == channels)
return true;

return false;
return std::any_of(m_channels.cbegin(), m_channels.cend(),
[channels](const auto entry)
{ return entry == channels; } );
}

int AudioOutputSettings::BestSupportedChannels()
Expand Down
7 changes: 2 additions & 5 deletions mythtv/libs/libmythtv/captions/cc608decoder.cpp
Expand Up @@ -988,11 +988,8 @@ static bool is_better(const QString &newStr, const QString &oldStr)
return true;

// check if the string contains any bogus characters
for (auto ch : qAsConst(newStr))
if (ch.toLatin1() < 0x20)
return false;

return true;
return std::all_of(newStr.cbegin(), newStr.cend(),
[](auto ch){ return ch.toLatin1() >= 0x20; } );
}
return false;
}
Expand Down
19 changes: 7 additions & 12 deletions mythtv/libs/libmythtv/decoders/mythvaapicontext.cpp
Expand Up @@ -187,18 +187,13 @@ MythCodecID MythVAAPIContext::GetSupportedCodec(AVCodecContext **Context,
MythCodecContext::FFmpegToMythProfile((*Context)->codec_id, (*Context)->profile);
auto haveprofile = [=](MythCodecContext::CodecProfile Profile, QSize Size)
{
for (auto vaprofile : qAsConst(profiles))
{
if (vaprofile.first == Profile &&
vaprofile.second.first.width() <= Size.width() &&
vaprofile.second.first.height() <= Size.height() &&
vaprofile.second.second.width() >= Size.width() &&
vaprofile.second.second.height() >= Size.height())
{
return true;
}
}
return false;
return std::any_of(profiles.cbegin(), profiles.cend(),
[&Profile,Size](auto vaprofile)
{ return vaprofile.first == Profile &&
vaprofile.second.first.width() <= Size.width() &&
vaprofile.second.first.height() <= Size.height() &&
vaprofile.second.second.width() >= Size.width() &&
vaprofile.second.second.height() >= Size.height(); } );
};

ok = haveprofile(mythprofile, QSize((*Context)->width, (*Context)->height));
Expand Down
18 changes: 7 additions & 11 deletions mythtv/libs/libmythtv/osd.cpp
Expand Up @@ -261,17 +261,13 @@ bool OSD::IsVisible(void)
if (GetNotificationCenter()->DisplayedNotifications() > 0)
return true;

for (MythScreenType* child : qAsConst(m_children))
{
if (child->IsVisible() &&
child->objectName() != OSD_WIN_SUBTITLE &&
child->objectName() != OSD_WIN_TELETEXT &&
child->objectName() != OSD_WIN_BDOVERLAY &&
child->objectName() != OSD_WIN_INTERACT)
return true;
}

return false;
return std::any_of(m_children.cbegin(), m_children.cend(),
[](MythScreenType* child)
{ return child->IsVisible() &&
child->objectName() != OSD_WIN_SUBTITLE &&
child->objectName() != OSD_WIN_TELETEXT &&
child->objectName() != OSD_WIN_BDOVERLAY &&
child->objectName() != OSD_WIN_INTERACT; } );
}

void OSD::HideAll(bool KeepSubs, MythScreenType* Except, bool DropNotification)
Expand Down
14 changes: 4 additions & 10 deletions mythtv/libs/libmythtv/recorders/avcinfo.cpp
Expand Up @@ -65,16 +65,10 @@ bool AVCInfo::GetSubunitInfo(void)

bool AVCInfo::IsSubunitType(int subunit_type) const
{
for (int subunit : m_unit_table)
{
if ((subunit != 0xff) &&
(subunit & FirewireDevice::kAVCSubunitTypeUnit) == subunit_type)
{
return true;
}
}

return false;
return std::any_of(m_unit_table.cbegin(), m_unit_table.cend(),
[subunit_type](int subunit)
{ return (subunit != 0xff) &&
(subunit & FirewireDevice::kAVCSubunitTypeUnit) == subunit_type; } );
}

QString AVCInfo::GetSubunitInfoString(void) const
Expand Down
8 changes: 4 additions & 4 deletions mythtv/libs/libmythtv/tv_play.cpp
Expand Up @@ -3898,7 +3898,7 @@ bool TV::SubtitleDelayHandleAction(const QStringList &Actions)
return handled;
}

bool TV::DiscMenuHandleAction(const QStringList& Actions)
bool TV::DiscMenuHandleAction(const QStringList& Actions) const
{
int64_t pts = 0;
MythVideoOutput *output = m_playerContext.m_player->GetVideoOutput();
Expand Down Expand Up @@ -5477,11 +5477,11 @@ void TV::SetFFRew(int Index)
if (!m_playerContext.m_ffRewState)
return;

size_t index = static_cast<size_t>(Index);
auto index = static_cast<size_t>(Index);
if (!m_ffRewSpeeds[index])
return;

size_t ffrewindex = static_cast<size_t>(m_playerContext.m_ffRewIndex);
auto ffrewindex = static_cast<size_t>(m_playerContext.m_ffRewIndex);
int speed = 0;
QString mesg;
if (m_playerContext.m_ffRewState > 0)
Expand Down Expand Up @@ -5961,7 +5961,7 @@ void TV::ToggleChannelFavorite()
LOG(VB_GENERAL, LOG_ERR, "TV::ToggleChannelFavorite() -- currently disabled");
}

void TV::ToggleChannelFavorite(const QString& ChangroupName)
void TV::ToggleChannelFavorite(const QString& ChangroupName) const
{
if (m_playerContext.m_recorder)
m_playerContext.m_recorder->ToggleChannelFavorite(ChangroupName);
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/tv_play.h
Expand Up @@ -360,7 +360,7 @@ class MTV_PUBLIC TV : public QObject, public MenuItemDisplayer, public Reference
bool HandleJumpToProgramAction(const QStringList& Actions);
bool SeekHandleAction(const QStringList& Actions, bool IsDVD);
bool TimeStretchHandleAction(const QStringList& Actions);
bool DiscMenuHandleAction(const QStringList& Actions);
bool DiscMenuHandleAction(const QStringList& Actions) const;
bool Handle3D(const QString& Action);

// Timers and timer events
Expand Down Expand Up @@ -448,7 +448,7 @@ class MTV_PUBLIC TV : public QObject, public MenuItemDisplayer, public Reference

// Channels
static void ToggleChannelFavorite();
void ToggleChannelFavorite(const QString &ChangroupName);
void ToggleChannelFavorite(const QString &ChangroupName) const;
void ChangeChannel(ChannelChangeDirection Direction);
void ChangeChannel(uint Chanid, const QString& Channum);

Expand Down Expand Up @@ -792,7 +792,7 @@ class MTV_PUBLIC TV : public QObject, public MenuItemDisplayer, public Reference

// embedded and suspended status
bool m_ignoreKeyPresses {false}; ///< should we ignore keypresses
bool m_savedPause; ///< saved pause state before embedding
bool m_savedPause {false}; ///< saved pause state before embedding

// Channel group stuff
/// \brief Lock necessary when modifying channel group variables.
Expand Down
6 changes: 4 additions & 2 deletions mythtv/libs/libmythtv/tvbrowsehelper.cpp
Expand Up @@ -223,15 +223,17 @@ bool TVBrowseHelper::IsBrowsing() const
*/
uint TVBrowseHelper::GetBrowseChanId(const QString& Channum, uint PrefCardid, uint PrefSourceid) const
{
if (PrefSourceid)
if (PrefSourceid) {
for (const auto & chan : m_dbAllChannels)
if (chan.m_sourceId == PrefSourceid && chan.m_chanNum == Channum)
return chan.m_chanId;
}

if (PrefCardid)
if (PrefCardid) {
for (const auto & chan : m_dbAllChannels)
if (chan.GetInputIds().contains(PrefCardid) && chan.m_chanNum == Channum)
return chan.m_chanId;
}

if (m_dbBrowseAllTuners)
{
Expand Down
8 changes: 4 additions & 4 deletions mythtv/libs/libmythtv/videodisplayprofile.cpp
Expand Up @@ -463,10 +463,10 @@ bool VideoDisplayProfile::CheckVideoRendererGroup(const QString &Renderer)
QString("Preferred video renderer: %1 (current: %2)")
.arg(Renderer).arg(m_lastVideoRenderer));

for (const auto& group : qAsConst(s_safe_renderer_group))
if (group.contains(m_lastVideoRenderer) && group.contains(Renderer))
return true;
return false;
return std::any_of(s_safe_renderer_group.cbegin(), s_safe_renderer_group.cend(),
[this,Renderer](const auto& group)
{ return group.contains(m_lastVideoRenderer) &&
group.contains(Renderer); } );
}

bool VideoDisplayProfile::IsDecoderCompatible(const QString &Decoder) const
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythui/mythscreensaver.h
Expand Up @@ -30,7 +30,7 @@ class MythScreenSaverControl : public QObject

public:
MythScreenSaverControl();
~MythScreenSaverControl();
~MythScreenSaverControl() override;

public slots:
void Disable();
Expand Down
52 changes: 22 additions & 30 deletions mythtv/libs/libmythui/mythuiwebbrowser.cpp
Expand Up @@ -739,40 +739,32 @@ QString MythWebView::getExtensionForMimetype(const QString &mimetype)

bool MythWebView::isMusicFile(const QString &extension, const QString &mimetype)
{
for (const auto &entry : SupportedMimeTypes)
{
if (entry.m_isVideo)
continue;

if (!mimetype.isEmpty() &&
mimetype == entry.m_mimeType)
return true;

if (!extension.isEmpty() &&
extension.toLower() == entry.m_extension)
return true;
}

return false;
return std::any_of(SupportedMimeTypes.cbegin(), SupportedMimeTypes.cend(),
[extension, mimetype](const auto &entry){
if (entry.m_isVideo)
return false;
if (!mimetype.isEmpty() &&
mimetype == entry.m_mimeType)
return true;
if (!extension.isEmpty() &&
extension.toLower() == entry.m_extension)
return true;
return false; } );
}

bool MythWebView::isVideoFile(const QString &extension, const QString &mimetype)
{
for (const auto &entry : SupportedMimeTypes)
{
if (!entry.m_isVideo)
continue;

if (!mimetype.isEmpty() &&
mimetype == entry.m_mimeType)
return true;

if (!extension.isEmpty() &&
extension.toLower() == entry.m_extension)
return true;
}

return false;
return std::any_of(SupportedMimeTypes.cbegin(), SupportedMimeTypes.cend(),
[extension, mimetype](const auto &entry) {
if (!entry.m_isVideo)
return false;
if (!mimetype.isEmpty() &&
mimetype == entry.m_mimeType)
return true;
if (!extension.isEmpty() &&
extension.toLower() == entry.m_extension)
return true;
return false; } );
}

QString MythWebView::getReplyMimetype(void)
Expand Down
8 changes: 4 additions & 4 deletions mythtv/libs/libmythui/platforms/mythscreensaverdrm.cpp
Expand Up @@ -9,7 +9,7 @@

MythScreenSaverDRM* MythScreenSaverDRM::Create()
{
auto result = new MythScreenSaverDRM();
auto* result = new MythScreenSaverDRM();
if (result->IsValid())
return result;
delete result;
Expand Down Expand Up @@ -42,7 +42,7 @@ MythScreenSaverDRM* MythScreenSaverDRM::Create()
MythScreenSaverDRM::MythScreenSaverDRM()
{
MythDisplay* display = MythDisplay::AcquireRelease(true);
MythDisplayDRM* drmdisplay = dynamic_cast<MythDisplayDRM*>(display);
auto* drmdisplay = dynamic_cast<MythDisplayDRM*>(display);
if (drmdisplay)
{
m_display = drmdisplay;
Expand Down Expand Up @@ -89,7 +89,7 @@ void MythScreenSaverDRM::ScreenChanged()
Init();
}

bool MythScreenSaverDRM::IsValid()
bool MythScreenSaverDRM::IsValid() const
{
return m_valid;
}
Expand Down Expand Up @@ -118,7 +118,7 @@ void MythScreenSaverDRM::UpdateDPMS()

m_asleep = true;
auto dpms = m_device->GetEnumProperty(DRM_DPMS);
for (auto & value : qAsConst(dpms.m_enums))
for (const auto & value : qAsConst(dpms.m_enums))
{
if ((value.first == dpms.m_value) && (value.second == DRM_ON))
{
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythui/platforms/mythscreensaverdrm.h
Expand Up @@ -20,7 +20,7 @@ class MythScreenSaverDRM : public QObject, public MythScreenSaver
static MythScreenSaverDRM* Create();
~MythScreenSaverDRM() override;

bool IsValid();
bool IsValid() const;
void Disable() override;
void Restore() override;
void Reset() override;
Expand Down

0 comments on commit ec09218

Please sign in to comment.