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