diff options
Diffstat (limited to 'src/urlbar')
-rw-r--r-- | src/urlbar/completionwidget.cpp | 3 | ||||
-rw-r--r-- | src/urlbar/listitem.cpp | 31 | ||||
-rw-r--r-- | src/urlbar/urlresolver.cpp | 24 | ||||
-rw-r--r-- | src/urlbar/urlresolver.h | 7 |
4 files changed, 43 insertions, 22 deletions
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp index f8bf6ee2..a42433b7 100644 --- a/src/urlbar/completionwidget.cpp +++ b/src/urlbar/completionwidget.cpp @@ -311,6 +311,9 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev) child = findChild<ListItem *>(QString::number(_currentIndex)); if(child && _currentIndex!=0) //the completionwidget is visible and the user had press down { + kDebug() << "USING LISTITEM URL: " << child->url(); + kDebug() << "USING LISTITEM TITLE: " << child->text(); + //we can use the url of the listitem emit chosenUrl(child->url(), Rekonq::CurrentTab); } diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp index 5fa46470..a0462e76 100644 --- a/src/urlbar/listitem.cpp +++ b/src/urlbar/listitem.cpp @@ -58,6 +58,7 @@ #include <QFile> #include <QTextDocument> + ListItem::ListItem(const UrlSearchItem &item, QWidget *parent) : QWidget(parent) , m_option() @@ -81,7 +82,6 @@ ListItem::~ListItem() } - void ListItem::activate() { m_option.state |= QStyle::State_Selected; @@ -166,11 +166,16 @@ TypeIconLabel::TypeIconLabel(int type, QWidget *parent) hLayout->setAlignment(Qt::AlignRight); setLayout(hLayout); - if (type & UrlSearchItem::Search) hLayout->addWidget(getIcon("edit-find")); - if (type & UrlSearchItem::Browse) hLayout->addWidget(getIcon("applications-internet")); - if (type & UrlSearchItem::Bookmark) hLayout->addWidget(getIcon("rating")); - if (type & UrlSearchItem::History) hLayout->addWidget(getIcon("view-history")); - if (type & UrlSearchItem::Suggestion) hLayout->addWidget(getIcon("help-hint")); + if (type & UrlSearchItem::Search) + hLayout->addWidget(getIcon("edit-find")); + if (type & UrlSearchItem::Browse) + hLayout->addWidget(getIcon("applications-internet")); + if (type & UrlSearchItem::Bookmark) + hLayout->addWidget(getIcon("rating")); + if (type & UrlSearchItem::History) + hLayout->addWidget(getIcon("view-history")); + if (type & UrlSearchItem::Suggestion) + hLayout->addWidget(getIcon("help-hint")); } @@ -204,8 +209,10 @@ IconLabel::IconLabel(const KIcon &icon, QWidget *parent) setPixmap(pixmapIcon); } + // --------------------------------------------------------------- + static QString highlightWordsInText(const QString &text, const QStringList &words) { QString ret = text; @@ -241,6 +248,7 @@ static QString highlightWordsInText(const QString &text, const QStringList &word return ret; } + TextLabel::TextLabel(const QString &text, const QString &textToPointOut, QWidget *parent) : QLabel(parent) { @@ -274,6 +282,7 @@ void TextLabel::setEngineText(const QString &engine, const QString &text) setText( i18nc("%1=search engine, e.g. Google, Wikipedia %2=text to search for", "Search %1 for <b>%2</b>", engine, Qt::escape(text) ) ); } + // --------------------------------------------------------------- @@ -350,6 +359,7 @@ PreviewLabel::PreviewLabel(const QString &url, int width, int height, QWidget *p } } + // --------------------------------------------------------------- @@ -382,6 +392,7 @@ void ImageLabel::slotResult(KJob *) setPixmap(pix); } + // --------------------------------------------------------------- @@ -416,12 +427,6 @@ QString SearchListItem::text() } -// QString SearchListItem::searchItemTitle(QString engine, QString text) -// { -// return QString(i18nc("%1=search engine, e.g. Google, Wikipedia %2=text to search for", "Search %1 for %2", engine, text)); -// } - - void SearchListItem::changeSearchEngine(KService::Ptr engine) { m_titleLabel->setEngineText(engine->name(), m_text); @@ -575,6 +580,7 @@ QString VisualSuggestionListItem::text() return m_text; } + // --------------------------------------------------------------- @@ -627,6 +633,7 @@ ListItem *ListItemFactory::create(const UrlSearchItem &item, const QString &text if (item.type & UrlSearchItem::Suggestion) { + kDebug() << "ITEM URL: " << item.url; if (item.description.isEmpty()) { kDebug() << "Suggestion"; diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index c3efb903..c95557cf 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -70,7 +70,8 @@ UrlResolver::UrlResolver(const QString &typedUrl) : QObject() , _typedString(typedUrl.trimmed()) { - if (!_searchEngine ) setSearchEngine(SearchEngine::defaultEngine()); + if (!_searchEngine ) + setSearchEngine(SearchEngine::defaultEngine()); if ( _browseRegexp.isEmpty() ) { @@ -196,8 +197,8 @@ UrlSearchList UrlResolver::orderLists() UrlSearchList common; int commonCount = 0; - //prefer items which are history items als well bookmarks item - //if there are more than 1000 bookmark results, the performance impact is noticeable + // prefer items which are history items as well bookmarks item + // if there are more than 1000 bookmark results, the performance impact is noticeable if(bookmarksCount < 1000) { //add as many items to the common list as there are available entries in the dropdown list @@ -316,7 +317,7 @@ UrlSearchList UrlResolver::orderLists() // PRIVATE ENGINES -//QUrl from User Input (easily the best solution... ) +// QUrl from User Input (easily the best solution... ) void UrlResolver::computeQurlFromUserInput() { QString url = _typedString; @@ -330,7 +331,7 @@ void UrlResolver::computeQurlFromUserInput() } -//webSearches +// webSearches void UrlResolver::computeWebSearches() { QString query = _typedString; @@ -341,11 +342,17 @@ void UrlResolver::computeWebSearches() _searchEngine = engine; } - _webSearches = (UrlSearchList() << UrlSearchItem(UrlSearchItem::Search, SearchEngine::buildQuery(_searchEngine, query), _searchEngine->name())); + if(_searchEngine) + { + UrlSearchItem item = UrlSearchItem(UrlSearchItem::Search, SearchEngine::buildQuery(_searchEngine, query), _searchEngine->name()); + UrlSearchList list; + list << item; + _webSearches = list; + } } -//history +// history void UrlResolver::computeHistory() { QList<HistoryItem> found = Application::historyManager()->find(_typedString); @@ -375,7 +382,7 @@ void UrlResolver::computeBookmarks() } -//opensearch suggestion +// opensearch suggestion void UrlResolver::computeSuggestions() { // if a string startsWith /, it is probably a local path @@ -405,6 +412,7 @@ void UrlResolver::suggestionsReceived(const QString &text, const ResponseList &s Q_FOREACH(const Response &i, suggestions) { + kDebug() << "RESPONSE URL: " << i.url; UrlSearchItem gItem(UrlSearchItem::Suggestion, i.url, i.title, i.description, i.image, i.image_width, i.image_height); sugList << gItem; } diff --git a/src/urlbar/urlresolver.h b/src/urlbar/urlresolver.h index 3e8e4fce..e21e65e8 100644 --- a/src/urlbar/urlresolver.h +++ b/src/urlbar/urlresolver.h @@ -30,6 +30,8 @@ // Rekonq Includes #include "rekonq_defines.h" + +// Locale Includes #include "application.h" #include "opensearchmanager.h" @@ -87,7 +89,7 @@ public: UrlSearchItem(const int &_type, const QString &_url, const QString &_title = QString(), - const QString &_description = QString(), + const QString &_description = QString(), const QString &_image = QString(), const int &_image_width = 0, const int &_image_height = 0 @@ -130,7 +132,8 @@ public: static void setSearchEngine(KService::Ptr engine) { _searchEngine = engine; - Application::opensearchManager()->setSearchProvider(engine->desktopEntryName()); + if(engine) + Application::opensearchManager()->setSearchProvider(engine->desktopEntryName()); }; void computeSuggestions(); |