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