notes.h 1.85 KB
Newer Older
Camilo higuita's avatar
Camilo higuita committed
1 2 3 4
#ifndef NOTES_H
#define NOTES_H

#include <QObject>
5
#include "owl.h"
Camilo higuita's avatar
Camilo higuita committed
6

7 8 9 10 11 12 13 14 15
#ifdef STATIC_MAUIKIT
#include "fmh.h"
#include "mauimodel.h"
#else
#include <MauiKit/fmh.h>
#include <MauiKit/mauilist.h>
#endif


16
class Syncer;
17
class Notes : public MauiList
Camilo higuita's avatar
Camilo higuita committed
18 19
{
    Q_OBJECT
20 21
    Q_PROPERTY(SORTBY sortBy READ getSortBy WRITE setSortBy NOTIFY sortByChanged)
    Q_PROPERTY(ORDER order READ getOrder WRITE setOrder NOTIFY orderChanged)
camilo higuita's avatar
camilo higuita committed
22
    Q_PROPERTY(QVariantMap account READ getAccount WRITE setAccount NOTIFY accountChanged)
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

public:    
    enum ORDER : uint8_t
    {
        DESC,
        ASC
    };
    Q_ENUM(ORDER)

    enum SORTBY : uint8_t
    {
        TITLE = FMH::MODEL_KEY::TITLE,
        ADDDATE = FMH::MODEL_KEY::ADDDATE,
        MODIFIED = FMH::MODEL_KEY::MODIFIED,
        COLOR = FMH::MODEL_KEY::COLOR,
        FAVORITE = FMH::MODEL_KEY::FAVORITE,
        PIN = FMH::MODEL_KEY::PIN
    };
    Q_ENUM(SORTBY)

Camilo higuita's avatar
Camilo higuita committed
43
    explicit Notes(QObject *parent = nullptr);
44 45 46 47 48 49
    FMH::MODEL_LIST items() const override final;

    void setSortBy(const SORTBY &sort);
    SORTBY getSortBy() const;
    void setOrder(const ORDER &order);
    ORDER getOrder() const;
Camilo higuita's avatar
Camilo higuita committed
50

camilo higuita's avatar
camilo higuita committed
51 52 53
    void setAccount(const QVariantMap &account);
    QVariantMap getAccount() const;

Camilo higuita's avatar
Camilo higuita committed
54
private:
55 56

    Syncer *syncer;
57

58
    FMH::MODEL_LIST notes;
59
    void sortList();
Camilo higuita's avatar
Camilo higuita committed
60

61 62
    SORTBY sort = SORTBY::MODIFIED;
    ORDER order = ORDER::DESC;
camilo higuita's avatar
camilo higuita committed
63
    QVariantMap m_account;
64

Camilo higuita's avatar
Camilo higuita committed
65
signals:
66 67
    void orderChanged();
    void sortByChanged();
camilo higuita's avatar
camilo higuita committed
68
    void accountChanged();
Camilo higuita's avatar
Camilo higuita committed
69 70

public slots:
71 72
    QVariantList getTags(const int &index);

73 74 75 76 77 78
    QVariantMap get(const int &index) const;
    bool insert(const QVariantMap &note);
    bool update(const int &index, const QVariant &value, const int &role); //deprecrated
    bool update(const QVariantMap &data, const int &index);
    bool update(const FMH::MODEL &note);
    bool remove(const int &index);
camilo higuita's avatar
camilo higuita committed
79

Camilo higuita's avatar
Camilo higuita committed
80 81 82
};

#endif // NOTES_H