Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 7f239f41 authored by camilo higuita's avatar camilo higuita

more work for the boolets model

parent 914f0aa1
#include "booklet.h" #include "booklet.h"
#include "syncer.h"
Booklet::Booklet(QObject *parent) : MauiList(parent) Booklet::Booklet(Syncer *_syncer, QObject *parent) : MauiList(parent),
syncer(_syncer)
{ {
} }
...@@ -30,6 +32,31 @@ Booklet::ORDER Booklet::getOrder() const ...@@ -30,6 +32,31 @@ Booklet::ORDER Booklet::getOrder() const
return this->order; return this->order;
} }
void Booklet::insert(const QVariantMap &data)
{
emit this->preItemAppended();
auto __booklet = FMH::toModel(data);
__booklet[FMH::MODEL_KEY::MODIFIED] = QDateTime::currentDateTime().toString(Qt::TextDate);
__booklet[FMH::MODEL_KEY::ADDDATE] = QDateTime::currentDateTime().toString(Qt::TextDate);
this->syncer->insertBooklet(__booklet);
this->m_list << __booklet;
emit this->postItemAppended();
}
void Booklet::update(const QVariantMap &data, const int &index)
{
}
void Booklet::remove(const int &index)
{
}
void Booklet::sortList() void Booklet::sortList()
{ {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <MauiKit/mauilist.h> #include <MauiKit/mauilist.h>
#endif #endif
class Syncer;
class Booklet : public MauiList class Booklet : public MauiList
{ {
Q_OBJECT Q_OBJECT
...@@ -19,7 +20,7 @@ class Booklet : public MauiList ...@@ -19,7 +20,7 @@ class Booklet : public MauiList
Q_PROPERTY(QString book READ getBook WRITE setBook NOTIFY bookChanged) Q_PROPERTY(QString book READ getBook WRITE setBook NOTIFY bookChanged)
public: public:
Booklet(QObject *parent = nullptr); Booklet(Syncer *syncer = nullptr, QObject *parent = nullptr);
enum ORDER : uint8_t enum ORDER : uint8_t
{ {
...@@ -61,8 +62,13 @@ public slots: ...@@ -61,8 +62,13 @@ public slots:
emit bookChanged(m_book); emit bookChanged(m_book);
} }
void insert(const QVariantMap &data);
void update(const QVariantMap &data, const int &index);
void remove(const int &index);
private: private:
FMH::MODEL_LIST m_list; FMH::MODEL_LIST m_list;
Syncer *syncer;
void sortList(); void sortList();
......
...@@ -121,6 +121,11 @@ void Syncer::insertBook(FMH::MODEL &book) ...@@ -121,6 +121,11 @@ void Syncer::insertBook(FMH::MODEL &book)
emit this->bookInserted(book, {STATE::TYPE::LOCAL, STATE::STATUS::OK, "Book inserted locally sucessfully"}); emit this->bookInserted(book, {STATE::TYPE::LOCAL, STATE::STATUS::OK, "Book inserted locally sucessfully"});
} }
void Syncer::insertBooklet(const FMH::MODEL &booklet)
{
}
void Syncer::addId(FMH::MODEL &model) void Syncer::addId(FMH::MODEL &model)
{ {
const auto id = QUuid::createUuid().toString(); const auto id = QUuid::createUuid().toString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment