Commit d7a2cf22 authored by Camilo higuita's avatar Camilo higuita

add remove option and confirmation dialog

parent 4b47bea2
This diff is collapsed.
<RCC> <RCC>
<qresource prefix="/"> <qresource prefix="/">
<file>smartphone.svg</file> <file>smartphone.svg</file>
<file>Circuit.svg</file>
</qresource> </qresource>
</RCC> </RCC>
...@@ -23,6 +23,11 @@ bool Synchroniser::updateContact(const FMH::MODEL &contact) ...@@ -23,6 +23,11 @@ bool Synchroniser::updateContact(const FMH::MODEL &contact)
return this->dba->updateContact(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) vCard Synchroniser::tovCard(const FMH::MODEL &contact)
{ {
Q_UNUSED(contact); Q_UNUSED(contact);
......
...@@ -21,6 +21,7 @@ public: ...@@ -21,6 +21,7 @@ public:
FMH::MODEL_LIST getContacts(const QString &query); FMH::MODEL_LIST getContacts(const QString &query);
bool insertContact(const FMH::MODEL &contact); bool insertContact(const FMH::MODEL &contact);
bool updateContact(const FMH::MODEL &contact); bool updateContact(const FMH::MODEL &contact);
bool removeContact(const FMH::MODEL &contact);
private: private:
DBActions *dba; DBActions *dba;
......
...@@ -24,7 +24,7 @@ Maui.ApplicationWindow ...@@ -24,7 +24,7 @@ Maui.ApplicationWindow
/** UI PROPS**/ /** UI PROPS**/
// altToolBars: true // altToolBars: true
bgColor: viewBackgroundColor bgColor: viewBackgroundColor
highlightColor: "#ff6a83" highlightColor: "#ff6a83"
...@@ -100,6 +100,27 @@ Maui.ApplicationWindow ...@@ -100,6 +100,27 @@ Maui.ApplicationWindow
ContactDialog ContactDialog
{ {
id: _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 EditContactDialog
......
...@@ -169,6 +169,22 @@ bool ContactsModel::update(const QVariantMap &map, const int &index) ...@@ -169,6 +169,22 @@ bool ContactsModel::update(const QVariantMap &map, const int &index)
return false; 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) void ContactsModel::append(const QVariantMap &item)
{ {
if(item.isEmpty()) if(item.isEmpty())
......
...@@ -59,6 +59,7 @@ public slots: ...@@ -59,6 +59,7 @@ public slots:
QVariantMap get(const int &index) const override; QVariantMap get(const int &index) const override;
bool insert(const QVariantMap &map) override; bool insert(const QVariantMap &map) override;
bool update(const QVariantMap &map, const int &index) 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, const int &at);
void append(const QVariantMap &item); void append(const QVariantMap &item);
......
...@@ -151,7 +151,7 @@ ItemDelegate ...@@ -151,7 +151,7 @@ ItemDelegate
{ {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
text: model.title text: model.tel
font.pointSize: fontSizes.small font.pointSize: fontSizes.small
font.weight: Font.Light font.weight: Font.Light
wrapMode: Text.WrapAnywhere wrapMode: Text.WrapAnywhere
...@@ -191,7 +191,7 @@ ItemDelegate ...@@ -191,7 +191,7 @@ ItemDelegate
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
horizontalAlignment: Qt.AlignRight horizontalAlignment: Qt.AlignRight
text: model.tel text: model.title
font.pointSize: fontSizes.small font.pointSize: fontSizes.small
font.weight: Font.Light font.weight: Font.Light
wrapMode: Text.WrapAnywhere wrapMode: Text.WrapAnywhere
......
...@@ -68,7 +68,21 @@ Maui.Page ...@@ -68,7 +68,21 @@ Maui.Page
id: _contactsList 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 id: _listView
anchors.fill: parent 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