mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +00:00
Merge branch 'key-filtering-feature'
This commit is contained in:
commit
eb63ef5e96
@ -96,6 +96,8 @@ void AWKeys::initKeys()
|
|||||||
extUpgrade.clear();
|
extUpgrade.clear();
|
||||||
graphicalItems.clear();
|
graphicalItems.clear();
|
||||||
keys.clear();
|
keys.clear();
|
||||||
|
foundBars.clear();
|
||||||
|
foundKeys.clear();
|
||||||
|
|
||||||
// init
|
// init
|
||||||
extQuotes = getExtQuotes();
|
extQuotes = getExtQuotes();
|
||||||
@ -148,14 +150,18 @@ QString AWKeys::parsePattern(const QString currentPattern)
|
|||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (keys.isEmpty()) return currentPattern;
|
if (keys.isEmpty()) return currentPattern;
|
||||||
|
|
||||||
|
// get key data
|
||||||
|
if ((foundBars.isEmpty()) && (foundKeys.isEmpty())) {
|
||||||
|
foundBars = findGraphicalItems(currentPattern);
|
||||||
|
foundKeys = findKeys(currentPattern);
|
||||||
|
}
|
||||||
|
|
||||||
QString parsed = currentPattern;
|
QString parsed = currentPattern;
|
||||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||||
for (int i=0; i<keys.count(); i++) {
|
for (int i=0; i<foundKeys.count(); i++)
|
||||||
if (keys[i].startsWith(QString("bar")))
|
parsed.replace(QString("$%1").arg(foundKeys[i]), htmlValue(foundKeys[i]));
|
||||||
parsed.replace(QString("$%1").arg(keys[i]), getItemByTag(keys[i])->image(valueByKey(keys[i]).toFloat()));
|
for (int i=0; i<foundBars.count(); i++)
|
||||||
else
|
parsed.replace(QString("$%1").arg(foundBars[i]), getItemByTag(foundBars[i])->image(valueByKey(foundBars[i]).toFloat()));
|
||||||
parsed.replace(QString("$%1").arg(keys[i]), htmlValue(keys[i]));
|
|
||||||
}
|
|
||||||
parsed.replace(QString("$\\$\\"), QString("$$"));
|
parsed.replace(QString("$\\$\\"), QString("$$"));
|
||||||
// wrap new lines if required
|
// wrap new lines if required
|
||||||
if (wrapNewLines) parsed.replace(QString("\n"), QString("<br>"));
|
if (wrapNewLines) parsed.replace(QString("\n"), QString("<br>"));
|
||||||
@ -1322,6 +1328,41 @@ float AWKeys::temperature(const float temp, const QString units)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList AWKeys::findGraphicalItems(const QString pattern)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QStringList orderedKeys;
|
||||||
|
for (int i=0; i<graphicalItems.count(); i++)
|
||||||
|
orderedKeys.append(graphicalItems[i]->name() + graphicalItems[i]->bar());
|
||||||
|
orderedKeys.sort();
|
||||||
|
|
||||||
|
QStringList selectedKeys;
|
||||||
|
for (int i=orderedKeys.count()-1; i>=0; i--)
|
||||||
|
if (pattern.contains(QString("$%1").arg(orderedKeys[i]))) {
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Found key" << orderedKeys[i];
|
||||||
|
selectedKeys.append(orderedKeys[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectedKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList AWKeys::findKeys(const QString pattern)
|
||||||
|
{
|
||||||
|
QStringList selectedKeys;
|
||||||
|
for (int i=0; i<keys.count(); i++) {
|
||||||
|
if (keys[i].startsWith(QString("bar"))) continue;
|
||||||
|
if (pattern.contains(QString("$%1").arg(keys[i]))) {
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Found key" << keys[i];
|
||||||
|
selectedKeys.append(keys[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectedKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<ExtQuotes *> AWKeys::getExtQuotes()
|
QList<ExtQuotes *> AWKeys::getExtQuotes()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
@ -93,6 +93,10 @@ private:
|
|||||||
QString htmlValue(QString key);
|
QString htmlValue(QString key);
|
||||||
int numberCpus();
|
int numberCpus();
|
||||||
float temperature(const float temp, const QString units);
|
float temperature(const float temp, const QString units);
|
||||||
|
// find methods
|
||||||
|
QStringList findGraphicalItems(const QString pattern);
|
||||||
|
QStringList findKeys(const QString pattern);
|
||||||
|
// get methods
|
||||||
// get methods
|
// get methods
|
||||||
QList<ExtQuotes *> getExtQuotes();
|
QList<ExtQuotes *> getExtQuotes();
|
||||||
QList<ExtScript *> getExtScripts();
|
QList<ExtScript *> getExtScripts();
|
||||||
@ -117,8 +121,9 @@ private:
|
|||||||
QList<ExtQuotes *> extQuotes;
|
QList<ExtQuotes *> extQuotes;
|
||||||
QList<ExtScript *> extScripts;
|
QList<ExtScript *> extScripts;
|
||||||
QList<ExtUpgrade *> extUpgrade;
|
QList<ExtUpgrade *> extUpgrade;
|
||||||
|
QStringList foundBars, foundKeys, keys;
|
||||||
QMap<QString, QString> values;
|
QMap<QString, QString> values;
|
||||||
QStringList keys, diskDevices, hddDevices, mountDevices, networkDevices, tempDevices;
|
QStringList diskDevices, hddDevices, mountDevices, networkDevices, tempDevices;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user