1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

SearchEngine: Prepare for POST method support

This commit is contained in:
nowrep 2013-11-08 22:17:27 +01:00
parent f465157897
commit 8a5a4017d6
5 changed files with 27 additions and 13 deletions

View File

@ -89,8 +89,8 @@ void ProfileUpdater::updateProfile(const QString &current, const QString &profil
return; return;
} }
// 1.3.5, 1.4.x = no changes if (prof >= Updater::Version("1.4.0") && prof <= Updater::Version("1.5.0")) {
if (prof >= Updater::Version("1.3.5") && prof < Updater::Version("1.5.0")) { update140();
return; return;
} }
@ -173,4 +173,16 @@ void ProfileUpdater::update130()
QSqlQuery query; QSqlQuery query;
query.exec("ALTER TABLE bookmarks ADD COLUMN keyword TEXT"); query.exec("ALTER TABLE bookmarks ADD COLUMN keyword TEXT");
update140();
}
void ProfileUpdater::update140()
{
std::cout << "QupZilla: Upgrading profile version from 1.4.0..." << std::endl;
mApp->connectDatabase();
QSqlQuery query;
query.exec("ALTER TABLE search_engines ADD COLUMN method TEXT");
query.exec("UPDATE search_engines SET method='GET'");
} }

View File

@ -36,6 +36,7 @@ private:
void update118(); void update118();
void update120(); void update120();
void update130(); void update130();
void update140();
QString m_profilePath; QString m_profilePath;
}; };

Binary file not shown.

View File

@ -67,14 +67,15 @@ void SearchEnginesManager::loadSettings()
m_settingsLoaded = true; m_settingsLoaded = true;
QSqlQuery query; QSqlQuery query;
query.exec("SELECT name, icon, url, shortcut, suggestionsUrl FROM search_engines"); query.exec("SELECT name, icon, url, shortcut, method, suggestionsUrl FROM search_engines");
while (query.next()) { while (query.next()) {
Engine en; Engine en;
en.name = query.value(0).toString(); en.name = query.value(0).toString();
en.icon = qIconProvider->iconFromBase64(query.value(1).toByteArray()); en.icon = qIconProvider->iconFromBase64(query.value(1).toByteArray());
en.url = query.value(2).toString(); en.url = query.value(2).toString();
en.shortcut = query.value(3).toString(); en.shortcut = query.value(3).toString();
en.suggestionsUrl = query.value(4).toString(); en.method = query.value(4).toString();
en.suggestionsUrl = query.value(5).toString();
m_allEngines.append(en); m_allEngines.append(en);
@ -446,13 +447,14 @@ void SearchEnginesManager::saveSettings()
query.exec("DELETE FROM search_engines"); query.exec("DELETE FROM search_engines");
foreach (const Engine &en, m_allEngines) { foreach (const Engine &en, m_allEngines) {
query.prepare("INSERT INTO search_engines (name, icon, url, shortcut, suggestionsUrl, suggestionsParameters) VALUES (?, ?, ?, ?, ?, ?)"); query.prepare("INSERT INTO search_engines (name, icon, url, shortcut, method, suggestionsUrl, suggestionsParameters) VALUES (?, ?, ?, ?, ?, ?)");
query.bindValue(0, en.name); query.addBindValue(en.name);
query.bindValue(1, qIconProvider->iconToBase64(en.icon)); query.addBindValue(qIconProvider->iconToBase64(en.icon));
query.bindValue(2, en.url); query.addBindValue(en.url);
query.bindValue(3, en.shortcut); query.addBindValue(en.shortcut);
query.bindValue(4, en.suggestionsUrl); query.addBindValue(en.method);
query.bindValue(5, en.suggestionsParameters); query.addBindValue(en.suggestionsUrl);
query.addBindValue(en.suggestionsParameters);
query.exec(); query.exec();
} }

View File

@ -34,7 +34,6 @@ class QT_QUPZILLA_EXPORT SearchEnginesManager : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit SearchEnginesManager(); explicit SearchEnginesManager();
struct Engine { struct Engine {
@ -42,11 +41,11 @@ public:
QIcon icon; QIcon icon;
QString url; QString url;
QString shortcut; QString shortcut;
QString method;
QString suggestionsUrl; QString suggestionsUrl;
QByteArray suggestionsParameters; QByteArray suggestionsParameters;
bool operator==(const Engine &other) const { bool operator==(const Engine &other) const {
return (this->name == other.name && return (this->name == other.name &&
this->url == other.url && this->url == other.url &&