diff options
author | Lionel Chauvin <megabigbug@yahoo.fr> | 2009-08-22 17:43:17 +0200 |
---|---|---|
committer | Lionel Chauvin <megabigbug@yahoo.fr> | 2009-08-22 17:43:17 +0200 |
commit | 94186b36d9b3b74b87ed892e573c747a24f63b51 (patch) | |
tree | 3e9d2de8e2e72abffacbb88dd6b6c2a9cac46b86 /src/urlbar.cpp | |
parent | Rekonq 0.2.0 (diff) | |
download | rekonq-94186b36d9b3b74b87ed892e573c747a24f63b51.tar.xz |
Remove url stack
Diffstat (limited to 'src/urlbar.cpp')
-rw-r--r-- | src/urlbar.cpp | 61 |
1 files changed, 56 insertions, 5 deletions
diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 94f248e3..6ece4783 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -55,11 +55,16 @@ UrlBar::UrlBar(QWidget *parent) : KHistoryComboBox(true, parent) , m_lineEdit(new LineEdit) , m_progress(0) + , m_completion(0) + , m_completionModel(0) { setUrlDropsEnabled(true); setAutoDeleteCompletionObject(true); - setMinimumWidth(180); + //cosmetic + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + setMinimumWidth(180); + setTrapReturnKey(true); setupLineEdit(); @@ -72,7 +77,8 @@ UrlBar::UrlBar(QWidget *parent) // setup completion box completionBox()->setTabHandling(true); // Konqueror bug #167135 - + setCompletionObject(completion()); + // set dropdown list background QPalette p = view()->palette(); p.setColor(QPalette::Base, palette().color(QPalette::Base)); @@ -132,14 +138,17 @@ void UrlBar::setupLineEdit() void UrlBar::setUrl(const QUrl& url) { - if (url.isEmpty()) - return; - m_currentUrl = url; slotUpdateUrl(); } +void UrlBar::setProgress(int progress) +{ + m_progress = progress; + repaint(); +} + void UrlBar::slotUpdateUrl() { if (count()) @@ -279,3 +288,45 @@ bool UrlBar::isLoading() } return true; } + + + +KCompletion *UrlBar::completion() +{ + // make sure completion was created + if (!m_completion) + { + m_completion = new KCompletion(); + m_completion->setCompletionMode(KGlobalSettings::CompletionPopupAuto); + m_completion->setOrder(KCompletion::Weighted); + m_completion->setIgnoreCase(true); + + kDebug() << "Initialize completion list..."; + HistoryCompletionModel *model = completionModel(); + int count = model->rowCount(); + kDebug() << "...initialize history items" << count; + + // change order to insertion to avoid confusion of the addItem method + // in weighted it expects format string:number and it thinks http it the whole string + m_completion->setOrder(KCompletion::Insertion); + for (int i = 0; i < count; ++i) + { + QString item = model->data(model->index(i, 0)).toString(); + item.remove(QRegExp("^http://|/$")); + m_completion->addItem(item); + } + + m_completion->setOrder(KCompletion::Weighted); + } + return m_completion; +} + +HistoryCompletionModel *UrlBar::completionModel() +{ + if (!m_completionModel) + { + m_completionModel = new HistoryCompletionModel(this); + m_completionModel->setSourceModel(Application::historyManager()->historyFilterModel()); + } + return m_completionModel; +}
\ No newline at end of file |