Commit 9b20370f authored by Camilo higuita's avatar Camilo higuita

fixes for new models implementation

parent 219cf0a6
......@@ -194,16 +194,16 @@ Maui.ApplicationWindow
function setNote(note)
{
// var tags = owl.getNoteTags(note.id)
// note.tags = tags
var tags = notesView.model.getTags(notesView.currentIndex)
note.tags = tags
notesView.currentNote = note
editNote.fill(note)
}
function previewLink(link)
{
// var tags = linksView.model.getLinkTags(link.link)
// link.tags = tags
var tags = linksView.model.getTags(linksView.currentIndex)
link.tags = tags
linksView.previewer.show(link)
}
......
......@@ -38,8 +38,6 @@ DBActions::DBActions(QObject *parent) : QObject(parent)
qDebug()<< "Starting DBActions";
this->db = DB::getInstance();
this->tag = Tagging::getInstance(OWL::App, OWL::version, "org.kde.buho", OWL::comment);
}
DBActions::~DBActions() {}
......
......@@ -13,6 +13,7 @@
Links::Links(QObject *parent) : QObject(parent)
{
this->db = DB::getInstance();
this->tag = Tagging::getInstance(OWL::App, OWL::version, "org.kde.buho", OWL::comment);
this->sortBy(OWL::KEY::UPDATED, "DESC");
}
......
......@@ -23,7 +23,7 @@ public:
bool updateLink(const OWL::DB &link);
Q_INVOKABLE bool removeLink(const QVariantMap &link);
Q_INVOKABLE QVariantList getLinkTags(const QString &link);
QVariantList getLinkTags(const QString &link);
private:
Tagging *tag;
DB *db;
......
......@@ -48,6 +48,11 @@ bool LinksModel::insert(const QVariantMap &link)
return false;
}
QVariantList LinksModel::getTags(const int &index)
{
return this->mLinks->getLinkTags(this->mLinks->items().at(index)[OWL::KEY::LINK]);
}
bool LinksModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (!mLinks)
......
......@@ -25,6 +25,7 @@ public:
Q_INVOKABLE QVariantMap get(const int &index);
Q_INVOKABLE void sortBy(const int &index, const QString &order);
Q_INVOKABLE bool insert(const QVariantMap &link);
Q_INVOKABLE QVariantList getTags(const int &index);
// Editable:
bool setData(const QModelIndex &index, const QVariant &value,
......
......@@ -12,6 +12,7 @@
Notes::Notes(QObject *parent) : QObject(parent)
{
this->db = DB::getInstance();
this->tag = Tagging::getInstance(OWL::App, OWL::version, "org.kde.buho", OWL::comment);
this->sortBy(OWL::KEY::UPDATED, "DESC");
}
......@@ -112,6 +113,8 @@ bool Notes::updateNote(const OWL::DB &note)
{OWL::KEYMAP[OWL::KEY::UPDATED], updated}
};
qDebug()<< "TRYING TO UPDATE TAGS"<< tags;
for(auto tg : tags)
this->tag->tagAbstract(tg, OWL::TABLEMAP[OWL::TABLE::NOTES], id, color);
......
......@@ -48,6 +48,12 @@ bool NotesModel::insert(const QVariantMap &note)
return false;
}
QVariantList NotesModel::getTags(const int &index)
{
qDebug()<< "CURRENT INDEX FOR "<< index;
return this->mNotes->getNoteTags(this->mNotes->items().at(index)[OWL::KEY::ID]);
}
bool NotesModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (!mNotes)
......
......@@ -25,6 +25,7 @@ public:
Q_INVOKABLE QVariantMap get(const int &index);
Q_INVOKABLE void sortBy(const int &index, const QString &order);
Q_INVOKABLE bool insert(const QVariantMap &note);
Q_INVOKABLE QVariantList getTags(const int &index);
// Editable:
bool setData(const QModelIndex &index, const QVariant &value,
......
......@@ -15,6 +15,7 @@ Maui.Page
property alias cardsView : cardsView
property alias previewer : previewer
property alias model : linksModel
property alias currentIndex : cardsView.currentIndex
property var currentLink : ({})
......
......@@ -15,6 +15,7 @@ Maui.Page
property alias cardsView : cardsView
property alias model : notesModel
property alias currentIndex : cardsView.currentIndex
signal noteClicked(var note)
......@@ -116,7 +117,6 @@ Maui.Page
itemHeight: cardsView.itemHeight * 0.9
itemWidth: itemHeight
onItemClicked: noteClicked(cardsView.model.get(index))
}
Kirigami.Separator
......
......@@ -207,12 +207,13 @@ ItemDelegate
function update(item)
{
console.log("update link color", item.color)
console.log("update link color", item.color, item.tag)
model.title = item.title
model.body = item.body
model.color = item.color
model.pin = item.pin ? 1 : 0
model.fav = item.fav ? 1 : 0
model.updated = item.updated
model.tag = item.tag.join(",")
}
}
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