1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Added option to import bookmarks form html. Closes #29

- also updated translations scripts
- updated translations
This commit is contained in:
nowrep 2011-12-08 21:52:03 +01:00
parent 51c178c5f1
commit 6ec593f436
32 changed files with 2845 additions and 2407 deletions

Binary file not shown.

View File

@ -1,24 +1,12 @@
#!/bin/bash
## circular inclusions workaround - we comment that buggy line
sed -i 's/include(3rdparty/##temp/g' ../src/QupZilla.pro
sed -i 's/include(3rdparty/##temp/g' ../src/src.pro
lupdate ../src/QupZilla.pro -no-obsolete -ts ../translations/cs_CZ.ts
lupdate ../src/QupZilla.pro -no-obsolete -ts ../translations/sk_SK.ts
lupdate ../src/QupZilla.pro -no-obsolete -ts ../translations/nl_NL.ts
lupdate ../src/QupZilla.pro -no-obsolete -ts ../translations/de_DE.ts
lupdate ../src/QupZilla.pro -no-obsolete -ts ../translations/es.ts
lupdate ../src/QupZilla.pro -no-obsolete -ts ../translations/it_IT.ts
lupdate ../src/QupZilla.pro -no-obsolete -ts ../translations/zh_CN.ts
lupdate ../src/src.pro -no-obsolete
## uncomment it now
sed -i 's/##temp/include(3rdparty/g' ../src/QupZilla.pro
sed -i 's/##temp/include(3rdparty/g' ../src/src.pro
read -p "Press [ENTER] to close terminal"
exit

View File

@ -1,24 +1,12 @@
#!/bin/bash
## circular inclusions workaround - we comment that buggy line
sed -i 's/include(3rdparty/##temp/g' ../src/QupZilla.pro
sed -i 's/include(3rdparty/##temp/g' ../src/src.pro
lupdate ../src/QupZilla.pro -ts ../translations/cs_CZ.ts
lupdate ../src/QupZilla.pro -ts ../translations/sk_SK.ts
lupdate ../src/QupZilla.pro -ts ../translations/nl_NL.ts
lupdate ../src/QupZilla.pro -ts ../translations/de_DE.ts
lupdate ../src/QupZilla.pro -ts ../translations/es.ts
lupdate ../src/QupZilla.pro -ts ../translations/it_IT.ts
lupdate ../src/QupZilla.pro -ts ../translations/zh_CN.ts
lupdate ../src/src.pro
## uncomment it now
sed -i 's/##temp/include(3rdparty/g' ../src/QupZilla.pro
sed -i 's/##temp/include(3rdparty/g' ../src/src.pro
read -p "Press [ENTER] to close terminal"
exit

View File

@ -571,7 +571,7 @@ void QupZilla::aboutToShowBookmarksMenu()
m_menuBookmarks->addAction(icon, title, this, SLOT(loadActionUrl()))->setData(url);
}
QMenu* menuBookmarks= new QMenu(tr("Bookmarks In ToolBar"), m_menuBookmarks);
QMenu* menuBookmarks = new QMenu(tr("Bookmarks In ToolBar"), m_menuBookmarks);
menuBookmarks->setIcon(QIcon(style()->standardIcon(QStyle::SP_DirOpenIcon)));
query.exec("SELECT title, url, icon FROM bookmarks WHERE folder='bookmarksToolbar'");

View File

@ -20,6 +20,7 @@
#include "webview.h"
#include "mainapplication.h"
#include "autofillnotification.h"
#include "databasewriter.h"
AutoFillModel::AutoFillModel(QupZilla* mainClass, QObject* parent) :
QObject(parent)
@ -73,7 +74,9 @@ void AutoFillModel::blockStoringfor(const QUrl &url)
{
QString server = url.host();
QSqlQuery query;
query.exec("INSERT INTO autofill_exceptions (server) VALUES ('" + server + "')");
query.prepare("INSERT INTO autofill_exceptions (server) VALUES (?)");
query.addBindValue(server);
mApp->dbWriter()->executeQuery(query);
}
QString AutoFillModel::getUsername(const QUrl &url)
@ -95,27 +98,27 @@ QString AutoFillModel::getPassword(const QUrl &url)
}
///HTTP Authorization
bool AutoFillModel::addEntry(const QUrl &url, const QString &name, const QString &pass)
void AutoFillModel::addEntry(const QUrl &url, const QString &name, const QString &pass)
{
QSqlQuery query;
query.exec("SELECT username FROM autofill WHERE server='" + url.host() + "'");
if (query.next()) {
return false;
return;
}
query.prepare("INSERT INTO autofill (server, username, password) VALUES (?,?,?)");
query.bindValue(0, url.host());
query.bindValue(1, name);
query.bindValue(2, pass);
return query.exec();
mApp->dbWriter()->executeQuery(query);
}
///WEB Form
bool AutoFillModel::addEntry(const QUrl &url, const QByteArray &data, const QString &user, const QString &pass)
void AutoFillModel::addEntry(const QUrl &url, const QByteArray &data, const QString &user, const QString &pass)
{
QSqlQuery query;
query.exec("SELECT data FROM autofill WHERE server='" + url.host() + "'");
if (query.next()) {
return false;
return;
}
query.prepare("INSERT INTO autofill (server, data, username, password) VALUES (?,?,?,?)");
@ -123,7 +126,7 @@ bool AutoFillModel::addEntry(const QUrl &url, const QByteArray &data, const QStr
query.bindValue(1, data);
query.bindValue(2, user);
query.bindValue(3, pass);
return query.exec();
mApp->dbWriter()->executeQuery(query);
}
void AutoFillModel::completePage(WebView* view)

View File

@ -41,8 +41,8 @@ public:
QString getUsername(const QUrl &url);
QString getPassword(const QUrl &url);
bool addEntry(const QUrl &url, const QString &name, const QString &pass);
bool addEntry(const QUrl &url, const QByteArray &data, const QString &user, const QString &pass);
void addEntry(const QUrl &url, const QString &name, const QString &pass);
void addEntry(const QUrl &url, const QByteArray &data, const QString &user, const QString &pass);
void post(const QNetworkRequest &request, const QByteArray &outgoingData);

View File

@ -19,6 +19,7 @@
#include "mainapplication.h"
#include "webview.h"
#include "iconprovider.h"
#include "databasewriter.h"
// SQLite DB -> table bookmarks + folders
// Unique in bookmarks table is id
@ -131,10 +132,7 @@ bool BookmarksModel::saveBookmark(const QUrl &url, const QString &title, const Q
query.bindValue(1, title);
query.bindValue(2, folder);
query.bindValue(3, IconProvider::iconToBase64(icon));
if (!query.exec()) {
return false;
}
mApp->dbWriter()->executeQuery(query);
Bookmark bookmark;
bookmark.id = query.lastInsertId().toInt();

View File

@ -20,6 +20,7 @@
#include "firefoximporter.h"
#include "chromeimporter.h"
#include "operaimporter.h"
#include "htmlimporter.h"
#include "mainapplication.h"
#include "iconfetcher.h"
#include "networkmanager.h"
@ -38,6 +39,10 @@ BookmarksImportDialog::BookmarksImportDialog(QWidget* parent)
connect(ui->chooseFile, SIGNAL(clicked()), this, SLOT(setFile()));
connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(close()));
connect(ui->stopButton, SIGNAL(clicked()), this, SLOT(stopDownloading()));
HtmlImporter html(this);
html.setFile("/home/david/bookmarks.html");
html.exportBookmarks();
}
void BookmarksImportDialog::nextPage()
@ -211,6 +216,19 @@ bool BookmarksImportDialog::exportedOK()
}
return true;
}
else if (m_browser == Html) {
HtmlImporter html(this);
html.setFile(ui->fileLine->text());
if (html.openFile()) {
m_exportedBookmarks = html.exportBookmarks();
}
if (html.error()) {
QMessageBox::critical(this, tr("Error!"), html.errorString());
return false;
}
return true;
}
return false;
}
@ -301,6 +319,16 @@ void BookmarksImportDialog::setupBrowser(Browser browser)
#endif
break;
case Html:
m_browserPixmap = QPixmap(":icons/browsers/html.png");
m_browserName = "Html Import";
m_browserBookmarkFile = "*.htm, *.html";
m_browserFileText = tr("You can import bookmarks from any browser that supports HTML exporting. "
"This file has usually these suffixes");
m_browserFileText2 = tr("Please choose this file to begin importing bookmarks.");
m_standardDir = ".html, .htm";
break;
case IE:
m_browserPixmap = QPixmap(":icons/browsers/ie.png");
m_browserName = "Internet Explorer";

View File

@ -51,7 +51,7 @@ private slots:
void loadFinished();
private:
enum Browser { Firefox = 0, Chrome = 1, Opera = 2, IE = 3};
enum Browser { Firefox = 0, Chrome = 1, Opera = 2, Html = 3, IE = 4};
void setupBrowser(Browser browser);
bool exportedOK();

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>505</width>
<height>329</height>
<height>327</height>
</rect>
</property>
<property name="windowTitle">
@ -63,21 +63,17 @@
<normaloff>:/icons/browsers/opera.png</normaloff>:/icons/browsers/opera.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>From File</string>
</property>
<property name="icon">
<iconset resource="../data/icons.qrc">
<normaloff>:/icons/browsers/html.png</normaloff>:/icons/browsers/html.png</iconset>
</property>
</item>
</widget>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label_2">
<property name="text">

View File

@ -0,0 +1,65 @@
#include "htmlimporter.h"
HtmlImporter::HtmlImporter(QObject* parent)
: QObject(parent)
, m_error(false)
, m_errorString(tr("No Error"))
{
}
void HtmlImporter::setFile(const QString &path)
{
m_path = path;
}
bool HtmlImporter::openFile()
{
m_file.setFileName(m_path);
if (!m_file.open(QFile::ReadOnly)) {
m_error = true;
m_errorString = tr("Unable to open file.");
return false;
}
return true;
}
QList<BookmarksModel::Bookmark> HtmlImporter::exportBookmarks()
{
QList<BookmarksModel::Bookmark> list;
QString bookmarks = m_file.readAll();
m_file.close();
QRegExp rx("<a (.*)</a>", Qt::CaseInsensitive);
rx.setMinimal(true);
int pos = 0;
while ((pos = rx.indexIn(bookmarks, pos)) != -1) {
QString string = rx.cap(0);
pos += rx.matchedLength();
QRegExp rx2(">(.*)</a>", Qt::CaseInsensitive);
rx2.setMinimal(true);
rx2.indexIn(string);
QString name = rx2.cap(1);
rx2.setPattern("href=\"(.*)\"");
rx2.indexIn(string);
QString url = rx2.cap(1);
if (name.isEmpty() || url.isEmpty() || url.startsWith("place:") || url.startsWith("about:")) {
continue;
}
BookmarksModel::Bookmark b;
b.folder = "Html Import";
b.title = name;
b.url = url;
list.append(b);
}
return list;
}

View File

@ -0,0 +1,36 @@
#ifndef HTMLIMPORTER_H
#define HTMLIMPORTER_H
#include <QObject>
#include <QFile>
#include <QRegExp>
#include "bookmarksmodel.h"
class HtmlImporter : public QObject
{
Q_OBJECT
public:
explicit HtmlImporter(QObject* parent = 0);
void setFile(const QString &path);
bool openFile();
QList<BookmarksModel::Bookmark> exportBookmarks();
bool error() { return m_error; }
QString errorString() { return m_errorString; }
signals:
public slots:
private:
QString m_path;
QFile m_file;
bool m_error;
QString m_errorString;
};
#endif // HTMLIMPORTER_H

View File

@ -47,7 +47,6 @@ private:
bool m_error;
QString m_errorString;
};
#endif // OPERAIMPORTER_H

View File

@ -67,5 +67,6 @@
<file>icons/preferences/dialog-question.png</file>
<file>icons/preferences/mail-inbox.png</file>
<file>icons/preferences/preferences-system-firewall.png</file>
<file>icons/browsers/html.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -59,7 +59,7 @@ int HistoryModel::addHistoryEntry(const QUrl &url, QString &title)
query.bindValue(0, QDateTime::currentMSecsSinceEpoch());
query.bindValue(1, url);
query.bindValue(2, title);
query.exec();
mApp->dbWriter()->executeQuery(query);
int id = query.lastInsertId().toInt();
HistoryEntry entry;

View File

@ -21,6 +21,7 @@
#include "networkmanager.h"
#include "opensearchreader.h"
#include "opensearchengine.h"
#include "databasewriter.h"
#define ENSURE_LOADED if (!m_settingsLoaded) loadSettings();

View File

@ -17,7 +17,7 @@
* ============================================================ */
#include "databasewriter.h"
DatabaseWriter::DatabaseWriter(QObject *parent)
DatabaseWriter::DatabaseWriter(QObject* parent)
: QObject(parent)
{
}

View File

@ -22,13 +22,12 @@
#include <QSqlQuery>
#include <QList>
#include <QtConcurrentRun>
#include <QFuture>
class DatabaseWriter : public QObject
{
Q_OBJECT
public:
explicit DatabaseWriter(QObject *parent = 0);
explicit DatabaseWriter(QObject* parent = 0);
void executeQuery(const QSqlQuery &query);

View File

@ -91,7 +91,8 @@ SourceViewer::SourceViewer(QWebPage* page, const QString &selectedHtml) :
//Highlight selectedHtml
if (!selectedHtml.isEmpty()) {
m_sourceEdit->find(selectedHtml, QTextDocument::FindWholeWords);
} else {
}
else {
QTextCursor cursor = m_sourceEdit->textCursor();
cursor.setPosition(0);
m_sourceEdit->setTextCursor(cursor);

View File

@ -25,6 +25,7 @@
#include "browsinglibrary.h"
#include "globalfunctions.h"
#include "followredirectreply.h"
#include "databasewriter.h"
RSSManager::RSSManager(QupZilla* mainClass, QWidget* parent)
: QWidget(parent)
@ -363,7 +364,7 @@ bool RSSManager::addRssFeed(const QString &address, const QString &title, const
query.bindValue(0, address);
query.bindValue(1, title);
query.bindValue(2, iconData);
query.exec();
mApp->dbWriter()->executeQuery(query);
return true;
}

View File

@ -174,7 +174,8 @@ SOURCES += main.cpp\
webview/webhistorywrapper.cpp \
tools/pagethumbnailer.cpp \
plugins/speeddial.cpp \
other/databasewriter.cpp
other/databasewriter.cpp \
bookmarksimport/htmlimporter.cpp
HEADERS += \
3rdparty/qtwin.h \
@ -291,7 +292,8 @@ HEADERS += \
webview/webhistorywrapper.h \
tools/pagethumbnailer.h \
plugins/speeddial.h \
other/databasewriter.h
other/databasewriter.h \
bookmarksimport/htmlimporter.h
FORMS += \
preferences/autofillmanager.ui \
@ -390,3 +392,5 @@ message(Using following defines)
message($$DEFINES)

View File

@ -86,7 +86,7 @@ void ToolButton::mousePressEvent(QMouseEvent* e)
void ToolButton::mouseReleaseEvent(QMouseEvent* e)
{
if (e->button() == Qt::MiddleButton && rect().contains(e->pos()) ) {
if (e->button() == Qt::MiddleButton && rect().contains(e->pos())) {
emit middleMouseClicked();
return;
}

View File

@ -575,7 +575,7 @@ void WebView::contextMenuEvent(QContextMenuEvent* event)
QWebElement element = r.element();
if (!element.isNull() && (element.tagName().toLower() == "input" || element.tagName().toLower() == "textarea" ||
element.tagName().toLower() == "video" || element.tagName().toLower() == "audio") ) {
element.tagName().toLower() == "video" || element.tagName().toLower() == "audio")) {
if (m_menu->isEmpty()) {
page()->createStandardContextMenu()->popup(QCursor::pos());
return;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff