refs #694 Support human readable names for settings and data cache traits.

This commit is contained in:
Mathew Sutcliffe
2016-07-28 22:26:47 +01:00
parent 61f3655b2c
commit 87b2396edb
5 changed files with 47 additions and 8 deletions

View File

@@ -473,6 +473,25 @@ namespace BlackMisc
changeValues({ values, 0 });
}
QString CValueCache::getHumanReadableName(const QString &key) const
{
QMutexLocker lock(&m_mutex);
return m_humanReadable.value(key, key);
}
QString CValueCache::getHumanReadableWithKey(const QString &key) const
{
QMutexLocker lock(&m_mutex);
QString hr = m_humanReadable.value(key);
return hr.isEmpty() ? key : QString("%1 (%2)").arg(hr, key);
}
void CValueCache::setHumanReadableName(const QString &key, const QString &name)
{
QMutexLocker lock(&m_mutex);
if (! m_humanReadable.contains(key)) { m_humanReadable.insert(key, name); }
}
CValueCache::BatchGuard CValueCache::batchChanges(QObject *owner)
{
Q_ASSERT(QThread::currentThread() == owner->thread());