diff options
author | Michal Klocek <michal.klocek@theqtcompany.com> | 2016-01-15 16:23:00 +0100 |
---|---|---|
committer | Michal Klocek <michal.klocek@theqtcompany.com> | 2016-01-15 15:37:02 +0000 |
commit | 3a28b83b6f7dabff75483c38bbc786c2ff7af321 (patch) | |
tree | 603f5ec9bbcf89d7d4082c76ac35afdfc262cda5 /src | |
parent | 1ad2e1b809b31ef21a34674590a2d55c49bd3468 (diff) |
Do not return negative values in WebEngineHistoryListModel
QSortFilterProxyModel does not like negative values
which were returned when adapter was not yet initialized.
Add missing guards for adapter.
Change-Id: I3d1dd5343aaf2c4d5504950005b05fb650835884
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/webengine/api/qquickwebenginehistory.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/webengine/api/qquickwebenginehistory.cpp b/src/webengine/api/qquickwebenginehistory.cpp index d790093a4..050833b28 100644 --- a/src/webengine/api/qquickwebenginehistory.cpp +++ b/src/webengine/api/qquickwebenginehistory.cpp @@ -54,7 +54,7 @@ QQuickWebEngineHistoryListModelPrivate::~QQuickWebEngineHistoryListModelPrivate( int QQuickWebEngineHistoryListModelPrivate::count() const { if (!adapter()) - return -1; + return 0; return adapter()->navigationEntryCount(); } @@ -65,6 +65,8 @@ int QQuickWebEngineHistoryListModelPrivate::index(int index) const int QQuickWebEngineHistoryListModelPrivate::offsetForIndex(int index) const { + if (!adapter()) + return index; return index - adapter()->currentNavigationEntryIndex(); } @@ -81,7 +83,7 @@ QQuickWebEngineBackHistoryListModelPrivate::QQuickWebEngineBackHistoryListModelP int QQuickWebEngineBackHistoryListModelPrivate::count() const { if (!adapter()) - return -1; + return 0; return adapter()->currentNavigationEntryIndex(); } @@ -104,12 +106,14 @@ QQuickWebEngineForwardHistoryListModelPrivate::QQuickWebEngineForwardHistoryList int QQuickWebEngineForwardHistoryListModelPrivate::count() const { if (!adapter()) - return -1; + return 0; return adapter()->navigationEntryCount() - adapter()->currentNavigationEntryIndex() - 1; } int QQuickWebEngineForwardHistoryListModelPrivate::index(int i) const { + if (!adapter()) + return i + 1; return adapter()->currentNavigationEntryIndex() + i + 1; } |