aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/bookmarks/bookmarkswidget.cpp5
-rw-r--r--lib/bookmarks/bookmarkswidget.h2
-rw-r--r--src/addressbar/completer.cpp7
-rw-r--r--src/addressbar/completer.h3
-rw-r--r--src/addressbar/urllineedit.cpp11
-rw-r--r--src/addressbar/urllineedit.h7
-rw-r--r--src/mainwindow/mainwindow.cpp2
7 files changed, 20 insertions, 17 deletions
diff --git a/lib/bookmarks/bookmarkswidget.cpp b/lib/bookmarks/bookmarkswidget.cpp
index 6ddd71c..2c89dd4 100644
--- a/lib/bookmarks/bookmarkswidget.cpp
+++ b/lib/bookmarks/bookmarkswidget.cpp
@@ -105,6 +105,11 @@ BookmarksWidget::~BookmarksWidget()
delete ui;
}
+BookmarksView *BookmarksWidget::model() const
+{
+ return ui->treeWidget;
+}
+
void BookmarksWidget::save()
{
/*
diff --git a/lib/bookmarks/bookmarkswidget.h b/lib/bookmarks/bookmarkswidget.h
index 129a5bc..f2188d2 100644
--- a/lib/bookmarks/bookmarkswidget.h
+++ b/lib/bookmarks/bookmarkswidget.h
@@ -18,6 +18,7 @@ namespace Ui
class BookmarksDialog;
}
+class BookmarksView;
class BookmarksWidget : public QWidget
{
Q_OBJECT
@@ -25,6 +26,7 @@ class BookmarksWidget : public QWidget
public:
explicit BookmarksWidget(const QString &path, QWidget *parent = 0);
~BookmarksWidget() override;
+ BookmarksView *model() const;
void save();
diff --git a/src/addressbar/completer.cpp b/src/addressbar/completer.cpp
index 4c95bce..5d64dd7 100644
--- a/src/addressbar/completer.cpp
+++ b/src/addressbar/completer.cpp
@@ -15,15 +15,16 @@ Completer::Completer(QWidget *parent)
setWindowFlags(Qt::ToolTip);
}
-bool Completer::updateItems(const QModelIndexList &list)
+bool Completer::updateItems(const QList<QTreeWidgetItem *> &list)
{
if(list.isEmpty())
return false;
// list is not empty
QStringList l;
- for(const QModelIndex &idx : list) {
- l.append(idx.data(Qt::EditRole).toString());
+ for(QTreeWidgetItem *item : list) {
+ if(!item->text(1).isEmpty())
+ l.append(item->text(1));
}
auto *model = new QStringListModel(l, this);
diff --git a/src/addressbar/completer.h b/src/addressbar/completer.h
index adf5d8e..ce19f07 100644
--- a/src/addressbar/completer.h
+++ b/src/addressbar/completer.h
@@ -11,6 +11,7 @@
#include <QListView>
#include <QStringListModel>
+#include <QTreeWidgetItem>
class Completer : public QListView
{
@@ -20,7 +21,7 @@ class Completer : public QListView
public:
explicit Completer(QWidget *parent = nullptr);
- bool updateItems(const QModelIndexList &list);
+ bool updateItems(const QList<QTreeWidgetItem*> &list);
bool keyPressed(QKeyEvent *event);
diff --git a/src/addressbar/urllineedit.cpp b/src/addressbar/urllineedit.cpp
index 5b8e6c6..21effb4 100644
--- a/src/addressbar/urllineedit.cpp
+++ b/src/addressbar/urllineedit.cpp
@@ -11,6 +11,7 @@
#include <QMenu>
#include <QTimer>
#include <QWidgetAction>
+#include <lib/bookmarks/bookmarksview.h>
UrlLineEdit::UrlLineEdit(QWidget *parent)
: QLineEdit(parent)
@@ -61,7 +62,7 @@ UrlLineEdit::UrlLineEdit(QWidget *parent)
});
}
-void UrlLineEdit::setCompleterModel(QAbstractItemModel *model)
+void UrlLineEdit::setCompleterModel(BookmarksView *model)
{
Q_CHECK_PTR(model);
m_bookmarksModel = model;
@@ -93,19 +94,13 @@ void UrlLineEdit::setUrl(const QUrl &url)
setText(urlText);
}
-void UrlLineEdit::showSslError(const QString &message)
-{
- m_sslLabel->setText(message);
- m_sslAction->trigger();
-}
-
void UrlLineEdit::updateCompleter(const QString &text)
{
if(m_bookmarksModel == nullptr) {
return;
}
- const QModelIndexList res = m_bookmarksModel->match(QModelIndex(), Qt::EditRole, text, 7);
+ const QList<QTreeWidgetItem*> res = m_bookmarksModel->findItems(text, Qt::MatchContains | Qt::MatchRecursive, 1);
if(!m_listView->updateItems(res)) {
m_listView->hide();
diff --git a/src/addressbar/urllineedit.h b/src/addressbar/urllineedit.h
index 4e62128..4c5ce82 100644
--- a/src/addressbar/urllineedit.h
+++ b/src/addressbar/urllineedit.h
@@ -15,7 +15,7 @@
#include <src/webengine/webview.h>
#include "completer.h"
-class QAbstractItemModel;
+class BookmarksView;
class QMenu;
class QLabel;
class UrlLineEdit : public QLineEdit
@@ -24,7 +24,7 @@ class UrlLineEdit : public QLineEdit
public:
explicit UrlLineEdit(QWidget *parent = nullptr);
- void setCompleterModel(QAbstractItemModel *model);
+ void setCompleterModel(BookmarksView *model);
signals:
void addressEntered(const QUrl &url);
@@ -33,7 +33,6 @@ signals:
public slots:
void connectWebView(WebView *view);
void setUrl(const QUrl &url);
- void showSslError(const QString &message);
void updateCompleter(const QString &text);
@@ -56,7 +55,7 @@ private:
QLabel *m_sslLabel;
// completer
- QAbstractItemModel *m_bookmarksModel = nullptr;
+ BookmarksView *m_bookmarksModel = nullptr;
Completer *m_listView;
QMetaObject::Connection urlChangedConnection;
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index 00c716f..5ee0a78 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -217,7 +217,7 @@ void MainWindow::setBookmarksWidget(std::shared_ptr<BookmarksWidget> &widget)
{
Q_ASSERT(widget);
m_bookmarksWidget = widget;
- //m_addressBar->setCompleterModel(m_bookmarksWidget->model());
+ m_addressBar->setCompleterModel(m_bookmarksWidget->model());
connect(menuBar->bookmarksAction(), &QAction::triggered, this, [this]() {
addTabbedDock(Qt::RightDockWidgetArea, m_bookmarksWidget.get());
});