mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T730, allow to specify a default value -> findByNameOrDefault
This commit is contained in:
committed by
Mat Sutcliffe
parent
fc70767636
commit
47475f1a18
@@ -38,6 +38,12 @@ namespace BlackMisc
|
||||
|
||||
CAudioDeviceInfo CAudioDeviceInfoList::findByName(const QString &name, bool strict) const
|
||||
{
|
||||
return this->findByNameOrDefault(name, CAudioDeviceInfo(), strict);
|
||||
}
|
||||
|
||||
CAudioDeviceInfo CAudioDeviceInfoList::findByNameOrDefault(const QString &name, const CAudioDeviceInfo defaultDevice, bool strict) const
|
||||
{
|
||||
if (name.isEmpty()) { return defaultDevice; }
|
||||
for (const CAudioDeviceInfo &d : *this)
|
||||
{
|
||||
if (strict)
|
||||
@@ -50,7 +56,7 @@ namespace BlackMisc
|
||||
if (name.startsWith(d.getName(), Qt::CaseInsensitive)) { return d; }
|
||||
}
|
||||
}
|
||||
return CAudioDeviceInfo();
|
||||
return defaultDevice;
|
||||
}
|
||||
|
||||
int CAudioDeviceInfoList::count(CAudioDeviceInfo::DeviceType type) const
|
||||
|
||||
@@ -48,6 +48,9 @@ namespace BlackMisc
|
||||
//! Find by name
|
||||
CAudioDeviceInfo findByName(const QString &name, bool strict = false) const;
|
||||
|
||||
//! Find by name
|
||||
CAudioDeviceInfo findByNameOrDefault(const QString &name, const CAudioDeviceInfo defaultDevice, bool strict = false) const;
|
||||
|
||||
//! Count (as of type)
|
||||
int count(CAudioDeviceInfo::DeviceType type) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user