mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Added option to choose what to suggest in address bar
- History and Bookmarks History only Bookmarks only Nothing
This commit is contained in:
parent
afd022534b
commit
1f225de11c
@ -16,6 +16,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
#include "locationcompletermodel.h"
|
#include "locationcompletermodel.h"
|
||||||
|
#include "locationbarsettings.h"
|
||||||
#include "iconprovider.h"
|
#include "iconprovider.h"
|
||||||
#include "mainapplication.h"
|
#include "mainapplication.h"
|
||||||
|
|
||||||
@ -42,53 +43,59 @@ void LocationCompleterModel::refreshCompletions(const QString &string)
|
|||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
|
Type showType = (Type) LocationBarSettings::showLocationSuggestions;
|
||||||
|
|
||||||
int limit = string.size() < 3 ? 25 : 15;
|
int limit = string.size() < 3 ? 25 : 15;
|
||||||
QString searchString = QString("%%1%").arg(string);
|
QString searchString = QString("%%1%").arg(string);
|
||||||
QList<QUrl> urlList;
|
QList<QUrl> urlList;
|
||||||
|
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
query.prepare("SELECT id, url, title, icon FROM bookmarks WHERE title LIKE ? OR url LIKE ? LIMIT ?");
|
|
||||||
query.addBindValue(searchString);
|
|
||||||
query.addBindValue(searchString);
|
|
||||||
query.addBindValue(limit);
|
|
||||||
query.exec();
|
|
||||||
|
|
||||||
while (query.next()) {
|
if (showType == HistoryAndBookmarks || showType == Bookmarks) {
|
||||||
QStandardItem* item = new QStandardItem();
|
query.prepare("SELECT id, url, title, icon FROM bookmarks WHERE title LIKE ? OR url LIKE ? LIMIT ?");
|
||||||
const QUrl &url = query.value(1).toUrl();
|
query.addBindValue(searchString);
|
||||||
|
query.addBindValue(searchString);
|
||||||
|
query.addBindValue(limit);
|
||||||
|
query.exec();
|
||||||
|
|
||||||
item->setIcon(qIconProvider->iconFromImage(QImage::fromData(query.value(3).toByteArray())));
|
while (query.next()) {
|
||||||
item->setText(url.toEncoded());
|
QStandardItem* item = new QStandardItem();
|
||||||
item->setData(query.value(0), IdRole);
|
const QUrl &url = query.value(1).toUrl();
|
||||||
item->setData(query.value(2), TitleRole);
|
|
||||||
item->setData(QVariant(true), BookmarkRole);
|
|
||||||
appendRow(item);
|
|
||||||
urlList.append(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
limit -= query.size();
|
item->setIcon(qIconProvider->iconFromImage(QImage::fromData(query.value(3).toByteArray())));
|
||||||
|
item->setText(url.toEncoded());
|
||||||
query.prepare("SELECT id, url, title FROM history WHERE title LIKE ? OR url LIKE ? ORDER BY count DESC LIMIT ?");
|
item->setData(query.value(0), IdRole);
|
||||||
query.addBindValue(searchString);
|
item->setData(query.value(2), TitleRole);
|
||||||
query.addBindValue(searchString);
|
item->setData(QVariant(true), BookmarkRole);
|
||||||
query.addBindValue(limit);
|
appendRow(item);
|
||||||
query.exec();
|
urlList.append(url);
|
||||||
|
|
||||||
while (query.next()) {
|
|
||||||
QStandardItem* item = new QStandardItem();
|
|
||||||
const QUrl &url = query.value(1).toUrl();
|
|
||||||
|
|
||||||
if (urlList.contains(url)) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
item->setIcon(_iconForUrl(url));
|
limit -= query.size();
|
||||||
item->setText(url.toEncoded());
|
}
|
||||||
item->setData(query.value(0), IdRole);
|
|
||||||
item->setData(query.value(2), TitleRole);
|
|
||||||
item->setData(QVariant(false), BookmarkRole);
|
|
||||||
|
|
||||||
appendRow(item);
|
if (showType == HistoryAndBookmarks || showType == History) {
|
||||||
|
query.prepare("SELECT id, url, title FROM history WHERE title LIKE ? OR url LIKE ? ORDER BY count DESC LIMIT ?");
|
||||||
|
query.addBindValue(searchString);
|
||||||
|
query.addBindValue(searchString);
|
||||||
|
query.addBindValue(limit);
|
||||||
|
query.exec();
|
||||||
|
|
||||||
|
while (query.next()) {
|
||||||
|
QStandardItem* item = new QStandardItem();
|
||||||
|
const QUrl &url = query.value(1).toUrl();
|
||||||
|
|
||||||
|
if (urlList.contains(url)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
item->setIcon(_iconForUrl(url));
|
||||||
|
item->setText(url.toEncoded());
|
||||||
|
item->setData(query.value(0), IdRole);
|
||||||
|
item->setData(query.value(2), TitleRole);
|
||||||
|
item->setData(QVariant(false), BookmarkRole);
|
||||||
|
|
||||||
|
appendRow(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,13 @@ signals:
|
|||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum Type {
|
||||||
|
HistoryAndBookmarks = 0,
|
||||||
|
History = 1,
|
||||||
|
Bookmarks = 2,
|
||||||
|
Nothing = 3
|
||||||
|
};
|
||||||
|
|
||||||
QString m_lastCompletion;
|
QString m_lastCompletion;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
bool LocationBarSettings::selectAllOnDoubleClick = false;
|
bool LocationBarSettings::selectAllOnDoubleClick = false;
|
||||||
bool LocationBarSettings::selectAllOnClick = false;
|
bool LocationBarSettings::selectAllOnClick = false;
|
||||||
bool LocationBarSettings::addCountryWithAlt = false;
|
bool LocationBarSettings::addCountryWithAlt = false;
|
||||||
|
|
||||||
|
int LocationBarSettings::showLocationSuggestions = 0;
|
||||||
bool LocationBarSettings::showSearchSuggestions = false;
|
bool LocationBarSettings::showSearchSuggestions = false;
|
||||||
|
|
||||||
LocationBarSettings::LocationBarSettings()
|
LocationBarSettings::LocationBarSettings()
|
||||||
@ -36,6 +38,7 @@ void LocationBarSettings::loadSettings()
|
|||||||
selectAllOnDoubleClick = settings.value("SelectAllTextOnDoubleClick", true).toBool();
|
selectAllOnDoubleClick = settings.value("SelectAllTextOnDoubleClick", true).toBool();
|
||||||
selectAllOnClick = settings.value("SelectAllTextOnClick", false).toBool();
|
selectAllOnClick = settings.value("SelectAllTextOnClick", false).toBool();
|
||||||
addCountryWithAlt = settings.value("AddCountryDomainWithAltKey", true).toBool();
|
addCountryWithAlt = settings.value("AddCountryDomainWithAltKey", true).toBool();
|
||||||
|
showLocationSuggestions = settings.value("showSuggestions", 0).toInt();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup("SearchEngines");
|
settings.beginGroup("SearchEngines");
|
||||||
|
@ -30,6 +30,7 @@ public:
|
|||||||
static bool selectAllOnClick;
|
static bool selectAllOnClick;
|
||||||
static bool addCountryWithAlt;
|
static bool addCountryWithAlt;
|
||||||
|
|
||||||
|
static int showLocationSuggestions;
|
||||||
static bool showSearchSuggestions;
|
static bool showSearchSuggestions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -176,6 +176,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
|
|||||||
|
|
||||||
//AddressBar
|
//AddressBar
|
||||||
settings.beginGroup("AddressBar");
|
settings.beginGroup("AddressBar");
|
||||||
|
ui->addressbarCompletion->setCurrentIndex(settings.value("showSuggestions", 0).toInt());
|
||||||
ui->selectAllOnFocus->setChecked(settings.value("SelectAllTextOnDoubleClick", true).toBool());
|
ui->selectAllOnFocus->setChecked(settings.value("SelectAllTextOnDoubleClick", true).toBool());
|
||||||
ui->selectAllOnClick->setChecked(settings.value("SelectAllTextOnClick", false).toBool());
|
ui->selectAllOnClick->setChecked(settings.value("SelectAllTextOnClick", false).toBool());
|
||||||
ui->addCountryWithAlt->setChecked(settings.value("AddCountryDomainWithAltKey", true).toBool());
|
ui->addCountryWithAlt->setChecked(settings.value("AddCountryDomainWithAltKey", true).toBool());
|
||||||
@ -873,6 +874,7 @@ void Preferences::saveSettings()
|
|||||||
//OTHER
|
//OTHER
|
||||||
//AddressBar
|
//AddressBar
|
||||||
settings.beginGroup("AddressBar");
|
settings.beginGroup("AddressBar");
|
||||||
|
settings.setValue("showSuggestions", ui->addressbarCompletion->currentIndex());
|
||||||
settings.setValue("SelectAllTextOnDoubleClick", ui->selectAllOnFocus->isChecked());
|
settings.setValue("SelectAllTextOnDoubleClick", ui->selectAllOnFocus->isChecked());
|
||||||
settings.setValue("SelectAllTextOnClick", ui->selectAllOnClick->isChecked());
|
settings.setValue("SelectAllTextOnClick", ui->selectAllOnClick->isChecked());
|
||||||
settings.setValue("AddCountryDomainWithAltKey", ui->addCountryWithAlt->isChecked());
|
settings.setValue("AddCountryDomainWithAltKey", ui->addCountryWithAlt->isChecked());
|
||||||
|
@ -646,42 +646,42 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="1">
|
<item row="9" column="1">
|
||||||
<widget class="QCheckBox" name="activateLastTab">
|
<widget class="QCheckBox" name="activateLastTab">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Activate last tab when closing active tab</string>
|
<string>Activate last tab when closing active tab</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="1">
|
<item row="10" column="1">
|
||||||
<widget class="QCheckBox" name="openNewTabAfterActive">
|
<widget class="QCheckBox" name="openNewTabAfterActive">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Open new tabs after active tab</string>
|
<string>Open new tabs after active tab</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="11" column="1">
|
<item row="12" column="1">
|
||||||
<widget class="QCheckBox" name="dontQuitOnTab">
|
<widget class="QCheckBox" name="dontQuitOnTab">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Don't quit upon closing last tab</string>
|
<string>Don't quit upon closing last tab</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="12" column="1">
|
<item row="13" column="1">
|
||||||
<widget class="QCheckBox" name="askWhenClosingMultipleTabs">
|
<widget class="QCheckBox" name="askWhenClosingMultipleTabs">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Ask when closing multiple tabs</string>
|
<string>Ask when closing multiple tabs</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="13" column="1">
|
<item row="14" column="1">
|
||||||
<widget class="QCheckBox" name="closedInsteadOpened">
|
<widget class="QCheckBox" name="closedInsteadOpened">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Closed tabs list instead of opened in tab bar</string>
|
<string>Closed tabs list instead of opened in tab bar</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="14" column="1">
|
<item row="15" column="1">
|
||||||
<spacer name="verticalSpacer_7">
|
<spacer name="verticalSpacer_7">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -694,35 +694,35 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="15" column="0" colspan="2">
|
<item row="16" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_25">
|
<widget class="QLabel" name="label_25">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><b>Address Bar behaviour</b></string>
|
<string><b>Address Bar behaviour</b></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="16" column="1" colspan="2">
|
<item row="18" column="1" colspan="2">
|
||||||
<widget class="QCheckBox" name="selectAllOnFocus">
|
<widget class="QCheckBox" name="selectAllOnFocus">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Select all text by double clicking in address bar</string>
|
<string>Select all text by double clicking in address bar</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="17" column="1">
|
<item row="19" column="1">
|
||||||
<widget class="QCheckBox" name="selectAllOnClick">
|
<widget class="QCheckBox" name="selectAllOnClick">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Select all text by clicking in address bar</string>
|
<string>Select all text by clicking in address bar</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="18" column="1">
|
<item row="20" column="1">
|
||||||
<widget class="QCheckBox" name="addCountryWithAlt">
|
<widget class="QCheckBox" name="addCountryWithAlt">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add .co.uk domain by pressing ALT key</string>
|
<string>Add .co.uk domain by pressing ALT key</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="19" column="1">
|
<item row="21" column="1">
|
||||||
<spacer name="verticalSpacer_8">
|
<spacer name="verticalSpacer_8">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -735,8 +735,22 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="11" column="1">
|
||||||
|
<widget class="QCheckBox" name="switchToNewTabs">
|
||||||
|
<property name="text">
|
||||||
|
<string>Automatically switch to newly opened tab</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_15">
|
<layout class="QHBoxLayout" name="horizontalLayout_15">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="showTabPreviews">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show tab previews</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_5">
|
<spacer name="horizontalSpacer_5">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -747,7 +761,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>10</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@ -762,19 +776,62 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="17" column="1" colspan="2">
|
||||||
<widget class="QCheckBox" name="showTabPreviews">
|
<layout class="QHBoxLayout" name="horizontalLayout_16">
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Show tab previews</string>
|
<widget class="QLabel" name="label_59">
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>Suggest when typing into address bar:</string>
|
||||||
</item>
|
</property>
|
||||||
<item row="10" column="1">
|
</widget>
|
||||||
<widget class="QCheckBox" name="switchToNewTabs">
|
</item>
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Automatically switch to newly opened tab</string>
|
<widget class="QComboBox" name="addressbarCompletion">
|
||||||
</property>
|
<property name="minimumSize">
|
||||||
</widget>
|
<size>
|
||||||
|
<width>170</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>History and Bookmarks</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>History</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Bookmarks</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Nothing</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_23">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
Reference in New Issue
Block a user