mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
add formatters reinit (fix #102)
This commit is contained in:
parent
064cd7e44f
commit
052d8a034c
@ -105,10 +105,10 @@ void AWKeys::initKeys(const QString currentPattern, const int interval,
|
||||
m_threadPool->setMaxThreadCount(limit == 0 ? QThread::idealThreadCount()
|
||||
: limit);
|
||||
// child objects
|
||||
aggregator->initFormatters();
|
||||
keyOperator->setPattern(currentPattern);
|
||||
keyOperator->updateCache();
|
||||
dataEngineAggregator->clear();
|
||||
|
||||
dataEngineAggregator->initDataEngines(interval);
|
||||
|
||||
// timer
|
||||
|
@ -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) {
|
||||
|
@ -69,6 +69,7 @@ class AWKeysAggregator : public QObject
|
||||
public:
|
||||
explicit AWKeysAggregator(QObject *parent = nullptr);
|
||||
virtual ~AWKeysAggregator();
|
||||
void initFormatters();
|
||||
// get methods
|
||||
QString formatter(const QVariant &data, const QString &key) const;
|
||||
QStringList keysFromSource(const QString &source) const;
|
||||
|
Loading…
Reference in New Issue
Block a user