aboutsummaryrefslogtreecommitdiff
path: root/lib/bookmarks
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bookmarks')
-rw-r--r--lib/bookmarks/bookmarkswidget.cpp17
-rw-r--r--lib/bookmarks/bookmarkswidget.h4
2 files changed, 14 insertions, 7 deletions
diff --git a/lib/bookmarks/bookmarkswidget.cpp b/lib/bookmarks/bookmarkswidget.cpp
index c46c420..c56fe6c 100644
--- a/lib/bookmarks/bookmarkswidget.cpp
+++ b/lib/bookmarks/bookmarkswidget.cpp
@@ -56,6 +56,8 @@ BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent)
auto *bookmark = ui->treeWidget->createBookmark(parentItem);
bookmark->setText(0, tr("title"));
bookmark->setText(1, tr("href"));
+
+ this->m_isChanged = true;
});
// add folder action
@@ -66,11 +68,14 @@ BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent)
auto *folder = ui->treeWidget->createFolder(parentItem);
folder->setText(0, tr("title"));
+
+ this->m_isChanged = true;
});
// delete item action
connect(ui->deleteItem_toolButton, &QToolButton::clicked, this, [this]() {
delete ui->treeWidget->currentItem();
+ this->m_isChanged = true;
});
// edit item action
@@ -98,6 +103,8 @@ BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent)
ui->bookmark_groupBox->setVisible(true);
}
}
+
+ this->m_isChanged = true;
});
}
@@ -108,20 +115,18 @@ BookmarksWidget::~BookmarksWidget()
void BookmarksWidget::save()
{
- /*
- if(!m_model->isModified()) {
- qDebug("Writing bookmarks skipped");
+ if (!m_isChanged) {
return;
}
- */
QFile bookmarksFile(m_bookmarksPath);
if(bookmarksFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
XbelWriter xbel(&bookmarksFile);
xbel.write(ui->treeWidget);
- //qDebug("Writing bookmarks %s", m_model->write(&xbel) ? "ok" : "failed");
bookmarksFile.flush();
bookmarksFile.close();
+
+ m_isChanged = false;
}
}
@@ -130,6 +135,8 @@ void BookmarksWidget::addBookmark(const QString &title, const QString &url)
auto *bookmark = ui->treeWidget->createBookmark(nullptr);
bookmark->setText(0, title);
bookmark->setText(1, url);
+
+ m_isChanged = true;
}
void BookmarksWidget::search(const QString &term, std::function<void(QStringList &)> callback) const
diff --git a/lib/bookmarks/bookmarkswidget.h b/lib/bookmarks/bookmarkswidget.h
index b1934b3..496bde9 100644
--- a/lib/bookmarks/bookmarkswidget.h
+++ b/lib/bookmarks/bookmarkswidget.h
@@ -28,17 +28,17 @@ public:
explicit BookmarksWidget(const QString &path, QWidget *parent = nullptr);
~BookmarksWidget() override;
- void save();
-
signals:
void openUrl(const QUrl &url);
public slots:
+ void save();
void addBookmark(const QString &title, const QString &url);
void search(const QString &term, std::function<void(QStringList &)> callback) const;
private:
Ui::BookmarksDialog *ui;
+ bool m_isChanged = false;
QString m_bookmarksPath;
};