File indexing completed on 2024-12-22 04:30:16

0001 #pragma once
0002 
0003 #include <QObject>
0004 #include <QThread>
0005 
0006 #include <MauiKit3/Core/fmh.h>
0007 
0008 #include "owl.h"
0009 
0010 class DB;
0011 class NotesLoader : public QObject
0012 {
0013     Q_OBJECT
0014 public:
0015     void fetchNotes(FMH::MODEL_LIST notes);
0016 
0017 Q_SIGNALS:
0018     void noteReady(FMH::MODEL note);
0019     void notesReady(FMH::MODEL_LIST notes);
0020 };
0021 
0022 class NotesController : public QObject
0023 {
0024     Q_OBJECT
0025 public:
0026     explicit NotesController(QObject *parent = nullptr);
0027     ~NotesController();
0028 
0029 public Q_SLOTS:
0030     /**
0031      * @brief insertNote
0032      * performs the insertion of a new note in the local storage
0033      * @param note
0034      * note to be inserted
0035      * @param url
0036      * url where to save the note
0037      * @return bool
0038      * true if the note was inserted sucessfully in the local storage
0039      */
0040     bool insertNote(FMH::MODEL &note);
0041     bool updateNote(FMH::MODEL &note, QString id);
0042     bool removeNote(const QString &id);
0043 
0044     void getNotes();
0045 
0046 private:
0047     QThread m_worker;
0048     DB *m_db;
0049 
0050 Q_SIGNALS:
0051     void noteReady(FMH::MODEL note);
0052     void notesReady(FMH::MODEL_LIST notes);
0053     void noteInserted(FMH::MODEL note);
0054     void noteUpdated(FMH::MODEL note);
0055     void fetchNotes(FMH::MODEL_LIST notes);
0056 };