|
Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
|
The list of chores: a model for the view, with ids, saved to a JSON file. More...
#include <chorestore.h>
Public Types | |
| enum | Role { IdRole = Qt::UserRole + 1 } |
| Item data roles of the model, beyond Qt's own. More... | |
Public Member Functions | |
| ChoreStore (QString path, QObject *parent=nullptr) | |
| An empty store that saves to path; an empty path saves nowhere. | |
| bool | load () |
| Reads the file, replacing the chores in the store. | |
| bool | save () const |
| Writes the chores to the file. False if it can't be written. | |
| int | add (const QString &title) |
| Adds a chore at the end and returns its id. | |
| bool | remove (int id) |
| Removes the chore with this id. False if there is none. | |
| int | idAt (int row) const |
| The id of the chore in row, or -1. | |
| int | rowOf (int id) const |
| The row of the chore with this id, or -1. | |
| int | openCount () const |
| Chores not yet done. | |
Private Member Functions | |
| void | append (int id, const QString &title, bool done) |
| Appends an item for a chore. | |
Private Attributes | |
| QString | m_path |
| The JSON file the chores are saved to. | |
| int | m_nextId = 1 |
| The id the next new chore gets. | |
The list of chores: a model for the view, with ids, saved to a JSON file.
Each chore is one checkable item. Its id (ChoreStore::IdRole) stays the same when the list is filtered or reordered, so actions find their chore by id.
| enum ChoreStore::Role |
| bool ChoreStore::load | ( | ) |
Reads the file, replacing the chores in the store.
False if it can't be read; a missing file is an empty list.