mirror of
https://github.com/quickshell-mirror/quickshell.git
synced 2026-10-27 02:54:36 +00:00
tooling: use QList<QJSValue> over QJSValueList
QJSValueList is not currently a defined QML type, breaking qmllint and qmlls.
This commit is contained in:
2 files changed
+7
-7
No files matched your search
@@ -13,7 +13,7 @@
|
||||
#include <qtypes.h>
|
||||
#include <qvariant.h>
|
||||
|
||||
bool ScriptModel::updateValuesUnique(const QJSValueList& newValues) {
|
||||
bool ScriptModel::updateValuesUnique(const QList<QJSValue>& newValues) {
|
||||
auto anyChanges = false;
|
||||
|
||||
this->hasActiveIterators = true;
|
||||
@@ -163,7 +163,7 @@ bool ScriptModel::updateValuesUnique(const QJSValueList& newValues) {
|
||||
return anyChanges;
|
||||
}
|
||||
|
||||
void ScriptModel::setValues(const QJSValueList& newValues) {
|
||||
void ScriptModel::setValues(const QList<QJSValue>& newValues) {
|
||||
auto changed = this->updateValuesUnique(newValues);
|
||||
if (changed) emit this->valuesChanged();
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class ScriptModel: public QAbstractListModel {
|
||||
/// > }
|
||||
/// > ```
|
||||
// TODO: use qjsobject for gc/free checks?
|
||||
Q_PROPERTY(QJSValueList values READ values WRITE setValues NOTIFY valuesChanged);
|
||||
Q_PROPERTY(QList<QJSValue> values READ values WRITE setValues NOTIFY valuesChanged);
|
||||
/// The property that javascript objects passed into the model will be compared with.
|
||||
///
|
||||
/// For example, if `objectProp` is `"myprop"` then `{ myprop: "a", other: "y" }` and
|
||||
@@ -82,14 +82,14 @@ class ScriptModel: public QAbstractListModel {
|
||||
QML_ELEMENT;
|
||||
|
||||
public:
|
||||
[[nodiscard]] QJSValueList values() const {
|
||||
[[nodiscard]] QList<QJSValue> values() const {
|
||||
auto values = this->mValues;
|
||||
// If not detached, the QML engine will invalidate iterators in updateValuesUnique.
|
||||
if (this->hasActiveIterators) values.detach();
|
||||
return values;
|
||||
}
|
||||
|
||||
void setValues(const QJSValueList& newValues);
|
||||
void setValues(const QList<QJSValue>& newValues);
|
||||
|
||||
[[nodiscard]] QString objectProp() const { return this->cmpKey; }
|
||||
void setObjectProp(const QString& objectProp);
|
||||
@@ -103,9 +103,9 @@ signals:
|
||||
void objectPropChanged();
|
||||
|
||||
private:
|
||||
QJSValueList mValues;
|
||||
QList<QJSValue> mValues;
|
||||
QString cmpKey;
|
||||
bool hasActiveIterators = false;
|
||||
|
||||
bool updateValuesUnique(const QJSValueList& newValues);
|
||||
bool updateValuesUnique(const QList<QJSValue>& newValues);
|
||||
};
|
||||
Reference in new issue
Block a user