1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-19 10:16:34 +01:00

Fixed bug when page with null icon could get "error page" siteicon

- also fixed deleting history entries
This commit is contained in:
nowrep 2012-04-04 14:45:45 +02:00
parent 6b79ca55bf
commit c9b28f31e6
10 changed files with 59 additions and 68 deletions

7
.gitignore vendored
View File

@ -1,6 +1,5 @@
build
DEBIAN
tools_
*.deb
*.pro.user
*.autosave
@ -12,12 +11,8 @@ tools_
headers*.tar.gz
license_template
Makefile*
TestPlugin-build
search_*
src-*
bin/qupzilla
*.so
libqupzilla.*
lib*.so*
bin/core
qupzilla.sh
git_revision

View File

@ -306,9 +306,9 @@ void HistoryManager::slotRefreshTable()
item->setText(1, url.toEncoded());
item->setToolTip(0, title);
item->setToolTip(1, url.toEncoded());
item->setData(0, Qt::UserRole + 10, id);
item->setIcon(0, _iconForUrl(url));
ui->historyTree->addTopLevelItem(item);
++counter;

View File

@ -30,9 +30,6 @@ HistoryModel::HistoryModel(QupZilla* mainClass)
, p_QupZilla(mainClass)
{
loadSettings();
connect(this, SIGNAL(signalAddHistoryEntry(QUrl, QString)), this, SLOT(slotAddHistoryEntry(QUrl, QString)));
connect(this, SIGNAL(signalDeleteHistoryEntry(QList<int>)), this, SLOT(slotDeleteHistoryEntry(QList<int>)));
}
void HistoryModel::loadSettings()
@ -46,7 +43,7 @@ void HistoryModel::loadSettings()
// AddHistoryEntry
void HistoryModel::addHistoryEntry(WebView* view)
{
if (!m_isSaving) {
if (!m_isSaving || view->loadingError()) {
return;
}
@ -57,17 +54,11 @@ void HistoryModel::addHistoryEntry(WebView* view)
}
void HistoryModel::addHistoryEntry(const QUrl &url, QString title)
{
emit signalAddHistoryEntry(url, title);
}
void HistoryModel::slotAddHistoryEntry(const QUrl &url, QString title)
{
if (!m_isSaving) {
return;
}
if (url.scheme() == "file:" || url.scheme() == "qupzilla" || url.scheme() == "about" ||
title.contains(tr("Failed loading page")) || url.isEmpty()) {
if (url.scheme() == "qupzilla" || url.scheme() == "about" || url.isEmpty()) {
return;
}
if (title == "") {
@ -125,7 +116,35 @@ void HistoryModel::deleteHistoryEntry(int index)
void HistoryModel::deleteHistoryEntry(const QList<int> &list)
{
emit signalDeleteHistoryEntry(list);
QSqlDatabase db = QSqlDatabase::database();
db.transaction();
foreach(int index, list) {
QSqlQuery query;
query.prepare("SELECT id, count, date, url, title FROM history WHERE id=?");
query.addBindValue(index);
query.exec();
query.next();
HistoryEntry entry;
entry.id = query.value(0).toInt();
entry.count = query.value(1).toInt();
entry.date = QDateTime::fromMSecsSinceEpoch(query.value(2).toLongLong());
entry.url = query.value(3).toUrl();
entry.title = query.value(4).toString();
query.prepare("DELETE FROM history WHERE id=?");
query.addBindValue(index);
query.exec();
query.prepare("DELETE FROM icons WHERE url=?");
query.addBindValue(entry.url.toEncoded(QUrl::RemoveFragment));
query.exec();
emit historyEntryDeleted(entry);
}
db.commit();
}
void HistoryModel::deleteHistoryEntry(const QString &url, const QString &title)
@ -141,38 +160,6 @@ void HistoryModel::deleteHistoryEntry(const QString &url, const QString &title)
}
}
void HistoryModel::slotDeleteHistoryEntry(const QList<int> &list)
{
QSqlDatabase db = QSqlDatabase::database();
db.transaction();
foreach(int index, list) {
QSqlQuery query;
query.prepare("SELECT id, count, date, url, title FROM history WHERE id=?");
query.bindValue(0, index);
query.exec();
HistoryEntry entry;
entry.id = query.value(0).toInt();
entry.count = query.value(1).toInt();
entry.date = QDateTime::fromMSecsSinceEpoch(query.value(2).toLongLong());
entry.url = query.value(3).toUrl();
entry.title = query.value(4).toString();
query.prepare("DELETE FROM history WHERE id=?");
query.bindValue(0, index);
query.exec();
query.prepare("DELETE FROM icons WHERE url=?");
query.bindValue(0, entry.url.toEncoded(QUrl::RemoveFragment));
query.exec();
emit historyEntryDeleted(entry);
}
db.commit();
}
bool HistoryModel::urlIsStored(const QString &url)
{
QSqlQuery query;

View File

@ -64,10 +64,6 @@ public:
void loadSettings();
private slots:
void slotAddHistoryEntry(const QUrl &url, QString title);
void slotDeleteHistoryEntry(const QList<int> &list);
signals:
void historyEntryAdded(HistoryEntry entry);
void historyEntryDeleted(HistoryEntry entry);

View File

@ -82,8 +82,6 @@ void TabbedWebView::slotIconChanged()
return;
}
mApp->iconProvider()->saveIcon(this);
showIcon();
}

View File

@ -67,7 +67,6 @@ WebPage::WebPage(QupZilla* mainClass)
, m_runningLoop(0)
, m_blockAlerts(false)
, m_secureStatus(false)
, m_isClosing(false)
{
m_networkProxy = new NetworkManagerProxy(this);
m_networkProxy->setPrimaryNetworkAccessManager(mApp->networkManager());
@ -135,6 +134,11 @@ void WebPage::scheduleAdjustPage()
}
}
bool WebPage::loadingError() const
{
return !mainFrame()->findFirstElement("span[id=\"qupzilla-error-page\"]").isNull();
}
bool WebPage::isRunningLoop()
{
return m_runningLoop;
@ -553,7 +557,7 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte
errString.replace("%RULE%", tr("Blocked by rule <i>%1</i>").arg(rule));
exReturn->baseUrl = exOption->url;
exReturn->content = errString.toUtf8();
exReturn->content = QString(errString + "<span id=\"qupzilla-error-page\"></span>").toUtf8();
if (PopupWebPage* popupPage = qobject_cast<PopupWebPage*>(exOption->frame->page())) {
WebView* view = qobject_cast<WebView*>(popupPage->view());
@ -599,7 +603,7 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte
errString.replace("%LI-3%", tr("If your computer or network is protected by a firewall or proxy, make sure that QupZilla is permitted to access the Web."));
errString.replace("%TRY-AGAIN%", tr("Try Again"));
exReturn->content = errString.toUtf8();
exReturn->content = QString(errString + "<span id=\"qupzilla-error-page\"></span>").toUtf8();
return true;
}
@ -631,7 +635,7 @@ bool WebPage::javaScriptPrompt(QWebFrame* originatingFrame, const QString &msg,
m_runningLoop = &eLoop;
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), &eLoop, SLOT(quit()));
if (eLoop.exec() == 1 || m_isClosing) {
if (eLoop.exec() == 1) {
return result;
}
m_runningLoop = 0;
@ -673,7 +677,7 @@ bool WebPage::javaScriptConfirm(QWebFrame* originatingFrame, const QString &msg)
m_runningLoop = &eLoop;
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), &eLoop, SLOT(quit()));
if (eLoop.exec() == 1 || m_isClosing) {
if (eLoop.exec() == 1) {
return false;
}
m_runningLoop = 0;
@ -728,7 +732,7 @@ void WebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString &msg)
m_runningLoop = &eLoop;
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), &eLoop, SLOT(quit()));
if (eLoop.exec() == 1 || m_isClosing) {
if (eLoop.exec() == 1) {
return;
}
m_runningLoop = 0;

View File

@ -66,6 +66,8 @@ public:
void scheduleAdjustPage();
bool isRunningLoop();
bool loadingError() const;
static void setUserAgent(const QString &agent);
QString userAgentForUrl(const QUrl &url) const;
@ -126,8 +128,6 @@ private:
bool m_blockAlerts;
bool m_secureStatus;
bool m_adjustingScheduled;
bool m_isClosing;
};
#endif // WEBPAGE_H

View File

@ -224,8 +224,9 @@ void WebTab::restoreTab(const WebTab::SavedTab &tab)
m_savedTab = tab;
int index = tabIndex();
m_view->tabWidget()->setTabIcon(tabIndex(), tab.icon);
m_view->tabWidget()->setTabIcon(index, tab.icon);
m_view->tabWidget()->setTabText(index, tab.title);
m_view->tabWidget()->setTabToolTip(index, tab.title);
m_locationBar.data()->showUrl(tab.url);
}
else {

View File

@ -155,6 +155,11 @@ void WebView::load(const QNetworkRequest &request, QNetworkAccessManager::Operat
}
bool WebView::loadingError() const
{
return page()->loadingError();
}
bool WebView::isLoading() const
{
return m_isLoading;
@ -343,8 +348,12 @@ void WebView::emitChangedUrl()
void WebView::slotIconChanged()
{
m_siteIcon = icon();
m_siteIconUrl = url();
if (!loadingError()) {
m_siteIcon = icon();
m_siteIconUrl = url();
mApp->iconProvider()->saveIcon(this);
}
}
void WebView::openUrlInNewWindow()

View File

@ -41,6 +41,7 @@ public:
void load(const QNetworkRequest &request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray &body = QByteArray());
bool loadingError() const;
bool isLoading() const;
int loadProgress() const;