Commit 97c2838b authored by Camilo higuita's avatar Camilo higuita

now remove links from linksmodel

parent df34e671
......@@ -119,10 +119,18 @@ bool Links::updateLink(const OWL::DB &link)
return this->db->update(OWL::TABLEMAP[OWL::TABLE::LINKS], link_map, {{OWL::KEYMAP[OWL::KEY::LINK], url}} );
}
bool Links::removeLink(const QVariantMap &link)
bool Links::removeLink(const int &index)
{
qDebug()<<link;
return this->db->remove(OWL::TABLEMAP[OWL::TABLE::LINKS], link);
auto linkUrl = this->links.at(index)[OWL::KEY::LINK];
QVariantMap link = {{OWL::KEYMAP[OWL::KEY::LINK], linkUrl}};
if(this->db->remove(OWL::TABLEMAP[OWL::TABLE::LINKS], link))
{
this->links.removeAt(index);
return true;
}
return false;
}
QVariantList Links::getLinkTags(const QString &link)
......
......@@ -21,7 +21,7 @@ public:
Q_INVOKABLE bool insertLink(const QVariantMap &link);
bool updateLink(const int &index, const QVariant &value, const int &role);
bool updateLink(const OWL::DB &link);
Q_INVOKABLE bool removeLink(const QVariantMap &link);
Q_INVOKABLE bool removeLink(const int &index);
QVariantList getLinkTags(const QString &link);
private:
......
......@@ -45,9 +45,22 @@ bool LinksModel::insert(const QVariantMap &link)
if( this->mLinks->insertLink(link))
{
beginInsertRows(QModelIndex(), index, index);
endInsertRows();
return true;
}
return false;
}
bool LinksModel::remove(const int &index)
{
if(this->mLinks->removeLink(index))
{
beginResetModel();
endResetModel();
return true;
}
return false;
}
......
......@@ -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 bool remove(const int &index);
Q_INVOKABLE QVariantList getTags(const int &index);
// Editable:
......
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