aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/bookmarks/bookmarksmodel.cpp3
-rw-r--r--lib/bookmarks/bookmarkswidget.cpp13
-rw-r--r--lib/bookmarks/bookmarkswidget.h3
3 files changed, 17 insertions, 2 deletions
diff --git a/lib/bookmarks/bookmarksmodel.cpp b/lib/bookmarks/bookmarksmodel.cpp
index 69f6334..e67668f 100644
--- a/lib/bookmarks/bookmarksmodel.cpp
+++ b/lib/bookmarks/bookmarksmodel.cpp
@@ -220,6 +220,7 @@ bool BookmarksModel::setData(const QModelIndex &index, const QVariant &value, in
case BookmarkItem::Folder:
if(index.column() == 0) {
node->title = value.toString();
+ emit dataChanged(index, index);
return true;
}
return false;
@@ -227,9 +228,11 @@ bool BookmarksModel::setData(const QModelIndex &index, const QVariant &value, in
case BookmarkItem::Bookmark:
if(index.column() == 0) {
node->title = value.toString();
+ emit dataChanged(index, index);
return true;
} else if(index.column() == 1) {
node->href = value.toString();
+ emit dataChanged(index, index);
return true;
}
return false;
diff --git a/lib/bookmarks/bookmarkswidget.cpp b/lib/bookmarks/bookmarkswidget.cpp
index e510218..27f00c3 100644
--- a/lib/bookmarks/bookmarkswidget.cpp
+++ b/lib/bookmarks/bookmarkswidget.cpp
@@ -26,9 +26,10 @@ BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent)
ui->deleteItem_toolButton->setIcon(style()->standardPixmap(QStyle::SP_TrashIcon));
ui->deleteItem_toolButton->setShortcut(QKeySequence::Delete);
+ editEntry_shortcut = new QShortcut(QKeySequence("F2"), this);
+
m_model = new BookmarksModel(style(), this);
ui->treeView->setModel(m_model);
- //ui->treeView->setEditTriggers(QAbstractItemView::EditKeyPressed);
xbel = new Xbel(path);
BookmarkItem *rootNode = xbel->read();
@@ -37,7 +38,10 @@ BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent)
//qDebug("Reading bookmarks [%s] %s", qUtf8Printable(m_path), xbel->read(m_path) ? "ok" : "failed");
connect(ui->treeView, &QTreeView::activated, this, [this](const QModelIndex &index) {
- emit openUrl(m_model->data(index, BookmarksModel::OpenUrlRole).toUrl());
+ if(ui->treeView->isPersistentEditorOpen(index))
+ ui->treeView->closePersistentEditor(index);
+ else
+ emit openUrl(m_model->data(index, BookmarksModel::OpenUrlRole).toUrl());
});
connect(ui->addBookmark_toolButton, &QToolButton::clicked, this, [this]() {
@@ -48,6 +52,11 @@ BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent)
QModelIndex idx = ui->treeView->currentIndex();
m_model->insertItem(BookmarkItem::Folder, idx);
});
+
+ connect(editEntry_shortcut, &QShortcut::activated, this, [this]() {
+ QModelIndex idx = ui->treeView->currentIndex();
+ ui->treeView->openPersistentEditor(idx);
+ });
}
BookmarksWidget::~BookmarksWidget()
diff --git a/lib/bookmarks/bookmarkswidget.h b/lib/bookmarks/bookmarkswidget.h
index fa830fa..0a44414 100644
--- a/lib/bookmarks/bookmarkswidget.h
+++ b/lib/bookmarks/bookmarkswidget.h
@@ -11,6 +11,7 @@
#include "bookmarksmodel.h"
#include "xbel.h"
+#include <QShortcut>
#include <QWidget>
namespace Ui
@@ -41,6 +42,8 @@ private:
Ui::BookmarksDialog *ui;
BookmarksModel *m_model;
Xbel *xbel;
+
+ QShortcut *editEntry_shortcut;
};
#endif // BOOKMARKSDIALOG_H