mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
History now emits historyEdited signal
This commit is contained in:
parent
0279018f17
commit
a959d148d3
Binary file not shown.
@ -126,7 +126,8 @@ SOURCES += main.cpp\
|
||||
navigation/locationbarsettings.cpp \
|
||||
other/browsinglibrary.cpp \
|
||||
3rdparty/stylehelper.cpp \
|
||||
3rdparty/fancytabwidget.cpp
|
||||
3rdparty/fancytabwidget.cpp \
|
||||
history/webhistoryinterface.cpp
|
||||
|
||||
HEADERS += \
|
||||
3rdparty/qtwin.h \
|
||||
@ -213,7 +214,8 @@ HEADERS += \
|
||||
navigation/locationbarsettings.h \
|
||||
other/browsinglibrary.h \
|
||||
3rdparty/stylehelper.h \
|
||||
3rdparty/fancytabwidget.h
|
||||
3rdparty/fancytabwidget.h \
|
||||
history/webhistoryinterface.h
|
||||
|
||||
FORMS += \
|
||||
preferences/autofillmanager.ui \
|
||||
|
@ -35,6 +35,8 @@
|
||||
#include "desktopnotificationsfactory.h"
|
||||
#include "iconprovider.h"
|
||||
#include "qtwin.h"
|
||||
#include "mainapplication.h"
|
||||
#include "webhistoryinterface.h"
|
||||
|
||||
MainApplication::MainApplication(const QList<CommandLineOptions::ActionPair> &cmdActions, int &argc, char **argv)
|
||||
: QtSingleApplication("QupZillaWebBrowser", argc, argv)
|
||||
@ -139,6 +141,7 @@ MainApplication::MainApplication(const QList<CommandLineOptions::ActionPair> &cm
|
||||
|
||||
translateApp();
|
||||
connectDatabase();
|
||||
QWebHistoryInterface::setDefaultInterface(new WebHistoryInterface(this));
|
||||
|
||||
QupZilla* qupzilla = new QupZilla(true, startUrl);
|
||||
m_mainWindows.append(qupzilla);
|
||||
|
@ -43,6 +43,7 @@ HistoryManager::HistoryManager(QupZilla* mainClass, QWidget* parent) :
|
||||
|
||||
connect(m_historyModel, SIGNAL(historyEntryAdded(HistoryModel::HistoryEntry)), this, SLOT(historyEntryAdded(HistoryModel::HistoryEntry)));
|
||||
connect(m_historyModel, SIGNAL(historyEntryDeleted(HistoryModel::HistoryEntry)), this, SLOT(historyEntryDeleted(HistoryModel::HistoryEntry)));
|
||||
connect(m_historyModel, SIGNAL(historyEntryEdited(HistoryModel::HistoryEntry,HistoryModel::HistoryEntry)), this, SLOT(historyEntryEdited(HistoryModel::HistoryEntry,HistoryModel::HistoryEntry)));
|
||||
connect(m_historyModel, SIGNAL(historyClear()), ui->historyTree, SLOT(clear()));
|
||||
|
||||
connect(ui->optimizeDb, SIGNAL(clicked(QPoint)), this, SLOT(optimizeDb()));
|
||||
@ -174,6 +175,12 @@ void HistoryManager::historyEntryDeleted(const HistoryModel::HistoryEntry &entry
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryManager::historyEntryEdited(const HistoryModel::HistoryEntry &before, const HistoryModel::HistoryEntry &after)
|
||||
{
|
||||
historyEntryDeleted(before);
|
||||
historyEntryAdded(after);
|
||||
}
|
||||
|
||||
void HistoryManager::clearHistory()
|
||||
{
|
||||
QMessageBox::StandardButton button = QMessageBox::warning(this, tr("Confirmation"),
|
||||
|
@ -53,6 +53,7 @@ private slots:
|
||||
|
||||
void historyEntryAdded(const HistoryModel::HistoryEntry &entry);
|
||||
void historyEntryDeleted(const HistoryModel::HistoryEntry &entry);
|
||||
void historyEntryEdited(const HistoryModel::HistoryEntry &before, const HistoryModel::HistoryEntry &after);
|
||||
|
||||
private:
|
||||
QupZilla* getQupZilla();
|
||||
|
@ -65,11 +65,22 @@ int HistoryModel::addHistoryEntry(const QString &url, QString &title)
|
||||
entry.title = title;
|
||||
emit historyEntryAdded(entry);
|
||||
} else {
|
||||
int id = query.value(0).toInt();
|
||||
query.prepare("UPDATE history SET count = count + 1, date=?, title=? WHERE url=?");
|
||||
query.bindValue(0, QDateTime::currentMSecsSinceEpoch());
|
||||
query.bindValue(1, title);
|
||||
query.bindValue(2, url);
|
||||
query.exec();
|
||||
|
||||
HistoryEntry before;
|
||||
before.id = id;
|
||||
|
||||
HistoryEntry after;
|
||||
after.id = id;
|
||||
after.date = QDateTime::currentDateTime();
|
||||
after.url = url;
|
||||
after.title = title;
|
||||
emit historyEntryEdited(before, after);
|
||||
}
|
||||
return query.lastInsertId().toInt();
|
||||
}
|
||||
@ -101,7 +112,11 @@ bool HistoryModel::deleteHistoryEntry(int index)
|
||||
|
||||
query.prepare("DELETE FROM history WHERE id=?");
|
||||
query.bindValue(0, index);
|
||||
if (query.exec()) {
|
||||
bool removeHistorySuccess = query.exec();
|
||||
query.prepare("DELETE FROM icons WHERE url=?");
|
||||
query.bindValue(0, entry.url.toEncoded(QUrl::RemoveFragment));
|
||||
query.exec();
|
||||
if (removeHistorySuccess) {
|
||||
emit historyEntryDeleted(entry);
|
||||
return true;
|
||||
}
|
||||
@ -122,6 +137,15 @@ bool HistoryModel::deleteHistoryEntry(const QString &url, const QString &title)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HistoryModel::urlIsStored(const QString &url)
|
||||
{
|
||||
QSqlQuery query;
|
||||
query.prepare("SELECT id FROM history WHERE url=?");
|
||||
query.bindValue(0, url);
|
||||
query.exec();
|
||||
return query.next();
|
||||
}
|
||||
|
||||
QList<HistoryModel::HistoryEntry> HistoryModel::mostVisited(int count)
|
||||
{
|
||||
QList<HistoryEntry> list;
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
int addHistoryEntry(const QString &url, QString &title);
|
||||
bool deleteHistoryEntry(int index);
|
||||
bool deleteHistoryEntry(const QString &url, const QString &title);
|
||||
bool urlIsStored(const QString &url);
|
||||
|
||||
QList<HistoryModel::HistoryEntry> mostVisited(int count);
|
||||
|
||||
@ -61,6 +62,8 @@ public:
|
||||
signals:
|
||||
void historyEntryAdded(HistoryModel::HistoryEntry entry);
|
||||
void historyEntryDeleted(HistoryModel::HistoryEntry entry);
|
||||
void historyEntryEdited(HistoryModel::HistoryEntry before, HistoryModel::HistoryEntry after);
|
||||
//WARNING: Incomplete HistoryEntry structs are passed to historyEntryEdited!
|
||||
void historyClear();
|
||||
|
||||
private:
|
||||
|
18
src/history/webhistoryinterface.cpp
Normal file
18
src/history/webhistoryinterface.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "webhistoryinterface.h"
|
||||
#include "mainapplication.h"
|
||||
#include "historymodel.h"
|
||||
|
||||
WebHistoryInterface::WebHistoryInterface(QObject *parent) :
|
||||
QWebHistoryInterface(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void WebHistoryInterface::addHistoryEntry(const QString &url)
|
||||
{
|
||||
m_clickedLinks.append(url);
|
||||
}
|
||||
|
||||
bool WebHistoryInterface::historyContains(const QString &url) const
|
||||
{
|
||||
return m_clickedLinks.contains(url);
|
||||
}
|
24
src/history/webhistoryinterface.h
Normal file
24
src/history/webhistoryinterface.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef WEBHISTORYINTERFACE_H
|
||||
#define WEBHISTORYINTERFACE_H
|
||||
|
||||
#include <QWebHistoryInterface>
|
||||
|
||||
class WebHistoryInterface : public QWebHistoryInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WebHistoryInterface(QObject *parent = 0);
|
||||
|
||||
void addHistoryEntry(const QString &url);
|
||||
bool historyContains(const QString &url) const;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
QList<QString> m_clickedLinks;
|
||||
|
||||
};
|
||||
|
||||
#endif // WEBHISTORYINTERFACE_H
|
@ -126,7 +126,7 @@ void BookmarksSideBar::addBookmark(const BookmarksModel::Bookmark &bookmark)
|
||||
item->setText(0, bookmark.title);
|
||||
item->setText(1, bookmark.url.toEncoded());
|
||||
item->setWhatsThis(0, QString::number(bookmark.id));
|
||||
item->setIcon(0, _iconForUrl(bookmark.url));
|
||||
item->setIcon(0, bookmark.icon);
|
||||
item->setToolTip(0, bookmark.url.toEncoded());
|
||||
|
||||
if (bookmark.folder != "unsorted")
|
||||
@ -211,12 +211,13 @@ void BookmarksSideBar::refreshTable()
|
||||
ui->bookmarksTree->addTopLevelItem(newItem);
|
||||
}
|
||||
|
||||
query.exec("SELECT title, url, id, folder FROM bookmarks");
|
||||
query.exec("SELECT title, url, id, folder, icon FROM bookmarks");
|
||||
while(query.next()) {
|
||||
QString title = query.value(0).toString();
|
||||
QUrl url = query.value(1).toUrl();
|
||||
int id = query.value(2).toInt();
|
||||
QString folder = query.value(3).toString();
|
||||
QIcon icon = IconProvider::iconFromBase64(query.value(4).toByteArray());
|
||||
QTreeWidgetItem* item;
|
||||
if (folder == "bookmarksMenu")
|
||||
folder = tr("Bookmarks In Menu");
|
||||
@ -243,7 +244,7 @@ void BookmarksSideBar::refreshTable()
|
||||
// item->setToolTip(1, url.toEncoded());
|
||||
|
||||
item->setWhatsThis(0, QString::number(id));
|
||||
item->setIcon(0, _iconForUrl(url));
|
||||
item->setIcon(0, icon);
|
||||
ui->bookmarksTree->addTopLevelItem(item);
|
||||
}
|
||||
ui->bookmarksTree->expandAll();
|
||||
|
@ -36,6 +36,7 @@ HistorySideBar::HistorySideBar(QupZilla* mainClass, QWidget* parent) :
|
||||
|
||||
connect(m_historyModel, SIGNAL(historyEntryAdded(HistoryModel::HistoryEntry)), this, SLOT(historyEntryAdded(HistoryModel::HistoryEntry)));
|
||||
connect(m_historyModel, SIGNAL(historyEntryDeleted(HistoryModel::HistoryEntry)), this, SLOT(historyEntryDeleted(HistoryModel::HistoryEntry)));
|
||||
connect(m_historyModel, SIGNAL(historyEntryEdited(HistoryModel::HistoryEntry,HistoryModel::HistoryEntry)), this, SLOT(historyEntryEdited(HistoryModel::HistoryEntry,HistoryModel::HistoryEntry)));
|
||||
connect(m_historyModel, SIGNAL(historyClear()), ui->historyTree, SLOT(clear()));
|
||||
|
||||
QTimer::singleShot(0, this, SLOT(refreshTable()));
|
||||
@ -130,6 +131,12 @@ void HistorySideBar::historyEntryDeleted(const HistoryModel::HistoryEntry &entry
|
||||
}
|
||||
}
|
||||
|
||||
void HistorySideBar::historyEntryEdited(const HistoryModel::HistoryEntry &before, const HistoryModel::HistoryEntry &after)
|
||||
{
|
||||
historyEntryDeleted(before);
|
||||
historyEntryAdded(after);
|
||||
}
|
||||
|
||||
void HistorySideBar::search()
|
||||
{
|
||||
QString searchText = ui->search->text();
|
||||
|
@ -50,6 +50,7 @@ private slots:
|
||||
|
||||
void historyEntryAdded(const HistoryModel::HistoryEntry &entry);
|
||||
void historyEntryDeleted(const HistoryModel::HistoryEntry &entry);
|
||||
void historyEntryEdited(const HistoryModel::HistoryEntry &before, const HistoryModel::HistoryEntry &after);
|
||||
|
||||
private:
|
||||
Ui::HistorySideBar* ui;
|
||||
|
@ -127,9 +127,7 @@ void WebView::urlChanged(const QUrl &url)
|
||||
|
||||
void WebView::linkClicked(const QUrl &url)
|
||||
{
|
||||
qDebug() << __FUNCTION__ << "called";
|
||||
if (isCurrent())
|
||||
emit showUrl(url);
|
||||
load(url);
|
||||
}
|
||||
|
||||
void WebView::setProgress(int prog)
|
||||
|
@ -612,7 +612,7 @@ p, li { white-space: pre-wrap; }
|
||||
<message>
|
||||
<location filename="../src/other/browsinglibrary.cpp" line="141"/>
|
||||
<source>Database successfuly optimized.<br/><br/><b>Database Size Before: </b>%1<br/><b>Databse Size After: </b>%2</source>
|
||||
<translation>Databáze byla úspěšně optimalizována.<br/><br/><b>Velikost databáze před: </b>%1<br/><b>Velikost databáze poté: </b>%2</translation>
|
||||
<translation type="unfinished">Databáze byla úspěšně optimalizována.<br/><br/><b>Velikost databáze před: </b>%1<br/><b>Velikost databáze po: </b>%2</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
Loading…
Reference in New Issue
Block a user