mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-06 10:25:52 +00:00
add formatters reinit (fix #102)
This commit is contained in:
@ -48,8 +48,6 @@ AWKeysAggregator::AWKeysAggregator(QObject *parent)
|
||||
m_formatter[QString("swap")] = FormatterType::Float;
|
||||
m_formatter[QString("swaptotmb")] = FormatterType::MemMBFormat;
|
||||
m_formatter[QString("swaptotgb")] = FormatterType::MemGBFormat;
|
||||
|
||||
m_customFormatters = new AWFormatterHelper(nullptr);
|
||||
}
|
||||
|
||||
|
||||
@ -61,6 +59,14 @@ AWKeysAggregator::~AWKeysAggregator()
|
||||
}
|
||||
|
||||
|
||||
void AWKeysAggregator::initFormatters()
|
||||
{
|
||||
if (m_customFormatters)
|
||||
delete m_customFormatters;
|
||||
m_customFormatters = new AWFormatterHelper(nullptr);
|
||||
}
|
||||
|
||||
|
||||
QString AWKeysAggregator::formatter(const QVariant &data,
|
||||
const QString &key) const
|
||||
{
|
||||
@ -170,7 +176,8 @@ QString AWKeysAggregator::formatter(const QVariant &data,
|
||||
output = data.toString();
|
||||
break;
|
||||
case FormatterType::Custom:
|
||||
output = m_customFormatters->convert(data, key);
|
||||
if (m_customFormatters)
|
||||
output = m_customFormatters->convert(data, key);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -574,7 +581,9 @@ QStringList AWKeysAggregator::registerSource(const QString &source,
|
||||
QStringList foundKeys = keysFromSource(source);
|
||||
|
||||
// rewrite formatters for custom ones
|
||||
QStringList customFormattersKeys = m_customFormatters->definedFormatters();
|
||||
QStringList customFormattersKeys;
|
||||
if (m_customFormatters)
|
||||
customFormattersKeys = m_customFormatters->definedFormatters();
|
||||
qCInfo(LOG_AW) << "Looking for fprmatters" << foundKeys << "in"
|
||||
<< customFormattersKeys;
|
||||
for (auto key : foundKeys) {
|
||||
|
Reference in New Issue
Block a user