1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

Address bar now searches also in bookmarks.

closes #79
This commit is contained in:
nowrep 2012-04-15 15:41:48 +02:00
parent 431782a147
commit ba1cf804eb
5 changed files with 38 additions and 32 deletions

View File

@ -365,6 +365,6 @@ RESOURCES += \
INSTALLS += target INSTALLS += target
} }
message(========== Building libqupzilla ==========) message(===========================================)
message( Using following defines:) message( Using following defines:)
message($$DEFINES) message( $$DEFINES)

View File

@ -116,21 +116,43 @@ void LocationCompleter::showMostVisited()
void LocationCompleter::refreshCompleter(const QString &string) void LocationCompleter::refreshCompleter(const QString &string)
{ {
int limit; int limit = string.size() < 3 ? 25 : 15;
if (string.size() < 3) {
limit = 25;
}
else {
limit = 15;
}
QSqlQuery query;
query.exec("SELECT title, url FROM history WHERE title LIKE '%" + string + "%' OR url LIKE '%" + string + "%' ORDER BY count DESC LIMIT " + QString::number(limit));
int i = 0; int i = 0;
QString searchString = QString("%%1%").arg(string);
QStandardItemModel* cModel = qobject_cast<QStandardItemModel*>(model()); QStandardItemModel* cModel = qobject_cast<QStandardItemModel*>(model());
QTreeView* treeView = qobject_cast<QTreeView*>(popup()); QTreeView* treeView = qobject_cast<QTreeView*>(popup());
cModel->clear(); cModel->clear();
QSqlQuery query;
query.prepare("SELECT title, url, 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* iconText = new QStandardItem();
QStandardItem* findUrl = new QStandardItem();
QString url = query.value(1).toUrl().toEncoded();
iconText->setIcon(IconProvider::iconFromImage(QImage::fromData(query.value(2).toByteArray())));
iconText->setText(query.value(0).toString().replace("\n", "").append("\n" + url));
findUrl->setText(url);
QList<QStandardItem*> items;
items.append(iconText);
items.append(findUrl);
cModel->insertRow(i, items);
i++;
}
query.prepare("SELECT title, url FROM history WHERE title LIKE ? OR url LIKE ? ORDER BY count DESC LIMIT ?");
query.addBindValue(searchString);
query.addBindValue(searchString);
query.addBindValue(limit - i);
query.exec();
while (query.next()) { while (query.next()) {
QStandardItem* iconText = new QStandardItem(); QStandardItem* iconText = new QStandardItem();
QStandardItem* findUrl = new QStandardItem(); QStandardItem* findUrl = new QStandardItem();
@ -147,20 +169,6 @@ void LocationCompleter::refreshCompleter(const QString &string)
i++; i++;
} }
// if (i == 0) {
// QStandardItem* iconText = new QStandardItem();
// QStandardItem* findUrl = new QStandardItem();
// QString url("http://www.google.com/search?client=qupzilla&q="+string);
// iconText->setIcon(QIcon(":/icons/menu/google.png"));
// iconText->setText(tr("Search %1 on Google.com\n..........").arg(string));
// findUrl->setText(url);
// QList<QStandardItem*> items;
// items.append(iconText);
// items.append(findUrl);
// cModel->insertRow(i, items);
// }
treeView->header()->setResizeMode(0, QHeaderView::Stretch); treeView->header()->setResizeMode(0, QHeaderView::Stretch);
treeView->header()->resizeSection(1, 0); treeView->header()->resizeSection(1, 0);

View File

@ -260,7 +260,7 @@ void SpeedDial::loadThumbnail(const QString &url, bool loadTitle)
PageThumbnailer* thumbnailer = new PageThumbnailer(this); PageThumbnailer* thumbnailer = new PageThumbnailer(this);
thumbnailer->setUrl(QUrl::fromEncoded(url.toUtf8())); thumbnailer->setUrl(QUrl::fromEncoded(url.toUtf8()));
thumbnailer->setLoadTitle(loadTitle); thumbnailer->setLoadTitle(loadTitle);
connect(thumbnailer, SIGNAL(thumbnailCreated(const QPixmap&)), this, SLOT(thumbnailCreated(const QPixmap&))); connect(thumbnailer, SIGNAL(thumbnailCreated(const QPixmap &)), this, SLOT(thumbnailCreated(const QPixmap &)));
thumbnailer->start(); thumbnailer->start();
} }

View File

@ -59,7 +59,7 @@ public:
void start(); void start();
signals: signals:
void thumbnailCreated(const QPixmap&); void thumbnailCreated(const QPixmap &);
public slots: public slots:

View File

@ -23,6 +23,4 @@ OTHER_FILES += appicon.rc \
os2:RC_FILE = appicon_os2.rc os2:RC_FILE = appicon_os2.rc
win32:RC_FILE = appicon.rc win32:RC_FILE = appicon.rc
unix:contains(DEFINES, "NO_SYSTEM_DATAPATH"): QMAKE_RPATHDIR += $$PWD/../../bin unix:contains(DEFINES, "NO_SYSTEM_DATAPATH"): QMAKE_LFLAGS+=$${QMAKE_LFLAGS_RPATH}\\$\$ORIGIN
message(========== Building qupzilla binary ==========)