diff options
Diffstat (limited to 'src/urlbar')
-rw-r--r-- | src/urlbar/completionwidget.cpp | 172 | ||||
-rw-r--r-- | src/urlbar/completionwidget.h | 20 | ||||
-rw-r--r-- | src/urlbar/listitem.cpp | 170 | ||||
-rw-r--r-- | src/urlbar/listitem.h | 40 | ||||
-rw-r--r-- | src/urlbar/rsswidget.cpp | 52 | ||||
-rw-r--r-- | src/urlbar/rsswidget.h | 12 | ||||
-rw-r--r-- | src/urlbar/urlbar.cpp | 130 | ||||
-rw-r--r-- | src/urlbar/urlbar.h | 12 | ||||
-rw-r--r-- | src/urlbar/urlresolver.cpp | 84 | ||||
-rw-r--r-- | src/urlbar/urlresolver.h | 16 |
10 files changed, 357 insertions, 351 deletions
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp index e0027a92..84e8141a 100644 --- a/src/urlbar/completionwidget.cpp +++ b/src/urlbar/completionwidget.cpp @@ -10,9 +10,9 @@ * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy +* by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. -* +* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -51,10 +51,10 @@ CompletionWidget::CompletionWidget(QWidget *parent) - : QFrame(parent, Qt::ToolTip) - , _parent(parent) - , _currentIndex(-1) - , _searchEngine( SearchEngine::defaultEngine() ) + : QFrame(parent, Qt::ToolTip) + , _parent(parent) + , _currentIndex(-1) + , _searchEngine(SearchEngine::defaultEngine()) { setFrameStyle(QFrame::Panel); setLayoutDirection(Qt::LeftToRight); @@ -72,22 +72,22 @@ void CompletionWidget::insertSearchList(const UrlSearchList &list, const QString foreach(UrlSearchItem item, _list) { ListItem *suggestion = ListItemFactory::create(item, text, this); - suggestion->setBackgroundRole(i%2 ? QPalette::AlternateBase : QPalette::Base); + suggestion->setBackgroundRole(i % 2 ? QPalette::AlternateBase : QPalette::Base); connect(suggestion, SIGNAL(itemClicked(ListItem *, Qt::MouseButton)), this, SLOT(itemChosen(ListItem *, Qt::MouseButton))); connect(this, SIGNAL(nextItemSubChoice()), suggestion, SLOT(nextItemSubChoice())); - suggestion->setObjectName( QString::number(i++) ); - layout()->addWidget( suggestion ); + suggestion->setObjectName(QString::number(i++)); + layout()->addWidget(suggestion); } } void CompletionWidget::sizeAndPosition() { - setFixedWidth( _parent->width() ); + setFixedWidth(_parent->width()); adjustSize(); - + // position - QPoint p = _parent->mapToGlobal( QPoint(0,0) ); + QPoint p = _parent->mapToGlobal(QPoint(0, 0)); move(p.x(), p.y() + _parent->height()); } @@ -104,19 +104,19 @@ void CompletionWidget::popup() void CompletionWidget::up() { // deactivate previous - if(_currentIndex != -1) + if (_currentIndex != -1) { - ListItem *widget = findChild<ListItem *>( QString::number(_currentIndex) ); + ListItem *widget = findChild<ListItem *>(QString::number(_currentIndex)); widget->deactivate(); } - if(_currentIndex > 0) + if (_currentIndex > 0) _currentIndex--; else - _currentIndex=layout()->count()-1; + _currentIndex = layout()->count() - 1; // activate "new" current - ListItem *widget = findChild<ListItem *>( QString::number(_currentIndex) ); + ListItem *widget = findChild<ListItem *>(QString::number(_currentIndex)); widget->activate(); } @@ -124,19 +124,19 @@ void CompletionWidget::up() void CompletionWidget::down() { // deactivate previous - if(_currentIndex != -1) + if (_currentIndex != -1) { - ListItem *widget = findChild<ListItem *>( QString::number(_currentIndex) ); + ListItem *widget = findChild<ListItem *>(QString::number(_currentIndex)); widget->deactivate(); } - - if(_currentIndex < _list.count() -1) + + if (_currentIndex < _list.count() - 1) _currentIndex++; else - _currentIndex=0; - + _currentIndex = 0; + // activate "new" current - ListItem *widget = findChild<ListItem *>( QString::number(_currentIndex) ); + ListItem *widget = findChild<ListItem *>(QString::number(_currentIndex)); widget->activate(); } @@ -144,32 +144,32 @@ void CompletionWidget::down() void CompletionWidget::clear() { QLayoutItem *child; - while ((child = layout()->takeAt(0)) != 0) + while ((child = layout()->takeAt(0)) != 0) { - delete child->widget(); + delete child->widget(); delete child; } _currentIndex = -1; } -bool CompletionWidget::eventFilter( QObject *o, QEvent *e ) +bool CompletionWidget::eventFilter(QObject *o, QEvent *e) { int type = e->type(); QWidget *wid = qobject_cast<QWidget*>(o); - - if (o == this) + + if (o == this) { return false; } //hide conditions of the CompletionWidget - if (wid - && ((wid == _parent && (type == QEvent::Move || type == QEvent::Resize)) - || ((wid->windowFlags() & Qt::Window) - && (type == QEvent::Move || type == QEvent::Hide || type == QEvent::WindowDeactivate) - && wid == _parent->window()) - || (type == QEvent::MouseButtonPress && !isAncestorOf(wid))) + if (wid + && ((wid == _parent && (type == QEvent::Move || type == QEvent::Resize)) + || ((wid->windowFlags() & Qt::Window) + && (type == QEvent::Move || type == QEvent::Hide || type == QEvent::WindowDeactivate) + && wid == _parent->window()) + || (type == QEvent::MouseButtonPress && !isAncestorOf(wid))) ) { hide(); @@ -177,63 +177,63 @@ bool CompletionWidget::eventFilter( QObject *o, QEvent *e ) } //actions on the CompletionWidget - if (wid && wid->isAncestorOf(_parent) && isVisible()) + if (wid && wid->isAncestorOf(_parent) && isVisible()) { ListItem *child; - - if ( type == QEvent::KeyPress ) + + if (type == QEvent::KeyPress) { - QKeyEvent *ev = static_cast<QKeyEvent *>( e ); - switch ( ev->key() ) + QKeyEvent *ev = static_cast<QKeyEvent *>(e); + switch (ev->key()) { - case Qt::Key_Up: - case Qt::Key_Backtab: - if (ev->modifiers() == Qt::NoButton || (ev->modifiers() & Qt::ShiftModifier)) - { - up(); - ev->accept(); - return true; - } - break; - - case Qt::Key_Down: - case Qt::Key_Tab: - if (ev->modifiers() == Qt::NoButton) - { - down(); - ev->accept(); - return true; - } - if (ev->modifiers() & Qt::ControlModifier) - { - emit nextItemSubChoice(); - ev->accept(); - return true; - } - break; - - case Qt::Key_Enter: - case Qt::Key_Return: - child = findChild<ListItem *>( QString::number(_currentIndex) ); - emit chosenUrl( child->url(), Rekonq::CurrentTab); + case Qt::Key_Up: + case Qt::Key_Backtab: + if (ev->modifiers() == Qt::NoButton || (ev->modifiers() & Qt::ShiftModifier)) + { + up(); ev->accept(); - hide(); return true; - - case Qt::Key_Escape: - hide(); + } + break; + + case Qt::Key_Down: + case Qt::Key_Tab: + if (ev->modifiers() == Qt::NoButton) + { + down(); + ev->accept(); + return true; + } + if (ev->modifiers() & Qt::ControlModifier) + { + emit nextItemSubChoice(); + ev->accept(); return true; + } + break; + + case Qt::Key_Enter: + case Qt::Key_Return: + child = findChild<ListItem *>(QString::number(_currentIndex)); + emit chosenUrl(child->url(), Rekonq::CurrentTab); + ev->accept(); + hide(); + return true; + + case Qt::Key_Escape: + hide(); + return true; } } } - - return QFrame::eventFilter(o,e); + + return QFrame::eventFilter(o, e); } -void CompletionWidget::setVisible( bool visible ) +void CompletionWidget::setVisible(bool visible) { - if (visible) + if (visible) { Application::instance()->installEventFilter(this); } @@ -241,7 +241,7 @@ void CompletionWidget::setVisible( bool visible ) { Application::instance()->removeEventFilter(this); } - + QFrame::setVisible(visible); } @@ -249,21 +249,21 @@ void CompletionWidget::setVisible( bool visible ) void CompletionWidget::itemChosen(ListItem *item, Qt::MouseButton button) { - if(button == Qt::MidButton) - emit chosenUrl( item->url(), Rekonq::NewCurrentTab); + if (button == Qt::MidButton) + emit chosenUrl(item->url(), Rekonq::NewCurrentTab); else - emit chosenUrl( item->url(), Rekonq::CurrentTab); + emit chosenUrl(item->url(), Rekonq::CurrentTab); hide(); } void CompletionWidget::suggestUrls(const QString &text) -{ +{ QWidget *w = qobject_cast<QWidget *>(parent()); - if(!w->hasFocus()) + if (!w->hasFocus()) return; - if(text.isEmpty()) + if (text.isEmpty()) { hide(); return; @@ -271,7 +271,7 @@ void CompletionWidget::suggestUrls(const QString &text) UrlResolver res(text); UrlSearchList list = res.orderedSearchItems(); - if(list.count() > 0) + if (list.count() > 0) { clear(); insertSearchList(list, text); diff --git a/src/urlbar/completionwidget.h b/src/urlbar/completionwidget.h index afd9b7e1..bb840c40 100644 --- a/src/urlbar/completionwidget.h +++ b/src/urlbar/completionwidget.h @@ -10,9 +10,9 @@ * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy +* by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. -* +* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -49,10 +49,16 @@ public: virtual bool eventFilter(QObject *obj, QEvent *ev); void setVisible(bool visible); - - KService::Ptr searchEngine() { return _searchEngine; }; - void setCurrentEngine(KService::Ptr engine) { _searchEngine = engine; }; - + + KService::Ptr searchEngine() + { + return _searchEngine; + }; + void setCurrentEngine(KService::Ptr engine) + { + _searchEngine = engine; + }; + private slots: void itemChosen(ListItem *item, Qt::MouseButton = Qt::LeftButton); void suggestUrls(const QString &text); @@ -60,7 +66,7 @@ private slots: signals: void chosenUrl(const KUrl &, Rekonq::OpenType); void nextItemSubChoice(); - + private: void insertSearchList(const UrlSearchList &list, const QString& text); void popup(); diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp index d69bdd03..d6d9e044 100644 --- a/src/urlbar/listitem.cpp +++ b/src/urlbar/listitem.cpp @@ -10,9 +10,9 @@ * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy +* by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. -* +* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -25,8 +25,8 @@ // Self Includes -#include "listitem.h" -#include "listitem.moc" +#include "listitem.h" +#include "listitem.moc" // Auto Includes #include "rekonq.h" @@ -60,9 +60,9 @@ ListItem::ListItem(const UrlSearchItem &item, QWidget *parent) - : QWidget(parent) - , m_option() - , m_url(item.url) + : QWidget(parent) + , m_option() + , m_url(item.url) { setAutoFillBackground(true); @@ -71,11 +71,11 @@ ListItem::ListItem(const UrlSearchItem &item, QWidget *parent) QPalette p(palette()); p.setColor(QPalette::Base, Qt::white); // TODO: choose the correct color - - p.setColor(QPalette::AlternateBase, QColor(247,247,247)); // TODO: choose the correct color + + p.setColor(QPalette::AlternateBase, QColor(247, 247, 247)); // TODO: choose the correct color setPalette(p); - deactivate(); + deactivate(); } @@ -103,14 +103,14 @@ void ListItem::deactivate() void ListItem::paintEvent(QPaintEvent *event) { Q_UNUSED(event); - - if( m_option.state.testFlag(QStyle::State_Selected) || m_option.state.testFlag(QStyle::State_MouseOver)) + + if (m_option.state.testFlag(QStyle::State_Selected) || m_option.state.testFlag(QStyle::State_MouseOver)) { QPainter painter(this); - m_option.rect=QRect(QPoint(),size()); + m_option.rect = QRect(QPoint(), size()); style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &m_option, &painter, this); } - + QWidget::paintEvent(event); } @@ -154,16 +154,16 @@ void ListItem::nextItemSubChoice() TypeIconLabel::TypeIconLabel(int type, QWidget *parent) - : QLabel(parent) + : QLabel(parent) { setMinimumWidth(40); QHBoxLayout *hLayout = new QHBoxLayout; hLayout->setMargin(0); 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::Browse) hLayout->addWidget(getIcon("applications-internet")); if (type & UrlSearchItem::Bookmark) hLayout->addWidget(getIcon("rating")); if (type & UrlSearchItem::History) hLayout->addWidget(getIcon("view-history")); } @@ -172,7 +172,7 @@ TypeIconLabel::TypeIconLabel(int type, QWidget *parent) QLabel *TypeIconLabel::getIcon(QString icon) { QLabel *iconLabel = new QLabel(this); - iconLabel->setFixedSize(16,16); + iconLabel->setFixedSize(16, 16); QPixmap pixmap = KIcon(icon).pixmap(16); iconLabel->setPixmap(pixmap); return iconLabel; @@ -183,10 +183,10 @@ QLabel *TypeIconLabel::getIcon(QString icon) IconLabel::IconLabel(const QString &icon, QWidget *parent) - : QLabel(parent) + : QLabel(parent) { - QPixmap pixmapIcon = Application::icon( KUrl(icon) ).pixmap(16); - setFixedSize(16,16); + QPixmap pixmapIcon = Application::icon(KUrl(icon)).pixmap(16); + setFixedSize(16, 16); setPixmap(pixmapIcon); } @@ -195,7 +195,7 @@ IconLabel::IconLabel(const QString &icon, QWidget *parent) TextLabel::TextLabel(const QString &text, const QString &textToPointOut, QWidget *parent) - : QLabel(parent) + : QLabel(parent) { QString t = text; if (!textToPointOut.isEmpty()) @@ -210,26 +210,26 @@ TextLabel::TextLabel(const QString &text, const QString &textToPointOut, QWidget PreviewListItem::PreviewListItem(const UrlSearchItem &item, const QString &text, QWidget *parent) - : ListItem(item, parent) + : ListItem(item, parent) { QHBoxLayout *hLayout = new QHBoxLayout; hLayout->setSpacing(4); QLabel *previewLabelIcon = new QLabel(this); - previewLabelIcon->setFixedSize(45,33); + previewLabelIcon->setFixedSize(45, 33); new PreviewLabel(item.url.url(), 38, 29, previewLabelIcon); IconLabel* icon = new IconLabel(item.url.url(), previewLabelIcon); icon->move(27, 16); hLayout->addWidget(previewLabelIcon); - - QVBoxLayout *vLayout = new QVBoxLayout; + + QVBoxLayout *vLayout = new QVBoxLayout; vLayout->setMargin(0); - vLayout->addWidget( new TextLabel(item.title, text, this) ); - vLayout->addWidget( new TextLabel("<i>" + item.url.url() + "</i>", text, this) ); + vLayout->addWidget(new TextLabel(item.title, text, this)); + vLayout->addWidget(new TextLabel("<i>" + item.url.url() + "</i>", text, this)); hLayout->addLayout(vLayout); - - hLayout->addWidget( new TypeIconLabel(item.type, this) ); + + hLayout->addWidget(new TypeIconLabel(item.type, this)); setLayout(hLayout); } @@ -239,16 +239,16 @@ PreviewListItem::PreviewListItem(const UrlSearchItem &item, const QString &text, PreviewLabel::PreviewLabel(const QString &url, int width, int height, QWidget *parent) - : QLabel(parent) + : QLabel(parent) { setFixedSize(width, height); setFrameStyle(QFrame::StyledPanel | QFrame::Raised); KUrl u = KUrl(url); - if( WebSnap::existsImage( KUrl(u) ) ) - { + if (WebSnap::existsImage(KUrl(u))) + { QPixmap preview; - preview.load( WebSnap::imagePathFromUrl(u) ); + preview.load(WebSnap::imagePathFromUrl(u)); setPixmap(preview.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); } } @@ -258,39 +258,39 @@ PreviewLabel::PreviewLabel(const QString &url, int width, int height, QWidget *p SearchListItem::SearchListItem(const UrlSearchItem &item, const QString &text, QWidget *parent) - : ListItem(item, parent) - , m_text(text) + : ListItem(item, parent) + , m_text(text) { KService::Ptr currentEngine = SearchEngine::defaultEngine(); - + QString query = text; KService::Ptr engine = SearchEngine::fromString(text); if (engine) { - query = query.remove(0, text.indexOf(SearchEngine::delimiter())+1); + query = query.remove(0, text.indexOf(SearchEngine::delimiter()) + 1); } else { engine = currentEngine; } - + m_url = SearchEngine::buildQuery(engine, query); m_iconLabel = new IconLabel("edit-find", this); //TODO: get the default engine icon - m_titleLabel = new TextLabel( searchItemTitle(engine->name(), query), QString(), this); + m_titleLabel = new TextLabel(searchItemTitle(engine->name(), query), QString(), this); m_engineBar = new EngineBar(currentEngine, parent); QHBoxLayout *hLayout = new QHBoxLayout; hLayout->setSpacing(4); - hLayout->addWidget( m_iconLabel ); - hLayout->addWidget( m_titleLabel ); - hLayout->addWidget( new QLabel( i18n("Engines: "), this ) ); - hLayout->addWidget( m_engineBar ); - hLayout->addWidget( new TypeIconLabel(item.type, this) ); + hLayout->addWidget(m_iconLabel); + hLayout->addWidget(m_titleLabel); + hLayout->addWidget(new QLabel(i18n("Engines: "), this)); + hLayout->addWidget(m_engineBar); + hLayout->addWidget(new TypeIconLabel(item.type, this)); setLayout(hLayout); - + connect(m_engineBar, SIGNAL(searchEngineChanged(KService::Ptr)), this, SLOT(changeSearchEngine(KService::Ptr))); } @@ -302,12 +302,12 @@ QString SearchListItem::searchItemTitle(QString engine, QString text) void SearchListItem::changeSearchEngine(KService::Ptr engine) { - m_titleLabel->setText(searchItemTitle(engine->name(),m_text)); - m_iconLabel->setPixmap(Application::icon( KUrl(engine->property("Query").toString()) ).pixmap(16)); + m_titleLabel->setText(searchItemTitle(engine->name(), m_text)); + m_iconLabel->setPixmap(Application::icon(KUrl(engine->property("Query").toString())).pixmap(16)); m_url = SearchEngine::buildQuery(engine, m_text); CompletionWidget *w = qobject_cast<CompletionWidget *>(parent()); - w->setCurrentEngine( engine ); + w->setCurrentEngine(engine); } @@ -321,23 +321,23 @@ void SearchListItem::nextItemSubChoice() EngineBar::EngineBar(KService::Ptr selectedEngine, QWidget *parent) -: KToolBar(parent) -{ - setIconSize(QSize(16,16)); + : KToolBar(parent) +{ + setIconSize(QSize(16, 16)); setToolButtonStyle(Qt::ToolButtonIconOnly); - + m_engineGroup = new QActionGroup(this); m_engineGroup->setExclusive(true); - m_engineGroup->addAction(newEngineAction(SearchEngine::defaultEngine(), selectedEngine)); + m_engineGroup->addAction(newEngineAction(SearchEngine::defaultEngine(), selectedEngine)); foreach(KService::Ptr engine, SearchEngine::favorites()) { - if(engine->desktopEntryName()!=SearchEngine::defaultEngine()->desktopEntryName()) + if (engine->desktopEntryName() != SearchEngine::defaultEngine()->desktopEntryName()) { m_engineGroup->addAction(newEngineAction(engine, selectedEngine)); } } - + addActions(m_engineGroup->actions()); } @@ -347,7 +347,7 @@ KAction *EngineBar::newEngineAction(KService::Ptr engine, KService::Ptr selected QString url = engine->property("Query").toString(); KAction *a = new KAction(Application::icon(url), engine->name(), this); a->setCheckable(true); - if (engine->desktopEntryName()==selectedEngine->desktopEntryName()) a->setChecked(true); + if (engine->desktopEntryName() == selectedEngine->desktopEntryName()) a->setChecked(true); a->setData(engine->entryPath()); connect(a, SIGNAL(triggered(bool)), this, SLOT(changeSearchEngine())); return a; @@ -363,23 +363,23 @@ void EngineBar::changeSearchEngine() void EngineBar::selectNextEngine() { - QList<QAction *> e = m_engineGroup->actions(); - int i = 0; - while(i<e.count() && !e.at(i)->isChecked()) - { - i++; - } - - if (i+1 == e.count()) - { - e.at(0)->setChecked(true); - e.at(0)->trigger(); - } - else - { - e.at(i+1)->setChecked(true); - e.at(i+1)->trigger(); - } + QList<QAction *> e = m_engineGroup->actions(); + int i = 0; + while (i < e.count() && !e.at(i)->isChecked()) + { + i++; + } + + if (i + 1 == e.count()) + { + e.at(0)->setChecked(true); + e.at(0)->trigger(); + } + else + { + e.at(i + 1)->setChecked(true); + e.at(i + 1)->trigger(); + } } @@ -387,18 +387,18 @@ void EngineBar::selectNextEngine() BrowseListItem::BrowseListItem(const UrlSearchItem &item, const QString &text, QWidget *parent) - : ListItem(item, parent) + : ListItem(item, parent) { QString url = text; - + kDebug() << text; - + QHBoxLayout *hLayout = new QHBoxLayout; hLayout->setSpacing(4); - - hLayout->addWidget( new IconLabel(item.url.url(), this) ); - hLayout->addWidget( new TextLabel(item.url.url(), text, this) ); - hLayout->addWidget( new TypeIconLabel(item.type, this) ); + + hLayout->addWidget(new IconLabel(item.url.url(), this)); + hLayout->addWidget(new TextLabel(item.url.url(), text, this)); + hLayout->addWidget(new TypeIconLabel(item.type, this)); setLayout(hLayout); } @@ -410,14 +410,14 @@ BrowseListItem::BrowseListItem(const UrlSearchItem &item, const QString &text, Q ListItem *ListItemFactory::create(const UrlSearchItem &item, const QString &text, QWidget *parent) { ListItem *newItem; - - if(item.type & UrlSearchItem::Browse) + + if (item.type & UrlSearchItem::Browse) { newItem = new BrowseListItem(item, text, parent); } else { - if(item.type & UrlSearchItem::Search) + if (item.type & UrlSearchItem::Search) { newItem = new SearchListItem(item, text, parent); } @@ -426,6 +426,6 @@ ListItem *ListItemFactory::create(const UrlSearchItem &item, const QString &text newItem = new PreviewListItem(item, text, parent); } } - + return newItem; } diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h index c15ef3f9..7dc1af39 100644 --- a/src/urlbar/listitem.h +++ b/src/urlbar/listitem.h @@ -10,9 +10,9 @@ * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy +* by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. -* +* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -58,7 +58,7 @@ public: void deactivate(); KUrl url(); - + public slots: virtual void nextItemSubChoice(); @@ -66,14 +66,14 @@ signals: void itemClicked(ListItem *item, Qt::MouseButton); protected: - virtual void paintEvent(QPaintEvent *event); - virtual void enterEvent(QEvent *); - virtual void leaveEvent(QEvent *); - virtual void mousePressEvent(QMouseEvent *e); + virtual void paintEvent(QPaintEvent *event); + virtual void enterEvent(QEvent *); + virtual void leaveEvent(QEvent *); + virtual void mousePressEvent(QMouseEvent *e); private: - QStyleOptionViewItemV4 m_option; - + QStyleOptionViewItemV4 m_option; + protected: KUrl m_url; }; @@ -85,7 +85,7 @@ protected: class TypeIconLabel : public QLabel { Q_OBJECT - + public: TypeIconLabel(int type, QWidget *parent = 0); @@ -112,7 +112,7 @@ public: class TextLabel : public QLabel { Q_OBJECT - + public: TextLabel(const QString &text, const QString &textToPointOut = QString(), QWidget *parent = 0); }; @@ -124,11 +124,11 @@ public: class EngineBar : public KToolBar { Q_OBJECT - + public: EngineBar(KService::Ptr selectedEngine, QWidget *parent = 0); void selectNextEngine(); - + signals: void searchEngineChanged(KService::Ptr engine); @@ -147,16 +147,16 @@ private: class SearchListItem : public ListItem { Q_OBJECT - + public: SearchListItem(const UrlSearchItem &item, const QString &text, QWidget *parent = 0); - + public slots: virtual void nextItemSubChoice(); - + private slots: void changeSearchEngine(KService::Ptr engine); - + private: QString searchItemTitle(QString engine, QString text); @@ -174,7 +174,7 @@ private: class PreviewListItem : public ListItem { Q_OBJECT - + public: PreviewListItem(const UrlSearchItem &item, const QString &text, QWidget *parent = 0); }; @@ -186,7 +186,7 @@ public: class PreviewLabel : public QLabel { Q_OBJECT - + public: PreviewLabel(const QString &url, int width, int height, QWidget *parent = 0); }; @@ -198,7 +198,7 @@ public: class BrowseListItem : public ListItem { Q_OBJECT - + public: BrowseListItem(const UrlSearchItem &item, const QString &text, QWidget *parent = 0); }; diff --git a/src/urlbar/rsswidget.cpp b/src/urlbar/rsswidget.cpp index 62275a84..5914b8c1 100644 --- a/src/urlbar/rsswidget.cpp +++ b/src/urlbar/rsswidget.cpp @@ -42,43 +42,43 @@ #include <KMessageBox> -RSSWidget::RSSWidget(QMap< KUrl, QString > map, QWidget *parent) +RSSWidget::RSSWidget(QMap< KUrl, QString > map, QWidget *parent) : QFrame(parent, Qt::Popup) , m_map(map) { setAttribute(Qt::WA_DeleteOnClose); setFixedWidth(250); setFrameStyle(Panel); - + QFormLayout *layout = new QFormLayout(this); setLayout(layout); - - + + QLabel *agregator = new QLabel(this); agregator->setText(i18n("Aggregator:")); - + m_agregators = new KComboBox(this); m_agregators->addItem(KIcon("application-rss+xml"), QString("Akregator")); m_agregators->addItem(Application::icon(KUrl("http://google.com/reader")), i18n("Google Reader")); - + layout->addRow(agregator, m_agregators); - - + + QLabel *feed = new QLabel(this); feed->setText(i18n("Feed:")); - + m_feeds = new KComboBox(this); foreach(QString title, m_map) - m_feeds->addItem(title); - + m_feeds->addItem(title); + layout->addRow(feed, m_feeds); - - + + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); buttonBox->button(QDialogButtonBox::Ok)->setText(i18n("Add Feed")); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accepted())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); - + layout->addWidget(buttonBox); } @@ -95,12 +95,12 @@ void RSSWidget::showAt(QPoint pos) void RSSWidget::accepted() { QString url = m_map.key(m_feeds->currentText()).toMimeDataString(); - - if(m_agregators->currentIndex() == 0) + + if (m_agregators->currentIndex() == 0) addWithAkregator(url); else addWithGoogleReader(url); - + close(); } @@ -115,15 +115,15 @@ void RSSWidget::addWithGoogleReader(QString url) void RSSWidget::addWithAkregator(QString url) { // Akregator is running - if(QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.akregator")) + if (QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.akregator")) { QDBusInterface akregator("org.kde.akregator", "/Akregator", "org.kde.akregator.part"); QDBusReply<void> reply = akregator.call("addFeedsToGroup", QStringList(url) , i18n("Imported Feeds")); - - if(!reply.isValid()) + + if (!reply.isValid()) { - KMessageBox::error( 0, QString(i18n("Could not add stream to akregator, Please add it manually :") - + "<br /><br /> <a href=\"" + url + "\">" + url + "</a>")); + KMessageBox::error(0, QString(i18n("Could not add stream to akregator, Please add it manually :") + + "<br /><br /> <a href=\"" + url + "\">" + url + "</a>")); } } // Akregator is not running @@ -132,12 +132,12 @@ void RSSWidget::addWithAkregator(QString url) KProcess proc; proc << "akregator" << "-g" << i18n("Imported Feeds"); proc << "-a" << url; - if(proc.startDetached() == 0) + if (proc.startDetached() == 0) { - KMessageBox::error( 0, QString(i18n("There was an error. Please verify Akregator is installed on your system.") - + "<br /><br /> <a href=\"" + url + "\">" + url + "</a>")); + KMessageBox::error(0, QString(i18n("There was an error. Please verify Akregator is installed on your system.") + + "<br /><br /> <a href=\"" + url + "\">" + url + "</a>")); } - + } } diff --git a/src/urlbar/rsswidget.h b/src/urlbar/rsswidget.h index 5c1ca736..253c20f2 100644 --- a/src/urlbar/rsswidget.h +++ b/src/urlbar/rsswidget.h @@ -31,22 +31,22 @@ class RSSWidget : public QFrame { Q_OBJECT - + public: // QMap< feedUrl, feedTitle> RSSWidget(QMap<KUrl, QString> map, QWidget *parent); - + void showAt(QPoint pos); - + public slots: void accepted(); - + private: void addWithAkregator(QString url); void addWithGoogleReader(QString url); - + QMap<KUrl, QString> m_map; - + KComboBox *m_agregators; KComboBox *m_feeds; }; diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index 90112600..34cbb9aa 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -13,9 +13,9 @@ * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy +* by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. -* +* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -56,7 +56,7 @@ IconButton::IconButton(QWidget *parent) - : QToolButton(parent) + : QToolButton(parent) { setToolButtonStyle(Qt::ToolButtonIconOnly); setStyleSheet("IconButton { background-color:transparent; border: none; padding: 0px}"); @@ -72,13 +72,13 @@ void IconButton::mouseReleaseEvent(QMouseEvent* event) UrlBar::UrlBar(QWidget *parent) - : KLineEdit(parent) - , _tab(0) - , _privateMode(false) - , _icon( new IconButton(this) ) + : KLineEdit(parent) + , _tab(0) + , _privateMode(false) + , _icon(new IconButton(this)) { // initial style - setStyleSheet( QString("UrlBar { padding: 0 0 0 %1px;} ").arg(_icon->sizeHint().width()) ); + setStyleSheet(QString("UrlBar { padding: 0 0 0 %1px;} ").arg(_icon->sizeHint().width())); // cosmetic setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); @@ -87,25 +87,25 @@ UrlBar::UrlBar(QWidget *parent) // doesn't show the clear button setClearButtonShown(false); - + // trap Key_Enter & Key_Return events, while emitting the returnPressed signal setTrapReturnKey(true); - + // insert decoded URLs setUrlDropsEnabled(true); // accept focus, via tabbing, clicking & wheeling setFocusPolicy(Qt::WheelFocus); - + // disable completion object (we have our own :) ) setCompletionObject(0); - + _tab = qobject_cast<WebTab *>(parent); - + connect(_tab->view(), SIGNAL(urlChanged(const QUrl &)), this, SLOT(setQUrl(const QUrl &))); connect(_tab->view(), SIGNAL(loadFinished(bool)), this, SLOT(loadFinished())); connect(_tab->view(), SIGNAL(loadStarted()), this, SLOT(clearRightIcons())); - + // load typed urls connect(this, SIGNAL(returnPressed(const QString &)), this, SLOT(loadTyped(const QString &))); @@ -123,9 +123,9 @@ UrlBar::~UrlBar() void UrlBar::setQUrl(const QUrl& url) { - if(url.scheme() == QL1S("about") ) + if (url.scheme() == QL1S("about")) { - _icon->setIcon( KIcon("arrow-right") ); + _icon->setIcon(KIcon("arrow-right")); clear(); setFocus(); } @@ -134,7 +134,7 @@ void UrlBar::setQUrl(const QUrl& url) clearFocus(); KLineEdit::setUrl(url); setCursorPosition(0); - _icon->setIcon( Application::icon(url) ); + _icon->setIcon(Application::icon(url)); } } @@ -142,7 +142,7 @@ void UrlBar::setQUrl(const QUrl& url) void UrlBar::activated(const KUrl& url, Rekonq::OpenType type) { activateSuggestions(false); - + clearFocus(); setUrl(url); Application::instance()->loadUrl(url, type); @@ -152,7 +152,7 @@ void UrlBar::activated(const KUrl& url, Rekonq::OpenType type) void UrlBar::paintEvent(QPaintEvent *event) { QColor backgroundColor; - if( _privateMode ) + if (_privateMode) { backgroundColor = QColor(220, 220, 220); // light gray } @@ -160,43 +160,43 @@ void UrlBar::paintEvent(QPaintEvent *event) { backgroundColor = Application::palette().color(QPalette::Base); } - + // set background color of UrlBar QPalette p = palette(); int progr = _tab->progress(); - if (progr == 0) + if (progr == 0) { - if( _tab->url().scheme() == QL1S("https") ) + if (_tab->url().scheme() == QL1S("https")) { backgroundColor = QColor(255, 255, 171); // light yellow } p.setBrush(QPalette::Base, backgroundColor); - } - else + } + else { QColor loadingColor = QColor(116, 192, 250); - + QLinearGradient gradient(0, 0, width(), 0); gradient.setColorAt(0, loadingColor); - gradient.setColorAt(((double)progr)/100, backgroundColor); + gradient.setColorAt(((double)progr) / 100, backgroundColor); p.setBrush(QPalette::Base, gradient); } setPalette(p); - + // you need this before our code to draw inside the line edit.. KLineEdit::paintEvent(event); - - if (text().isEmpty()) - { + + if (text().isEmpty()) + { QStyleOptionFrame option; initStyleOption(&option); QRect textRect = style()->subElementRect(QStyle::SE_LineEditContents, &option, this); QPainter painter(this); painter.setPen(Qt::gray); - painter.drawText( textRect, - Qt::AlignCenter, - i18n("Start typing here to search your bookmarks, history and the web...") + painter.drawText(textRect, + Qt::AlignCenter, + i18n("Start typing here to search your bookmarks, history and the web...") ); } } @@ -207,7 +207,7 @@ void UrlBar::keyPressEvent(QKeyEvent *event) // this handles the Modifiers + Return key combinations QString currentText = text().trimmed(); if ((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) - && !currentText.startsWith(QLatin1String("http://"), Qt::CaseInsensitive)) + && !currentText.startsWith(QLatin1String("http://"), Qt::CaseInsensitive)) { QString append; if (event->modifiers() == Qt::ControlModifier) @@ -232,7 +232,7 @@ void UrlBar::keyPressEvent(QKeyEvent *event) setText(url.toString()); } } - + if (event->key() == Qt::Key_Escape) { clearFocus(); @@ -246,7 +246,7 @@ void UrlBar::keyPressEvent(QKeyEvent *event) void UrlBar::focusInEvent(QFocusEvent *event) { activateSuggestions(true); - + KLineEdit::focusInEvent(event); } @@ -266,36 +266,36 @@ void UrlBar::dropEvent(QDropEvent *event) void UrlBar::loadFinished() { - if(_tab->progress() != 0) + if (_tab->progress() != 0) return; - - if(_tab->url().scheme() == QL1S("about") ) + + if (_tab->url().scheme() == QL1S("about")) { update(); return; } - + // show KGet downloads?? - if(ReKonfig::kgetList()) + if (ReKonfig::kgetList()) { IconButton *bt = addRightIcon(UrlBar::KGet); connect(bt, SIGNAL(clicked(QPoint)), _tab->page(), SLOT(downloadAllContentsWithKGet())); } - + // show RSS - if(_tab->hasRSSInfo()) + if (_tab->hasRSSInfo()) { IconButton *bt = addRightIcon(UrlBar::RSS); connect(bt, SIGNAL(clicked(QPoint)), _tab, SLOT(showRSSInfo(QPoint))); } - + // show SSL - if(_tab->url().scheme() == QL1S("https") ) + if (_tab->url().scheme() == QL1S("https")) { IconButton *bt = addRightIcon(UrlBar::SSL); connect(bt, SIGNAL(clicked(QPoint)), _tab->page(), SLOT(showSSLInfo())); } - + update(); } @@ -308,9 +308,9 @@ void UrlBar::loadTyped(const QString &text) void UrlBar::activateSuggestions(bool b) { - if(b) + if (b) { - if(_box.isNull()) + if (_box.isNull()) { _box = new CompletionWidget(this); installEventFilter(_box.data()); @@ -337,31 +337,31 @@ void UrlBar::mouseDoubleClickEvent(QMouseEvent *) IconButton *UrlBar::addRightIcon(UrlBar::icon ic) { IconButton *rightIcon = new IconButton(this); - - switch(ic) + + switch (ic) { case UrlBar::KGet: - rightIcon->setIcon( KIcon("download") ); - rightIcon->setToolTip( i18n("List all links with KGet") ); + rightIcon->setIcon(KIcon("download")); + rightIcon->setToolTip(i18n("List all links with KGet")); break; case UrlBar::RSS: - rightIcon->setIcon( KIcon("application-rss+xml") ); - rightIcon->setToolTip( i18n("List all available RSS feeds") ); + rightIcon->setIcon(KIcon("application-rss+xml")); + rightIcon->setToolTip(i18n("List all available RSS feeds")); break; case UrlBar::SSL: - rightIcon->setIcon( KIcon("object-locked") ); - rightIcon->setToolTip( i18n("Show SSL Infos") ); + rightIcon->setIcon(KIcon("object-locked")); + rightIcon->setToolTip(i18n("Show SSL Infos")); break; default: kDebug() << "ERROR.. default non extant case!!"; break; } - + _rightIconsList << rightIcon; int iconsCount = _rightIconsList.count(); - rightIcon->move( width() - 23*iconsCount, 6); + rightIcon->move(width() - 23*iconsCount, 6); rightIcon->show(); - + return rightIcon; } @@ -375,16 +375,16 @@ void UrlBar::clearRightIcons() void UrlBar::resizeEvent(QResizeEvent *event) { - int newHeight = ( height() - 19 )/2; - _icon->move(4, newHeight ); - + int newHeight = (height() - 19) / 2; + _icon->move(4, newHeight); + int iconsCount = _rightIconsList.count(); int w = width(); - - for(int i = 0; i < iconsCount; ++i) + + for (int i = 0; i < iconsCount; ++i) { IconButton *bt = _rightIconsList.at(i); - bt->move( w - 25*(i+1), newHeight ); + bt->move(w - 25*(i + 1), newHeight); } KLineEdit::resizeEvent(event); diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h index 91b38e23..2c1e7f23 100644 --- a/src/urlbar/urlbar.h +++ b/src/urlbar/urlbar.h @@ -13,9 +13,9 @@ * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy +* by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. -* +* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -76,11 +76,11 @@ class REKONQ_TESTS_EXPORT UrlBar : public KLineEdit public: enum icon - { + { KGet = 0x00000001, RSS = 0x00000010, SSL = 0x00000100, - }; + }; explicit UrlBar(QWidget *parent = 0); ~UrlBar(); @@ -105,9 +105,9 @@ protected: void resizeEvent(QResizeEvent *); private: - IconButton *addRightIcon(UrlBar::icon ); + IconButton *addRightIcon(UrlBar::icon); void activateSuggestions(bool); - + QWeakPointer<CompletionWidget> _box; WebTab *_tab; bool _privateMode; diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index b53b6b42..d3683282 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -10,9 +10,9 @@ * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy +* by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. -* +* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -58,13 +58,13 @@ bool UrlSearchItem::operator==(UrlSearchItem i) -{ - return url==i.url; +{ + return url == i.url; } UrlResolver::UrlResolver(const QString &typedUrl) - : _typedString(typedUrl.trimmed()) + : _typedString(typedUrl.trimmed()) { } @@ -72,61 +72,61 @@ UrlResolver::UrlResolver(const QString &typedUrl) UrlSearchList UrlResolver::orderedSearchItems() { // NOTE: the logic here is : "we wanna suggest (at least) 9 elements" - // so we have (more or less) 3 from first results (1 from QUrl Resolutions, 2 from + // so we have (more or less) 3 from first results (1 from QUrl Resolutions, 2 from // default search engines). // There are 6 remaining: if bookmarkResults + historyResults <= 6, catch all, else // catch first 3 results from the two resulting lists :) - + UrlSearchList list; - + // if(isHttp()) // { // list << qurlFromUserInputResolution(); // } - list << qurlFromUserInputResolution(); + list << qurlFromUserInputResolution(); list << webSearchesResolution(); if (_typedString.length() >= 2) - { + { int firstResults = list.count(); int checkPoint = 9 - firstResults; - + UrlSearchList historyList = historyResolution(); int historyResults = historyList.count(); UrlSearchList bookmarksList = bookmarksResolution(); int bookmarkResults = bookmarksList.count(); - if(historyResults + bookmarkResults > checkPoint) + if (historyResults + bookmarkResults > checkPoint) { - historyList = historyList.mid(0,3); - bookmarksList = bookmarksList.mid(0,3); + historyList = historyList.mid(0, 3); + bookmarksList = bookmarksList.mid(0, 3); } - + QList<UrlSearchItem> common; - - foreach (UrlSearchItem i, historyList) + + foreach(UrlSearchItem i, historyList) { if (!bookmarksList.contains(i)) { list << i; } - else + else { i.type |= UrlSearchItem::Bookmark; common << i; } } - - foreach (UrlSearchItem i, common) + + foreach(UrlSearchItem i, common) { - list << i; + list << i; } - - foreach (UrlSearchItem i, bookmarksList) + + foreach(UrlSearchItem i, bookmarksList) { - if (!common.contains(i)) + if (!common.contains(i)) list << i; } } @@ -138,23 +138,23 @@ UrlSearchList UrlResolver::orderedSearchItems() bool UrlResolver::isHttp() { QString ipv4 = "^0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])"\ - "\\.0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])"; - + "\\.0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])"; + QString ipv6 = "^([0-9a-fA-F]{4}|0)(\\:([0-9a-fA-F]{4}|0)){7}"; - + QString address = "[\\d\\w-.]+\\.(a[cdefgilmnoqrstuwz]|b[abdefghijmnorstvwyz]|"\ - "c[acdfghiklmnoruvxyz]|d[ejkmnoz]|e[ceghrst]|f[ijkmnor]|g[abdefghilmnpqrstuwy]|"\ - "h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|"\ - "m[acdghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eouw]|"\ - "s[abcdeghijklmnortuvyz]|t[cdfghjkmnoprtvwz]|u[augkmsyz]|v[aceginu]|w[fs]|"\ - "y[etu]|z[amw]|aero|arpa|biz|com|coop|edu|info|int|gov|mil|museum|name|net|org|"\ - "pro)"; - - return _typedString.startsWith("http://") - || _typedString.startsWith("https://") - || (QRegExp(address, Qt::CaseInsensitive).indexIn(_typedString) != -1) - || (QRegExp(ipv4, Qt::CaseInsensitive).indexIn(_typedString) != -1) - || (QRegExp(ipv6, Qt::CaseInsensitive).indexIn(_typedString) != -1); + "c[acdfghiklmnoruvxyz]|d[ejkmnoz]|e[ceghrst]|f[ijkmnor]|g[abdefghilmnpqrstuwy]|"\ + "h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|"\ + "m[acdghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eouw]|"\ + "s[abcdeghijklmnortuvyz]|t[cdfghjkmnoprtvwz]|u[augkmsyz]|v[aceginu]|w[fs]|"\ + "y[etu]|z[amw]|aero|arpa|biz|com|coop|edu|info|int|gov|mil|museum|name|net|org|"\ + "pro)"; + + return _typedString.startsWith("http://") + || _typedString.startsWith("https://") + || (QRegExp(address, Qt::CaseInsensitive).indexIn(_typedString) != -1) + || (QRegExp(ipv4, Qt::CaseInsensitive).indexIn(_typedString) != -1) + || (QRegExp(ipv6, Qt::CaseInsensitive).indexIn(_typedString) != -1); } @@ -168,7 +168,7 @@ UrlSearchList UrlResolver::qurlFromUserInputResolution() UrlSearchList list; QString url2 = _typedString; QUrl urlFromUserInput = QUrl::fromUserInput(url2); - if(urlFromUserInput.isValid()) + if (urlFromUserInput.isValid()) { QString gTitle = i18nc("Browse a website", "Browse"); UrlSearchItem gItem(UrlSearchItem::Browse, urlFromUserInput, gTitle); @@ -190,7 +190,7 @@ UrlSearchList UrlResolver::webSearchesResolution() UrlSearchList UrlResolver::historyResolution() { UrlSearchList list; - + KCompletion *historyCompletion = Application::historyManager()->completionObject(); QStringList historyResults = historyCompletion->substringCompletion(_typedString); Q_FOREACH(const QString &s, historyResults) @@ -207,7 +207,7 @@ UrlSearchList UrlResolver::historyResolution() UrlSearchList UrlResolver::bookmarksResolution() { UrlSearchList list; - + KCompletion *bookmarkCompletion = Application::bookmarkProvider()->completionObject(); QStringList bookmarkResults = bookmarkCompletion->substringCompletion(_typedString); Q_FOREACH(const QString &s, bookmarkResults) diff --git a/src/urlbar/urlresolver.h b/src/urlbar/urlresolver.h index 5200a401..482f8809 100644 --- a/src/urlbar/urlresolver.h +++ b/src/urlbar/urlresolver.h @@ -10,9 +10,9 @@ * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy +* by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. -* +* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -38,21 +38,21 @@ class UrlSearchItem { public: - - enum types - { + + enum types + { Search = 0x00000001, Browse = 0x00000010, History = 0x00000100, Bookmark = 0x00001000, - }; + }; int type; KUrl url; QString title; UrlSearchItem(const int &_type, const KUrl &_url, const QString &_title = QString()) - : type(_type), url(_url), title(_title) + : type(_type), url(_url), title(_title) {}; bool operator==(UrlSearchItem i); @@ -68,7 +68,7 @@ class UrlResolver { public: UrlResolver(const QString &typedUrl); - + UrlSearchList orderedSearchItems(); private: |