mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-24 04:36:34 +01:00
Code cleanups
This commit is contained in:
parent
556c6804ca
commit
98d51b0661
@ -243,6 +243,7 @@ QString DownloadFileHelper::getFileName(QNetworkReply* reply)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (path.isEmpty()) {
|
||||
path = reply->url().path();
|
||||
}
|
||||
|
@ -85,7 +85,6 @@ SOURCES += \
|
||||
rss/rsswidget.cpp \
|
||||
autofill/autofillnotification.cpp \
|
||||
rss/rssnotification.cpp \
|
||||
navigation/locationpopup.cpp \
|
||||
preferences/sslmanager.cpp \
|
||||
tools/animatedwidget.cpp \
|
||||
tools/htmlhighlighter.cpp \
|
||||
@ -226,7 +225,6 @@ HEADERS += \
|
||||
rss/rsswidget.h \
|
||||
autofill/autofillnotification.h \
|
||||
rss/rssnotification.h \
|
||||
navigation/locationpopup.h \
|
||||
preferences/sslmanager.h \
|
||||
tools/animatedwidget.h \
|
||||
tools/htmlhighlighter.h \
|
||||
|
@ -69,9 +69,6 @@ LocationBar::LocationBar(QupZilla* mainClass)
|
||||
m_locationCompleter = new LocationCompleter();
|
||||
setCompleter(m_locationCompleter);
|
||||
|
||||
// LocationPopup* com = new LocationPopup(this);
|
||||
// connect(down, SIGNAL(clicked(QPoint)), com, SLOT(show()));
|
||||
|
||||
connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEdit()));
|
||||
connect(this, SIGNAL(textEdited(QString)), m_locationCompleter, SLOT(refreshCompleter(QString)));
|
||||
connect(m_locationCompleter->popup(), SIGNAL(clicked(QModelIndex)), this, SLOT(urlEnter()));
|
||||
@ -135,7 +132,6 @@ void LocationBar::urlEnter()
|
||||
|
||||
void LocationBar::textEdit()
|
||||
{
|
||||
m_locationCompleter->popup()->setUpdatesEnabled(false);
|
||||
showGoButton();
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,12 @@
|
||||
LocationCompleter::LocationCompleter(QObject* parent)
|
||||
: QCompleter(parent)
|
||||
{
|
||||
QStandardItemModel* completeModel = new QStandardItemModel();
|
||||
setModel(completeModel);
|
||||
m_model = new QStandardItemModel();
|
||||
|
||||
m_listView = new CompleterListView();
|
||||
m_listView->setItemDelegateForColumn(0, new LocationCompleterDelegate(m_listView));
|
||||
|
||||
setModel(m_model);
|
||||
setPopup(m_listView);
|
||||
|
||||
setCompletionMode(QCompleter::PopupCompletion);
|
||||
@ -46,8 +47,7 @@ QStringList LocationCompleter::splitPath(const QString &path) const
|
||||
|
||||
void LocationCompleter::showMostVisited()
|
||||
{
|
||||
QStandardItemModel* cModel = qobject_cast<QStandardItemModel*>(model());
|
||||
cModel->clear();
|
||||
m_model->clear();
|
||||
|
||||
QSqlQuery query;
|
||||
query.exec("SELECT url, title FROM history ORDER BY count DESC LIMIT 15");
|
||||
@ -60,11 +60,9 @@ void LocationCompleter::showMostVisited()
|
||||
item->setText(url.toEncoded());
|
||||
item->setData(query.value(1), Qt::UserRole);
|
||||
|
||||
cModel->appendRow(item);
|
||||
m_model->appendRow(item);
|
||||
}
|
||||
|
||||
m_listView->setMinimumHeight(6 * m_listView->rowHeight());
|
||||
|
||||
QCompleter::complete();
|
||||
}
|
||||
|
||||
@ -74,8 +72,7 @@ void LocationCompleter::refreshCompleter(const QString &string)
|
||||
QString searchString = QString("%%1%").arg(string);
|
||||
QList<QUrl> urlList;
|
||||
|
||||
QStandardItemModel* cModel = qobject_cast<QStandardItemModel*>(model());
|
||||
cModel->clear();
|
||||
m_model->clear();
|
||||
|
||||
QSqlQuery query;
|
||||
query.prepare("SELECT url, title, icon FROM bookmarks WHERE title LIKE ? OR url LIKE ? LIMIT ?");
|
||||
@ -92,7 +89,7 @@ void LocationCompleter::refreshCompleter(const QString &string)
|
||||
item->setData(query.value(1), Qt::UserRole);
|
||||
item->setIcon(IconProvider::iconFromImage(QImage::fromData(query.value(2).toByteArray())));
|
||||
|
||||
cModel->appendRow(item);
|
||||
m_model->appendRow(item);
|
||||
urlList.append(url);
|
||||
}
|
||||
|
||||
@ -116,15 +113,6 @@ void LocationCompleter::refreshCompleter(const QString &string)
|
||||
item->setText(url.toEncoded());
|
||||
item->setData(query.value(1), Qt::UserRole);
|
||||
|
||||
cModel->appendRow(item);
|
||||
m_model->appendRow(item);
|
||||
}
|
||||
|
||||
if (cModel->rowCount() > 6) {
|
||||
m_listView->setMinimumHeight(6 * m_listView->rowHeight());
|
||||
}
|
||||
else {
|
||||
m_listView->setMinimumHeight(0);
|
||||
}
|
||||
|
||||
m_listView->setUpdatesEnabled(true);
|
||||
}
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include "qz_namespace.h"
|
||||
|
||||
class QStandardItemModel;
|
||||
|
||||
class CompleterListView;
|
||||
|
||||
class QT_QUPZILLA_EXPORT LocationCompleter : public QCompleter
|
||||
@ -40,6 +42,7 @@ public slots:
|
||||
|
||||
private:
|
||||
CompleterListView* m_listView;
|
||||
QStandardItemModel* m_model;
|
||||
};
|
||||
|
||||
#endif // LOCATIONCOMPLETER_H
|
||||
|
@ -29,6 +29,7 @@ CompleterListView::CompleterListView(QWidget* parent)
|
||||
, m_rowHeight(0)
|
||||
{
|
||||
setMouseTracking(true);
|
||||
setUniformItemSizes(true);
|
||||
}
|
||||
|
||||
bool CompleterListView::ignoreSelectedFlag() const
|
||||
|
@ -1,80 +0,0 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#include "locationpopup.h"
|
||||
|
||||
LocationPopup::LocationPopup(QWidget* parent)
|
||||
: QAbstractItemView()
|
||||
, m_parent(parent)
|
||||
{
|
||||
setWindowFlags(Qt::Popup);
|
||||
}
|
||||
|
||||
void LocationPopup::show()
|
||||
{
|
||||
QPoint p = m_parent->mapToGlobal(QPoint(0, 0));
|
||||
move((p.x()), (p.y() + m_parent->height()));
|
||||
resize(m_parent->width(), 100);
|
||||
QAbstractItemView::show();
|
||||
}
|
||||
|
||||
#if 0
|
||||
QRect LocationPopup::visualRect(const QModelIndex &index) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LocationPopup::scrollTo(const QModelIndex &index, ScrollHint hint)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QModelIndex LocationPopup::indexAt(const QPoint &point) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QModelIndex LocationPopup::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int LocationPopup::horizontalOffset() const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int LocationPopup::verticalOffset() const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool LocationPopup::isIndexHidden(const QModelIndex &index) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LocationPopup::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QRegion LocationPopup::visualRegionForSelection(const QItemSelection &selection) const
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
@ -1,50 +0,0 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#ifndef LOCATIONPOPUP_H
|
||||
#define LOCATIONPOPUP_H
|
||||
|
||||
#include <QAbstractItemView>
|
||||
|
||||
#include "qz_namespace.h"
|
||||
|
||||
class QT_QUPZILLA_EXPORT LocationPopup : public QAbstractItemView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LocationPopup(QWidget* parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void show();
|
||||
private:
|
||||
#if 0
|
||||
QRect visualRect(const QModelIndex &index) const;
|
||||
void scrollTo(const QModelIndex &index, ScrollHint hint);
|
||||
QModelIndex indexAt(const QPoint &point) const;
|
||||
QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
|
||||
int horizontalOffset() const;
|
||||
int verticalOffset() const;
|
||||
bool isIndexHidden(const QModelIndex &index) const;
|
||||
void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
|
||||
QRegion visualRegionForSelection(const QItemSelection &selection) const;
|
||||
#endif
|
||||
QWidget* m_parent;
|
||||
};
|
||||
|
||||
#endif // LOCATIONPOPUP_H
|
@ -180,7 +180,7 @@ QSize TabBar::tabSizeHint(int index) const
|
||||
QSize size = QTabBar::tabSizeHint(index);
|
||||
WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index));
|
||||
TabBar* tabBar = const_cast <TabBar*>(this);
|
||||
tabBar->m_adjustingLastTab = false;
|
||||
m_adjustingLastTab = false;
|
||||
|
||||
if (webTab && webTab->isPinned()) {
|
||||
size.setWidth(PINNED_TAB_WIDTH);
|
||||
@ -189,24 +189,24 @@ QSize TabBar::tabSizeHint(int index) const
|
||||
int availableWidth = width() - (PINNED_TAB_WIDTH * m_pinnedTabsCount) - m_tabWidget->buttonListTabs()->width() - m_tabWidget->buttonAddTab()->width();
|
||||
int normalTabsCount = count() - m_pinnedTabsCount;
|
||||
if (availableWidth >= MAXIMUM_TAB_WIDTH * normalTabsCount) {
|
||||
tabBar->m_normalTabWidth = MAXIMUM_TAB_WIDTH;
|
||||
m_normalTabWidth = MAXIMUM_TAB_WIDTH;
|
||||
size.setWidth(m_normalTabWidth);
|
||||
}
|
||||
else if (availableWidth < MINIMUM_TAB_WIDTH * normalTabsCount) {
|
||||
tabBar->m_normalTabWidth = MINIMUM_TAB_WIDTH;
|
||||
m_normalTabWidth = MINIMUM_TAB_WIDTH;
|
||||
size.setWidth(m_normalTabWidth);
|
||||
}
|
||||
else {
|
||||
int maxWidthForTab = availableWidth / normalTabsCount;
|
||||
tabBar->m_normalTabWidth = maxWidthForTab;
|
||||
m_normalTabWidth = maxWidthForTab;
|
||||
//Fill any empty space (we've got from rounding) with last tab
|
||||
if (index == count() - 1) {
|
||||
tabBar->m_lastTabWidth = (availableWidth - maxWidthForTab * normalTabsCount) + maxWidthForTab;
|
||||
tabBar->m_adjustingLastTab = true;
|
||||
m_lastTabWidth = (availableWidth - maxWidthForTab * normalTabsCount) + maxWidthForTab;
|
||||
m_adjustingLastTab = true;
|
||||
size.setWidth(m_lastTabWidth);
|
||||
}
|
||||
else {
|
||||
tabBar->m_lastTabWidth = maxWidthForTab;
|
||||
m_lastTabWidth = maxWidthForTab;
|
||||
size.setWidth(m_lastTabWidth);
|
||||
}
|
||||
}
|
||||
|
@ -103,9 +103,9 @@ private:
|
||||
int m_clickedTab;
|
||||
int m_pinnedTabsCount;
|
||||
|
||||
int m_normalTabWidth;
|
||||
int m_lastTabWidth;
|
||||
bool m_adjustingLastTab;
|
||||
mutable int m_normalTabWidth;
|
||||
mutable int m_lastTabWidth;
|
||||
mutable bool m_adjustingLastTab;
|
||||
|
||||
QPoint m_dragStartPosition;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user