Skip to content

Commit

Permalink
core/scriptmodel: improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
outfoxxed committed Jan 14, 2025
1 parent 2c4ef64 commit 958056b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/core/scriptmodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
/// delegate: // ...
/// }
/// ```
/// [QAbstractItemModel]: https://doc.qt.io/qt-6/qabstractitemmodel.html
/// [Data Model]: https://doc.qt.io/qt-6/qtquick-modelviewsdata-modelview.html#qml-data-models
class ScriptModel: public QAbstractListModel {
Q_OBJECT;
/// The list of values to reflect in the model.
Expand All @@ -51,8 +53,19 @@ class ScriptModel: public QAbstractListModel {
/// > }
/// > ```
/// >
/// > Note that we are using @@DesktopEntries.values because it will cause @@ScriptModel.values
/// > Note that we are using @@ObjectModel.values because it will cause @@ScriptModel.values
/// > to receive an update on change.
///
/// > [!TIP] Most lists exposed by Quickshell are read-only. Some operations like `sort()`
/// > act on a list in-place and cannot be used directly on a list exposed by Quickshell.
/// > You can copy a list using spread syntax: `[...variable]` instead of `variable`.
/// >
/// > For example:
/// > ```qml
/// > ScriptModel {
/// > values: [...DesktopEntries.applications.values].sort(...)
/// > }
/// > ```
Q_PROPERTY(QVariantList values READ values WRITE setValues NOTIFY valuesChanged);
QML_ELEMENT;

Expand Down

0 comments on commit 958056b

Please sign in to comment.