From a934072cf9695e46e793898102590322f43c0733 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 28 Mar 2009 15:53:26 +0100 Subject: astyle. First round.. --- scripts/codingstyle.sh | 5 +- src/application.cpp | 30 ++-- src/application.h | 2 +- src/autosaver.cpp | 16 +- src/autosaver.h | 4 +- src/bookmarks.cpp | 68 ++++---- src/bookmarks.h | 38 ++--- src/cookiejar.cpp | 284 ++++++++++++++++++---------------- src/download.cpp | 56 +++---- src/download.h | 54 +++---- src/edittableview.cpp | 11 +- src/edittreeview.cpp | 11 +- src/findbar.cpp | 32 ++-- src/findbar.h | 2 +- src/history.cpp | 310 +++++++++++++++++++++---------------- src/history.h | 33 ++-- src/main.cpp | 36 ++--- src/mainview.cpp | 107 ++++++------- src/mainview.h | 4 +- src/mainwindow.cpp | 358 +++++++++++++++++++++---------------------- src/mainwindow.h | 4 +- src/modelmenu.cpp | 42 ++--- src/networkaccessmanager.cpp | 30 ++-- src/searchbar.cpp | 20 +-- src/searchbar.h | 6 +- src/settings.cpp | 48 +++--- src/settings.h | 2 +- src/tabbar.cpp | 26 ++-- src/tabbar.h | 4 +- src/urlbar.cpp | 26 ++-- src/urlbar.h | 2 +- src/webview.cpp | 94 ++++++------ src/webview.h | 18 ++- 33 files changed, 948 insertions(+), 835 deletions(-) mode change 100644 => 100755 scripts/codingstyle.sh diff --git a/scripts/codingstyle.sh b/scripts/codingstyle.sh old mode 100644 new mode 100755 index ce24a5a1..f0fb984f --- a/scripts/codingstyle.sh +++ b/scripts/codingstyle.sh @@ -8,6 +8,9 @@ # In rekonq we use some little different rules.. { +PWD=$(pwd) + +cd $PWD cd .. cd src @@ -21,4 +24,4 @@ astyle \ --convert-tabs \ --indent-preprocessor \ `find -type f -name '*.cpp'` `find -type f -name '*.h'` -} \ No newline at end of file +} diff --git a/src/application.cpp b/src/application.cpp index 6c621015..53b1cbce 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -59,17 +59,17 @@ NetworkAccessManager *Application::s_networkAccessManager = 0; Application::Application() - : KUniqueApplication() + : KUniqueApplication() { m_mainWindow = new MainWindow(); m_mainWindow->setObjectName("MainWindow"); - setWindowIcon( KIcon("rekonq") ); + setWindowIcon(KIcon("rekonq")); newTab(); mainWindow()->slotHome(); m_mainWindow->show(); - QTimer::singleShot(0, this, SLOT( postLaunch() ) ); + QTimer::singleShot(0, this, SLOT(postLaunch())); } @@ -85,16 +85,16 @@ int Application::newInstance() KCmdLineArgs::setCwd(QDir::currentPath().toUtf8()); KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); - if (args->count() > 0) + if (args->count() > 0) { - for (int i = 0; i < args->count(); ++i) + for (int i = 0; i < args->count(); ++i) { - KUrl url = MainWindow::guessUrlFromString( args->arg(i) ); + KUrl url = MainWindow::guessUrlFromString(args->arg(i)); newTab(); - mainWindow()->loadUrl( url ); + mainWindow()->loadUrl(url); } args->clear(); - } + } return 0; } @@ -108,9 +108,9 @@ Application *Application::instance() void Application::postLaunch() { - // set Icon Database Path to store "favicons" associated with web sites - QString directory = KStandardDirs::locateLocal( "cache" , "" , true ); - if ( directory.isEmpty() ) + // set Icon Database Path to store "favicons" associated with web sites + QString directory = KStandardDirs::locateLocal("cache" , "" , true); + if (directory.isEmpty()) { directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); } @@ -122,7 +122,7 @@ void Application::postLaunch() void Application::downloadUrl(const KUrl &srcUrl, const KUrl &destUrl) { - new Download( srcUrl, destUrl ); + new Download(srcUrl, destUrl); } @@ -152,7 +152,7 @@ CookieJar *Application::cookieJar() NetworkAccessManager *Application::networkAccessManager() { - if (!s_networkAccessManager) + if (!s_networkAccessManager) { s_networkAccessManager = new NetworkAccessManager(); s_networkAccessManager->setCookieJar(new CookieJar); @@ -164,7 +164,7 @@ NetworkAccessManager *Application::networkAccessManager() HistoryManager *Application::historyManager() { - if (!s_historyManager) + if (!s_historyManager) { s_historyManager = new HistoryManager(); QWebHistoryInterface::setDefaultInterface(s_historyManager); @@ -175,7 +175,7 @@ HistoryManager *Application::historyManager() KIcon Application::icon(const KUrl &url) const { - KIcon icon = KIcon( QWebSettings::iconForUrl(url) ); + KIcon icon = KIcon(QWebSettings::iconForUrl(url)); if (icon.isNull()) { icon = KIcon("kde"); diff --git a/src/application.h b/src/application.h index 438638c9..fa731c4e 100644 --- a/src/application.h +++ b/src/application.h @@ -39,7 +39,7 @@ class HistoryManager; class NetworkAccessManager; /** - * + * */ class Application : public KUniqueApplication { diff --git a/src/autosaver.cpp b/src/autosaver.cpp index a2ec7be5..b09f35e9 100644 --- a/src/autosaver.cpp +++ b/src/autosaver.cpp @@ -52,9 +52,12 @@ void AutoSaver::changeOccurred() if (m_firstChange.isNull()) m_firstChange.start(); - if (m_firstChange.elapsed() > MAXWAIT) { + if (m_firstChange.elapsed() > MAXWAIT) + { saveIfNeccessary(); - } else { + } + else + { m_timer.start(AUTOSAVE_IN, this); } } @@ -62,9 +65,12 @@ void AutoSaver::changeOccurred() void AutoSaver::timerEvent(QTimerEvent *event) { - if (event->timerId() == m_timer.timerId()) { + if (event->timerId() == m_timer.timerId()) + { saveIfNeccessary(); - } else { + } + else + { QObject::timerEvent(event); } } @@ -76,7 +82,7 @@ void AutoSaver::saveIfNeccessary() return; m_timer.stop(); m_firstChange = QTime(); - if (!QMetaObject::invokeMethod(parent(), "save", Qt::DirectConnection)) + if (!QMetaObject::invokeMethod(parent(), "save", Qt::DirectConnection)) { kWarning() << "AutoSaver: error invoking slot save() on parent"; } diff --git a/src/autosaver.h b/src/autosaver.h index a686e11e..8d85a78d 100644 --- a/src/autosaver.h +++ b/src/autosaver.h @@ -30,9 +30,9 @@ It will wait several seconds after changed() to combining multiple changes and prevent continuous writing to disk. */ -class AutoSaver : public QObject +class AutoSaver : public QObject { -Q_OBJECT + Q_OBJECT public: AutoSaver(QObject *parent); diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index ab207736..da8b3908 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -39,19 +39,19 @@ OwnBookMarks::OwnBookMarks(KMainWindow *parent) - : QObject(parent) - , KBookmarkOwner() + : QObject(parent) + , KBookmarkOwner() { - m_parent = qobject_cast( parent ); - connect( this, SIGNAL( openUrl( const KUrl &) ) , parent , SLOT( loadUrl( const KUrl & ) ) ); + m_parent = qobject_cast(parent); + connect(this, SIGNAL(openUrl(const KUrl &)) , parent , SLOT(loadUrl(const KUrl &))); } -void OwnBookMarks::openBookmark (const KBookmark & b, Qt::MouseButtons mb, Qt::KeyboardModifiers km) +void OwnBookMarks::openBookmark(const KBookmark & b, Qt::MouseButtons mb, Qt::KeyboardModifiers km) { Q_UNUSED(mb); Q_UNUSED(km); - emit openUrl( b.url() ); + emit openUrl(b.url()); } @@ -65,22 +65,22 @@ QString OwnBookMarks::currentUrl() const QString OwnBookMarks::currentTitle() const { QString title = m_parent->windowTitle(); - return title.remove( " - rekonq" ); + return title.remove(" - rekonq"); } // ------------------------------------------------------------------------------------------------------ -BookmarksMenu::BookmarksMenu( KBookmarkManager* manager, KBookmarkOwner* owner, KMenu* menu, KActionCollection* ac ) - : KBookmarkMenu(manager, owner, menu, ac) -{ +BookmarksMenu::BookmarksMenu(KBookmarkManager* manager, KBookmarkOwner* owner, KMenu* menu, KActionCollection* ac) + : KBookmarkMenu(manager, owner, menu, ac) +{ } KMenu* BookmarksMenu::viewContextMenu(QAction* action) { - return contextMenu( action ); + return contextMenu(action); } @@ -88,17 +88,17 @@ KMenu* BookmarksMenu::viewContextMenu(QAction* action) BookmarksProvider::BookmarksProvider(KMainWindow* parent) - : m_parent(parent) - , m_owner(new OwnBookMarks(parent)) - , m_bmMenu(0) - , m_bmToolbar(0) + : m_parent(parent) + , m_owner(new OwnBookMarks(parent)) + , m_bmMenu(0) + , m_bmToolbar(0) { - KUrl bookfile = KUrl( "~/.kde/share/apps/konqueror/bookmarks.xml" ); // share konqueror bookmarks + KUrl bookfile = KUrl("~/.kde/share/apps/konqueror/bookmarks.xml"); // share konqueror bookmarks - if (!QFile::exists( bookfile.path() ) ) + if (!QFile::exists(bookfile.path())) { - bookfile = KUrl( "~/.kde4/share/apps/konqueror/bookmarks.xml" ); - if (!QFile::exists( bookfile.path() ) ) + bookfile = KUrl("~/.kde4/share/apps/konqueror/bookmarks.xml"); + if (!QFile::exists(bookfile.path())) { QString bookmarksDefaultPath = KStandardDirs::locate("appdata" , "defaultbookmarks.xbel"); kWarning() << bookmarksDefaultPath; @@ -107,13 +107,13 @@ BookmarksProvider::BookmarksProvider(KMainWindow* parent) bookmarksPath.replace("rekonq", "konqueror"); bkms.copy(bookmarksPath); - bookfile = KUrl( bookmarksPath ); + bookfile = KUrl(bookmarksPath); } } - m_manager = KBookmarkManager::managerForExternalFile( bookfile.path() ); - m_ac = new KActionCollection( this ); + m_manager = KBookmarkManager::managerForExternalFile(bookfile.path()); + m_ac = new KActionCollection(this); - connect( m_manager, SIGNAL( changed(const QString &, const QString &) ), this, SLOT( slotBookmarksChanged(const QString &) ) ); + connect(m_manager, SIGNAL(changed(const QString &, const QString &)), this, SLOT(slotBookmarksChanged(const QString &))); } @@ -122,7 +122,7 @@ void BookmarksProvider::slotBookmarksChanged(const QString & group) KBookmarkGroup toolbarGroup = m_manager->toolbar(); kWarning() << "KBookmarkBar::slotBookmarksChanged( " << group << " )"; - if ( toolbarGroup.isNull() ) + if (toolbarGroup.isNull()) return; m_bmToolbar->clear(); @@ -133,22 +133,22 @@ void BookmarksProvider::slotBookmarksChanged(const QString & group) void BookmarksProvider::provideBmToolbar(KToolBar* toolbar) { m_bmToolbar = toolbar; - toolbar->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); + toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - toolbar->setContextMenuPolicy( Qt::CustomContextMenu ); - connect( toolbar, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &)) ); + toolbar->setContextMenuPolicy(Qt::CustomContextMenu); + connect(toolbar, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &))); KBookmarkGroup toolbarGroup = m_manager->toolbar(); KBookmark bm = toolbarGroup.first(); - while(!bm.isNull()) + while (!bm.isNull()) { - if(bm.isGroup()) + if (bm.isGroup()) { // do nothing! } else { - if(bm.isSeparator()) + if (bm.isSeparator()) { toolbar->addSeparator(); } @@ -167,18 +167,18 @@ void BookmarksProvider::provideBmToolbar(KToolBar* toolbar) KMenu *BookmarksProvider::bookmarksMenu() { KMenu *menu = new KMenu(m_parent); - m_bmMenu = new BookmarksMenu( m_manager, m_owner, menu, m_ac ); + m_bmMenu = new BookmarksMenu(m_manager, m_owner, menu, m_ac); return menu; } void BookmarksProvider::contextMenu(const QPoint & point) { - KAction* action = dynamic_cast( m_bmToolbar->actionAt( point ) ); - if(!action) + KAction* action = dynamic_cast(m_bmToolbar->actionAt(point)); + if (!action) return; KMenu *menu = m_bmMenu->viewContextMenu(action); menu->setAttribute(Qt::WA_DeleteOnClose); - menu->popup( m_bmToolbar->mapToGlobal( point )); + menu->popup(m_bmToolbar->mapToGlobal(point)); } diff --git a/src/bookmarks.h b/src/bookmarks.h index 9ef82624..f31cea62 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -37,8 +37,8 @@ class MainWindow; -/** - * Inherited from KBookmarkOwner, this class allows to manage +/** + * Inherited from KBookmarkOwner, this class allows to manage * bookmarks as actions * * @author Andrea Diamantini @@ -46,21 +46,21 @@ class MainWindow; */ class OwnBookMarks : public QObject , public KBookmarkOwner { -Q_OBJECT + Q_OBJECT public: - /** + /** * The class ctor. * * @param parent the pointer to the browser mainwindow. We need it - * to link bookmarks actions with the right window + * to link bookmarks actions with the right window * where load url in */ OwnBookMarks(KMainWindow *parent); /** - * This function is called when a bookmark is selected and belongs to + * This function is called when a bookmark is selected and belongs to * the ancestor class. * This method actually emits signal to load bookmark's url without * considering mousebuttons or keyboard modifiers. @@ -69,10 +69,10 @@ public: * @param mb the mouse buttons clicked to select the bookmark * @param km the keyboard modifiers pushed when the bookmark was selected */ - virtual void openBookmark (const KBookmark &b , Qt::MouseButtons mb, Qt::KeyboardModifiers km); + virtual void openBookmark(const KBookmark &b , Qt::MouseButtons mb, Qt::KeyboardModifiers km); + - - /** + /** * this method, from KBookmarkOwner interface, allows to add the current page * to the bookmark list, returning the URL page as QString. * @@ -80,7 +80,7 @@ public: */ virtual QString currentUrl() const; - /** + /** * this method, from KBookmarkOwner interface, allows to add the current page * to the bookmark list, returning the title's page as QString. * @@ -90,7 +90,7 @@ public: signals: /** - * This signal is emitted when an url has to be loaded + * This signal is emitted when an url has to be loaded * * @param url the URL to load * @@ -106,7 +106,7 @@ private: // ------------------------------------------------------------------------------ -/** +/** * This class represent the rekonq bookmarks menu. * It's just a simple class inherited from KBookmarkMenu * @@ -116,10 +116,10 @@ private: */ class BookmarksMenu : public KBookmarkMenu { -Q_OBJECT + Q_OBJECT public: - BookmarksMenu( KBookmarkManager* manager, KBookmarkOwner* owner, KMenu* menu, KActionCollection* ac); + BookmarksMenu(KBookmarkManager* manager, KBookmarkOwner* owner, KMenu* menu, KActionCollection* ac); KMenu *viewContextMenu(QAction* action); }; @@ -128,7 +128,7 @@ public: // ------------------------------------------------------------------------------ -/** +/** * This class represent the interface to rekonq bookmarks system. * All rekonq needs (Bookmarks Menu, Bookmarks Toolbar) is provided * from this class. @@ -140,10 +140,10 @@ public: */ class BookmarksProvider : public QObject { -Q_OBJECT + Q_OBJECT public: - /** + /** * Class constructor. Connect BookmarksProvider with bookmarks source * (actually konqueror's bookmarks) * @@ -152,14 +152,14 @@ public: */ BookmarksProvider(KMainWindow* parent); - /** + /** * Customize bookmarks toolbar * * @param toolbar the toolbar to customize */ void provideBmToolbar(KToolBar* toolbar); - /** + /** * Generate the Bookmarks Menu * * @return the Bookmarks Menu diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp index d4ecb3f2..e74dd8e4 100644 --- a/src/cookiejar.cpp +++ b/src/cookiejar.cpp @@ -66,12 +66,12 @@ QDataStream &operator>>(QDataStream &stream, QList &list) quint32 count; stream >> count; - for(quint32 i = 0; i < count; ++i) + for (quint32 i = 0; i < count; ++i) { QByteArray value; stream >> value; QList newCookies = QNetworkCookie::parseCookies(value); - if (newCookies.count() == 0 && value.length() != 0) + if (newCookies.count() == 0 && value.length() != 0) { kWarning() << "CookieJar: Unable to parse saved cookie:" << value; } @@ -85,10 +85,10 @@ QDataStream &operator>>(QDataStream &stream, QList &list) CookieJar::CookieJar(QObject *parent) - : QNetworkCookieJar(parent) - , m_loaded(false) - , m_saveTimer(new AutoSaver(this)) - , m_acceptCookies(AcceptOnlyFromSitesNavigatedTo) + : QNetworkCookieJar(parent) + , m_loaded(false) + , m_saveTimer(new AutoSaver(this)) + , m_acceptCookies(AcceptOnlyFromSitesNavigatedTo) { } @@ -117,26 +117,26 @@ void CookieJar::load() qRegisterMetaTypeStreamOperators >("QList"); QString filepath = KStandardDirs::locateLocal("appdata", "cookies.ini"); - KConfig iniconfig( filepath ); + KConfig iniconfig(filepath); KConfigGroup inigroup1 = iniconfig.group("general"); - QStringList cookieStringList = inigroup1.readEntry( QString("cookies"), QStringList() ); + QStringList cookieStringList = inigroup1.readEntry(QString("cookies"), QStringList()); QList cookieNetworkList; - foreach( QString str, cookieStringList ) + foreach(QString str, cookieStringList) { - cookieNetworkList << QNetworkCookie( str.toLocal8Bit() ); + cookieNetworkList << QNetworkCookie(str.toLocal8Bit()); } - setAllCookies( cookieNetworkList ); + setAllCookies(cookieNetworkList); KConfigGroup inigroup2 = iniconfig.group("exceptions"); - m_exceptions_block = inigroup2.readEntry( QString("block") , QStringList() ); - m_exceptions_allow = inigroup2.readEntry( QString("allow"), QStringList() ); - m_exceptions_allowForSession = inigroup2.readEntry( QString("allowForSession"), QStringList() ); + m_exceptions_block = inigroup2.readEntry(QString("block") , QStringList()); + m_exceptions_allow = inigroup2.readEntry(QString("allow"), QStringList()); + m_exceptions_allowForSession = inigroup2.readEntry(QString("allowForSession"), QStringList()); - qSort( m_exceptions_block.begin(), m_exceptions_block.end() ); - qSort( m_exceptions_allow.begin(), m_exceptions_allow.end() ); - qSort( m_exceptions_allowForSession.begin(), m_exceptions_allowForSession.end() ); + qSort(m_exceptions_block.begin(), m_exceptions_block.end()); + qSort(m_exceptions_allow.begin(), m_exceptions_allow.end()); + qSort(m_exceptions_allowForSession.begin(), m_exceptions_allowForSession.end()); loadSettings(); } @@ -146,7 +146,7 @@ void CookieJar::loadSettings() { int canAcceptCookies = ReKonfig::acceptCookies(); - switch(canAcceptCookies) + switch (canAcceptCookies) { case 0: m_acceptCookies = AcceptAlways; @@ -162,7 +162,7 @@ void CookieJar::loadSettings() int canKeepCookiesUntil = ReKonfig::keepCookiesUntil(); - switch(canKeepCookiesUntil) + switch (canKeepCookiesUntil) { default: case 0: @@ -176,7 +176,7 @@ void CookieJar::loadSettings() m_keepCookies = KeepUntilTimeLimit; break; } - + m_loaded = true; emit cookiesChanged(); } @@ -187,33 +187,33 @@ void CookieJar::save() if (!m_loaded) return; purgeOldCookies(); - + QString filepath = KStandardDirs::locateLocal("appdata", "cookies.ini"); - KConfig iniconfig( filepath ); + KConfig iniconfig(filepath); KConfigGroup inigroup1 = iniconfig.group("general"); QList cookies = allCookies(); - for (int i = cookies.count() - 1; i >= 0; --i) + for (int i = cookies.count() - 1; i >= 0; --i) { if (cookies.at(i).isSessionCookie()) cookies.removeAt(i); } QStringList cookieStringList; - foreach( QNetworkCookie cook, cookies ) + foreach(QNetworkCookie cook, cookies) { - cookieStringList << QString( cook.toRawForm() ); + cookieStringList << QString(cook.toRawForm()); } - inigroup1.writeEntry( QString("cookies"), cookieStringList ); - + inigroup1.writeEntry(QString("cookies"), cookieStringList); + KConfigGroup inigroup2 = iniconfig.group("exceptions"); - inigroup2.writeEntry( QString("block"), m_exceptions_block ); - inigroup2.writeEntry( QString("allow"), m_exceptions_allow ); - inigroup2.writeEntry( QString("allowForSession"), m_exceptions_allowForSession ); + inigroup2.writeEntry(QString("block"), m_exceptions_block); + inigroup2.writeEntry(QString("allow"), m_exceptions_allow); + inigroup2.writeEntry(QString("allowForSession"), m_exceptions_allowForSession); // save cookie settings int n; - switch(m_acceptCookies) + switch (m_acceptCookies) { case AcceptAlways: n = 0; @@ -229,7 +229,7 @@ void CookieJar::save() ReKonfig::setAcceptCookies(n); - switch(m_keepCookies) + switch (m_keepCookies) { default: case KeepUntilExpire: @@ -253,7 +253,7 @@ void CookieJar::purgeOldCookies() return; int oldCount = cookies.count(); QDateTime now = QDateTime::currentDateTime(); - for (int i = cookies.count() - 1; i >= 0; --i) + for (int i = cookies.count() - 1; i >= 0; --i) { if (!cookies.at(i).isSessionCookie() && cookies.at(i).expirationDate() < now) cookies.removeAt(i); @@ -299,29 +299,29 @@ bool CookieJar::setCookiesFromUrl(const QList &cookieList, const bool addedCookies = false; // pass exceptions bool acceptInitially = (m_acceptCookies != AcceptNever); - if ( (acceptInitially && !eBlock) || (!acceptInitially && (eAllow || eAllowSession) ) ) + if ((acceptInitially && !eBlock) || (!acceptInitially && (eAllow || eAllowSession))) { // pass url domain == cookie domain QDateTime soon = QDateTime::currentDateTime(); soon = soon.addDays(90); - foreach(QNetworkCookie cookie, cookieList) + foreach(QNetworkCookie cookie, cookieList) { QList lst; if (m_keepCookies == KeepUntilTimeLimit - && !cookie.isSessionCookie() - && cookie.expirationDate() > soon) + && !cookie.isSessionCookie() + && cookie.expirationDate() > soon) { - cookie.setExpirationDate(soon); + cookie.setExpirationDate(soon); } lst += cookie; if (QNetworkCookieJar::setCookiesFromUrl(lst, url)) { addedCookies = true; - } - else + } + else { // finally force it in if wanted - if (m_acceptCookies == AcceptAlways) + if (m_acceptCookies == AcceptAlways) { QList cookies = allCookies(); cookies += cookie; @@ -336,7 +336,7 @@ bool CookieJar::setCookiesFromUrl(const QList &cookieList, const } } - if (addedCookies) + if (addedCookies) { m_saveTimer->changeOccurred(); emit cookiesChanged(); @@ -441,8 +441,8 @@ void CookieJar::setAllowForSessionCookies(const QStringList &list) CookieModel::CookieModel(CookieJar *cookieJar, QObject *parent) - : QAbstractTableModel(parent) - , m_cookieJar(cookieJar) + : QAbstractTableModel(parent) + , m_cookieJar(cookieJar) { connect(m_cookieJar, SIGNAL(cookiesChanged()), this, SLOT(cookiesChanged())); m_cookieJar->load(); @@ -451,34 +451,37 @@ CookieModel::CookieModel(CookieJar *cookieJar, QObject *parent) QVariant CookieModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (role == Qt::SizeHintRole) { + if (role == Qt::SizeHintRole) + { QFont font; font.setPointSize(10); QFontMetrics fm(font); - int height = fm.height() + fm.height()/3; + int height = fm.height() + fm.height() / 3; int width = fm.width(headerData(section, orientation, Qt::DisplayRole).toString()); return QSize(width, height); } - if (orientation == Qt::Horizontal) { + if (orientation == Qt::Horizontal) + { if (role != Qt::DisplayRole) return QVariant(); - switch (section) { - case 0: - return i18n("Website"); - case 1: - return i18n("Name"); - case 2: - return i18n("Path"); - case 3: - return i18n("Secure"); - case 4: - return i18n("Expires"); - case 5: - return i18n("Contents"); - default: - return QVariant(); + switch (section) + { + case 0: + return i18n("Website"); + case 1: + return i18n("Name"); + case 2: + return i18n("Path"); + case 3: + return i18n("Secure"); + case 4: + return i18n("Expires"); + case 5: + return i18n("Contents"); + default: + return QVariant(); } } return QAbstractTableModel::headerData(section, orientation, role); @@ -493,30 +496,34 @@ QVariant CookieModel::data(const QModelIndex &index, int role) const if (index.row() < 0 || index.row() >= lst.size()) return QVariant(); - switch (role) { + switch (role) + { case Qt::DisplayRole: - case Qt::EditRole: { + case Qt::EditRole: + { QNetworkCookie cookie = lst.at(index.row()); - switch (index.column()) { - case 0: - return cookie.domain(); - case 1: - return cookie.name(); - case 2: - return cookie.path(); - case 3: - return cookie.isSecure(); - case 4: - return cookie.expirationDate(); - case 5: - return cookie.value(); - } + switch (index.column()) + { + case 0: + return cookie.domain(); + case 1: + return cookie.name(); + case 2: + return cookie.path(); + case 3: + return cookie.isSecure(); + case 4: + return cookie.expirationDate(); + case 5: + return cookie.value(); } - case Qt::FontRole:{ + } + case Qt::FontRole: + { QFont font; font.setPointSize(10); return font; - } + } } return QVariant(); @@ -542,7 +549,8 @@ bool CookieModel::removeRows(int row, int count, const QModelIndex &parent) int lastRow = row + count - 1; beginRemoveRows(parent, row, lastRow); QList lst = m_cookieJar->allCookies(); - for (int i = lastRow; i >= row; --i) { + for (int i = lastRow; i >= row; --i) + { lst.removeAt(i); } m_cookieJar->setAllCookies(lst); @@ -561,8 +569,8 @@ void CookieModel::cookiesChanged() // ------------------------------------------------------------------------------------------------ -CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) - : QDialog(parent) +CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) + : QDialog(parent) { setupUi(this); setWindowFlags(Qt::Sheet); @@ -583,12 +591,14 @@ CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) QFont f = font(); f.setPointSize(10); QFontMetrics fm(f); - int height = fm.height() + fm.height()/3; + int height = fm.height() + fm.height() / 3; cookiesTable->verticalHeader()->setDefaultSectionSize(height); cookiesTable->verticalHeader()->setMinimumSectionSize(-1); - for (int i = 0; i < model->columnCount(); ++i){ + for (int i = 0; i < model->columnCount(); ++i) + { int header = cookiesTable->horizontalHeader()->sectionSizeHint(i); - switch (i) { + switch (i) + { case 0: header = fm.width(QLatin1String("averagehost.domain.com")); break; @@ -611,8 +621,8 @@ CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) CookieExceptionsModel::CookieExceptionsModel(CookieJar *cookiejar, QObject *parent) - : QAbstractTableModel(parent) - , m_cookieJar(cookiejar) + : QAbstractTableModel(parent) + , m_cookieJar(cookiejar) { m_allowedCookies = m_cookieJar->allowedCookies(); m_blockedCookies = m_cookieJar->blockedCookies(); @@ -622,22 +632,25 @@ CookieExceptionsModel::CookieExceptionsModel(CookieJar *cookiejar, QObject *pare QVariant CookieExceptionsModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (role == Qt::SizeHintRole) { + if (role == Qt::SizeHintRole) + { QFont font; font.setPointSize(10); QFontMetrics fm(font); - int height = fm.height() + fm.height()/3; + int height = fm.height() + fm.height() / 3; int width = fm.width(headerData(section, orientation, Qt::DisplayRole).toString()); return QSize(width, height); } if (orientation == Qt::Horizontal - && role == Qt::DisplayRole) { - switch (section) { - case 0: - return i18n("Website"); - case 1: - return i18n("Status"); + && role == Qt::DisplayRole) + { + switch (section) + { + case 0: + return i18n("Website"); + case 1: + return i18n("Status"); } } return QAbstractTableModel::headerData(section, orientation, role); @@ -649,42 +662,51 @@ QVariant CookieExceptionsModel::data(const QModelIndex &index, int role) const if (index.row() < 0 || index.row() >= rowCount()) return QVariant(); - switch (role) { + switch (role) + { case Qt::DisplayRole: - case Qt::EditRole: { + case Qt::EditRole: + { int row = index.row(); - if (row < m_allowedCookies.count()) { - switch (index.column()) { - case 0: - return m_allowedCookies.at(row); - case 1: - return i18n("Allow"); + if (row < m_allowedCookies.count()) + { + switch (index.column()) + { + case 0: + return m_allowedCookies.at(row); + case 1: + return i18n("Allow"); } } row = row - m_allowedCookies.count(); - if (row < m_blockedCookies.count()) { - switch (index.column()) { - case 0: - return m_blockedCookies.at(row); - case 1: - return i18n("Block"); + if (row < m_blockedCookies.count()) + { + switch (index.column()) + { + case 0: + return m_blockedCookies.at(row); + case 1: + return i18n("Block"); } } row = row - m_blockedCookies.count(); - if (row < m_sessionCookies.count()) { - switch (index.column()) { - case 0: - return m_sessionCookies.at(row); - case 1: - return i18n("Allow For Session"); + if (row < m_sessionCookies.count()) + { + switch (index.column()) + { + case 0: + return m_sessionCookies.at(row); + case 1: + return i18n("Allow For Session"); } } - } - case Qt::FontRole:{ + } + case Qt::FontRole: + { QFont font; font.setPointSize(10); return font; - } + } } return QVariant(); } @@ -709,18 +731,22 @@ bool CookieExceptionsModel::removeRows(int row, int count, const QModelIndex &pa int lastRow = row + count - 1; beginRemoveRows(parent, row, lastRow); - for (int i = lastRow; i >= row; --i) { - if (i < m_allowedCookies.count()) { + for (int i = lastRow; i >= row; --i) + { + if (i < m_allowedCookies.count()) + { m_allowedCookies.removeAt(row); continue; } i = i - m_allowedCookies.count(); - if (i < m_blockedCookies.count()) { + if (i < m_blockedCookies.count()) + { m_blockedCookies.removeAt(row); continue; } i = i - m_blockedCookies.count(); - if (i < m_sessionCookies.count()) { + if (i < m_sessionCookies.count()) + { m_sessionCookies.removeAt(row); continue; } @@ -737,8 +763,8 @@ bool CookieExceptionsModel::removeRows(int row, int count, const QModelIndex &pa CookiesExceptionsDialog::CookiesExceptionsDialog(CookieJar *cookieJar, QWidget *parent) - : QDialog(parent) - , m_cookieJar(cookieJar) + : QDialog(parent) + , m_cookieJar(cookieJar) { setupUi(this); setWindowFlags(Qt::Sheet); @@ -769,12 +795,14 @@ CookiesExceptionsDialog::CookiesExceptionsDialog(CookieJar *cookieJar, QWidget * QFont f = font(); f.setPointSize(10); QFontMetrics fm(f); - int height = fm.height() + fm.height()/3; + int height = fm.height() + fm.height() / 3; exceptionTable->verticalHeader()->setDefaultSectionSize(height); exceptionTable->verticalHeader()->setMinimumSectionSize(-1); - for (int i = 0; i < m_exceptionsModel->columnCount(); ++i){ + for (int i = 0; i < m_exceptionsModel->columnCount(); ++i) + { int header = exceptionTable->horizontalHeader()->sectionSizeHint(i); - switch (i) { + switch (i) + { case 0: header = fm.width(QLatin1String("averagebiglonghost.domain.com")); break; diff --git a/src/download.cpp b/src/download.cpp index deba9a53..7edc8dc6 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -30,12 +30,12 @@ #include Download::Download(const KUrl &srcUrl, const KUrl &destUrl) - : m_srcUrl(srcUrl), - m_destUrl(destUrl) + : m_srcUrl(srcUrl), + m_destUrl(destUrl) { kWarning() << "DownloadFile: " << m_srcUrl.url() << " to dest: " << m_destUrl.url(); m_copyJob = KIO::get(m_srcUrl); - connect(m_copyJob, SIGNAL(data(KIO::Job*,const QByteArray &)), SLOT(slotData(KIO::Job*, const QByteArray&))); + connect(m_copyJob, SIGNAL(data(KIO::Job*, const QByteArray &)), SLOT(slotData(KIO::Job*, const QByteArray&))); connect(m_copyJob, SIGNAL(result(KJob *)), SLOT(slotResult(KJob *))); } @@ -53,34 +53,34 @@ void Download::slotResult(KJob * job) { switch (job->error()) { - case 0://The download has finished + case 0://The download has finished + { + kDebug(5001) << "Downloading successfully finished: " << m_destUrl.url(); + QFile destFile(m_destUrl.path()); + int n = 1; + QString fn = destFile.fileName(); + while (destFile.exists()) { - kDebug(5001) << "Downloading successfully finished: " << m_destUrl.url(); - QFile destFile(m_destUrl.path()); - int n = 1; - QString fn = destFile.fileName(); - while( destFile.exists() ) - { - destFile.setFileName( fn + "." + QString::number(n) ); - n++; - } - if ( destFile.open(QIODevice::WriteOnly | QIODevice::Text) ) - { - destFile.write(m_data); - destFile.close(); - } - m_data = 0; - break; + destFile.setFileName(fn + "." + QString::number(n)); + n++; } - case KIO::ERR_FILE_ALREADY_EXIST: + if (destFile.open(QIODevice::WriteOnly | QIODevice::Text)) { - kWarning() << "ERROR - File already exists"; - m_data = 0; - break; + destFile.write(m_data); + destFile.close(); } - default: - kWarning() << "We are sorry to say you, that there were errors while downloading :("; - m_data = 0; - break; + m_data = 0; + break; + } + case KIO::ERR_FILE_ALREADY_EXIST: + { + kWarning() << "ERROR - File already exists"; + m_data = 0; + break; + } + default: + kWarning() << "We are sorry to say you, that there were errors while downloading :("; + m_data = 0; + break; } } diff --git a/src/download.h b/src/download.h index a905e1ae..fe415c0b 100644 --- a/src/download.h +++ b/src/download.h @@ -31,41 +31,41 @@ /** * This class lets rekonq to download an object from the network. - * Creating a new object, you can continue downloading a file also + * Creating a new object, you can continue downloading a file also * when rekonq is closed. * - */ + */ class Download : public QObject { Q_OBJECT - public: - /** - * Class constructor. This is the unique method we need to - * use this class. In fact Download class needs to know just - * "where" catch the file to download and where it has to put it - * - * @param srcUrl the source url - * - * @param destUrl the destination url - * - */ - Download(const KUrl &srcUrl, const KUrl &destUrl); +public: + /** + * Class constructor. This is the unique method we need to + * use this class. In fact Download class needs to know just + * "where" catch the file to download and where it has to put it + * + * @param srcUrl the source url + * + * @param destUrl the destination url + * + */ + Download(const KUrl &srcUrl, const KUrl &destUrl); - /** - * class destructor - */ - ~Download(); + /** + * class destructor + */ + ~Download(); - private slots: - void slotResult(KJob * job); - void slotData(KIO::Job *job, const QByteArray& data); +private slots: + void slotResult(KJob * job); + void slotData(KIO::Job *job, const QByteArray& data); - private: - KIO::TransferJob *m_copyJob; - KUrl m_srcUrl; - KUrl m_destUrl; - KUrl m_destFile; - QByteArray m_data; +private: + KIO::TransferJob *m_copyJob; + KUrl m_srcUrl; + KUrl m_destUrl; + KUrl m_destFile; + QByteArray m_data; }; #endif diff --git a/src/edittableview.cpp b/src/edittableview.cpp index ea916c8d..2f35e9f3 100644 --- a/src/edittableview.cpp +++ b/src/edittableview.cpp @@ -24,17 +24,20 @@ #include EditTableView::EditTableView(QWidget *parent) - : QTableView(parent) + : QTableView(parent) { } void EditTableView::keyPressEvent(QKeyEvent *event) { if ((event->key() == Qt::Key_Delete - || event->key() == Qt::Key_Backspace) - && model()) { + || event->key() == Qt::Key_Backspace) + && model()) + { removeOne(); - } else { + } + else + { QAbstractItemView::keyPressEvent(event); } } diff --git a/src/edittreeview.cpp b/src/edittreeview.cpp index 014e0415..747753de 100644 --- a/src/edittreeview.cpp +++ b/src/edittreeview.cpp @@ -25,17 +25,20 @@ #include EditTreeView::EditTreeView(QWidget *parent) - : QTreeView(parent) + : QTreeView(parent) { } void EditTreeView::keyPressEvent(QKeyEvent *event) { if ((event->key() == Qt::Key_Delete - || event->key() == Qt::Key_Backspace) - && model()) { + || event->key() == Qt::Key_Backspace) + && model()) + { removeOne(); - } else { + } + else + { QAbstractItemView::keyPressEvent(event); } } diff --git a/src/findbar.cpp b/src/findbar.cpp index 1c82aa4a..514ec56f 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -35,8 +35,8 @@ FindBar::FindBar(KXmlGuiWindow *mainwindow) - : QWidget() - , m_lineEdit(0) + : QWidget() + , m_lineEdit(0) { QHBoxLayout *layout = new QHBoxLayout; @@ -49,7 +49,7 @@ FindBar::FindBar(KXmlGuiWindow *mainwindow) hideButton->setIcon(KIcon("dialog-close")); connect(hideButton, SIGNAL(clicked()), this, SLOT(hide())); layout->addWidget(hideButton); - layout->setAlignment( hideButton, Qt::AlignLeft|Qt::AlignTop ); + layout->setAlignment(hideButton, Qt::AlignLeft | Qt::AlignTop); // label QLabel *label = new QLabel("Find: "); @@ -58,18 +58,18 @@ FindBar::FindBar(KXmlGuiWindow *mainwindow) // lineEdit, focusProxy m_lineEdit = new KLineEdit(this); setFocusProxy(m_lineEdit); - m_lineEdit->setMaximumWidth( 250 ); - connect( m_lineEdit, SIGNAL( textChanged(const QString &) ), mainwindow, SLOT( slotFind(const QString &) ) ); - layout->addWidget( m_lineEdit ); + m_lineEdit->setMaximumWidth(250); + connect(m_lineEdit, SIGNAL(textChanged(const QString &)), mainwindow, SLOT(slotFind(const QString &))); + layout->addWidget(m_lineEdit); // buttons - KPushButton *findNext = new KPushButton( KIcon("go-down"), "&Next", this ); - KPushButton *findPrev = new KPushButton( KIcon("go-up"), "&Previous", this ); - connect( findNext, SIGNAL( clicked() ), mainwindow, SLOT( slotFindNext() ) ); - connect( findPrev, SIGNAL( clicked() ), mainwindow, SLOT( slotFindPrevious() ) ); - layout->addWidget( findNext ); - layout->addWidget( findPrev ); - + KPushButton *findNext = new KPushButton(KIcon("go-down"), "&Next", this); + KPushButton *findPrev = new KPushButton(KIcon("go-up"), "&Previous", this); + connect(findNext, SIGNAL(clicked()), mainwindow, SLOT(slotFindNext())); + connect(findPrev, SIGNAL(clicked()), mainwindow, SLOT(slotFindPrevious())); + layout->addWidget(findNext); + layout->addWidget(findPrev); + // stretching widget on the left layout->addStretch(); @@ -100,7 +100,7 @@ void FindBar::clear() void FindBar::showFindBar() { - if (!isVisible()) + if (!isVisible()) { show(); } @@ -116,9 +116,9 @@ void FindBar::keyPressEvent(QKeyEvent* event) hide(); return; } - if(event->key() == Qt::Key_Return && !m_lineEdit->text().isEmpty() ) + if (event->key() == Qt::Key_Return && !m_lineEdit->text().isEmpty()) { - emit searchString( m_lineEdit->text() ); + emit searchString(m_lineEdit->text()); return; } QWidget::keyPressEvent(event); diff --git a/src/findbar.h b/src/findbar.h index 4763944b..66286cec 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -39,7 +39,7 @@ public: public slots: void clear(); void showFindBar(); - + protected Q_SLOTS: void keyPressEvent(QKeyEvent* event); diff --git a/src/history.cpp b/src/history.cpp index 5c545b10..96efd3e5 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -46,12 +46,12 @@ static const unsigned int HISTORY_VERSION = 23; HistoryManager::HistoryManager(QObject *parent) - : QWebHistoryInterface(parent) - , m_saveTimer(new AutoSaver(this)) - , m_historyLimit(30) - , m_historyModel(0) - , m_historyFilterModel(0) - , m_historyTreeModel(0) + : QWebHistoryInterface(parent) + , m_saveTimer(new AutoSaver(this)) + , m_historyLimit(30) + , m_historyModel(0) + , m_historyFilterModel(0) + , m_historyTreeModel(0) { m_expiredTimer.setSingleShot(true); connect(&m_expiredTimer, SIGNAL(timeout()), this, SLOT(checkForExpired())); @@ -106,9 +106,12 @@ void HistoryManager::setHistory(const QList &history, bool loadedAn checkForExpired(); - if (loadedAndSorted) { + if (loadedAndSorted) + { m_lastSavedUrl = m_history.value(0).url; - } else { + } + else + { m_lastSavedUrl = QString(); m_saveTimer->changeOccurred(); } @@ -142,13 +145,17 @@ void HistoryManager::checkForExpired() QDateTime now = QDateTime::currentDateTime(); int nextTimeout = 0; - while (!m_history.isEmpty()) { + while (!m_history.isEmpty()) + { QDateTime checkForExpired = m_history.last().dateTime; checkForExpired.setDate(checkForExpired.date().addDays(m_historyLimit)); - if (now.daysTo(checkForExpired) > 7) { + if (now.daysTo(checkForExpired) > 7) + { // check at most in a week to prevent int overflows on the timer nextTimeout = 7 * 86400; - } else { + } + else + { nextTimeout = now.secsTo(checkForExpired); } if (nextTimeout > 0) @@ -179,9 +186,9 @@ void HistoryManager::addHistoryItem(const HistoryItem &item) void HistoryManager::updateHistoryItem(const KUrl &url, const QString &title) { - for (int i = 0; i < m_history.count(); ++i) + for (int i = 0; i < m_history.count(); ++i) { - if (url == m_history.at(i).url) + if (url == m_history.at(i).url) { m_history[i].title = title; m_saveTimer->changeOccurred(); @@ -223,16 +230,16 @@ void HistoryManager::clear() void HistoryManager::loadSettings() { int historyExpire = ReKonfig::expireHistory(); - int days; - switch (historyExpire) + int days; + switch (historyExpire) { - case 0: days = 1; break; - case 1: days = 7; break; - case 2: days = 14; break; - case 3: days = 30; break; - case 4: days = 365; break; - case 5: days = -1; break; - default: days = -1; + case 0: days = 1; break; + case 1: days = 7; break; + case 2: days = 14; break; + case 3: days = 30; break; + case 4: days = 365; break; + case 5: days = -1; break; + default: days = -1; } m_historyLimit = days; } @@ -243,10 +250,10 @@ void HistoryManager::load() loadSettings(); QString historyFilePath = KStandardDirs::locateLocal("appdata" , "history"); - QFile historyFile( historyFilePath ); + QFile historyFile(historyFilePath); if (!historyFile.exists()) return; - if (!historyFile.open(QFile::ReadOnly)) + if (!historyFile.open(QFile::ReadOnly)) { kWarning() << "Unable to open history file" << historyFile.fileName(); return; @@ -261,7 +268,7 @@ void HistoryManager::load() QDataStream stream; QBuffer buffer; stream.setDevice(&buffer); - while ( !historyFile.atEnd() ) + while (!historyFile.atEnd()) { in >> data; buffer.close(); @@ -279,26 +286,26 @@ void HistoryManager::load() if (!item.dateTime.isValid()) continue; - if ( item == lastInsertedItem ) + if (item == lastInsertedItem) { if (lastInsertedItem.title.isEmpty() && !list.isEmpty()) list[0].title = item.title; continue; } - if ( !needToSort && !list.isEmpty() && lastInsertedItem < item ) + if (!needToSort && !list.isEmpty() && lastInsertedItem < item) needToSort = true; list.prepend(item); lastInsertedItem = item; } if (needToSort) - qSort( list.begin(), list.end() ); + qSort(list.begin(), list.end()); setHistory(list, true); // If we had to sort re-write the whole history sorted - if (needToSort) + if (needToSort) { m_lastSavedUrl = QString(); m_saveTimer->changeOccurred(); @@ -310,12 +317,12 @@ void HistoryManager::save() { bool saveAll = m_lastSavedUrl.isEmpty(); int first = m_history.count() - 1; - if (!saveAll) + if (!saveAll) { // find the first one to save - for (int i = 0; i < m_history.count(); ++i) + for (int i = 0; i < m_history.count(); ++i) { - if (m_history.at(i).url == m_lastSavedUrl) + if (m_history.at(i).url == m_lastSavedUrl) { first = i - 1; break; @@ -326,30 +333,30 @@ void HistoryManager::save() saveAll = true; QString historyFilePath = KStandardDirs::locateLocal("appdata" , "history"); - QFile historyFile( historyFilePath ); + QFile historyFile(historyFilePath); // When saving everything use a temporary file to prevent possible data loss. QTemporaryFile tempFile; tempFile.setAutoRemove(false); bool open = false; - if (saveAll) + if (saveAll) { open = tempFile.open(); } - else + else { open = historyFile.open(QFile::Append); } - if (!open) + if (!open) { kWarning() << "Unable to open history file for saving" - << (saveAll ? tempFile.fileName() : historyFile.fileName()); + << (saveAll ? tempFile.fileName() : historyFile.fileName()); return; } QDataStream out(saveAll ? &tempFile : &historyFile); - for (int i = first; i >= 0; --i) + for (int i = first; i >= 0; --i) { QByteArray data; QDataStream stream(&data, QIODevice::WriteOnly); @@ -359,7 +366,7 @@ void HistoryManager::save() } tempFile.close(); - if (saveAll) + if (saveAll) { if (historyFile.exists() && !historyFile.remove()) kWarning() << "History: error removing old history." << historyFile.errorString(); @@ -374,8 +381,8 @@ void HistoryManager::save() HistoryModel::HistoryModel(HistoryManager *history, QObject *parent) - : QAbstractTableModel(parent) - , m_history(history) + : QAbstractTableModel(parent) + , m_history(history) { Q_ASSERT(m_history); connect(m_history, SIGNAL(historyReset()), this, SLOT(historyReset())); @@ -408,12 +415,12 @@ void HistoryModel::entryUpdated(int offset) QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal - && role == Qt::DisplayRole) + && role == Qt::DisplayRole) { - switch (section) + switch (section) { - case 0: return i18n("Title"); - case 1: return i18n("Address"); + case 0: return i18n("Title"); + case 1: return i18n("Address"); } } return QAbstractTableModel::headerData(section, orientation, role); @@ -427,7 +434,7 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const return QVariant(); const HistoryItem &item = lst.at(index.row()); - switch (role) + switch (role) { case DateTimeRole: return item.dateTime; @@ -438,23 +445,27 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const case UrlStringRole: return item.url; case Qt::DisplayRole: - case Qt::EditRole: { - switch (index.column()) { - case 0: - // when there is no title try to generate one from the url - if (item.title.isEmpty()) { - QString page = QFileInfo(QUrl(item.url).path()).fileName(); - if (!page.isEmpty()) - return page; - return item.url; - } - return item.title; - case 1: + case Qt::EditRole: + { + switch (index.column()) + { + case 0: + // when there is no title try to generate one from the url + if (item.title.isEmpty()) + { + QString page = QFileInfo(QUrl(item.url).path()).fileName(); + if (!page.isEmpty()) + return page; return item.url; + } + return item.title; + case 1: + return item.url; } - } + } case Qt::DecorationRole: - if (index.column() == 0) { + if (index.column() == 0) + { return Application::instance()->icon(item.url); } } @@ -502,8 +513,8 @@ bool HistoryModel::removeRows(int row, int count, const QModelIndex &parent) Maps the first bunch of items of the source model to the root */ HistoryMenuModel::HistoryMenuModel(HistoryTreeModel *sourceModel, QObject *parent) - : QAbstractProxyModel(parent) - , m_treeModel(sourceModel) + : QAbstractProxyModel(parent) + , m_treeModel(sourceModel) { setSourceModel(sourceModel); } @@ -529,16 +540,18 @@ int HistoryMenuModel::rowCount(const QModelIndex &parent) const if (parent.column() > 0) return 0; - if (!parent.isValid()) { + if (!parent.isValid()) + { int folders = sourceModel()->rowCount(); int bumpedItems = bumpedRows(); if (bumpedItems <= MOVEDROWS - && bumpedItems == sourceModel()->rowCount(sourceModel()->index(0, 0))) + && bumpedItems == sourceModel()->rowCount(sourceModel()->index(0, 0))) --folders; return bumpedItems + folders; } - if (parent.internalId() == -1) { + if (parent.internalId() == -1) + { if (parent.row() < bumpedRows()) return 0; } @@ -565,7 +578,8 @@ QModelIndex HistoryMenuModel::mapToSource(const QModelIndex &proxyIndex) const if (!proxyIndex.isValid()) return QModelIndex(); - if (proxyIndex.internalId() == -1) { + if (proxyIndex.internalId() == -1) + { int bumpedItems = bumpedRows(); if (proxyIndex.row() < bumpedItems) return m_treeModel->index(proxyIndex.row(), proxyIndex.column(), m_treeModel->index(0, 0)); @@ -583,8 +597,8 @@ QModelIndex HistoryMenuModel::mapToSource(const QModelIndex &proxyIndex) const QModelIndex HistoryMenuModel::index(int row, int column, const QModelIndex &parent) const { if (row < 0 - || column < 0 || column >= columnCount(parent) - || parent.column() > 0) + || column < 0 || column >= columnCount(parent) + || parent.column() > 0) return QModelIndex(); if (!parent.isValid()) return createIndex(row, column, -1); @@ -625,8 +639,8 @@ QModelIndex HistoryMenuModel::parent(const QModelIndex &index) const HistoryMenu::HistoryMenu(QWidget *parent) - : ModelMenu(parent) - , m_history(0) + : ModelMenu(parent) + , m_history(0) { connect(this, SIGNAL(activated(const QModelIndex &)), this, SLOT(activated(const QModelIndex &))); setHoverRole(HistoryModel::UrlStringRole); @@ -641,7 +655,7 @@ void HistoryMenu::activated(const QModelIndex &index) bool HistoryMenu::prePopulated() { - if (!m_history) + if (!m_history) { m_history = Application::historyManager(); m_historyMenuModel = new HistoryMenuModel(m_history->historyTreeModel(), this); @@ -663,11 +677,11 @@ void HistoryMenu::postPopulated() if (m_history->history().count() > 0) addSeparator(); - KAction *showAllAction = new KAction( i18n("Show All History"), this); + KAction *showAllAction = new KAction(i18n("Show All History"), this); connect(showAllAction, SIGNAL(triggered()), this, SLOT(showHistoryDialog())); addAction(showAllAction); - KAction *clearAction = new KAction( i18n("Clear History"), this); + KAction *clearAction = new KAction(i18n("Clear History"), this); connect(clearAction, SIGNAL(triggered()), m_history, SLOT(clear())); addAction(clearAction); } @@ -746,12 +760,13 @@ void HistoryDialog::customContextMenuRequested(const QPoint &pos) QMenu menu; QModelIndex index = tree->indexAt(pos); index = index.sibling(index.row(), 0); - if (index.isValid() && !tree->model()->hasChildren(index)) { - menu.addAction( i18n("Open"), this, SLOT(open())); + if (index.isValid() && !tree->model()->hasChildren(index)) + { + menu.addAction(i18n("Open"), this, SLOT(open())); menu.addSeparator(); - menu.addAction( i18n("Copy"), this, SLOT(copy())); + menu.addAction(i18n("Copy"), this, SLOT(copy())); } - menu.addAction( i18n("Delete"), tree, SLOT(removeOne())); + menu.addAction(i18n("Delete"), tree, SLOT(removeOne())); menu.exec(QCursor::pos()); } @@ -780,8 +795,8 @@ void HistoryDialog::copy() // --------------------------------------------------------------------------------------------------------------- HistoryFilterModel::HistoryFilterModel(QAbstractItemModel *sourceModel, QObject *parent) - : QAbstractProxyModel(parent), - m_loaded(false) + : QAbstractProxyModel(parent), + m_loaded(false) { setSourceModel(sourceModel); } @@ -804,23 +819,25 @@ QVariant HistoryFilterModel::data(const QModelIndex &index, int role) const void HistoryFilterModel::setSourceModel(QAbstractItemModel *newSourceModel) { - if (sourceModel()) { + if (sourceModel()) + { disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); disconnect(sourceModel(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(dataChanged(const QModelIndex &, const QModelIndex &))); disconnect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), - this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); + this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), - this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); + this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); } QAbstractProxyModel::setSourceModel(newSourceModel); - if (sourceModel()) { + if (sourceModel()) + { m_loaded = false; connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); connect(sourceModel(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), - this, SLOT(sourceDataChanged(const QModelIndex &, const QModelIndex &))); + this, SLOT(sourceDataChanged(const QModelIndex &, const QModelIndex &))); connect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); connect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), @@ -885,8 +902,10 @@ QModelIndex HistoryFilterModel::mapFromSource(const QModelIndex &sourceIndex) co int realRow = -1; int sourceModelRow = sourceModel()->rowCount() - sourceIndex.row(); - for (int i = 0; i < m_sourceRow.count(); ++i) { - if (m_sourceRow.at(i) == sourceModelRow) { + for (int i = 0; i < m_sourceRow.count(); ++i) + { + if (m_sourceRow.at(i) == sourceModelRow) + { realRow = i; break; } @@ -902,7 +921,7 @@ QModelIndex HistoryFilterModel::index(int row, int column, const QModelIndex &pa { load(); if (row < 0 || row >= rowCount(parent) - || column < 0 || column >= columnCount(parent)) + || column < 0 || column >= columnCount(parent)) return QModelIndex(); return createIndex(row, column, m_sourceRow[row]); @@ -922,10 +941,12 @@ void HistoryFilterModel::load() const m_sourceRow.clear(); m_historyHash.clear(); m_historyHash.reserve(sourceModel()->rowCount()); - for (int i = 0; i < sourceModel()->rowCount(); ++i) { + for (int i = 0; i < sourceModel()->rowCount(); ++i) + { QModelIndex idx = sourceModel()->index(i, 0); QString url = idx.data(HistoryModel::UrlStringRole).toString(); - if (!m_historyHash.contains(url)) { + if (!m_historyHash.contains(url)) + { m_sourceRow.append(sourceModel()->rowCount() - i); m_historyHash[url] = sourceModel()->rowCount() - i; } @@ -942,7 +963,8 @@ void HistoryFilterModel::sourceRowsInserted(const QModelIndex &parent, int start return; QModelIndex idx = sourceModel()->index(start, 0, parent); QString url = idx.data(HistoryModel::UrlStringRole).toString(); - if (m_historyHash.contains(url)) { + if (m_historyHash.contains(url)) + { int sourceRow = sourceModel()->rowCount() - m_historyHash[url]; int realRow = mapFromSource(sourceModel()->index(sourceRow, 0)).row(); beginRemoveRows(QModelIndex(), realRow, realRow); @@ -975,7 +997,7 @@ bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &paren return false; int lastRow = row + count - 1; disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), - this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); + this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); beginRemoveRows(parent, row, lastRow); int oldCount = rowCount(); int start = sourceModel()->rowCount() - m_sourceRow.value(row); @@ -983,7 +1005,7 @@ bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &paren sourceModel()->removeRows(start, end - start + 1); endRemoveRows(); connect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), - this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); + this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); m_loaded = false; if (oldCount - count != rowCount()) reset(); @@ -995,7 +1017,7 @@ bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &paren HistoryCompletionModel::HistoryCompletionModel(QObject *parent) - : QAbstractProxyModel(parent) + : QAbstractProxyModel(parent) { } @@ -1003,12 +1025,14 @@ HistoryCompletionModel::HistoryCompletionModel(QObject *parent) QVariant HistoryCompletionModel::data(const QModelIndex &index, int role) const { if (sourceModel() - && (role == Qt::EditRole || role == Qt::DisplayRole) - && index.isValid()) { + && (role == Qt::EditRole || role == Qt::DisplayRole) + && index.isValid()) + { QModelIndex idx = mapToSource(index); idx = idx.sibling(idx.row(), 1); QString urlString = idx.data(HistoryModel::UrlStringRole).toString(); - if (index.row() % 2) { + if (index.row() % 2) + { QUrl url = urlString; QString s = url.toString(QUrl::RemoveScheme | QUrl::RemoveUserInfo @@ -1052,7 +1076,7 @@ QModelIndex HistoryCompletionModel::mapToSource(const QModelIndex &proxyIndex) c QModelIndex HistoryCompletionModel::index(int row, int column, const QModelIndex &parent) const { if (row < 0 || row >= rowCount(parent) - || column < 0 || column >= columnCount(parent)) + || column < 0 || column >= columnCount(parent)) return QModelIndex(); return createIndex(row, column, 0); } @@ -1066,17 +1090,19 @@ QModelIndex HistoryCompletionModel::parent(const QModelIndex &) const void HistoryCompletionModel::setSourceModel(QAbstractItemModel *newSourceModel) { - if (sourceModel()) { + if (sourceModel()) + { disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); disconnect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), - this, SLOT(sourceReset())); + this, SLOT(sourceReset())); disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), - this, SLOT(sourceReset())); + this, SLOT(sourceReset())); } QAbstractProxyModel::setSourceModel(newSourceModel); - if (newSourceModel) { + if (newSourceModel) + { connect(newSourceModel, SIGNAL(modelReset()), this, SLOT(sourceReset())); connect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(sourceReset())); @@ -1098,7 +1124,7 @@ void HistoryCompletionModel::sourceReset() HistoryTreeModel::HistoryTreeModel(QAbstractItemModel *sourceModel, QObject *parent) - : QAbstractProxyModel(parent) + : QAbstractProxyModel(parent) { setSourceModel(sourceModel); } @@ -1112,25 +1138,30 @@ QVariant HistoryTreeModel::headerData(int section, Qt::Orientation orientation, QVariant HistoryTreeModel::data(const QModelIndex &index, int role) const { - if ((role == Qt::EditRole || role == Qt::DisplayRole)) { + if ((role == Qt::EditRole || role == Qt::DisplayRole)) + { int start = index.internalId(); - if (start == 0) { + if (start == 0) + { int offset = sourceDateRow(index.row()); - if (index.column() == 0) { + if (index.column() == 0) + { QModelIndex idx = sourceModel()->index(offset, 0); QDate date = idx.data(HistoryModel::DateRole).toDate(); if (date == QDate::currentDate()) return i18n("Earlier Today"); return date.toString(QLatin1String("dddd, MMMM d, yyyy")); } - if (index.column() == 1) { + if (index.column() == 1) + { return QString(rowCount(index.sibling(index.row(), 0))) + i18n(" items") ; } } } if (role == Qt::DecorationRole && index.column() == 0 && !index.parent().isValid()) return KIcon("view-history"); - if (role == HistoryModel::DateRole && index.column() == 0 && index.internalId() == 0) { + if (role == HistoryModel::DateRole && index.column() == 0 && index.internalId() == 0) + { int offset = sourceDateRow(index.row()); QModelIndex idx = sourceModel()->index(offset, 0); return idx.data(HistoryModel::DateRole); @@ -1148,22 +1179,25 @@ int HistoryTreeModel::columnCount(const QModelIndex &parent) const int HistoryTreeModel::rowCount(const QModelIndex &parent) const { - if ( parent.internalId() != 0 - || parent.column() > 0 - || !sourceModel()) + if (parent.internalId() != 0 + || parent.column() > 0 + || !sourceModel()) return 0; // row count OF dates - if (!parent.isValid()) { + if (!parent.isValid()) + { if (!m_sourceRowCache.isEmpty()) return m_sourceRowCache.count(); QDate currentDate; int rows = 0; int totalRows = sourceModel()->rowCount(); - for (int i = 0; i < totalRows; ++i) { + for (int i = 0; i < totalRows; ++i) + { QDate rowDate = sourceModel()->index(i, 0).data(HistoryModel::DateRole).toDate(); - if (rowDate != currentDate) { + if (rowDate != currentDate) + { m_sourceRowCache.append(i); currentDate = rowDate; ++rows; @@ -1189,7 +1223,8 @@ int HistoryTreeModel::sourceDateRow(int row) const if (m_sourceRowCache.isEmpty()) rowCount(QModelIndex()); - if (row >= m_sourceRowCache.count()) { + if (row >= m_sourceRowCache.count()) + { if (!sourceModel()) return 0; return sourceModel()->rowCount(); @@ -1211,8 +1246,8 @@ QModelIndex HistoryTreeModel::mapToSource(const QModelIndex &proxyIndex) const QModelIndex HistoryTreeModel::index(int row, int column, const QModelIndex &parent) const { if (row < 0 - || column < 0 || column >= columnCount(parent) - || parent.column() > 0) + || column < 0 || column >= columnCount(parent) + || parent.column() > 0) return QModelIndex(); if (!parent.isValid()) @@ -1252,13 +1287,17 @@ bool HistoryTreeModel::removeRows(int row, int count, const QModelIndex &parent) if (row < 0 || count <= 0 || row + count > rowCount(parent)) return false; - if (parent.isValid()) { + if (parent.isValid()) + { // removing pages int offset = sourceDateRow(parent.row()); return sourceModel()->removeRows(offset + row, count); - } else { + } + else + { // removing whole dates - for (int i = row + count - 1; i >= row; --i) { + for (int i = row + count - 1; i >= row; --i) + { QModelIndex dateParent = index(i, 0); int offset = sourceDateRow(dateParent.row()); if (!sourceModel()->removeRows(offset, rowCount(dateParent))) @@ -1271,18 +1310,20 @@ bool HistoryTreeModel::removeRows(int row, int count, const QModelIndex &parent) void HistoryTreeModel::setSourceModel(QAbstractItemModel *newSourceModel) { - if (sourceModel()) { + if (sourceModel()) + { disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); disconnect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(sourceReset())); disconnect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), - this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); + this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), - this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); + this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); } QAbstractProxyModel::setSourceModel(newSourceModel); - if (newSourceModel) { + if (newSourceModel) + { connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); connect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(sourceReset())); connect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), @@ -1306,7 +1347,8 @@ void HistoryTreeModel::sourceRowsInserted(const QModelIndex &parent, int start, { Q_UNUSED(parent); // Avoid warnings when compiling release Q_ASSERT(!parent.isValid()); - if (start != 0 || start != end) { + if (start != 0 || start != end) + { m_sourceRowCache.clear(); reset(); return; @@ -1315,10 +1357,13 @@ void HistoryTreeModel::sourceRowsInserted(const QModelIndex &parent, int start, m_sourceRowCache.clear(); QModelIndex treeIndex = mapFromSource(sourceModel()->index(start, 0)); QModelIndex treeParent = treeIndex.parent(); - if (rowCount(treeParent) == 1) { + if (rowCount(treeParent) == 1) + { beginInsertRows(QModelIndex(), 0, 0); endInsertRows(); - } else { + } + else + { beginInsertRows(treeParent, treeIndex.row(), treeIndex.row()); endInsertRows(); } @@ -1349,11 +1394,13 @@ void HistoryTreeModel::sourceRowsRemoved(const QModelIndex &parent, int start, i Q_ASSERT(!parent.isValid()); if (m_sourceRowCache.isEmpty()) return; - for (int i = end; i >= start;) { + for (int i = end; i >= start;) + { QList::iterator it; it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), i); // playing it safe - if (it == m_sourceRowCache.end()) { + if (it == m_sourceRowCache.end()) + { m_sourceRowCache.clear(); reset(); return; @@ -1366,11 +1413,14 @@ void HistoryTreeModel::sourceRowsRemoved(const QModelIndex &parent, int start, i QModelIndex dateParent = index(row, 0); // If we can remove all the rows in the date do that and skip over them int rc = rowCount(dateParent); - if (i - rc + 1 == offset && start <= i - rc + 1) { + if (i - rc + 1 == offset && start <= i - rc + 1) + { beginRemoveRows(QModelIndex(), row, row); m_sourceRowCache.removeAt(row); i -= rc + 1; - } else { + } + else + { beginRemoveRows(dateParent, i - offset, i - offset); ++row; --i; diff --git a/src/history.h b/src/history.h index 4b8773ca..41b4116c 100644 --- a/src/history.h +++ b/src/history.h @@ -49,15 +49,19 @@ public: HistoryItem() {} HistoryItem(const QString &u, const QDateTime &d = QDateTime(), const QString &t = QString()) - : title(t), url(u), dateTime(d) {} + : title(t), url(u), dateTime(d) {} inline bool operator==(const HistoryItem &other) const - { return other.title == title - && other.url == url && other.dateTime == dateTime; } + { + return other.title == title + && other.url == url && other.dateTime == dateTime; + } // history is sorted in reverse inline bool operator <(const HistoryItem &other) const - { return dateTime > other.dateTime; } + { + return dateTime > other.dateTime; + } QString title; QString url; @@ -145,7 +149,8 @@ public slots: void entryUpdated(int offset); public: - enum Roles { + enum Roles + { DateRole = Qt::UserRole + 1, DateTimeRole = Qt::UserRole + 2, UrlRole = Qt::UserRole + 3, @@ -181,7 +186,9 @@ public: HistoryFilterModel(QAbstractItemModel *sourceModel, QObject *parent = 0); inline bool historyContains(const QString &url) const - { load(); return m_historyHash.contains(url); } + { + load(); return m_historyHash.contains(url); + } int historyLocation(const QString &url) const; QModelIndex mapFromSource(const QModelIndex &sourceIndex) const; @@ -191,7 +198,7 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; QModelIndex index(int, int, const QModelIndex& = QModelIndex()) const; - QModelIndex parent(const QModelIndex& index= QModelIndex()) const; + QModelIndex parent(const QModelIndex& index = QModelIndex()) const; bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; @@ -257,8 +264,8 @@ signals: void openUrl(const KUrl &url); public: - HistoryMenu(QWidget *parent = 0); - void setInitialActions(QList actions); + HistoryMenu(QWidget *parent = 0); + void setInitialActions(QList actions); protected: bool prePopulated(); @@ -279,7 +286,7 @@ private: /** * Proxy model for the history model that - * exposes each url http://www.foo.com and + * exposes each url http://www.foo.com and * it url starting at the host www.foo.com * */ @@ -296,7 +303,7 @@ public: QModelIndex mapFromSource(const QModelIndex &sourceIndex) const; QModelIndex mapToSource(const QModelIndex &proxyIndex) const; QModelIndex index(int, int, const QModelIndex& = QModelIndex()) const; - QModelIndex parent(const QModelIndex& index= QModelIndex()) const; + QModelIndex parent(const QModelIndex& index = QModelIndex()) const; void setSourceModel(QAbstractItemModel *sourceModel); private slots: @@ -326,7 +333,7 @@ public: QModelIndex mapFromSource(const QModelIndex &sourceIndex) const; QModelIndex mapToSource(const QModelIndex &proxyIndex) const; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &index= QModelIndex()) const; + QModelIndex parent(const QModelIndex &index = QModelIndex()) const; bool hasChildren(const QModelIndex &parent = QModelIndex()) const; Qt::ItemFlags flags(const QModelIndex &index) const; bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); @@ -349,7 +356,7 @@ private: // ----------------------------------------------------------------------------------------------------------------- /** - * A modified QSortFilterProxyModel that always accepts + * A modified QSortFilterProxyModel that always accepts * the root nodes in the tree * so filtering is only done on the children. * Used in the HistoryDialog. diff --git a/src/main.cpp b/src/main.cpp index 71f5792d..9248aa14 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,34 +34,34 @@ static const char version[] = "0.0.5"; int main(int argc, char **argv) { - KAboutData about( "rekonq", - 0, - ki18n("rekonq"), - version, - ki18n(description), - KAboutData::License_GPL, - ki18n("(C) 2008 Andrea Diamantini"), - KLocalizedString(), - "http://rekonq.sourceforge.net", - "adjam7@gmail.com" + KAboutData about("rekonq", + 0, + ki18n("rekonq"), + version, + ki18n(description), + KAboutData::License_GPL, + ki18n("(C) 2008 Andrea Diamantini"), + KLocalizedString(), + "http://rekonq.sourceforge.net", + "adjam7@gmail.com" ); - about.addAuthor( ki18n("Andrea Diamantini"), - KLocalizedString(), - "adjam7@gmail.com" + about.addAuthor(ki18n("Andrea Diamantini"), + KLocalizedString(), + "adjam7@gmail.com" ); KCmdLineArgs::init(argc, argv, &about); KCmdLineOptions options; - options.add( "+URL" , ki18n("Location to open") ); - KCmdLineArgs::addCmdLineOptions( options ); + options.add("+URL" , ki18n("Location to open")); + KCmdLineArgs::addCmdLineOptions(options); Application::addCmdLineOptions(); - if (!Application::start()) + if (!Application::start()) { - kWarning() << "rekonq is already running!"; - return 0; + kWarning() << "rekonq is already running!"; + return 0; } Application app; return app.exec(); diff --git a/src/mainview.cpp b/src/mainview.cpp index 7238b966..4ab8dc8b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -52,12 +52,12 @@ MainView::MainView(QWidget *parent) - : KTabWidget(parent) - , m_recentlyClosedTabsAction(0) - , m_recentlyClosedTabsMenu(0) - , m_lineEditCompleter(0) - , m_lineEdits(new QStackedWidget(this)) - , m_tabBar(new TabBar(this)) + : KTabWidget(parent) + , m_recentlyClosedTabsAction(0) + , m_recentlyClosedTabsMenu(0) + , m_lineEditCompleter(0) + , m_lineEdits(new QStackedWidget(this)) + , m_tabBar(new TabBar(this)) { setTabBar(m_tabBar); @@ -86,29 +86,29 @@ MainView::~MainView() { delete m_lineEditCompleter; delete m_recentlyClosedTabsMenu; -} +} void MainView::showTabBar() { bool astb = ReKonfig::alwaysShowTabBar(); - if(astb == true) + if (astb == true) { - if( m_tabBar->isHidden() ) + if (m_tabBar->isHidden()) { m_tabBar->show(); } return; } - if( m_tabBar->count() == 1 ) + if (m_tabBar->count() == 1) { m_tabBar->hide(); } else { - if( m_tabBar->isHidden() ) + if (m_tabBar->isHidden()) { m_tabBar->show(); } @@ -208,7 +208,7 @@ void MainView::clear() // clear the recently closed tabs m_recentlyClosedTabs.clear(); // clear the line edit history - for (int i = 0; i < m_lineEdits->count(); ++i) + for (int i = 0; i < m_lineEdits->count(); ++i) { QLineEdit *qLineEdit = lineEdit(i); qLineEdit->setText(qLineEdit->text()); @@ -252,10 +252,10 @@ void MainView::currentChanged(int index) if (!webView) return; - Q_ASSERT( m_lineEdits->count() == count() ); + Q_ASSERT(m_lineEdits->count() == count()); WebView *oldWebView = this->webView(m_lineEdits->currentIndex()); - if (oldWebView) + if (oldWebView) { disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); @@ -306,14 +306,14 @@ QLineEdit *MainView::lineEdit(int index) const WebView *MainView::webView(int index) const { QWidget *widget = this->widget(index); - if (WebView *webView = qobject_cast(widget)) + if (WebView *webView = qobject_cast(widget)) { return webView; - } - else + } + else { // optimization to delay creating the first webview - if (count() == 1) + if (count() == 1) { MainView *that = const_cast(this); that->setUpdatesEnabled(false); @@ -339,7 +339,7 @@ WebView *MainView::newTab(bool makeCurrent) // line edit UrlBar *urlLineEdit = new UrlBar; QLineEdit *lineEdit = urlLineEdit->lineEdit(); - if (!m_lineEditCompleter && count() > 0) + if (!m_lineEditCompleter && count() > 0) { HistoryCompletionModel *completionModel = new HistoryCompletionModel(this); completionModel->setSourceModel(Application::historyManager()->historyFilterModel()); @@ -358,7 +358,7 @@ WebView *MainView::newTab(bool makeCurrent) m_lineEdits->setSizePolicy(lineEdit->sizePolicy()); // optimization to delay creating the more expensive WebView, history, etc - if (count() == 0) + if (count() == 0) { QWidget *emptyWidget = new QWidget; QPalette p = emptyWidget->palette(); @@ -370,7 +370,7 @@ WebView *MainView::newTab(bool makeCurrent) connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); return 0; } - + // webview WebView *webView = new WebView; urlLineEdit->setWebView(webView); @@ -387,10 +387,10 @@ WebView *MainView::newTab(bool makeCurrent) connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SIGNAL(statusBarVisibilityChangeRequested(bool))); connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SIGNAL(toolBarVisibilityChangeRequested(bool))); - connect(webView, SIGNAL( ctrlTabPressed() ), this, SLOT( nextTab() ) ); - connect(webView, SIGNAL( shiftCtrlTabPressed() ), this, SLOT( previousTab() ) ); + connect(webView, SIGNAL(ctrlTabPressed()), this, SLOT(nextTab())); + connect(webView, SIGNAL(shiftCtrlTabPressed()), this, SLOT(previousTab())); - addTab(webView, i18n("(Untitled)") ); + addTab(webView, i18n("(Untitled)")); if (makeCurrent) setCurrentWidget(webView); @@ -406,10 +406,10 @@ WebView *MainView::newTab(bool makeCurrent) void MainView::reloadAllTabs() { - for (int i = 0; i < count(); ++i) + for (int i = 0; i < count(); ++i) { QWidget *tabWidget = widget(i); - if (WebView *tab = qobject_cast(tabWidget)) + if (WebView *tab = qobject_cast(tabWidget)) { tab->reload(); } @@ -419,9 +419,9 @@ void MainView::reloadAllTabs() void MainView::lineEditReturnPressed() { - if (QLineEdit *lineEdit = qobject_cast(sender())) + if (QLineEdit *lineEdit = qobject_cast(sender())) { - emit loadUrlPage( KUrl( lineEdit->text() ) ); + emit loadUrlPage(KUrl(lineEdit->text())); if (m_lineEdits->currentWidget() == lineEdit) { currentWebView()->setFocus(); @@ -435,7 +435,7 @@ void MainView::windowCloseRequested() WebPage *webPage = qobject_cast(sender()); WebView *webView = qobject_cast(webPage->view()); int index = webViewIndex(webView); - if (index >= 0) + if (index >= 0) { if (count() == 1) webView->webPage()->mainWindow()->close(); @@ -466,7 +466,7 @@ void MainView::cloneTab(int index) if (index < 0 || index >= count()) return; WebView *tab = newTab(false); - tab->setUrl( webView(index)->url() ); + tab->setUrl(webView(index)->url()); showTabBar(); } @@ -481,16 +481,16 @@ void MainView::closeTab(int index) return; bool hasFocus = false; - if (WebView *tab = webView(index)) + if (WebView *tab = webView(index)) { - if (tab->isModified()) + if (tab->isModified()) { - int risp = KMessageBox::questionYesNo( this , - i18n("You have modified this page and when closing it you would lose the modification.\n" - "Do you really want to close this page?\n"), - i18n("Do you really want to close this page?"), - KStandardGuiItem::no() ); - if( risp == KMessageBox::No ) + int risp = KMessageBox::questionYesNo(this , + i18n("You have modified this page and when closing it you would lose the modification.\n" + "Do you really want to close this page?\n"), + i18n("Do you really want to close this page?"), + KStandardGuiItem::no()); + if (risp == KMessageBox::No) return; } hasFocus = tab->hasFocus(); @@ -520,9 +520,9 @@ void MainView::webViewLoadStarted() { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - if (-1 != index) + if (-1 != index) { - setTabIcon(index, KIcon("rekonq") ); + setTabIcon(index, KIcon("rekonq")); } } @@ -531,7 +531,7 @@ void MainView::webViewIconChanged() { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - if (-1 != index) + if (-1 != index) { QIcon icon = Application::instance()->icon(webView->url()); setTabIcon(index, icon); @@ -543,7 +543,8 @@ void MainView::webViewTitleChanged(const QString &title) { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - if (-1 != index) { + if (-1 != index) + { setTabText(index, title); } if (currentIndex() == index) @@ -556,7 +557,8 @@ void MainView::webViewUrlChanged(const QUrl &url) { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - if (-1 != index) { + if (-1 != index) + { m_tabBar->setTabData(index, url); } emit tabsChanged(); @@ -566,13 +568,13 @@ void MainView::webViewUrlChanged(const QUrl &url) void MainView::aboutToShowRecentTabsMenu() { m_recentlyClosedTabsMenu->clear(); - for (int i = 0; i < m_recentlyClosedTabs.count(); ++i) + for (int i = 0; i < m_recentlyClosedTabs.count(); ++i) { KAction *action = new KAction(m_recentlyClosedTabsMenu); action->setData(m_recentlyClosedTabs.at(i)); QIcon icon = Application::instance()->icon(m_recentlyClosedTabs.at(i)); action->setIcon(icon); - action->setText( m_recentlyClosedTabs.at(i).prettyUrl() ); + action->setText(m_recentlyClosedTabs.at(i).prettyUrl()); m_recentlyClosedTabsMenu->addAction(action); } } @@ -587,9 +589,9 @@ void MainView::aboutToShowRecentTriggeredAction(QAction *action) void MainView::mouseDoubleClickEvent(QMouseEvent *event) { - if ( !childAt(event->pos() ) - // Remove the line below when QTabWidget does not have a one pixel frame - && event->pos().y() < (tabBar()->y() + tabBar()->height())) + if (!childAt(event->pos()) + // Remove the line below when QTabWidget does not have a one pixel frame + && event->pos().y() < (tabBar()->y() + tabBar()->height())) { newTab(); return; @@ -600,7 +602,8 @@ void MainView::mouseDoubleClickEvent(QMouseEvent *event) void MainView::contextMenuEvent(QContextMenuEvent *event) { - if (!childAt(event->pos())) { + if (!childAt(event->pos())) + { m_tabBar->contextMenuRequested(event->pos()); return; } @@ -612,10 +615,10 @@ void MainView::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::MidButton && !childAt(event->pos()) // Remove the line below when QTabWidget does not have a one pixel frame - && event->pos().y() < (tabBar()->y() + tabBar()->height())) + && event->pos().y() < (tabBar()->y() + tabBar()->height())) { - KUrl url( QApplication::clipboard()->text(QClipboard::Selection) ); - if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) + KUrl url(QApplication::clipboard()->text(QClipboard::Selection)); + if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) { WebView *webView = newTab(); webView->setUrl(url); diff --git a/src/mainview.h b/src/mainview.h index 78fe2a2c..4e2d8b6e 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -87,8 +87,8 @@ public: QLineEdit *lineEdit(int index) const; int webViewIndex(WebView *webView) const; - /** - * show and hide TabBar if user doesn't choose + /** + * show and hide TabBar if user doesn't choose * "Always Show TabBar" option * */ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6f12220f..d76b0d8d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -63,9 +63,9 @@ MainWindow::MainWindow() - : KXmlGuiWindow() - , m_view( new MainView(this) ) - , m_bookmarksProvider( new BookmarksProvider(this) ) + : KXmlGuiWindow() + , m_view(new MainView(this)) + , m_bookmarksProvider(new BookmarksProvider(this)) { // accept dnd setAcceptDrops(true); @@ -81,26 +81,26 @@ MainWindow::MainWindow() // Find Bar m_findBar = new FindBar(this); - connect( m_findBar, SIGNAL( searchString(const QString &) ), this, SLOT( slotFind(const QString &) ) ); + connect(m_findBar, SIGNAL(searchString(const QString &)), this, SLOT(slotFind(const QString &))); layout->addWidget(m_findBar); centralWidget->setLayout(layout); setCentralWidget(centralWidget); // setting size policies - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // connect signals and slots - connect(m_view, SIGNAL( loadUrlPage(const KUrl &) ), this, SLOT( loadUrl(const KUrl &) ) ); - connect(m_view, SIGNAL( setCurrentTitle(const QString &)), this, SLOT( slotUpdateWindowTitle(const QString &) ) ); - connect(m_view, SIGNAL( showStatusBarMessage(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); - connect(m_view, SIGNAL( linkHovered(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); - connect(m_view, SIGNAL( loadProgress(int)), this, SLOT( slotLoadProgress(int) ) ); - connect(m_view, SIGNAL( geometryChangeRequested(const QRect &)), this, SLOT( geometryChangeRequested(const QRect &) ) ); - connect(m_view, SIGNAL( printRequested(QWebFrame *)), this, SLOT( printRequested(QWebFrame *) ) ); - connect(m_view, SIGNAL( menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT( setVisible(bool) ) ); - connect(m_view, SIGNAL( statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT( setVisible(bool) ) ); - connect(m_view, SIGNAL( lastTabClosed() ), m_view, SLOT(newTab() ) ); + connect(m_view, SIGNAL(loadUrlPage(const KUrl &)), this, SLOT(loadUrl(const KUrl &))); + connect(m_view, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(slotUpdateWindowTitle(const QString &))); + connect(m_view, SIGNAL(showStatusBarMessage(const QString&)), statusBar(), SLOT(showMessage(const QString&))); + connect(m_view, SIGNAL(linkHovered(const QString&)), statusBar(), SLOT(showMessage(const QString&))); + connect(m_view, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int))); + connect(m_view, SIGNAL(geometryChangeRequested(const QRect &)), this, SLOT(geometryChangeRequested(const QRect &))); + connect(m_view, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *))); + connect(m_view, SIGNAL(menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT(setVisible(bool))); + connect(m_view, SIGNAL(statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT(setVisible(bool))); + connect(m_view, SIGNAL(lastTabClosed()), m_view, SLOT(newTab())); slotUpdateWindowTitle(); @@ -111,10 +111,10 @@ MainWindow::MainWindow() statusBar()->show(); // ----- BOOKMARKS MENU: this has to be done BEFORE setupGUI!! - KAction *a = new KActionMenu( i18n("B&ookmarks"), this ); - actionCollection()->addAction( QLatin1String("bookmarks"), a ); + KAction *a = new KActionMenu(i18n("B&ookmarks"), this); + actionCollection()->addAction(QLatin1String("bookmarks"), a); KMenu *bmMenu = m_bookmarksProvider->bookmarksMenu(); - a->setMenu( bmMenu ); + a->setMenu(bmMenu); // a call to KXmlGuiWindow::setupGUI() populates the GUI // with actions, using KXMLGUI. @@ -130,17 +130,17 @@ MainWindow::MainWindow() setupTabBar(); // setting up custom widgets.. - KToolBar *navigationBar = toolBar( "mainToolBar" ); - navigationBar->addWidget( m_view->lineEditStack() ); + KToolBar *navigationBar = toolBar("mainToolBar"); + navigationBar->addWidget(m_view->lineEditStack()); KToolBar *bmToolbar = toolBar("bookmarksToolBar"); - m_bookmarksProvider->provideBmToolbar( bmToolbar ); + m_bookmarksProvider->provideBmToolbar(bmToolbar); // setting up toolbars to NOT have context menu enabled - setContextMenuPolicy( Qt::DefaultContextMenu ); + setContextMenuPolicy(Qt::DefaultContextMenu); // search bar - m_searchBar = new SearchBar( this ); + m_searchBar = new SearchBar(this); connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); navigationBar->addWidget(m_searchBar); } @@ -165,106 +165,106 @@ void MainWindow::setupActions() KAction *a; // Standard Actions - KStandardAction::openNew(this, SLOT( slotFileNew() ) , actionCollection() ); - KStandardAction::open( this, SLOT( slotFileOpen() ), actionCollection() ); - KStandardAction::saveAs( this, SLOT( slotFileSaveAs() ), actionCollection() ); - KStandardAction::printPreview( this, SLOT( slotFilePrintPreview() ), actionCollection() ); - KStandardAction::print( this, SLOT( slotFilePrint() ), actionCollection() ); - KStandardAction::quit( this , SLOT( close() ), actionCollection() ); - KStandardAction::find(this, SLOT( slotViewFindBar() ) , actionCollection() ); - KStandardAction::findNext(this, SLOT( slotFindNext() ) , actionCollection() ); - KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , actionCollection() ); - KStandardAction::fullScreen( this, SLOT( slotViewFullScreen(bool) ), this, actionCollection() ); - KStandardAction::home( this, SLOT( slotHome() ), actionCollection() ); - KStandardAction::preferences( this, SLOT( slotPreferences() ), actionCollection() ); + KStandardAction::openNew(this, SLOT(slotFileNew()) , actionCollection()); + KStandardAction::open(this, SLOT(slotFileOpen()), actionCollection()); + KStandardAction::saveAs(this, SLOT(slotFileSaveAs()), actionCollection()); + KStandardAction::printPreview(this, SLOT(slotFilePrintPreview()), actionCollection()); + KStandardAction::print(this, SLOT(slotFilePrint()), actionCollection()); + KStandardAction::quit(this , SLOT(close()), actionCollection()); + KStandardAction::find(this, SLOT(slotViewFindBar()) , actionCollection()); + KStandardAction::findNext(this, SLOT(slotFindNext()) , actionCollection()); + KStandardAction::findPrev(this, SLOT(slotFindPrevious()) , actionCollection()); + KStandardAction::fullScreen(this, SLOT(slotViewFullScreen(bool)), this, actionCollection()); + KStandardAction::home(this, SLOT(slotHome()), actionCollection()); + KStandardAction::preferences(this, SLOT(slotPreferences()), actionCollection()); // WEB Actions (NO KStandardActions..) - KStandardAction::redisplay( m_view, SLOT( slotWebReload() ), actionCollection() ); - KStandardAction::back( m_view, SLOT( slotWebBack() ), actionCollection() ); - KStandardAction::forward( m_view, SLOT( slotWebForward() ), actionCollection() ); - KStandardAction::undo( m_view, SLOT( slotWebUndo() ), actionCollection() ); - KStandardAction::redo( m_view, SLOT( slotWebRedo() ), actionCollection() ); - KStandardAction::cut( m_view, SLOT( slotWebCut() ), actionCollection() ); - KStandardAction::copy( m_view, SLOT( slotWebCopy() ), actionCollection() ); - KStandardAction::paste( m_view, SLOT( slotWebPaste() ), actionCollection() ); - - a = new KAction ( KIcon( "process-stop" ), i18n("&Stop"), this ); - a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); - actionCollection()->addAction( QLatin1String("stop"), a ); - connect( a, SIGNAL( triggered(bool) ), m_view, SLOT( slotWebStop() ) ); - - // stop reload Action - m_stopReload = new KAction( KIcon("view-refresh"), i18n("reload"), this ); - actionCollection()->addAction( QLatin1String("stop reload") , m_stopReload ); - - // ============== Custom Actions - a = new KAction( KIcon(), i18n("Open Location"), this); - actionCollection()->addAction( QLatin1String("open location"), a ); - connect( a, SIGNAL( triggered(bool) ) , this, SLOT( slotOpenLocation() ) ); - - a = new KAction( i18n("Private &Browsing..."), this ); + KStandardAction::redisplay(m_view, SLOT(slotWebReload()), actionCollection()); + KStandardAction::back(m_view, SLOT(slotWebBack()), actionCollection()); + KStandardAction::forward(m_view, SLOT(slotWebForward()), actionCollection()); + KStandardAction::undo(m_view, SLOT(slotWebUndo()), actionCollection()); + KStandardAction::redo(m_view, SLOT(slotWebRedo()), actionCollection()); + KStandardAction::cut(m_view, SLOT(slotWebCut()), actionCollection()); + KStandardAction::copy(m_view, SLOT(slotWebCopy()), actionCollection()); + KStandardAction::paste(m_view, SLOT(slotWebPaste()), actionCollection()); + + a = new KAction(KIcon("process-stop"), i18n("&Stop"), this); + a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Period)); + actionCollection()->addAction(QLatin1String("stop"), a); + connect(a, SIGNAL(triggered(bool)), m_view, SLOT(slotWebStop())); + + // stop reload Action + m_stopReload = new KAction(KIcon("view-refresh"), i18n("reload"), this); + actionCollection()->addAction(QLatin1String("stop reload") , m_stopReload); + + // ============== Custom Actions + a = new KAction(KIcon(), i18n("Open Location"), this); + actionCollection()->addAction(QLatin1String("open location"), a); + connect(a, SIGNAL(triggered(bool)) , this, SLOT(slotOpenLocation())); + + a = new KAction(i18n("Private &Browsing..."), this); a->setCheckable(true); - actionCollection()->addAction( i18n("private browsing"), a ); - connect( a, SIGNAL( triggered(bool) ) , this, SLOT( slotPrivateBrowsing() ) ); + actionCollection()->addAction(i18n("private browsing"), a); + connect(a, SIGNAL(triggered(bool)) , this, SLOT(slotPrivateBrowsing())); - a = new KAction( KIcon("zoom-in"), i18n("&Enlarge Font"), this ); - a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Plus) ); - actionCollection()->addAction( QLatin1String("bigger font"), a ); - connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotViewTextBigger() ) ); + a = new KAction(KIcon("zoom-in"), i18n("&Enlarge Font"), this); + a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Plus)); + actionCollection()->addAction(QLatin1String("bigger font"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewTextBigger())); - a = new KAction( KIcon("zoom-original"), i18n("&Normal Font"), this ); - a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_0) ); - actionCollection()->addAction( QLatin1String("normal font"), a ); - connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotViewTextNormal() ) ); + a = new KAction(KIcon("zoom-original"), i18n("&Normal Font"), this); + a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_0)); + actionCollection()->addAction(QLatin1String("normal font"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewTextNormal())); - a = new KAction( KIcon("zoom-out"), i18n("&Shrink Font"), this ); - a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Minus) ); - actionCollection()->addAction( QLatin1String("smaller font"), a ); - connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotViewTextSmaller() ) ); + a = new KAction(KIcon("zoom-out"), i18n("&Shrink Font"), this); + a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Minus)); + actionCollection()->addAction(QLatin1String("smaller font"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewTextSmaller())); - a = new KAction( i18n("Page S&ource"), this ); - actionCollection()->addAction( QLatin1String("page source"), a ); - connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotViewPageSource() ) ); + a = new KAction(i18n("Page S&ource"), this); + actionCollection()->addAction(QLatin1String("page source"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewPageSource())); - a = new KAction( KIcon("tools-report-bug"), i18n("Enable Web &Inspector"), this ); + a = new KAction(KIcon("tools-report-bug"), i18n("Enable Web &Inspector"), this); a->setCheckable(true); - actionCollection()->addAction( QLatin1String("web inspector"), a ); - connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotToggleInspector(bool) ) ); + actionCollection()->addAction(QLatin1String("web inspector"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(slotToggleInspector(bool))); // ================ history related actions - KAction *historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); + KAction *historyBack = new KAction(KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); historyBack->setMenu(m_historyBackMenu); - connect(historyBack, SIGNAL( triggered(bool) ), this, SLOT( slotOpenPrevious() ) ); + connect(historyBack, SIGNAL(triggered(bool)), this, SLOT(slotOpenPrevious())); // FIXME < --------------------------------------------------------------------------------------------------------------------------------------| connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); - actionCollection()->addAction( QLatin1String("history back"), historyBack); + actionCollection()->addAction(QLatin1String("history back"), historyBack); - KAction *historyForward = new KAction( KIcon("go-next"), i18n("Forward"), this ); - connect(historyForward, SIGNAL( triggered(bool) ), this, SLOT( slotOpenNext() ) ); - actionCollection()->addAction( QLatin1String("history forward"), historyForward ); + KAction *historyForward = new KAction(KIcon("go-next"), i18n("Forward"), this); + connect(historyForward, SIGNAL(triggered(bool)), this, SLOT(slotOpenNext())); + actionCollection()->addAction(QLatin1String("history forward"), historyForward); // =================== Tab Actions - a = new KAction( KIcon("tab-new"), i18n("New &Tab"), this); - a->setShortcut( KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T) ); - actionCollection()->addAction( QLatin1String("new tab"), a); - connect(a, SIGNAL( triggered(bool) ), m_view, SLOT(newTab())); + a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this); + a->setShortcut(KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T)); + actionCollection()->addAction(QLatin1String("new tab"), a); + connect(a, SIGNAL(triggered(bool)), m_view, SLOT(newTab())); a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); - a->setShortcut( KShortcut( Qt::CTRL + Qt::Key_W ) ); - actionCollection()->addAction( QLatin1String("close tab"), a); - connect(a, SIGNAL( triggered(bool) ), m_view, SLOT(closeTab())); + a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_W)); + actionCollection()->addAction(QLatin1String("close tab"), a); + connect(a, SIGNAL(triggered(bool)), m_view, SLOT(closeTab())); a = new KAction(i18n("Show Next Tab"), this); - a->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext() ); - actionCollection()->addAction( QLatin1String("show next tab"), a); - connect(a, SIGNAL( triggered(bool) ), m_view, SLOT(nextTab())); + a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext()); + actionCollection()->addAction(QLatin1String("show next tab"), a); + connect(a, SIGNAL(triggered(bool)), m_view, SLOT(nextTab())); a = new KAction(i18n("Show Previous Tab"), this); - a->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev() ); - actionCollection()->addAction( QLatin1String("show prev tab"), a); - connect(a, SIGNAL( triggered(bool) ), m_view, SLOT(previousTab())); + a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev()); + actionCollection()->addAction(QLatin1String("show prev tab"), a); + connect(a, SIGNAL(triggered(bool)), m_view, SLOT(previousTab())); } @@ -272,14 +272,14 @@ void MainWindow::setupTabBar() { // Left corner button QToolButton *addTabButton = new QToolButton(this); - addTabButton->setDefaultAction( actionCollection()->action("new tab") ); + addTabButton->setDefaultAction(actionCollection()->action("new tab")); addTabButton->setAutoRaise(true); addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); m_view->setCornerWidget(addTabButton, Qt::TopLeftCorner); // right corner button QToolButton *closeTabButton = new QToolButton(this); - closeTabButton->setDefaultAction( actionCollection()->action("close tab") ); + closeTabButton->setDefaultAction(actionCollection()->action("close tab")); closeTabButton->setAutoRaise(true); closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); m_view->setCornerWidget(closeTabButton, Qt::TopRightCorner); @@ -291,13 +291,13 @@ void MainWindow::setupHistoryMenu() HistoryMenu *historyMenu = new HistoryMenu(this); connect(historyMenu, SIGNAL(openUrl(const KUrl&)), m_view, SLOT(loadUrlInCurrentTab(const KUrl&))); connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); - historyMenu->setTitle( i18n("&History") ); - menuBar()->insertMenu( actionCollection()->action("bookmarks"), historyMenu); + historyMenu->setTitle(i18n("&History")); + menuBar()->insertMenu(actionCollection()->action("bookmarks"), historyMenu); QList historyActions; - historyActions.append( actionCollection()->action("history back") ); - historyActions.append( actionCollection()->action("history forward") ); - historyActions.append( m_view->recentlyClosedTabsAction() ); + historyActions.append(actionCollection()->action("history back")); + historyActions.append(actionCollection()->action("history forward")); + historyActions.append(m_view->recentlyClosedTabsAction()); historyMenu->setInitialActions(historyActions); } @@ -308,7 +308,7 @@ void MainWindow::setupHistoryMenu() void MainWindow::slotUpdateConf() { - // ============== General ================== + // ============== General ================== m_homePage = ReKonfig::homePage(); mainView()->showTabBar(); @@ -354,34 +354,34 @@ KUrl MainWindow::guessUrlFromString(const QString &string) // Check if it looks like a qualified URL. Try parsing it and see. bool hasSchema = test.exactMatch(urlStr); - if (hasSchema) + if (hasSchema) { QUrl qurl(urlStr, QUrl::TolerantMode); KUrl url(qurl); - if ( url.isValid() ) + if (url.isValid()) { return url; } } // Might be a file. - if (QFile::exists(urlStr)) + if (QFile::exists(urlStr)) { QFileInfo info(urlStr); - return KUrl::fromPath( info.absoluteFilePath() ); + return KUrl::fromPath(info.absoluteFilePath()); } // Might be a shorturl - try to detect the schema. - if (!hasSchema) + if (!hasSchema) { int dotIndex = urlStr.indexOf(QLatin1Char('.')); - if (dotIndex != -1) + if (dotIndex != -1) { QString prefix = urlStr.left(dotIndex).toLower(); QString schema = (prefix == QLatin1String("ftp")) ? prefix : QLatin1String("http"); QUrl qurl(schema + QLatin1String("://") + urlStr, QUrl::TolerantMode); KUrl url(qurl); - if ( url.isValid() ) + if (url.isValid()) { return url; } @@ -393,7 +393,7 @@ KUrl MainWindow::guessUrlFromString(const QString &string) KUrl url(qurl); // finally for cases where the user just types in a hostname add http - if ( qurl.scheme().isEmpty() ) + if (qurl.scheme().isEmpty()) { qurl = QUrl(QLatin1String("http://") + string, QUrl::TolerantMode); url = KUrl(qurl); @@ -407,7 +407,7 @@ void MainWindow::loadUrl(const KUrl &url) if (!currentTab() || url.isEmpty()) return; - m_view->currentLineEdit()->setText( url.prettyUrl() ); + m_view->currentLineEdit()->setText(url.prettyUrl()); m_view->loadUrlInCurrentTab(url); } @@ -424,7 +424,7 @@ void MainWindow::slotFileSaveAs() KUrl srcUrl = currentTab()->url(); QString destPath = KFileDialog::getSaveFileName(); KUrl destUrl = KUrl(destPath); - Application::instance()->downloadUrl( srcUrl, destUrl ); + Application::instance()->downloadUrl(srcUrl, destUrl); } @@ -432,7 +432,7 @@ void MainWindow::slotPreferences() { // an instance the dialog could be already created and could be cached, // in which case you want to display the cached dialog - if ( SettingsDialog::showDialog( "rekonfig" ) ) + if (SettingsDialog::showDialog("rekonfig")) return; // we didn't find an instance of this dialog, so lets create it @@ -453,11 +453,11 @@ void MainWindow::slotUpdateStatusbar(const QString &string) void MainWindow::slotUpdateWindowTitle(const QString &title) { - if (title.isEmpty()) + if (title.isEmpty()) { setWindowTitle("rekonq"); - } - else + } + else { setWindowTitle(title + " - rekonq"); } @@ -473,16 +473,16 @@ void MainWindow::slotFileNew() void MainWindow::slotFileOpen() { - QString filePath = KFileDialog::getOpenFileName( KUrl(), - i18n("Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)"), - this, - i18n("Open Web Resource") + QString filePath = KFileDialog::getOpenFileName(KUrl(), + i18n("Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)"), + this, + i18n("Open Web Resource") ); if (filePath.isEmpty()) return; - loadUrl( guessUrlFromString(filePath) ); + loadUrl(guessUrlFromString(filePath)); } @@ -508,8 +508,8 @@ void MainWindow::printRequested(QWebFrame *frame) { QPrinter printer; QPrintDialog *dialog = new QPrintDialog(&printer, this); - dialog->setWindowTitle( i18n("Print Document") ); - if (dialog->exec() != QDialog::Accepted ) + dialog->setWindowTitle(i18n("Print Document")); + if (dialog->exec() != QDialog::Accepted) return; frame->print(&printer); } @@ -519,25 +519,25 @@ void MainWindow::slotPrivateBrowsing() { QWebSettings *settings = QWebSettings::globalSettings(); bool pb = settings->testAttribute(QWebSettings::PrivateBrowsingEnabled); - if (!pb) + if (!pb) { QString title = i18n("Are you sure you want to turn on private browsing?"); QString text = "" + title + i18n("

When private browsing in turned on," - " webpages are not added to the history," - " items are automatically removed from the Downloads window," \ - " new cookies are not stored, current cookies can't be accessed," \ - " site icons wont be stored, session wont be saved, " \ - " and searches are not addded to the pop-up menu in the Google search box." \ - " Until you close the window, you can still click the Back and Forward buttons" \ - " to return to the webpages you have opened."); - - int button = KMessageBox::questionYesNo( this, text, title ); - if (button == KMessageBox::Ok) + " webpages are not added to the history," + " items are automatically removed from the Downloads window," \ + " new cookies are not stored, current cookies can't be accessed," \ + " site icons wont be stored, session wont be saved, " \ + " and searches are not addded to the pop-up menu in the Google search box." \ + " Until you close the window, you can still click the Back and Forward buttons" \ + " to return to the webpages you have opened."); + + int button = KMessageBox::questionYesNo(this, text, title); + if (button == KMessageBox::Ok) { settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); } - } - else + } + else { settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false); @@ -550,13 +550,13 @@ void MainWindow::slotPrivateBrowsing() // void MainWindow::closeEvent(QCloseEvent *event) // { -// if (m_view->count() > 1) +// if (m_view->count() > 1) // { -// int ret = KMessageBox::warningYesNo(this, +// int ret = KMessageBox::warningYesNo(this, // i18n("Are you sure you want to close the window?" " There are %1 tab open" , m_view->count() ), -// i18n("Closing") +// i18n("Closing") // ); -// if (ret == KMessageBox::No) +// if (ret == KMessageBox::No) // { // event->ignore(); // return; @@ -588,7 +588,7 @@ void MainWindow::slotFindNext() return; if (!currentTab()->findText(m_lastSearch, QWebPage::FindWrapsAroundDocument)) { - slotUpdateStatusbar( QString(m_lastSearch) + i18n(" not found.") ); + slotUpdateStatusbar(QString(m_lastSearch) + i18n(" not found.")); } } @@ -599,7 +599,7 @@ void MainWindow::slotFindPrevious() return; if (!currentTab()->findText(m_lastSearch, QWebPage::FindBackward)) { - slotUpdateStatusbar( QString(m_lastSearch) + i18n(" not found.") ); + slotUpdateStatusbar(QString(m_lastSearch) + i18n(" not found.")); } } @@ -629,9 +629,9 @@ void MainWindow::slotViewTextSmaller() // TODO improve this -void MainWindow::slotViewFullScreen( bool makeFullScreen ) +void MainWindow::slotViewFullScreen(bool makeFullScreen) { - if ( makeFullScreen == true ) + if (makeFullScreen == true) { menuBar()->hide(); toolBar("mainToolBar")->hide(); @@ -641,7 +641,7 @@ void MainWindow::slotViewFullScreen( bool makeFullScreen ) menuBar()->show(); toolBar("mainToolBar")->show(); } - KToggleFullScreenAction::setFullScreen( this, makeFullScreen ); + KToggleFullScreenAction::setFullScreen(this, makeFullScreen); } @@ -652,7 +652,7 @@ void MainWindow::slotViewPageSource() QString markup = currentTab()->page()->mainFrame()->toHtml(); QPlainTextEdit *view = new QPlainTextEdit(markup); - view->setWindowTitle( i18n("Page Source of ") + currentTab()->title() ); + view->setWindowTitle(i18n("Page Source of ") + currentTab()->title()); view->setMinimumWidth(640); view->setAttribute(Qt::WA_DeleteOnClose); view->show(); @@ -661,20 +661,20 @@ void MainWindow::slotViewPageSource() void MainWindow::slotHome() { - loadUrl( KUrl(m_homePage) ); + loadUrl(KUrl(m_homePage)); } void MainWindow::slotToggleInspector(bool enable) { QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, enable); - if (enable) + if (enable) { - int result = KMessageBox::questionYesNo(this, - i18n("The web inspector will only work correctly for pages that were loaded after enabling.\n" - "Do you want to reload all pages?"), - i18n("Web Inspector") ); - if (result == KMessageBox::Yes) + int result = KMessageBox::questionYesNo(this, + i18n("The web inspector will only work correctly for pages that were loaded after enabling.\n" + "Do you want to reload all pages?"), + i18n("Web Inspector")); + if (result == KMessageBox::Yes) { m_view->reloadAllTabs(); } @@ -711,23 +711,23 @@ WebView *MainWindow::currentTab() const // FIXME: this actually doesn't work properly.. void MainWindow::slotLoadProgress(int progress) { - QAction *stop = actionCollection()->action( "stop" ); - QAction *reload = actionCollection()->action( "view_redisplay" ); - if (progress < 100 && progress > 0) + QAction *stop = actionCollection()->action("stop"); + QAction *reload = actionCollection()->action("view_redisplay"); + if (progress < 100 && progress > 0) { - disconnect( m_stopReload, SIGNAL( triggered( bool ) ), reload , SIGNAL( triggered(bool) ) ); - m_stopReload->setIcon( KIcon( "process-stop" ) ); - m_stopReload->setToolTip( i18n("Stop loading the current page") ); - m_stopReload->setText( i18n("Stop") ); - connect(m_stopReload, SIGNAL( triggered(bool ) ), stop, SIGNAL( triggered(bool) ) ); - } - else + disconnect(m_stopReload, SIGNAL(triggered(bool)), reload , SIGNAL(triggered(bool))); + m_stopReload->setIcon(KIcon("process-stop")); + m_stopReload->setToolTip(i18n("Stop loading the current page")); + m_stopReload->setText(i18n("Stop")); + connect(m_stopReload, SIGNAL(triggered(bool)), stop, SIGNAL(triggered(bool))); + } + else { - disconnect( m_stopReload, SIGNAL( triggered( bool ) ), stop , SIGNAL( triggered(bool ) ) ); - m_stopReload->setIcon( KIcon( "view-refresh" ) ); - m_stopReload->setToolTip( i18n("Reload the current page") ); - m_stopReload->setText( i18n("Reload") ); - connect(m_stopReload, SIGNAL( triggered( bool ) ), reload, SIGNAL( triggered(bool) ) ); + disconnect(m_stopReload, SIGNAL(triggered(bool)), stop , SIGNAL(triggered(bool))); + m_stopReload->setIcon(KIcon("view-refresh")); + m_stopReload->setToolTip(i18n("Reload the current page")); + m_stopReload->setText(i18n("Reload")); + connect(m_stopReload, SIGNAL(triggered(bool)), reload, SIGNAL(triggered(bool))); } } @@ -740,11 +740,11 @@ void MainWindow::slotAboutToShowBackMenu() return; QWebHistory *history = currentTab()->history(); int historyCount = history->count(); - for (int i = history->backItems(historyCount).count() - 1; i >= 0; --i) + for (int i = history->backItems(historyCount).count() - 1; i >= 0; --i) { QWebHistoryItem item = history->backItems(history->count()).at(i); KAction *action = new KAction(this); - action->setData(-1*(historyCount-i-1)); + action->setData(-1*(historyCount - i - 1)); QIcon icon = Application::instance()->icon(item.url()); action->setIcon(icon); action->setText(item.title()); @@ -761,7 +761,7 @@ void MainWindow::slotOpenActionUrl(QAction *action) { history->goToItem(history->backItems(-1*offset).first()); // back } - else + else { if (offset > 0) { @@ -774,16 +774,16 @@ void MainWindow::slotOpenActionUrl(QAction *action) void MainWindow::slotOpenPrevious() { QWebHistory *history = currentTab()->history(); - if ( history->canGoBack() ) - history->goToItem( history->backItem() ); + if (history->canGoBack()) + history->goToItem(history->backItem()); } void MainWindow::slotOpenNext() { QWebHistory *history = currentTab()->history(); - if ( history->canGoForward() ) - history->goToItem( history->forwardItem() ); + if (history->canGoForward()) + history->goToItem(history->forwardItem()); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 15eda7ec..220fceca 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -43,11 +43,11 @@ class WebView; /** - * This class serves as the main window for rekonq. + * This class serves as the main window for rekonq. * It handles the menus, toolbars, and status bars. * */ -class MainWindow : public KXmlGuiWindow +class MainWindow : public KXmlGuiWindow { Q_OBJECT diff --git a/src/modelmenu.cpp b/src/modelmenu.cpp index 3ed5b9ac..fae8acab 100644 --- a/src/modelmenu.cpp +++ b/src/modelmenu.cpp @@ -23,13 +23,13 @@ ModelMenu::ModelMenu(QWidget * parent) - : KMenu(parent) - , m_maxRows(7) - , m_firstSeparator(-1) - , m_maxWidth(-1) - , m_hoverRole(0) - , m_separatorRole(0) - , m_model(0) + : KMenu(parent) + , m_maxRows(7) + , m_firstSeparator(-1) + , m_maxWidth(-1) + , m_hoverRole(0) + , m_separatorRole(0) + , m_model(0) { connect(this, SIGNAL(aboutToShow()), this, SLOT(aboutToShow())); } @@ -121,10 +121,10 @@ int ModelMenu::separatorRole() const Q_DECLARE_METATYPE(QModelIndex) void ModelMenu::aboutToShow() { - if (QMenu *menu = qobject_cast(sender())) + if (QMenu *menu = qobject_cast(sender())) { QVariant v = menu->menuAction()->data(); - if (v.canConvert()) + if (v.canConvert()) { QModelIndex idx = qvariant_cast(v); createMenu(idx, -1, menu, menu); @@ -145,7 +145,7 @@ void ModelMenu::aboutToShow() void ModelMenu::createMenu(const QModelIndex &parent, int max, QMenu *parentMenu, QMenu *menu) { - if (!menu) + if (!menu) { QString title = parent.data().toString(); menu = new QMenu(title, this); @@ -163,16 +163,20 @@ void ModelMenu::createMenu(const QModelIndex &parent, int max, QMenu *parentMenu if (max != -1) end = qMin(max, end); - connect(menu, SIGNAL( triggered(QAction*) ), this, SLOT( triggered(QAction*) ) ); - connect(menu, SIGNAL( hovered(QAction*) ), this, SLOT( hovered(QAction*) ) ); + connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(triggered(QAction*))); + connect(menu, SIGNAL(hovered(QAction*)), this, SLOT(hovered(QAction*))); - for (int i = 0; i < end; ++i) { + for (int i = 0; i < end; ++i) + { QModelIndex idx = m_model->index(i, 0, parent); - if (m_model->hasChildren(idx)) { + if (m_model->hasChildren(idx)) + { createMenu(idx, -1, menu); - } else { + } + else + { if (m_separatorRole != 0 - && idx.data(m_separatorRole).toBool()) + && idx.data(m_separatorRole).toBool()) addSeparator(); else menu->addAction(makeAction(idx)); @@ -184,7 +188,7 @@ void ModelMenu::createMenu(const QModelIndex &parent, int max, QMenu *parentMenu KAction *ModelMenu::makeAction(const QModelIndex &index) { - QIcon icon = qvariant_cast( index.data(Qt::DecorationRole) ); + QIcon icon = qvariant_cast(index.data(Qt::DecorationRole)); KAction *action = (KAction *) makeAction(KIcon(icon), index.data().toString(), this); QVariant v; v.setValue(index); @@ -204,7 +208,7 @@ KAction *ModelMenu::makeAction(const KIcon &icon, const QString &text, QObject * void ModelMenu::triggered(QAction *action) { QVariant v = action->data(); - if (v.canConvert()) + if (v.canConvert()) { QModelIndex idx = qvariant_cast(v); emit activated(idx); @@ -214,7 +218,7 @@ void ModelMenu::triggered(QAction *action) void ModelMenu::hovered(QAction *action) { QVariant v = action->data(); - if (v.canConvert()) + if (v.canConvert()) { QModelIndex idx = qvariant_cast(v); QString hoveredString = idx.data(m_hoverRole).toString(); diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 1c426c61..c0b05e6a 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -49,10 +49,10 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) - : QNetworkAccessManager(parent) + : QNetworkAccessManager(parent) { connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), - SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); + SLOT(authenticationRequired(QNetworkReply*, QAuthenticator*))); connect(this, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), SLOT(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*))); @@ -66,11 +66,11 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) #if QT_VERSION >= 0x040500 QNetworkDiskCache *diskCache = new QNetworkDiskCache(this); - QString location = KStandardDirs::locateLocal("cache","",true); + QString location = KStandardDirs::locateLocal("cache", "", true); diskCache->setCacheDirectory(location); setCache(diskCache); -#endif +#endif } @@ -79,9 +79,9 @@ void NetworkAccessManager::loadSettings() { kWarning() << "loading NetworkAccessManager settings.."; QNetworkProxy proxy; - if ( ReKonfig::isProxyEnabled() ) + if (ReKonfig::isProxyEnabled()) { - if ( ReKonfig::proxyType() == 0 ) + if (ReKonfig::proxyType() == 0) { proxy.setType(QNetworkProxy::Socks5Proxy); } @@ -89,10 +89,10 @@ void NetworkAccessManager::loadSettings() { proxy.setType(QNetworkProxy::HttpProxy); } - proxy.setHostName( ReKonfig::proxyHostName() ); - proxy.setPort( ReKonfig::proxyPort() ); - proxy.setUser( ReKonfig::proxyUserName() ); - proxy.setPassword( ReKonfig::proxyPassword() ); + proxy.setHostName(ReKonfig::proxyHostName()); + proxy.setPort(ReKonfig::proxyPort()); + proxy.setUser(ReKonfig::proxyUserName()); + proxy.setPassword(ReKonfig::proxyPassword()); } setProxy(proxy); } @@ -112,12 +112,12 @@ void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthent passwordDialog.iconLabel->setText(QString()); passwordDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32)); - QString introMessage = i18n("Enter username and password for ") + - Qt::escape(reply->url().toString()) + i18n(" at ") + Qt::escape(reply->url().toString()) + ""; + QString introMessage = i18n("Enter username and password for ") + + Qt::escape(reply->url().toString()) + i18n(" at ") + Qt::escape(reply->url().toString()) + ""; passwordDialog.introLabel->setText(introMessage); passwordDialog.introLabel->setWordWrap(true); - if (dialog.exec() == QDialog::Accepted) + if (dialog.exec() == QDialog::Accepted) { auth->setUser(passwordDialog.userNameLineEdit->text()); auth->setPassword(passwordDialog.passwordLineEdit->text()); @@ -141,7 +141,7 @@ void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &prox proxyDialog.introLabel->setText(introMessage); proxyDialog.introLabel->setWordWrap(true); - if (dialog.exec() == QDialog::Accepted) + if (dialog.exec() == QDialog::Accepted) { auth->setUser(proxyDialog.userNameLineEdit->text()); auth->setPassword(proxyDialog.passwordLineEdit->text()); @@ -157,7 +157,7 @@ void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QListurl().toString() + "\n\n" + QString(errors) + "\n\n"); + int ret = KMessageBox::warningYesNo(mainWindow, i18n("SSL Errors:\n\n") + reply->url().toString() + "\n\n" + QString(errors) + "\n\n"); if (ret == KMessageBox::Yes) reply->ignoreSslErrors(); } diff --git a/src/searchbar.cpp b/src/searchbar.cpp index 80b231ac..0d318edb 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -36,23 +36,23 @@ #include -SearchBar::SearchBar(QWidget *parent) : - KLineEdit(parent) +SearchBar::SearchBar(QWidget *parent) : + KLineEdit(parent) { setMinimumWidth(180); kWarning() << "setting fixed minimum width.." ; - setFocusPolicy( Qt::WheelFocus ); - setMouseTracking( true ); + setFocusPolicy(Qt::WheelFocus); + setMouseTracking(true); setAcceptDrops(true); QSizePolicy policy = sizePolicy(); setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy()); - setClearButtonShown( true ); + setClearButtonShown(true); // better solution than using QPalette(s).. - setClickMessage( i18n("Search..") ); + setClickMessage(i18n("Search..")); // setting QNetworkAccessManager.. netMan = new QNetworkAccessManager(this); @@ -64,7 +64,7 @@ SearchBar::SearchBar(QWidget *parent) : connect(timer, SIGNAL(timeout()), SLOT(autoSuggest())); connect(this, SIGNAL(textEdited(QString)), timer, SLOT(start())); - connect(this, SIGNAL( returnPressed() ) , this , SLOT( searchNow() ) ); + connect(this, SIGNAL(returnPressed()) , this , SLOT(searchNow())); } @@ -92,8 +92,8 @@ void SearchBar::focusInEvent(QFocusEvent *event) KLineEdit::focusInEvent(event); QPalette p; - p.setColor( QPalette::Text , Qt::black ); - setPalette( p ); + p.setColor(QPalette::Text , Qt::black); + setPalette(p); clear(); } @@ -109,7 +109,7 @@ void SearchBar::autoSuggest() void SearchBar::handleNetworkData(QNetworkReply *networkReply) { QUrl url = networkReply->url(); - if (!networkReply->error()) + if (!networkReply->error()) { QStringList choices; diff --git a/src/searchbar.h b/src/searchbar.h index 5ec81885..39e66952 100644 --- a/src/searchbar.h +++ b/src/searchbar.h @@ -33,7 +33,7 @@ class QNetworkAccessManager; class QNetworkReply; /** - * This class defines an internet search bar. + * This class defines an internet search bar. */ class SearchBar : public KLineEdit { @@ -46,7 +46,7 @@ public: public slots: void autoSuggest(); void handleNetworkData(QNetworkReply *networkReply); - + /** * Use this slot to perform one search in one search engine * @@ -54,7 +54,7 @@ public slots: void searchNow(); protected: - void focusInEvent(QFocusEvent * ); + void focusInEvent(QFocusEvent *); signals: void search(const KUrl &url); diff --git a/src/settings.cpp b/src/settings.cpp index 860e7050..8f3d61a0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -63,7 +63,7 @@ private: Private(SettingsDialog *parent); -friend class SettingsDialog; + friend class SettingsDialog; }; @@ -73,47 +73,47 @@ Private::Private(SettingsDialog *parent) KPageWidgetItem *pageItem; widget = new QWidget; - generalUi.setupUi( widget ); + generalUi.setupUi(widget); widget->layout()->setMargin(0); - pageItem = parent->addPage( widget , i18n("General") ); - pageItem->setIcon( KIcon("rekonq") ); + pageItem = parent->addPage(widget , i18n("General")); + pageItem->setIcon(KIcon("rekonq")); widget = new QWidget; - fontsUi.setupUi( widget ); + fontsUi.setupUi(widget); widget->layout()->setMargin(0); - pageItem = parent->addPage( widget , i18n("Fonts") ); - pageItem->setIcon( KIcon("preferences-desktop-font") ); + pageItem = parent->addPage(widget , i18n("Fonts")); + pageItem->setIcon(KIcon("preferences-desktop-font")); widget = new QWidget; - privacyUi.setupUi( widget ); + privacyUi.setupUi(widget); widget->layout()->setMargin(0); - pageItem = parent->addPage( widget , i18n("Privacy") ); - pageItem->setIcon( KIcon("preferences-desktop-personal") ); + pageItem = parent->addPage(widget , i18n("Privacy")); + pageItem->setIcon(KIcon("preferences-desktop-personal")); widget = new QWidget; - proxyUi.setupUi( widget ); + proxyUi.setupUi(widget); widget->layout()->setMargin(0); - pageItem = parent->addPage( widget , i18n("Proxy") ); - pageItem->setIcon( KIcon("preferences-system-network") ); + pageItem = parent->addPage(widget , i18n("Proxy")); + pageItem->setIcon(KIcon("preferences-system-network")); } // ----------------------------------------------------------------------------------------------------- SettingsDialog::SettingsDialog(QWidget *parent) - : KConfigDialog(parent, "rekonfig", ReKonfig::self()) - , d(new Private(this)) + : KConfigDialog(parent, "rekonfig", ReKonfig::self()) + , d(new Private(this)) { setFaceType(KPageDialog::List); showButtonSeparator(true); - setWindowTitle( i18n("rekonfig..") ); + setWindowTitle(i18n("rekonfig..")); setModal(true); readConfig(); - connect( d->generalUi.setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT( setHomeToCurrentPage() ) ); - connect( d->privacyUi.exceptionsButton, SIGNAL(clicked()), this, SLOT( showExceptions() ) ); - connect( d->privacyUi.cookiesButton, SIGNAL(clicked()), this, SLOT( showCookies() ) ); + connect(d->generalUi.setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT(setHomeToCurrentPage())); + connect(d->privacyUi.exceptionsButton, SIGNAL(clicked()), this, SLOT(showExceptions())); + connect(d->privacyUi.cookiesButton, SIGNAL(clicked()), this, SLOT(showCookies())); } @@ -129,13 +129,13 @@ void SettingsDialog::readConfig() { // ======= General d->generalUi.downloadDirUrlRequester->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly); - d->generalUi.downloadDirUrlRequester->setUrl( ReKonfig::downloadDir() ); - connect(d->generalUi.downloadDirUrlRequester, SIGNAL(textChanged(QString)),this, SLOT(saveSettings())); + d->generalUi.downloadDirUrlRequester->setUrl(ReKonfig::downloadDir()); + connect(d->generalUi.downloadDirUrlRequester, SIGNAL(textChanged(QString)), this, SLOT(saveSettings())); // ======= Fonts // QFont stdFont = ReKonfig::standardFont(); // d->fontsUi.standardFont->setCurrentFont(stdFont); -// +// // QFont fxFont = ReKonfig::fixedFont(); d->fontsUi.kcfg_fixedFont->setOnlyFixed(true); // d->fontsUi.fixedFont->setCurrentFont(fxFont); @@ -151,7 +151,7 @@ void SettingsDialog::readConfig() void SettingsDialog::saveSettings() { // General - ReKonfig::setDownloadDir( d->generalUi.downloadDirUrlRequester->url().prettyUrl() ); + ReKonfig::setDownloadDir(d->generalUi.downloadDirUrlRequester->url().prettyUrl()); // Fonts // ReKonfig::setStandardFont( d->fontsUi.standardFont->currentFont() ); @@ -185,6 +185,6 @@ void SettingsDialog::setHomeToCurrentPage() WebView *webView = mw->currentTab(); if (webView) { - d->generalUi.kcfg_homePage->setText( webView->url().prettyUrl() ); + d->generalUi.kcfg_homePage->setText(webView->url().prettyUrl()); } } diff --git a/src/settings.h b/src/settings.h index 3bf099b4..3d781c20 100644 --- a/src/settings.h +++ b/src/settings.h @@ -40,7 +40,7 @@ public: private: Private* const d; - + private slots: void readConfig(); void saveSettings(); diff --git a/src/tabbar.cpp b/src/tabbar.cpp index d00a95ce..43940f7d 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -42,8 +42,8 @@ TabBar::TabBar(QWidget *parent) - : KTabBar(parent) - , m_parent(parent) + : KTabBar(parent) + , m_parent(parent) { setElideMode(Qt::ElideRight); setContextMenuPolicy(Qt::CustomContextMenu); @@ -53,7 +53,7 @@ TabBar::TabBar(QWidget *parent) QFont standardFont = KGlobalSettings::generalFont(); QString fontFamily = standardFont.family(); int dim = standardFont.pointSize(); - setFont( QFont(fontFamily, dim-1) ); + setFont(QFont(fontFamily, dim - 1)); } @@ -62,12 +62,12 @@ TabBar::~TabBar() } -QSize TabBar::tabSizeHint (int index) const +QSize TabBar::tabSizeHint(int index) const { Q_UNUSED(index); QSize s = m_parent->sizeHint(); int w; - if ( count() > 3 ) + if (count() > 3) { w = s.width() / 4; } @@ -77,7 +77,7 @@ QSize TabBar::tabSizeHint (int index) const } int h = KTabBar::tabSizeHint(index).height(); - QSize ts = QSize(w,h); + QSize ts = QSize(w, h); return ts; } @@ -98,20 +98,20 @@ void TabBar::contextMenuRequested(const QPoint &position) { // FIXME: use right actions KMenu menu; - menu.addAction(i18n("New &Tab"), this, SIGNAL( newTab() ), QKeySequence::AddTab); + menu.addAction(i18n("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab); int index = tabAt(position); if (-1 != index) { m_actualIndex = index; - KAction *action = (KAction * ) menu.addAction(i18n("Clone Tab"), this, SLOT(cloneTab())); + KAction *action = (KAction *) menu.addAction(i18n("Clone Tab"), this, SLOT(cloneTab())); menu.addSeparator(); - action = (KAction * ) menu.addAction(i18n("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close); - action = (KAction * ) menu.addAction(i18n("Close &Other Tabs"), this, SLOT(closeOtherTabs())); + action = (KAction *) menu.addAction(i18n("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close); + action = (KAction *) menu.addAction(i18n("Close &Other Tabs"), this, SLOT(closeOtherTabs())); menu.addSeparator(); - action = (KAction * ) menu.addAction(i18n("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh); - } - else + action = (KAction *) menu.addAction(i18n("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh); + } + else { menu.addSeparator(); } diff --git a/src/tabbar.h b/src/tabbar.h index a265d85c..ad7a376d 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -31,7 +31,7 @@ #include /** - * Tab bar with a few more features such as + * Tab bar with a few more features such as * a context menu and shortcuts * */ @@ -64,7 +64,7 @@ protected: * Added to fix tab dimension * */ - virtual QSize tabSizeHint (int index) const; + virtual QSize tabSizeHint(int index) const; private slots: void selectTabAction(); diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 37c18636..0c904e45 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -33,19 +33,19 @@ UrlBar::UrlBar(QWidget *parent) - : KHistoryComboBox( true, parent ) - , m_webView(0) - , m_lineEdit(new QLineEdit) + : KHistoryComboBox(true, parent) + , m_webView(0) + , m_lineEdit(new QLineEdit) { - setLineEdit( m_lineEdit ); + setLineEdit(m_lineEdit); QSizePolicy policy = sizePolicy(); setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy()); - m_defaultBaseColor = palette().color( QPalette::Base ); + m_defaultBaseColor = palette().color(QPalette::Base); // add every item to history - connect( this, SIGNAL( activated( const QString& ) ), this, SLOT( addToHistory( const QString& ) ) ); + connect(this, SIGNAL(activated(const QString&)), this, SLOT(addToHistory(const QString&))); webViewIconChanged(); } @@ -91,10 +91,10 @@ void UrlBar::webViewIconChanged() QIcon icon = Application::instance()->icon(url); QPixmap pixmap(icon.pixmap(16, 16)); QIcon urlIcon = QIcon(pixmap); - + // FIXME simple hack to show Icon in the urlbar, as calling changeUrl() doesn't affect it - insertUrl(0,urlIcon,url); - if(count()>1) + insertUrl(0, urlIcon, url); + if (count() > 1) { removeItem(1); } @@ -116,18 +116,18 @@ QLinearGradient UrlBar::generateGradient(const QColor &color) const // void UrlBar::paintEvent( QPaintEvent *event ) // { // QPalette p = palette(); -// if (m_webView && m_webView->url().scheme() == QLatin1String("https")) +// if (m_webView && m_webView->url().scheme() == QLatin1String("https")) // { // QColor lightYellow(248, 248, 210); // p.setBrush(QPalette::Base, generateGradient(lightYellow)); -// } -// else +// } +// else // { // p.setBrush(QPalette::Base, m_defaultBaseColor); // } // setPalette(p); // KHistoryComboBox::paintEvent(event); -// +// // QPainter painter( this ); // QRect backgroundRect = m_lineEdit->frameGeometry(); // contentsRect(); // FIXME perhaps better working with contentsRect // if ( m_webView && !hasFocus() ) // and modifying colours.. diff --git a/src/urlbar.h b/src/urlbar.h index 72c0bd52..cd6477c4 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -37,7 +37,7 @@ class QColor; class UrlBar : public KHistoryComboBox { -Q_OBJECT + Q_OBJECT public: UrlBar(QWidget *parent = 0); diff --git a/src/webview.cpp b/src/webview.cpp index 947b08cd..239a5f5a 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -46,12 +46,12 @@ WebPage::WebPage(QObject *parent) - : QWebPage(parent) - , m_keyboardModifiers(Qt::NoModifier) - , m_pressedButtons(Qt::NoButton) - , m_openInNewTab(false) + : QWebPage(parent) + , m_keyboardModifiers(Qt::NoModifier) + , m_pressedButtons(Qt::NoButton) + , m_openInNewTab(false) { - setNetworkAccessManager( Application::networkAccessManager() ); + setNetworkAccessManager(Application::networkAccessManager()); connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(handleUnsupportedContent(QNetworkReply *))); } @@ -65,7 +65,7 @@ WebPage::~WebPage() MainWindow *WebPage::mainWindow() { QObject *w = this->parent(); - while (w) + while (w) { if (MainWindow *mw = qobject_cast(w)) return mw; @@ -81,8 +81,8 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r // ctrl open in new tab and select // ctrl-alt open in new window - if ( type == QWebPage::NavigationTypeLinkClicked && (m_keyboardModifiers & Qt::ControlModifier - || m_pressedButtons == Qt::MidButton) ) + if (type == QWebPage::NavigationTypeLinkClicked && (m_keyboardModifiers & Qt::ControlModifier + || m_pressedButtons == Qt::MidButton)) { WebView *webView = Application::instance()->newTab(); webView->setFocus(); @@ -91,7 +91,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r m_pressedButtons = Qt::NoButton; return false; } - if ( frame == mainFrame() ) + if (frame == mainFrame()) { m_loadingUrl = request.url(); emit loadingUrl(m_loadingUrl); @@ -108,7 +108,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) { // added to manage web modal dialogs - if(type == QWebPage::WebModalDialog) + if (type == QWebPage::WebModalDialog) { WebView *w = new WebView; return w->page(); @@ -118,8 +118,8 @@ QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) { m_openInNewTab = true; } - - if (m_openInNewTab) + + if (m_openInNewTab) { m_openInNewTab = false; return mainWindow()->mainView()->newTab()->page(); @@ -145,45 +145,45 @@ QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QS void WebPage::handleUnsupportedContent(QNetworkReply *reply) { - if (reply->error() == QNetworkReply::NoError) + if (reply->error() == QNetworkReply::NoError) { KUrl srcUrl = reply->url(); QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); KUrl destUrl = KUrl(path); - Application::instance()->downloadUrl( srcUrl, destUrl ); + Application::instance()->downloadUrl(srcUrl, destUrl); return; } QString myfilestr = KStandardDirs::locate("data", "rekonq/htmls/notfound.html"); - QFile file( myfilestr ); + QFile file(myfilestr); bool isOpened = file.open(QIODevice::ReadOnly); Q_ASSERT(isOpened); QString title = i18n("Error loading page: ") + reply->url().toString(); - QString imagePath = KIconLoader::global()->iconPath( "rekonq", KIconLoader::NoGroup, false); + QString imagePath = KIconLoader::global()->iconPath("rekonq", KIconLoader::NoGroup, false); QString html = QString(QLatin1String(file.readAll())) - .arg(title) - .arg("file://" + imagePath) - .arg(reply->errorString()) - .arg(reply->url().toString()); + .arg(title) + .arg("file://" + imagePath) + .arg(reply->errorString()) + .arg(reply->url().toString()); QList frames; frames.append(mainFrame()); - while (!frames.isEmpty()) + while (!frames.isEmpty()) { QWebFrame *frame = frames.takeFirst(); - if (frame->url() == reply->url()) + if (frame->url() == reply->url()) { frame->setHtml(html, reply->url()); return; } QList children = frame->childFrames(); foreach(QWebFrame *frame, children) - frames.append(frame); + frames.append(frame); } - if (m_loadingUrl == reply->url()) + if (m_loadingUrl == reply->url()) { mainFrame()->setHtml(html, reply->url()); } @@ -194,9 +194,9 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) WebView::WebView(QWidget* parent) - : QWebView(parent) - , m_progress(0) - , m_page(new WebPage(this)) + : QWebView(parent) + , m_progress(0) + , m_page(new WebPage(this)) { setPage(m_page); connect(page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&))); @@ -214,18 +214,18 @@ WebView::WebView(QWidget* parent) void WebView::contextMenuEvent(QContextMenuEvent *event) { QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos()); - if (!r.linkUrl().isEmpty()) + if (!r.linkUrl().isEmpty()) { KMenu menu(this); - KAction *a = new KAction( KIcon("tab-new"), i18n("Open in New Tab"), this); - connect( a, SIGNAL( triggered() ), this , SLOT( openLinkInNewTab() ) ); + KAction *a = new KAction(KIcon("tab-new"), i18n("Open in New Tab"), this); + connect(a, SIGNAL(triggered()), this , SLOT(openLinkInNewTab())); menu.addAction(a); menu.addSeparator(); - menu.addAction( pageAction(QWebPage::DownloadLinkToDisk) ); + menu.addAction(pageAction(QWebPage::DownloadLinkToDisk)); // Add link to bookmarks... menu.addSeparator(); - menu.addAction( pageAction(QWebPage::CopyLinkToClipboard) ); - if ( page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled) ) + menu.addAction(pageAction(QWebPage::CopyLinkToClipboard)); + if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled)) { menu.addAction(pageAction(QWebPage::InspectElement)); } @@ -238,7 +238,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) void WebView::wheelEvent(QWheelEvent *event) { - if (QApplication::keyboardModifiers() & Qt::ControlModifier) + if (QApplication::keyboardModifiers() & Qt::ControlModifier) { int numDegrees = event->delta() / 8; int numSteps = numDegrees / 15; @@ -265,10 +265,10 @@ void WebView::setProgress(int progress) void WebView::loadFinished() { - if (m_progress != 100) + if (m_progress != 100) { kWarning() << "Recieved finished signal while progress is still:" << progress() - << "Url:" << url(); + << "Url:" << url(); } m_progress = 0; } @@ -279,12 +279,12 @@ void WebView::loadUrl(const KUrl &url) { m_initialUrl = url; - if( m_initialUrl.isRelative() ) + if (m_initialUrl.isRelative()) { kWarning() << "1: " << m_initialUrl.url(); - QString fn = m_initialUrl.url( KUrl::RemoveTrailingSlash ); + QString fn = m_initialUrl.url(KUrl::RemoveTrailingSlash); kWarning() << "2: " << fn; - m_initialUrl.setUrl( "//" + fn ); + m_initialUrl.setUrl("//" + fn); m_initialUrl.setScheme("http"); kWarning() << "3: " << m_initialUrl.url(); } @@ -302,7 +302,7 @@ QString WebView::lastStatusBarText() const KUrl WebView::url() const { KUrl url = QWebView::url(); - if ( !url.isEmpty() ) + if (!url.isEmpty()) { return url; } @@ -321,10 +321,10 @@ void WebView::mousePressEvent(QMouseEvent *event) void WebView::mouseReleaseEvent(QMouseEvent *event) { QWebView::mouseReleaseEvent(event); - if (!event->isAccepted() && (m_page->m_pressedButtons & Qt::MidButton)) + if (!event->isAccepted() && (m_page->m_pressedButtons & Qt::MidButton)) { - KUrl url( QApplication::clipboard()->text(QClipboard::Selection) ); - if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) + KUrl url(QApplication::clipboard()->text(QClipboard::Selection)); + if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) { setUrl(url); } @@ -343,24 +343,24 @@ void WebView::downloadRequested(const QNetworkRequest &request) KUrl srcUrl = request.url(); QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); KUrl destUrl = KUrl(path); - Application::instance()->downloadUrl( srcUrl, destUrl ); + Application::instance()->downloadUrl(srcUrl, destUrl); } void WebView::keyPressEvent(QKeyEvent *event) { - if ( (event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_Tab) ) + if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_Tab)) { emit ctrlTabPressed(); return; } - if( (event->modifiers() == Qt::ControlModifier + Qt::ShiftModifier) && (event->key() == Qt::Key_Backtab) ) + if ((event->modifiers() == Qt::ControlModifier + Qt::ShiftModifier) && (event->key() == Qt::Key_Backtab)) { emit shiftCtrlTabPressed(); return; } - QWebView::keyPressEvent( event ); + QWebView::keyPressEvent(event); } diff --git a/src/webview.h b/src/webview.h index a7832cef..de2822b9 100644 --- a/src/webview.h +++ b/src/webview.h @@ -39,7 +39,7 @@ class QNetworkReply; class QSslError; -class WebPage : public QWebPage +class WebPage : public QWebPage { Q_OBJECT @@ -77,19 +77,25 @@ private: #include -class WebView : public QWebView +class WebView : public QWebView { Q_OBJECT public: WebView(QWidget *parent = 0); - WebPage *webPage() const { return m_page; } + WebPage *webPage() const + { + return m_page; + } void loadUrl(const KUrl &url); KUrl url() const; QString lastStatusBarText() const; - inline int progress() const { return m_progress; } + inline int progress() const + { + return m_progress; + } signals: // switching tabs @@ -102,9 +108,9 @@ protected: void contextMenuEvent(QContextMenuEvent *event); void wheelEvent(QWheelEvent *event); - /** + /** * Filters (SHIFT + ) CTRL + TAB events and emit (shift)ctrlTabPressed() - * to make switch tab + * to make switch tab */ void keyPressEvent(QKeyEvent *event); -- cgit v1.2.1