Commit c21cc6b6 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use std::as_const

parent f2ac2269
Pipeline #167231 passed with stage
in 56 seconds
......@@ -30,6 +30,8 @@ set (PA_MIN_VERSION "0.9.16")
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} )
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(KDEInstallDirs)
include(KDECMakeSettings)
......
......@@ -387,7 +387,7 @@ void KMixWindow::saveViewConfig()
// The following loop is necessary for the case that the user has hidden all views for a Mixer instance.
// Otherwise we would not save the Meta information (step -2- below for that mixer.
// We also do not save dynamic mixers (e.g. PulseAudio)
for (const Mixer *mixer : qAsConst(Mixer::mixers()))
for (const Mixer *mixer : std::as_const(Mixer::mixers()))
{
mixerViews[mixer->id()]; // just insert a map entry
}
......@@ -566,7 +566,7 @@ void KMixWindow::recreateGUI(bool saveConfig, const QString& mixerId, bool force
}
}
for (const GUIProfile *guiprof : qAsConst(activeGuiProfiles))
for (const GUIProfile *guiprof : std::as_const(activeGuiProfiles))
{
const Mixer *mixer = Mixer::findMixer(guiprof->getMixerId());
if (mixer==nullptr)
......@@ -596,7 +596,7 @@ void KMixWindow::recreateGUI(bool saveConfig, const QString& mixerId, bool force
// -3- ADD TABS FOR Mixer instances that have no tab yet **********************************
KConfigGroup pconfig(KSharedConfig::openConfig(), "Profiles");
for (const Mixer *mixer : qAsConst(Mixer::mixers()))
for (const Mixer *mixer : std::as_const(Mixer::mixers()))
{
if ( mixerHasProfile.contains(mixer))
{
......@@ -636,7 +636,7 @@ void KMixWindow::recreateGUI(bool saveConfig, const QString& mixerId, bool force
{
bool atLeastOneProfileWasAdded = false;
for (const QString &profileId : qAsConst(profileList))
for (const QString &profileId : std::as_const(profileList))
{
// This handles the profileList form the kmixrc
qCDebug(KMIX_LOG) << "Searching for GUI profile" << profileId;
......
......@@ -76,7 +76,7 @@ Mixer_Backend::~Mixer_Backend()
void Mixer_Backend::freeMixDevices()
{
for (shared_ptr<MixDevice> md : qAsConst(m_mixDevices)) md->close();
for (shared_ptr<MixDevice> md : std::as_const(m_mixDevices)) md->close();
m_mixDevices.clear();
}
......@@ -181,7 +181,7 @@ void Mixer_Backend::readSetFromHW()
int ret = Mixer::OK_UNCHANGED;
for (shared_ptr<MixDevice> md : qAsConst(m_mixDevices))
for (shared_ptr<MixDevice> md : std::as_const(m_mixDevices))
{
//bool debugMe = (md->id() == "PCM:0" );
bool debugMe = false;
......
......@@ -283,7 +283,7 @@ int Mixer_MPRIS2::addAllRunningPlayersAndInitHotplug()
}
const QStringList &replyValues = repl.value();
for (const QString &busDestination : qAsConst(replyValues))
for (const QString &busDestination : std::as_const(replyValues))
{
if ( busDestination.startsWith(QLatin1String("org.mpris.MediaPlayer2")) )
{
......
......@@ -66,7 +66,7 @@ MasterControl Mixer::_globalMasterPreferred;
*/
/* static */ bool Mixer::dynamicBackendsPresent()
{
for (const Mixer *mixer : qAsConst(s_mixers))
for (const Mixer *mixer : std::as_const(s_mixers))
{
if (mixer->isDynamic()) return (true);
}
......@@ -75,7 +75,7 @@ MasterControl Mixer::_globalMasterPreferred;
/* static */ bool Mixer::pulseaudioPresent()
{
for (const Mixer *mixer : qAsConst(s_mixers))
for (const Mixer *mixer : std::as_const(s_mixers))
{
if (mixer->getDriverName()=="PulseAudio") return (true);
}
......@@ -409,7 +409,7 @@ QString Mixer::getBaseName() const
/* static */ Mixer *Mixer::getGlobalMasterMixerNoFalback()
{
for (Mixer *mixer : qAsConst(s_mixers))
for (Mixer *mixer : std::as_const(s_mixers))
{
if (mixer!=nullptr && mixer->id()==_globalMasterCurrent.getCard())
return mixer;
......@@ -468,7 +468,7 @@ QString Mixer::getBaseName() const
return mixer->_mixerBackend->recommendedMaster();
}
for (const shared_ptr<MixDevice> &md : qAsConst(mixer->_mixerBackend->m_mixDevices))
for (const shared_ptr<MixDevice> &md : std::as_const(mixer->_mixerBackend->m_mixDevices))
{
if (!md) continue; // invalid
......@@ -516,7 +516,7 @@ void Mixer::setLocalMasterMD(const QString &devPK)
shared_ptr<MixDevice> Mixer::find(const QString &mixdeviceID) const
{
shared_ptr<MixDevice> mdRet;
for (const shared_ptr<MixDevice> &md : qAsConst(_mixerBackend->m_mixDevices))
for (const shared_ptr<MixDevice> &md : std::as_const(_mixerBackend->m_mixDevices))
{
if (!md) continue; // invalid
if (md->id()==mixdeviceID)
......
......@@ -309,7 +309,7 @@ qreal Volume::getAvgVolume(Volume::ChannelMask chmask) const
{
int avgVolumeCounter = 0;
long long sumOfActiveVolumes = 0;
for (const VolumeChannel &vc : qAsConst(_volumesL))
for (const VolumeChannel &vc : std::as_const(_volumesL))
{
if (channelMask[vc.chid] & chmask )
{
......@@ -363,7 +363,7 @@ std::ostream& operator<<(std::ostream& os, const Volume& vol) {
os << "(";
bool first = true;
for (const VolumeChannel &vc : qAsConst(vol.getVolumes()))
for (const VolumeChannel &vc : std::as_const(vol.getVolumes()))
{
if ( !first ) os << ",";
else first = false;
......@@ -380,7 +380,7 @@ std::ostream& operator<<(std::ostream& os, const Volume& vol) {
QDebug operator<<(QDebug os, const Volume& vol) {
os << "(";
bool first = true;
for (const VolumeChannel &vc : qAsConst(vol.getVolumes()))
for (const VolumeChannel &vc : std::as_const(vol.getVolumes()))
{
if ( !first ) os << ",";
else first = false;
......
......@@ -84,7 +84,7 @@ QString DBusMixerWrapper::driverName()
QStringList DBusMixerWrapper::controls()
{
QStringList result;
for (const shared_ptr<MixDevice> &md : qAsConst(m_mixer->getMixSet()))
for (const shared_ptr<MixDevice> &md : std::as_const(m_mixer->getMixSet()))
{
result.append( md->dbusPath() );
}
......
......@@ -65,7 +65,7 @@ void DBusMixSetWrapper::controlsChange(ControlManager::ChangeType changeType)
QStringList DBusMixSetWrapper::mixers() const
{
QStringList result;
for (Mixer *mixer : qAsConst(Mixer::mixers())) result.append(mixer->dbusPath());
for (Mixer *mixer : std::as_const(Mixer::mixers())) result.append(mixer->dbusPath());
return result;
}
......
......@@ -82,7 +82,7 @@ void DialogChooseBackends::createPage(const QSet<QString> &mixerIds)
#endif
bool hasMixerFilter = !mixerIds.isEmpty();
qCDebug(KMIX_LOG) << "MixerIds=" << mixerIds;
for (const Mixer *mixer : qAsConst(Mixer::mixers()))
for (const Mixer *mixer : std::as_const(Mixer::mixers()))
{
// TODO: No point in showing mixers which do not have any volume controls.
// See checks done in ViewDockAreaPopup::initLayout()
......
......@@ -181,7 +181,7 @@ void DialogViewConfiguration::moveSelection(DialogViewConfigurationWidget *from,
const QList<QListWidgetItem *> sel = from->selectedItems();
from->selectionModel()->clearSelection();
for (QListWidgetItem *item : qAsConst(sel))
for (QListWidgetItem *item : std::as_const(sel))
{
from->takeItem(from->row(item));
to->addItem(item);
......@@ -305,7 +305,7 @@ void DialogViewConfiguration::apply()
prepareControls(model, false, oldControlset, newControlset);
// -2- Copy all mandatory "catch-all" controls form the old to the new ControlSet *******
for (const ProfControl *pctl : qAsConst(oldControlset))
for (const ProfControl *pctl : std::as_const(oldControlset))
{
if ( pctl->isMandatory() ) {
ProfControl* newCtl = new ProfControl(*pctl);
......@@ -352,7 +352,7 @@ void DialogViewConfiguration::prepareControls(QAbstractItemModel* model, bool is
// -3- Insert it in the new ControlSet **************************
// qCDebug(KMIX_LOG) << "Should add to new ControlSet: " << ctlId;
for (const ProfControl *control : qAsConst(oldCtlSet))
for (const ProfControl *control : std::as_const(oldCtlSet))
{
//qCDebug(KMIX_LOG) << " checking " << control->id;
QRegExp idRegexp(control->id());
......
......@@ -373,7 +373,7 @@ bool GUIProfile::readProfile(const QString &fileName)
const QXmlStreamAttributes attrs = reader.attributes();
#ifdef DEBUG_XMLREADER
qCDebug(KMIX_LOG) << " element" << name << "has" << attrs.count() << "attributes:";
for (const QXmlStreamAttribute &attr : qAsConst(attrs))
for (const QXmlStreamAttribute &attr : std::as_const(attrs))
{
qCDebug(KMIX_LOG) << " " << attr.name() << "=" << attr.value();
}
......@@ -448,7 +448,7 @@ bool GUIProfile::writeProfile()
// />
writer.writeEndElement();
for (const ProfProduct *prd : qAsConst(_products))
for (const ProfProduct *prd : std::as_const(_products))
{
// <product
writer.writeStartElement("product");
......@@ -464,7 +464,7 @@ bool GUIProfile::writeProfile()
writer.writeEndElement();
} // for all products
for (const ProfControl *profControl : qAsConst(getControls()))
for (const ProfControl *profControl : std::as_const(getControls()))
{
// <control
writer.writeStartElement("control");
......
......@@ -154,7 +154,7 @@ void ViewBase::createDeviceWidgets()
qCDebug(KMIX_LOG) << id() << "orientation" << _orientation;
initLayout();
for (const shared_ptr<MixDevice> &md : qAsConst(_mixSet))
for (const shared_ptr<MixDevice> &md : std::as_const(_mixSet))
{
QWidget *mdw = add(md); // a) Let the implementation do its work
_mdws.append(mdw); // b) Add it to the local list
......@@ -308,7 +308,7 @@ void ViewBase::refreshVolumeLevels()
*/
bool ViewBase::isDynamic() const
{
for (const Mixer *mixer : qAsConst(_mixers))
for (const Mixer *mixer : std::as_const(_mixers))
{
if (mixer->isDynamic()) return true;
}
......@@ -318,7 +318,7 @@ bool ViewBase::isDynamic() const
bool ViewBase::pulseaudioPresent() const
{
// We do not use Mixer::pulseaudioPresent(), as we are only interested in Mixer instances contained in this View.
for (const Mixer *mixer : qAsConst(_mixers))
for (const Mixer *mixer : std::as_const(_mixers))
{
if ( mixer->getDriverName() == "PulseAudio" ) return true;
}
......@@ -342,7 +342,7 @@ void ViewBase::resetMdws()
int ViewBase::visibleControls() const
{
int visibleCount = 0;
for (const QWidget *qw : qAsConst(_mdws))
for (const QWidget *qw : std::as_const(_mdws))
{
if (qw->isVisible())
++ visibleCount;
......@@ -398,7 +398,7 @@ void ViewBase::load(const KConfig *config)
{
const GuiVisibility guiCompl = guiVisibilities[i];
bool atLeastOneControlIsShown = false;
for (QWidget *qmdw : qAsConst(view->_mdws))
for (QWidget *qmdw : std::as_const(view->_mdws))
{
MixDeviceWidget *mdw = qobject_cast<MixDeviceWidget *>(qmdw);
if (mdw!=nullptr)
......@@ -457,7 +457,7 @@ void ViewBase::setGuiLevel(GuiVisibility guiLevel)
*/
ProfControl *ViewBase::findMdw(const QString& mdwId, GuiVisibility visibility) const
{
for (ProfControl *pControl : qAsConst(guiProfile()->getControls()))
for (ProfControl *pControl : std::as_const(guiProfile()->getControls()))
{
QRegExp idRegExp(pControl->id());
if ( mdwId.contains(idRegExp) )
......
......@@ -302,7 +302,7 @@ Application: KMix (kmix), signal: Segmentation fault
const QStringList preferredMixersForSoundmenu = Settings::mixersForSoundMenu();
//qCDebug(KMIX_LOG) << "Launch with " << preferredMixersForSoundmenu;
for (Mixer *mixer : qAsConst(Mixer::mixers()))
for (Mixer *mixer : std::as_const(Mixer::mixers()))
{
bool useMixer = preferredMixersForSoundmenu.isEmpty() || preferredMixersForSoundmenu.contains(mixer->id());
if (useMixer) addMixer(mixer);
......@@ -313,7 +313,7 @@ Application: KMix (kmix), signal: Segmentation fault
// backends.
if (getMixers().isEmpty())
{
for (Mixer *mixer : qAsConst(Mixer::mixers()))
for (Mixer *mixer : std::as_const(Mixer::mixers()))
{
addMixer(mixer);
}
......@@ -336,7 +336,7 @@ Application: KMix (kmix), signal: Segmentation fault
//
// Maybe need a configuration option?
for (const Mixer *mixer : qAsConst(getMixers()))
for (const Mixer *mixer : std::as_const(getMixers()))
{
//qCDebug(KMIX_LOG) << "ADD? mixerId=" << mixer->id();
// Get the configured master control for the mixer.
......@@ -363,9 +363,9 @@ Application: KMix (kmix), signal: Segmentation fault
} // loop over all cards
// Finally add all application streams
for (const Mixer *mixer : qAsConst(getMixers()))
for (const Mixer *mixer : std::as_const(getMixers()))
{
for (shared_ptr<MixDevice> md : qAsConst(mixer->getMixSet()))
for (shared_ptr<MixDevice> md : std::as_const(mixer->getMixSet()))
{
if (md->isApplicationStream()) addToMixSet(md);
}
......
......@@ -224,7 +224,7 @@ void ViewSliders::initLayout()
{
const MixSet &mixset = mixer->getMixSet();
for (ProfControl *control : qAsConst(guiprof->getControls()))
for (ProfControl *control : std::as_const(guiprof->getControls()))
{
// The TabName of the control matches this View name (!! attention: Better use some ID, due to i18n() )
QRegExp idRegexp(control->id());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment