aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-01-20 21:10:51 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-01-20 21:10:51 +0100
commit31e071b59fab651794cd283b25cff052bb26aa32 (patch)
treea1ec4fc95851bc7cd74d3cd33b2b7cc811999a3f
parentSaner bookmark editing (diff)
downloadsmolbote-31e071b59fab651794cd283b25cff052bb26aa32.tar.xz
Pressing enter/return sets bookmark items
-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()) {