Commit df34e671 authored by Camilo higuita's avatar Camilo higuita

now remove notes form model

parent c1b24157
......@@ -69,7 +69,6 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
DISTFILES += \
src/db/script.sql \
src/utils/owl.js \
HEADERS += \
src/db/db.h \
......
......@@ -16,7 +16,6 @@
<file>src/widgets/ColorsBar.qml</file>
<file>src/widgets/CardsList.qml</file>
<file>src/widgets/CardMenu.qml</file>
<file>src/utils/owl.js</file>
<file>src/widgets/LinkCardDelegate.qml</file>
</qresource>
</RCC>
......@@ -121,10 +121,18 @@ bool Notes::updateNote(const OWL::DB &note)
return this->db->update(OWL::TABLEMAP[OWL::TABLE::NOTES], note_map, {{OWL::KEYMAP[OWL::KEY::ID], id}} );
}
bool Notes::removeNote(const QVariantMap &note)
bool Notes::removeNote(const int &index)
{
qDebug()<<note;
return this->db->remove(OWL::TABLEMAP[OWL::TABLE::NOTES], note);
auto id = this->notes.at(index)[OWL::KEY::ID];
QVariantMap note = {{OWL::KEYMAP[OWL::KEY::ID], id}};
if(this->db->remove(OWL::TABLEMAP[OWL::TABLE::NOTES], note))
{
this->notes.removeAt(index);
return true;
}
return false;
}
QVariantList Notes::getNoteTags(const QString &id)
......
......@@ -24,7 +24,8 @@ public:
bool updateNote(const int &index, const QVariant &value, const int &role);
bool updateNote(const OWL::DB &note);
bool removeNote(const QVariantMap &note);
bool removeNote(const int &index);
QVariantList getNoteTags(const QString &id);
private:
......
......@@ -42,9 +42,24 @@ void NotesModel::sortBy(const int &index, const QString &order)
bool NotesModel::insert(const QVariantMap &note)
{
const int index = mNotes->items().size();
beginInsertRows(QModelIndex(), index, index);
this->mNotes->insertNote(note);
endInsertRows();
if(this->mNotes->insertNote(note))
{
beginInsertRows(QModelIndex(), index, index);
endInsertRows();
return true;
}
return false;
}
bool NotesModel::remove(const int &index)
{
if(mNotes->removeNote(index))
{
beginResetModel();
endResetModel();
return true;
}
return false;
}
......
......@@ -22,9 +22,12 @@ public:
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
Q_INVOKABLE QVariantMap get(const int &index);
Q_INVOKABLE void sortBy(const int &index, const QString &order);
Q_INVOKABLE QVariantMap get(const int &index);
Q_INVOKABLE bool insert(const QVariantMap &note);
Q_INVOKABLE bool remove(const int &index);
Q_INVOKABLE QVariantList getTags(const int &index);
// Editable:
......
function saveNote(title, body, color, tags)
{
return owl.insertNote(title, body, color, tags)
}
function removeNote(note)
{
var map = {id: note.id }
return owl.removeNote(map)
}
function removeLink(link)
{
var map = {link: link.link }
return owl.removeLink(map)
}
......@@ -4,7 +4,6 @@ import org.kde.mauikit 1.0 as Maui
import org.kde.kirigami 2.2 as Kirigami
import "../../widgets"
import "../../utils/owl.js" as O
import Links 1.0
import Owl 1.0
......@@ -154,8 +153,7 @@ Maui.Page
Connections
{
target: cardsView.menu
onDeleteClicked: if(O.removeLink(cardsView.model.get(cardsView.currentIndex)))
cardsView.model.remove(cardsView.currentIndex)
onDeleteClicked: linksModel.remove(cardsView.currentIndex)
}
}
}
......@@ -8,7 +8,6 @@ import org.kde.mauikit 1.0 as Maui
import org.kde.kirigami 2.2 as Kirigami
import "../../widgets"
import "../../utils/owl.js" as O
import Notes 1.0
import Owl 1.0
......@@ -189,8 +188,7 @@ Maui.Page
Connections
{
target: cardsView.menu
onDeleteClicked: if(O.removeNote(cardsView.model.get(cardsView.currentIndex)))
cardsView.model.remove(cardsView.currentIndex)
onDeleteClicked: notesModel.remove(cardsView.currentIndex)
}
}
}
......
......@@ -14,12 +14,18 @@ ListView
orientation: ListView.Horizontal
spacing: 0
Maui.Holder
{
id: holder
visible: count < 1
message: "<h3>No pinned notes!</h3><p>You can pin your notes to see them here</p>"
}
// Maui.Holder
// {
// id: holder
// visible: control.count > 0
// emoji: "qrc:/Type.png"
// emojiSize: iconSizes.big
// isMask: false
// title : "No pinned notes!"
// body: "You can pin your notes to see them here"
// z: 999
// colorScheme.textColor: altColorText
// }
model: notesView.model
delegate: Item
......
......@@ -18,6 +18,7 @@ ItemDelegate
signal rightClicked();
visible: condition
clip: true
width: cardWidth
height: cardHeight
......@@ -75,6 +76,7 @@ ItemDelegate
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.margins: unit
clip: true
ColumnLayout
{
......@@ -97,6 +99,7 @@ ItemDelegate
font.weight: Font.Bold
font.bold: true
font.pointSize: fontSizes.small
clip: true
}
Label
......
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