From 7189ff58b40f06a807834215a8c624a268411530 Mon Sep 17 00:00:00 2001 From: nowrep Date: Sat, 8 Sep 2012 22:52:32 +0200 Subject: [PATCH] LocationCompleter: Improved sorting bookmarks by visit count. - it sorts by visit counts of bookmark's url from history - count column in bookmarks is not needed after all :-) Patch by Franz Fellner --- CHANGELOG | 1 + src/lib/app/profileupdater.cpp | 28 ++++-------------- src/lib/app/profileupdater.h | 1 - src/lib/bookmarks/bookmarksmanager.cpp | 6 ---- src/lib/bookmarks/bookmarksmodel.cpp | 8 ----- src/lib/bookmarks/bookmarksmodel.h | 2 -- src/lib/data/data/browsedata.db | Bin 18432 -> 18432 bytes .../completer/locationcompleter.cpp | 12 +------- .../navigation/completer/locationcompleter.h | 2 +- .../completer/locationcompletermodel.cpp | 6 ++-- src/lib/navigation/locationbar.cpp | 15 ++-------- src/lib/navigation/locationbar.h | 3 +- src/lib/sidebar/bookmarkssidebar.cpp | 15 +++------- 13 files changed, 18 insertions(+), 81 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 99662ac2f..952df36a8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,6 +21,7 @@ Version 1.3.5 * new option to hide close button on tabs * new option to start new instance with --no-remote option * X11: restore windows on correct virtual desktops + * MouseGestures: added 2 new gestures for switching tabs * fixed visibility of navigation bar in fullscreen * fixed bad position of add tab button when there is a lot of tabs * fixed gui with RTL languages diff --git a/src/lib/app/profileupdater.cpp b/src/lib/app/profileupdater.cpp index ef3d96ac4..b684efb7d 100644 --- a/src/lib/app/profileupdater.cpp +++ b/src/lib/app/profileupdater.cpp @@ -29,8 +29,6 @@ ProfileUpdater::ProfileUpdater(const QString &profilePath) : m_profilePath(profilePath) { - // FIXME: Remove this line when releasing new version - update131(); } void ProfileUpdater::checkProfile() @@ -84,9 +82,9 @@ void ProfileUpdater::updateProfile(const QString ¤t, const QString &profil return; } - if (profileVersion == Updater::parseVersionFromString("1.1.0") || - profileVersion == Updater::parseVersionFromString("1.1.5") || - profileVersion == Updater::parseVersionFromString("1.1.8")) { + if (profileVersion == Updater::parseVersionFromString("1.1.0") + || profileVersion == Updater::parseVersionFromString("1.1.5") + || profileVersion == Updater::parseVersionFromString("1.1.8")) { update118(); return; } @@ -96,16 +94,12 @@ void ProfileUpdater::updateProfile(const QString ¤t, const QString &profil return; } - if (profileVersion == Updater::parseVersionFromString("1.3.0")) { + if (profileVersion == Updater::parseVersionFromString("1.3.0") + || profileVersion == Updater::parseVersionFromString("1.3.1")) { update130(); return; } - if (profileVersion == Updater::parseVersionFromString("1.3.1")) { - update131(); - return; - } - std::cout << "QupZilla: Incompatible profile version detected, overwriting profile data..." << std::endl; copyDataToProfile(); @@ -212,16 +206,4 @@ void ProfileUpdater::update130() QSqlQuery query; query.exec("ALTER TABLE bookmarks ADD COLUMN keyword TEXT"); - - update131(); -} - -void ProfileUpdater::update131() -{ - std::cout << "QupZilla: Upgrading profile version from 1.3.1..." << std::endl; - mApp->connectDatabase(); - - QSqlQuery query; - query.exec("ALTER TABLE bookmarks ADD COLUMN count NUMERIC"); - query.exec("UPDATE bookmarks SET count=0"); } diff --git a/src/lib/app/profileupdater.h b/src/lib/app/profileupdater.h index 5b2a11e25..c088f5d92 100644 --- a/src/lib/app/profileupdater.h +++ b/src/lib/app/profileupdater.h @@ -38,7 +38,6 @@ private: void update118(); void update120(); void update130(); - void update131(); QString m_profilePath; }; diff --git a/src/lib/bookmarks/bookmarksmanager.cpp b/src/lib/bookmarks/bookmarksmanager.cpp index c8df0a893..de6f916eb 100644 --- a/src/lib/bookmarks/bookmarksmanager.cpp +++ b/src/lib/bookmarks/bookmarksmanager.cpp @@ -196,9 +196,6 @@ void BookmarksManager::itemControlClicked(QTreeWidgetItem* item) return; } - int id = item->data(0, Qt::UserRole + 10).toInt(); - mApp->bookmarksModel()->countUpBookmark(id); - const QUrl &url = QUrl::fromEncoded(item->text(1).toUtf8()); getQupZilla()->tabWidget()->addView(url, item->text(0)); } @@ -212,9 +209,6 @@ void BookmarksManager::loadInNewTab() return; } - int id = item->data(0, Qt::UserRole + 10).toInt(); - mApp->bookmarksModel()->countUpBookmark(id); - getQupZilla()->tabWidget()->addView(action->data().toUrl(), item->text(0), qzSettings->newTabPosition); } diff --git a/src/lib/bookmarks/bookmarksmodel.cpp b/src/lib/bookmarks/bookmarksmodel.cpp index 80ce218d2..bea0b023d 100644 --- a/src/lib/bookmarks/bookmarksmodel.cpp +++ b/src/lib/bookmarks/bookmarksmodel.cpp @@ -369,14 +369,6 @@ bool BookmarksModel::changeIcon(int id, const QIcon &icon) return true; } -void BookmarksModel::countUpBookmark(int id) -{ - QSqlQuery query; - query.prepare("UPDATE bookmarks SET count = count + 1 WHERE id=?"); - query.addBindValue(id); - query.exec(); -} - bool BookmarksModel::createFolder(const QString &name) { if (isFolder(name)) { diff --git a/src/lib/bookmarks/bookmarksmodel.h b/src/lib/bookmarks/bookmarksmodel.h index 3e6da40c1..eaeb73d20 100644 --- a/src/lib/bookmarks/bookmarksmodel.h +++ b/src/lib/bookmarks/bookmarksmodel.h @@ -88,8 +88,6 @@ public: bool editBookmark(int id, const QString &title = QString(), const QUrl &url = QUrl(), const QString &folder = QString()); bool changeIcon(int id, const QIcon &icon); - void countUpBookmark(int id); - bool createFolder(const QString &name); void removeFolder(const QString &name); diff --git a/src/lib/data/data/browsedata.db b/src/lib/data/data/browsedata.db index 2eb02a647bae81d196fc7a2cab0e70c42d32e780..b15dca4534d1446170e9af62e880d0d26038e592 100644 GIT binary patch delta 128 zcmZpez}PT>ae}mw2P&~0Q ale?XZm7~`{mqFH+V{@ZJH1p(}?&<(uM<4b8 delta 146 zcmZpez}PT>ae}m itemList; if (showType == HistoryAndBookmarks || showType == Bookmarks) { - QSqlQuery query = createQuery(string, "bookmarks.count DESC", urlList, limit, true); + QSqlQuery query = createQuery(string, "history.count DESC", urlList, limit, true); query.exec(); while (query.next()) { @@ -67,7 +67,7 @@ void LocationCompleterModel::refreshCompletions(const QString &string) item->setText(url.toEncoded()); item->setData(query.value(0), IdRole); item->setData(query.value(2), TitleRole); - item->setData(query.value(3).toInt() + 10, CountRole); // Give +10 count bonus to bookmarks + item->setData(query.value(3), CountRole); item->setData(QVariant(true), BookmarkRole); item->setData(string, SearchStringRole); @@ -129,7 +129,7 @@ QSqlQuery LocationCompleterModel::createQuery(const QString &searchString, const const QList &alreadyFound, int limit, bool bookmarks, bool exactMatch) { QString table = bookmarks ? "bookmarks" : "history"; - QString query = QString("SELECT %1.id, %1.url, %1.title, %1.count").arg(table); + QString query = QString("SELECT %1.id, %1.url, %1.title, history.count").arg(table); QStringList searchList; if (bookmarks) { diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index 879cf0d8a..5be4d9ffa 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -50,7 +50,6 @@ LocationBar::LocationBar(QupZilla* mainClass) , m_pasteAndGoAction(0) , m_clearAction(0) , m_holdingAlt(false) - , m_completerBookmarkId(-1) , m_loadProgress(0) , m_loadFinished(true) { @@ -77,7 +76,7 @@ LocationBar::LocationBar(QupZilla* mainClass) addWidget(down, LineEdit::RightSide); m_completer.setLocationBar(this); - connect(&m_completer, SIGNAL(showCompletion(QString, int)), this, SLOT(showCompletion(QString, int))); + connect(&m_completer, SIGNAL(showCompletion(QString)), this, SLOT(showCompletion(QString))); connect(&m_completer, SIGNAL(completionActivated()), this, SLOT(urlEnter())); connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEdit())); @@ -110,10 +109,8 @@ void LocationBar::updatePlaceHolderText() setPlaceholderText(tr("Enter URL address or search on %1").arg(mApp->searchEnginesManager()->activeEngine().name)); } -void LocationBar::showCompletion(const QString &newText, int bookmarkId) +void LocationBar::showCompletion(const QString &newText) { - m_completerBookmarkId = bookmarkId; - LineEdit::setText(newText); // Move cursor to the end @@ -162,12 +159,6 @@ QString LocationBar::convertUrlToText(const QUrl &url) const void LocationBar::urlEnter() { - if (m_completerBookmarkId != -1) { - mApp->bookmarksModel()->countUpBookmark(m_completerBookmarkId); - - m_completerBookmarkId = -1; - } - m_completer.closePopup(); m_webView->setFocus(); @@ -183,8 +174,6 @@ void LocationBar::textEdit() m_completer.closePopup(); } - m_completerBookmarkId = -1; - showGoButton(); } diff --git a/src/lib/navigation/locationbar.h b/src/lib/navigation/locationbar.h index 3adddc975..3e1cf6ac5 100644 --- a/src/lib/navigation/locationbar.h +++ b/src/lib/navigation/locationbar.h @@ -71,7 +71,7 @@ private slots: void pasteAndGo(); void updatePlaceHolderText(); - void showCompletion(const QString &newText, int bookmarkId); + void showCompletion(const QString &newText); void onLoadProgress(int progress); void onLoadFinished(); @@ -109,7 +109,6 @@ private: bool m_rssIconVisible; bool m_holdingAlt; - int m_completerBookmarkId; int m_loadProgress; bool m_loadFinished; diff --git a/src/lib/sidebar/bookmarkssidebar.cpp b/src/lib/sidebar/bookmarkssidebar.cpp index b0890fc86..5311c250f 100644 --- a/src/lib/sidebar/bookmarkssidebar.cpp +++ b/src/lib/sidebar/bookmarkssidebar.cpp @@ -54,12 +54,14 @@ BookmarksSideBar::BookmarksSideBar(QupZilla* mainClass, QWidget* parent) connect(m_bookmarksModel, SIGNAL(bookmarkAdded(BookmarksModel::Bookmark)), this, SLOT(addBookmark(BookmarksModel::Bookmark))); connect(m_bookmarksModel, SIGNAL(bookmarkDeleted(BookmarksModel::Bookmark)), this, SLOT(removeBookmark(BookmarksModel::Bookmark))); - connect(m_bookmarksModel, SIGNAL(bookmarkEdited(BookmarksModel::Bookmark, BookmarksModel::Bookmark)), this, SLOT(bookmarkEdited(BookmarksModel::Bookmark, BookmarksModel::Bookmark))); + connect(m_bookmarksModel, SIGNAL(bookmarkEdited(BookmarksModel::Bookmark, BookmarksModel::Bookmark)), + this, SLOT(bookmarkEdited(BookmarksModel::Bookmark, BookmarksModel::Bookmark))); connect(m_bookmarksModel, SIGNAL(folderAdded(QString)), this, SLOT(addFolder(QString))); connect(m_bookmarksModel, SIGNAL(folderDeleted(QString)), this, SLOT(removeFolder(QString))); connect(m_bookmarksModel, SIGNAL(folderRenamed(QString, QString)), this, SLOT(renameFolder(QString, QString))); connect(m_bookmarksModel, SIGNAL(folderParentChanged(QString, bool)), this, SLOT(changeFolderParent(QString, bool))); - connect(m_bookmarksModel, SIGNAL(bookmarkParentChanged(QString, QByteArray, int, QUrl, QString, QString)), this, SLOT(changeBookmarkParent(QString, QByteArray, int, QUrl, QString, QString))); + connect(m_bookmarksModel, SIGNAL(bookmarkParentChanged(QString, QByteArray, int, QUrl, QString, QString)), + this, SLOT(changeBookmarkParent(QString, QByteArray, int, QUrl, QString, QString))); QTimer::singleShot(0, this, SLOT(refreshTable())); } @@ -70,9 +72,6 @@ void BookmarksSideBar::itemControlClicked(QTreeWidgetItem* item) return; } - int id = item->data(0, Qt::UserRole + 10).toInt(); - mApp->bookmarksModel()->countUpBookmark(id); - const QUrl &url = QUrl::fromEncoded(item->text(1).toUtf8()); p_QupZilla->tabWidget()->addView(url, item->text(0)); } @@ -83,9 +82,6 @@ void BookmarksSideBar::itemDoubleClicked(QTreeWidgetItem* item) return; } - int id = item->data(0, Qt::UserRole + 10).toInt(); - mApp->bookmarksModel()->countUpBookmark(id); - const QUrl &url = QUrl::fromEncoded(item->text(1).toUtf8()); p_QupZilla->loadAddress(url); } @@ -99,9 +95,6 @@ void BookmarksSideBar::loadInNewTab() return; } - int id = item->data(0, Qt::UserRole + 10).toInt(); - mApp->bookmarksModel()->countUpBookmark(id); - p_QupZilla->tabWidget()->addView(action->data().toUrl(), item->text(0), qzSettings->newTabPosition); }