1
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:
nowrep 2012-08-10 18:06:29 +02:00
parent afd022534b
commit 1f225de11c
6 changed files with 140 additions and 63 deletions

View File

@ -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,11 +43,14 @@ 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;
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);
@ -67,7 +71,9 @@ void LocationCompleterModel::refreshCompletions(const QString &string)
}
limit -= query.size();
}
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);
@ -90,6 +96,7 @@ void LocationCompleterModel::refreshCompletions(const QString &string)
appendRow(item);
}
}
}
void LocationCompleterModel::showMostVisited()

View File

@ -38,6 +38,13 @@ signals:
public slots:
private:
enum Type {
HistoryAndBookmarks = 0,
History = 1,
Bookmarks = 2,
Nothing = 3
};
QString m_lastCompletion;
};

View File

@ -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");

View File

@ -30,6 +30,7 @@ public:
static bool selectAllOnClick;
static bool addCountryWithAlt;
static int showLocationSuggestions;
static bool showSearchSuggestions;
};

View File

@ -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());

View File

@ -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>&lt;b&gt;Address Bar behaviour&lt;/b&gt;</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,20 +776,63 @@
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="showTabPreviews">
<item row="17" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
<widget class="QLabel" name="label_59">
<property name="text">
<string>Show tab previews</string>
<string>Suggest when typing into address bar:</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>
<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>
<widget class="QWidget" name="stackedWidgetPage4">