diff options
author | Sergio Ahumada <sergio.ahumada@digia.com> | 2012-09-20 08:43:14 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-09-20 08:56:36 +0200 |
commit | 52638dd841fc6a2dbfa8e916db8d4e710be0380d (patch) | |
tree | f432495406f7e96e6066d734451ca22f00ac27ed /examples/browser | |
parent | 660e24df0a75365e7458a05a100930740ba58116 (diff) | |
download | qtwebkit-examples-52638dd841fc6a2dbfa8e916db8d4e710be0380d.tar.gz |
examples: Fix some compilation errors
Change-Id: Ibe844411aa4c11fab9cbd73ddeb794ea2af3f54b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'examples/browser')
-rw-r--r-- | examples/browser/bookmarks.cpp | 4 | ||||
-rw-r--r-- | examples/browser/browserapplication.cpp | 2 | ||||
-rw-r--r-- | examples/browser/cookiejar.cpp | 16 | ||||
-rw-r--r-- | examples/browser/downloadmanager.cpp | 2 | ||||
-rw-r--r-- | examples/browser/history.cpp | 34 | ||||
-rw-r--r-- | examples/browser/networkaccessmanager.cpp | 6 | ||||
-rw-r--r-- | examples/browser/settings.cpp | 2 | ||||
-rw-r--r-- | examples/browser/toolbarsearch.cpp | 11 |
8 files changed, 47 insertions, 30 deletions
diff --git a/examples/browser/bookmarks.cpp b/examples/browser/bookmarks.cpp index f32be69..57dac2e 100644 --- a/examples/browser/bookmarks.cpp +++ b/examples/browser/bookmarks.cpp @@ -96,7 +96,7 @@ void BookmarksManager::load() return; m_loaded = true; - QString dir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + QString dir = QStandardPaths::writableLocation(QStandardPaths::DataLocation); QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel"); if (!QFile::exists(bookmarkFile)) bookmarkFile = QLatin1String(":defaultbookmarks.xbel"); @@ -160,7 +160,7 @@ void BookmarksManager::save() const return; XbelWriter writer; - QString dir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + QString dir = QStandardPaths::writableLocation(QStandardPaths::DataLocation); QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel"); if (!writer.write(bookmarkFile, m_bookmarkRootNode)) qWarning() << "BookmarkManager: error saving to" << bookmarkFile; diff --git a/examples/browser/browserapplication.cpp b/examples/browser/browserapplication.cpp index e1f75b9..d2812e9 100644 --- a/examples/browser/browserapplication.cpp +++ b/examples/browser/browserapplication.cpp @@ -201,7 +201,7 @@ void BrowserApplication::quitBrowser() */ void BrowserApplication::postLaunch() { - QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + QString directory = QStandardPaths::writableLocation(QStandardPaths::DataLocation); if (directory.isEmpty()) directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); QWebSettings::setIconDatabasePath(directory); diff --git a/examples/browser/cookiejar.cpp b/examples/browser/cookiejar.cpp index b25937d..d02c308 100644 --- a/examples/browser/cookiejar.cpp +++ b/examples/browser/cookiejar.cpp @@ -132,7 +132,7 @@ void CookieJar::load() return; // load cookies and exceptions qRegisterMetaTypeStreamOperators<QList<QNetworkCookie> >("QList<QNetworkCookie>"); - QSettings cookieSettings(QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/cookies.ini"), QSettings::IniFormat); + QSettings cookieSettings(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1String("/cookies.ini"), QSettings::IniFormat); setAllCookies(qvariant_cast<QList<QNetworkCookie> >(cookieSettings.value(QLatin1String("cookies")))); cookieSettings.beginGroup(QLatin1String("Exceptions")); m_exceptions_block = cookieSettings.value(QLatin1String("block")).toStringList(); @@ -174,7 +174,7 @@ void CookieJar::save() if (!m_loaded) return; purgeOldCookies(); - QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + QString directory = QStandardPaths::writableLocation(QStandardPaths::DataLocation); if (directory.isEmpty()) directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); if (!QFile::exists(directory)) { @@ -479,7 +479,8 @@ bool CookieModel::removeRows(int row, int count, const QModelIndex &parent) void CookieModel::cookiesChanged() { - reset(); + beginResetModel(); + endResetModel(); } CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) : QDialog(parent) @@ -711,7 +712,8 @@ void CookiesExceptionsDialog::block() return; m_exceptionsModel->m_blockedCookies.append(domainLineEdit->text()); m_cookieJar->setBlockedCookies(m_exceptionsModel->m_blockedCookies); - m_exceptionsModel->reset(); + m_exceptionsModel->beginResetModel(); + m_exceptionsModel->endResetModel(); } void CookiesExceptionsDialog::allow() @@ -720,7 +722,8 @@ void CookiesExceptionsDialog::allow() return; m_exceptionsModel->m_allowedCookies.append(domainLineEdit->text()); m_cookieJar->setAllowedCookies(m_exceptionsModel->m_allowedCookies); - m_exceptionsModel->reset(); + m_exceptionsModel->beginResetModel(); + m_exceptionsModel->endResetModel(); } void CookiesExceptionsDialog::allowForSession() @@ -729,6 +732,7 @@ void CookiesExceptionsDialog::allowForSession() return; m_exceptionsModel->m_sessionCookies.append(domainLineEdit->text()); m_cookieJar->setAllowForSessionCookies(m_exceptionsModel->m_sessionCookies); - m_exceptionsModel->reset(); + m_exceptionsModel->beginResetModel(); + m_exceptionsModel->endResetModel(); } diff --git a/examples/browser/downloadmanager.cpp b/examples/browser/downloadmanager.cpp index 128b3c7..0eaf14e 100644 --- a/examples/browser/downloadmanager.cpp +++ b/examples/browser/downloadmanager.cpp @@ -119,7 +119,7 @@ void DownloadItem::getFileName() { QSettings settings; settings.beginGroup(QLatin1String("downloadmanager")); - QString defaultLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); + QString defaultLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); QString downloadDirectory = settings.value(QLatin1String("downloadDirectory"), defaultLocation).toString(); if (!downloadDirectory.isEmpty()) downloadDirectory += QLatin1Char('/'); diff --git a/examples/browser/history.cpp b/examples/browser/history.cpp index b99e2de..d9efd24 100644 --- a/examples/browser/history.cpp +++ b/examples/browser/history.cpp @@ -239,7 +239,7 @@ void HistoryManager::load() { loadSettings(); - QFile historyFile(QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QFile historyFile(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1String("/history")); if (!historyFile.exists()) return; @@ -318,7 +318,7 @@ void HistoryManager::save() if (first == m_history.count() - 1) saveAll = true; - QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + QString directory = QStandardPaths::writableLocation(QStandardPaths::DataLocation); if (directory.isEmpty()) directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); if (!QFile::exists(directory)) { @@ -380,7 +380,8 @@ HistoryModel::HistoryModel(HistoryManager *history, QObject *parent) void HistoryModel::historyReset() { - reset(); + beginResetModel(); + endResetModel(); } void HistoryModel::entryAdded() @@ -786,7 +787,8 @@ QVariant HistoryFilterModel::headerData(int section, Qt::Orientation orientation void HistoryFilterModel::sourceReset() { m_loaded = false; - reset(); + beginResetModel(); + endResetModel(); } int HistoryFilterModel::rowCount(const QModelIndex &parent) const @@ -917,8 +919,10 @@ bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &paren connect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(sourceRowsRemoved(QModelIndex,int,int))); m_loaded = false; - if (oldCount - count != rowCount()) - reset(); + if (oldCount - count != rowCount()) { + beginResetModel(); + endResetModel(); + } return true; } @@ -1004,12 +1008,14 @@ void HistoryCompletionModel::setSourceModel(QAbstractItemModel *newSourceModel) this, SLOT(sourceReset())); } - reset(); + beginResetModel(); + endResetModel(); } void HistoryCompletionModel::sourceReset() { - reset(); + beginResetModel(); + endResetModel(); } HistoryTreeModel::HistoryTreeModel(QAbstractItemModel *sourceModel, QObject *parent) @@ -1194,13 +1200,15 @@ void HistoryTreeModel::setSourceModel(QAbstractItemModel *newSourceModel) this, SLOT(sourceRowsRemoved(QModelIndex,int,int))); } - reset(); + beginResetModel(); + endResetModel(); } void HistoryTreeModel::sourceReset() { + beginResetModel(); m_sourceRowCache.clear(); - reset(); + endResetModel(); } void HistoryTreeModel::sourceRowsInserted(const QModelIndex &parent, int start, int end) @@ -1208,8 +1216,9 @@ 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) { + beginResetModel(); m_sourceRowCache.clear(); - reset(); + endResetModel(); return; } @@ -1253,8 +1262,9 @@ void HistoryTreeModel::sourceRowsRemoved(const QModelIndex &parent, int start, i it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), i); // playing it safe if (it == m_sourceRowCache.end()) { + beginResetModel(); m_sourceRowCache.clear(); - reset(); + endResetModel(); return; } diff --git a/examples/browser/networkaccessmanager.cpp b/examples/browser/networkaccessmanager.cpp index 85f0144..413ffa3 100644 --- a/examples/browser/networkaccessmanager.cpp +++ b/examples/browser/networkaccessmanager.cpp @@ -79,7 +79,7 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) loadSettings(); QNetworkDiskCache *diskCache = new QNetworkDiskCache(this); - QString location = QDesktopServices::storageLocation(QDesktopServices::CacheLocation); + QString location = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); diskCache->setCacheDirectory(location); setCache(diskCache); } @@ -154,7 +154,7 @@ void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthent passwordDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32)); QString introMessage = tr("<qt>Enter username and password for \"%1\" at %2</qt>"); - introMessage = introMessage.arg(Qt::escape(reply->url().toString())).arg(Qt::escape(reply->url().toString())); + introMessage = introMessage.arg(reply->url().toString().toHtmlEscaped()).arg(reply->url().toString().toHtmlEscaped()); passwordDialog.introLabel->setText(introMessage); passwordDialog.introLabel->setWordWrap(true); @@ -178,7 +178,7 @@ void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &prox proxyDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32)); QString introMessage = tr("<qt>Connect to proxy \"%1\" using:</qt>"); - introMessage = introMessage.arg(Qt::escape(proxy.hostName())); + introMessage = introMessage.arg(proxy.hostName().toHtmlEscaped()); proxyDialog.introLabel->setText(introMessage); proxyDialog.introLabel->setWordWrap(true); diff --git a/examples/browser/settings.cpp b/examples/browser/settings.cpp index 17163c5..7adb2bf 100644 --- a/examples/browser/settings.cpp +++ b/examples/browser/settings.cpp @@ -79,7 +79,7 @@ void SettingsDialog::loadDefaults() fixedFont = QFont(fixedFontFamily, fixedFontSize); fixedLabel->setText(QString(QLatin1String("%1 %2")).arg(fixedFont.family()).arg(fixedFont.pointSize())); - downloadsLocation->setText(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)); + downloadsLocation->setText(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)); enableJavascript->setChecked(defaultSettings->testAttribute(QWebSettings::JavascriptEnabled)); enablePlugins->setChecked(defaultSettings->testAttribute(QWebSettings::PluginsEnabled)); diff --git a/examples/browser/toolbarsearch.cpp b/examples/browser/toolbarsearch.cpp index 24eba18..d2d9dce 100644 --- a/examples/browser/toolbarsearch.cpp +++ b/examples/browser/toolbarsearch.cpp @@ -44,6 +44,7 @@ #include <QtCore/QSettings> #include <QtCore/QUrl> +#include <QtCore/QUrlQuery> #include <QtWidgets/QCompleter> #include <QtWidgets/QMenu> @@ -115,10 +116,12 @@ void ToolbarSearch::searchNow() } QUrl url(QLatin1String("http://www.google.com/search")); - url.addQueryItem(QLatin1String("q"), searchText); - url.addQueryItem(QLatin1String("ie"), QLatin1String("UTF-8")); - url.addQueryItem(QLatin1String("oe"), QLatin1String("UTF-8")); - url.addQueryItem(QLatin1String("client"), QLatin1String("qtdemobrowser")); + QUrlQuery urlQuery; + urlQuery.addQueryItem(QLatin1String("q"), searchText); + urlQuery.addQueryItem(QLatin1String("ie"), QLatin1String("UTF-8")); + urlQuery.addQueryItem(QLatin1String("oe"), QLatin1String("UTF-8")); + urlQuery.addQueryItem(QLatin1String("client"), QLatin1String("qtdemobrowser")); + url.setQuery(urlQuery); emit search(url); } |