Commit d7a2cf22 authored by Camilo higuita's avatar Camilo higuita

add remove option and confirmation dialog

parent 4b47bea2
This diff is collapsed.
<RCC>
<qresource prefix="/">
<file>smartphone.svg</file>
<file>Circuit.svg</file>
</qresource>
</RCC>
......@@ -23,6 +23,11 @@ bool Synchroniser::updateContact(const FMH::MODEL &contact)
return this->dba->updateContact(contact);
}
bool Synchroniser::removeContact(const FMH::MODEL &contact)
{
return this->dba->removeContact(contact[FMH::MODEL_KEY::ID]);
}
vCard Synchroniser::tovCard(const FMH::MODEL &contact)
{
Q_UNUSED(contact);
......
......@@ -21,6 +21,7 @@ public:
FMH::MODEL_LIST getContacts(const QString &query);
bool insertContact(const FMH::MODEL &contact);
bool updateContact(const FMH::MODEL &contact);
bool removeContact(const FMH::MODEL &contact);
private:
DBActions *dba;
......
......@@ -24,7 +24,7 @@ Maui.ApplicationWindow
/** UI PROPS**/
// altToolBars: true
// altToolBars: true
bgColor: viewBackgroundColor
highlightColor: "#ff6a83"
......@@ -100,6 +100,27 @@ Maui.ApplicationWindow
ContactDialog
{
id: _contactDialog
rejectButton.visible: true
rejectButton.text: "Remove"
Maui.Dialog
{
id: _removeDialog
title: qsTr("Remove contact...")
message: qsTr("Are you sure you want to remove this contact? This action can not be undone.")
onRejected: close()
onAccepted:
{
close()
_contactDialog.close()
_contacsView.list.remove(_contacsView.listView.currentIndex)
}
}
onRejected: _removeDialog.open()
}
EditContactDialog
......
......@@ -169,6 +169,22 @@ bool ContactsModel::update(const QVariantMap &map, const int &index)
return false;
}
bool ContactsModel::remove(const int &index)
{
if(index >= this->list.size() || index < 0)
return false;
if(this->syncer->removeContact(this->list[index]))
{
emit this->preItemRemoved(index);
this->list.removeAt(index);
emit this->postItemRemoved();
return true;
}
return false;
}
void ContactsModel::append(const QVariantMap &item)
{
if(item.isEmpty())
......
......@@ -59,6 +59,7 @@ public slots:
QVariantMap get(const int &index) const override;
bool insert(const QVariantMap &map) override;
bool update(const QVariantMap &map, const int &index) override;
bool remove(const int &index);
void append(const QVariantMap &item, const int &at);
void append(const QVariantMap &item);
......
......@@ -151,7 +151,7 @@ ItemDelegate
{
Layout.fillHeight: true
Layout.fillWidth: true
text: model.title
text: model.tel
font.pointSize: fontSizes.small
font.weight: Font.Light
wrapMode: Text.WrapAnywhere
......@@ -191,7 +191,7 @@ ItemDelegate
Layout.fillWidth: true
Layout.alignment: Qt.AlignRight
horizontalAlignment: Qt.AlignRight
text: model.tel
text: model.title
font.pointSize: fontSizes.small
font.weight: Font.Light
wrapMode: Text.WrapAnywhere
......
......@@ -68,7 +68,21 @@ Maui.Page
id: _contactsList
}
content: ListView
Maui.Holder
{
id: _holder
emoji: "qrc:/Circuit.svg"
isMask: false
title: qsTr("There's not contacts")
body: qsTr("Add new contacts")
emojiSize: iconSizes.huge
visible: !listView.count
onActionTriggered: _newContactDialog.open()
}
ListView
{
id: _listView
anchors.fill: parent
......
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