From 9d20e99fffeebe67fd8ff27cb4f9e353892f5190 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 25 Feb 2011 00:19:27 +0100 Subject: Coding style --- src/adblock/adblockhostmatcher.cpp | 5 +- src/adblock/adblockhostmatcher.h | 5 +- src/adblock/adblockmanager.cpp | 10 +- src/adblock/adblockrule.cpp | 6 +- src/adblock/adblockrule.h | 3 +- src/adblock/adblockrulefallbackimpl.cpp | 26 ++-- src/adblock/adblockruleimpl.h | 2 +- src/adblock/adblockrulenullimpl.cpp | 6 +- src/adblock/adblockrulenullimpl.h | 2 +- src/adblock/adblockruletextmatchimpl.cpp | 5 +- src/adblock/adblockruletextmatchimpl.h | 2 +- src/analyzer/analyzerpanel.cpp | 12 +- src/analyzer/networkanalyzer.cpp | 102 +++++++-------- src/analyzer/networkanalyzer.h | 6 +- src/application.cpp | 92 ++++++------- src/application.h | 14 +- src/bookmarks/bookmarkowner.cpp | 24 ++-- src/bookmarks/bookmarkowner.h | 5 +- src/bookmarks/bookmarkprovider.cpp | 12 +- src/bookmarks/bookmarkprovider.h | 12 +- src/bookmarks/bookmarkspanel.cpp | 4 +- src/bookmarks/bookmarkspanel.h | 15 ++- src/bookmarks/bookmarkstoolbar.cpp | 24 ++-- src/bookmarks/bookmarkstoolbar.h | 6 +- src/bookmarks/bookmarkstreemodel.cpp | 14 +- src/filterurljob.cpp | 2 +- src/findbar.cpp | 12 +- src/history/historymanager.cpp | 33 ++--- src/history/historymanager.h | 19 ++- src/history/historymodels.h | 4 +- src/iconmanager.cpp | 70 +++++----- src/iconmanager.h | 4 +- src/main.cpp | 16 +-- src/mainview.cpp | 42 +++--- src/mainview.h | 17 ++- src/mainwindow.cpp | 170 ++++++++++++------------ src/mainwindow.h | 18 ++- src/messagebar.cpp | 28 ++-- src/messagebar.h | 7 +- src/networkaccessmanager.cpp | 20 +-- src/newtabpage.cpp | 214 +++++++++++++++---------------- src/notificationbar.cpp | 6 +- src/notificationbar.h | 13 +- src/opensearch/opensearchengine.cpp | 18 +-- src/opensearch/opensearchengine.h | 2 +- src/opensearch/opensearchmanager.cpp | 56 ++++---- src/opensearch/opensearchmanager.h | 8 +- src/opensearch/opensearchreader.cpp | 62 ++++----- src/opensearch/opensearchwriter.cpp | 18 +-- src/opensearch/searchengine.cpp | 2 +- src/opensearch/suggestionparser.cpp | 22 ++-- src/opensearch/suggestionparser.h | 46 ++++--- src/paneltreeview.cpp | 2 +- src/previewselectorbar.h | 5 +- src/protocolhandler.cpp | 21 +-- src/protocolhandler.h | 2 +- src/rekonq_defines.h | 52 ++++---- src/sessionmanager.cpp | 15 ++- src/sessionmanager.h | 5 +- src/settings/appearancewidget.cpp | 46 +++---- src/settings/generalwidget.cpp | 2 +- src/settings/settingsdialog.cpp | 6 +- src/settings/settingsdialog.h | 2 +- src/tabbar.cpp | 70 +++++----- src/tabhighlighteffect.cpp | 12 +- src/tabhighlighteffect.h | 2 +- src/tests/listitem_test.cpp | 8 +- src/urlbar/bookmarkwidget.cpp | 2 +- src/urlbar/completionwidget.cpp | 26 ++-- src/urlbar/completionwidget.h | 2 +- src/urlbar/listitem.cpp | 49 ++++--- src/urlbar/rsswidget.cpp | 2 +- src/urlbar/stackedurlbar.h | 2 +- src/urlbar/urlbar.cpp | 42 +++--- src/urlbar/urlbar.h | 2 +- src/urlbar/urlresolver.cpp | 80 ++++++------ src/urlbar/urlresolver.h | 46 +++---- src/urlbar/webshortcutwidget.cpp | 18 +-- src/urlbar/webshortcutwidget.h | 4 +- src/urlfilterproxymodel.cpp | 2 +- src/urlpanel.cpp | 2 +- src/urlpanel.h | 5 +- src/useragent/useragentinfo.cpp | 72 +++++------ src/useragent/useragentinfo.h | 12 +- src/useragent/useragentwidget.cpp | 28 ++-- src/webicon.cpp | 2 +- src/webinspectorpanel.cpp | 6 +- src/webpage.cpp | 136 ++++++++++---------- src/webpage.h | 38 ++++-- src/websnap.cpp | 20 +-- src/websslinfo.cpp | 28 ++-- src/websslinfo.h | 6 +- src/webtab.cpp | 26 ++-- src/webtab.h | 25 +++- src/webview.cpp | 64 ++++----- src/webview.h | 5 +- src/zoombar.cpp | 12 +- 97 files changed, 1257 insertions(+), 1100 deletions(-) diff --git a/src/adblock/adblockhostmatcher.cpp b/src/adblock/adblockhostmatcher.cpp index c0b25726..021fe12d 100644 --- a/src/adblock/adblockhostmatcher.cpp +++ b/src/adblock/adblockhostmatcher.cpp @@ -31,8 +31,9 @@ bool AdBlockHostMatcher::tryAddFilter(const QString &filter) { - if (filter.startsWith(QL1S("||"))) { - + if (filter.startsWith(QL1S("||"))) + { + QString domain = filter.mid(2); if (!domain.endsWith(QL1C('^'))) diff --git a/src/adblock/adblockhostmatcher.h b/src/adblock/adblockhostmatcher.h index 74b32c3c..bdad883c 100644 --- a/src/adblock/adblockhostmatcher.h +++ b/src/adblock/adblockhostmatcher.h @@ -42,7 +42,10 @@ public: return m_hostList.contains(host.toLower()); } - void clear() { m_hostList.clear(); } + void clear() + { + m_hostList.clear(); + } private: QSet m_hostList; diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp index a96475e2..9b096bb9 100644 --- a/src/adblock/adblockmanager.cpp +++ b/src/adblock/adblockmanager.cpp @@ -82,7 +82,7 @@ void AdBlockManager::loadSettings(bool checkUpdateDate) // just to be sure.. _isHideAdsEnabled = ReKonfig::hideAdsEnabled(); - + // read settings KSharedConfig::Ptr config = KSharedConfig::openConfig("adblock", KConfig::SimpleConfig, "appdata"); KConfigGroup rulesGroup(config, "rules"); @@ -137,7 +137,7 @@ void AdBlockManager::loadRules(const QStringList &rules) const QString filter = stringRule.mid(2); if (_hostWhiteList.tryAddFilter(filter)) continue; - + AdBlockRule rule(filter); _whiteList << rule; continue; @@ -180,7 +180,8 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa // check white rules before :) - if (_hostWhiteList.match(host)) { + if (_hostWhiteList.match(host)) + { kDebug() << "****ADBLOCK: WHITE RULE (@@) Matched by host matcher: ***********"; kDebug() << "UrlString: " << urlString; return 0; @@ -197,7 +198,8 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa } // then check the black ones :( - if (_hostBlackList.match(host)) { + if (_hostBlackList.match(host)) + { kDebug() << "****ADBLOCK: BLACK RULE Matched by host matcher: ***********"; kDebug() << "UrlString: " << urlString; AdBlockNetworkReply *reply = new AdBlockNetworkReply(request, urlString, this); diff --git a/src/adblock/adblockrule.cpp b/src/adblock/adblockrule.cpp index 3cd50020..87fcb680 100644 --- a/src/adblock/adblockrule.cpp +++ b/src/adblock/adblockrule.cpp @@ -37,7 +37,7 @@ AdBlockRule::AdBlockRule(const QString &filter) { - switch( AdBlockRule::ruleType(filter) ) + switch (AdBlockRule::ruleType(filter)) { case TextRule: m_implementation = QSharedPointer(new AdBlockRuleTextMatchImpl(filter)); @@ -57,10 +57,10 @@ AdBlockRule::AdBlockRule(const QString &filter) RuleTypes AdBlockRule::ruleType(const QString &filter) { - if( AdBlockRuleTextMatchImpl::isTextMatchFilter(filter) ) + if (AdBlockRuleTextMatchImpl::isTextMatchFilter(filter)) return TextRule; - if( AdBlockRuleNullImpl::isNullFilter(filter) ) + if (AdBlockRuleNullImpl::isNullFilter(filter)) return NullRule; return FallbackRule; diff --git a/src/adblock/adblockrule.h b/src/adblock/adblockrule.h index 076c6272..f5f913dc 100644 --- a/src/adblock/adblockrule.h +++ b/src/adblock/adblockrule.h @@ -57,7 +57,8 @@ public: { Q_ASSERT(encodedUrl.toLower() == encodedUrlLowerCase); bool b = m_implementation->match(request, encodedUrl, encodedUrlLowerCase); - if(b) { + if (b) + { kDebug() << m_implementation->ruleType() << ": rule string = " << m_implementation->ruleString(); } return b; diff --git a/src/adblock/adblockrulefallbackimpl.cpp b/src/adblock/adblockrulefallbackimpl.cpp index dfe732df..915516c7 100644 --- a/src/adblock/adblockrulefallbackimpl.cpp +++ b/src/adblock/adblockrulefallbackimpl.cpp @@ -41,7 +41,7 @@ static inline bool isRegExpFilter(const QString &filter) } AdBlockRuleFallbackImpl::AdBlockRuleFallbackImpl(const QString &filter) - : AdBlockRuleImpl(filter) + : AdBlockRuleImpl(filter) { m_regExp.setCaseSensitivity(Qt::CaseInsensitive); m_regExp.setPatternSyntax(QRegExp::RegExp2); @@ -49,19 +49,23 @@ AdBlockRuleFallbackImpl::AdBlockRuleFallbackImpl(const QString &filter) QString parsedLine = filter; const int optionsNumber = parsedLine.lastIndexOf(QL1C('$')); - if (optionsNumber >= 0 && !isRegExpFilter(parsedLine)) { + if (optionsNumber >= 0 && !isRegExpFilter(parsedLine)) + { const QStringList options(parsedLine.mid(optionsNumber + 1).split(QL1C(','))); parsedLine = parsedLine.left(optionsNumber); if (options.contains(QL1S("match-case"))) m_regExp.setCaseSensitivity(Qt::CaseSensitive); - foreach (const QString &option, options) { + foreach(const QString &option, options) + { // Domain restricted filter const QString domainKeyword(QL1S("domain=")); - if (option.startsWith(domainKeyword)) { + if (option.startsWith(domainKeyword)) + { QStringList domainList = option.mid(domainKeyword.length()).split(QL1C('|')); - foreach (const QString &domain, domainList) { + foreach(const QString &domain, domainList) + { if (domain.startsWith(QL1C('~'))) m_whiteDomains.insert(domain.toLower()); else @@ -83,18 +87,22 @@ bool AdBlockRuleFallbackImpl::match(const QNetworkRequest &request, const QStrin { const bool regexpMatch = m_regExp.indexIn(encodedUrl) != -1; - if (regexpMatch && (!m_whiteDomains.isEmpty() || !m_blackDomains.isEmpty())) { + if (regexpMatch && (!m_whiteDomains.isEmpty() || !m_blackDomains.isEmpty())) + { Q_ASSERT(qobject_cast(request.originatingObject())); - const QWebFrame *const origin = static_cast(request.originatingObject()); + const QWebFrame *const origin = static_cast(request.originatingObject()); const QString originDomain = origin->url().host(); - if (!m_whiteDomains.isEmpty()) { + if (!m_whiteDomains.isEmpty()) + { // In this context, white domains means we block anything but what is in the list. if (m_whiteDomains.contains(originDomain)) return false; return true; - } else if (m_blackDomains.contains(originDomain)) { + } + else if (m_blackDomains.contains(originDomain)) + { return true; } return false; diff --git a/src/adblock/adblockruleimpl.h b/src/adblock/adblockruleimpl.h index 2344b698..f1d428d5 100644 --- a/src/adblock/adblockruleimpl.h +++ b/src/adblock/adblockruleimpl.h @@ -35,7 +35,7 @@ public: AdBlockRuleImpl(const QString &) {} virtual ~AdBlockRuleImpl() {} virtual bool match(const QNetworkRequest &request, const QString &encodedUrl, const QString &encodedUrlLowerCase) const = 0; - + // This are added just for debugging purposes virtual QString ruleString() const = 0; virtual QString ruleType() const = 0; diff --git a/src/adblock/adblockrulenullimpl.cpp b/src/adblock/adblockrulenullimpl.cpp index 6d68715d..7f6ab765 100644 --- a/src/adblock/adblockrulenullimpl.cpp +++ b/src/adblock/adblockrulenullimpl.cpp @@ -35,7 +35,7 @@ AdBlockRuleNullImpl::AdBlockRuleNullImpl(const QString &filter) - : AdBlockRuleImpl(filter) + : AdBlockRuleImpl(filter) { } @@ -69,11 +69,11 @@ bool AdBlockRuleNullImpl::isNullFilter(const QString &filter) // background if (option == QL1S("background")) return true; - + // stylesheet if (option == QL1S("stylesheet")) return true; - + // object if (option == QL1S("object")) return true; diff --git a/src/adblock/adblockrulenullimpl.h b/src/adblock/adblockrulenullimpl.h index 3d2e94a1..8a479880 100644 --- a/src/adblock/adblockrulenullimpl.h +++ b/src/adblock/adblockrulenullimpl.h @@ -37,7 +37,7 @@ class AdBlockRuleNullImpl : public AdBlockRuleImpl { - + public: AdBlockRuleNullImpl(const QString &filter); bool match(const QNetworkRequest &, const QString &, const QString &) const; diff --git a/src/adblock/adblockruletextmatchimpl.cpp b/src/adblock/adblockruletextmatchimpl.cpp index 0ca2d40a..d8ec70b6 100644 --- a/src/adblock/adblockruletextmatchimpl.cpp +++ b/src/adblock/adblockruletextmatchimpl.cpp @@ -32,7 +32,7 @@ AdBlockRuleTextMatchImpl::AdBlockRuleTextMatchImpl(const QString &filter) - : AdBlockRuleImpl(filter) + : AdBlockRuleImpl(filter) { Q_ASSERT(AdBlockRuleTextMatchImpl::isTextMatchFilter(filter)); @@ -69,7 +69,8 @@ bool AdBlockRuleTextMatchImpl::isTextMatchFilter(const QString &filter) // We only handle * at the beginning or the end int starPosition = filter.indexOf(QL1C('*')); - while (starPosition >= 0) { + while (starPosition >= 0) + { if (starPosition != 0 && starPosition != (filter.length() - 1)) return false; starPosition = filter.indexOf(QL1C('*'), starPosition + 1); diff --git a/src/adblock/adblockruletextmatchimpl.h b/src/adblock/adblockruletextmatchimpl.h index 3a89c2ba..8600543d 100644 --- a/src/adblock/adblockruletextmatchimpl.h +++ b/src/adblock/adblockruletextmatchimpl.h @@ -41,7 +41,7 @@ public: bool match(const QNetworkRequest &request, const QString &encodedUrl, const QString &encodedUrlLowerCase) const; static bool isTextMatchFilter(const QString &filter); - + QString ruleString() const; QString ruleType() const; diff --git a/src/analyzer/analyzerpanel.cpp b/src/analyzer/analyzerpanel.cpp index 5520582a..964a512b 100644 --- a/src/analyzer/analyzerpanel.cpp +++ b/src/analyzer/analyzerpanel.cpp @@ -72,22 +72,22 @@ void NetworkAnalyzerPanel::toggle(bool enable) mainWindow()->actionByName("net_analyzer")->setChecked(enable); WebPage *page = mainWindow()->currentTab()->page(); NetworkAccessManager *manager = qobject_cast(page->networkAccessManager()); - + page->enableNetworkAnalyzer(enable); - + if (enable) { - connect(page, SIGNAL(loadStarted()), _viewer, SLOT(clear())); + connect(page, SIGNAL(loadStarted()), _viewer, SLOT(clear())); connect(manager, SIGNAL(networkData(QNetworkAccessManager::Operation, const QNetworkRequest &, QNetworkReply *)), - _viewer, SLOT(addRequest(QNetworkAccessManager::Operation, const QNetworkRequest &, QNetworkReply *) ) ); + _viewer, SLOT(addRequest(QNetworkAccessManager::Operation, const QNetworkRequest &, QNetworkReply *))); - show(); + show(); } else { disconnect(page, SIGNAL(loadStarted()), _viewer, SLOT(clear())); disconnect(manager, SIGNAL(networkData(QNetworkAccessManager::Operation, const QNetworkRequest &, QNetworkReply *)), - _viewer, SLOT(addRequest(QNetworkAccessManager::Operation, const QNetworkRequest &, QNetworkReply *) ) ); + _viewer, SLOT(addRequest(QNetworkAccessManager::Operation, const QNetworkRequest &, QNetworkReply *))); hide(); } diff --git a/src/analyzer/networkanalyzer.cpp b/src/analyzer/networkanalyzer.cpp index 752543d9..a3675dfa 100644 --- a/src/analyzer/networkanalyzer.cpp +++ b/src/analyzer/networkanalyzer.cpp @@ -46,29 +46,29 @@ #include NetworkAnalyzer::NetworkAnalyzer(QWidget *parent) - : QWidget(parent) - , _mapper(new QSignalMapper(this)) - , _requestList(new QTreeWidget(this)) + : QWidget(parent) + , _mapper(new QSignalMapper(this)) + , _requestList(new QTreeWidget(this)) { QStringList headers; headers << i18n("Method") << i18n("URL") << i18n("Response") << i18n("Length") << i18n("Content Type") << i18n("Info"); - _requestList->setHeaderLabels( headers ); - + _requestList->setHeaderLabels(headers); + _requestList->header()->setResizeMode(0, QHeaderView::Interactive); _requestList->header()->setResizeMode(1, QHeaderView::Interactive); _requestList->header()->setResizeMode(2, QHeaderView::Interactive); _requestList->header()->setResizeMode(3, QHeaderView::Interactive); _requestList->header()->setResizeMode(4, QHeaderView::Interactive); - + _requestList->setAlternatingRowColors(true); - + QVBoxLayout *lay = new QVBoxLayout(this); - lay->addWidget( _requestList ); + lay->addWidget(_requestList); _requestList->setContextMenuPolicy(Qt::CustomContextMenu); - connect( _mapper, SIGNAL(mapped(QObject *)), this, SLOT(requestFinished(QObject *)) ); - connect( _requestList, SIGNAL(itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( showItemDetails( QTreeWidgetItem *) ) ); - connect( _requestList, SIGNAL(customContextMenuRequested(QPoint) ), this, SLOT( popupContextMenu(QPoint))); + connect(_mapper, SIGNAL(mapped(QObject *)), this, SLOT(requestFinished(QObject *))); + connect(_requestList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(showItemDetails(QTreeWidgetItem *))); + connect(_requestList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(popupContextMenu(QPoint))); } @@ -78,12 +78,12 @@ NetworkAnalyzer::~NetworkAnalyzer() void NetworkAnalyzer::popupContextMenu(const QPoint& pos) { - if(_requestList->topLevelItemCount() >= 1) + if (_requestList->topLevelItemCount() >= 1) { KMenu menu(_requestList); KAction *copy; - copy = new KAction(KIcon("edit-copy"),i18n("Copy URL"), this); - connect(copy,SIGNAL(triggered(bool)),this,SLOT(copyURL())); + copy = new KAction(KIcon("edit-copy"), i18n("Copy URL"), this); + connect(copy, SIGNAL(triggered(bool)), this, SLOT(copyURL())); menu.addAction(copy); menu.exec(mapToGlobal(pos)); } @@ -95,11 +95,11 @@ void NetworkAnalyzer::copyURL() clipboard->setText(_requestList->currentItem()->text(1)); } -void NetworkAnalyzer::addRequest( QNetworkAccessManager::Operation op, const QNetworkRequest &req, QNetworkReply *reply ) +void NetworkAnalyzer::addRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &req, QNetworkReply *reply) { // Add to list of requests QStringList cols; - switch( op ) + switch (op) { case QNetworkAccessManager::HeadOperation: cols << QL1S("HEAD"); @@ -126,16 +126,16 @@ void NetworkAnalyzer::addRequest( QNetworkAccessManager::Operation op, const QNe cols << req.url().toString(); cols << i18n("Pending"); - QTreeWidgetItem *item = new QTreeWidgetItem( cols ); - _requestList->addTopLevelItem( item ); + QTreeWidgetItem *item = new QTreeWidgetItem(cols); + _requestList->addTopLevelItem(item); // Add to maps - _requestMap.insert( reply, req ); - _itemMap.insert( reply, item ); - _itemRequestMap.insert( item, req ); + _requestMap.insert(reply, req); + _itemMap.insert(reply, item); + _itemRequestMap.insert(item, req); - _mapper->setMapping( reply, reply ); - connect( reply, SIGNAL( finished() ), _mapper, SLOT( map() ) ); + _mapper->setMapping(reply, reply); + connect(reply, SIGNAL(finished()), _mapper, SLOT(map())); _requestList->header()->resizeSections(QHeaderView::ResizeToContents); } @@ -151,10 +151,11 @@ void NetworkAnalyzer::clear() } -void NetworkAnalyzer::requestFinished( QObject *replyObject ) +void NetworkAnalyzer::requestFinished(QObject *replyObject) { - QNetworkReply *reply = qobject_cast( replyObject ); - if ( !reply ) { + QNetworkReply *reply = qobject_cast(replyObject); + if (!reply) + { kDebug() << "Failed to downcast reply"; return; } @@ -163,68 +164,69 @@ void NetworkAnalyzer::requestFinished( QObject *replyObject ) // Record the reply headers QList headerValues; - foreach(const QByteArray &header, reply->rawHeaderList() ) + foreach(const QByteArray &header, reply->rawHeaderList()) { - headerValues += reply->rawHeader( header ); + headerValues += reply->rawHeader(header); } - + QPair< QList, QList > replyHeaders; replyHeaders.first = reply->rawHeaderList(); replyHeaders.second = headerValues; _itemReplyMap[item] = replyHeaders; // Display the request - int status = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute ).toInt(); - QString reason = reply->attribute( QNetworkRequest::HttpReasonPhraseAttribute ).toString(); - item->setText( 2, i18n("%1 %2", status, reason) ); + int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + QString reason = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString(); + item->setText(2, i18n("%1 %2", status, reason)); - QString length = reply->header( QNetworkRequest::ContentLengthHeader ).toString(); - item->setText( 3, length ); + QString length = reply->header(QNetworkRequest::ContentLengthHeader).toString(); + item->setText(3, length); - QString contentType = reply->header( QNetworkRequest::ContentTypeHeader ).toString(); - item->setText( 4, contentType ); + QString contentType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); + item->setText(4, contentType); - if ( status == 302 ) { - QUrl target = reply->attribute( QNetworkRequest::RedirectionTargetAttribute ).toUrl(); - item->setText( 5, i18n("Redirect: %1", target.toString() ) ); + if (status == 302) + { + QUrl target = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); + item->setText(5, i18n("Redirect: %1", target.toString())); } } -void NetworkAnalyzer::showItemDetails( QTreeWidgetItem *item ) +void NetworkAnalyzer::showItemDetails(QTreeWidgetItem *item) { // Show request details QString details; - + QNetworkRequest req = _itemRequestMap[item]; details += i18n("

Request Details

"); details += QL1S("
    "); - foreach(const QByteArray &header, req.rawHeaderList() ) + foreach(const QByteArray &header, req.rawHeaderList()) { details += QL1S("
  • "); - details += QL1S( header ); + details += QL1S(header); details += QL1S(": "); - details += QL1S( req.rawHeader( header ) ); + details += QL1S(req.rawHeader(header)); details += QL1S("
  • "); } details += QL1S("
"); - + QPair< QList, QList > replyHeaders = _itemReplyMap[item]; details += i18n("

Response Details

"); details += QL1S("
    "); - for ( int i = 0; i < replyHeaders.first.count(); i++ ) + for (int i = 0; i < replyHeaders.first.count(); i++) { details += QL1S("
  • "); - details += QL1S( replyHeaders.first[i] ); + details += QL1S(replyHeaders.first[i]); details += QL1S(": "); - details += QL1S( replyHeaders.second[i] ); + details += QL1S(replyHeaders.second[i]); details += QL1S("
  • "); } details += QL1S("
"); - + // QLabel *label = new QLabel(details, this); // KPassivePopup *popup = new KPassivePopup(this); // popup->setView(label); // popup->show(_requestList->mapToGlobal(_requestList->pos())); - KPassivePopup::message(details,this); + KPassivePopup::message(details, this); } diff --git a/src/analyzer/networkanalyzer.h b/src/analyzer/networkanalyzer.h index d52978d1..9ff1bae6 100644 --- a/src/analyzer/networkanalyzer.h +++ b/src/analyzer/networkanalyzer.h @@ -59,11 +59,11 @@ public: ~NetworkAnalyzer(); private slots: - void addRequest( QNetworkAccessManager::Operation op, const QNetworkRequest &req, QNetworkReply *reply ); + void addRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &req, QNetworkReply *reply); void clear(); - void requestFinished( QObject *replyObject ); - void showItemDetails( QTreeWidgetItem *item ); + void requestFinished(QObject *replyObject); + void showItemDetails(QTreeWidgetItem *item); void copyURL(); void popupContextMenu(const QPoint &pos); diff --git a/src/application.cpp b/src/application.cpp index 6db3d31e..66d1384e 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -117,51 +117,57 @@ int Application::newInstance() int exitValue = 1 * isFirstLoad + 2 * areThereArguments + 4 * isRekonqCrashed; - if (isRekonqCrashed && isFirstLoad) { - loadUrl(KUrl("about:closedTabs")); - MessageBar *msgBar = new MessageBar(i18n("It seems rekonq was not closed properly. Do you want " - "to restore the last saved session?") - , mainWindow()->currentTab() - , QMessageBox::Warning - , MessageBar::Yes | MessageBar::No ); - - connect(msgBar, SIGNAL(accepted()), sessionManager(), SLOT(restoreSession())); - mainWindow()->currentTab()->insertBar(msgBar); + if (isRekonqCrashed && isFirstLoad) + { + loadUrl(KUrl("about:closedTabs")); + MessageBar *msgBar = new MessageBar(i18n("It seems rekonq was not closed properly. Do you want " + "to restore the last saved session?") + , mainWindow()->currentTab() + , QMessageBox::Warning + , MessageBar::Yes | MessageBar::No); + + connect(msgBar, SIGNAL(accepted()), sessionManager(), SLOT(restoreSession())); + mainWindow()->currentTab()->insertBar(msgBar); } - if (areThereArguments) { + if (areThereArguments) + { KUrl::List urlList; - for(int i = 0; i < args->count(); ++i) + for (int i = 0; i < args->count(); ++i) { const KUrl u = args->url(i); if (u.isLocalFile() && QFile::exists(u.toLocalFile())) // "rekonq somefile.html" case urlList += u; else - urlList += KUrl( args->arg(i) ); // "rekonq kde.org" || "rekonq kde:kdialog" case + urlList += KUrl(args->arg(i)); // "rekonq kde.org" || "rekonq kde:kdialog" case } - if (isFirstLoad && !isRekonqCrashed) { + if (isFirstLoad && !isRekonqCrashed) + { // No windows in the current desktop? No windows at all? // Create a new one and load there sites... loadUrl(urlList.at(0), Rekonq::CurrentTab); } else { - if(ReKonfig::openTabNoWindow()) { + if (ReKonfig::openTabNoWindow()) + { loadUrl(urlList.at(0), Rekonq::NewTab); - if( !mainWindow()->isActiveWindow() ) + if (!mainWindow()->isActiveWindow()) KWindowSystem::demandAttention(mainWindow()->winId(), true); } else loadUrl(urlList.at(0), Rekonq::NewWindow); } - + for (int i = 1; i < urlList.count(); ++i) - loadUrl( urlList.at(i), Rekonq::NewTab); + loadUrl(urlList.at(i), Rekonq::NewTab); KStartupInfo::appStarted(); - } else if (!isRekonqCrashed) { + } + else if (!isRekonqCrashed) + { if (isFirstLoad) // we are starting rekonq, for the first time with no args: use startup behaviour { @@ -195,15 +201,15 @@ int Application::newInstance() case 2: // homepage loadUrl(KUrl(ReKonfig::homePage()) , Rekonq::NewWindow); break; - default: + default: loadUrl(KUrl("about:blank") , Rekonq::NewWindow); break; - } + } } } - if(isFirstLoad) + if (isFirstLoad) { // give me some time to do the other things.. QTimer::singleShot(100, this, SLOT(postLaunch())); @@ -232,7 +238,7 @@ void Application::postLaunch() // bookmarks loading connect(bookmarkProvider(), SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType&)), instance(), SLOT(loadUrl(const KUrl&, const Rekonq::OpenType&))); - + // crash recovering ReKonfig::setRecoverOnCrash(ReKonfig::recoverOnCrash() + 1); saveConfiguration(); @@ -332,8 +338,8 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) switch (type) { case Rekonq::NewTab: - if( ReKonfig::openTabNoWindow() ) - tab = w->mainView()->newWebTab( !ReKonfig::openTabsBack() ); + if (ReKonfig::openTabNoWindow()) + tab = w->mainView()->newWebTab(!ReKonfig::openTabsBack()); else { w = newMainWindow(); @@ -355,7 +361,7 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) // rapidly show first loading url.. int tabIndex = w->mainView()->indexOf(tab); - Q_ASSERT( tabIndex != -1 ); + Q_ASSERT(tabIndex != -1); UrlBar *barForTab = qobject_cast(w->mainView()->widgetBar()->widget(tabIndex)); barForTab->activateSuggestions(false); barForTab->setQUrl(url); @@ -447,10 +453,10 @@ void Application::updateConfiguration() QWebSettings *defaultSettings = QWebSettings::globalSettings(); // =========== Fonts ============== - defaultSettings->setFontFamily(QWebSettings::StandardFont, ReKonfig::standardFontFamily() ); - defaultSettings->setFontFamily(QWebSettings::FixedFont, ReKonfig::fixedFontFamily() ); - defaultSettings->setFontFamily(QWebSettings::SerifFont, ReKonfig::serifFontFamily() ); - defaultSettings->setFontFamily(QWebSettings::SansSerifFont, ReKonfig::sansSerifFontFamily() ); + defaultSettings->setFontFamily(QWebSettings::StandardFont, ReKonfig::standardFontFamily()); + defaultSettings->setFontFamily(QWebSettings::FixedFont, ReKonfig::fixedFontFamily()); + defaultSettings->setFontFamily(QWebSettings::SerifFont, ReKonfig::serifFontFamily()); + defaultSettings->setFontFamily(QWebSettings::SansSerifFont, ReKonfig::sansSerifFontFamily()); defaultSettings->setFontFamily(QWebSettings::CursiveFont, ReKonfig::cursiveFontFamily()); defaultSettings->setFontFamily(QWebSettings::FantasyFont, ReKonfig::fantasyFontFamily()); @@ -464,11 +470,11 @@ void Application::updateConfiguration() kDebug() << "Logical Dot per Inch Y: " << logDpiY; float toPix = (logDpiY < 96.0) - ? 96.0/72.0 - : logDpiY/72.0 ; + ? 96.0 / 72.0 + : logDpiY / 72.0 ; - defaultSettings->setFontSize(QWebSettings::DefaultFontSize, qRound(defaultFontSize * toPix) ); - defaultSettings->setFontSize(QWebSettings::MinimumFontSize, qRound(minimumFontSize * toPix) ); + defaultSettings->setFontSize(QWebSettings::DefaultFontSize, qRound(defaultFontSize * toPix)); + defaultSettings->setFontSize(QWebSettings::MinimumFontSize, qRound(minimumFontSize * toPix)); // encodings QString enc = ReKonfig::defaultEncoding(); @@ -513,13 +519,13 @@ void Application::updateConfiguration() // ====== load Settings on main classes historyManager()->loadSettings(); adblockManager()->loadSettings(); - if(!ReKonfig::useFavicon()) + if (!ReKonfig::useFavicon()) mainWindow()->setWindowIcon(KIcon("rekonq")); else mainWindow()->changeWindowIcon(mainWindow()->mainView()->currentIndex()); // hovering unfocused tabs options - switch(ReKonfig::hoveringTabOption()) + switch (ReKonfig::hoveringTabOption()) { case 0: // tab previews case 3: // nothing @@ -612,7 +618,7 @@ void Application::setPrivateBrowsingMode(bool b) // NOTE // to let work nicely Private Browsing, we need the following: // - enable WebKit Private Browsing mode :) -// - treat all cookies as session cookies +// - treat all cookies as session cookies // (so that they do not get saved to a persistent storage). Available from KDE SC 4.5.72, see BUG: 250122 // - favicons (fixed in rekonq 0.5.87) // - save actual session (to restore it when Private Mode is closed) and stop storing it @@ -620,7 +626,7 @@ void Application::setPrivateBrowsingMode(bool b) QWebSettings *settings = QWebSettings::globalSettings(); bool isJustEnabled = settings->testAttribute(QWebSettings::PrivateBrowsingEnabled); - if(isJustEnabled == b) + if (isJustEnabled == b) return; // uhm... something goes wrong... if (b) @@ -629,7 +635,7 @@ void Application::setPrivateBrowsingMode(bool b) QString text = i18n("%1" "

rekonq will save your current tabs for when you'll stop private browsing the net.

", caption); - int button = KMessageBox::warningContinueCancel(mainWindow(), text, caption, KStandardGuiItem::cont(), KStandardGuiItem::cancel(), i18n("don't ask again") ); + int button = KMessageBox::warningContinueCancel(mainWindow(), text, caption, KStandardGuiItem::cont(), KStandardGuiItem::cancel(), i18n("don't ask again")); if (button != KMessageBox::Continue) return; @@ -640,7 +646,7 @@ void Application::setPrivateBrowsingMode(bool b) { w.data()->close(); } - loadUrl( KUrl("about:home"), Rekonq::NewWindow); + loadUrl(KUrl("about:home"), Rekonq::NewWindow); } else { @@ -652,8 +658,8 @@ void Application::setPrivateBrowsingMode(bool b) settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false); _privateBrowsingAction->setChecked(false); - loadUrl( KUrl("about:blank"), Rekonq::NewWindow); - if(!sessionManager()->restoreSession()) - loadUrl( KUrl("about:home"), Rekonq::NewWindow); + loadUrl(KUrl("about:blank"), Rekonq::NewWindow); + if (!sessionManager()->restoreSession()) + loadUrl(KUrl("about:home"), Rekonq::NewWindow); } } diff --git a/src/application.h b/src/application.h index 135b37de..3cd3c96b 100644 --- a/src/application.h +++ b/src/application.h @@ -52,7 +52,10 @@ class SessionManager; class KAction; -namespace ThreadWeaver {class Job;} +namespace ThreadWeaver +{ +class Job; +} typedef QList< QWeakPointer > MainWindowList; @@ -110,8 +113,11 @@ public: void addDownload(const QString &srcUrl, const QString &destUrl); DownloadList downloads(); bool clearDownloadsHistory(); - - KAction *privateBrowsingAction() { return _privateBrowsingAction; }; + + KAction *privateBrowsingAction() + { + return _privateBrowsingAction; + }; public slots: /** @@ -139,7 +145,7 @@ private slots: void updateConfiguration(); // the general place to set private browsing - void setPrivateBrowsingMode(bool); + void setPrivateBrowsingMode(bool); private: QWeakPointer m_historyManager; diff --git a/src/bookmarks/bookmarkowner.cpp b/src/bookmarks/bookmarkowner.cpp index de193d41..bfca6ef3 100644 --- a/src/bookmarks/bookmarkowner.cpp +++ b/src/bookmarks/bookmarkowner.cpp @@ -61,36 +61,36 @@ KAction* BookmarkOwner::createAction(const KBookmark &bookmark, const BookmarkAc { case OPEN: return createAction(i18n("Open"), "tab-new", - i18n("Open bookmark in current tab"), SLOT(openBookmark(const KBookmark &)), bookmark); + i18n("Open bookmark in current tab"), SLOT(openBookmark(const KBookmark &)), bookmark); case OPEN_IN_TAB: return createAction(i18n("Open in New Tab"), "tab-new", - i18n("Open bookmark in new tab"), SLOT(openBookmarkInNewTab(const KBookmark &)), bookmark); + i18n("Open bookmark in new tab"), SLOT(openBookmarkInNewTab(const KBookmark &)), bookmark); case OPEN_IN_WINDOW: return createAction(i18n("Open in New Window"), "window-new", - i18n("Open bookmark in new window"), SLOT(openBookmarkInNewWindow(const KBookmark &)), bookmark); + i18n("Open bookmark in new window"), SLOT(openBookmarkInNewWindow(const KBookmark &)), bookmark); case OPEN_FOLDER: return createAction(i18n("Open Folder in Tabs"), "tab-new", - i18n("Open all the bookmarks in folder in tabs"), SLOT(openBookmarkFolder(const KBookmark &)), bookmark); + i18n("Open all the bookmarks in folder in tabs"), SLOT(openBookmarkFolder(const KBookmark &)), bookmark); case BOOKMARK_PAGE: return createAction(i18n("Add Bookmark"), "bookmark-new", - i18n("Bookmark current page"), SLOT(bookmarkCurrentPage(const KBookmark &)), bookmark); + i18n("Bookmark current page"), SLOT(bookmarkCurrentPage(const KBookmark &)), bookmark); case NEW_FOLDER: return createAction(i18n("New Folder"), "folder-new", - i18n("Create a new bookmark folder"), SLOT(newBookmarkFolder(const KBookmark &)), bookmark); + i18n("Create a new bookmark folder"), SLOT(newBookmarkFolder(const KBookmark &)), bookmark); case NEW_SEPARATOR: return createAction(i18n("New Separator"), "edit-clear", - i18n("Create a new bookmark separator"), SLOT(newSeparator(const KBookmark &)), bookmark); + i18n("Create a new bookmark separator"), SLOT(newSeparator(const KBookmark &)), bookmark); case COPY: return createAction(i18n("Copy Link"), "edit-copy", - i18n("Copy the bookmark's link address"), SLOT(copyLink(const KBookmark &)), bookmark); + i18n("Copy the bookmark's link address"), SLOT(copyLink(const KBookmark &)), bookmark); case EDIT: return createAction(i18n("Edit"), "configure", - i18n("Edit the bookmark"), SLOT(editBookmark(const KBookmark &)), bookmark); + i18n("Edit the bookmark"), SLOT(editBookmark(const KBookmark &)), bookmark); case DELETE: - return createAction(i18n("Delete"), "edit-delete", - i18n("Delete the bookmark"), SLOT(deleteBookmark(const KBookmark &)), bookmark); + return createAction(i18n("Delete"), "edit-delete", + i18n("Delete the bookmark"), SLOT(deleteBookmark(const KBookmark &)), bookmark); default: - return 0; + return 0; } } diff --git a/src/bookmarks/bookmarkowner.h b/src/bookmarks/bookmarkowner.h index 16fc111f..918e25d1 100644 --- a/src/bookmarks/bookmarkowner.h +++ b/src/bookmarks/bookmarkowner.h @@ -79,7 +79,10 @@ public: virtual QList< QPair > currentBookmarkList() const; // @} - virtual bool supportsTabs() const {return true;} + virtual bool supportsTabs() const + { + return true; + } // @{ /** diff --git a/src/bookmarks/bookmarkprovider.cpp b/src/bookmarks/bookmarkprovider.cpp index d58fd29a..6d7a6440 100644 --- a/src/bookmarks/bookmarkprovider.cpp +++ b/src/bookmarks/bookmarkprovider.cpp @@ -199,7 +199,7 @@ void BookmarkProvider::slotBookmarksChanged() fillBookmarkBar(bookmarkToolBar); } } - if(rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks")) + if (rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks")) rApp->loadUrl(KUrl("about:bookmarks"), Rekonq::CurrentTab); } @@ -232,7 +232,7 @@ void BookmarkProvider::fillBookmarkBar(BookmarkToolBar *toolBar) else { KBookmarkAction *action = new KBookmarkAction(bookmark, m_owner, this); - action->setIcon(rApp->iconManager()->iconForUrl( KUrl(bookmark.url()) )); + action->setIcon(rApp->iconManager()->iconForUrl(KUrl(bookmark.url()))); connect(action, SIGNAL(hovered()), toolBar, SLOT(actionHovered())); toolBar->toolBar()->addAction(action); toolBar->toolBar()->widgetForAction(action)->installEventFilter(toolBar); @@ -243,12 +243,12 @@ void BookmarkProvider::fillBookmarkBar(BookmarkToolBar *toolBar) void BookmarkProvider::slotPanelChanged() { - foreach (BookmarksPanel *panel, m_bookmarkPanels) + foreach(BookmarksPanel *panel, m_bookmarkPanels) { if (panel && panel != sender()) panel->loadFoldedState(); } - if(rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks")) + if (rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks")) rApp->loadUrl(KUrl("about:bookmarks"), Rekonq::CurrentTab); } @@ -265,10 +265,10 @@ void BookmarkProvider::find(QList *list, const KBookmark &bookmark, c { QStringList words = text.split(' '); bool matches = true; - foreach (const QString &word, words) + foreach(const QString &word, words) { if (!bookmark.url().url().contains(word, Qt::CaseInsensitive) - && !bookmark.fullText().contains(word, Qt::CaseInsensitive)) + && !bookmark.fullText().contains(word, Qt::CaseInsensitive)) { matches = false; break; diff --git a/src/bookmarks/bookmarkprovider.h b/src/bookmarks/bookmarkprovider.h index 3e63bd2f..e0dee7a5 100644 --- a/src/bookmarks/bookmarkprovider.h +++ b/src/bookmarks/bookmarkprovider.h @@ -106,9 +106,15 @@ public: */ KBookmarkGroup rootGroup(); - inline KBookmarkManager* bookmarkManager() { return m_manager; } + inline KBookmarkManager* bookmarkManager() + { + return m_manager; + } - inline BookmarkOwner* bookmarkOwner() { return m_owner; } + inline BookmarkOwner* bookmarkOwner() + { + return m_owner; + } QList find(const QString &text); @@ -128,7 +134,7 @@ public Q_SLOTS: private Q_SLOTS: void slotPanelChanged(); - + Q_SIGNALS: /** * @short This signal is emitted when an url has to be loaded diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index a7d6daf8..94a3de94 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -74,7 +74,7 @@ void BookmarksPanel::contextMenu(const QPoint &pos) if (_loadingState) return; - BookmarksContextMenu menu(bookmarkForIndex( panelTreeView()->indexAt(pos) ), + BookmarksContextMenu menu(bookmarkForIndex(panelTreeView()->indexAt(pos)), rApp->bookmarkProvider()->bookmarkManager(), rApp->bookmarkProvider()->bookmarkOwner() ); @@ -129,7 +129,7 @@ void BookmarksPanel::setup() void BookmarksPanel::loadFoldedState(const QModelIndex &root) { QAbstractItemModel *model = panelTreeView()->model(); - if(!model) + if (!model) return; int count = model->rowCount(root); diff --git a/src/bookmarks/bookmarkspanel.h b/src/bookmarks/bookmarkspanel.h index 2a3942d7..06873b1a 100644 --- a/src/bookmarks/bookmarkspanel.h +++ b/src/bookmarks/bookmarkspanel.h @@ -60,9 +60,18 @@ Q_SIGNALS: private Q_SLOTS: void contextMenu(const QPoint &pos); - virtual void contextMenuItem (const QPoint &pos) {contextMenu(pos);} - virtual void contextMenuGroup (const QPoint &pos) {contextMenu(pos);} - virtual void contextMenuEmpty (const QPoint &pos) {contextMenu(pos);} + virtual void contextMenuItem(const QPoint &pos) + { + contextMenu(pos); + } + virtual void contextMenuGroup(const QPoint &pos) + { + contextMenu(pos); + } + virtual void contextMenuEmpty(const QPoint &pos) + { + contextMenu(pos); + } void deleteBookmark(); void onCollapse(const QModelIndex &index); diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp index 8c19c96f..072f9db7 100644 --- a/src/bookmarks/bookmarkstoolbar.cpp +++ b/src/bookmarks/bookmarkstoolbar.cpp @@ -92,7 +92,7 @@ QAction * BookmarkMenu::actionForBookmark(const KBookmark &bookmark) else { KBookmarkAction *action = new KBookmarkAction(bookmark, owner(), this); - action->setIcon(rApp->iconManager()->iconForUrl( KUrl(bookmark.url()) )); + action->setIcon(rApp->iconManager()->iconForUrl(KUrl(bookmark.url()))); connect(action, SIGNAL(hovered()), this, SLOT(actionHovered())); return action; } @@ -157,12 +157,12 @@ void BookmarkMenu::actionHovered() BookmarkToolBar::BookmarkToolBar(KToolBar *toolBar, QObject *parent) - : QObject(parent) - , m_toolBar(toolBar) - , m_currentMenu(0) - , m_dragAction(0) - , m_dropAction(0) - , m_filled(false) + : QObject(parent) + , m_toolBar(toolBar) + , m_currentMenu(0) + , m_dragAction(0) + , m_dropAction(0) + , m_filled(false) { toolBar->setContextMenuPolicy(Qt::CustomContextMenu); connect(toolBar, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &))); @@ -220,7 +220,7 @@ void BookmarkToolBar::menuHidden() void BookmarkToolBar::hideMenu() { - if(m_currentMenu) + if (m_currentMenu) m_currentMenu->hide(); } @@ -367,7 +367,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) QWidget *widgetAction = toolBar()->widgetForAction(destAction); if (destBookmarkAction && !destBookmarkAction->bookmark().isNull() && widgetAction - && bookmark.address() != destBookmarkAction->bookmark().address()) + && bookmark.address() != destBookmarkAction->bookmark().address()) { KBookmark destBookmark = destBookmarkAction->bookmark(); @@ -430,9 +430,9 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) if (action && action->bookmark().isGroup() && distance < QApplication::startDragDistance()) { - KBookmarkActionMenu *menu = dynamic_cast(toolBar()->actionAt(m_startDragPos)); - QPoint actionPos = toolBar()->mapToGlobal(toolBar()->widgetForAction(menu)->pos()); - menu->menu()->popup(QPoint(actionPos.x(), actionPos.y() + toolBar()->widgetForAction(menu)->height())); + KBookmarkActionMenu *menu = dynamic_cast(toolBar()->actionAt(m_startDragPos)); + QPoint actionPos = toolBar()->mapToGlobal(toolBar()->widgetForAction(menu)->pos()); + menu->menu()->popup(QPoint(actionPos.x(), actionPos.y() + toolBar()->widgetForAction(menu)->height())); } } } diff --git a/src/bookmarks/bookmarkstoolbar.h b/src/bookmarks/bookmarkstoolbar.h index d7d1cee9..83e4605f 100644 --- a/src/bookmarks/bookmarkstoolbar.h +++ b/src/bookmarks/bookmarkstoolbar.h @@ -85,10 +85,10 @@ class BookmarkToolBar : public QObject Q_OBJECT public: -BookmarkToolBar(KToolBar *toolBar, QObject *parent); -~BookmarkToolBar(); + BookmarkToolBar(KToolBar *toolBar, QObject *parent); + ~BookmarkToolBar(); -KToolBar* toolBar(); + KToolBar* toolBar(); protected: bool eventFilter(QObject *watched, QEvent *event); diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp index 0478a714..8d82e2b0 100644 --- a/src/bookmarks/bookmarkstreemodel.cpp +++ b/src/bookmarks/bookmarkstreemodel.cpp @@ -334,20 +334,20 @@ void BookmarksTreeModel::bookmarksChanged(const QString &groupAddress) BtmItem *node = m_root; QModelIndex nodeIndex; - QStringList indexChain( groupAddress.split('/', QString::SkipEmptyParts) ); + QStringList indexChain(groupAddress.split('/', QString::SkipEmptyParts)); bool ok; int i; - foreach (const QString &sIndex, indexChain) + foreach(const QString &sIndex, indexChain) { - i = sIndex.toInt( &ok ); - if( !ok ) + i = sIndex.toInt(&ok); + if (!ok) break; - if( i < 0 || i >= node->childCount() ) + if (i < 0 || i >= node->childCount()) break; - node = node->child( i ); - nodeIndex = index( i, 0, nodeIndex ); + node = node->child(i); + nodeIndex = index(i, 0, nodeIndex); } populate(node, rApp->bookmarkProvider()->bookmarkManager()->findByAddress(groupAddress).toGroup()); endResetModel(); diff --git a/src/filterurljob.cpp b/src/filterurljob.cpp index cf35a497..65eab8cc 100644 --- a/src/filterurljob.cpp +++ b/src/filterurljob.cpp @@ -39,7 +39,7 @@ FilterUrlJob::FilterUrlJob(WebView *view, const QString &urlString, QObject *par , _view(view) , _urlString(urlString) { - if(!s_uriFilter) + if (!s_uriFilter) s_uriFilter = KUriFilter::self(); } diff --git a/src/findbar.cpp b/src/findbar.cpp index a7c86816..c1f170cd 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -162,7 +162,7 @@ void FindBar::setVisible(bool visible) m_mainWindow->findNext(); return; } - + QWidget::setVisible(visible); if (visible) @@ -171,12 +171,12 @@ void FindBar::setVisible(bool visible) if (!hasFocus() && !selectedText.isEmpty()) { const QString previousText = m_lineEdit->text(); - m_lineEdit->setText(selectedText); + m_lineEdit->setText(selectedText); - if (m_lineEdit->text() != previousText) - m_mainWindow->findPrevious(); - else - m_mainWindow->updateHighlight();; + if (m_lineEdit->text() != previousText) + m_mainWindow->findPrevious(); + else + m_mainWindow->updateHighlight();; } else if (selectedText.isEmpty()) { diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp index b6096b55..9138ab10 100644 --- a/src/history/historymanager.cpp +++ b/src/history/historymanager.cpp @@ -115,17 +115,17 @@ void HistoryManager::addHistoryEntry(const QString &url) QString checkUrlString = cleanUrl.toString(); HistoryItem item; - + // NOTE // check if the url has just been visited. // if so, remove previous entry from history, update and prepend it - if(historyContains(checkUrlString)) + if (historyContains(checkUrlString)) { int index = m_historyFilterModel->historyLocation(checkUrlString); item = m_history.at(index); m_history.removeOne(item); emit entryRemoved(item); - + item.dateTime = QDateTime::currentDateTime(); item.visitCount++; } @@ -133,10 +133,10 @@ void HistoryManager::addHistoryEntry(const QString &url) { item = HistoryItem(checkUrlString, QDateTime::currentDateTime()); } - + m_history.prepend(item); emit entryAdded(item); - + if (m_history.count() == 1) checkForExpired(); } @@ -195,7 +195,7 @@ void HistoryManager::checkForExpired() } if (nextTimeout > 0) - QTimer::singleShot( nextTimeout * 1000, this, SLOT(checkForExpired()) ); + QTimer::singleShot(nextTimeout * 1000, this, SLOT(checkForExpired())); } @@ -203,15 +203,15 @@ void HistoryManager::updateHistoryEntry(const KUrl &url, const QString &title) { QString urlString = url.url(); urlString.remove(QL1S("www.")); - if(urlString.startsWith(QL1S("http")) && urlString.endsWith(QL1C('/'))) - urlString.remove(urlString.length()-1,1); + if (urlString.startsWith(QL1S("http")) && urlString.endsWith(QL1C('/'))) + urlString.remove(urlString.length() - 1, 1); for (int i = 0; i < m_history.count(); ++i) { QString itemUrl = m_history.at(i).url; itemUrl.remove(QL1S("www.")); - if(itemUrl.startsWith(QL1S("http")) && itemUrl.endsWith(QL1C('/'))) - itemUrl.remove(itemUrl.length()-1,1); + if (itemUrl.startsWith(QL1S("http")) && itemUrl.endsWith(QL1C('/'))) + itemUrl.remove(itemUrl.length() - 1, 1); if (urlString == itemUrl) { @@ -258,10 +258,11 @@ QList HistoryManager::find(const QString &text) QStringList words = text.split(' '); bool matches = true; - foreach (const QString &word, words) + foreach(const QString &word, words) { if (!url.contains(word, Qt::CaseInsensitive) - && !item.title.contains(word, Qt::CaseInsensitive)) { + && !item.title.contains(word, Qt::CaseInsensitive)) + { matches = false; break; } @@ -347,9 +348,9 @@ void HistoryManager::load() buffer.open(QIODevice::ReadOnly); quint32 version; stream >> version; - + HistoryItem item; - + switch (version) { case HISTORY_VERSION: // default case @@ -365,11 +366,11 @@ void HistoryManager::load() stream >> item.title; item.visitCount = 1; break; - + default: continue; }; - + if (!item.dateTime.isValid()) continue; diff --git a/src/history/historymanager.h b/src/history/historymanager.h index 72a1f12a..a7a7661e 100644 --- a/src/history/historymanager.h +++ b/src/history/historymanager.h @@ -70,7 +70,7 @@ public: inline bool operator==(const HistoryItem &other) const { return other.title == title - && other.url == url + && other.url == url && other.dateTime == dateTime; } @@ -120,13 +120,22 @@ public: QList find(const QString &text); - QList history() const { return m_history; }; + QList history() const + { + return m_history; + }; void setHistory(const QList &history, bool loadedAndSorted = false); // History manager keeps around these models for use by the completer and other classes - HistoryFilterModel *historyFilterModel() const { return m_historyFilterModel; }; - HistoryTreeModel *historyTreeModel() const { return m_historyTreeModel; }; - + HistoryFilterModel *historyFilterModel() const + { + return m_historyFilterModel; + }; + HistoryTreeModel *historyTreeModel() const + { + return m_historyTreeModel; + }; + Q_SIGNALS: void historyReset(); void entryAdded(const HistoryItem &item); diff --git a/src/history/historymodels.h b/src/history/historymodels.h index 50689392..8cb1a5dd 100644 --- a/src/history/historymodels.h +++ b/src/history/historymodels.h @@ -65,14 +65,14 @@ public Q_SLOTS: void historyReset(); void entryAdded(); void entryUpdated(int offset); - + public: QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; int rowCount(const QModelIndex &parent = QModelIndex()) const; bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); - + private: HistoryManager *m_historyManager; }; diff --git a/src/iconmanager.cpp b/src/iconmanager.cpp index 1c667c88..579c3015 100644 --- a/src/iconmanager.cpp +++ b/src/iconmanager.cpp @@ -49,7 +49,7 @@ IconManager::IconManager(QObject *parent) - : QObject(parent) + : QObject(parent) { _faviconsDir = KStandardDirs::locateLocal("cache" , "favicons/" , true); } @@ -65,7 +65,7 @@ KIcon IconManager::iconForUrl(const KUrl &url) // first things first.. avoid infinite loop at startup if (url.isEmpty() || rApp->mainWindowList().isEmpty()) return KIcon("text-html"); - + QByteArray encodedUrl = url.toEncoded(); // rekonq icons.. if (encodedUrl == QByteArray("about:home")) @@ -82,18 +82,18 @@ KIcon IconManager::iconForUrl(const KUrl &url) return KIcon("download"); // TODO: return other mimetype icons - if(url.isLocalFile()) + if (url.isLocalFile()) { return KIcon("folder"); } - + QString i = KMimeType::favIconForUrl(url); - if(!i.isEmpty()) + if (!i.isEmpty()) { QString faviconDir = KStandardDirs::locateLocal("cache" , "" , true); return KIcon(faviconDir + i); } - + kDebug() << "Icon NOT Found for url: " << url; return KIcon("text-html"); } @@ -102,63 +102,63 @@ KIcon IconManager::iconForUrl(const KUrl &url) void IconManager::provideIcon(QWebPage *page, const KUrl &url, bool notify) { // provide icons just for http/https sites - if( !url.scheme().startsWith(QL1S("http")) ) + if (!url.scheme().startsWith(QL1S("http"))) { kDebug() << "No http/https site..."; - if(notify) + if (notify) emit iconChanged(); return; } // do not load new icons in private browsing.. - if(QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + if (QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) { kDebug() << "Private browsing, private icon..."; - if(notify) + if (notify) emit iconChanged(); return; } - + // check if icon exists - if(!KMimeType::favIconForUrl(url).isEmpty()) + if (!KMimeType::favIconForUrl(url).isEmpty()) { kDebug() << "icon JUST present. Aborting..."; - if(notify) + if (notify) emit iconChanged(); return; } // the simplest way.. - const QString rootUrlString = url.scheme() + QL1S("://") + url.host(); + const QString rootUrlString = url.scheme() + QL1S("://") + url.host(); // find favicon url - KUrl faviconUrl( rootUrlString + QL1S("/favicon.ico") ); + KUrl faviconUrl(rootUrlString + QL1S("/favicon.ico")); QWebElement root = page->mainFrame()->documentElement(); QWebElement e = root.findFirst(QL1S("link[rel~=\"icon\"]")); QString relUrlString = e.attribute(QL1S("href")); - if(relUrlString.isEmpty()) + if (relUrlString.isEmpty()) { e = root.findFirst(QL1S("link[rel~=\"shortcut icon\"]")); - relUrlString = e.attribute(QL1S("href")); + relUrlString = e.attribute(QL1S("href")); } - if(!relUrlString.isEmpty()) + if (!relUrlString.isEmpty()) { faviconUrl = relUrlString.startsWith(QL1S("http")) - ? KUrl(relUrlString) - : KUrl(rootUrlString + QL1C('/') + relUrlString) ; + ? KUrl(relUrlString) + : KUrl(rootUrlString + QL1C('/') + relUrlString) ; } kDebug() << "ICON URL: " << faviconUrl; // dest url - KUrl destUrl(_faviconsDir + url.host() + QL1S(".png") ); + KUrl destUrl(_faviconsDir + url.host() + QL1S(".png")); kDebug() << "DEST URL: " << destUrl; // download icon KIO::FileCopyJob *job = KIO::file_copy(faviconUrl, destUrl, -1, KIO::HideProgressInfo); - if(notify) + if (notify) connect(job, SIGNAL(result(KJob*)), this, SLOT(notifyLastStuffs(KJob *))); else connect(job, SIGNAL(result(KJob*)), this, SLOT(doLastStuffs(KJob *))); @@ -184,47 +184,47 @@ void IconManager::clearIconCache() void IconManager::doLastStuffs(KJob *j) { - if(j->error()) + if (j->error()) { kDebug() << "FAVICON JOB ERROR"; return; } - + KIO::FileCopyJob *job = static_cast(j); KUrl dest = job->destUrl(); - QString s = dest.url().remove( QL1S("file://") ); + QString s = dest.url().remove(QL1S("file://")); QFile fav(s); - if(!fav.exists()) + if (!fav.exists()) { kDebug() << "FAVICON DOES NOT EXISTS"; fav.remove(); return; } - - if(fav.size() == 0) + + if (fav.size() == 0) { kDebug() << "SIZE ZERO FAVICON"; fav.remove(); return; } - + QPixmap px; - if(!px.load(s)) + if (!px.load(s)) { kDebug() << "PIXMAP NOT LOADED"; return; } - - if(px.isNull()) + + if (px.isNull()) { kDebug() << "PIXMAP IS NULL"; fav.remove(); return; } - - px = px.scaled(16,16); - if(!px.save(s)) + + px = px.scaled(16, 16); + if (!px.save(s)) { kDebug() << "PIXMAP NOT SAVED"; return; diff --git a/src/iconmanager.h b/src/iconmanager.h index c35ae345..6836175e 100644 --- a/src/iconmanager.h +++ b/src/iconmanager.h @@ -58,10 +58,10 @@ public: private Q_SLOTS: void doLastStuffs(KJob *); void notifyLastStuffs(KJob *); - + Q_SIGNALS: void iconChanged(); - + private: bool existsIconForUrl(const KUrl &url); diff --git a/src/main.cpp b/src/main.cpp index 2736bf2d..d2d6482f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -119,15 +119,15 @@ extern "C" KDE_EXPORT int kdemain(int argc, char **argv) "http://www.openyourcode.org/"); about.addAuthor(ki18n("Pierre Rossi"), - ki18n("Urlbar, tests, new tab page, bars... and more"), - "pierre.rossi@gmail.com", - ""); - + ki18n("Urlbar, tests, new tab page, bars... and more"), + "pierre.rossi@gmail.com", + ""); + about.addAuthor(ki18n("Furkan Uzumcu"), - ki18n("A lot of improvements, especially on usability"), - "furkanuzumcu@gmail.com", - ""); - + ki18n("A lot of improvements, especially on usability"), + "furkanuzumcu@gmail.com", + ""); + // --------------- about credits ----------------------------- about.addCredit(ki18n("Dawit Alemayehu"), ki18n("KDEWebKit (main) developer. And KIO. And KUriFilter. And more.."), diff --git a/src/mainview.cpp b/src/mainview.cpp index fec31d73..4ab7a8a3 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -58,11 +58,11 @@ MainView::MainView(MainWindow *parent) - : KTabWidget(parent) - , m_widgetBar(new StackedUrlBar(this)) - , m_addTabButton(0) - , m_currentTabIndex(0) - , m_parentWindow(parent) + : KTabWidget(parent) + , m_widgetBar(new StackedUrlBar(this)) + , m_addTabButton(0) + , m_currentTabIndex(0) + , m_parentWindow(parent) { // setting tabbar TabBar *tabBar = new TabBar(this); @@ -101,7 +101,7 @@ void MainView::postLaunch() QStringList list = rApp->sessionManager()->closedSites(); Q_FOREACH(const QString &line, list) { - if(line.startsWith( QL1S("about") )) + if (line.startsWith(QL1S("about"))) break; QString title = line; QString url = title; @@ -147,9 +147,9 @@ void MainView::updateTabBar() { tabBar()->show(); } - + // this to ensure tab button visibility also on new window creation - if(m_addTabButton->isHidden()) + if (m_addTabButton->isHidden()) { m_addTabButton->show(); } @@ -266,7 +266,7 @@ void MainView::currentChanged(int index) tab->view()->setFocus(); tabBar()->resetTabHighlighted(index); - + emit tabsChanged(); } @@ -301,7 +301,7 @@ WebTab *MainView::newWebTab(bool focused) connect(tab->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); connect(tab->page(), SIGNAL(printRequested(QWebFrame *)), this, SIGNAL(printRequested(QWebFrame *))); - if ( ReKonfig::openTabsNearCurrent() ) + if (ReKonfig::openTabsNearCurrent()) { insertTab(currentIndex() + 1, tab, i18n("(Untitled)")); m_widgetBar->insertWidget(currentIndex() + 1, tab->urlBar()); @@ -319,11 +319,11 @@ WebTab *MainView::newWebTab(bool focused) } else { - // if tab is not focused, + // if tab is not focused, // current index doesn't change... emit tabsChanged(); } - + return tab; } @@ -425,7 +425,7 @@ void MainView::closeTab(int index, bool del) { WebView *w = currentWebTab()->view(); - if( currentWebTab()->url().protocol() == QL1S("about") ) + if (currentWebTab()->url().protocol() == QL1S("about")) return; switch (ReKonfig::newTabsBehaviour()) @@ -465,7 +465,7 @@ void MainView::closeTab(int index, bool del) } if (!tabToClose->url().isEmpty() - && !QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled) + && !QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled) ) { const int recentlyClosedTabsLimit = 10; @@ -481,7 +481,7 @@ void MainView::closeTab(int index, bool del) removeTab(index); updateTabBar(); // UI operation: do it ASAP!! - m_widgetBar->removeWidget( tabToClose->urlBar() ); + m_widgetBar->removeWidget(tabToClose->urlBar()); m_widgetBar->setCurrentIndex(m_currentTabIndex); if (del) @@ -490,7 +490,7 @@ void MainView::closeTab(int index, bool del) } // if tab was not focused, current index does not change... - if(index != currentIndex()) + if (index != currentIndex()) emit tabsChanged(); } @@ -567,7 +567,7 @@ void MainView::webViewIconChanged() void MainView::webViewTitleChanged(const QString &title) { - QString viewTitle = title.isEmpty()? i18n("(Untitled)") : title; + QString viewTitle = title.isEmpty() ? i18n("(Untitled)") : title; QString tabTitle = viewTitle; tabTitle.replace('&', "&&"); @@ -643,7 +643,7 @@ void MainView::openClosedTab() QString title = action->text(); title = title.remove('&'); - HistoryItem item(action->data().toString(), QDateTime(), title ); + HistoryItem item(action->data().toString(), QDateTime(), title); m_recentlyClosedTabs.removeAll(item); } } @@ -655,9 +655,9 @@ void MainView::switchToTab() QAction *sender = static_cast(QObject::sender()); int index = sender->data().toInt(); index -= 1; // to compensate for off by 1 presented to the user - if( index < 0 || index >= count() ) + if (index < 0 || index >= count()) return; - setCurrentIndex( index ); + setCurrentIndex(index); } @@ -713,7 +713,7 @@ void MainView::detachTab(int index, MainWindow *toWindow) closeTab(index, false); MainWindow *w; - if( toWindow == NULL ) + if (toWindow == NULL) w = rApp->newMainWindow(false); else w = toWindow; diff --git a/src/mainview.h b/src/mainview.h index 8b239325..acc2d8c9 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -67,7 +67,10 @@ class REKONQ_TESTS_EXPORT MainView : public KTabWidget public: MainView(MainWindow *parent); - inline StackedUrlBar *widgetBar() const { return m_widgetBar; } + inline StackedUrlBar *widgetBar() const + { + return m_widgetBar; + } TabBar *tabBar() const; @@ -83,7 +86,10 @@ public: */ void updateTabBar(); - inline QToolButton *addTabButton() const { return m_addTabButton; } + inline QToolButton *addTabButton() const + { + return m_addTabButton; + } /** * This function creates a new empty tab @@ -94,11 +100,14 @@ public: */ WebTab *newWebTab(bool focused = true); - inline QList recentlyClosedTabs() { return m_recentlyClosedTabs; } + inline QList recentlyClosedTabs() + { + return m_recentlyClosedTabs; + } Q_SIGNALS: // tabs change when: - // - current tab change + // - current tab change // - one tab is closed // - one tab is added // - one tab is updated (eg: changes url) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4a798477..b50679a3 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -192,7 +192,7 @@ void MainWindow::setupToolbars() // location bar a = new KAction(i18n("Location Bar"), this); a->setDefaultWidget(m_view->widgetBar()); - actionCollection()->addAction( QL1S("url_bar"), a); + actionCollection()->addAction(QL1S("url_bar"), a); KToolBar *mainBar = toolBar("mainToolBar"); @@ -230,7 +230,7 @@ void MainWindow::configureToolbars() void MainWindow::updateToolsMenu() { - if( m_toolsMenu->isEmpty() ) + if (m_toolsMenu->isEmpty()) { m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Open))); m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::SaveAs))); @@ -239,7 +239,7 @@ void MainWindow::updateToolsMenu() QAction *action = actionByName(KStandardAction::name(KStandardAction::Zoom)); action->setCheckable(true); - connect (m_zoomBar, SIGNAL(visibilityChanged(bool)), action, SLOT(setChecked(bool))); + connect(m_zoomBar, SIGNAL(visibilityChanged(bool)), action, SLOT(setChecked(bool))); m_toolsMenu->addAction(action); m_toolsMenu->addAction(actionByName(QL1S("useragent"))); @@ -257,7 +257,7 @@ void MainWindow::updateToolsMenu() m_developerMenu->addAction(actionByName(QL1S("net_analyzer"))); m_toolsMenu->addAction(m_developerMenu); - if(!ReKonfig::showDeveloperTools()) + if (!ReKonfig::showDeveloperTools()) m_developerMenu->setVisible(false); m_toolsMenu->addSeparator(); @@ -305,7 +305,7 @@ void MainWindow::postLaunch() // (shift +) ctrl + tab switching connect(this, SIGNAL(ctrlTabPressed()), m_view, SLOT(nextTab())); connect(this, SIGNAL(shiftCtrlTabPressed()), m_view, SLOT(previousTab())); - + // wheel history navigation connect(m_view, SIGNAL(openPreviousInHistory()), this, SLOT(openPrevious())); connect(m_view, SIGNAL(openNextInHistory()), this, SLOT(openNext())); @@ -350,7 +350,7 @@ void MainWindow::changeWindowIcon(int index) if (ReKonfig::useFavicon()) { KUrl url = mainView()->webTab(index)->url(); - QIcon icon = rApp->iconManager()->iconForUrl(url).pixmap(QSize(32,32)); + QIcon icon = rApp->iconManager()->iconForUrl(url).pixmap(QSize(32, 32)); setWindowIcon(icon); } } @@ -417,7 +417,7 @@ void MainWindow::setupActions() // set zoom bar actions m_zoomBar->setupActions(this); - + // tab list m_tabListMenu = new KMenu(); m_tabListMenu->addAction("hack"); // necessary to show the menu on the right side the first time @@ -461,7 +461,7 @@ void MainWindow::setupActions() a->setMenu(m_historyForwardMenu); connect(m_historyForwardMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowForwardMenu())); connect(m_historyForwardMenu, SIGNAL(triggered(QAction *)), this, SLOT(openActionUrl(QAction*))); - + // ============================== General Tab Actions ==================================== a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this); a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_T)); @@ -493,17 +493,18 @@ void MainWindow::setupActions() actionCollection()->addAction(QL1S("closed_tab_menu"), closedTabsMenu); // shortcuts for quickly switching to a tab - for( int i = 1; i <= 9; i++ ) { + for (int i = 1; i <= 9; i++) + { a = new KAction(i18n("Switch to Tab %1", i), this); - a->setShortcut(KShortcut( QString("Alt+%1").arg(i) )); - a->setData( QVariant(i) ); + a->setShortcut(KShortcut(QString("Alt+%1").arg(i))); + a->setData(QVariant(i)); actionCollection()->addAction(QL1S(("switch_tab_" + QString::number(i)).toAscii()), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(switchToTab())); } // ============================== Indexed Tab Actions ==================================== a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); - a->setShortcuts( KStandardShortcut::close() ); + a->setShortcuts(KStandardShortcut::close()); actionCollection()->addAction(QL1S("close_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(closeTab())); @@ -528,7 +529,7 @@ void MainWindow::setupActions() bmMenu->setIcon(KIcon("bookmarks")); bmMenu->setDelayed(false); bmMenu->setShortcutConfigurable(true); - bmMenu->setShortcut( KShortcut(Qt::ALT + Qt::Key_B) ); + bmMenu->setShortcut(KShortcut(Qt::ALT + Qt::Key_B)); actionCollection()->addAction(QL1S("bookmarksActionMenu"), bmMenu); // --- User Agent @@ -536,7 +537,7 @@ void MainWindow::setupActions() actionCollection()->addAction(QL1S("useragent"), a); a->setMenu(m_userAgentMenu); connect(m_userAgentMenu, SIGNAL(aboutToShow()), this, SLOT(populateUserAgentMenu())); - + a = new KAction(KIcon("preferences-web-browser-identification"), i18n("Browser Identification"), this); actionCollection()->addAction(QL1S("UserAgentSettings"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(showUserAgentSettings())); @@ -548,10 +549,10 @@ void MainWindow::setupTools() KActionMenu *toolsAction = new KActionMenu(KIcon("configure"), i18n("&Tools"), this); toolsAction->setDelayed(false); toolsAction->setShortcutConfigurable(true); - toolsAction->setShortcut( KShortcut(Qt::ALT + Qt::Key_T) ); + toolsAction->setShortcut(KShortcut(Qt::ALT + Qt::Key_T)); m_toolsMenu = new KMenu(this); toolsAction->setMenu(m_toolsMenu); // dummy menu to have the dropdown arrow - connect( m_toolsMenu, SIGNAL(aboutToShow()), this, SLOT(updateToolsMenu()) ); + connect(m_toolsMenu, SIGNAL(aboutToShow()), this, SLOT(updateToolsMenu())); // adding rekonq_tools to rekonq actionCollection actionCollection()->addAction(QL1S("rekonq_tools"), toolsAction); @@ -611,7 +612,7 @@ void MainWindow::setupPanels() // STEP 4 // Setup Network analyzer panel - m_analyzerPanel = new NetworkAnalyzerPanel( i18n("Network Analyzer"), this); + m_analyzerPanel = new NetworkAnalyzerPanel(i18n("Network Analyzer"), this); connect(mainView(), SIGNAL(currentChanged(int)), m_analyzerPanel, SLOT(changeCurrentPage())); a = new KAction(KIcon("document-edit-decrypt-verify"), i18n("Network Analyzer"), this); @@ -625,7 +626,7 @@ void MainWindow::setupPanels() void MainWindow::openLocation() { - if(isFullScreen()) + if (isFullScreen()) { setWidgetsVisible(true); } @@ -638,7 +639,7 @@ void MainWindow::fileSaveAs() { WebTab *w = currentTab(); KUrl srcUrl = w->url(); - + // First, try with suggested file name... QString name = w->page()->suggestedFileName(); @@ -647,17 +648,17 @@ void MainWindow::fileSaveAs() { name = srcUrl.fileName(); } - + // Last chance... - if(name.isEmpty()) + if (name.isEmpty()) { name = srcUrl.host() + QString(".html"); } - + const QString destUrl = KFileDialog::getSaveFileName(name, QString(), this); - if (destUrl.isEmpty()) + if (destUrl.isEmpty()) return; - + KIO::Job *job = KIO::file_copy(srcUrl, KUrl(destUrl), -1, KIO::Overwrite); job->addMetaData("MaxCacheSize", "0"); // Don't store in http cache. job->addMetaData("cache", "cache"); // Use entry from cache if available. @@ -689,7 +690,7 @@ void MainWindow::updateActions() bool rekonqPage = currentTab()->page()->isOnRekonqPage(); QAction *historyBackAction = actionByName(KStandardAction::name(KStandardAction::Back)); - if( rekonqPage && currentTab()->view()->history()->count() > 0 ) + if (rekonqPage && currentTab()->view()->history()->count() > 0) historyBackAction->setEnabled(true); else historyBackAction->setEnabled(currentTab()->view()->history()->canGoBack()); @@ -747,18 +748,18 @@ void MainWindow::printRequested(QWebFrame *frame) if (!currentTab()) return; - if(currentTab()->page()->isOnRekonqPage()) + if (currentTab()->page()->isOnRekonqPage()) { // trigger print part action instead of ours.. KParts::ReadOnlyPart *p = currentTab()->part(); - if(p) + if (p) { KParts::BrowserExtension *ext = p->browserExtension(); - if(ext) + if (ext) { KParts::BrowserExtension::ActionSlotMap *actionSlotMap = KParts::BrowserExtension::actionSlotMapPtr(); - connect(this, SIGNAL(triggerPartPrint()), ext, actionSlotMap->value("print")); + connect(this, SIGNAL(triggerPartPrint()), ext, actionSlotMap->value("print")); emit triggerPartPrint(); return; @@ -812,11 +813,11 @@ void MainWindow::findNext() if (!currentTab()) return; - if(currentTab()->page()->isOnRekonqPage()) + if (currentTab()->page()->isOnRekonqPage()) { // trigger part find action KParts::ReadOnlyPart *p = currentTab()->part(); - if(p) + if (p) { connect(this, SIGNAL(triggerPartFind()), p, SLOT(slotFind())); emit triggerPartFind(); @@ -961,13 +962,13 @@ void MainWindow::viewPageSource() void MainWindow::homePage(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers keyboardModifiers) { KUrl homeUrl = ReKonfig::useNewTabPage() - ? KUrl( QL1S("about:home") ) - : KUrl( ReKonfig::homePage() ); + ? KUrl(QL1S("about:home")) + : KUrl(ReKonfig::homePage()); if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) - rApp->loadUrl( homeUrl, Rekonq::NewTab); + rApp->loadUrl(homeUrl, Rekonq::NewTab); else - currentTab()->view()->load( homeUrl ); + currentTab()->view()->load(homeUrl); } @@ -979,8 +980,8 @@ WebTab *MainWindow::currentTab() const void MainWindow::browserLoading(bool v) { - QAction *stop = actionCollection()->action( QL1S("stop") ); - QAction *reload = actionCollection()->action( QL1S("view_redisplay") ); + QAction *stop = actionCollection()->action(QL1S("stop")); + QAction *reload = actionCollection()->action(QL1S("view_redisplay")); if (v) { disconnect(m_stopReloadAction, SIGNAL(triggered(bool)), reload , SIGNAL(triggered(bool))); @@ -998,7 +999,7 @@ void MainWindow::browserLoading(bool v) m_stopReloadAction->setText(i18n("Reload")); connect(m_stopReloadAction, SIGNAL(triggered(bool)), reload, SIGNAL(triggered(bool))); stop->setEnabled(false); - + updateActions(); } } @@ -1021,7 +1022,7 @@ void MainWindow::openPrevious(Qt::MouseButtons mouseButtons, Qt::KeyboardModifie } } - if(!item) + if (!item) return; if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) @@ -1054,7 +1055,7 @@ void MainWindow::openNext(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers k } } - if(!item) + if (!item) return; if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) @@ -1106,7 +1107,7 @@ bool MainWindow::event(QEvent *event) currentTab()->setFocus(); return true; } - + // if findbar is visible, hide it if (m_findBar->isVisible()) { @@ -1349,7 +1350,7 @@ void MainWindow::aboutToShowForwardMenu() { QWebHistoryItem item = historyList.at(i - 1); KAction *action = new KAction(this); - action->setData(pivot +i + offset); + action->setData(pivot + i + offset); KIcon icon = rApp->iconManager()->iconForUrl(item.url()); action->setIcon(icon); action->setText(item.title()); @@ -1361,11 +1362,12 @@ void MainWindow::aboutToShowForwardMenu() void MainWindow::aboutToShowTabListMenu() { m_tabListMenu->clear(); - for( int i = 0; i < m_view->count(); ++i ){ + for (int i = 0; i < m_view->count(); ++i) + { KAction *action = new KAction(m_view->tabText(i), this); action->setIcon(rApp->iconManager()->iconForUrl(m_view->webTab(i)->url()).pixmap(16, 16)); action->setData(i); - if(mainView()->tabBar()->currentIndex() == i) + if (mainView()->tabBar()->currentIndex() == i) { QFont font = action->font(); font.setBold(true); @@ -1394,7 +1396,7 @@ void MainWindow::openActionUrl(QAction *action) void MainWindow::openActionTab(QAction* action) { int index = action->data().toInt(); - if(index < 0 || index >= m_view->count()) + if (index < 0 || index >= m_view->count()) { kDebug() << "Invalid Index!: " << index; return; @@ -1410,7 +1412,7 @@ void MainWindow::setUserAgent() QString info; QString desc = sender->text(); int uaIndex = sender->data().toInt(); - + KUrl url = currentTab()->url(); UserAgentInfo uaInfo; kDebug() << "SETTING USER AGENT"; @@ -1424,33 +1426,33 @@ void MainWindow::populateUserAgentMenu() kDebug() << "populating user agent menu..."; bool defaultUA = true; KUrl url = currentTab()->url(); - + QAction *a, *defaultAction; - + m_userAgentMenu->clear(); - - defaultAction = new QAction( i18nc("Default rekonq user agent", "Default"), this); + + defaultAction = new QAction(i18nc("Default rekonq user agent", "Default"), this); defaultAction->setData(-1); defaultAction->setCheckable(true); connect(defaultAction, SIGNAL(triggered(bool)), this, SLOT(setUserAgent())); - + m_userAgentMenu->addAction(defaultAction); m_userAgentMenu->addSeparator(); - + UserAgentInfo uaInfo; QStringList UAlist = uaInfo.availableUserAgents(); int uaIndex = uaInfo.uaIndexForHost(currentTab()->url().host()); - + for (int i = 0; i < UAlist.count(); ++i) { QString uaDesc = UAlist.at(i); - + a = new QAction(uaDesc, this); a->setData(i); a->setCheckable(true); - connect(a, SIGNAL(triggered(bool)), this, SLOT(setUserAgent())); - - if(i == uaIndex) + connect(a, SIGNAL(triggered(bool)), this, SLOT(setUserAgent())); + + if (i == uaIndex) { a->setChecked(true); defaultUA = false; @@ -1458,9 +1460,9 @@ void MainWindow::populateUserAgentMenu() m_userAgentMenu->addAction(a); } defaultAction->setChecked(defaultUA); - + m_userAgentMenu->addSeparator(); - m_userAgentMenu->addAction( actionByName("UserAgentSettings") ); + m_userAgentMenu->addAction(actionByName("UserAgentSettings")); } @@ -1474,39 +1476,39 @@ void MainWindow::enableNetworkAnalysis(bool b) bool MainWindow::queryClose() { // this should fux bug 240432 - if(rApp->sessionSaving()) + if (rApp->sessionSaving()) return true; // smooth private browsing mode - if(QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + if (QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) return true; if (m_view->count() > 1) { int answer = KMessageBox::questionYesNoCancel( - this, - i18np("Are you sure you want to close the window?\n" "You have 1 tab open.", - "Are you sure you want to close the window?\n" "You have %1 tabs open.", - m_view->count()), - i18n("Are you sure you want to close the window?"), - KStandardGuiItem::quit(), - KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close")), - KStandardGuiItem::cancel(), - "confirmClosingMultipleTabs" - ); + this, + i18np("Are you sure you want to close the window?\n" "You have 1 tab open.", + "Are you sure you want to close the window?\n" "You have %1 tabs open.", + m_view->count()), + i18n("Are you sure you want to close the window?"), + KStandardGuiItem::quit(), + KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close")), + KStandardGuiItem::cancel(), + "confirmClosingMultipleTabs" + ); switch (answer) { - case KMessageBox::Yes: - // Quit - return true; + case KMessageBox::Yes: + // Quit + return true; - case KMessageBox::No: - // Close only the current tab - m_view->closeTab(); + case KMessageBox::No: + // Close only the current tab + m_view->closeTab(); - default: - return false; + default: + return false; } } return true; @@ -1524,14 +1526,14 @@ void MainWindow::setupBookmarksAndToolsShortcuts() { KToolBar *mainBar = toolBar("mainToolBar"); - QToolButton *bookmarksButton = qobject_cast(mainBar->widgetForAction(actionByName( QL1S("bookmarksActionMenu") ))); - if(bookmarksButton) + QToolButton *bookmarksButton = qobject_cast(mainBar->widgetForAction(actionByName(QL1S("bookmarksActionMenu")))); + if (bookmarksButton) { connect(actionByName(QL1S("bookmarksActionMenu")), SIGNAL(triggered()), bookmarksButton, SLOT(showMenu())); } - QToolButton *toolsButton = qobject_cast(mainBar->widgetForAction(actionByName( QL1S("rekonq_tools") ))); - if(toolsButton) + QToolButton *toolsButton = qobject_cast(mainBar->widgetForAction(actionByName(QL1S("rekonq_tools")))); + if (toolsButton) { connect(actionByName(QL1S("rekonq_tools")), SIGNAL(triggered()), toolsButton, SLOT(showMenu())); } @@ -1547,6 +1549,6 @@ void MainWindow::showUserAgentSettings() UserAgentWidget widget; dialog->setMainWidget(&widget); dialog->exec(); - + dialog->deleteLater(); } diff --git a/src/mainwindow.h b/src/mainwindow.h index c0d047cd..6c2c12be 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -68,8 +68,14 @@ public: MainWindow(); ~MainWindow(); - inline MainView *mainView() const { return m_view; } - inline QAction *actionByName(const QString &name) { return actionCollection()->action(name); } + inline MainView *mainView() const + { + return m_view; + } + inline QAction *actionByName(const QString &name) + { + return actionCollection()->action(name); + } WebTab *currentTab() const; virtual QSize sizeHint() const; @@ -161,7 +167,7 @@ private Q_SLOTS: void aboutToShowBackMenu(); void aboutToShowForwardMenu(); - + void aboutToShowTabListMenu(); void openActionUrl(QAction *action); void openActionTab(QAction *action); @@ -187,14 +193,14 @@ private: NetworkAnalyzerPanel *m_analyzerPanel; KAction *m_stopReloadAction; - + KMenu *m_historyBackMenu; KMenu *m_historyForwardMenu; - + KMenu *m_tabListMenu; KMenu *m_userAgentMenu; - + BookmarkToolBar *m_bookmarksBar; QString m_lastSearch; diff --git a/src/messagebar.cpp b/src/messagebar.cpp index 4a5d019d..5072735b 100644 --- a/src/messagebar.cpp +++ b/src/messagebar.cpp @@ -39,9 +39,9 @@ #include MessageBar::MessageBar(const QString &message, QWidget *parent, QMessageBox::Icon icon, StandardButtons buttons) - : NotificationBar(parent) - , m_icon(0) - , m_text(0) + : NotificationBar(parent) + , m_icon(0) + , m_text(0) { QToolButton *closeButton = new QToolButton(this); closeButton->setAutoRaise(true); @@ -53,7 +53,8 @@ MessageBar::MessageBar(const QString &message, QWidget *parent, QMessageBox::Ico m_icon = new QLabel; QString icon_name; - switch (icon) { + switch (icon) + { case QMessageBox::NoIcon: break; case QMessageBox::Information: @@ -72,31 +73,36 @@ MessageBar::MessageBar(const QString &message, QWidget *parent, QMessageBox::Ico m_icon->setPixmap(KIcon(icon_name).pixmap(int(KIconLoader::SizeSmallMedium))); QPushButton *button; - if (buttons & Ok) { + if (buttons & Ok) + { button = new QPushButton(KIcon("dialog-ok"), i18n("Ok")); connect(button, SIGNAL(clicked()), this, SIGNAL(accepted())); connect(button, SIGNAL(clicked()), this, SLOT(destroy())); m_buttons.append(button); } - if (buttons & Cancel) { + if (buttons & Cancel) + { button = new QPushButton(KIcon("dialog-cancel"), i18n("Cancel")); connect(button, SIGNAL(clicked()), this, SIGNAL(rejected())); connect(button, SIGNAL(clicked()), this, SLOT(destroy())); m_buttons.append(button); } - if (buttons & Yes) { + if (buttons & Yes) + { button = new QPushButton(i18n("Yes")); connect(button, SIGNAL(clicked()), this, SIGNAL(accepted())); connect(button, SIGNAL(clicked()), this, SLOT(destroy())); m_buttons.append(button); } - if (buttons & No) { + if (buttons & No) + { button = new QPushButton(i18n("No")); connect(button, SIGNAL(clicked()), this, SIGNAL(rejected())); connect(button, SIGNAL(clicked()), this, SLOT(destroy())); m_buttons.append(button); } - if (buttons & Continue) { + if (buttons & Continue) + { button = new QPushButton(i18n("Continue")); connect(button, SIGNAL(clicked()), this, SIGNAL(accepted())); connect(button, SIGNAL(clicked()), this, SLOT(destroy())); @@ -109,8 +115,8 @@ MessageBar::MessageBar(const QString &message, QWidget *parent, QMessageBox::Ico layout->addWidget(m_icon); layout->addWidget(m_text); foreach(QPushButton *button, m_buttons) - layout->addWidget(button, 2); - layout->setStretch(2,20); + layout->addWidget(button, 2); + layout->setStretch(2, 20); setLayout(layout); diff --git a/src/messagebar.h b/src/messagebar.h index df8d668a..65313662 100644 --- a/src/messagebar.h +++ b/src/messagebar.h @@ -46,7 +46,8 @@ class REKONQ_TESTS_EXPORT MessageBar : public NotificationBar public: - enum StandardButton { + enum StandardButton + { NoButton = 0x00000000, Ok = 0x00000001, Cancel = 0x00000002, @@ -58,8 +59,8 @@ public: Q_DECLARE_FLAGS(StandardButtons, StandardButton) explicit MessageBar(const QString & message, QWidget *parent - , QMessageBox::Icon icon = QMessageBox::NoIcon - , StandardButtons buttons = NoButton); + , QMessageBox::Icon icon = QMessageBox::NoIcon + , StandardButtons buttons = NoButton); ~MessageBar(); Q_SIGNALS: diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index d781f0b7..9a500cf8 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -91,7 +91,7 @@ QNetworkReply *NetworkAccessManager::createRequest(QNetworkAccessManager::Operat // 1) DeleteOperation // 2) CustomOperation - switch(op) + switch (op) { case QNetworkAccessManager::HeadOperation: break; @@ -106,35 +106,35 @@ QNetworkReply *NetworkAccessManager::createRequest(QNetworkAccessManager::Operat case QNetworkAccessManager::PostOperation: break; - // This particular issue has been solved for KDE Version 4.5.96, - // so we can safely disable this piece of code - #if !KDE_IS_VERSION( 4, 5, 96) + // This particular issue has been solved for KDE Version 4.5.96, + // so we can safely disable this piece of code +#if !KDE_IS_VERSION( 4, 5, 96) case QNetworkAccessManager::DeleteOperation: kDebug() << "DELETE OPERATION..."; reply = QNetworkAccessManager::createRequest(op, req, outgoingData); - if(!reply) + if (!reply) kDebug() << "OOOOOOOOOOOOOOOOOOO DELETE REPLY NULL"; break; case QNetworkAccessManager::CustomOperation: kDebug() << "CUSTOM OPERATION..."; reply = QNetworkAccessManager::createRequest(op, req, outgoingData); - if(!reply) + if (!reply) kDebug() << "OOOOOOOOOOOOOOOOOOO CUSTOM REPLY NULL"; break; - #endif +#endif default: kDebug() << "NON EXTANT CASE..."; break; } - if(!reply) + if (!reply) reply = AccessManager::createRequest(op, req, outgoingData); - if(parentPage && parentPage->hasNetworkAnalyzerEnabled()) - emit networkData( op, req, reply ); + if (parentPage && parentPage->hasNetworkAnalyzerEnabled()) + emit networkData(op, req, reply); return reply; } diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp index 49ae4f32..44b6fc89 100644 --- a/src/newtabpage.cpp +++ b/src/newtabpage.cpp @@ -117,7 +117,7 @@ void NewTabPage::generate(const KUrl &url) if (url.fileName() == QL1S("clear")) { rApp->mainWindow()->actionByName("clear_private_data")->trigger(); - generate( QL1S("about:") + url.directory() ); + generate(QL1S("about:") + url.directory()); return; } if (url == KUrl("about:bookmarks/edit")) @@ -130,7 +130,7 @@ void NewTabPage::generate(const KUrl &url) page->mainFrame()->setHtml(m_html); page->setIsOnRekonqPage(true); - m_root = page->mainFrame()->documentElement().findFirst( QL1S("#content") ); + m_root = page->mainFrame()->documentElement().findFirst(QL1S("#content")); browsingMenu(url); @@ -162,13 +162,13 @@ void NewTabPage::generate(const KUrl &url) title = i18n("Downloads"); } - m_root.document().findFirst( QL1S("title") ).setPlainText(title); + m_root.document().findFirst(QL1S("title")).setPlainText(title); } void NewTabPage::favoritesPage() { - m_root.addClass( QL1S("favorites") ); + m_root.addClass(QL1S("favorites")); const QWebElement add = createLinkItem(i18n("Add Favorite"), QL1S("about:preview/add"), @@ -181,7 +181,7 @@ void NewTabPage::favoritesPage() if (urls.isEmpty()) { - m_root.addClass( QL1S("empty") ); + m_root.addClass(QL1S("empty")); m_root.setPlainText(i18n("You can add a favorite by clicking the \"Add Favorite\" button in the top-right corner of this page")); return; } @@ -207,13 +207,13 @@ void NewTabPage::favoritesPage() QWebElement NewTabPage::emptyPreview(int index) { - QWebElement prev = markup( QL1S(".thumbnail") ); + QWebElement prev = markup(QL1S(".thumbnail")); - prev.findFirst( QL1S(".preview img") ).setAttribute( QL1S("src") , - QL1S("file:///") + KIconLoader::global()->iconPath("insert-image", KIconLoader::Desktop)); - prev.findFirst( QL1S("span a") ).setPlainText(i18n("Set a Preview...")); - prev.findFirst( QL1S("a") ).setAttribute( QL1S("href"), - QL1S("about:preview/modify/") + QVariant(index).toString()); + prev.findFirst(QL1S(".preview img")).setAttribute(QL1S("src") , + QL1S("file:///") + KIconLoader::global()->iconPath("insert-image", KIconLoader::Desktop)); + prev.findFirst(QL1S("span a")).setPlainText(i18n("Set a Preview...")); + prev.findFirst(QL1S("a")).setAttribute(QL1S("href"), + QL1S("about:preview/modify/") + QVariant(index).toString()); setupPreview(prev, index); //hideControls(prev); @@ -224,12 +224,12 @@ QWebElement NewTabPage::emptyPreview(int index) QWebElement NewTabPage::loadingPreview(int index, const KUrl &url) { - QWebElement prev = markup( QL1S(".thumbnail") ); + QWebElement prev = markup(QL1S(".thumbnail")); - prev.findFirst( QL1S(".preview img") ).setAttribute( QL1S("src"), - QL1S("file:///") + KStandardDirs::locate("appdata", "pics/busywidget.gif")); - prev.findFirst( QL1S("span a") ).setPlainText(i18n("Loading Preview...")); - prev.findFirst( QL1S("a") ).setAttribute( QL1S("href"), url.toMimeDataString()); + prev.findFirst(QL1S(".preview img")).setAttribute(QL1S("src"), + QL1S("file:///") + KStandardDirs::locate("appdata", "pics/busywidget.gif")); + prev.findFirst(QL1S("span a")).setPlainText(i18n("Loading Preview...")); + prev.findFirst(QL1S("a")).setAttribute(QL1S("href"), url.toMimeDataString()); setupPreview(prev, index); showControls(prev); @@ -246,13 +246,13 @@ QWebElement NewTabPage::loadingPreview(int index, const KUrl &url) QWebElement NewTabPage::validPreview(int index, const KUrl &url, const QString &title) { - QWebElement prev = markup( QL1S(".thumbnail") ); + QWebElement prev = markup(QL1S(".thumbnail")); QString previewPath = QL1S("file://") + WebSnap::imagePathFromUrl(url); - prev.findFirst( QL1S(".preview img") ).setAttribute( QL1S("src") , previewPath); - prev.findFirst( QL1S("a") ).setAttribute( QL1S("href"), url.toMimeDataString()); - prev.findFirst( QL1S("span a") ).setAttribute( QL1S("href"), url.toMimeDataString()); - prev.findFirst( QL1S("span a") ).setPlainText(checkTitle(title)); + prev.findFirst(QL1S(".preview img")).setAttribute(QL1S("src") , previewPath); + prev.findFirst(QL1S("a")).setAttribute(QL1S("href"), url.toMimeDataString()); + prev.findFirst(QL1S("span a")).setAttribute(QL1S("href"), url.toMimeDataString()); + prev.findFirst(QL1S("span a")).setPlainText(checkTitle(title)); setupPreview(prev, index); showControls(prev); @@ -262,38 +262,38 @@ QWebElement NewTabPage::validPreview(int index, const KUrl &url, const QString & void NewTabPage::hideControls(QWebElement e) { - e.findFirst( QL1S(".remove") ).setStyleProperty( QL1S("visibility"), QL1S("hidden") ); - e.findFirst( QL1S(".modify") ).setStyleProperty( QL1S("visibility"), QL1S("hidden") ); + e.findFirst(QL1S(".remove")).setStyleProperty(QL1S("visibility"), QL1S("hidden")); + e.findFirst(QL1S(".modify")).setStyleProperty(QL1S("visibility"), QL1S("hidden")); } void NewTabPage::showControls(QWebElement e) { - e.findFirst( QL1S(".remove") ).setStyleProperty( QL1S("visibility"), QL1S("visible") ); - e.findFirst( QL1S(".modify") ).setStyleProperty( QL1S("visibility"), QL1S("visible") ); + e.findFirst(QL1S(".remove")).setStyleProperty(QL1S("visibility"), QL1S("visible")); + e.findFirst(QL1S(".modify")).setStyleProperty(QL1S("visibility"), QL1S("visible")); } void NewTabPage::setupPreview(QWebElement e, int index) { - e.findFirst( QL1S(".remove img") ).setAttribute( QL1S("src"), QL1S("file:///") + KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState)); - e.findFirst( QL1S(".remove") ).setAttribute( QL1S("title"), QL1S("Remove favorite")); - e.findFirst( QL1S(".modify img") ).setAttribute( QL1S("src"), QL1S("file:///") + KIconLoader::global()->iconPath("insert-image", KIconLoader::DefaultState)); - e.findFirst( QL1S(".modify") ).setAttribute( QL1S("title"), QL1S("Set new favorite")); + e.findFirst(QL1S(".remove img")).setAttribute(QL1S("src"), QL1S("file:///") + KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState)); + e.findFirst(QL1S(".remove")).setAttribute(QL1S("title"), QL1S("Remove favorite")); + e.findFirst(QL1S(".modify img")).setAttribute(QL1S("src"), QL1S("file:///") + KIconLoader::global()->iconPath("insert-image", KIconLoader::DefaultState)); + e.findFirst(QL1S(".modify")).setAttribute(QL1S("title"), QL1S("Set new favorite")); - e.findFirst( QL1S(".modify") ).setAttribute( QL1S("href"), QL1S("about:preview/modify/") + QVariant(index).toString() ); - e.findFirst( QL1S(".remove") ).setAttribute( QL1S("href"), QL1S("about:preview/remove/") + QVariant(index).toString() ); + e.findFirst(QL1S(".modify")).setAttribute(QL1S("href"), QL1S("about:preview/modify/") + QVariant(index).toString()); + e.findFirst(QL1S(".remove")).setAttribute(QL1S("href"), QL1S("about:preview/remove/") + QVariant(index).toString()); - e.setAttribute( QL1S("id"), QL1S("preview") + QVariant(index).toString()); + e.setAttribute(QL1S("id"), QL1S("preview") + QVariant(index).toString()); } void NewTabPage::snapFinished() { // Update page, but only if open - if (m_root.document().findAll( QL1S("#rekonq-newtabpage") ).count() == 0) + if (m_root.document().findAll(QL1S("#rekonq-newtabpage")).count() == 0) return; - if (m_root.findAll( QL1S(".favorites") ).count() == 0 && m_root.findAll( QL1S(".closedTabs") ).count() == 0) + if (m_root.findAll(QL1S(".favorites")).count() == 0 && m_root.findAll(QL1S(".closedTabs")).count() == 0) return; QStringList urls = ReKonfig::previewUrls(); @@ -306,12 +306,12 @@ void NewTabPage::snapFinished() if (WebSnap::existsImage(url)) { - QWebElement prev = m_root.findFirst( QL1S("#preview") + QVariant(i).toString()); - if (KUrl(prev.findFirst("a").attribute( QL1S("href") )) == url) + QWebElement prev = m_root.findFirst(QL1S("#preview") + QVariant(i).toString()); + if (KUrl(prev.findFirst("a").attribute(QL1S("href"))) == url) { QWebElement newPrev = validPreview(i, url, title); - if (m_root.findAll( QL1S(".closedTabs") ).count() != 0) + if (m_root.findAll(QL1S(".closedTabs")).count() != 0) hideControls(newPrev); prev.replace(newPrev); @@ -374,33 +374,33 @@ void NewTabPage::browsingMenu(const KUrl ¤tUrl) foreach(QWebElement it, navItems) { - const QString aTagString( QL1C('a') ); + const QString aTagString(QL1C('a')); const QString hrefAttributeString(QL1S("href")); if (it.findFirst(aTagString).attribute(hrefAttributeString) == currentUrl.toMimeDataString()) - it.addClass( QL1S("current") ); + it.addClass(QL1S("current")); else if (currentUrl == QL1S("about:home") && it.findFirst(aTagString).attribute(hrefAttributeString) == QL1S("about:favorites")) - it.addClass( QL1S("current") ); - m_root.document().findFirst( QL1S("#navigation") ).appendInside(it); + it.addClass(QL1S("current")); + m_root.document().findFirst(QL1S("#navigation")).appendInside(it); } } void NewTabPage::historyPage() { - m_root.addClass( QL1S("history") ); + m_root.addClass(QL1S("history")); const QWebElement clearData = createLinkItem(i18n("Clear Private Data"), - QL1S("about:history/clear"), - QL1S("edit-clear"), - KIconLoader::Toolbar); - m_root.document().findFirst( QL1S("#actions") ).appendInside(clearData); + QL1S("about:history/clear"), + QL1S("edit-clear"), + KIconLoader::Toolbar); + m_root.document().findFirst(QL1S("#actions")).appendInside(clearData); HistoryTreeModel *model = rApp->historyManager()->historyTreeModel(); if (model->rowCount() == 0) { - m_root.addClass( QL1S("empty") ); + m_root.addClass(QL1S("empty")); m_root.setPlainText(i18n("Your browsing history is empty")); return; } @@ -413,29 +413,29 @@ void NewTabPage::historyPage() QModelIndex index = model->index(i, 0, QModelIndex()); if (model->hasChildren(index)) { - m_root.appendInside(markup( QL1S("h3") )); + m_root.appendInside(markup(QL1S("h3"))); m_root.lastChild().setPlainText(index.data().toString()); for (int j = 0; j < model->rowCount(index); ++j) - { + { QModelIndex son = model->index(j, 0, index); KUrl u = son.data(HistoryModel::UrlStringRole).toUrl(); QString b = faviconsDir + u.host() + QL1S(".png"); - if( QFile::exists(b) ) + if (QFile::exists(b)) icon = QL1S("file://") + b; - + m_root.appendInside(son.data(HistoryModel::DateTimeRole).toDateTime().toString("hh:mm")); - m_root.appendInside( QL1S(" ") ); - m_root.appendInside(markup( QL1S("img") )); - m_root.lastChild().setAttribute( QL1S("src"), icon); - m_root.lastChild().setAttribute( QL1S("width"), QL1S("16")); - m_root.lastChild().setAttribute( QL1S("height"), QL1S("16")); - m_root.appendInside( QL1S(" ") ); - m_root.appendInside(markup( QL1S("a") )); - m_root.lastChild().setAttribute( QL1S("href") , u.url()); + m_root.appendInside(QL1S(" ")); + m_root.appendInside(markup(QL1S("img"))); + m_root.lastChild().setAttribute(QL1S("src"), icon); + m_root.lastChild().setAttribute(QL1S("width"), QL1S("16")); + m_root.lastChild().setAttribute(QL1S("height"), QL1S("16")); + m_root.appendInside(QL1S(" ")); + m_root.appendInside(markup(QL1S("a"))); + m_root.lastChild().setAttribute(QL1S("href") , u.url()); m_root.lastChild().appendInside(son.data().toString()); - m_root.appendInside( QL1S("
") ); + m_root.appendInside(QL1S("
")); } } i++; @@ -446,18 +446,18 @@ void NewTabPage::historyPage() void NewTabPage::bookmarksPage() { - m_root.addClass( QL1S("bookmarks") ); + m_root.addClass(QL1S("bookmarks")); const QWebElement editBookmarks = createLinkItem(i18n("Edit Bookmarks"), - QL1S("about:bookmarks/edit"), - QL1S("bookmarks-organize"), - KIconLoader::Toolbar); - m_root.document().findFirst( QL1S("#actions") ).appendInside(editBookmarks); + QL1S("about:bookmarks/edit"), + QL1S("bookmarks-organize"), + KIconLoader::Toolbar); + m_root.document().findFirst(QL1S("#actions")).appendInside(editBookmarks); KBookmarkGroup bookGroup = rApp->bookmarkProvider()->rootGroup(); if (bookGroup.isNull()) { - m_root.addClass( QL1S("empty") ); + m_root.addClass(QL1S("empty")); m_root.setPlainText(i18n("You have no bookmarks")); return; } @@ -479,9 +479,9 @@ void NewTabPage::createBookItem(const KBookmark &bookmark, QWebElement parent) { KBookmarkGroup group = bookmark.toGroup(); KBookmark bm = group.first(); - parent.appendInside(markup( QL1S("h3") )); + parent.appendInside(markup(QL1S("h3"))); parent.lastChild().setPlainText(group.fullText()); - parent.appendInside(markup( QL1S(".bookfolder") )); + parent.appendInside(markup(QL1S(".bookfolder"))); while (!bm.isNull()) { createBookItem(bm, parent.lastChild()); // it is .bookfolder @@ -490,36 +490,36 @@ void NewTabPage::createBookItem(const KBookmark &bookmark, QWebElement parent) } else if (bookmark.isSeparator()) { - parent.appendInside( QL1S("
") ); + parent.appendInside(QL1S("
")); } else { QString b = bookmark.icon(); - if(b.contains( QL1S("favicons") )) + if (b.contains(QL1S("favicons"))) icon = cacheDir + bookmark.icon() + QL1S(".png"); - - parent.appendInside(markup( QL1S("img") )); - parent.lastChild().setAttribute( QL1S("src") , icon); - parent.lastChild().setAttribute( QL1S("width") , QL1S("16")); - parent.lastChild().setAttribute( QL1S("height") , QL1S("16")); - parent.appendInside( QL1S(" ") ); - parent.appendInside(markup( QL1S("a") )); - parent.lastChild().setAttribute( QL1S("href") , bookmark.url().prettyUrl()); + + parent.appendInside(markup(QL1S("img"))); + parent.lastChild().setAttribute(QL1S("src") , icon); + parent.lastChild().setAttribute(QL1S("width") , QL1S("16")); + parent.lastChild().setAttribute(QL1S("height") , QL1S("16")); + parent.appendInside(QL1S(" ")); + parent.appendInside(markup(QL1S("a"))); + parent.lastChild().setAttribute(QL1S("href") , bookmark.url().prettyUrl()); parent.lastChild().setPlainText(bookmark.fullText()); - parent.appendInside( QL1S("
") ); + parent.appendInside(QL1S("
")); } } void NewTabPage::closedTabsPage() { - m_root.addClass( QL1S("closedTabs") ); + m_root.addClass(QL1S("closedTabs")); QList links = rApp->mainWindow()->mainView()->recentlyClosedTabs(); if (links.isEmpty()) { - m_root.addClass( QL1S("empty") ); + m_root.addClass(QL1S("empty")); m_root.setPlainText(i18n("There are no recently closed tabs")); return; } @@ -536,7 +536,7 @@ void NewTabPage::closedTabsPage() ? validPreview(i, item.url, item.title) : loadingPreview(i, item.url); - prev.setAttribute( QL1S("id"), QL1S("preview") + QVariant(i).toString()); + prev.setAttribute(QL1S("id"), QL1S("preview") + QVariant(i).toString()); hideControls(prev); m_root.appendInside(prev); } @@ -557,29 +557,29 @@ QString NewTabPage::checkTitle(const QString &title) void NewTabPage::downloadsPage() { - m_root.addClass( QL1S("downloads") ); + m_root.addClass(QL1S("downloads")); const QWebElement clearData = createLinkItem(i18n("Clear Private Data"), - QL1S("about:downloads/clear"), - QL1S("edit-clear"), - KIconLoader::Toolbar); - m_root.document().findFirst( QL1S("#actions") ).appendInside(clearData); + QL1S("about:downloads/clear"), + QL1S("edit-clear"), + KIconLoader::Toolbar); + m_root.document().findFirst(QL1S("#actions")).appendInside(clearData); DownloadList list = rApp->downloads(); if (list.isEmpty()) { - m_root.addClass( QL1S("empty") ); + m_root.addClass(QL1S("empty")); m_root.setPlainText(i18n("There are no recently downloaded files to show")); return; } foreach(const DownloadItem &item, list) { - m_root.prependInside(markup( QL1S("div") )); + m_root.prependInside(markup(QL1S("div"))); QWebElement div = m_root.firstChild(); - div.addClass( QL1S("download") ); + div.addClass(QL1S("download")); KUrl u = KUrl(item.destUrlString); QString fName = u.fileName(); @@ -589,25 +589,25 @@ void NewTabPage::downloadsPage() KIconLoader *loader = KIconLoader::global(); QString iconPath = QL1S("file://") + loader->iconPath(KMimeType::iconNameForUrl(u), KIconLoader::Desktop); - div.appendInside(markup( QL1S("img") )); - div.lastChild().setAttribute( QL1S("src"), iconPath); + div.appendInside(markup(QL1S("img"))); + div.lastChild().setAttribute(QL1S("src"), iconPath); - div.appendInside( QL1S("") + fName + QL1S("") ); - div.appendInside( QL1S(" - ") ); + div.appendInside(QL1S("") + fName + QL1S("")); + div.appendInside(QL1S(" - ")); QString date = KGlobal::locale()->formatDateTime(item.dateTime, KLocale::FancyLongDate); - div.appendInside( QL1S("") + date + QL1S("") ); - div.appendInside( QL1S("
") ); + div.appendInside(QL1S("") + date + QL1S("")); + div.appendInside(QL1S("
")); - div.appendInside( QL1S("") ); - div.appendInside( QL1S("
") ); + div.appendInside(QL1S("
")); + div.appendInside(QL1S("
")); - div.appendInside(markup( QL1S("a") )); - div.lastChild().setAttribute( QL1S("href"), dir); + div.appendInside(markup(QL1S("a"))); + div.lastChild().setAttribute(QL1S("href"), dir); div.lastChild().setPlainText(i18n("Open directory")); - div.appendInside( QL1S(" - ") ); - div.appendInside(markup( QL1S("a") )); - div.lastChild().setAttribute( QL1S("href"), file); + div.appendInside(QL1S(" - ")); + div.appendInside(markup(QL1S("a"))); + div.lastChild().setAttribute(QL1S("href"), file); div.lastChild().setPlainText(i18n("Open file")); } } @@ -617,9 +617,9 @@ QWebElement NewTabPage::createLinkItem(const QString &title, const QString &urlS { const KIconLoader * const loader = KIconLoader::global(); - QWebElement nav = markup( QL1S(".link") ); - nav.findFirst( QL1S("a") ).setAttribute( QL1S("href"), urlString); - nav.findFirst( QL1S("img") ).setAttribute( QL1S("src"), QL1S("file://") + loader->iconPath(iconPath, groupOrSize)); - nav.findFirst( QL1S("span") ).appendInside(title); + QWebElement nav = markup(QL1S(".link")); + nav.findFirst(QL1S("a")).setAttribute(QL1S("href"), urlString); + nav.findFirst(QL1S("img")).setAttribute(QL1S("src"), QL1S("file://") + loader->iconPath(iconPath, groupOrSize)); + nav.findFirst(QL1S("span")).appendInside(title); return nav; } diff --git a/src/notificationbar.cpp b/src/notificationbar.cpp index 7e4ed29c..78bdd004 100644 --- a/src/notificationbar.cpp +++ b/src/notificationbar.cpp @@ -33,9 +33,9 @@ NotificationBar::NotificationBar(QWidget *parent) - : QWidget(parent) - , m_blinkEffect(new BlinkEffect(this)) - , m_opacityAnimation(new QPropertyAnimation(m_blinkEffect, "opacity")) + : QWidget(parent) + , m_blinkEffect(new BlinkEffect(this)) + , m_opacityAnimation(new QPropertyAnimation(m_blinkEffect, "opacity")) { m_blinkEffect->setOpacity(0); setGraphicsEffect(m_blinkEffect); diff --git a/src/notificationbar.h b/src/notificationbar.h index 2d0e2c3f..4b098584 100644 --- a/src/notificationbar.h +++ b/src/notificationbar.h @@ -44,12 +44,15 @@ class BlinkEffect : public QGraphicsEffect public: BlinkEffect(QObject *parent = 0) - : QGraphicsEffect(parent) - , m_opacity(0) - , m_backgroundColor(QApplication::palette().highlight().color().lighter()) + : QGraphicsEffect(parent) + , m_opacity(0) + , m_backgroundColor(QApplication::palette().highlight().color().lighter()) {} - qreal opacity() const { return m_opacity; } + qreal opacity() const + { + return m_opacity; + } void setOpacity(qreal opacity) { m_opacity = opacity; @@ -59,7 +62,7 @@ public: protected: void draw(QPainter *painter) { - painter->drawPixmap(QPoint(0,0), sourcePixmap()); + painter->drawPixmap(QPoint(0, 0), sourcePixmap()); painter->setOpacity(m_opacity); painter->fillRect(boundingRect(), m_backgroundColor); } diff --git a/src/opensearch/opensearchengine.cpp b/src/opensearch/opensearchengine.cpp index febcebea..dcd0f8b4 100644 --- a/src/opensearch/opensearchengine.cpp +++ b/src/opensearch/opensearchengine.cpp @@ -43,15 +43,15 @@ OpenSearchEngine::OpenSearchEngine(QObject *parent) - : QObject(parent) - , m_parser(0) + : QObject(parent) + , m_parser(0) { } OpenSearchEngine::~OpenSearchEngine() { - if (m_parser) + if (m_parser) { delete m_parser; } @@ -64,10 +64,10 @@ QString OpenSearchEngine::parseTemplate(const QString &searchTerm, const QString // Simple conversion to RFC 3066. language = language.replace(QL1C('_'), QL1C('-')); QString country = language; - country = (country.remove(0, country.indexOf(QL1C('-'))+1)).toLower(); + country = (country.remove(0, country.indexOf(QL1C('-')) + 1)).toLower(); const int firstDashPosition = country.indexOf(QL1C('-')); if (firstDashPosition >= 0) - country = country.mid(firstDashPosition+1); + country = country.mid(firstDashPosition + 1); QString result = searchTemplate; result.replace(QL1S("{count}"), QL1S("20")); @@ -121,7 +121,7 @@ void OpenSearchEngine::setSearchUrlTemplate(const QString &searchUrlTemplate) KUrl OpenSearchEngine::searchUrl(const QString &searchTerm) const { - if (m_searchUrlTemplate.isEmpty()) + if (m_searchUrlTemplate.isEmpty()) { return KUrl(); } @@ -129,7 +129,7 @@ KUrl OpenSearchEngine::searchUrl(const QString &searchTerm) const KUrl retVal = KUrl::fromEncoded(parseTemplate(searchTerm, m_searchUrlTemplate).toUtf8()); QList::const_iterator i; - for ( i = m_searchParameters.constBegin(); i != m_searchParameters.constEnd(); ++i) + for (i = m_searchParameters.constBegin(); i != m_searchParameters.constEnd(); ++i) { retVal.addQueryItem(i->first, parseTemplate(searchTerm, i->second)); } @@ -158,7 +158,7 @@ void OpenSearchEngine::setSuggestionsUrlTemplate(const QString &suggestionsUrlTe KUrl OpenSearchEngine::suggestionsUrl(const QString &searchTerm) const { - if (m_suggestionsUrlTemplate.isEmpty()) + if (m_suggestionsUrlTemplate.isEmpty()) { return KUrl(); } @@ -166,7 +166,7 @@ KUrl OpenSearchEngine::suggestionsUrl(const QString &searchTerm) const KUrl retVal = KUrl::fromEncoded(parseTemplate(searchTerm, m_suggestionsUrlTemplate).toUtf8()); QList::const_iterator i; - for( i = m_suggestionsParameters.constBegin(); i != m_suggestionsParameters.constEnd(); ++i) + for (i = m_suggestionsParameters.constBegin(); i != m_suggestionsParameters.constEnd(); ++i) { retVal.addQueryItem(i->first, parseTemplate(searchTerm, i->second)); } diff --git a/src/opensearch/opensearchengine.h b/src/opensearch/opensearchengine.h index 8b0cf6bf..8194cfb2 100644 --- a/src/opensearch/opensearchengine.h +++ b/src/opensearch/opensearchengine.h @@ -48,7 +48,7 @@ class OpenSearchEngine : public QObject { - Q_OBJECT + Q_OBJECT public: typedef QPair Parameter; diff --git a/src/opensearch/opensearchmanager.cpp b/src/opensearch/opensearchmanager.cpp index a52abf22..0b482409 100644 --- a/src/opensearch/opensearchmanager.cpp +++ b/src/opensearch/opensearchmanager.cpp @@ -54,16 +54,16 @@ #include OpenSearchManager::OpenSearchManager(QObject *parent) - : QObject(parent) - , m_activeEngine(0) - , m_currentJob(0) + : QObject(parent) + , m_activeEngine(0) + , m_currentJob(0) { m_state = IDLE; loadEngines(); } -OpenSearchManager::~OpenSearchManager() +OpenSearchManager::~OpenSearchManager() { qDeleteAll(m_engineCache.values()); m_engineCache.clear(); @@ -79,14 +79,14 @@ void OpenSearchManager::setSearchProvider(const QString &searchProvider) { const QString fileName = KGlobal::dirs()->findResource("data", "rekonq/opensearch/" + trimmedEngineName(searchProvider) + ".xml"); kDebug() << searchProvider << " trimmed name: " << trimmedEngineName(searchProvider) << " file name path: " << fileName; - if (fileName.isEmpty()) + if (fileName.isEmpty()) { kDebug() << "OpenSearch file name empty"; return; } QFile file(fileName); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { kDebug() << "Cannot open opensearch description file: " + fileName; return; @@ -95,11 +95,11 @@ void OpenSearchManager::setSearchProvider(const QString &searchProvider) OpenSearchReader reader; OpenSearchEngine *engine = reader.read(&file); - if (engine) + if (engine) { m_engineCache.insert(searchProvider, engine); } - else + else { return; } @@ -121,7 +121,7 @@ void OpenSearchManager::addOpenSearchEngine(const KUrl &url, const QString &titl m_shortcut = shortcut; - if (m_state != IDLE) + if (m_state != IDLE) { idleJob(); } @@ -135,12 +135,12 @@ void OpenSearchManager::addOpenSearchEngine(const KUrl &url, const QString &titl void OpenSearchManager::requestSuggestion(const QString &searchText) { - if (!m_activeEngine) + if (!m_activeEngine) return; - if (m_state != IDLE) + if (m_state != IDLE) { - // NOTE: + // NOTE: // changing OpenSearchManager behavior // using idleJob here lets opensearchmanager to start another search, while // if we want in any case lets it finish its previous job we can just return here. @@ -180,24 +180,24 @@ void OpenSearchManager::jobFinished(KJob *job) return; // just silently return } - if (m_state == REQ_SUGGESTION) + if (m_state == REQ_SUGGESTION) { const ResponseList suggestionsList = m_activeEngine->parseSuggestion(_typedText, m_jobData); - kDebug() << "Received suggestions in "<< _typedText << " from " << m_activeEngine->name() << ": "; + kDebug() << "Received suggestions in " << _typedText << " from " << m_activeEngine->name() << ": "; Q_FOREACH(const Response &r, suggestionsList) { - kDebug() << r.title; + kDebug() << r.title; } emit suggestionsReceived(_typedText, suggestionsList); idleJob(); return; } - if (m_state == REQ_DESCRIPTION) + if (m_state == REQ_DESCRIPTION) { OpenSearchReader reader; OpenSearchEngine *engine = reader.read(m_jobData); - if (engine) + if (engine) { m_engineCache.insert(engine->name(), engine); m_engines.insert(m_jobUrl, trimmedEngineName(engine->name())); @@ -235,7 +235,7 @@ void OpenSearchManager::jobFinished(KJob *job) emit openSearchEngineAdded(engine->name(), searchUrl, m_shortcut); } - else + else { kFatal() << "Error while adding new open search engine"; } @@ -250,16 +250,16 @@ void OpenSearchManager::loadEngines() QFile file(KStandardDirs::locate("appdata", "opensearch/db_opensearch.json")); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - kDebug() << "opensearch db cannot be read"; - return; + kDebug() << "opensearch db cannot be read"; + return; } QString fileContent = QString::fromUtf8(file.readAll()); QScriptEngine reader; if (!reader.canEvaluate(fileContent)) { - kDebug() << "opensearch db cannot be read"; - return; + kDebug() << "opensearch db cannot be read"; + return; } QScriptValue responseParts = reader.evaluate(fileContent); @@ -268,8 +268,8 @@ void OpenSearchManager::loadEngines() QStringList l; Q_FOREACH(const QVariant &e, list) { - l=e.toStringList(); - m_engines.insert(KUrl(l.first()),l.last()); + l = e.toStringList(); + m_engines.insert(KUrl(l.first()), l.last()); } file.close(); } @@ -280,12 +280,12 @@ void OpenSearchManager::saveEngines() QFile file(KStandardDirs::locateLocal("appdata", "opensearch/db_opensearch.json")); if (!file.open(QIODevice::WriteOnly)) { - kDebug() << "opensearch db cannot be writen"; - return; + kDebug() << "opensearch db cannot be writen"; + return; } QTextStream out(&file); out << "["; - int i=0; + int i = 0; QList urls = m_engines.keys(); Q_FOREACH(const KUrl &url, urls) { @@ -355,7 +355,7 @@ void OpenSearchManager::idleJob() disconnect(m_currentJob); m_currentJob->kill(); } - + m_jobData.clear(); m_state = IDLE; } diff --git a/src/opensearch/opensearchmanager.h b/src/opensearch/opensearchmanager.h index ca969810..a75c765b 100644 --- a/src/opensearch/opensearchmanager.h +++ b/src/opensearch/opensearchmanager.h @@ -45,16 +45,16 @@ class OpenSearchEngine; /** - * This class acts as a proxy between the SearchBar plugin + * This class acts as a proxy between the SearchBar plugin * and the individual suggestion engine. - * This class has a map of all available engines, + * This class has a map of all available engines, * and route the suggestion request to the correct engine. */ class OpenSearchManager : public QObject { Q_OBJECT - enum STATE + enum STATE { REQ_SUGGESTION, REQ_DESCRIPTION, @@ -82,7 +82,7 @@ public: public Q_SLOTS: /** * Ask the specific suggestion engine to request for suggestion for the search text - * + * * @param searchText the text to be queried to the suggestion service */ void requestSuggestion(const QString &searchText); diff --git a/src/opensearch/opensearchreader.cpp b/src/opensearch/opensearchreader.cpp index 4d9130a8..2076338b 100644 --- a/src/opensearch/opensearchreader.cpp +++ b/src/opensearch/opensearchreader.cpp @@ -42,7 +42,7 @@ OpenSearchReader::OpenSearchReader() - : QXmlStreamReader() + : QXmlStreamReader() { } @@ -60,7 +60,7 @@ OpenSearchEngine *OpenSearchReader::read(QIODevice *device) { clear(); - if (!device->isOpen()) + if (!device->isOpen()) { device->open(QIODevice::ReadOnly); } @@ -74,20 +74,20 @@ OpenSearchEngine *OpenSearchReader::read() { OpenSearchEngine *engine = new OpenSearchEngine(); - while (!isStartElement() && !atEnd()) + while (!isStartElement() && !atEnd()) { readNext(); } - if ( name() != QL1S("OpenSearchDescription") - || namespaceUri() != QL1S("http://a9.com/-/spec/opensearch/1.1/") - ) + if (name() != QL1S("OpenSearchDescription") + || namespaceUri() != QL1S("http://a9.com/-/spec/opensearch/1.1/") + ) { raiseError(i18n("The file is not an OpenSearch 1.1 file.")); return engine; } - while (!(isEndElement() && name() == QL1S("OpenSearchDescription")) && !atEnd()) + while (!(isEndElement() && name() == QL1S("OpenSearchDescription")) && !atEnd()) { readNext(); @@ -95,21 +95,21 @@ OpenSearchEngine *OpenSearchReader::read() continue; // ShortName - if (name() == QL1S("ShortName")) + if (name() == QL1S("ShortName")) { engine->setName(readElementText()); continue; } - + // Description - if (name() == QL1S("Description")) + if (name() == QL1S("Description")) { engine->setDescription(readElementText()); continue; } - + // Url - if (name() == QL1S("Url")) + if (name() == QL1S("Url")) { QString type = attributes().value(QL1S("type")).toString(); QString url = attributes().value(QL1S("template")).toString(); @@ -121,11 +121,11 @@ OpenSearchEngine *OpenSearchReader::read() readNext(); - while (!(isEndElement() && name() == QL1S("Url"))) + while (!(isEndElement() && name() == QL1S("Url"))) { - if (!isStartElement() - || (name() != QL1S("Param") - && name() != QL1S("Parameter"))) + if (!isStartElement() + || (name() != QL1S("Param") + && name() != QL1S("Parameter"))) { readNext(); continue; @@ -134,12 +134,12 @@ OpenSearchEngine *OpenSearchReader::read() QString key = attributes().value(QL1S("name")).toString(); QString value = attributes().value(QL1S("value")).toString(); - if (!key.isEmpty() && !value.isEmpty()) + if (!key.isEmpty() && !value.isEmpty()) { parameters.append(OpenSearchEngine::Parameter(key, value)); } - while (!isEndElement()) + while (!isEndElement()) { readNext(); } @@ -152,8 +152,8 @@ OpenSearchEngine *OpenSearchReader::read() } else { - if (engine->suggestionsUrlTemplate().isEmpty() - && type == QL1S("application/x-suggestions+json")) //note: xml is preferred + if (engine->suggestionsUrlTemplate().isEmpty() + && type == QL1S("application/x-suggestions+json")) //note: xml is preferred { engine->setSuggestionsUrlTemplate(url); engine->setSuggestionsParameters(parameters); @@ -166,24 +166,24 @@ OpenSearchEngine *OpenSearchReader::read() engine->setSuggestionParser(new XMLParser()); } } - + continue; } - + // Image - if (name() == QL1S("Image")) + if (name() == QL1S("Image")) { - engine->setImageUrl(readElementText()); - continue; + engine->setImageUrl(readElementText()); + continue; } // Engine check - if ( !engine->name().isEmpty() - && !engine->description().isEmpty() - && !engine->suggestionsUrlTemplate().isEmpty() - && !engine->searchUrlTemplate().isEmpty() - && !engine->imageUrl().isEmpty() - ) + if (!engine->name().isEmpty() + && !engine->description().isEmpty() + && !engine->suggestionsUrlTemplate().isEmpty() + && !engine->searchUrlTemplate().isEmpty() + && !engine->imageUrl().isEmpty() + ) { break; } diff --git a/src/opensearch/opensearchwriter.cpp b/src/opensearch/opensearchwriter.cpp index d6649477..d1464275 100644 --- a/src/opensearch/opensearchwriter.cpp +++ b/src/opensearch/opensearchwriter.cpp @@ -37,7 +37,7 @@ OpenSearchWriter::OpenSearchWriter() - : QXmlStreamWriter() + : QXmlStreamWriter() { setAutoFormatting(true); } @@ -63,29 +63,29 @@ void OpenSearchWriter::write(OpenSearchEngine *engine) writeStartElement(QL1S("OpenSearchDescription")); writeDefaultNamespace(QL1S("http://a9.com/-/spec/opensearch/1.1/")); - if (!engine->name().isEmpty()) + if (!engine->name().isEmpty()) { writeTextElement(QL1S("ShortName"), engine->name()); } - if (!engine->description().isEmpty()) + if (!engine->description().isEmpty()) { writeTextElement(QL1S("Description"), engine->description()); } - if (!engine->searchUrlTemplate().isEmpty()) + if (!engine->searchUrlTemplate().isEmpty()) { writeStartElement(QL1S("Url")); writeAttribute(QL1S("method"), QL1S("get")); writeAttribute(QL1S("template"), engine->searchUrlTemplate()); - if (!engine->searchParameters().empty()) + if (!engine->searchParameters().empty()) { writeNamespace(QL1S("http://a9.com/-/spec/opensearch/extensions/parameters/1.0/"), QL1S("p")); QList::const_iterator end = engine->searchParameters().constEnd(); QList::const_iterator i = engine->searchParameters().constBegin(); - for (; i != end; ++i) + for (; i != end; ++i) { writeStartElement(QL1S("p:Parameter")); writeAttribute(QL1S("name"), i->first); @@ -97,20 +97,20 @@ void OpenSearchWriter::write(OpenSearchEngine *engine) writeEndElement(); } - if (!engine->suggestionsUrlTemplate().isEmpty()) + if (!engine->suggestionsUrlTemplate().isEmpty()) { writeStartElement(QL1S("Url")); writeAttribute(QL1S("method"), QL1S("get")); writeAttribute(QL1S("type"), engine->type()); writeAttribute(QL1S("template"), engine->suggestionsUrlTemplate()); - if (!engine->suggestionsParameters().empty()) + if (!engine->suggestionsParameters().empty()) { writeNamespace(QL1S("http://a9.com/-/spec/opensearch/extensions/parameters/1.0/"), QL1S("p")); QList::const_iterator end = engine->suggestionsParameters().constEnd(); QList::const_iterator i = engine->suggestionsParameters().constBegin(); - for (; i != end; ++i) + for (; i != end; ++i) { writeStartElement(QL1S("p:Parameter")); writeAttribute(QL1S("name"), i->first); diff --git a/src/opensearch/searchengine.cpp b/src/opensearch/searchengine.cpp index 5c1d34de..974bcc77 100644 --- a/src/opensearch/searchengine.cpp +++ b/src/opensearch/searchengine.cpp @@ -137,7 +137,7 @@ KService::Ptr SearchEngine::fromString(const QString &text) QString SearchEngine::buildQuery(KService::Ptr engine, const QString &text) { - if(!engine) + if (!engine) return QString(); QString query = engine->property("Query").toString(); query = query.replace("\\{@}", KUrl::toPercentEncoding(text)); diff --git a/src/opensearch/suggestionparser.cpp b/src/opensearch/suggestionparser.cpp index d824f04b..a6619441 100644 --- a/src/opensearch/suggestionparser.cpp +++ b/src/opensearch/suggestionparser.cpp @@ -1,5 +1,5 @@ /* ============================================================ - * + * * This file is a part of the rekonq project * * Copyright (C) 2010-2011 by Lionel Chauvin @@ -55,7 +55,7 @@ ResponseList XMLParser::parse(const QByteArray &resp) { m_reader.readNext(); - if (m_reader.isStartDocument()) + if (m_reader.isStartDocument()) continue; if (m_reader.isStartElement() && m_reader.name() == QL1S("Item")) @@ -64,19 +64,19 @@ ResponseList XMLParser::parse(const QByteArray &resp) QString description; QString url; QString image; - int image_width=0; - int image_height=0; + int image_width = 0; + int image_height = 0; m_reader.readNext(); - while( !(m_reader.isEndElement() && m_reader.name() == QL1S("Item")) ) + while (!(m_reader.isEndElement() && m_reader.name() == QL1S("Item"))) { - if(m_reader.isStartElement()) + if (m_reader.isStartElement()) { - if (m_reader.name() == QL1S("Text")) + if (m_reader.name() == QL1S("Text")) title = m_reader.readElementText(); - if (m_reader.name() == QL1S("Url")) + if (m_reader.name() == QL1S("Url")) url = m_reader.readElementText(); if (m_reader.name() == QL1S("Image")) @@ -86,7 +86,7 @@ ResponseList XMLParser::parse(const QByteArray &resp) image_height = m_reader.attributes().value("height").toString().toInt(); } - if (m_reader.name() == QL1S("Description")) + if (m_reader.name() == QL1S("Description")) description = m_reader.readElementText(); } @@ -112,8 +112,8 @@ ResponseList JSONParser::parse(const QByteArray &resp) } if (!response.startsWith(QL1C('[')) - || !response.endsWith(QL1C(']')) - ) + || !response.endsWith(QL1C(']')) + ) { kDebug() << "RESPONSE is NOT well FORMED"; return ResponseList(); diff --git a/src/opensearch/suggestionparser.h b/src/opensearch/suggestionparser.h index 902793d0..f96061c7 100644 --- a/src/opensearch/suggestionparser.h +++ b/src/opensearch/suggestionparser.h @@ -1,5 +1,5 @@ /* ============================================================ - * + * * This file is a part of the rekonq project * * Copyright (C) 2010-2011 by Lionel Chauvin @@ -50,20 +50,20 @@ public: int image_height; Response(const Response &item) : title(item.title), - description(item.description), - url(item.url), - image(item.image), - image_width(item.image_width), - image_height(item.image_height) + description(item.description), + url(item.url), + image(item.image), + image_width(item.image_width), + image_height(item.image_height) {}; Response() : title(QString()), - description(QString()), - url(QString()), - image(QString()), - image_width(0), - image_height(0) + description(QString()), + url(QString()), + image(QString()), + image_width(0), + image_height(0) {}; @@ -73,11 +73,11 @@ public: const QString &_image = QString(), const int &_image_width = 0, const int &_image_height = 0) : title(_title), - description(_description), - url(_url), - image(_image), - image_width(_image_width), - image_height(_image_height) + description(_description), + url(_url), + image(_image), + image_width(_image_width), + image_height(_image_height) {}; }; @@ -98,13 +98,16 @@ public: class XMLParser : public SuggestionParser -{ +{ protected: QXmlStreamReader m_reader; public: ResponseList parse(const QByteArray &resp); - inline QString type() { return QL1S("application/x-suggestions+xml"); } + inline QString type() + { + return QL1S("application/x-suggestions+xml"); + } }; @@ -112,10 +115,13 @@ class JSONParser : public SuggestionParser { private: QScriptEngine m_reader; - + public: ResponseList parse(const QByteArray &resp); - inline QString type() { return QL1S("application/x-suggestions+json"); } + inline QString type() + { + return QL1S("application/x-suggestions+json"); + } }; #endif //SUGGESTIONPARSER_H diff --git a/src/paneltreeview.cpp b/src/paneltreeview.cpp index 479bf018..23bcd20e 100644 --- a/src/paneltreeview.cpp +++ b/src/paneltreeview.cpp @@ -105,7 +105,7 @@ void PanelTreeView::mouseReleaseEvent(QMouseEvent *event) else if (event->button() == Qt::LeftButton) { if (model()->rowCount(index) == 0) - emit openUrl(qVariantValue< KUrl >(index.data(Qt::UserRole))); + emit openUrl(qVariantValue< KUrl >(index.data(Qt::UserRole))); else setExpanded(index, !isExpanded(index)); } diff --git a/src/previewselectorbar.h b/src/previewselectorbar.h index 6209d82b..424b2420 100644 --- a/src/previewselectorbar.h +++ b/src/previewselectorbar.h @@ -45,7 +45,10 @@ public: PreviewSelectorBar(int index, QWidget *parent); ~PreviewSelectorBar(); - inline void setIndex(int index) { m_previewIndex = index; } + inline void setIndex(int index) + { + m_previewIndex = index; + } private slots: void clicked(); diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index eb303b7b..6a1f1534 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -66,11 +66,11 @@ static bool fileItemListLessThan(const KFileItem &s1, const KFileItem &s2) static KFileItemList sortFileList(const KFileItemList &list) { KFileItemList orderedList, dirList, fileList; - + // order dirs before files.. Q_FOREACH(const KFileItem &item, list) { - if(item.isDir()) + if (item.isDir()) dirList << item; else fileList << item; @@ -80,7 +80,7 @@ static KFileItemList sortFileList(const KFileItemList &list) orderedList << dirList; orderedList << fileList; - + return orderedList; } @@ -90,7 +90,7 @@ static KFileItemList sortFileList(const KFileItemList &list) ProtocolHandler::ProtocolHandler(QObject *parent) : QObject(parent) - , _lister( new KDirLister(this) ) + , _lister(new KDirLister(this)) , _frame(0) { } @@ -118,7 +118,7 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra // rekonq can handle kde documentation protocol if (_url.protocol() == QL1S("man") || _url.protocol() == QL1S("help") || _url.protocol() == QL1S("info")) return false; - + // relative urls if (_url.isRelative()) return false; @@ -127,7 +127,8 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra if (_url.protocol() == QL1S("javascript")) { QString scriptSource = _url.authority(); - if(scriptSource.isEmpty()) { + if (scriptSource.isEmpty()) + { // if javascript: then authority() returns // an empty string. Extract the source manually // Use the prettyUrl() since that is unencoded @@ -136,7 +137,7 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra // fromPercentEncoding() is used to decode all the % encoded // characters to normal, so that it is treated as valid javascript scriptSource = QUrl::fromPercentEncoding(_url.url().mid(11).toAscii()); - if(scriptSource.isEmpty()) + if (scriptSource.isEmpty()) return false; } @@ -190,7 +191,7 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra WebPage *page = qobject_cast(frame->page()); page->setIsOnRekonqPage(true); - + NewTabPage p(frame); p.generate(_url); @@ -198,7 +199,7 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra } // If rekonq cannot handle a protocol by itself, it will hand it over to KDE via KRun - if(KProtocolInfo::isKnownProtocol(_url)) + if (KProtocolInfo::isKnownProtocol(_url)) { new KRun(_url, rApp->mainWindow()); // No need to delete KRun, it autodeletes itself return true; @@ -206,7 +207,7 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra // Error Message, for those protocols even KDE cannot handle KMessageBox::error(rApp->mainWindow(), i18nc("@info", - "rekonq cannot handle this URL. \ + "rekonq cannot handle this URL. \ Please use an appropriate application to open it.")); return false; } diff --git a/src/protocolhandler.h b/src/protocolhandler.h index a82be680..76eeec92 100644 --- a/src/protocolhandler.h +++ b/src/protocolhandler.h @@ -76,7 +76,7 @@ private slots: private: QString dirHandling(const KFileItemList &list); void abpHandling(); - + KDirLister *_lister; QWebFrame *_frame; KUrl _url; diff --git a/src/rekonq_defines.h b/src/rekonq_defines.h index d844bd48..fd0d1e25 100644 --- a/src/rekonq_defines.h +++ b/src/rekonq_defines.h @@ -58,32 +58,32 @@ namespace Rekonq { - /** - * @short notifying message status - * Different message status - */ - - enum Notify - { - Success, ///< url successfully (down)loaded - Error, ///< url failed to (down)load - Download, ///< downloading url - Info, ///< information - Url ///< url string shown (default) - }; - - /** - * @short Open link options - * Different modes of opening new tab - */ - enum OpenType - { - CurrentTab, ///< open url in current tab - NewTab, ///< open url according to users settings - NewFocusedTab, ///< open url in new tab and focus it - NewBackTab, ///< open url in new tab in background - NewWindow ///< open url in new window - }; +/** +* @short notifying message status +* Different message status +*/ + +enum Notify +{ + Success, ///< url successfully (down)loaded + Error, ///< url failed to (down)load + Download, ///< downloading url + Info, ///< information + Url ///< url string shown (default) +}; + +/** +* @short Open link options +* Different modes of opening new tab +*/ +enum OpenType +{ + CurrentTab, ///< open url in current tab + NewTab, ///< open url according to users settings + NewFocusedTab, ///< open url in new tab and focus it + NewBackTab, ///< open url in new tab in background + NewWindow ///< open url in new window +}; } diff --git a/src/sessionmanager.cpp b/src/sessionmanager.cpp index 30ab4b25..65acff77 100644 --- a/src/sessionmanager.cpp +++ b/src/sessionmanager.cpp @@ -111,11 +111,14 @@ bool SessionManager::restoreSession() if (line == QL1S("window")) { line = in.readLine(); - if (windowAlreadyOpen) { - rApp->loadUrl( KUrl(line), Rekonq::CurrentTab); + if (windowAlreadyOpen) + { + rApp->loadUrl(KUrl(line), Rekonq::CurrentTab); windowAlreadyOpen = false; - } else { - rApp->loadUrl( KUrl(line), Rekonq::NewWindow); + } + else + { + rApp->loadUrl(KUrl(line), Rekonq::NewWindow); } } else @@ -138,7 +141,7 @@ bool SessionManager::restoreSession() } else { - rApp->loadUrl( KUrl(line), Rekonq::NewFocusedTab); + rApp->loadUrl(KUrl(line), Rekonq::NewFocusedTab); } } } @@ -168,7 +171,7 @@ QStringList SessionManager::closedSites() line = in.readLine(); if (line != QL1S("window")) { - if(line == QL1S("currenttab")) + if (line == QL1S("currenttab")) { in.readLine(); // drop out the next field, containing the index of the current tab.. } diff --git a/src/sessionmanager.h b/src/sessionmanager.h index 2462f0a0..bb66041c 100644 --- a/src/sessionmanager.h +++ b/src/sessionmanager.h @@ -49,7 +49,10 @@ class REKONQ_TESTS_EXPORT SessionManager : public QObject public: SessionManager(QObject *parent = 0); ~SessionManager(); - inline void setSessionManagementEnabled(bool on) { m_safe = on; } + inline void setSessionManagementEnabled(bool on) + { + m_safe = on; + } QStringList closedSites(); diff --git a/src/settings/appearancewidget.cpp b/src/settings/appearancewidget.cpp index 7700652f..eb486c90 100644 --- a/src/settings/appearancewidget.cpp +++ b/src/settings/appearancewidget.cpp @@ -40,22 +40,22 @@ AppearanceWidget::AppearanceWidget(QWidget *parent) , _changed(false) { setupUi(this); - + fixedFontChooser->setOnlyFixed(true); - - standardFontChooser->setCurrentFont( QFont( ReKonfig::standardFontFamily() ) ); - fixedFontChooser->setCurrentFont( QFont( ReKonfig::fixedFontFamily() ) ); - serifFontChooser->setCurrentFont( QFont( ReKonfig::serifFontFamily() ) ); - sansSerifFontChooser->setCurrentFont( QFont( ReKonfig::sansSerifFontFamily() ) ); - cursiveFontChooser->setCurrentFont( QFont( ReKonfig::cursiveFontFamily() ) ); - fantasyFontChooser->setCurrentFont( QFont( ReKonfig::fantasyFontFamily() ) ); - - connect(standardFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT( hasChanged() )); - connect(fixedFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT( hasChanged() )); - connect(serifFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT( hasChanged() )); - connect(sansSerifFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT( hasChanged() )); - connect(cursiveFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT( hasChanged() )); - connect(fantasyFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT( hasChanged() )); + + standardFontChooser->setCurrentFont(QFont(ReKonfig::standardFontFamily())); + fixedFontChooser->setCurrentFont(QFont(ReKonfig::fixedFontFamily())); + serifFontChooser->setCurrentFont(QFont(ReKonfig::serifFontFamily())); + sansSerifFontChooser->setCurrentFont(QFont(ReKonfig::sansSerifFontFamily())); + cursiveFontChooser->setCurrentFont(QFont(ReKonfig::cursiveFontFamily())); + fantasyFontChooser->setCurrentFont(QFont(ReKonfig::fantasyFontFamily())); + + connect(standardFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(hasChanged())); + connect(fixedFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(hasChanged())); + connect(serifFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(hasChanged())); + connect(sansSerifFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(hasChanged())); + connect(cursiveFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(hasChanged())); + connect(fantasyFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(hasChanged())); populateEncodingMenu(); } @@ -63,12 +63,12 @@ AppearanceWidget::AppearanceWidget(QWidget *parent) void AppearanceWidget::save() { - ReKonfig::setStandardFontFamily( standardFontChooser->currentFont().family() ); - ReKonfig::setFixedFontFamily( fixedFontChooser->currentFont().family() ); - ReKonfig::setSerifFontFamily( serifFontChooser->currentFont().family() ); - ReKonfig::setSansSerifFontFamily( sansSerifFontChooser->currentFont().family() ); - ReKonfig::setCursiveFontFamily( cursiveFontChooser->currentFont().family() ); - ReKonfig::setFantasyFontFamily( fantasyFontChooser->currentFont().family() ); + ReKonfig::setStandardFontFamily(standardFontChooser->currentFont().family()); + ReKonfig::setFixedFontFamily(fixedFontChooser->currentFont().family()); + ReKonfig::setSerifFontFamily(serifFontChooser->currentFont().family()); + ReKonfig::setSansSerifFontFamily(sansSerifFontChooser->currentFont().family()); + ReKonfig::setCursiveFontFamily(cursiveFontChooser->currentFont().family()); + ReKonfig::setFantasyFontFamily(fantasyFontChooser->currentFont().family()); } @@ -101,8 +101,8 @@ void AppearanceWidget::populateEncodingMenu() QStringList encodings = KGlobal::charsets()->availableEncodingNames(); encodingCombo->addItems(encodings); - encodingCombo->setWhatsThis( i18n( "Select the default encoding to be used; normally, you will be fine with 'Use language encoding' " - "and should not have to change this.") ); + encodingCombo->setWhatsThis(i18n("Select the default encoding to be used; normally, you will be fine with 'Use language encoding' " + "and should not have to change this.")); connect(encodingCombo, SIGNAL(activated(const QString &)), this, SLOT(setEncoding(const QString &))); connect(encodingCombo, SIGNAL(activated(const QString &)), this, SLOT(hasChanged())); diff --git a/src/settings/generalwidget.cpp b/src/settings/generalwidget.cpp index dbda5f70..b86e7aec 100644 --- a/src/settings/generalwidget.cpp +++ b/src/settings/generalwidget.cpp @@ -95,7 +95,7 @@ void GeneralWidget::checkKGetPresence() kcfg_kgetDownload->setDisabled(true); kcfg_kgetList->setDisabled(true); kcfg_kgetDownload->setToolTip(i18n("Install KGet to enable rekonq to use KGet as download manager")); - + } else { diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp index 3d5f0a3a..4947d19f 100644 --- a/src/settings/settingsdialog.cpp +++ b/src/settings/settingsdialog.cpp @@ -138,7 +138,7 @@ Private::Private(SettingsDialog *parent) } pageItem->setIcon(wsIcon); - // WARNING + // WARNING // remember wheh changing here that the smallest netbooks // have a 1024x576 resolution. So DON'T bother that limits!! parent->setMinimumSize(700, 525); @@ -229,8 +229,8 @@ bool SettingsDialog::hasChanged() bool SettingsDialog::isDefault() { bool isDef = KConfigDialog::isDefault(); - - if(isDef) + + if (isDef) { // check our private widget values isDef = d->appearanceWidg->isDefault(); diff --git a/src/settings/settingsdialog.h b/src/settings/settingsdialog.h index d48e1f7c..486ce88c 100644 --- a/src/settings/settingsdialog.h +++ b/src/settings/settingsdialog.h @@ -52,7 +52,7 @@ public: protected: virtual bool isDefault(); - + private: Private* const d; diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 7c91783a..ffa15353 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -70,12 +70,12 @@ static inline QByteArray highlightPropertyName(int index) TabBar::TabBar(QWidget *parent) - : KTabBar(parent) - , m_actualIndex(-1) - , m_currentTabPreviewIndex(-1) - , m_isFirstTimeOnTab(true) - , m_tabHighlightEffect(new TabHighlightEffect(this)) - , m_animationMapper(new QSignalMapper(this)) + : KTabBar(parent) + , m_actualIndex(-1) + , m_currentTabPreviewIndex(-1) + , m_isFirstTimeOnTab(true) + , m_tabHighlightEffect(new TabHighlightEffect(this)) + , m_animationMapper(new QSignalMapper(this)) { setElideMode(Qt::ElideRight); @@ -163,9 +163,9 @@ void TabBar::detachTab() void TabBar::showTabPreview() { - if(m_isFirstTimeOnTab) + if (m_isFirstTimeOnTab) m_isFirstTimeOnTab = false; - + //delete previous tab preview delete m_previewPopup.data(); m_previewPopup.clear(); @@ -192,7 +192,7 @@ void TabBar::showTabPreview() m_previewPopup.data()->setFixedSize(w, h); QLabel *l = new QLabel(); - l->setPixmap( WebSnap::renderTabPreview(*indexedTab->page(), w, h) ); + l->setPixmap(WebSnap::renderTabPreview(*indexedTab->page(), w, h)); m_previewPopup.data()->setView(l); m_previewPopup.data()->layout()->setAlignment(Qt::AlignTop); @@ -245,11 +245,11 @@ void TabBar::mouseMoveEvent(QMouseEvent *event) ) { m_currentTabPreviewIndex = tabIndex; - + // if first time over tab, apply a small delay. If not, show it now! m_isFirstTimeOnTab - ? QTimer::singleShot(200, this, SLOT(showTabPreview())) - : showTabPreview(); + ? QTimer::singleShot(200, this, SLOT(showTabPreview())) + : showTabPreview(); } // if current tab or not found then hide previous tab preview @@ -310,18 +310,18 @@ void TabBar::contextMenu(int tab, const QPoint &pos) KMenu menu; MainWindow *mainWindow = rApp->mainWindow(); - menu.addAction(mainWindow->actionByName( QL1S("new_tab") )); - menu.addAction(mainWindow->actionByName( QL1S("clone_tab") )); + menu.addAction(mainWindow->actionByName(QL1S("new_tab"))); + menu.addAction(mainWindow->actionByName(QL1S("clone_tab"))); if (count() > 1) - menu.addAction(mainWindow->actionByName( QL1S("detach_tab") )); - menu.addAction(mainWindow->actionByName( QL1S("open_last_closed_tab") )); - menu.addAction(mainWindow->actionByName( QL1S("closed_tab_menu") )); + menu.addAction(mainWindow->actionByName(QL1S("detach_tab"))); + menu.addAction(mainWindow->actionByName(QL1S("open_last_closed_tab"))); + menu.addAction(mainWindow->actionByName(QL1S("closed_tab_menu"))); menu.addSeparator(); - menu.addAction(mainWindow->actionByName( QL1S("close_tab") )); - menu.addAction(mainWindow->actionByName( QL1S("close_other_tabs") )); + menu.addAction(mainWindow->actionByName(QL1S("close_tab"))); + menu.addAction(mainWindow->actionByName(QL1S("close_other_tabs"))); menu.addSeparator(); - menu.addAction(mainWindow->actionByName( QL1S("reload_tab") )); - menu.addAction(mainWindow->actionByName( QL1S("reload_all_tabs") )); + menu.addAction(mainWindow->actionByName(QL1S("reload_tab"))); + menu.addAction(mainWindow->actionByName(QL1S("reload_all_tabs"))); menu.exec(pos); } @@ -334,16 +334,16 @@ void TabBar::emptyAreaContextMenu(const QPoint &pos) KMenu menu; MainWindow *mainWindow = rApp->mainWindow(); - menu.addAction(mainWindow->actionByName( QL1S("new_tab") )); - menu.addAction(mainWindow->actionByName( QL1S("open_last_closed_tab") )); - menu.addAction(mainWindow->actionByName( QL1S("closed_tab_menu") )); + menu.addAction(mainWindow->actionByName(QL1S("new_tab"))); + menu.addAction(mainWindow->actionByName(QL1S("open_last_closed_tab"))); + menu.addAction(mainWindow->actionByName(QL1S("closed_tab_menu"))); menu.addSeparator(); - menu.addAction(mainWindow->actionByName( QL1S("reload_all_tabs") )); + menu.addAction(mainWindow->actionByName(QL1S("reload_all_tabs"))); KToolBar *mainBar = mainWindow->toolBar("mainToolBar"); - if(!mainBar->isVisible()) + if (!mainBar->isVisible()) { - menu.addAction( mainBar->toggleViewAction() ); + menu.addAction(mainBar->toggleViewAction()); } menu.exec(pos); @@ -370,21 +370,21 @@ void TabBar::setupHistoryActions() MainWindow *w = rApp->mainWindow(); MainView *mv = qobject_cast(parent()); - QAction *openLastClosedTabAction = w->actionByName( QL1S("open_last_closed_tab") ); - openLastClosedTabAction->setEnabled( mv->recentlyClosedTabs().size() > 0 ); + QAction *openLastClosedTabAction = w->actionByName(QL1S("open_last_closed_tab")); + openLastClosedTabAction->setEnabled(mv->recentlyClosedTabs().size() > 0); // update closed tabs menu - KActionMenu *am = qobject_cast( w->actionByName( QL1S("closed_tab_menu") )); + KActionMenu *am = qobject_cast(w->actionByName(QL1S("closed_tab_menu"))); if (!am) return; - bool isEnabled = ( mv->recentlyClosedTabs().size() > 0 ); + bool isEnabled = (mv->recentlyClosedTabs().size() > 0); am->setEnabled(isEnabled); if (am->menu()) am->menu()->clear(); - if(!isEnabled) + if (!isEnabled) return; Q_FOREACH(const HistoryItem &item, mv->recentlyClosedTabs()) @@ -399,9 +399,9 @@ void TabBar::setupHistoryActions() QRect TabBar::tabTextRect(int index) { - QStyleOptionTabV3 option; - initStyleOption(&option, index); - return style()->subElementRect(QStyle::SE_TabBarTabText, &option, this); + QStyleOptionTabV3 option; + initStyleOption(&option, index); + return style()->subElementRect(QStyle::SE_TabBarTabText, &option, this); } diff --git a/src/tabhighlighteffect.cpp b/src/tabhighlighteffect.cpp index fe663167..14cdb6b6 100644 --- a/src/tabhighlighteffect.cpp +++ b/src/tabhighlighteffect.cpp @@ -37,9 +37,9 @@ const QByteArray prep("hAnim"); TabHighlightEffect::TabHighlightEffect(TabBar *tabBar) - : QGraphicsEffect(tabBar) - , m_tabBar(tabBar) - , m_highlightColor(tabBar->palette().highlight().color().lighter()) + : QGraphicsEffect(tabBar) + , m_tabBar(tabBar) + , m_highlightColor(tabBar->palette().highlight().color().lighter()) { Q_ASSERT(m_tabBar); } @@ -47,7 +47,7 @@ TabHighlightEffect::TabHighlightEffect(TabBar *tabBar) void TabHighlightEffect::draw(QPainter *painter) { - painter->drawPixmap(QPoint(0,0), sourcePixmap()); + painter->drawPixmap(QPoint(0, 0), sourcePixmap()); Q_FOREACH(const QByteArray &propertyName, dynamicPropertyNames()) { @@ -59,12 +59,12 @@ void TabHighlightEffect::draw(QPainter *painter) QRect textRect = m_tabBar->tabTextRect(index); QString tabText = m_tabBar->fontMetrics().elidedText(m_tabBar->tabText(index), Qt::ElideRight, - textRect.width(), Qt::TextShowMnemonic); + textRect.width(), Qt::TextShowMnemonic); painter->setOpacity(opacity); painter->setPen(m_highlightColor); painter->drawText(textRect, Qt::AlignCenter | Qt::TextShowMnemonic, tabText); - } + } } diff --git a/src/tabhighlighteffect.h b/src/tabhighlighteffect.h index 269a3315..6deaa285 100644 --- a/src/tabhighlighteffect.h +++ b/src/tabhighlighteffect.h @@ -42,7 +42,7 @@ class TabHighlightEffect : public QGraphicsEffect Q_OBJECT public: - explicit TabHighlightEffect (TabBar *tabBar = 0); + explicit TabHighlightEffect(TabBar *tabBar = 0); protected: virtual void draw(QPainter *painter); diff --git a/src/tests/listitem_test.cpp b/src/tests/listitem_test.cpp index fc0b62ec..08b04e80 100644 --- a/src/tests/listitem_test.cpp +++ b/src/tests/listitem_test.cpp @@ -61,11 +61,11 @@ void ListItemTest::wordHighLighting_data() QTest::addColumn("expected"); QTest::newRow("plan b") << "http://www.google.com/search?q=plan b&ie=UTF-8&oe=UTF-8" - << "plan b" << "http://www.google.com/search?q=plan b&ie=UTF-8&oe=UTF-8"; + << "plan b" << "http://www.google.com/search?q=plan b&ie=UTF-8&oe=UTF-8"; QTest::newRow("plan b #2") << "http://en.wikipedia.org/wiki/Plan_B_(British_musician)" - << "plan b" << "http://en.wikipedia.org/wiki/Plan_B_(British_musician)"; + << "plan b" << "http://en.wikipedia.org/wiki/Plan_B_(British_musician)"; QTest::newRow("i") << "http://i.imgur.com/jacoj.jpg" << "i" - << "http://i.imgur.com/jacoj.jpg"; + << "http://i.imgur.com/jacoj.jpg"; QTest::newRow("i#2") << "KDE - Experience Freedom!" << "i" << "KDE - Experience Freedom!"; QTest::newRow("i#3") << "The WebKit Open Source Project" << "i" << "The WebKit Open Source Project"; QTest::newRow("i#4") << "http://webkit.org/" << "i" << "http://webkit.org/"; @@ -73,7 +73,7 @@ void ListItemTest::wordHighLighting_data() QTest::newRow("b#2") << "rekonq, WebKit KDE browser" << "b" << "rekonq, WebKit KDE browser"; QTest::newRow("<") << "Subject < Section < Wiki" << "<" << "Subject < Section < Wiki"; QTest::newRow("&") << "http://www.google.com/search?q=qt test&ie=UTF-8&oe=UTF-8" << "&" - << "http://www.google.com/search?q=qt test&ie=UTF-8&oe=UTF-8"; + << "http://www.google.com/search?q=qt test&ie=UTF-8&oe=UTF-8"; QTest::newRow("ciao") << "ciao" << "ciao" << "ciao"; QTest::newRow("http://ciao") << "http://ciao" << "ciao" << "http://ciao"; } 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(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(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 "" and "" 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("")); bold = true; - } else if (bold && !boldSections.testBit(i)){ + } + else if (bold && !boldSections.testBit(i)) + { ret.insert(i + 1, QL1S("")); 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 %2", engine, Qt::escape(text) ) ); + setText(i18nc("%1=search engine, e.g. Google, Wikipedia %2=text to search for", "Search %1 for %2", 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(""+item.description+""); + d->setText("" + item.description + ""); } 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; icount(); 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 * Copyright (C) 2010-2011 by Lionel Chauvin * @@ -30,14 +30,14 @@ #include #include - + #include #include #include #include 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 * Copyright (C) 2010-2011 by Lionel Chauvin - * + * * 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 diff --git a/src/urlfilterproxymodel.cpp b/src/urlfilterproxymodel.cpp index ab77a6d1..4aaf09da 100644 --- a/src/urlfilterproxymodel.cpp +++ b/src/urlfilterproxymodel.cpp @@ -39,7 +39,7 @@ UrlFilterProxyModel::UrlFilterProxyModel(QObject *parent) bool UrlFilterProxyModel::filterAcceptsRow(const int source_row, const QModelIndex &source_parent) const { - return recursiveMatch( sourceModel()->index(source_row, 0, source_parent) ); + return recursiveMatch(sourceModel()->index(source_row, 0, source_parent)); } diff --git a/src/urlpanel.cpp b/src/urlpanel.cpp index 94679094..388815c2 100644 --- a/src/urlpanel.cpp +++ b/src/urlpanel.cpp @@ -56,7 +56,7 @@ UrlPanel::UrlPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags) void UrlPanel::showing(bool b) { - if(!_loaded && b) + if (!_loaded && b) { setup(); _loaded = true; diff --git a/src/urlpanel.h b/src/urlpanel.h index 3fa83eac..1f53bc1e 100644 --- a/src/urlpanel.h +++ b/src/urlpanel.h @@ -60,7 +60,10 @@ protected: virtual void setup(); virtual QAbstractItemModel* model() = 0; - PanelTreeView* panelTreeView() const {return _treeView;} + PanelTreeView* panelTreeView() const + { + return _treeView; + } protected Q_SLOTS: virtual void contextMenuItem(const QPoint &pos) = 0; diff --git a/src/useragent/useragentinfo.cpp b/src/useragent/useragentinfo.cpp index cf07d9a4..d6b286b6 100644 --- a/src/useragent/useragentinfo.cpp +++ b/src/useragent/useragentinfo.cpp @@ -44,8 +44,8 @@ UserAgentInfo::UserAgentInfo() { -/* KService::List m_providers = KServiceTypeTrader::self()->query("UserAgentStrings");*/ - + /* KService::List m_providers = KServiceTypeTrader::self()->query("UserAgentStrings");*/ + // NOTE: limiting User Agent Numbers m_providers << KService::serviceByDesktopName("firefox36oncurrent"); m_providers << KService::serviceByDesktopName("ie70onwinnt51"); @@ -61,76 +61,76 @@ UserAgentInfo::UserAgentInfo() QString UserAgentInfo::userAgentString(int i) { - if(i<0) + if (i < 0) { kDebug() << "oh oh... negative index on the user agent choice!"; return QL1S("Default"); } - + QString tmp = m_providers.at(i)->property("X-KDE-UA-FULL").toString(); - + struct utsname utsn; - uname( &utsn ); + uname(&utsn); - tmp.replace( QL1S("appSysName"), QString(utsn.sysname) ); - tmp.replace( QL1S("appSysRelease"), QString(utsn.release) ); - tmp.replace( QL1S("appMachineType"), QString(utsn.machine) ); + tmp.replace(QL1S("appSysName"), QString(utsn.sysname)); + tmp.replace(QL1S("appSysRelease"), QString(utsn.release)); + tmp.replace(QL1S("appMachineType"), QString(utsn.machine)); QStringList languageList = KGlobal::locale()->languageList(); - if ( languageList.count() ) + if (languageList.count()) { - int ind = languageList.indexOf( QL1S("C") ); - if( ind >= 0 ) + int ind = languageList.indexOf(QL1S("C")); + if (ind >= 0) { - if( languageList.contains( QL1S("en") ) ) - languageList.removeAt( ind ); + if (languageList.contains(QL1S("en"))) + languageList.removeAt(ind); else languageList.value(ind) = QL1S("en"); } } - tmp.replace( QL1S("appLanguage"), QString("%1").arg(languageList.join(", ")) ); - tmp.replace( QL1S("appPlatform"), QL1S("X11") ); - + tmp.replace(QL1S("appLanguage"), QString("%1").arg(languageList.join(", "))); + tmp.replace(QL1S("appPlatform"), QL1S("X11")); + return tmp; } QString UserAgentInfo::userAgentName(int i) { - if(i<0) + if (i < 0) { kDebug() << "oh oh... negative index on the user agent choice!"; return QL1S("Default"); } - + return m_providers.at(i)->property("X-KDE-UA-NAME").toString(); } QString UserAgentInfo::userAgentVersion(int i) { - if(i<0) + if (i < 0) { kDebug() << "oh oh... negative index on the user agent choice!"; return QL1S("Default"); } - + return m_providers.at(i)->property("X-KDE-UA-VERSION").toString(); } QString UserAgentInfo::userAgentDescription(int i) { - if(i<0) + if (i < 0) { kDebug() << "oh oh... negative index on the user agent choice!"; return QL1S("Default"); } - + QString tmp = m_providers.at(i)->property("Name").toString(); - tmp.remove( QL1S("UADescription (") ); - tmp.remove( QL1C(')') ); + tmp.remove(QL1S("UADescription (")); + tmp.remove(QL1C(')')); return tmp; } @@ -139,7 +139,7 @@ QStringList UserAgentInfo::availableUserAgents() { QStringList UAs; int n = m_providers.count(); - for(int i = 0; i -class UserAgentInfo +class UserAgentInfo { public: UserAgentInfo(); - + /** * Lists all available User Agents - * + * * @returns the list of the UA descriptions */ QStringList availableUserAgents(); - + /** * Set User Agent for host - * + * * @param uaIndex the index of the UA description. @see availableUserAgents() * @param host the host to se the UA */ bool setUserAgentForHost(int uaIndex, const QString &host); - + /** * @returns the index of the UA set for the @p host */ diff --git a/src/useragent/useragentwidget.cpp b/src/useragent/useragentwidget.cpp index dc4f10ea..0cdddadf 100644 --- a/src/useragent/useragentwidget.cpp +++ b/src/useragent/useragentwidget.cpp @@ -33,7 +33,7 @@ UserAgentWidget::UserAgentWidget(QWidget *parent) - : QWidget(parent) + : QWidget(parent) { setupUi(this); @@ -48,9 +48,9 @@ UserAgentWidget::UserAgentWidget(QWidget *parent) { QStringList tmp; tmp << host; - + KConfigGroup hostGroup(&config, host); - tmp << hostGroup.readEntry( QL1S("UserAgent"), QString()); + tmp << hostGroup.readEntry(QL1S("UserAgent"), QString()); kDebug() << "TMP: " << tmp; QTreeWidgetItem *item = new QTreeWidgetItem(sitePolicyTreeWidget, tmp); @@ -62,17 +62,17 @@ UserAgentWidget::UserAgentWidget(QWidget *parent) void UserAgentWidget::deleteUserAgent() { QTreeWidgetItem *item = sitePolicyTreeWidget->currentItem(); - if(!item) + if (!item) return; - - sitePolicyTreeWidget->takeTopLevelItem( sitePolicyTreeWidget->indexOfTopLevelItem(item) ); - + + sitePolicyTreeWidget->takeTopLevelItem(sitePolicyTreeWidget->indexOfTopLevelItem(item)); + QString host = item->text(0); kDebug() << "HOST: " << host; - + KConfig config("kio_httprc", KConfig::NoGlobals); KConfigGroup group(&config, host); - if(group.exists()) + if (group.exists()) { group.deleteGroup(); KProtocolManager::reparseConfiguration(); @@ -83,16 +83,16 @@ void UserAgentWidget::deleteUserAgent() void UserAgentWidget::deleteAll() { sitePolicyTreeWidget->clear(); - + KConfig config("kio_httprc", KConfig::NoGlobals); - + QStringList list = config.groupList(); Q_FOREACH(const QString &groupName, list) { - kDebug() << "HOST: " << groupName; - + kDebug() << "HOST: " << groupName; + KConfigGroup group(&config, groupName); - group.deleteGroup(); + group.deleteGroup(); } KConfigGroup group(&config, QString()); group.deleteGroup(); diff --git a/src/webicon.cpp b/src/webicon.cpp index 52acdbe5..ae285cc0 100644 --- a/src/webicon.cpp +++ b/src/webicon.cpp @@ -63,7 +63,7 @@ void WebIcon::load() void WebIcon::saveIcon(bool b) { - if(b) + if (b) rApp->iconManager()->provideIcon(&m_page, m_url, false); this->deleteLater(); diff --git a/src/webinspectorpanel.cpp b/src/webinspectorpanel.cpp index 365bc6be..b42756fc 100644 --- a/src/webinspectorpanel.cpp +++ b/src/webinspectorpanel.cpp @@ -56,14 +56,14 @@ void WebInspectorPanel::closeEvent(QCloseEvent *event) void WebInspectorPanel::toggle(bool enable) { MainWindow *w = qobject_cast(parent()); - w->actionByName( QL1S("web_inspector") )->setChecked(enable); + w->actionByName(QL1S("web_inspector"))->setChecked(enable); if (enable) { w->currentTab()->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); - if(!_inspector) + if (!_inspector) { _inspector = new QWebInspector(this); - _inspector->setPage( w->currentTab()->page() ); + _inspector->setPage(w->currentTab()->page()); setWidget(_inspector); } show(); diff --git a/src/webpage.cpp b/src/webpage.cpp index e7d5f2d4..036e9db1 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -113,20 +113,20 @@ static void extractSuggestedFileName(const QNetworkReply* reply, QString& fileNa fileName.clear(); const KIO::MetaData& metaData = reply->attribute(static_cast(KIO::AccessManager::MetaData)).toMap(); if (metaData.value(QL1S("content-disposition-type")).compare(QL1S("attachment"), Qt::CaseInsensitive) == 0) - fileName = metaData.value(QL1S("content-disposition-filename")); + fileName = metaData.value(QL1S("content-disposition-filename")); if (!fileName.isEmpty()) return; if (!reply->hasRawHeader("Content-Disposition")) - return; + return; - const QString value (QL1S(reply->rawHeader("Content-Disposition").simplified().constData())); - if (value.startsWith(QL1S("attachment"), Qt::CaseInsensitive) || value.startsWith(QL1S("inline"), Qt::CaseInsensitive)) + const QString value(QL1S(reply->rawHeader("Content-Disposition").simplified().constData())); + if (value.startsWith(QL1S("attachment"), Qt::CaseInsensitive) || value.startsWith(QL1S("inline"), Qt::CaseInsensitive)) { const int length = value.size(); int pos = value.indexOf(QL1S("filename"), 0, Qt::CaseInsensitive); - if (pos > -1) + if (pos > -1) { pos += 9; while (pos < length && (value.at(pos) == QL1C(' ') || value.at(pos) == QL1C('=') || value.at(pos) == QL1C('"'))) @@ -137,7 +137,7 @@ static void extractSuggestedFileName(const QNetworkReply* reply, QString& fileNa endPos++; if (endPos > pos) - fileName = value.mid(pos, (endPos-pos)).trimmed(); + fileName = value.mid(pos, (endPos - pos)).trimmed(); } } } @@ -156,49 +156,49 @@ static void extractMimeType(const QNetworkReply* reply, QString& mimeType) if (!reply->hasRawHeader("Content-Type")) return; - const QString value (QL1S(reply->rawHeader("Content-Type").simplified().constData())); + const QString value(QL1S(reply->rawHeader("Content-Type").simplified().constData())); const int index = value.indexOf(QL1C(';')); if (index == -1) - mimeType = value; + mimeType = value; else - mimeType = value.left(index); + mimeType = value.left(index); } -static bool downloadResource (const KUrl& srcUrl, const KIO::MetaData& metaData = KIO::MetaData(), - QWidget* parent = 0, const QString& suggestedName = QString()) +static bool downloadResource(const KUrl& srcUrl, const KIO::MetaData& metaData = KIO::MetaData(), + QWidget * parent = 0, const QString & suggestedName = QString()) { KUrl destUrl; int result = KIO::R_OVERWRITE; - const QString fileName ((suggestedName.isEmpty() ? srcUrl.fileName() : suggestedName)); + const QString fileName((suggestedName.isEmpty() ? srcUrl.fileName() : suggestedName)); do { // follow bug:184202 fixes destUrl = KFileDialog::getSaveFileName(KUrl::fromPath(fileName), QString(), parent); - if(destUrl.isEmpty()) + if (destUrl.isEmpty()) return false; if (destUrl.isLocalFile()) { - QFileInfo finfo (destUrl.toLocalFile()); + QFileInfo finfo(destUrl.toLocalFile()); if (finfo.exists()) { QDateTime now = QDateTime::currentDateTime(); - QPointer dlg = new KIO::RenameDialog( parent, - i18n("Overwrite File?"), - srcUrl, - destUrl, - KIO::RenameDialog_Mode(KIO::M_OVERWRITE | KIO::M_SKIP), - -1, - finfo.size(), - now.toTime_t(), - finfo.created().toTime_t(), - now.toTime_t(), - finfo.lastModified().toTime_t() - ); + QPointer dlg = new KIO::RenameDialog(parent, + i18n("Overwrite File?"), + srcUrl, + destUrl, + KIO::RenameDialog_Mode(KIO::M_OVERWRITE | KIO::M_SKIP), + -1, + finfo.size(), + now.toTime_t(), + finfo.created().toTime_t(), + now.toTime_t(), + finfo.lastModified().toTime_t() + ); result = dlg->exec(); delete dlg; } @@ -292,14 +292,14 @@ WebPage::~WebPage() bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { - if(_isOnRekonqPage) + if (_isOnRekonqPage) { WebView *view = qobject_cast(parent()); WebTab *tab = qobject_cast(view->parent()); _isOnRekonqPage = false; tab->setPart(0, KUrl()); // re-enable the view page } - + // reset webpage values _suggestedFileName.clear(); _loadingUrl = request.url(); @@ -368,7 +368,7 @@ WebPage *WebPage::createWindow(QWebPage::WebWindowType type) WebTab *w = 0; if (ReKonfig::openTabNoWindow()) { - w = rApp->mainWindow()->mainView()->newWebTab( !ReKonfig::openTabsBack() ); + w = rApp->mainWindow()->mainView()->newWebTab(!ReKonfig::openTabsBack()); } else { @@ -380,23 +380,23 @@ WebPage *WebPage::createWindow(QWebPage::WebWindowType type) void WebPage::handleUnsupportedContent(QNetworkReply *reply) { - Q_ASSERT (reply); + Q_ASSERT(reply); // Put the job on hold... - #if KDE_IS_VERSION( 4, 5, 96) - kDebug() << "PUT REPLY ON HOLD..."; - KIO::Integration::AccessManager::putReplyOnHold(reply); - #else - reply->abort(); - #endif - +#if KDE_IS_VERSION( 4, 5, 96) + kDebug() << "PUT REPLY ON HOLD..."; + KIO::Integration::AccessManager::putReplyOnHold(reply); +#else + reply->abort(); +#endif + // This is probably needed just in ONE stupid case.. if (_protHandler.postHandling(reply->request(), mainFrame())) { kDebug() << "POST HANDLING the unsupported..."; return; } - + if (reply->error() != QNetworkReply::NoError) return; @@ -408,11 +408,11 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) // Get mimeType... extractMimeType(reply, _mimeType); - + // Convert executable text files to plain text... if (KParts::BrowserRun::isTextExecutable(_mimeType)) _mimeType = QL1S("text/plain"); - + kDebug() << "Detected MimeType = " << _mimeType; kDebug() << "Suggested File Name = " << _suggestedFileName; // ------------------------------------------------ @@ -435,7 +435,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) if (!isLocal) { KParts::BrowserOpenOrSaveQuestion dlg(rApp->mainWindow(), replyUrl, _mimeType); - if(!_suggestedFileName.isEmpty()) + if (!_suggestedFileName.isEmpty()) dlg.setSuggestedFileName(_suggestedFileName); switch (dlg.askEmbedOrSave()) @@ -454,10 +454,10 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) } // Handle Post operations that return content... - if (reply->operation() == QNetworkAccessManager::PostOperation) + if (reply->operation() == QNetworkAccessManager::PostOperation) { kDebug() << "POST OPERATION: downloading file..."; - QFileInfo finfo (_suggestedFileName.isEmpty() ? _loadingUrl.fileName() : _suggestedFileName); + QFileInfo finfo(_suggestedFileName.isEmpty() ? _loadingUrl.fileName() : _suggestedFileName); KTemporaryFile tempFile; tempFile.setSuffix(QL1C('.') + finfo.suffix()); tempFile.setAutoRemove(false); @@ -481,7 +481,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) if (appName == appService->desktopEntryName() || appService->exec().trimmed().startsWith(appName)) { kDebug() << "SELF..."; - QNetworkRequest req (reply->request()); + QNetworkRequest req(reply->request()); req.setRawHeader("x-kdewebkit-ignore-disposition", "true"); currentFrame()->load(req); return; @@ -492,16 +492,16 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) if (pa) { kDebug() << "EMBEDDING CONTENT..."; - + _isOnRekonqPage = true; WebView *view = qobject_cast(parent()); WebTab *tab = qobject_cast(view->parent()); - tab->setPart(pa,replyUrl); + tab->setPart(pa, replyUrl); UrlBar *bar = tab->urlBar(); bar->setQUrl(replyUrl); - + rApp->mainWindow()->updateActions(); } else @@ -509,11 +509,11 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) // No parts, just app services. Load it! // If the app is a KDE one, publish the slave on hold to let it use it. // Otherwise, run the app and remove it (the io slave...) - if (appService->categories().contains(QL1S("KDE"), Qt::CaseInsensitive)) + if (appService->categories().contains(QL1S("KDE"), Qt::CaseInsensitive)) { - #if KDE_IS_VERSION( 4, 5, 96) - KIO::Scheduler::publishSlaveOnHold(); - #endif +#if KDE_IS_VERSION( 4, 5, 96) + KIO::Scheduler::publishSlaveOnHold(); +#endif KRun::run(*appService, replyUrl, 0, false, _suggestedFileName); return; } @@ -521,11 +521,11 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) } // Remove any ioslave that was put on hold... - #if KDE_IS_VERSION( 4, 5, 96) - kDebug() << "REMOVE SLAVES ON HOLD..."; - KIO::Scheduler::removeSlaveOnHold(); - #endif - +#if KDE_IS_VERSION( 4, 5, 96) + kDebug() << "REMOVE SLAVES ON HOLD..."; + KIO::Scheduler::removeSlaveOnHold(); +#endif + return; } @@ -541,7 +541,7 @@ void WebPage::loadFinished(bool ok) // set zoom factor QString val; KSharedConfig::Ptr config = KGlobal::config(); - KConfigGroup group( config, "Zoom" ); + KConfigGroup group(config, "Zoom"); val = group.readEntry(_loadingUrl.host(), QString("10")); int value = val.toInt(); @@ -570,9 +570,9 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) Q_ASSERT(reply); // check suggested file name - if(_suggestedFileName.isEmpty()) + if (_suggestedFileName.isEmpty()) extractSuggestedFileName(reply, _suggestedFileName); - + QWebFrame* frame = qobject_cast(reply->request().originatingObject()); const bool isMainFrameRequest = (frame == mainFrame()); @@ -624,10 +624,10 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) if (reply->url() == _loadingUrl) { frame->setHtml(errorPage(reply)); - if(isMainFrameRequest) + if (isMainFrameRequest) { _isOnRekonqPage = true; - + WebView *view = qobject_cast(parent()); WebTab *tab = qobject_cast(view->parent()); UrlBar *bar = tab->urlBar(); @@ -659,11 +659,11 @@ QString WebPage::errorPage(QNetworkReply *reply) } QString title = i18n("There was a problem while loading the page"); - - // NOTE: + + // NOTE: // this, to take care about XSS (see BUG 217464)... QString urlString = Qt::escape(reply->url().toString()); - + QString iconPath = QString("file://") + KIconLoader::global()->iconPath("dialog-warning" , KIconLoader::Small); iconPath.replace(QL1S("16"), QL1S("128")); @@ -694,7 +694,7 @@ QString WebPage::errorPage(QNetworkReply *reply) void WebPage::downloadReply(const QNetworkReply *reply, const QString &suggestedFileName) { - downloadResource( reply->url(), KIO::MetaData(), view(), suggestedFileName); + downloadResource(reply->url(), KIO::MetaData(), view(), suggestedFileName); } @@ -708,7 +708,7 @@ void WebPage::downloadRequest(const QNetworkRequest &request) void WebPage::downloadUrl(const KUrl &url) { - downloadResource( url, KIO::MetaData(), view() ); + downloadResource(url, KIO::MetaData(), view()); } @@ -794,8 +794,8 @@ void WebPage::updateImage(bool ok) void WebPage::copyToTempFileResult(KJob* job) { - if ( job->error() ) + if (job->error()) job->uiDelegate()->showErrorMessage(); - else + else (void)KRun::runUrl(static_cast(job)->destUrl(), _mimeType, rApp->mainWindow()); } diff --git a/src/webpage.h b/src/webpage.h index a2ab6833..86a4cb5b 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -52,15 +52,33 @@ public: explicit WebPage(QWidget *parent = 0); ~WebPage(); - inline bool hasNetworkAnalyzerEnabled() const { return _networkAnalyzer; }; - inline void enableNetworkAnalyzer(bool b) { _networkAnalyzer = b; }; + inline bool hasNetworkAnalyzerEnabled() const + { + return _networkAnalyzer; + }; + inline void enableNetworkAnalyzer(bool b) + { + _networkAnalyzer = b; + }; + + inline bool isOnRekonqPage() const + { + return _isOnRekonqPage; + }; + inline void setIsOnRekonqPage(bool b) + { + _isOnRekonqPage = b; + }; + + inline KUrl loadingUrl() + { + return _loadingUrl; + }; + inline QString suggestedFileName() + { + return _suggestedFileName; + }; - inline bool isOnRekonqPage() const { return _isOnRekonqPage; }; - inline void setIsOnRekonqPage(bool b) { _isOnRekonqPage = b; }; - - inline KUrl loadingUrl() { return _loadingUrl; }; - inline QString suggestedFileName() { return _suggestedFileName; }; - public Q_SLOTS: void downloadAllContentsWithKGet(QPoint); @@ -83,7 +101,7 @@ private Q_SLOTS: void updateImage(bool ok); void copyToTempFileResult(KJob*); - + private: void downloadReply(const QNetworkReply *reply, const QString &suggestedFileName = QString()); @@ -96,7 +114,7 @@ private: QString _mimeType; QString _suggestedFileName; - + bool _networkAnalyzer; bool _isOnRekonqPage; }; diff --git a/src/websnap.cpp b/src/websnap.cpp index 2137afd8..d03e39a4 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -89,7 +89,7 @@ QPixmap WebSnap::render(const QWebPage &page, int w, int h) QPainter p(&pageImage); page.mainFrame()->render(&p, QWebFrame::ContentsLayer); p.end(); - + return pageImage; } @@ -98,10 +98,10 @@ QPixmap WebSnap::renderTabPreview(const QWebPage &page, int w, int h) { QSize oldSize = page.viewportSize(); int width = page.mainFrame()->contentsSize().width(); - page.setViewportSize(QSize(width, width * ((0.0 + h) / w))); + page.setViewportSize(QSize(width, width * ((0.0 + h) / w))); QPixmap pageImage = WebSnap::render(page, page.viewportSize().width(), page.viewportSize().height()); page.setViewportSize(oldSize); - return pageImage.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + return pageImage.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } /* @@ -116,10 +116,10 @@ QPixmap WebSnap::renderVisiblePagePreview(const QWebPage &page, int w, int h) // save page settings QSize oldSize = page.viewportSize(); QPoint oldScrollPosition = page.mainFrame()->scrollPosition(); - + // minimum width int width = 640; - + // find best width QSize size; while(page.mainFrame()->scrollBarMaximum(Qt::Horizontal) && width<1920) @@ -131,7 +131,7 @@ QPixmap WebSnap::renderVisiblePagePreview(const QWebPage &page, int w, int h) // scroll to top page.mainFrame()->setScrollBarValue(Qt::Vertical, 0); - + // render QPixmap pageImage = WebSnap::render(page, page.viewportSize().width(), page.viewportSize().height()); @@ -142,7 +142,7 @@ QPixmap WebSnap::renderVisiblePagePreview(const QWebPage &page, int w, int h) // resize image pageImage = pageImage.copy(0, 0, width - scrollbarWidth, size.height() - scrollbarHeight); pageImage = pageImage.scaled(w, h, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); - + // restore page settings page.setViewportSize(oldSize); page.mainFrame()->setScrollPosition(oldScrollPosition); @@ -152,12 +152,12 @@ QPixmap WebSnap::renderVisiblePagePreview(const QWebPage &page, int w, int h) */ QPixmap WebSnap::renderClosingPagePreview(const QWebPage &page, int w, int h) -{ +{ //scroll to top page.mainFrame()->setScrollBarValue(Qt::Vertical, 0); // reduce as much as possible - page.setViewportSize(QSize(10, 10)); + page.setViewportSize(QSize(10, 10)); return renderPagePreview(page, w, h); } @@ -168,7 +168,7 @@ QPixmap WebSnap::renderPagePreview(const QWebPage &page, int w, int h) //prepare page page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); int width = page.mainFrame()->contentsSize().width(); - page.setViewportSize(QSize(width, width * ((0.0 + h) / w))); + page.setViewportSize(QSize(width, width * ((0.0 + h) / w))); //render QPixmap pageImage = WebSnap::render(page, page.viewportSize().width(), page.viewportSize().height()); diff --git a/src/websslinfo.cpp b/src/websslinfo.cpp index 3e7ef951..e77e24e8 100644 --- a/src/websslinfo.cpp +++ b/src/websslinfo.cpp @@ -111,9 +111,9 @@ QList WebSslInfo::certificateChain() const return (d ? d->certificateChain : QList()); } -WebSslInfo& WebSslInfo::operator=(const WebSslInfo& other) +WebSslInfo& WebSslInfo::operator=(const WebSslInfo & other) { - if(d) + if (d) { d->ciphers = other.d->ciphers; d->protocol = other.d->protocol; @@ -133,7 +133,7 @@ WebSslInfo& WebSslInfo::operator=(const WebSslInfo& other) bool WebSslInfo::saveTo(QMap& data) const { const bool ok = isValid(); - if(ok) + if (ok) { data.insert("ssl_in_use", true); data.insert("ssl_peer_ip", d->peerAddress.toString()); @@ -154,10 +154,10 @@ bool WebSslInfo::saveTo(QMap& data) const void WebSslInfo::restoreFrom(const QVariant& value, const QUrl& url) { - if(value.isValid() && value.type() == QVariant::Map) + if (value.isValid() && value.type() == QVariant::Map) { QMap metaData = value.toMap(); - if(metaData.value("ssl_in_use", false).toBool()) + if (metaData.value("ssl_in_use", false).toBool()) { setCertificateChain(metaData.value("ssl_peer_chain").toByteArray()); setPeerAddress(metaData.value("ssl_peer_ip").toString()); @@ -174,54 +174,54 @@ void WebSslInfo::restoreFrom(const QVariant& value, const QUrl& url) void WebSslInfo::setUrl(const QUrl &url) { - if(d) + if (d) d->url = url; } void WebSslInfo::setPeerAddress(const QString& address) { - if(d) + if (d) d->peerAddress = address; } void WebSslInfo::setParentAddress(const QString& address) { - if(d) + if (d) d->parentAddress = address; } void WebSslInfo::setProtocol(const QString& protocol) { - if(d) + if (d) d->protocol = protocol; } void WebSslInfo::setCertificateChain(const QByteArray& chain) { - if(d) + if (d) d->certificateChain = QSslCertificate::fromData(chain); } void WebSslInfo::setCiphers(const QString& ciphers) { - if(d) + if (d) d->ciphers = ciphers; } void WebSslInfo::setUsedCipherBits(const QString& bits) { - if(d) + if (d) d->usedCipherBits = bits.toInt(); } void WebSslInfo::setSupportedCipherBits(const QString& bits) { - if(d) + if (d) d->supportedCipherBits = bits.toInt(); } void WebSslInfo::setCertificateErrors(const QString& certErrors) { - if(d) + if (d) d->certErrors = certErrors; } diff --git a/src/websslinfo.h b/src/websslinfo.h index a8f80081..0f66e4c2 100644 --- a/src/websslinfo.h +++ b/src/websslinfo.h @@ -44,14 +44,14 @@ public: QString ciphers() const; QString protocol() const; QString certificateErrors() const; - int supportedChiperBits () const; - int usedChiperBits () const; + int supportedChiperBits() const; + int usedChiperBits() const; QList certificateChain() const; bool saveTo(QMap&) const; void restoreFrom(const QVariant &, const QUrl& = QUrl()); - void setUrl (const QUrl &url); + void setUrl(const QUrl &url); WebSslInfo& operator = (const WebSslInfo&); protected: diff --git a/src/webtab.cpp b/src/webtab.cpp index 935a6052..09940173 100644 --- a/src/webtab.cpp +++ b/src/webtab.cpp @@ -99,7 +99,7 @@ WebTab::~WebTab() KUrl WebTab::url() { - if(page() && page()->isOnRekonqPage()) + if (page() && page()->isOnRekonqPage()) { return page()->loadingUrl(); } @@ -136,11 +136,14 @@ void WebTab::createWalletBar(const QString &key, const QUrl &url) return; KWebWallet *wallet = page()->wallet(); - if(m_walletBar.isNull()) { + if (m_walletBar.isNull()) + { m_walletBar = new WalletBar(this); m_walletBar.data()->onSaveFormData(key, url); - qobject_cast(layout())->insertWidget(0, m_walletBar.data() ); - } else { + qobject_cast(layout())->insertWidget(0, m_walletBar.data()); + } + else + { disconnect(wallet); m_walletBar.data()->notifyUser(); } @@ -154,10 +157,13 @@ void WebTab::createWalletBar(const QString &key, const QUrl &url) void WebTab::createPreviewSelectorBar(int index) { - if(m_previewSelectorBar.isNull()) { + if (m_previewSelectorBar.isNull()) + { m_previewSelectorBar = new PreviewSelectorBar(index, this); qobject_cast(layout())->insertWidget(0, m_previewSelectorBar.data()); - } else { + } + else + { disconnect(m_previewSelectorBar.data()); m_previewSelectorBar.data()->setIndex(index); m_previewSelectorBar.data()->notifyUser(); @@ -223,7 +229,7 @@ void WebTab::showRSSInfo(const QPoint &pos) void WebTab::setPart(KParts::ReadOnlyPart *p, const KUrl &u) { - if(p) + if (p) { // Ok, part exists. Insert & show it.. m_part = p; @@ -235,7 +241,7 @@ void WebTab::setPart(KParts::ReadOnlyPart *p, const KUrl &u) return; } - if(!m_part) + if (!m_part) return; // Part NO more exists. Let's clean up from webtab @@ -283,7 +289,7 @@ void WebTab::showSearchEngine(const QPoint &pos) connect(widget, SIGNAL(webShortcutSet(const KUrl &, const QString &, const QString &)), rApp->opensearchManager(), SLOT(addOpenSearchEngine(const KUrl &, const QString &, const QString &))); connect(rApp->opensearchManager(), SIGNAL(openSearchEngineAdded(const QString &, const QString &, const QString &)), - this, SLOT(openSearchEngineAdded())); + this, SLOT(openSearchEngineAdded())); widget->show(extractOpensearchUrl(e), title, pos); } @@ -296,5 +302,5 @@ void WebTab::openSearchEngineAdded() KBuildSycocaProgressDialog::rebuildKSycoca(this); disconnect(rApp->opensearchManager(), SIGNAL(openSearchEngineAdded(const QString &, const QString &, const QString &)), - this, SLOT(openSearchEngineAdded())); + this, SLOT(openSearchEngineAdded())); } diff --git a/src/webtab.h b/src/webtab.h index 638e4897..092d6ce9 100644 --- a/src/webtab.h +++ b/src/webtab.h @@ -58,10 +58,22 @@ public: explicit WebTab(QWidget *parent = 0); ~WebTab(); - inline WebView *view() const { return m_webView; } - UrlBar *urlBar() const { return m_urlBar; } - inline WebPage *page() const { return view()->page(); } - inline int progress() const { return m_progress; } + inline WebView *view() const + { + return m_webView; + } + UrlBar *urlBar() const + { + return m_urlBar; + } + inline WebPage *page() const + { + return view()->page(); + } + inline int progress() const + { + return m_progress; + } KUrl url(); void createPreviewSelectorBar(int index); @@ -72,7 +84,10 @@ public: bool isPageLoading(); bool hasNewSearchEngine(); - KParts::ReadOnlyPart *part() { return m_part; } + KParts::ReadOnlyPart *part() + { + return m_part; + } void setPart(KParts::ReadOnlyPart *p, const KUrl &u); private Q_SLOTS: diff --git a/src/webview.cpp b/src/webview.cpp index a722c749..9e05a89e 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -89,7 +89,8 @@ WebView::WebView(QWidget* parent) // // But it doesn't work :( // // We'll see in next KDE releases... QPalette p; - if (p.color(QPalette::ButtonText).lightness() > 50) { //if it is a dark theme + if (p.color(QPalette::ButtonText).lightness() > 50) //if it is a dark theme + { QWindowsStyle s; p = s.standardPalette(); setPalette(p); @@ -197,12 +198,12 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) else a->setText(i18n("Copy")); menu.addAction(a); - if(selectedText().contains('.') && selectedText().indexOf('.') < selectedText().length() && !selectedText().trimmed().contains(" ")) + if (selectedText().contains('.') && selectedText().indexOf('.') < selectedText().length() && !selectedText().trimmed().contains(" ")) { QString text = selectedText(); text = text.trimmed(); KUrl urlLikeText(text); - if(urlLikeText.isValid()) + if (urlLikeText.isValid()) { QString truncatedUrl = text; const int maxTextSize = 18; @@ -425,9 +426,9 @@ void WebView::mousePressEvent(QMouseEvent *event) case Qt::MidButton: if (m_canEnableAutoScroll - && !m_isAutoScrollEnabled - && !page()->currentFrame()->scrollBarGeometry(Qt::Horizontal).contains(event->pos()) - && !page()->currentFrame()->scrollBarGeometry(Qt::Vertical).contains(event->pos())) + && !m_isAutoScrollEnabled + && !page()->currentFrame()->scrollBarGeometry(Qt::Horizontal).contains(event->pos()) + && !page()->currentFrame()->scrollBarGeometry(Qt::Vertical).contains(event->pos())) { if (!page()->currentFrame()->scrollBarGeometry(Qt::Horizontal).isNull() || !page()->currentFrame()->scrollBarGeometry(Qt::Vertical).isNull()) @@ -470,7 +471,7 @@ void WebView::mouseMoveEvent(QMouseEvent *event) } else { - if(!w->mainView()->currentUrlBar()->hasFocus()) + if (!w->mainView()->currentUrlBar()->hasFocus()) w->setWidgetsVisible(false); } } @@ -480,7 +481,7 @@ void WebView::mouseMoveEvent(QMouseEvent *event) void WebView::enterEvent(QEvent *event) { - if(m_isAutoScrollEnabled) + if (m_isAutoScrollEnabled) setCursor(KIcon("transform-move").pixmap(32)); KWebView::enterEvent(event); @@ -542,17 +543,17 @@ void WebView::viewImage(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifier void WebView::slotCopyImageLocation() { KAction *a = qobject_cast(sender()); - KUrl imageUrl (a->data().toUrl()); + KUrl imageUrl(a->data().toUrl()); #ifndef QT_NO_MIMECLIPBOARD // Set it in both the mouse selection and in the clipboard QMimeData* mimeData = new QMimeData; - imageUrl.populateMimeData( mimeData ); - QApplication::clipboard()->setMimeData( mimeData, QClipboard::Clipboard ); + imageUrl.populateMimeData(mimeData); + QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard); mimeData = new QMimeData; - imageUrl.populateMimeData( mimeData ); - QApplication::clipboard()->setMimeData( mimeData, QClipboard::Selection ); + imageUrl.populateMimeData(mimeData); + QApplication::clipboard()->setMimeData(mimeData, QClipboard::Selection); #else - QApplication::clipboard()->setText( imageUrl.url() ); + QApplication::clipboard()->setText(imageUrl.url()); #endif } @@ -650,13 +651,13 @@ void WebView::keyPressEvent(QKeyEvent *event) void WebView::wheelEvent(QWheelEvent *event) { - if( event->orientation() == Qt::Vertical || !ReKonfig::hScrollWheelHistory() ) + if (event->orientation() == Qt::Vertical || !ReKonfig::hScrollWheelHistory()) { // To let some websites (eg: google maps) to handle wheel events int prevPos = page()->currentFrame()->scrollPosition().y(); KWebView::wheelEvent(event); int newPos = page()->currentFrame()->scrollPosition().y(); - + // Sync with the zoom slider if (event->modifiers() == Qt::ControlModifier) { @@ -665,39 +666,42 @@ void WebView::wheelEvent(QWheelEvent *event) setZoomFactor(1.9); else if (zoomFactor() < 0.1) setZoomFactor(0.1); - + // Round the factor (Fix slider's end value) int newFactor = zoomFactor() * 10; if ((zoomFactor() * 10 - newFactor) > 0.5) newFactor++; - + emit zoomChanged(newFactor); } else if (ReKonfig::smoothScrolling() && prevPos != newPos) { - + page()->currentFrame()->setScrollPosition(QPoint(page()->currentFrame()->scrollPosition().x(), prevPos)); - + if ((event->delta() > 0) != !m_scrollBottom) stopScrolling(); - + if (event->delta() > 0) m_scrollBottom = false; else m_scrollBottom = true; - - + + setupSmoothScrolling(abs(newPos - prevPos)); } } // use horizontal wheel events to go back and forward in tab history - else { + else + { // left -> go to previous page - if( event->delta() > 0 ){ + if (event->delta() > 0) + { emit openPreviousInHistory(); } // right -> go to next page - if( event->delta() < 0 ){ + if (event->delta() < 0) + { emit openNextInHistory(); } } @@ -737,7 +741,7 @@ void WebView::scrollFrameChanged() void WebView::setupSmoothScrolling(int posY) { - int ddy = qMax(m_smoothScrollSteps ? abs(m_dy)/m_smoothScrollSteps : 0,3); + int ddy = qMax(m_smoothScrollSteps ? abs(m_dy) / m_smoothScrollSteps : 0, 3); m_dy += posY; @@ -751,7 +755,7 @@ void WebView::setupSmoothScrolling(int posY) if (m_dy / m_smoothScrollSteps < ddy) { - m_smoothScrollSteps = (abs(m_dy)+ddy-1)/ddy; + m_smoothScrollSteps = (abs(m_dy) + ddy - 1) / ddy; if (m_smoothScrollSteps < 1) m_smoothScrollSteps = 1; } @@ -787,9 +791,9 @@ void WebView::scrollTick() if (takesteps > m_smoothScrollSteps) takesteps = m_smoothScrollSteps; - for(int i = 0; i < takesteps; i++) + for (int i = 0; i < takesteps; i++) { - int ddy = (m_dy / (m_smoothScrollSteps+1)) * 2; + int ddy = (m_dy / (m_smoothScrollSteps + 1)) * 2; // limit step to requested scrolling distance if (abs(ddy) > abs(m_dy)) diff --git a/src/webview.h b/src/webview.h index 9a666e0b..7f981abb 100644 --- a/src/webview.h +++ b/src/webview.h @@ -52,7 +52,10 @@ public: WebPage *page(); - inline QPoint mousePos() { return m_mousePos; } + inline QPoint mousePos() + { + return m_mousePos; + } protected: void contextMenuEvent(QContextMenuEvent *event); diff --git a/src/zoombar.cpp b/src/zoombar.cpp index bb4b3085..64c32b8b 100644 --- a/src/zoombar.cpp +++ b/src/zoombar.cpp @@ -52,10 +52,10 @@ ZoomBar::ZoomBar(QWidget *parent) : QWidget(parent) - ,m_zoomIn(new QToolButton(this)) - ,m_zoomOut(new QToolButton(this)) - ,m_zoomNormal(new QToolButton(this)) - ,m_zoomSlider(new QSlider(Qt::Horizontal, this)) + , m_zoomIn(new QToolButton(this)) + , m_zoomOut(new QToolButton(this)) + , m_zoomNormal(new QToolButton(this)) + , m_zoomSlider(new QSlider(Qt::Horizontal, this)) { QHBoxLayout *layout = new QHBoxLayout; @@ -198,7 +198,7 @@ void ZoomBar::toggleVisibility() void ZoomBar::saveZoomValue(const QString &host, int value) { KSharedConfig::Ptr config = KGlobal::config(); - KConfigGroup group( config, "Zoom" ); - group.writeEntry(host, QString::number(value) ); + KConfigGroup group(config, "Zoom"); + group.writeEntry(host, QString::number(value)); config->sync(); } -- cgit v1.2.1