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

Improved performance of bookmarks import and bookmarks deleting.

- moved general defines into qz_namespace.h file
- fixed showing default theme to be "default" on mac in
  theme manager instead of "mac" theme
This commit is contained in:
nowrep 2012-04-05 10:27:35 +02:00
parent ec973d960a
commit b1d0cd9228
13 changed files with 106 additions and 104 deletions

View File

@ -45,13 +45,13 @@ Then you can start compiling by running this commands:
After a successful compilation the executable binary can be found in the bin/ directory. After a successful compilation the executable binary can be found in the bin/ directory.
On Linux/Unix: To install QupZilla, you will have to run this command: (it may be necessary to run it as root) On Linux/Unix: To install QupZilla, run this command: (it may be necessary to run it as root)
$ make install $ make install
On Mac OS X: To deploy QupZilla in bundle, run this command: On Mac OS X: To deploy QupZilla in bundle, run this command:
$ cd scripts && ./macdeploy.sh full-path-to-macdeployqt $ ./scripts/macdeploy.sh full-path-to-macdeployqt
You need to specify path to `macdeployqt` only if it is not in PATH. You need to specify path to `macdeployqt` only if it is not in PATH.
@ -80,6 +80,4 @@ FAQ and Changelog
If you are experiencing some sort of problem, please read the FAQ before you open an issue. If you are experiencing some sort of problem, please read the FAQ before you open an issue.
FAQ: https://github.com/nowrep/QupZilla/wiki/FAQ [FAQ](https://github.com/nowrep/QupZilla/wiki/FAQ) | [Changelog](https://github.com/nowrep/QupZilla/wiki/Changelog) | [Bug Reports](https://github.com/nowrep/QupZilla/wiki/Bug-Reports)
Changelog: https://github.com/nowrep/QupZilla/wiki/Changelog

View File

@ -60,24 +60,6 @@
#include <QTimer> #include <QTimer>
#include <QTranslator> #include <QTranslator>
#ifdef Q_WS_WIN
#define DEFAULT_CHECK_UPDATES true
#else
#define DEFAULT_CHECK_UPDATES false
#endif
#ifdef Q_WS_WIN
#define DEFAULT_THEME_NAME "windows"
#elif defined(Q_WS_X11)
#define DEFAULT_THEME_NAME "linux"
#elif defined(Q_WS_MAC)
#define DEFAULT_THEME_NAME "mac"
#elif defined(Q_OS_OS2)
#define DEFAULT_THEME_NAME "windows"
#else
#define DEFAULT_THEME_NAME "default"
#endif
#if defined(PORTABLE_BUILD) && !defined(NO_SYSTEM_DATAPATH) #if defined(PORTABLE_BUILD) && !defined(NO_SYSTEM_DATAPATH)
#define NO_SYSTEM_DATAPATH #define NO_SYSTEM_DATAPATH
#endif #endif

View File

@ -120,7 +120,7 @@ void ProfileUpdater::copyDataToProfile()
browseData.copy(browseDataBackup); browseData.copy(browseDataBackup);
QFile(m_profilePath + "settings.ini").copy(settingsBackup); QFile(m_profilePath + "settings.ini").copy(settingsBackup);
const QString &text = "Incompatible profile version has been detected. To avoid losing your profile data, they were " const QString &text = "Incompatible profile version has been detected. To avoid losing your profile data, they were "
"backed up in following directories:<br/><br/><b>" + browseDataBackup + "<br/>" + settingsBackup + "<br/></b>"; "backed up in following directories:<br/><br/><b>" + browseDataBackup + "<br/>" + settingsBackup + "<br/></b>";
QMessageBox::warning(0, "QupZilla: Incompatible profile version", text); QMessageBox::warning(0, "QupZilla: Incompatible profile version", text);
} }

View File

@ -81,4 +81,40 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qz::NewTabPositionFlags)
} }
#ifdef Q_WS_WIN
#define DEFAULT_THEME_NAME "windows"
#elif defined(Q_WS_X11)
#define DEFAULT_THEME_NAME "linux"
#elif defined(Q_WS_MAC)
#define DEFAULT_THEME_NAME "mac"
#elif defined(Q_OS_OS2)
#define DEFAULT_THEME_NAME "windows"
#else
#define DEFAULT_THEME_NAME "default"
#endif
#ifdef Q_WS_WIN
#define DEFAULT_CHECK_UPDATES true
#else
#define DEFAULT_CHECK_UPDATES false
#endif
#ifdef Q_WS_WIN
#define DEFAULT_DOWNLOAD_USE_NATIVE_DIALOG false
#else
#define DEFAULT_DOWNLOAD_USE_NATIVE_DIALOG true
#endif
#ifdef PORTABLE_BUILD
#define DEFAULT_ENABLE_PLUGINS false
#else
#define DEFAULT_ENABLE_PLUGINS true
#endif
#ifdef Q_WS_WIN
#define DEFAULT_DOWNLOAD_USE_NATIVE_DIALOG false
#else
#define DEFAULT_DOWNLOAD_USE_NATIVE_DIALOG true
#endif
#endif // QZ_NAMESPACE_H #endif // QZ_NAMESPACE_H

View File

@ -204,41 +204,55 @@ bool BookmarksModel::saveBookmark(WebView* view, QString folder)
return saveBookmark(view->url(), view->title(), view->icon(), folder); return saveBookmark(view->url(), view->title(), view->icon(), folder);
} }
bool BookmarksModel::removeBookmark(int id) void BookmarksModel::removeBookmark(int id)
{ {
QSqlQuery query; QList<int> list;
query.prepare("SELECT url, title, folder FROM bookmarks WHERE id = ?"); list.append(id);
query.bindValue(0, id);
query.exec(); return removeBookmark(list);
if (!query.next()) { }
return false;
void BookmarksModel::removeBookmark(const QList<int> list)
{
QSqlDatabase db = QSqlDatabase::database();
db.transaction();
foreach (int id, list) {
QSqlQuery query;
query.prepare("SELECT url, title, folder FROM bookmarks WHERE id = ?");
query.bindValue(0, id);
query.exec();
if (!query.next()) {
continue;
}
Bookmark bookmark;
bookmark.id = id;
bookmark.url = query.value(0).toUrl();
bookmark.title = query.value(1).toString();
bookmark.folder = query.value(2).toString();
bookmark.image = QImage::fromData(query.value(3).toByteArray());
bookmark.inSubfolder = isSubfolder(bookmark.folder);
if (!query.exec("DELETE FROM bookmarks WHERE id = " + QString::number(id))) {
continue;
}
emit bookmarkDeleted(bookmark);
} }
Bookmark bookmark; db.commit();
bookmark.id = id;
bookmark.url = query.value(0).toUrl();
bookmark.title = query.value(1).toString();
bookmark.folder = query.value(2).toString();
bookmark.image = QImage::fromData(query.value(3).toByteArray());
bookmark.inSubfolder = isSubfolder(bookmark.folder);
if (!query.exec("DELETE FROM bookmarks WHERE id = " + QString::number(id))) {
return false;
}
emit bookmarkDeleted(bookmark);
mApp->sendMessages(Qz::AM_BookmarksChanged, true); mApp->sendMessages(Qz::AM_BookmarksChanged, true);
return true;
} }
bool BookmarksModel::removeBookmark(const QUrl &url) void BookmarksModel::removeBookmark(const QUrl &url)
{ {
return removeBookmark(bookmarkId(url)); removeBookmark(bookmarkId(url));
} }
bool BookmarksModel::removeBookmark(WebView* view) void BookmarksModel::removeBookmark(WebView* view)
{ {
return removeBookmark(bookmarkId(view->url())); removeBookmark(bookmarkId(view->url()));
} }
//bool BookmarksModel::editBookmark(int id, const QString &title, const QString &folder) //bool BookmarksModel::editBookmark(int id, const QString &title, const QString &folder)
@ -322,37 +336,32 @@ bool BookmarksModel::createFolder(const QString &name)
return true; return true;
} }
bool BookmarksModel::removeFolder(const QString &name) void BookmarksModel::removeFolder(const QString &name)
{ {
if (name == _bookmarksMenu || name == _bookmarksToolbar) { if (name == _bookmarksMenu || name == _bookmarksToolbar) {
return false; return;
} }
QSqlQuery query; QSqlQuery query;
query.prepare("SELECT id FROM bookmarks WHERE folder = ? "); query.prepare("SELECT id FROM bookmarks WHERE folder = ? ");
query.bindValue(0, name); query.bindValue(0, name);
if (!query.exec()) { if (!query.exec()) {
return false; return;
} }
QList<int> list;
while (query.next()) { while (query.next()) {
removeBookmark(query.value(0).toInt()); list.append(query.value(0).toInt());
} }
removeBookmark(list);
query.prepare("DELETE FROM folders WHERE name=?"); query.prepare("DELETE FROM folders WHERE name=?");
query.bindValue(0, name); query.bindValue(0, name);
if (!query.exec()) { query.exec();
return false;
}
query.prepare("DELETE FROM bookmarks WHERE folder=?");
query.bindValue(0, name);
if (!query.exec()) {
return false;
}
emit folderDeleted(name); emit folderDeleted(name);
mApp->sendMessages(Qz::AM_BookmarksChanged, true); mApp->sendMessages(Qz::AM_BookmarksChanged, true);
return true;
} }
bool BookmarksModel::renameFolder(const QString &before, const QString &after) bool BookmarksModel::renameFolder(const QString &before, const QString &after)

View File

@ -80,16 +80,17 @@ public:
bool saveBookmark(const QUrl &url, const QString &title, const QIcon &icon, const QString &folder = "unsorted"); bool saveBookmark(const QUrl &url, const QString &title, const QIcon &icon, const QString &folder = "unsorted");
bool saveBookmark(WebView* view, QString folder = QString()); bool saveBookmark(WebView* view, QString folder = QString());
bool removeBookmark(int id); void removeBookmark(const QUrl &url);
bool removeBookmark(const QUrl &url); void removeBookmark(WebView* view);
bool removeBookmark(WebView* view); void removeBookmark(int id);
void removeBookmark(const QList<int> list);
bool editBookmark(int id, const QString &title = "", const QUrl &url = QUrl(), const QString &folder = ""); bool editBookmark(int id, const QString &title = "", const QUrl &url = QUrl(), const QString &folder = "");
// bool editBookmark(int id, const QString &title, const QString &folder); // bool editBookmark(int id, const QString &title, const QString &folder);
// bool editBookmark(int id, const QUrl &url, const QString &title); // bool editBookmark(int id, const QUrl &url, const QString &title);
bool createFolder(const QString &name); bool createFolder(const QString &name);
bool removeFolder(const QString &name); void removeFolder(const QString &name);
QList<Bookmark> folderBookmarks(const QString &name); QList<Bookmark> folderBookmarks(const QString &name);

View File

@ -260,15 +260,19 @@ void BookmarksImportDialog::setFile()
void BookmarksImportDialog::addExportedBookmarks() void BookmarksImportDialog::addExportedBookmarks()
{ {
qApp->setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
BookmarksModel* model = mApp->bookmarksModel(); BookmarksModel* model = mApp->bookmarksModel();
QSqlDatabase db = QSqlDatabase::database();
db.transaction();
foreach(const Bookmark & b, m_exportedBookmarks) { foreach(const Bookmark & b, m_exportedBookmarks) {
model->saveBookmark(b.url, b.title, IconProvider::iconFromImage(b.image), b.folder); model->saveBookmark(b.url, b.title, IconProvider::iconFromImage(b.image), b.folder);
} }
qApp->restoreOverrideCursor(); db.commit();
QApplication::restoreOverrideCursor();
} }
void BookmarksImportDialog::setupBrowser(Browser browser) void BookmarksImportDialog::setupBrowser(Browser browser)

View File

@ -35,12 +35,6 @@
#include <QProcess> #include <QProcess>
#include <QMessageBox> #include <QMessageBox>
#ifdef Q_WS_WIN
#define DEFAULT_USE_NATIVE_DIALOG false
#else
#define DEFAULT_USE_NATIVE_DIALOG true
#endif
DownloadManager::DownloadManager(QWidget* parent) DownloadManager::DownloadManager(QWidget* parent)
: QWidget(parent) : QWidget(parent)
, ui(new Ui::DownloadManager) , ui(new Ui::DownloadManager)
@ -76,7 +70,7 @@ void DownloadManager::loadSettings()
m_downloadPath = settings.value("defaultDownloadPath", "").toString(); m_downloadPath = settings.value("defaultDownloadPath", "").toString();
m_lastDownloadPath = settings.value("lastDownloadPath", QDir::homePath().append("/")).toString(); m_lastDownloadPath = settings.value("lastDownloadPath", QDir::homePath().append("/")).toString();
m_closeOnFinish = settings.value("CloseManagerOnFinish", false).toBool(); m_closeOnFinish = settings.value("CloseManagerOnFinish", false).toBool();
m_useNativeDialog = settings.value("useNativeDialog", DEFAULT_USE_NATIVE_DIALOG).toBool(); m_useNativeDialog = settings.value("useNativeDialog", DEFAULT_DOWNLOAD_USE_NATIVE_DIALOG).toBool();
m_useExternalManager = settings.value("UseExternalManager", false).toBool(); m_useExternalManager = settings.value("UseExternalManager", false).toBool();
m_externalExecutable = settings.value("ExternalManagerExecutable", "").toString(); m_externalExecutable = settings.value("ExternalManagerExecutable", "").toString();

View File

@ -33,6 +33,10 @@ struct PluginSpec {
QPixmap icon; QPixmap icon;
bool hasSettings; bool hasSettings;
PluginSpec() {
hasSettings = false;
}
bool operator==(const PluginSpec &other) { bool operator==(const PluginSpec &other) {
return (this->name == other.name && return (this->name == other.name &&
this->info == other.info && this->info == other.info &&

View File

@ -25,12 +25,6 @@
#include <QPluginLoader> #include <QPluginLoader>
#include <QDir> #include <QDir>
#ifdef PORTABLE_BUILD
#define DEFAULT_ENABLE_PLUGINS false
#else
#define DEFAULT_ENABLE_PLUGINS true
#endif
Plugins::Plugins(QObject* parent) Plugins::Plugins(QObject* parent)
: QObject(parent) : QObject(parent)
, m_pluginsLoaded(false) , m_pluginsLoaded(false)

View File

@ -27,12 +27,6 @@
#include <QMessageBox> #include <QMessageBox>
#include <QTimer> #include <QTimer>
#ifdef PORTABLE_BUILD
#define DEFAULT_ENABLE_PLUGINS false
#else
#define DEFAULT_ENABLE_PLUGINS true
#endif
PluginsList::PluginsList(QWidget* parent) PluginsList::PluginsList(QWidget* parent)
: QWidget(parent) : QWidget(parent)
, ui(new Ui::PluginsList) , ui(new Ui::PluginsList)

View File

@ -48,14 +48,6 @@
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#ifdef Q_WS_WIN
#define DEFAULT_CHECK_UPDATES true
#define DEFAULT_USE_NATIVE_DIALOG false
#else
#define DEFAULT_CHECK_UPDATES false
#define DEFAULT_USE_NATIVE_DIALOG true
#endif
Preferences::Preferences(QupZilla* mainClass, QWidget* parent) Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
: QDialog(parent) : QDialog(parent)
, ui(new Ui::Preferences) , ui(new Ui::Preferences)
@ -285,7 +277,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
settings.beginGroup("DownloadManager"); settings.beginGroup("DownloadManager");
ui->downLoc->setText(settings.value("defaultDownloadPath", "").toString()); ui->downLoc->setText(settings.value("defaultDownloadPath", "").toString());
ui->closeDownManOnFinish->setChecked(settings.value("CloseManagerOnFinish", false).toBool()); ui->closeDownManOnFinish->setChecked(settings.value("CloseManagerOnFinish", false).toBool());
ui->downlaodNativeSystemDialog->setChecked(settings.value("useNativeDialog", DEFAULT_USE_NATIVE_DIALOG).toBool()); ui->downlaodNativeSystemDialog->setChecked(settings.value("useNativeDialog", DEFAULT_DOWNLOAD_USE_NATIVE_DIALOG).toBool());
if (ui->downLoc->text().isEmpty()) { if (ui->downLoc->text().isEmpty()) {
ui->askEverytime->setChecked(true); ui->askEverytime->setChecked(true);
} }

View File

@ -26,12 +26,6 @@
#include <QTextBrowser> #include <QTextBrowser>
#include <QDir> #include <QDir>
#ifdef Q_WS_WIN
#define DEFAULT_THEME_NAME "windows"
#else
#define DEFAULT_THEME_NAME "linux"
#endif
ThemeManager::ThemeManager(QWidget* parent, Preferences* preferences) ThemeManager::ThemeManager(QWidget* parent, Preferences* preferences)
: QWidget() : QWidget()
, ui(new Ui::ThemeManager) , ui(new Ui::ThemeManager)