diff options
Diffstat (limited to 'src/addressbar')
-rw-r--r-- | src/addressbar/completer.cpp | 7 | ||||
-rw-r--r-- | src/addressbar/completer.h | 3 | ||||
-rw-r--r-- | src/addressbar/urllineedit.cpp | 11 | ||||
-rw-r--r-- | src/addressbar/urllineedit.h | 7 |
4 files changed, 12 insertions, 16 deletions
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; |