aboutsummaryrefslogtreecommitdiff
path: root/lib/bookmarks/forms/editbookmarkdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bookmarks/forms/editbookmarkdialog.cpp')
-rw-r--r--lib/bookmarks/forms/editbookmarkdialog.cpp41
1 files changed, 33 insertions, 8 deletions
diff --git a/lib/bookmarks/forms/editbookmarkdialog.cpp b/lib/bookmarks/forms/editbookmarkdialog.cpp
index 47aa0b7..7bc1331 100644
--- a/lib/bookmarks/forms/editbookmarkdialog.cpp
+++ b/lib/bookmarks/forms/editbookmarkdialog.cpp
@@ -18,28 +18,53 @@ EditBookmarkDialog::EditBookmarkDialog(BookmarkModel *model, const QModelIndex &
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
+ Q_CHECK_PTR(model);
+ m_model = model;
+ m_index = index;
+
ui->title->setText(model->data(index, BookmarkItem::Title, Qt::DisplayRole).toString());
- connect(ui->title, &QLineEdit::editingFinished, this, [this, model, index]() {
- model->setData(index, ui->title->text(), BookmarkItem::Title, Qt::DisplayRole);
+ connect(ui->title, &QLineEdit::editingFinished, this, [this]() {
+ titleChanged = true;
});
ui->address->setText(model->data(index, BookmarkItem::Href, Qt::DisplayRole).toString());
- connect(ui->address, &QLineEdit::editingFinished, this, [this, model, index]() {
- model->setData(index, ui->address->text(), BookmarkItem::Href, Qt::DisplayRole);
+ connect(ui->address, &QLineEdit::editingFinished, this, [this]() {
+ hrefChanged = true;
});
ui->tags->setText(model->data(index, BookmarkItem::Tags, Qt::DisplayRole).toStringList().join(", "));
- connect(ui->tags, &QLineEdit::editingFinished, this, [this, model, index]() {
- model->setData(index, ui->tags->text().split(", "), BookmarkItem::Tags, Qt::DisplayRole);
+ connect(ui->tags, &QLineEdit::editingFinished, this, [this]() {
+ tagsChanged = true;
});
ui->description->setPlainText(model->data(index, BookmarkItem::Description, Qt::DisplayRole).toString());
- connect(ui->description, &QPlainTextEdit::textChanged, this, [this, model, index]() {
- model->setData(index, ui->description->toPlainText(), BookmarkItem::Description, Qt::DisplayRole);
+ connect(ui->description, &QPlainTextEdit::textChanged, this, [this]() {
+ descriptionChanged = true;
});
+
+ connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &EditBookmarkDialog::saveChanges);
}
EditBookmarkDialog::~EditBookmarkDialog()
{
delete ui;
}
+
+void EditBookmarkDialog::saveChanges()
+{
+ if(titleChanged) {
+ m_model->setData(m_index, ui->title->text(), BookmarkItem::Title, Qt::DisplayRole);
+ }
+
+ if(hrefChanged) {
+ m_model->setData(m_index, ui->address->text(), BookmarkItem::Href, Qt::DisplayRole);
+ }
+
+ if(tagsChanged) {
+ m_model->setData(m_index, ui->tags->text().split(", "), BookmarkItem::Tags, Qt::DisplayRole);
+ }
+
+ if(descriptionChanged) {
+ m_model->setData(m_index, ui->description->toPlainText(), BookmarkItem::Description, Qt::DisplayRole);
+ }
+} \ No newline at end of file