Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
notesstore.h
Go to the documentation of this file.
1#pragma once
2
6
7#include <QtCore/QList>
8#include <QtCore/QObject>
9#include <QtCore/QString>
10#include <QtGui/QUndoStack>
11
13struct Note
14{
15 QString title;
16 QString text;
17};
18
21class NotesStore : public QObject
22{
23 Q_OBJECT
24public:
26 explicit NotesStore(QObject *parent = nullptr);
27
29 const QList<Note> &notes() const { return m_notes; }
31 qsizetype indexOf(const QString &title) const;
33 QUndoStack *undoStack() { return &m_undo; }
34
36 void append(const QString &title, const QString &text);
38 bool remove(const QString &title);
39
40Q_SIGNALS:
42 void changed();
43
44private:
45 friend class AppendCommand;
46 friend class RemoveCommand;
47
48 QList<Note> m_notes;
49 QUndoStack m_undo;
50};
bool remove(const QString &title)
Deletes the note titled title. Undoable.
Definition notesstore.cpp:108
QList< Note > m_notes
The notes, in order.
Definition notesstore.h:48
NotesStore(QObject *parent=nullptr)
An empty notebook.
Definition notesstore.cpp:94
void append(const QString &title, const QString &text)
Adds a note, or appends text to the note titled title. Undoable.
Definition notesstore.cpp:103
QUndoStack m_undo
Every change, for undo.
Definition notesstore.h:49
void changed()
The notes changed.
const QList< Note > & notes() const
The notes, in order.
Definition notesstore.h:29
qsizetype indexOf(const QString &title) const
The index of the note titled title, or -1.
Definition notesstore.cpp:96
QUndoStack * undoStack()
The undo stack (for the Edit menu).
Definition notesstore.h:33
One note.
Definition notesstore.h:14
QString text
Its text.
Definition notesstore.h:16
QString title
Its title, unique in the notebook.
Definition notesstore.h:15