aboutsummaryrefslogtreecommitdiff
path: root/lib/bookmarks
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bookmarks')
-rw-r--r--lib/bookmarks/bookmarkswidget.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/bookmarks/bookmarkswidget.cpp b/lib/bookmarks/bookmarkswidget.cpp
index 93287c4..09f8c22 100644
--- a/lib/bookmarks/bookmarkswidget.cpp
+++ b/lib/bookmarks/bookmarkswidget.cpp
@@ -35,19 +35,45 @@ BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent)
qDebug("Reading bookmarks [%s] %s", qUtf8Printable(path), m_model->read(xbel) ? "ok" : "failed");
m_model->expandItems(ui->treeView);
+ // open bookmark action
connect(ui->treeView, &QTreeView::activated, this, [this](const QModelIndex &index) {
emit openUrl(m_model->data(index, BookmarksModel::OpenUrlRole).toUrl());
});
+ // add bookmark action
connect(ui->addBookmark_toolButton, &QToolButton::clicked, this, [this]() {
QModelIndex idx = ui->treeView->currentIndex();
m_model->insertItem(BookmarkItem::Bookmark, idx);
});
+
+ // add folder action
connect(ui->addFolder_toolButton, &QToolButton::clicked, this, [this]() {
QModelIndex idx = ui->treeView->currentIndex();
m_model->insertItem(BookmarkItem::Folder, idx);
});
+ // set folder title action
+ connect(ui->folderTitle, &QLineEdit::returnPressed, this, [this]() {
+ QModelIndex idx = ui->treeView->currentIndex();
+ Q_ASSERT(m_model->type(idx) == BookmarkItem::Folder);
+ m_model->setData(idx, ui->folderTitle->text(), BookmarksModel::TitleRole);
+ });
+
+ // set bookmark title action
+ connect(ui->bookmarkTitle, &QLineEdit::returnPressed, this, [this]() {
+ QModelIndex idx = ui->treeView->currentIndex();
+ Q_ASSERT(m_model->type(idx) == BookmarkItem::Bookmark);
+ m_model->setData(idx, ui->bookmarkTitle->text(), BookmarksModel::TitleRole);
+ });
+
+ // set bookmark href action
+ connect(ui->bookmarkHref, &QLineEdit::returnPressed, this, [this]() {
+ QModelIndex idx = ui->treeView->currentIndex();
+ Q_ASSERT(m_model->type(idx) == BookmarkItem::Bookmark);
+ m_model->setData(idx, ui->bookmarkHref->text(), BookmarksModel::OpenUrlRole);
+ });
+
+ // set item action
connect(ui->treeView->selectionModel(), &QItemSelectionModel::currentChanged, this, [this](const QModelIndex &current, const QModelIndex &previous) {
// save the previous item
if(previous.isValid()) {