mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-19 10:16:34 +01:00
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 <alpine.art.de@gmail.com>
This commit is contained in:
parent
c2100127e0
commit
7189ff58b4
@ -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
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ private:
|
||||
void update118();
|
||||
void update120();
|
||||
void update130();
|
||||
void update131();
|
||||
|
||||
QString m_profilePath;
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
|
||||
|
Binary file not shown.
@ -63,23 +63,13 @@ void LocationCompleter::showMostVisited()
|
||||
|
||||
void LocationCompleter::currentChanged(const QModelIndex &index)
|
||||
{
|
||||
int bookmarkId = -1;
|
||||
QString completion = index.data().toString();
|
||||
|
||||
if (completion.isEmpty()) {
|
||||
completion = m_originalText;
|
||||
}
|
||||
|
||||
if (index.data(LocationCompleterModel::BookmarkRole).toBool()) {
|
||||
bool ok = false;
|
||||
int id = index.data(LocationCompleterModel::IdRole).toInt(&ok);
|
||||
|
||||
if (ok) {
|
||||
bookmarkId = id;
|
||||
}
|
||||
}
|
||||
|
||||
emit showCompletion(completion, bookmarkId);
|
||||
emit showCompletion(completion);
|
||||
}
|
||||
|
||||
void LocationCompleter::popupClosed()
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
void closePopup();
|
||||
|
||||
signals:
|
||||
void showCompletion(const QString &, int bookmarkId);
|
||||
void showCompletion(const QString &);
|
||||
void completionActivated();
|
||||
|
||||
public slots:
|
||||
|
@ -56,7 +56,7 @@ void LocationCompleterModel::refreshCompletions(const QString &string)
|
||||
QList<QStandardItem*> 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<QUrl> &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) {
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user