1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +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.
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
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.
@ -80,6 +80,4 @@ FAQ and Changelog
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
Changelog: https://github.com/nowrep/QupZilla/wiki/Changelog
[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)

View File

@ -60,24 +60,6 @@
#include <QTimer>
#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)
#define NO_SYSTEM_DATAPATH
#endif

View File

@ -120,7 +120,7 @@ void ProfileUpdater::copyDataToProfile()
browseData.copy(browseDataBackup);
QFile(m_profilePath + "settings.ini").copy(settingsBackup);
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);
}

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

View File

@ -204,41 +204,55 @@ bool BookmarksModel::saveBookmark(WebView* view, QString folder)
return saveBookmark(view->url(), view->title(), view->icon(), folder);
}
bool BookmarksModel::removeBookmark(int id)
void BookmarksModel::removeBookmark(int id)
{
QSqlQuery query;
query.prepare("SELECT url, title, folder FROM bookmarks WHERE id = ?");
query.bindValue(0, id);
query.exec();
if (!query.next()) {
return false;
QList<int> list;
list.append(id);
return removeBookmark(list);
}
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;
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);
db.commit();
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)
@ -322,37 +336,32 @@ bool BookmarksModel::createFolder(const QString &name)
return true;
}
bool BookmarksModel::removeFolder(const QString &name)
void BookmarksModel::removeFolder(const QString &name)
{
if (name == _bookmarksMenu || name == _bookmarksToolbar) {
return false;
return;
}
QSqlQuery query;
query.prepare("SELECT id FROM bookmarks WHERE folder = ? ");
query.bindValue(0, name);
if (!query.exec()) {
return false;
return;
}
QList<int> list;
while (query.next()) {
removeBookmark(query.value(0).toInt());
list.append(query.value(0).toInt());
}
removeBookmark(list);
query.prepare("DELETE FROM folders WHERE name=?");
query.bindValue(0, name);
if (!query.exec()) {
return false;
}
query.prepare("DELETE FROM bookmarks WHERE folder=?");
query.bindValue(0, name);
if (!query.exec()) {
return false;
}
query.exec();
emit folderDeleted(name);
mApp->sendMessages(Qz::AM_BookmarksChanged, true);
return true;
}
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(WebView* view, QString folder = QString());
bool removeBookmark(int id);
bool removeBookmark(const QUrl &url);
bool removeBookmark(WebView* view);
void removeBookmark(const QUrl &url);
void 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 QString &folder);
// bool editBookmark(int id, const QUrl &url, const QString &title);
bool createFolder(const QString &name);
bool removeFolder(const QString &name);
void removeFolder(const QString &name);
QList<Bookmark> folderBookmarks(const QString &name);

View File

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

View File

@ -35,12 +35,6 @@
#include <QProcess>
#include <QMessageBox>
#ifdef Q_WS_WIN
#define DEFAULT_USE_NATIVE_DIALOG false
#else
#define DEFAULT_USE_NATIVE_DIALOG true
#endif
DownloadManager::DownloadManager(QWidget* parent)
: QWidget(parent)
, ui(new Ui::DownloadManager)
@ -76,7 +70,7 @@ void DownloadManager::loadSettings()
m_downloadPath = settings.value("defaultDownloadPath", "").toString();
m_lastDownloadPath = settings.value("lastDownloadPath", QDir::homePath().append("/")).toString();
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_externalExecutable = settings.value("ExternalManagerExecutable", "").toString();

View File

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

View File

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

View File

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

View File

@ -48,14 +48,6 @@
#include <QFileDialog>
#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)
: QDialog(parent)
, ui(new Ui::Preferences)
@ -285,7 +277,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
settings.beginGroup("DownloadManager");
ui->downLoc->setText(settings.value("defaultDownloadPath", "").toString());
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()) {
ui->askEverytime->setChecked(true);
}

View File

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