diff options
Diffstat (limited to 'src/urlbar')
-rw-r--r-- | src/urlbar/bookmarkwidget.cpp | 2 | ||||
-rw-r--r-- | src/urlbar/completionwidget.cpp | 26 | ||||
-rw-r--r-- | src/urlbar/completionwidget.h | 2 | ||||
-rw-r--r-- | src/urlbar/listitem.cpp | 49 | ||||
-rw-r--r-- | src/urlbar/rsswidget.cpp | 2 | ||||
-rw-r--r-- | src/urlbar/stackedurlbar.h | 2 | ||||
-rw-r--r-- | src/urlbar/urlbar.cpp | 42 | ||||
-rw-r--r-- | src/urlbar/urlbar.h | 2 | ||||
-rw-r--r-- | src/urlbar/urlresolver.cpp | 80 | ||||
-rw-r--r-- | src/urlbar/urlresolver.h | 46 | ||||
-rw-r--r-- | src/urlbar/webshortcutwidget.cpp | 18 | ||||
-rw-r--r-- | src/urlbar/webshortcutwidget.h | 4 |
12 files changed, 141 insertions, 134 deletions
diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp index 357ee05a..a7b3ded0 100644 --- a/src/urlbar/bookmarkwidget.cpp +++ b/src/urlbar/bookmarkwidget.cpp @@ -112,7 +112,7 @@ void BookmarkWidget::showAt(const QPoint &pos) { adjustSize(); - QPoint p(pos.x()-width(), pos.y()+10); + QPoint p(pos.x() - width(), pos.y() + 10); move(p); show(); } diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp index c090524c..465f5cf5 100644 --- a/src/urlbar/completionwidget.cpp +++ b/src/urlbar/completionwidget.cpp @@ -90,7 +90,7 @@ void CompletionWidget::updateSearchList(const UrlSearchList &list, const QString static int counter = 0; counter++; kDebug() << counter; - if(_hasSuggestions || _typedString != text) + if (_hasSuggestions || _typedString != text) return; _hasSuggestions = true; @@ -101,7 +101,7 @@ void CompletionWidget::updateSearchList(const UrlSearchList &list, const QString insertItems(_resList, text); _list = _resList; - UrlSearchList sugList = list.mid(0,4); + UrlSearchList sugList = list.mid(0, 4); insertItems(sugList, text, _list.count()); _list.append(sugList); popup(); @@ -119,7 +119,7 @@ void CompletionWidget::sizeAndPosition() QWidget *widget = layout()->itemAt(i)->widget(); h += widget->sizeHint().height(); } - setFixedSize(_parent->width(),h+5); + setFixedSize(_parent->width(), h + 5); // position QPoint p = _parent->mapToGlobal(QPoint(0, 0)); @@ -205,10 +205,10 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev) // 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))) + && ((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(); @@ -255,9 +255,9 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev) case Qt::Key_Enter: case Qt::Key_Return: w = qobject_cast<UrlBar *>(parent()); - if(kev->modifiers() == Qt::AltModifier) + if (kev->modifiers() == Qt::AltModifier) { - if(kev->key() == Qt::Key_Return || kev->key() == Qt::Key_Enter) + if (kev->key() == Qt::Key_Return || kev->key() == Qt::Key_Enter) { emit chosenUrl(w->text(), Rekonq::NewFocusedTab); } @@ -294,10 +294,10 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev) } - if( _currentIndex == -1) + if (_currentIndex == -1) _currentIndex = 0; child = findChild<ListItem *>(QString::number(_currentIndex)); - if(child && _currentIndex!=0) //the completionwidget is visible and the user had press down + 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(); @@ -343,8 +343,8 @@ void CompletionWidget::setVisible(bool visible) void CompletionWidget::itemChosen(ListItem *item, Qt::MouseButton button, Qt::KeyboardModifiers modifier) { - if (button == Qt::MidButton - || modifier == Qt::ControlModifier) + if (button == Qt::MidButton + || modifier == Qt::ControlModifier) { emit chosenUrl(item->url(), Rekonq::NewFocusedTab); } diff --git a/src/urlbar/completionwidget.h b/src/urlbar/completionwidget.h index 33414e3e..cd3e9549 100644 --- a/src/urlbar/completionwidget.h +++ b/src/urlbar/completionwidget.h @@ -83,7 +83,7 @@ private: QString _typedString; bool _hasSuggestions; - + UrlSearchList _resList; }; diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp index b41f02d8..e1c13ce7 100644 --- a/src/urlbar/listitem.cpp +++ b/src/urlbar/listitem.cpp @@ -166,15 +166,15 @@ TypeIconLabel::TypeIconLabel(int type, QWidget *parent) hLayout->setAlignment(Qt::AlignRight); setLayout(hLayout); - if (type & UrlSearchItem::Search) + if (type & UrlSearchItem::Search) hLayout->addWidget(getIcon("edit-find")); - if (type & UrlSearchItem::Browse) + if (type & UrlSearchItem::Browse) hLayout->addWidget(getIcon("applications-internet")); - if (type & UrlSearchItem::Bookmark) + if (type & UrlSearchItem::Bookmark) hLayout->addWidget(getIcon("rating")); - if (type & UrlSearchItem::History) + if (type & UrlSearchItem::History) hLayout->addWidget(getIcon("view-history")); - if (type & UrlSearchItem::Suggestion) + if (type & UrlSearchItem::Suggestion) hLayout->addWidget(getIcon("help-hint")); } @@ -202,7 +202,7 @@ IconLabel::IconLabel(const QString &icon, QWidget *parent) IconLabel::IconLabel(const KIcon &icon, QWidget *parent) - : QLabel(parent) + : QLabel(parent) { QPixmap pixmapIcon = icon.pixmap(16); setFixedSize(16, 16); @@ -217,15 +217,18 @@ static QString highlightWordsInText(const QString &text, const QStringList &word { QString ret = text; QBitArray boldSections(ret.size()); - foreach (const QString &wordToPointOut, words) { + foreach(const QString &wordToPointOut, words) + { int index = ret.indexOf(wordToPointOut, 0, Qt::CaseInsensitive); - while(index > -1) { + while (index > -1) + { boldSections.fill(true, index, index + wordToPointOut.size()); index = ret.indexOf(wordToPointOut, index + wordToPointOut.size(), Qt::CaseInsensitive); } } int numSections = 0; - for (int i = 0; i < boldSections.size() - 1; ++i){ + for (int i = 0; i < boldSections.size() - 1; ++i) + { if (boldSections.testBit(i) && !boldSections.testBit(i + 1)) ++numSections; } @@ -234,11 +237,15 @@ static QString highlightWordsInText(const QString &text, const QStringList &word const int tagLength = 7; // length of "<b>" and "</b>" we're going to add for each bold section. ret.reserve(ret.size() + numSections * tagLength); bool bold = false; - for (int i = boldSections.size() - 1; i >= 0; --i){ - if (!bold && boldSections.testBit(i)){ + for (int i = boldSections.size() - 1; i >= 0; --i) + { + if (!bold && boldSections.testBit(i)) + { ret.insert(i + 1, QL1S("</b>")); bold = true; - } else if (bold && !boldSections.testBit(i)){ + } + else if (bold && !boldSections.testBit(i)) + { ret.insert(i + 1, QL1S("<b>")); bold = false; } @@ -269,7 +276,7 @@ TextLabel::TextLabel(const QString &text, const QString &textToPointOut, QWidget TextLabel::TextLabel(QWidget *parent) - : QLabel(parent) + : QLabel(parent) { setTextFormat(Qt::RichText); setMouseTracking(false); @@ -279,7 +286,7 @@ TextLabel::TextLabel(QWidget *parent) 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) ) ); + setText(i18nc("%1=search engine, e.g. Google, Wikipedia %2=text to search for", "Search %1 for <b>%2</b>", engine, Qt::escape(text))); } @@ -478,7 +485,7 @@ EngineBar::EngineBar(KService::Ptr selectedEngine, QWidget *parent) KAction *EngineBar::newEngineAction(KService::Ptr engine, KService::Ptr selectedEngine) { QUrl u = engine->property("Query").toUrl(); - KUrl url = KUrl( u.toString( QUrl::RemovePath | QUrl::RemoveQuery ) ); + KUrl url = KUrl(u.toString(QUrl::RemovePath | QUrl::RemoveQuery)); kDebug() << "Engine NAME: " << engine->name() << " URL: " << url; KAction *a = new KAction(rApp->iconManager()->iconForUrl(url), engine->name(), this); @@ -554,13 +561,13 @@ VisualSuggestionListItem::VisualSuggestionListItem(const UrlSearchItem &item, co QHBoxLayout *hLayout = new QHBoxLayout; hLayout->setSpacing(4); QLabel *previewLabelIcon = new QLabel(this); - + if (!item.image.isEmpty()) { - previewLabelIcon->setFixedSize(item.image_width+10, item.image_height+10); + previewLabelIcon->setFixedSize(item.image_width + 10, item.image_height + 10); new ImageLabel(item.image, item.image_width, item.image_height, previewLabelIcon); IconLabel* icon = new IconLabel(item.url, previewLabelIcon); - icon->move(item.image_width - 10, item.image_height -10); + icon->move(item.image_width - 10, item.image_height - 10); } else { @@ -571,15 +578,15 @@ VisualSuggestionListItem::VisualSuggestionListItem(const UrlSearchItem &item, co hLayout->addWidget(previewLabelIcon); QVBoxLayout *vLayout = new QVBoxLayout; vLayout->setMargin(0); - vLayout->addItem(new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::MinimumExpanding)); + vLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::MinimumExpanding)); vLayout->addWidget(new TextLabel(item.title, text, this)); DescriptionLabel *d = new DescriptionLabel("", this); vLayout->addWidget(d); - vLayout->addItem(new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::MinimumExpanding)); + vLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::MinimumExpanding)); hLayout->addLayout(vLayout); hLayout->addWidget(new TypeIconLabel(item.type, this)); setLayout(hLayout); - d->setText("<i>"+item.description+"</i>"); + d->setText("<i>" + item.description + "</i>"); } diff --git a/src/urlbar/rsswidget.cpp b/src/urlbar/rsswidget.cpp index a896ac7b..aba03a4c 100644 --- a/src/urlbar/rsswidget.cpp +++ b/src/urlbar/rsswidget.cpp @@ -116,7 +116,7 @@ void RSSWidget::showAt(const QPoint &pos) { adjustSize(); - QPoint p(pos.x()-width(), pos.y()+10); + QPoint p(pos.x() - width(), pos.y() + 10); move(p); show(); } diff --git a/src/urlbar/stackedurlbar.h b/src/urlbar/stackedurlbar.h index ae263a24..5009d49a 100644 --- a/src/urlbar/stackedurlbar.h +++ b/src/urlbar/stackedurlbar.h @@ -48,7 +48,7 @@ public: UrlBar *currentUrlBar(); UrlBar *urlBar(int index); - + private slots: void moveBar(int, int); }; diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index d0014677..f82468b8 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -187,21 +187,21 @@ void UrlBar::paintEvent(QPaintEvent *event) { QColor highlight = rApp->palette().color(QPalette::Highlight); - int r = (highlight.red()+2*backgroundColor.red())/3; - int g = (highlight.green()+2*backgroundColor.green())/3; - int b = (highlight.blue()+2*backgroundColor.blue())/3; + int r = (highlight.red() + 2 * backgroundColor.red()) / 3; + int g = (highlight.green() + 2 * backgroundColor.green()) / 3; + int b = (highlight.blue() + 2 * backgroundColor.blue()) / 3; QColor loadingColor(r, g, b); if (abs(loadingColor.lightness() - backgroundColor.lightness()) < 20) //eg. Gaia color scheme { - r = (2*highlight.red()+backgroundColor.red())/3; - g = (2*highlight.green()+backgroundColor.green())/3; - b = (2*highlight.blue()+backgroundColor.blue())/3; + r = (2 * highlight.red() + backgroundColor.red()) / 3; + g = (2 * highlight.green() + backgroundColor.green()) / 3; + b = (2 * highlight.blue() + backgroundColor.blue()) / 3; loadingColor = QColor(r, g, b); } - QLinearGradient gradient( QPoint(0, 0), QPoint(width(), 0) ); + QLinearGradient gradient(QPoint(0, 0), QPoint(width(), 0)); gradient.setColorAt(0, loadingColor); gradient.setColorAt(((double)progr) / 100 - .000001, loadingColor); gradient.setColorAt(((double)progr) / 100, backgroundColor); @@ -212,7 +212,7 @@ void UrlBar::paintEvent(QPaintEvent *event) // you need this before our code to draw inside the line edit.. KLineEdit::paintEvent(event); - if( text().isEmpty() && progr == 0 ) + if (text().isEmpty() && progr == 0) { QStyleOptionFrame option; initStyleOption(&option); @@ -231,9 +231,9 @@ void UrlBar::keyPressEvent(QKeyEvent *event) { // this handles the Modifiers + Return key combinations QString currentText = text().trimmed(); - if(event->modifiers() == Qt::AltModifier) + if (event->modifiers() == Qt::AltModifier) { - if(event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) + if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) { activated(currentText, Rekonq::NewFocusedTab); } @@ -272,7 +272,7 @@ void UrlBar::keyPressEvent(QKeyEvent *event) } else if ((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) - && !currentText.isEmpty()) + && !currentText.isEmpty()) { loadTyped(currentText); } @@ -353,7 +353,7 @@ void UrlBar::loadFinished() void UrlBar::showBookmarkInfo(const QPoint &pos) { - if( _tab->url().scheme() == QL1S("about") ) + if (_tab->url().scheme() == QL1S("about")) return; KBookmark bookmark = rApp->bookmarkProvider()->bookmarkForUrl(_tab->url()); @@ -391,7 +391,7 @@ void UrlBar::updateRightIcons() void UrlBar::loadTyped(const QString &text) { - activated( KUrl(text) ); + activated(KUrl(text)); } @@ -445,7 +445,7 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic) case UrlBar::BK: if (rApp->bookmarkProvider()->bookmarkForUrl(_tab->url()).isNull()) { - rightIcon->setIcon(KIcon("bookmarks").pixmap(32,32, QIcon::Disabled)); + rightIcon->setIcon(KIcon("bookmarks").pixmap(32, 32, QIcon::Disabled)); rightIcon->setToolTip(i18n("Bookmark this page")); } else @@ -507,13 +507,13 @@ void UrlBar::resizeEvent(QResizeEvent *event) void UrlBar::detectTypedString(const QString &typed) { - if(typed.count() == 1) + if (typed.count() == 1) { QTimer::singleShot(0, this, SLOT(suggest())); return; } - if(_suggestionTimer->isActive()) + if (_suggestionTimer->isActive()) _suggestionTimer->stop(); _suggestionTimer->start(50); } @@ -521,21 +521,21 @@ void UrlBar::detectTypedString(const QString &typed) void UrlBar::suggest() { - if(!_box.isNull()) - _box.data()->suggestUrls( text() ); + if (!_box.isNull()) + _box.data()->suggestUrls(text()); } void UrlBar::refreshFavicon() { - if(QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + if (QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) { _icon->setIcon(KIcon("view-media-artist")); return; } - + KUrl u = _tab->url(); - if(u.scheme() == QL1S("about")) + if (u.scheme() == QL1S("about")) { _icon->setIcon(KIcon("arrow-right")); return; diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h index d01c7fd8..9ed89dae 100644 --- a/src/urlbar/urlbar.h +++ b/src/urlbar/urlbar.h @@ -54,7 +54,7 @@ class IconButton : public QToolButton public: IconButton(QWidget *parent = 0); - + signals: void clicked(QPoint); diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index f0364f13..ee01599c 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -71,10 +71,10 @@ UrlResolver::UrlResolver(const QString &typedUrl) , _typedString(typedUrl.trimmed()) , _typedQuery() { - if (!_searchEngine ) + if (!_searchEngine) setSearchEngine(SearchEngine::defaultEngine()); - if ( _browseRegexp.isEmpty() ) + if (_browseRegexp.isEmpty()) { kDebug() << "browse regexp empty. Setting value.."; @@ -85,28 +85,28 @@ UrlResolver::UrlResolver(const QString &typedUrl) QString local = "^/"; 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[ceghrstu]|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|local|mil|museum|name|net|org|"\ - "pro)"; - - _browseRegexp = QRegExp('(' + protocol + ")|(" + localhost + ")|(" + local + ")|(" + address + ")|(" + ipv6 + ")|(" + ipv4 +')'); + "c[acdfghiklmnoruvxyz]|d[ejkmnoz]|e[ceghrstu]|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|local|mil|museum|name|net|org|"\ + "pro)"; + + _browseRegexp = QRegExp('(' + protocol + ")|(" + localhost + ")|(" + local + ")|(" + address + ")|(" + ipv6 + ")|(" + ipv4 + ')'); } - if ( _searchEnginesRegexp.isEmpty() ) + if (_searchEnginesRegexp.isEmpty()) { QString reg; QString engineUrl; Q_FOREACH(KService::Ptr s, SearchEngine::favorites()) { - engineUrl = QRegExp::escape(s->property("Query").toString()).replace("\\\\\\{@\\}","[\\d\\w-.]+"); + engineUrl = QRegExp::escape(s->property("Query").toString()).replace("\\\\\\{@\\}", "[\\d\\w-.]+"); if (reg.isEmpty()) reg = '(' + engineUrl + ')'; else @@ -119,20 +119,20 @@ UrlResolver::UrlResolver(const QString &typedUrl) UrlSearchList UrlResolver::orderedSearchItems() { - if( _typedString.startsWith( QL1S("about:") ) ) + if (_typedString.startsWith(QL1S("about:"))) { UrlSearchList list; - UrlSearchItem home(UrlSearchItem::Browse, QString("about:home"), QL1S("home") ); + UrlSearchItem home(UrlSearchItem::Browse, QString("about:home"), QL1S("home")); list << home; - UrlSearchItem favs(UrlSearchItem::Browse, QString("about:favorites"), QL1S("favorites") ); + UrlSearchItem favs(UrlSearchItem::Browse, QString("about:favorites"), QL1S("favorites")); list << favs; - UrlSearchItem clos(UrlSearchItem::Browse, QString("about:closedTabs"), QL1S("closed tabs") ); + UrlSearchItem clos(UrlSearchItem::Browse, QString("about:closedTabs"), QL1S("closed tabs")); list << clos; - UrlSearchItem book(UrlSearchItem::Browse, QString("about:bookmarks"), QL1S("bookmarks") ); + UrlSearchItem book(UrlSearchItem::Browse, QString("about:bookmarks"), QL1S("bookmarks")); list << book; - UrlSearchItem hist(UrlSearchItem::Browse, QString("about:history"), QL1S("history") ); + UrlSearchItem hist(UrlSearchItem::Browse, QString("about:history"), QL1S("history")); list << hist; - UrlSearchItem down(UrlSearchItem::Browse, QString("about:downloads"), QL1S("downloads") ); + UrlSearchItem down(UrlSearchItem::Browse, QString("about:downloads"), QL1S("downloads")); list << down; return list; @@ -162,7 +162,7 @@ UrlSearchList UrlResolver::orderLists() UrlSearchList list; - if(_browseRegexp.indexIn(_typedString) != -1) + if (_browseRegexp.indexIn(_typedString) != -1) { list << _qurlFromUserInput; list << _webSearches; @@ -182,7 +182,7 @@ UrlSearchList UrlResolver::orderLists() { privileged = privilegedItem(&_bookmarks); } - else if(privileged.type == UrlSearchItem::History && _bookmarks.removeOne(privileged)) + else if (privileged.type == UrlSearchItem::History && _bookmarks.removeOne(privileged)) { privileged.type |= UrlSearchItem::Bookmark; } @@ -200,11 +200,11 @@ UrlSearchList UrlResolver::orderLists() // 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) + if (bookmarksCount < 1000) { //add as many items to the common list as there are available entries in the dropdown list UrlSearchItem urlSearchItem; - for(int i = 0; i < _history.count(); i++) + for (int i = 0; i < _history.count(); i++) { if (_bookmarks.removeOne(_history.at(i))) { @@ -212,7 +212,7 @@ UrlSearchList UrlResolver::orderLists() urlSearchItem.type |= UrlSearchItem::Bookmark; common << urlSearchItem; commonCount++; - if(commonCount >= availableEntries) + if (commonCount >= availableEntries) { break; } @@ -220,7 +220,7 @@ UrlSearchList UrlResolver::orderLists() } commonCount = common.count(); - if(commonCount >= availableEntries) + if (commonCount >= availableEntries) { common = common.mid(0, availableEntries); _history = UrlSearchList(); @@ -230,11 +230,11 @@ UrlSearchList UrlResolver::orderLists() else //remove all items from the history and bookmarks list up to the remaining entries in the dropdown list { availableEntries -= commonCount; - if(historyCount >= availableEntries) + if (historyCount >= availableEntries) { _history = _history.mid(0, availableEntries); } - if(bookmarksCount >= availableEntries) + if (bookmarksCount >= availableEntries) { _bookmarks = _bookmarks.mid(0, availableEntries); } @@ -243,17 +243,17 @@ UrlSearchList UrlResolver::orderLists() else //if there are too many bookmarks items, remove all items up to the remaining entries in the dropdown list { - if(historyCount >= availableEntries) + if (historyCount >= availableEntries) { _history = _history.mid(0, availableEntries); } - if(bookmarksCount >= availableEntries) + if (bookmarksCount >= availableEntries) { _bookmarks = _bookmarks.mid(0, availableEntries); } UrlSearchItem urlSearchItem; - for(int i = 0; i < _history.count(); i++) + for (int i = 0; i < _history.count(); i++) { if (_bookmarks.removeOne(_history.at(i))) { @@ -273,9 +273,9 @@ UrlSearchList UrlResolver::orderLists() kDebug() << "HISTORY COUNT: " << historyCount; //now fill the list to MAX_ELEMENTS - if(availableEntries > 0) + if (availableEntries > 0) { - int historyEntries = ((int) (availableEntries / 2)) + availableEntries % 2; + int historyEntries = ((int)(availableEntries / 2)) + availableEntries % 2; int bookmarksEntries = availableEntries - historyEntries; if (historyCount >= historyEntries && bookmarksCount >= bookmarksEntries) @@ -285,14 +285,14 @@ UrlSearchList UrlResolver::orderLists() } else if (historyCount < historyEntries && bookmarksCount >= bookmarksEntries) { - if(historyCount + bookmarksCount > availableEntries) + if (historyCount + bookmarksCount > availableEntries) { _bookmarks = _bookmarks.mid(0, availableEntries - historyCount); } } else if (historyCount >= historyEntries && bookmarksCount < bookmarksEntries) { - if(historyCount + bookmarksCount > availableEntries) + if (historyCount + bookmarksCount > availableEntries) { _history = _history.mid(0, availableEntries - bookmarksCount); } @@ -343,7 +343,7 @@ void UrlResolver::computeWebSearches() setSearchEngine(engine); } - if(_searchEngine) + if (_searchEngine) { UrlSearchItem item = UrlSearchItem(UrlSearchItem::Search, SearchEngine::buildQuery(_searchEngine, query), query); UrlSearchList list; @@ -388,7 +388,7 @@ void UrlResolver::computeSuggestions() { // if a string startsWith /, it is probably a local path // so, no need for suggestions... - if(_typedString.startsWith('/') || !rApp->opensearchManager()->isSuggestionAvailable()) + if (_typedString.startsWith('/') || !rApp->opensearchManager()->isSuggestionAvailable()) { UrlSearchList list; emit suggestionsReady(list, _typedString); @@ -415,7 +415,7 @@ void UrlResolver::computeSuggestions() void UrlResolver::suggestionsReceived(const QString &text, const ResponseList &suggestions) { - if(text != _typedQuery) + if (text != _typedQuery) return; UrlSearchList sugList; @@ -425,7 +425,7 @@ void UrlResolver::suggestionsReceived(const QString &text, const ResponseList &s urlString = i.url; if (urlString.isEmpty()) { - urlString = SearchEngine::buildQuery(UrlResolver::searchEngine(),i.title); + urlString = SearchEngine::buildQuery(UrlResolver::searchEngine(), i.title); } UrlSearchItem gItem(UrlSearchItem::Suggestion, urlString, i.title, i.description, i.image, i.image_width, i.image_height); @@ -443,7 +443,7 @@ UrlSearchItem UrlResolver::privilegedItem(UrlSearchList* list) QString test1 = QString(QL1C('/')) + _typedString + dot; QString test2 = dot + _typedString + dot; - for(int i = 0; i<list->count(); i++) + for (int i = 0; i < list->count(); i++) { item = list->at(i); //TODO: move this to AwesomeUrlCompletion::substringCompletion and add a priviledged flag to UrlSearchItem diff --git a/src/urlbar/urlresolver.h b/src/urlbar/urlresolver.h index b6c4ec2b..70549094 100644 --- a/src/urlbar/urlresolver.h +++ b/src/urlbar/urlresolver.h @@ -69,21 +69,21 @@ public: QString bookmarkPath; UrlSearchItem(const UrlSearchItem &item) : type(item.type), - url(item.url), - title(item.title), - description(item.description), - image(item.image), - image_width(item.image_width), - image_height(item.image_height) + url(item.url), + title(item.title), + description(item.description), + image(item.image), + image_width(item.image_width), + image_height(item.image_height) {}; UrlSearchItem() : type(UrlSearchItem::Undefined), - url(QString()), - title(QString()), - description(QString()), - image(QString()), - image_width(0), - image_height(0) + url(QString()), + title(QString()), + description(QString()), + image(QString()), + image_width(0), + image_height(0) {}; UrlSearchItem(const int &_type, @@ -93,14 +93,14 @@ public: const QString &_image = QString(), const int &_image_width = 0, const int &_image_height = 0 - ) - : type(_type), - url(_url), - title(_title), - description(_description), - image(_image), - image_width(_image_width), - image_height(_image_height) + ) + : type(_type), + url(_url), + title(_title), + description(_description), + image(_image), + image_width(_image_width), + image_height(_image_height) {}; inline bool operator==(const UrlSearchItem &i) const @@ -132,14 +132,14 @@ public: static void setSearchEngine(KService::Ptr engine) { _searchEngine = engine; - if(engine) + if (engine) rApp->opensearchManager()->setSearchProvider(engine->desktopEntryName()); }; void computeSuggestions(); private Q_SLOTS: - void suggestionsReceived(const QString &text, const ResponseList &suggestions); + void suggestionsReceived(const QString &text, const ResponseList &suggestions); Q_SIGNALS: void suggestionsReady(const UrlSearchList &, const QString &); @@ -165,7 +165,7 @@ private: static QRegExp _browseRegexp; static QRegExp _searchEnginesRegexp; - static KService::Ptr _searchEngine; + static KService::Ptr _searchEngine; }; // ------------------------------------------------------------------------------ diff --git a/src/urlbar/webshortcutwidget.cpp b/src/urlbar/webshortcutwidget.cpp index 2eb6f2e4..bf281177 100644 --- a/src/urlbar/webshortcutwidget.cpp +++ b/src/urlbar/webshortcutwidget.cpp @@ -1,5 +1,5 @@ /* This file is part of the KDE project - * + * * Copyright (C) 2009 by Fredy Yanardi <fyanardi@gmail.com> * Copyright (C) 2010-2011 by Lionel Chauvin <megabigbug@yahoo.fr> * @@ -30,14 +30,14 @@ #include <QtGui/QPushButton> #include <QtGui/QFormLayout> - + #include <KGlobalSettings> #include <KIcon> #include <KLocale> #include <KServiceTypeTrader> WebShortcutWidget::WebShortcutWidget(QWidget *parent) - : QDialog(parent) + : QDialog(parent) { QVBoxLayout *mainLayout = new QVBoxLayout(); QHBoxLayout *titleLayout = new QHBoxLayout(); @@ -100,7 +100,7 @@ WebShortcutWidget::WebShortcutWidget(QWidget *parent) setLayout(mainLayout); - setMinimumWidth (250); + setMinimumWidth(250); m_providers = KServiceTypeTrader::self()->query("SearchProvider"); @@ -154,11 +154,11 @@ void WebShortcutWidget::shortcutsChanged(const QString& newShorthands) QString contenderName = ""; QString contenderWS = ""; - Q_FOREACH (const QString &shorthand, shorthands) + Q_FOREACH(const QString &shorthand, shorthands) { - Q_FOREACH (KService::Ptr provider, m_providers) + Q_FOREACH(KService::Ptr provider, m_providers) { - if(provider->property("Keys").toStringList().contains(shorthand)) + if (provider->property("Keys").toStringList().contains(shorthand)) { contenderName = provider->property("Name").toString(); contenderWS = shorthand; @@ -172,7 +172,7 @@ void WebShortcutWidget::shortcutsChanged(const QString& newShorthands) m_okButton->setEnabled(false); m_noteLabel->setText(i18n("The shortcut \"%1\" is already assigned to \"%2\".", contenderWS, contenderName)); m_noteLabel->setVisible(true); - resize(minimumSize().width(), minimumSizeHint().height()+15); + resize(minimumSize().width(), minimumSizeHint().height() + 15); } else { @@ -189,4 +189,4 @@ void WebShortcutWidget::shortcutsChanged(const QString& newShorthands) #include "webshortcutwidget.moc" - + diff --git a/src/urlbar/webshortcutwidget.h b/src/urlbar/webshortcutwidget.h index ea3801e3..2cf1eedf 100644 --- a/src/urlbar/webshortcutwidget.h +++ b/src/urlbar/webshortcutwidget.h @@ -1,8 +1,8 @@ /* This file is part of the KDE project - * + * * Copyright (C) 2009 by Fredy Yanardi <fyanardi@gmail.com> * Copyright (C) 2010-2011 by Lionel Chauvin <megabigbug@yahoo.fr> - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either |