Skip to content

Commit 958056b

Browse files
committed
core/scriptmodel: improve docs
1 parent 2c4ef64 commit 958056b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/core/scriptmodel.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
/// delegate: // ...
3737
/// }
3838
/// ```
39+
/// [QAbstractItemModel]: https://doc.qt.io/qt-6/qabstractitemmodel.html
40+
/// [Data Model]: https://doc.qt.io/qt-6/qtquick-modelviewsdata-modelview.html#qml-data-models
3941
class ScriptModel: public QAbstractListModel {
4042
Q_OBJECT;
4143
/// The list of values to reflect in the model.
@@ -51,8 +53,19 @@ class ScriptModel: public QAbstractListModel {
5153
/// > }
5254
/// > ```
5355
/// >
54-
/// > Note that we are using @@DesktopEntries.values because it will cause @@ScriptModel.values
56+
/// > Note that we are using @@ObjectModel.values because it will cause @@ScriptModel.values
5557
/// > to receive an update on change.
58+
///
59+
/// > [!TIP] Most lists exposed by Quickshell are read-only. Some operations like `sort()`
60+
/// > act on a list in-place and cannot be used directly on a list exposed by Quickshell.
61+
/// > You can copy a list using spread syntax: `[...variable]` instead of `variable`.
62+
/// >
63+
/// > For example:
64+
/// > ```qml
65+
/// > ScriptModel {
66+
/// > values: [...DesktopEntries.applications.values].sort(...)
67+
/// > }
68+
/// > ```
5669
Q_PROPERTY(QVariantList values READ values WRITE setValues NOTIFY valuesChanged);
5770
QML_ELEMENT;
5871

0 commit comments

Comments
 (0)