diff -Nru webbrowser-app-0.23+16.04.20151130/debian/changelog webbrowser-app-0.23+16.04.20151204/debian/changelog --- webbrowser-app-0.23+16.04.20151130/debian/changelog 2015-12-04 17:45:31.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/debian/changelog 2015-12-04 17:45:31.000000000 +0000 @@ -1,13 +1,23 @@ -webbrowser-app (0.23+16.04.20151130-0ubuntu1) xenial; urgency=medium +webbrowser-app (0.23+16.04.20151204-0ubuntu1) xenial; urgency=medium [ CI Train Bot ] - * Rebuild against Qt 5.5.1. + * New rebuild forced. * Resync trunk. [ Olivier Tilloy ] + * Fix 3 autopilot test failures on desktop in narrow mode. (LP: + #1522344) + * Fix multiple keyboard focus/shortcut issues. (LP: #1522776, + #1522783, #1522757, #1522767) + * Replace custom models (HistoryDomainListChronologicalModel, + HistoryLastVisitDateModel and TopSitesModel) with simple, pure QML + SortFilterModel instances. Remove entirely HistoryTimeframeModel + which was not needed any longer. (LP: #1480947) + * Skip a test that requires HTTPS support in the test suite, which is + lacking for now. * Update translation template. - -- CI Train Bot Mon, 30 Nov 2015 14:50:57 +0000 + -- Olivier Tilloy Fri, 04 Dec 2015 11:06:50 +0000 webbrowser-app (0.23+16.04.20151126-0ubuntu1) xenial; urgency=medium diff -Nru webbrowser-app-0.23+16.04.20151130/po/pl.po webbrowser-app-0.23+16.04.20151204/po/pl.po --- webbrowser-app-0.23+16.04.20151130/po/pl.po 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/po/pl.po 2015-12-04 11:06:23.000000000 +0000 @@ -8,16 +8,16 @@ "Project-Id-Version: webbrowser-app\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2015-11-27 19:20+0100\n" -"PO-Revision-Date: 2015-11-07 09:38+0000\n" -"Last-Translator: Krzysztof Tataradziński \n" +"PO-Revision-Date: 2015-12-01 08:12+0000\n" +"Last-Translator: Piotr Strębski \n" "Language-Team: Polish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " "|| n%100>=20) ? 1 : 2;\n" -"X-Launchpad-Export-Date: 2015-11-28 04:58+0000\n" -"X-Generator: Launchpad (build 17850)\n" +"X-Launchpad-Export-Date: 2015-12-02 05:40+0000\n" +"X-Generator: Launchpad (build 17856)\n" #: src/app/AlertDialog.qml:23 msgid "JavaScript Alert" @@ -49,6 +49,7 @@ msgstr "Hasło" #: src/app/AuthenticationDialog.qml:53 src/app/ConfirmDialog.qml:31 +#: src/app/ContentDownloadDialog.qml:110 #: src/app/HttpAuthenticationDialog.qml:69 src/app/PromptDialog.qml:38 #: src/app/webbrowser/BookmarkOptions.qml:143 #: src/app/webbrowser/ContextMenuMobile.qml:139 @@ -105,11 +106,11 @@ msgid "" "Choose an application to open this file or add it to the downloads folder." msgstr "" -"Wybierz aplikację do otwarcia tego pliku albo umieścić go w folderze Pobrane." +"Wybierz program do otwarcia tego pliku albo umieścić go w katalogu Pobrane." #: src/app/ContentDownloadDialog.qml:84 msgid "Choose an application" -msgstr "Wybierz aplikację" +msgstr "Wybierz program" #: src/app/ContentDownloadDialog.qml:97 msgid "Download" @@ -477,9 +478,10 @@ #: src/app/actions/SaveLink.qml:22 msgid "Save link" -msgstr "Zapisz link" +msgstr "Zapisz odnośnik" -#: src/app/actions/SelectAll.qml:22 src/app/webbrowser/HistoryView.qml:173 +#: src/app/actions/SelectAll.qml:22 src/app/webbrowser/DownloadsPage.qml:83 +#: src/app/webbrowser/HistoryView.qml:173 #: src/app/webbrowser/HistoryViewWide.qml:409 msgid "Select all" msgstr "Zaznacz wszystko" @@ -612,10 +614,11 @@ msgid "Confirm selection" msgstr "Potwierdź zaznaczenie" +#: src/app/webbrowser/DownloadsPage.qml:99 #: src/app/webbrowser/HistoryView.qml:199 #: src/app/webbrowser/HistoryViewWide.qml:428 msgid "Delete" -msgstr "Kasuj" +msgstr "Usuń" #: src/app/webbrowser/DownloadsPage.qml:207 msgid "No downloads available" @@ -792,7 +795,7 @@ #: src/app/webbrowser/SettingsDeviceSelector.qml:43 msgid "Default" -msgstr "" +msgstr "Domyślny" #: src/app/webbrowser/SettingsPage.qml:80 #: src/app/webbrowser/SettingsPage.qml:175 @@ -924,7 +927,7 @@ #: src/app/webcontainer/AccountsSplashScreen.qml:77 msgid "Close the app" -msgstr "Zamknij aplikację" +msgstr "Zamknij program" #: src/app/webcontainer/AccountsSplashScreen.qml:77 msgid "Skip" diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/Browser.qml webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/Browser.qml --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/Browser.qml 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/Browser.qml 2015-12-04 11:06:46.000000000 +0000 @@ -572,7 +572,7 @@ Keys.onDownPressed: { if (suggestionsList.count) suggestionsList.focus = true else if (newTabViewLoader.status == Loader.Ready) { - newTabViewLoader.focus = true + newTabViewLoader.forceActiveFocus() } } @@ -753,6 +753,13 @@ Keys.onEscapePressed: bookmarksViewLoader.active = false + onActiveChanged: { + if (active) { + chrome.findInPageMode = false + forceActiveFocus() + } + } + Connections { target: bookmarksViewLoader.item @@ -806,7 +813,12 @@ Keys.onEscapePressed: historyViewLoader.active = false - onActiveChanged: if (active) chrome.findInPageMode = false + onActiveChanged: { + if (active) { + chrome.findInPageMode = false + forceActiveFocus() + } + } Component { id: historyViewComponent @@ -1365,7 +1377,7 @@ if (!incognito && closedTabHistory.length > 0) { var tabInfo = closedTabHistory.pop() var tab = session.createTabFromState(tabInfo.state) - internal.addTab(tab, true, tabInfo.index) + addTab(tab, true, tabInfo.index) } } @@ -1375,7 +1387,6 @@ } else { internal.switchToTab(tabsModel.count - 1, true) } - if (recentView.visible) recentView.focus = true } function switchToNextTab() { @@ -1384,7 +1395,6 @@ } else { internal.switchToTab(tabsModel.count - 1, true) } - if (recentView.visible) recentView.focus = true } function switchToTab(index, delayed) { @@ -1395,7 +1405,9 @@ tabsModel.currentIndex = index nextTabIndex = -1 var tab = tabsModel.currentTab - if (tab) { + if (recentView.visible) { + recentView.focus = true + } else if (tab) { if (!tab.url.toString() && !tab.initialUrl.toString() && (formFactor == "desktop")) { focusAddressBar() diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/CMakeLists.txt webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/CMakeLists.txt --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/CMakeLists.txt 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/CMakeLists.txt 2015-12-04 11:06:32.000000000 +0000 @@ -14,16 +14,12 @@ bookmarks-folder-model.cpp bookmarks-folderlist-model.cpp history-domain-model.cpp - history-domainlist-chronological-model.cpp history-domainlist-model.cpp - history-lastvisitdate-model.cpp history-lastvisitdatelist-model.cpp history-model.cpp - history-timeframe-model.cpp limit-proxy-model.cpp tabs-model.cpp text-search-filter-model.cpp - top-sites-model.cpp ) set(WEBBROWSER_APP_MODELS webbrowser-app-models) diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-domainlist-chronological-model.cpp webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-domainlist-chronological-model.cpp --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-domainlist-chronological-model.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-domainlist-chronological-model.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -/* - * Copyright 2013-2015 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app 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; version 3. - * - * webbrowser-app 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 . - */ - -#include "history-domainlist-chronological-model.h" -#include "history-domainlist-model.h" - -/*! - \class HistoryDomainListChronologicalModel - \brief Proxy model that sorts a domain list model in reverse chronological - order - - HistoryDomainListChronologicalModel is a proxy model that sorts a - HistoryDomainListModel in reverse chronological order - (i.e. the domain with the latest entry visited first). -*/ -HistoryDomainListChronologicalModel::HistoryDomainListChronologicalModel(QObject* parent) - : QSortFilterProxyModel(parent) -{ - setDynamicSortFilter(true); - setSortRole(HistoryDomainListModel::LastVisit); - sort(0, Qt::DescendingOrder); -} - -HistoryDomainListModel* HistoryDomainListChronologicalModel::sourceModel() const -{ - return qobject_cast(QSortFilterProxyModel::sourceModel()); -} - -void HistoryDomainListChronologicalModel::setSourceModel(HistoryDomainListModel* sourceModel) -{ - if (sourceModel != this->sourceModel()) { - QSortFilterProxyModel::setSourceModel(sourceModel); - Q_EMIT sourceModelChanged(); - } -} - -QString HistoryDomainListChronologicalModel::get(int index) const -{ - return data(this->index(index, 0), HistoryDomainListModel::Domain).toString(); -} diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-domainlist-chronological-model.h webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-domainlist-chronological-model.h --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-domainlist-chronological-model.h 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-domainlist-chronological-model.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* - * Copyright 2013-2015 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app 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; version 3. - * - * webbrowser-app 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 . - */ - -#ifndef __HISTORY_DOMAINLIST_CHRONOLOGICAL_MODEL_H__ -#define __HISTORY_DOMAINLIST_CHRONOLOGICAL_MODEL_H__ - -// Qt -#include -#include - -class HistoryDomainListModel; - -class HistoryDomainListChronologicalModel : public QSortFilterProxyModel -{ - Q_OBJECT - - Q_PROPERTY(HistoryDomainListModel* sourceModel READ sourceModel WRITE setSourceModel NOTIFY sourceModelChanged) - -public: - HistoryDomainListChronologicalModel(QObject* parent=0); - - HistoryDomainListModel* sourceModel() const; - void setSourceModel(HistoryDomainListModel* sourceModel); - - Q_INVOKABLE QString get(int index) const; - -Q_SIGNALS: - void sourceModelChanged() const; -}; - -#endif // __HISTORY_DOMAINLIST_CHRONOLOGICAL_MODEL_H__ diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-domainlist-model.cpp webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-domainlist-model.cpp --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-domainlist-model.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-domainlist-model.cpp 2015-12-04 11:06:32.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright 2013 Canonical Ltd. + * Copyright 2013-2015 Canonical Ltd. * * This file is part of webbrowser-app. * @@ -19,7 +19,6 @@ #include "history-domain-model.h" #include "history-domainlist-model.h" #include "history-model.h" -#include "history-timeframe-model.h" // Qt #include @@ -29,7 +28,7 @@ \brief List model that exposes history entries grouped by domain name HistoryDomainListModel is a list model that exposes history entries from a - HistoryTimeframeModel grouped by domain name. Each item in the list has + HistoryModel grouped by domain name. Each item in the list has three roles: 'domain' for the domain name, 'lastVisit' for the timestamp of the last page visited in this domain, and 'entries' for the corresponding HistoryDomainModel that contains all entries in this group. @@ -91,12 +90,12 @@ } } -HistoryTimeframeModel* HistoryDomainListModel::sourceModel() const +HistoryModel* HistoryDomainListModel::sourceModel() const { return m_sourceModel; } -void HistoryDomainListModel::setSourceModel(HistoryTimeframeModel* sourceModel) +void HistoryDomainListModel::setSourceModel(HistoryModel* sourceModel) { if (sourceModel != m_sourceModel) { beginResetModel(); diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-domainlist-model.h webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-domainlist-model.h --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-domainlist-model.h 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-domainlist-model.h 2015-12-04 11:06:32.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright 2013 Canonical Ltd. + * Copyright 2013-2015 Canonical Ltd. * * This file is part of webbrowser-app. * @@ -25,13 +25,13 @@ #include class HistoryDomainModel; -class HistoryTimeframeModel; +class HistoryModel; class HistoryDomainListModel : public QAbstractListModel { Q_OBJECT - Q_PROPERTY(HistoryTimeframeModel* sourceModel READ sourceModel WRITE setSourceModel NOTIFY sourceModelChanged) + Q_PROPERTY(HistoryModel* sourceModel READ sourceModel WRITE setSourceModel NOTIFY sourceModelChanged) Q_ENUMS(Roles) @@ -53,8 +53,8 @@ int rowCount(const QModelIndex& parent=QModelIndex()) const; QVariant data(const QModelIndex& index, int role) const; - HistoryTimeframeModel* sourceModel() const; - void setSourceModel(HistoryTimeframeModel* sourceModel); + HistoryModel* sourceModel() const; + void setSourceModel(HistoryModel* sourceModel); Q_SIGNALS: void sourceModelChanged() const; @@ -67,7 +67,7 @@ void onDomainDataChanged(); private: - HistoryTimeframeModel* m_sourceModel; + HistoryModel* m_sourceModel; QMap m_domains; void clearDomains(); diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-domain-model.cpp webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-domain-model.cpp --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-domain-model.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-domain-model.cpp 2015-12-04 11:06:32.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright 2013 Canonical Ltd. + * Copyright 2013-2015 Canonical Ltd. * * This file is part of webbrowser-app. * @@ -18,7 +18,6 @@ #include "history-domain-model.h" #include "history-model.h" -#include "history-timeframe-model.h" // Qt #include @@ -46,12 +45,12 @@ connect(this, SIGNAL(dataChanged(QModelIndex, QModelIndex, QVector)), SLOT(onModelChanged())); } -HistoryTimeframeModel* HistoryDomainModel::sourceModel() const +HistoryModel* HistoryDomainModel::sourceModel() const { - return qobject_cast(QSortFilterProxyModel::sourceModel()); + return qobject_cast(QSortFilterProxyModel::sourceModel()); } -void HistoryDomainModel::setSourceModel(HistoryTimeframeModel* sourceModel) +void HistoryDomainModel::setSourceModel(HistoryModel* sourceModel) { if (sourceModel != this->sourceModel()) { QSortFilterProxyModel::setSourceModel(sourceModel); diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-domain-model.h webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-domain-model.h --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-domain-model.h 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-domain-model.h 2015-12-04 11:06:32.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright 2013 Canonical Ltd. + * Copyright 2013-2015 Canonical Ltd. * * This file is part of webbrowser-app. * @@ -25,13 +25,13 @@ #include #include -class HistoryTimeframeModel; +class HistoryModel; class HistoryDomainModel : public QSortFilterProxyModel { Q_OBJECT - Q_PROPERTY(HistoryTimeframeModel* sourceModel READ sourceModel WRITE setSourceModel NOTIFY sourceModelChanged) + Q_PROPERTY(HistoryModel* sourceModel READ sourceModel WRITE setSourceModel NOTIFY sourceModelChanged) Q_PROPERTY(QString domain READ domain WRITE setDomain NOTIFY domainChanged) Q_PROPERTY(QDateTime lastVisit READ lastVisit NOTIFY lastVisitChanged) Q_PROPERTY(QString lastVisitedTitle READ lastVisitedTitle NOTIFY lastVisitedTitleChanged) @@ -40,8 +40,8 @@ public: HistoryDomainModel(QObject* parent=0); - HistoryTimeframeModel* sourceModel() const; - void setSourceModel(HistoryTimeframeModel* sourceModel); + HistoryModel* sourceModel() const; + void setSourceModel(HistoryModel* sourceModel); const QString& domain() const; void setDomain(const QString& domain); diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-lastvisitdatelist-model.cpp webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-lastvisitdatelist-model.cpp --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-lastvisitdatelist-model.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-lastvisitdatelist-model.cpp 2015-12-04 11:06:32.000000000 +0000 @@ -18,7 +18,6 @@ #include "history-lastvisitdatelist-model.h" #include "history-model.h" -#include "history-timeframe-model.h" // Qt #include @@ -28,10 +27,10 @@ \class HistoryLastVisitDateListModel \brief List model that exposes a list of all last visit dates from history - HistoryLastVisitiDateListModel is a list model that exposes all last visit + HistoryLastVisitDateListModel is a list model that exposes all last visit dates from the source model. Each item has one single role: 'lastVisitDate' for a date in which there is at least one url visited on the source model. - A special entry is added to the begining of the list to represent all dates. + A special entry is added to the beginning of the list to represent all dates. The source model needs to expose a role named 'lastVisitDate', from which the input dates will be read. If such role is not present, this model will @@ -86,9 +85,9 @@ void HistoryLastVisitDateListModel::setSourceModel(QVariant sourceModel) { QAbstractItemModel* newSourceModel = qvariant_cast(sourceModel); - if (sourceModel.isValid() && newSourceModel == 0) { - qWarning() << "Only QAbstractItemModel-derived instances are allowed as" - << "source models"; + if (sourceModel.isValid() && (newSourceModel == 0) && !sourceModel.canConvert()) { + qWarning() << "Only QAbstractItemModel-derived instances and null are" + << "allowed as source models"; } if (newSourceModel != m_sourceModel) { @@ -107,6 +106,9 @@ SLOT(onRowsInserted(const QModelIndex&, int, int))); connect(m_sourceModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), SLOT(onRowsRemoved(const QModelIndex&, int, int))); + connect(m_sourceModel, + SIGNAL(rowsMoved(const QModelIndex&, int, int, const QModelIndex&, int)), + SLOT(onRowsMoved(const QModelIndex&, int, int, const QModelIndex&, int))); connect(m_sourceModel, SIGNAL(modelReset()), SLOT(onModelReset())); connect(m_sourceModel, SIGNAL(layoutChanged(QList, QAbstractItemModel::LayoutChangeHint)), SLOT(onModelReset())); @@ -160,6 +162,7 @@ int removeAt = m_orderedDates.indexOf(lastVisitDate.key()); beginRemoveRows(QModelIndex(), removeAt, removeAt); m_orderedDates.removeAt(removeAt); + delete lastVisitDate.value(); lastVisitDate = m_lastVisitDates.erase(lastVisitDate); endRemoveRows(); } else { @@ -175,6 +178,41 @@ } } +void HistoryLastVisitDateListModel::onRowsMoved(const QModelIndex& parent, int start, int end, const QModelIndex& destination, int row) +{ + Q_UNUSED(parent); + Q_UNUSED(destination); + + // Rows were moved in the source model, meaning that their last visit dates + // were potentially updated, so we remove all the dates corresponding to + // the rows before they were moved, and we add all the dates corresponding + // to the rows after they were moved. + + // Determine a lower and upper bound for the dates that should be removed + // by looking at the indexes surrounding the rows before they were moved. + QDate lower = m_sourceModel->data(m_sourceModel->index((row < start) ? end + 1 : start, 0), m_sourceModelRole).toDate(); + if (!lower.isValid()) { + // The last row was moved too, we don’t have a strict lower bound. + lower = m_orderedDates.last().addDays(-1); + } + QDate upper = m_sourceModel->data(m_sourceModel->index((row < start) ? end : start - 1, 0), m_sourceModelRole).toDate(); + for (QDate i = upper.addDays(-1); i > lower; i = i.addDays(-1)) { + if (m_orderedDates.contains(i)) { + int removeAt = m_orderedDates.indexOf(i); + beginRemoveRows(QModelIndex(), removeAt, removeAt); + m_orderedDates.removeAt(removeAt); + delete m_lastVisitDates.take(i); + endRemoveRows(); + } + } + + // Now add back dates for all the rows after they were moved. + for (int i = 0; i <= (end - start); ++i) { + int index = i + row + ((row < start) ? 0 : start - end); + insertNewHistoryEntry(new QPersistentModelIndex(m_sourceModel->index(index, 0)), true); + } +} + void HistoryLastVisitDateListModel::updateSourceModelRole() { if (m_sourceModel && m_sourceModel->roleNames().count() > 0) { @@ -198,7 +236,7 @@ void HistoryLastVisitDateListModel::insertNewHistoryEntry(QPersistentModelIndex* index, bool notify) { if (m_sourceModelRole == -1) { - return; + return; } QDate lastVisitDate = index->data(m_sourceModelRole).toDate(); diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-lastvisitdatelist-model.h webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-lastvisitdatelist-model.h --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-lastvisitdatelist-model.h 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-lastvisitdatelist-model.h 2015-12-04 11:06:32.000000000 +0000 @@ -55,6 +55,7 @@ private Q_SLOTS: void onRowsInserted(const QModelIndex& parent, int start, int end); void onRowsRemoved(const QModelIndex& parent, int start, int end); + void onRowsMoved(const QModelIndex& parent, int start, int end, const QModelIndex& destination, int row); void onModelReset(); private: diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-lastvisitdate-model.cpp webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-lastvisitdate-model.cpp --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-lastvisitdate-model.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-lastvisitdate-model.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,141 +0,0 @@ -/* - * Copyright 2015 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app 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; version 3. - * - * webbrowser-app 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 . - */ - -#include "history-lastvisitdate-model.h" -#include "history-model.h" -#include "history-timeframe-model.h" - -// Qt -#include -#include - -/*! - \class HistoryLastVisitDateModel - \brief Proxy model that filters the contents of a model based on last - visit date - - HistoryLastVisitDateModel is a proxy model that filters the contents - of any QAbstractItemModel-derived model based on a role called - "lastVisitDate". - - An entry in the history model matches if the last visit date equals - the filter visit date. - - When no visit date is set, all entries match. If the model does not have - the "lastVisitDate" role, then no entries are returned if a filter visit - date is set, otherwise all entries match. -*/ -HistoryLastVisitDateModel::HistoryLastVisitDateModel(QObject* parent) - : QSortFilterProxyModel(parent) -{ -} - -QVariant HistoryLastVisitDateModel::sourceModel() const -{ - QAbstractItemModel* model = QSortFilterProxyModel::sourceModel(); - return (model) ? QVariant::fromValue(model) : QVariant(); -} - -void HistoryLastVisitDateModel::setSourceModel(QVariant sourceModel) -{ - QAbstractItemModel* newSourceModel = qvariant_cast(sourceModel); - if (sourceModel.isValid() && newSourceModel == 0) { - qWarning() << "Only QAbstractItemModel-derived instances are allowed as" - << "source models"; - } - - if (newSourceModel != QSortFilterProxyModel::sourceModel()) { - beginResetModel(); - - QAbstractItemModel* currentModel = QSortFilterProxyModel::sourceModel(); - if (currentModel != 0) { - currentModel->disconnect(this); - } - QSortFilterProxyModel::setSourceModel(newSourceModel); - updateSourceModelRole(); - - if (newSourceModel != 0) { - connect(newSourceModel, SIGNAL(modelReset()), SLOT(updateSourceModelRole())); - connect(newSourceModel, SIGNAL(layoutChanged(QList, QAbstractItemModel::LayoutChangeHint)), - SLOT(updateSourceModelRole())); - } - - endResetModel(); - Q_EMIT sourceModelChanged(); - } -} - -const QDate& HistoryLastVisitDateModel::lastVisitDate() const -{ - return m_lastVisitDate; -} - -void HistoryLastVisitDateModel::setLastVisitDate(const QDate& lastVisitDate) -{ - if (lastVisitDate != m_lastVisitDate) { - m_lastVisitDate = lastVisitDate; - invalidate(); - Q_EMIT lastVisitDateChanged(); - } -} - -QVariantMap HistoryLastVisitDateModel::get(int i) const -{ - QVariantMap item; - QHash roles = roleNames(); - - QModelIndex modelIndex = index(i, 0); - if (modelIndex.isValid()) { - Q_FOREACH(int role, roles.keys()) { - QString roleName = QString::fromUtf8(roles.value(role)); - item.insert(roleName, data(modelIndex, role)); - } - } - return item; -} - -bool HistoryLastVisitDateModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const -{ - if (m_lastVisitDate.isNull()) { - return true; - } - - if (m_sourceModelRole == -1) { - return false; - } - - QAbstractItemModel* model = QSortFilterProxyModel::sourceModel(); - if (model) { - QModelIndex index = model->index(source_row, 0, source_parent); - return m_lastVisitDate == model->data(index, m_sourceModelRole).toDate(); - } else { - return false; - } -} - -void HistoryLastVisitDateModel::updateSourceModelRole() -{ - QAbstractItemModel* sourceModel = QSortFilterProxyModel::sourceModel(); - if (sourceModel && sourceModel->roleNames().count() > 0) { - m_sourceModelRole = sourceModel->roleNames().key("lastVisitDate", -1); - if (m_sourceModelRole == -1) { - qWarning() << "No results will be returned because the sourceModel" - << "does not have a role named \"lastVisitDate\""; - } - } -} diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-lastvisitdate-model.h webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-lastvisitdate-model.h --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-lastvisitdate-model.h 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-lastvisitdate-model.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright 2015 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app 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; version 3. - * - * webbrowser-app 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 . - */ - -#ifndef __HISTORY_LASTVISITDATE_MODEL_H__ -#define __HISTORY_LASTVISITDATE_MODEL_H__ - -// Qt -#include -#include -#include -#include -#include - -class HistoryLastVisitDateModel : public QSortFilterProxyModel -{ - Q_OBJECT - - Q_PROPERTY(QVariant sourceModel READ sourceModel WRITE setSourceModel NOTIFY sourceModelChanged) - Q_PROPERTY(QDate lastVisitDate READ lastVisitDate WRITE setLastVisitDate NOTIFY lastVisitDateChanged) - -public: - HistoryLastVisitDateModel(QObject* parent=0); - - QVariant sourceModel() const; - void setSourceModel(QVariant sourceModel); - - const QDate& lastVisitDate() const; - Q_INVOKABLE void setLastVisitDate(const QDate& lastVisitDate); - - Q_INVOKABLE QVariantMap get(int index) const; - -Q_SIGNALS: - void sourceModelChanged() const; - void lastVisitDateChanged() const; - -protected: - // reimplemented from QSortFilterProxyModel - bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const; - -private Q_SLOTS: - void updateSourceModelRole(); - -private: - QDate m_lastVisitDate; - int m_sourceModelRole; -}; - -#endif // __HISTORY_LASTVISITDATE_MODEL_H__ diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-model.cpp webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-model.cpp --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-model.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-model.cpp 2015-12-04 11:06:32.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright 2013 Canonical Ltd. + * Copyright 2013-2015 Canonical Ltd. * * This file is part of webbrowser-app. * @@ -150,6 +150,7 @@ roles[Visits] = "visits"; roles[LastVisit] = "lastVisit"; roles[LastVisitDate] = "lastVisitDate"; + roles[LastVisitDateString] = "lastVisitDateString"; roles[Hidden] = "hidden"; } return roles; @@ -182,6 +183,8 @@ return entry.lastVisit; case LastVisitDate: return entry.lastVisit.toLocalTime().date(); + case LastVisitDateString: + return entry.lastVisit.toLocalTime().date().toString(Qt::ISODate); case Hidden: return entry.hidden; default: @@ -261,6 +264,10 @@ } count = ++entry.visits; if (now != entry.lastVisit) { + if (now.date() != entry.lastVisit.date()) { + roles << LastVisitDate; + roles << LastVisitDateString; + } entry.lastVisit = now; roles << LastVisit; } @@ -279,6 +286,7 @@ if (now != entry.lastVisit) { if (now.date() != entry.lastVisit.date()) { roles << LastVisitDate; + roles << LastVisitDateString; } entry.lastVisit = now; roles << LastVisit; diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-model.h webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-model.h --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-model.h 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-model.h 2015-12-04 11:06:32.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright 2013 Canonical Ltd. + * Copyright 2013-2015 Canonical Ltd. * * This file is part of webbrowser-app. * @@ -49,6 +49,7 @@ Visits, LastVisit, LastVisitDate, + LastVisitDateString, Hidden, }; diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-timeframe-model.cpp webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-timeframe-model.cpp --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-timeframe-model.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-timeframe-model.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app 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; version 3. - * - * webbrowser-app 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 . - */ - -#include "history-timeframe-model.h" -#include "history-model.h" - -/*! - \class HistoryTimeframeModel - \brief Proxy model that filters the contents of the history model - excluding all entries that are not contained in a given timeframe - - HistoryTimeframeModel is a proxy model that filters the contents of a - HistoryModel, excluding all entries that are not contained in a given - timeframe specified by a start datetime and an end datetime. - - To leave one side of the timeframe open, do not set either the start or end - datetime (or reset them to an invalid datetime). -*/ -HistoryTimeframeModel::HistoryTimeframeModel(QObject* parent) - : QSortFilterProxyModel(parent) -{ -} - -HistoryModel* HistoryTimeframeModel::sourceModel() const -{ - return qobject_cast(QSortFilterProxyModel::sourceModel()); -} - -void HistoryTimeframeModel::setSourceModel(HistoryModel* sourceModel) -{ - if (sourceModel != this->sourceModel()) { - beginResetModel(); - QSortFilterProxyModel::setSourceModel(sourceModel); - endResetModel(); - Q_EMIT sourceModelChanged(); - } -} - -const QDateTime& HistoryTimeframeModel::start() const -{ - return m_start; -} - -void HistoryTimeframeModel::setStart(const QDateTime& start) -{ - if (start != m_start) { - m_start = start; - invalidate(); - Q_EMIT startChanged(); - } -} - -const QDateTime& HistoryTimeframeModel::end() const -{ - return m_end; -} - -void HistoryTimeframeModel::setEnd(const QDateTime& end) -{ - if (end != m_end) { - m_end = end; - invalidate(); - Q_EMIT endChanged(); - } -} - -bool HistoryTimeframeModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const -{ - QModelIndex index = sourceModel()->index(source_row, 0, source_parent); - QDateTime lastVisit = sourceModel()->data(index, HistoryModel::LastVisit).toDateTime(); - if (m_start.isValid() && (lastVisit < m_start)) { - return false; - } - if (m_end.isValid() && (lastVisit > m_end)) { - return false; - } - return true; -} - -QHash HistoryTimeframeModel::roleNames() const -{ - return (sourceModel()) ? sourceModel()->roleNames() : QHash(); -} diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-timeframe-model.h webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-timeframe-model.h --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/history-timeframe-model.h 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/history-timeframe-model.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app 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; version 3. - * - * webbrowser-app 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 . - */ - -#ifndef __HISTORY_TIMEFRAME_MODEL_H__ -#define __HISTORY_TIMEFRAME_MODEL_H__ - -// Qt -#include -#include - -class HistoryModel; - -class HistoryTimeframeModel : public QSortFilterProxyModel -{ - Q_OBJECT - - Q_PROPERTY(HistoryModel* sourceModel READ sourceModel WRITE setSourceModel NOTIFY sourceModelChanged) - Q_PROPERTY(QDateTime start READ start WRITE setStart NOTIFY startChanged) - Q_PROPERTY(QDateTime end READ end WRITE setEnd NOTIFY endChanged) - -public: - HistoryTimeframeModel(QObject* parent=0); - - HistoryModel* sourceModel() const; - void setSourceModel(HistoryModel* sourceModel); - - const QDateTime& start() const; - void setStart(const QDateTime& start); - - const QDateTime& end() const; - void setEnd(const QDateTime& end); - -Q_SIGNALS: - void sourceModelChanged() const; - void startChanged() const; - void endChanged() const; - -protected: - // reimplemented from QSortFilterProxyModel - bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const; - QHash roleNames() const; - -private: - QDateTime m_start; - QDateTime m_end; -}; - -#endif // __HISTORY_TIMEFRAME_MODEL_H__ diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/HistoryView.qml webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/HistoryView.qml --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/HistoryView.qml 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/HistoryView.qml 2015-12-04 11:06:32.000000000 +0000 @@ -37,7 +37,7 @@ // the view is displayed as early as possible. id: loadModelTimer interval: 1 - onTriggered: historyTimeframeModel.sourceModel = HistoryModel + onTriggered: historyDomainListModel.sourceModel = HistoryModel } function loadModel() { loadModelTimer.restart() } @@ -53,12 +53,12 @@ rightMargin: units.gu(2) } - model: HistoryDomainListChronologicalModel { - sourceModel: HistoryDomainListModel { - sourceModel: HistoryTimeframeModel { - id: historyTimeframeModel - } + model: SortFilterModel { + model: HistoryDomainListModel { + id: historyDomainListModel } + sort.property: "lastVisit" + sort.order: Qt.DescendingOrder } section.property: "lastVisitDate" diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/HistoryViewWide.qml webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/HistoryViewWide.qml --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/HistoryViewWide.qml 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/HistoryViewWide.qml 2015-12-04 11:06:46.000000000 +0000 @@ -45,10 +45,8 @@ Keys.onPressed: { if (event.modifiers === Qt.ControlModifier && event.key === Qt.Key_F) { if (searchMode) searchQuery.focus = true - else { - if (!selectMode) searchMode = true - else event.accepted = true - } + else if (!selectMode) searchMode = true + event.accepted = true } } Keys.onDeletePressed: { @@ -123,7 +121,7 @@ currentIndex: 0 onCurrentIndexChanged: { if (currentItem) { - historyLastVisitDateModel.setLastVisitDate(currentItem.lastVisitDate) + historyLastVisitDateModel.lastVisitDate = currentItem.lastVisitDate } urlsListView.ViewItems.selectedIndices = [] } @@ -163,7 +161,7 @@ } model: HistoryLastVisitDateListModel { - sourceModel: historyLastVisitDateModel.sourceModel + sourceModel: historyLastVisitDateModel.model } delegate: ListItem { @@ -244,13 +242,18 @@ Keys.onReturnPressed: historyEntrySelected() Keys.onEnterPressed: historyEntrySelected() - model: HistoryLastVisitDateModel { + model: SortFilterModel { id: historyLastVisitDateModel + property date lastVisitDate + filter { + property: "lastVisitDateString" + pattern: new RegExp(lastVisitDate.isValid() ? "^%1$".arg(Qt.formatDate(lastVisitDate, "yyyy-MM-dd")) : "") + } // Until a valid HistoryModel is assigned the TextSearchFilterModel - // will not report role names, and the HistoryLastVisit*Models will emit warnings - // since they need a dateLastVisit role to be present. - // We avoid this by delaying assigning the source model until it is ready. - sourceModel: historySearchModel.sourceModel ? historySearchModel : undefined + // will not report role names, and the HistoryLastVisitDateListModel + // will emit warnings since it needs a dateLastVisit role to be + // present. + model: historySearchModel.sourceModel ? historySearchModel : null } clip: true diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/limit-proxy-model.h webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/limit-proxy-model.h --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/limit-proxy-model.h 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/limit-proxy-model.h 2015-12-04 11:06:32.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright 2014 Canonical Ltd. + * Copyright 2014-2015 Canonical Ltd. * * This file is part of webbrowser-app. * diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/NewTabView.qml webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/NewTabView.qml --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/NewTabView.qml 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/NewTabView.qml 2015-12-04 11:06:32.000000000 +0000 @@ -20,7 +20,6 @@ import Qt.labs.settings 1.0 import Ubuntu.Components 1.3 import webbrowserapp.private 0.1 -import ".." import "." Item { @@ -34,10 +33,7 @@ TopSitesModel { id: topSitesModel - sourceModel: HistoryTimeframeModel { - id: historyTimeframeModel - sourceModel: HistoryModel - } + model: HistoryModel } QtObject { diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/NewTabViewWide.qml webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/NewTabViewWide.qml --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/NewTabViewWide.qml 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/NewTabViewWide.qml 2015-12-04 11:06:32.000000000 +0000 @@ -17,10 +17,8 @@ */ import QtQuick 2.4 -import Qt.labs.settings 1.0 import Ubuntu.Components 1.3 import webbrowserapp.private 0.1 -import ".." import "." FocusScope { @@ -51,10 +49,7 @@ id: topSitesModel limit: 10 sourceModel: TopSitesModel { - sourceModel: HistoryTimeframeModel { - id: historyTimeframeModel - sourceModel: HistoryModel - } + model: HistoryModel } } diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/PreviewManager.qml webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/PreviewManager.qml --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/PreviewManager.qml 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/PreviewManager.qml 2015-12-04 11:06:32.000000000 +0000 @@ -30,9 +30,7 @@ id: topSites limit: 10 sourceModel: TopSitesModel { - sourceModel: HistoryTimeframeModel { - sourceModel: HistoryModel - } + model: HistoryModel } function contains(url) { for (var i = 0; i < topSites.count; i++) { diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/tabs-model.cpp webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/tabs-model.cpp --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/tabs-model.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/tabs-model.cpp 2015-12-04 11:06:37.000000000 +0000 @@ -148,7 +148,9 @@ m_currentIndex = 0; Q_EMIT currentIndexChanged(); Q_EMIT currentTabChanged(); - } else if (index <= m_currentIndex) { + } else if (index == m_currentIndex) { + Q_EMIT currentTabChanged(); + } else if (index < m_currentIndex) { // Increment the index if we are inserting items before the current index. m_currentIndex++; Q_EMIT currentIndexChanged(); diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/top-sites-model.cpp webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/top-sites-model.cpp --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/top-sites-model.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/top-sites-model.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -/* - * Copyright 2015 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app 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; version 3. - * - * webbrowser-app 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 . - */ - -#include "history-model.h" -#include "history-timeframe-model.h" -#include "top-sites-model.h" - -/*! - \class TopSitesModel - \brief Proxy model that filters a history model based on hidden role and sorts it by number of visits - - TopSitesModel is a proxy model that filters a HistoryTimeframeModel - based on the hidden rule and sorts it by the number of visits - (i.e. the history with the greatest number of visits first ignoring entries marked as removed by user). -*/ -TopSitesModel::TopSitesModel(QObject* parent) - : QSortFilterProxyModel(parent) -{ - setDynamicSortFilter(true); - setSortRole(HistoryModel::Visits); - sort(0, Qt::DescendingOrder); - connect(this, SIGNAL(rowsInserted(const QModelIndex&, int, int)), SIGNAL(countChanged())); - connect(this, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), SIGNAL(countChanged())); - connect(this, SIGNAL(modelReset()), SIGNAL(countChanged())); -} - -HistoryTimeframeModel* TopSitesModel::sourceModel() const -{ - return qobject_cast(QSortFilterProxyModel::sourceModel()); -} - -void TopSitesModel::setSourceModel(HistoryTimeframeModel* sourceModel) -{ - if (sourceModel != this->sourceModel()) { - QSortFilterProxyModel::setSourceModel(sourceModel); - Q_EMIT sourceModelChanged(); - Q_EMIT countChanged(); - } -} - -bool TopSitesModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const -{ - QModelIndex index = sourceModel()->index(source_row, 0, source_parent); - return !sourceModel()->data(index, HistoryModel::Hidden).toBool(); -} diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/top-sites-model.h webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/top-sites-model.h --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/top-sites-model.h 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/top-sites-model.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright 2015 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app 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; version 3. - * - * webbrowser-app 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 . - */ - -#ifndef __TOP_SITES_MODEL_H__ -#define __TOP_SITES_MODEL_H__ - -// Qt -#include - -class HistoryTimeframeModel; - -class TopSitesModel : public QSortFilterProxyModel -{ - Q_OBJECT - - Q_PROPERTY(HistoryTimeframeModel* sourceModel READ sourceModel WRITE setSourceModel NOTIFY sourceModelChanged) - Q_PROPERTY(int count READ rowCount NOTIFY countChanged) - -public: - TopSitesModel(QObject* parent=0); - - HistoryTimeframeModel* sourceModel() const; - void setSourceModel(HistoryTimeframeModel* sourceModel); - -Q_SIGNALS: - void sourceModelChanged() const; - void countChanged() const; - -protected: - // reimplemented from QSortFilterProxyModel - bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const; -}; - -#endif // __TOP_SITES_MODEL_H__ diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/TopSitesModel.qml webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/TopSitesModel.qml --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/TopSitesModel.qml 1970-01-01 00:00:00.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/TopSitesModel.qml 2015-12-04 11:06:32.000000000 +0000 @@ -0,0 +1,31 @@ +/* + * Copyright 2015 Canonical Ltd. + * + * This file is part of webbrowser-app. + * + * webbrowser-app 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; version 3. + * + * webbrowser-app 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 . + */ + +import QtQuick 2.4 +import Ubuntu.Components 1.3 + +SortFilterModel { + sort { + order: Qt.DescendingOrder + property: "visits" + } + filter { + pattern: /^false$/ + property: "hidden" + } +} diff -Nru webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/webbrowser-app.cpp webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/webbrowser-app.cpp --- webbrowser-app-0.23+16.04.20151130/src/app/webbrowser/webbrowser-app.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/src/app/webbrowser/webbrowser-app.cpp 2015-12-04 11:06:32.000000000 +0000 @@ -21,17 +21,13 @@ #include "cache-deleter.h" #include "config.h" #include "file-operations.h" -#include "history-domainlist-chronological-model.h" #include "history-domainlist-model.h" #include "history-lastvisitdatelist-model.h" -#include "history-lastvisitdate-model.h" #include "history-model.h" -#include "history-timeframe-model.h" #include "limit-proxy-model.h" #include "searchengine.h" #include "text-search-filter-model.h" #include "tabs-model.h" -#include "top-sites-model.h" #include "webbrowser-app.h" // Qt @@ -82,12 +78,8 @@ { const char* uri = "webbrowserapp.private"; qmlRegisterSingletonType(uri, 0, 1, "HistoryModel", HistoryModel_singleton_factory); - qmlRegisterType(uri, 0, 1, "HistoryTimeframeModel"); - qmlRegisterType(uri, 0 , 1, "TopSitesModel"); qmlRegisterType(uri, 0, 1, "HistoryDomainListModel"); - qmlRegisterType(uri, 0, 1, "HistoryDomainListChronologicalModel"); qmlRegisterType(uri, 0, 1, "HistoryLastVisitDateListModel"); - qmlRegisterType(uri, 0, 1, "HistoryLastVisitDateModel"); qmlRegisterType(uri, 0 , 1, "LimitProxyModel"); qmlRegisterType(uri, 0, 1, "TabsModel"); qmlRegisterSingletonType(uri, 0, 1, "BookmarksModel", BookmarksModel_singleton_factory); diff -Nru webbrowser-app-0.23+16.04.20151130/tests/autopilot/webbrowser_app/emulators/browser.py webbrowser-app-0.23+16.04.20151204/tests/autopilot/webbrowser_app/emulators/browser.py --- webbrowser-app-0.23+16.04.20151130/tests/autopilot/webbrowser_app/emulators/browser.py 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/autopilot/webbrowser_app/emulators/browser.py 2015-12-04 11:06:46.000000000 +0000 @@ -523,6 +523,9 @@ return sorted(self.select_many("UrlDelegate"), key=lambda item: item.globalRect.y) + def get_search_field(self): + return self.select_single(objectName="searchQuery") + class ExpandedHistoryView(uitk.UbuntuUIToolkitCustomProxyObjectBase): diff -Nru webbrowser-app-0.23+16.04.20151130/tests/autopilot/webbrowser_app/tests/test_keyboard.py webbrowser-app-0.23+16.04.20151204/tests/autopilot/webbrowser_app/tests/test_keyboard.py --- webbrowser-app-0.23+16.04.20151130/tests/autopilot/webbrowser_app/tests/test_keyboard.py 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/autopilot/webbrowser_app/tests/test_keyboard.py 2015-12-04 11:06:46.000000000 +0000 @@ -345,6 +345,61 @@ new_tab_view = self.main_window.get_new_tab_view() self.assertThat(new_tab_view.visible, Eventually(Equals(True))) + def test_search_in_history(self): + if not self.main_window.wide: + self.skipTest("Only on wide form factors") + + self.assertThat(self.main_window.get_history_view(), Equals(None)) + self.main_window.press_key('Ctrl+h') + self.assertThat(lambda: self.main_window.get_history_view(), + Eventually(NotEquals(None))) + history_view = self.main_window.get_history_view() + + self.main_window.press_key('Ctrl+f') + self.assertThat(history_view.searchMode, Eventually(Equals(True))) + search_field = history_view.get_search_field() + self.assertThat(search_field.visible, Equals(True)) + self.assertThat(search_field.activeFocus, Eventually(Equals(True))) + + self.main_window.press_key('Escape') + self.assertThat(history_view.searchMode, Eventually(Equals(False))) + self.assertThat(search_field.visible, Equals(False)) + + self.main_window.press_key('Escape') + history_view.wait_until_destroyed() + + def test_open_history_exits_findinpage(self): + address_bar = self.main_window.chrome.address_bar + self.main_window.press_key('Ctrl+f') + self.assertThat(address_bar.findInPageMode, Eventually(Equals(True))) + self.assertThat(address_bar.activeFocus, Eventually(Equals(True))) + + self.main_window.press_key('Ctrl+h') + self.assertThat(lambda: self.main_window.get_history_view(), + Eventually(NotEquals(None))) + history_view = self.main_window.get_history_view() + self.assertThat(address_bar.findInPageMode, Eventually(Equals(False))) + self.assertThat(address_bar.activeFocus, Eventually(Equals(False))) + + self.main_window.press_key('Escape') + history_view.wait_until_destroyed() + + def test_open_bookmarks_exits_findinpage(self): + address_bar = self.main_window.chrome.address_bar + self.main_window.press_key('Ctrl+f') + self.assertThat(address_bar.findInPageMode, Eventually(Equals(True))) + self.assertThat(address_bar.activeFocus, Eventually(Equals(True))) + + self.main_window.press_key('Ctrl+Shift+o') + self.assertThat(lambda: self.main_window.get_bookmarks_view(), + Eventually(NotEquals(None))) + bookmarks_view = self.main_window.get_bookmarks_view() + self.assertThat(address_bar.findInPageMode, Eventually(Equals(False))) + self.assertThat(address_bar.activeFocus, Eventually(Equals(False))) + + self.main_window.press_key('Escape') + bookmarks_view.wait_until_destroyed() + def test_escape_settings(self): settings = self.open_settings() self.main_window.press_key('Escape') @@ -364,3 +419,21 @@ self.open_new_tab() self.main_window.press_key('Ctrl+f') self.assertThat(address_bar.findInPageMode, Equals(False)) + + def test_navigate_between_address_bar_and_new_tab_view(self): + if not self.main_window.wide: + self.skipTest("Only on wide form factors") + + address_bar = self.main_window.chrome.address_bar + + self.main_window.press_key('Ctrl+t') + new_tab_view = self.main_window.get_new_tab_view() + self.assertThat(address_bar.activeFocus, Eventually(Equals(True))) + + self.main_window.press_key('Down') + self.assertThat(address_bar.activeFocus, Eventually(Equals(False))) + self.assertThat(new_tab_view.activeFocus, Eventually(Equals(True))) + + self.main_window.press_key('Up') + self.assertThat(new_tab_view.activeFocus, Eventually(Equals(False))) + self.assertThat(address_bar.activeFocus, Eventually(Equals(True))) diff -Nru webbrowser-app-0.23+16.04.20151130/tests/autopilot/webbrowser_app/tests/test_media_access_permission.py webbrowser-app-0.23+16.04.20151204/tests/autopilot/webbrowser_app/tests/test_media_access_permission.py --- webbrowser-app-0.23+16.04.20151130/tests/autopilot/webbrowser_app/tests/test_media_access_permission.py 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/autopilot/webbrowser_app/tests/test_media_access_permission.py 2015-12-04 11:06:41.000000000 +0000 @@ -63,6 +63,8 @@ self.main_window.go_to_url(url) self.main_window.wait_until_page_loaded(self.allowed_url) + @testtools.skip("Skipping due to the lack of HTTPS support in the " + "test suite, see https://launchpad.net/bugs/1505995") def test_deny(self): # verify that trying to access any media raises an authorization dialog # and we get redirected to the denial page in case we refuse to give diff -Nru webbrowser-app-0.23+16.04.20151130/tests/autopilot/webbrowser_app/tests/test_tabs.py webbrowser-app-0.23+16.04.20151204/tests/autopilot/webbrowser_app/tests/test_tabs.py --- webbrowser-app-0.23+16.04.20151130/tests/autopilot/webbrowser_app/tests/test_tabs.py 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/autopilot/webbrowser_app/tests/test_tabs.py 2015-12-04 11:06:37.000000000 +0000 @@ -282,10 +282,9 @@ @testtools.skipIf(model() != "Desktop", "on desktop only") def test_undo_close_tab(self): - tabs = self.main_window.chrome.get_tabs_bar() url0 = self.main_window.get_current_webview().url - self.open_new_tab() + self.open_new_tab(open_tabs_view=not self.main_window.wide) url1 = self.base_url + "/tab/1" self.main_window.go_to_url(url1) self.main_window.wait_until_page_loaded(url1) @@ -293,19 +292,19 @@ # Insert a "new tab view" page in the middle, without any page loaded # so that we can verify that it will not be restored - self.open_new_tab() + self.open_new_tab(open_tabs_view=not self.main_window.wide) - self.open_new_tab() + self.open_new_tab(open_tabs_view=not self.main_window.wide) url2 = self.base_url + "/tab/2" self.main_window.go_to_url(url2) self.main_window.wait_until_page_loaded(url2) self.assert_number_webviews_eventually(4) - tabs.close_tab(3) + self.main_window.press_key('Ctrl+w') self.assert_number_webviews_eventually(3) - tabs.close_tab(2) + self.main_window.press_key('Ctrl+w') self.assert_number_webviews_eventually(2) - tabs.close_tab(1) + self.main_window.press_key('Ctrl+w') self.assert_number_webviews_eventually(1) self.check_current_tab(url0) @@ -325,7 +324,7 @@ @testtools.skipIf(model() != "Desktop", "on desktop only") def test_undo_close_tab_incognito(self): start_url = self.main_window.get_current_webview().url - self.open_new_tab() + self.open_new_tab(open_tabs_view=not self.main_window.wide) url = self.base_url + "/tab/1" self.main_window.go_to_url(url) self.main_window.wait_until_page_loaded(url) @@ -341,7 +340,7 @@ self.main_window.go_to_url(incognito_url) self.main_window.wait_until_page_loaded(incognito_url) - self.open_new_tab() + self.open_new_tab(open_tabs_view=not self.main_window.wide) self.main_window.go_to_url(incognito_url) self.main_window.wait_until_page_loaded(incognito_url) self.main_window.press_key('Ctrl+w') diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/CMakeLists.txt webbrowser-app-0.23+16.04.20151204/tests/unittests/CMakeLists.txt --- webbrowser-app-0.23+16.04.20151130/tests/unittests/CMakeLists.txt 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/CMakeLists.txt 2015-12-04 11:06:32.000000000 +0000 @@ -2,13 +2,9 @@ add_subdirectory(qml) add_subdirectory(domain-utils) add_subdirectory(history-model) -add_subdirectory(history-timeframe-model) add_subdirectory(history-domain-model) add_subdirectory(history-domainlist-model) -add_subdirectory(history-domainlist-chronological-model) -add_subdirectory(history-lastvisitdate-model) add_subdirectory(history-lastvisitdatelist-model) -add_subdirectory(top-sites-model) add_subdirectory(session-utils) add_subdirectory(tabs-model) add_subdirectory(bookmarks-model) diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/history-domainlist-chronological-model/CMakeLists.txt webbrowser-app-0.23+16.04.20151204/tests/unittests/history-domainlist-chronological-model/CMakeLists.txt --- webbrowser-app-0.23+16.04.20151130/tests/unittests/history-domainlist-chronological-model/CMakeLists.txt 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/history-domainlist-chronological-model/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -find_package(Qt5Core REQUIRED) -find_package(Qt5Sql REQUIRED) -find_package(Qt5Test REQUIRED) -set(TEST tst_HistoryDomainListChronologicalModelTests) -add_executable(${TEST} tst_HistoryDomainListChronologicalModelTests.cpp) -include_directories(${webbrowser-app_SOURCE_DIR}) -target_link_libraries(${TEST} - Qt5::Core - Qt5::Sql - Qt5::Test - webbrowser-app-models -) -add_test(${TEST} ${CMAKE_CURRENT_BINARY_DIR}/${TEST} -xunitxml -o ${TEST}.xml) diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/history-domainlist-chronological-model/tst_HistoryDomainListChronologicalModelTests.cpp webbrowser-app-0.23+16.04.20151204/tests/unittests/history-domainlist-chronological-model/tst_HistoryDomainListChronologicalModelTests.cpp --- webbrowser-app-0.23+16.04.20151130/tests/unittests/history-domainlist-chronological-model/tst_HistoryDomainListChronologicalModelTests.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/history-domainlist-chronological-model/tst_HistoryDomainListChronologicalModelTests.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app 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; version 3. - * - * webbrowser-app 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 . - */ - -// Qt -#include -#include - -// local -#include "domain-utils.h" -#include "history-model.h" -#include "history-domain-model.h" -#include "history-domainlist-model.h" -#include "history-domainlist-chronological-model.h" -#include "history-timeframe-model.h" - -class HistoryDomainListChronologicalModelTests : public QObject -{ - Q_OBJECT - -private: - HistoryModel* history; - HistoryTimeframeModel* timeframe; - HistoryDomainListModel* domainlist; - HistoryDomainListChronologicalModel* model; - -private Q_SLOTS: - void init() - { - history = new HistoryModel; - history->setDatabasePath(":memory:"); - timeframe = new HistoryTimeframeModel; - timeframe->setSourceModel(history); - domainlist = new HistoryDomainListModel; - domainlist->setSourceModel(timeframe); - model = new HistoryDomainListChronologicalModel; - model->setSourceModel(domainlist); - } - - void cleanup() - { - delete model; - delete domainlist; - delete timeframe; - delete history; - } - - void shouldBeInitiallyEmpty() - { - QCOMPARE(model->rowCount(), 0); - } - - void shouldNotifyWhenChangingSourceModel() - { - QSignalSpy spy(model, SIGNAL(sourceModelChanged())); - model->setSourceModel(domainlist); - QVERIFY(spy.isEmpty()); - HistoryDomainListModel* domainlist2 = new HistoryDomainListModel; - model->setSourceModel(domainlist2); - QCOMPARE(spy.count(), 1); - QCOMPARE(model->sourceModel(), domainlist2); - model->setSourceModel(0); - QCOMPARE(spy.count(), 2); - QCOMPARE(model->sourceModel(), (HistoryDomainListModel*) 0); - delete domainlist2; - } - - void shouldRemainSorted() - { - history->add(QUrl("http://example.org/"), "Example Domain", QUrl()); - QTest::qWait(1001); - history->add(QUrl("http://ubuntu.com/"), "Ubuntu", QUrl()); - QCOMPARE(model->data(model->index(0, 0), HistoryDomainListModel::Domain).toString(), QString("ubuntu.com")); - QCOMPARE(model->data(model->index(1, 0), HistoryDomainListModel::Domain).toString(), QString("example.org")); - } - - void shouldRemoveDomain() { - history->add(QUrl("http://example.org/"), "Example Domain", QUrl()); - QTest::qWait(1001); - history->add(QUrl("http://ubuntu.com/"), "Ubuntu", QUrl()); - QSignalSpy spy(model, SIGNAL(rowsRemoved(const QModelIndex&, int, int))); - history->removeEntriesByDomain("ubuntu.com"); - QCOMPARE(spy.count(), 1); - QList args = spy.takeFirst(); - QCOMPARE(args.at(1).toInt(), 0); - QCOMPARE(args.at(2).toInt(), 0); - } - - void shouldReturnDomain() { - history->add(QUrl("http://example.org/"), "Example Domain", QUrl()); - QCOMPARE(model->get(0), QString("example.org")); - } -}; - -QTEST_MAIN(HistoryDomainListChronologicalModelTests) -#include "tst_HistoryDomainListChronologicalModelTests.moc" diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/history-domainlist-model/tst_HistoryDomainListModelTests.cpp webbrowser-app-0.23+16.04.20151204/tests/unittests/history-domainlist-model/tst_HistoryDomainListModelTests.cpp --- webbrowser-app-0.23+16.04.20151130/tests/unittests/history-domainlist-model/tst_HistoryDomainListModelTests.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/history-domainlist-model/tst_HistoryDomainListModelTests.cpp 2015-12-04 11:06:32.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright 2013 Canonical Ltd. + * Copyright 2013-2015 Canonical Ltd. * * This file is part of webbrowser-app. * @@ -25,7 +25,6 @@ #include "history-model.h" #include "history-domain-model.h" #include "history-domainlist-model.h" -#include "history-timeframe-model.h" class HistoryDomainListModelTests : public QObject { @@ -33,7 +32,6 @@ private: HistoryModel* history; - HistoryTimeframeModel* timeframe; HistoryDomainListModel* model; void verifyDataChanged(QSignalSpy& spy, int row) @@ -54,16 +52,13 @@ { history = new HistoryModel; history->setDatabasePath(":memory:"); - timeframe = new HistoryTimeframeModel; - timeframe->setSourceModel(history); model = new HistoryDomainListModel; - model->setSourceModel(timeframe); + model->setSourceModel(history); } void cleanup() { delete model; - delete timeframe; delete history; } @@ -108,20 +103,12 @@ void shouldUpdateDomainListWhenRemovingEntries() { history->add(QUrl("http://example.org/"), "Example Domain", QUrl()); - QTest::qWait(100); - QDateTime t0 = QDateTime::currentDateTimeUtc(); - QTest::qWait(100); history->add(QUrl("http://example.com/"), "Example Domain", QUrl()); - QTest::qWait(100); - QDateTime t1 = QDateTime::currentDateTimeUtc(); - QTest::qWait(100); history->add(QUrl("http://example.org/test"), "Example Domain", QUrl()); QCOMPARE(model->rowCount(), 2); - - timeframe->setEnd(t1); + history->removeEntryByUrl(QUrl("http://example.org/test")); QCOMPARE(model->rowCount(), 2); - - timeframe->setStart(t0); + history->removeEntryByUrl(QUrl("http://example.org/")); QCOMPARE(model->rowCount(), 1); } @@ -168,21 +155,20 @@ history->add(QUrl("http://ubuntu.com/"), "Ubuntu", QUrl()); QCOMPARE(model->rowCount(), 3); - model->setSourceModel(timeframe); + model->setSourceModel(history); QVERIFY(spy.isEmpty()); QCOMPARE(model->rowCount(), 3); - model->setSourceModel(0); + model->setSourceModel(nullptr); QCOMPARE(spy.count(), 1); - QCOMPARE(model->sourceModel(), (HistoryTimeframeModel*) 0); + QCOMPARE(model->sourceModel(), (HistoryModel*) nullptr); QCOMPARE(model->rowCount(), 0); - HistoryTimeframeModel* timeframe2 = new HistoryTimeframeModel(history); - timeframe2->setSourceModel(history); - model->setSourceModel(timeframe2); + HistoryModel history2; + model->setSourceModel(&history2); QCOMPARE(spy.count(), 2); - QCOMPARE(model->sourceModel(), timeframe2); - QCOMPARE(model->rowCount(), 3); + QCOMPARE(model->sourceModel(), &history2); + QCOMPARE(model->rowCount(), 0); } void shouldKeepDomainsSorted() diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/history-domain-model/tst_HistoryDomainModelTests.cpp webbrowser-app-0.23+16.04.20151204/tests/unittests/history-domain-model/tst_HistoryDomainModelTests.cpp --- webbrowser-app-0.23+16.04.20151130/tests/unittests/history-domain-model/tst_HistoryDomainModelTests.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/history-domain-model/tst_HistoryDomainModelTests.cpp 2015-12-04 11:06:32.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright 2013 Canonical Ltd. + * Copyright 2013-2015 Canonical Ltd. * * This file is part of webbrowser-app. * @@ -23,8 +23,6 @@ // local #include "history-model.h" #include "history-domain-model.h" -#include "history-timeframe-model.h" - class HistoryDomainModelTests : public QObject { @@ -32,7 +30,6 @@ private: HistoryModel* history; - HistoryTimeframeModel* timeframe; HistoryDomainModel* model; private Q_SLOTS: @@ -40,16 +37,13 @@ { history = new HistoryModel; history->setDatabasePath(":memory:"); - timeframe = new HistoryTimeframeModel; - timeframe->setSourceModel(history); model = new HistoryDomainModel; - model->setSourceModel(timeframe); + model->setSourceModel(history); } void cleanup() { delete model; - delete timeframe; delete history; } @@ -61,15 +55,15 @@ void shouldNotifyWhenChangingSourceModel() { QSignalSpy spy(model, SIGNAL(sourceModelChanged())); - model->setSourceModel(timeframe); + model->setSourceModel(history); QVERIFY(spy.isEmpty()); - HistoryTimeframeModel* timeframe2 = new HistoryTimeframeModel(model); - model->setSourceModel(timeframe2); + HistoryModel history2; + model->setSourceModel(&history2); QCOMPARE(spy.count(), 1); - QCOMPARE(model->sourceModel(), timeframe2); - model->setSourceModel(0); + QCOMPARE(model->sourceModel(), &history2); + model->setSourceModel(nullptr); QCOMPARE(spy.count(), 2); - QCOMPARE(model->sourceModel(), (HistoryTimeframeModel*) 0); + QCOMPARE(model->sourceModel(), (HistoryModel*) nullptr); } void shouldNotifyWhenChangingDomain() diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/history-lastvisitdatelist-model/tst_HistoryLastVisitDateListModelTests.cpp webbrowser-app-0.23+16.04.20151204/tests/unittests/history-lastvisitdatelist-model/tst_HistoryLastVisitDateListModelTests.cpp --- webbrowser-app-0.23+16.04.20151130/tests/unittests/history-lastvisitdatelist-model/tst_HistoryLastVisitDateListModelTests.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/history-lastvisitdatelist-model/tst_HistoryLastVisitDateListModelTests.cpp 2015-12-04 11:06:32.000000000 +0000 @@ -25,7 +25,6 @@ #include "domain-utils.h" #include "history-lastvisitdatelist-model.h" #include "history-model.h" -#include "history-timeframe-model.h" class MockHistoryModel : public HistoryModel { @@ -145,7 +144,6 @@ private: MockHistoryModel* mockHistory; - HistoryTimeframeModel* timeframe; HistoryLastVisitDateListModel* model; BookmarksModel* bookmarks; @@ -154,10 +152,8 @@ { mockHistory = new MockHistoryModel; mockHistory->setDatabasePath(":memory:"); - timeframe = new HistoryTimeframeModel; - timeframe->setSourceModel(mockHistory); model = new HistoryLastVisitDateListModel; - model->setSourceModel(QVariant::fromValue(timeframe)); + model->setSourceModel(QVariant::fromValue(mockHistory)); bookmarks = new BookmarksModel; bookmarks->setDatabasePath(":memory:"); } @@ -165,7 +161,6 @@ void cleanup() { delete model; - delete timeframe; delete mockHistory; delete bookmarks; } @@ -175,7 +170,7 @@ QCOMPARE(model->rowCount(), 0); } - void shouldUpdateLastVsitDateListWhenInsertingEntries() + void shouldUpdateLastVisitDateListWhenInsertingEntries() { QSignalSpy spyRowsInserted(model, SIGNAL(rowsInserted(const QModelIndex&, int, int))); qRegisterMetaType >(); @@ -224,26 +219,6 @@ QCOMPARE(model->rowCount(), 0); } - void shouldUpdateLastVisitDateListWhenChangingTimeFrame() - { - QDateTime dt1 = QDateTime(QDate(1970, 1, 1), QTime(6, 0, 0)); - QDateTime dt2 = QDateTime(QDate(1970, 1, 2), QTime(6, 0, 0)); - QDateTime dt3 = QDateTime(QDate(1970, 1, 3), QTime(6, 0, 0)); - - mockHistory->add(QUrl("http://example.com/"), "Example Domain", "example.com", QUrl(), dt1); - mockHistory->add(QUrl("http://example.org/"), "Example Domain", "example.org", QUrl(), dt2); - mockHistory->add(QUrl("http://example.net/"), "Example Domain", "example.net", QUrl(), dt3); - QDateTime t0 = QDateTime(QDate(1970, 1, 1), QTime(7, 0, 0)); - QDateTime t1 = QDateTime(QDate(1970, 1, 2), QTime(7, 0, 0)); - QCOMPARE(model->rowCount(), 4); - - timeframe->setEnd(t1); - QCOMPARE(model->rowCount(), 3); - - timeframe->setStart(t0); - QCOMPARE(model->rowCount(), 2); - } - void shouldUpdateLastVisitDateListWhenRemovingEntries() { QSignalSpy spyRowsRemoved(model, SIGNAL(rowsRemoved(const QModelIndex&, int, int))); @@ -313,24 +288,23 @@ mockHistory->add(QUrl("http://example.net/"), "Example Domain", "example.net", QUrl(), dt3); QCOMPARE(model->rowCount(), 4); - model->setSourceModel(QVariant::fromValue(timeframe)); + model->setSourceModel(QVariant::fromValue(mockHistory)); QVERIFY(spy.isEmpty()); QCOMPARE(model->rowCount(), 4); - QTest::ignoreMessage(QtWarningMsg, "Only QAbstractItemModel-derived instances are allowed as source models"); + QTest::ignoreMessage(QtWarningMsg, "Only QAbstractItemModel-derived instances and null are allowed as source models"); model->setSourceModel(0); QCOMPARE(spy.count(), 1); QVERIFY(!model->sourceModel().isValid()); QCOMPARE(model->rowCount(), 0); - HistoryTimeframeModel timeframe2(mockHistory); - timeframe2.setSourceModel(mockHistory); - model->setSourceModel(QVariant::fromValue(&timeframe2)); + MockHistoryModel mockHistory2; + model->setSourceModel(QVariant::fromValue(&mockHistory2)); QCOMPARE(spy.count(), 2); - QCOMPARE(model->sourceModel(), QVariant::fromValue(&timeframe2)); - QCOMPARE(model->rowCount(), 4); + QCOMPARE(model->sourceModel().value(), &mockHistory2); + QCOMPARE(model->rowCount(), 0); - QTest::ignoreMessage(QtWarningMsg, "Only QAbstractItemModel-derived instances are allowed as source models"); + QTest::ignoreMessage(QtWarningMsg, "Only QAbstractItemModel-derived instances and null are allowed as source models"); model->setSourceModel(QVariant::fromValue(QString("not a model"))); QCOMPARE(spy.count(), 3); QVERIFY(!model->sourceModel().isValid()); @@ -340,6 +314,11 @@ bookmarks->add(QUrl("http://example.org/"), "Example Domain", QUrl(), ""); model->setSourceModel(QVariant::fromValue(bookmarks)); QCOMPARE(model->rowCount(), 0); + + spy.clear(); + model->setSourceModel(QVariant()); + QCOMPARE(spy.count(), 1); + QVERIFY(model->sourceModel().isNull()); } void shouldKeepLastVisitDatesSorted() diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/history-lastvisitdate-model/CMakeLists.txt webbrowser-app-0.23+16.04.20151204/tests/unittests/history-lastvisitdate-model/CMakeLists.txt --- webbrowser-app-0.23+16.04.20151130/tests/unittests/history-lastvisitdate-model/CMakeLists.txt 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/history-lastvisitdate-model/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -find_package(Qt5Sql REQUIRED) -find_package(Qt5Test REQUIRED) -set(TEST tst_HistoryLastVisitDateModelTests) -add_executable(${TEST} tst_HistoryLastVisitDateModelTests.cpp) -include_directories(${webbrowser-app_SOURCE_DIR}) -target_link_libraries(${TEST} - webbrowser-app-models - Qt5::Sql - Qt5::Test -) -add_test(${TEST} ${CMAKE_CURRENT_BINARY_DIR}/${TEST} -xunitxml -o ${TEST}.xml) diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/history-lastvisitdate-model/tst_HistoryLastVisitDateModelTests.cpp webbrowser-app-0.23+16.04.20151204/tests/unittests/history-lastvisitdate-model/tst_HistoryLastVisitDateModelTests.cpp --- webbrowser-app-0.23+16.04.20151130/tests/unittests/history-lastvisitdate-model/tst_HistoryLastVisitDateModelTests.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/history-lastvisitdate-model/tst_HistoryLastVisitDateModelTests.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,138 +0,0 @@ -/* - * Copyright 2015 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app 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; version 3. - * - * webbrowser-app 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 . - */ - -// Qt -#include -#include - -// local -#include "bookmarks-model.h" -#include "history-lastvisitdate-model.h" -#include "history-model.h" -#include "history-timeframe-model.h" - - -class HistoryLastVisitDateModelTests : public QObject -{ - Q_OBJECT - -private: - HistoryModel* history; - HistoryTimeframeModel* timeframe; - HistoryLastVisitDateModel* model; - -private Q_SLOTS: - void init() - { - history = new HistoryModel; - history->setDatabasePath(":memory:"); - timeframe = new HistoryTimeframeModel; - timeframe->setSourceModel(history); - model = new HistoryLastVisitDateModel; - model->setSourceModel(QVariant::fromValue(timeframe)); - } - - void cleanup() - { - delete model; - delete timeframe; - delete history; - } - - void shouldBeInitiallyEmpty() - { - QCOMPARE(model->rowCount(), 0); - } - - void shouldNotifyWhenChangingSourceModel() - { - QSignalSpy spy(model, SIGNAL(sourceModelChanged())); - model->setSourceModel(QVariant::fromValue(timeframe)); - QVERIFY(spy.isEmpty()); - - HistoryTimeframeModel* timeframe2 = new HistoryTimeframeModel(model); - model->setSourceModel(QVariant::fromValue(timeframe2)); - QCOMPARE(spy.count(), 1); - QCOMPARE(model->sourceModel(), QVariant::fromValue(timeframe2)); - - model->setSourceModel(QVariant()); - QCOMPARE(spy.count(), 2); - QVERIFY(!model->sourceModel().isValid()); - - QTest::ignoreMessage(QtWarningMsg, "Only QAbstractItemModel-derived instances are allowed as source models"); - model->setSourceModel(QVariant::fromValue(QString("not a model"))); - QVERIFY(!model->sourceModel().isValid()); - QCOMPARE(model->rowCount(), 0); - QCOMPARE(spy.count(), 2); // model is still invalid internally so no signal emitted - - QTest::ignoreMessage(QtWarningMsg, "No results will be returned because the sourceModel does not have a role named \"lastVisitDate\""); - BookmarksModel bookmarks; - bookmarks.setDatabasePath(":memory:"); - bookmarks.add(QUrl("http://example.org/"), "Example Domain", QUrl(), ""); - model->setSourceModel(QVariant::fromValue(&bookmarks)); - QCOMPARE(spy.count(), 3); - // with no filter, all entries match even if the model doesn't have the lastVisitDate role - QCOMPARE(model->rowCount(), 1); - model->setLastVisitDate(QDate::currentDate()); - QCOMPARE(model->rowCount(), 0); - - delete timeframe2; - } - - void shouldNotifyWhenChangingLastVisitDate() - { - QSignalSpy spy(model, SIGNAL(lastVisitDateChanged())); - model->setLastVisitDate(QDate()); - QVERIFY(spy.isEmpty()); - model->setLastVisitDate(QDate::currentDate()); - QCOMPARE(spy.count(), 1); - } - - void shouldMatchAllWhenNoLastVisitDateSet() - { - history->add(QUrl("http://example.org"), "Example Domain", QUrl()); - history->add(QUrl("http://example.com"), "Example Domain", QUrl()); - QCOMPARE(model->rowCount(), 2); - } - - void shouldFilterOutNonMatchingLastVisitDate() - { - history->add(QUrl("http://example.org/"), "Example Domain", QUrl()); - QTest::qWait(1001); - history->add(QUrl("http://example.com/"), "Example Domain", QUrl()); - model->setLastVisitDate(QDate::currentDate()); - QCOMPARE(model->rowCount(), 2); - model->setLastVisitDate(QDate(1970, 1, 1)); - QCOMPARE(model->rowCount(), 0); - } - - void shouldReturnDataByIndex() - { - history->add(QUrl("http://example.org"), "Example Domain", QUrl()); - QTest::qWait(1001); - history->add(QUrl("http://example.com"), "Example Domain", QUrl()); - QCOMPARE(model->rowCount(), 2); - QVariantMap entry = model->get(2); - QVERIFY(entry.isEmpty()); - entry = model->get(1); - QCOMPARE(entry.value("url").toUrl(), QUrl("http://example.org")); - } -}; - -QTEST_MAIN(HistoryLastVisitDateModelTests) -#include "tst_HistoryLastVisitDateModelTests.moc" diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/history-model/tst_HistoryModelTests.cpp webbrowser-app-0.23+16.04.20151204/tests/unittests/history-model/tst_HistoryModelTests.cpp --- webbrowser-app-0.23+16.04.20151130/tests/unittests/history-model/tst_HistoryModelTests.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/history-model/tst_HistoryModelTests.cpp 2015-12-04 11:06:32.000000000 +0000 @@ -184,7 +184,7 @@ QCOMPARE(model->data(model->index(0, 0), HistoryModel::Icon).toUrl(), QUrl("image://webicon/123")); QCOMPARE(model->data(model->index(0, 0), HistoryModel::Visits).toInt(), 1); QVERIFY(model->data(model->index(0, 0), HistoryModel::LastVisit).toDateTime() >= now); - QVERIFY(!model->data(model->index(0, 0), HistoryModel::LastVisit + 3).isValid()); + QVERIFY(!model->data(model->index(0, 0), HistoryModel::LastVisit + 4).isValid()); } void shouldReturnDatabasePath() diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/history-timeframe-model/CMakeLists.txt webbrowser-app-0.23+16.04.20151204/tests/unittests/history-timeframe-model/CMakeLists.txt --- webbrowser-app-0.23+16.04.20151130/tests/unittests/history-timeframe-model/CMakeLists.txt 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/history-timeframe-model/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -find_package(Qt5Core REQUIRED) -find_package(Qt5Sql REQUIRED) -find_package(Qt5Test REQUIRED) -set(TEST tst_HistoryTimeframeModelTests) -add_executable(${TEST} tst_HistoryTimeframeModelTests.cpp) -include_directories(${webbrowser-app_SOURCE_DIR}) -target_link_libraries(${TEST} - Qt5::Core - Qt5::Sql - Qt5::Test - webbrowser-app-models -) -add_test(${TEST} ${CMAKE_CURRENT_BINARY_DIR}/${TEST}) diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/history-timeframe-model/tst_HistoryTimeframeModelTests.cpp webbrowser-app-0.23+16.04.20151204/tests/unittests/history-timeframe-model/tst_HistoryTimeframeModelTests.cpp --- webbrowser-app-0.23+16.04.20151130/tests/unittests/history-timeframe-model/tst_HistoryTimeframeModelTests.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/history-timeframe-model/tst_HistoryTimeframeModelTests.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app 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; version 3. - * - * webbrowser-app 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 . - */ - -// Qt -#include -#include - -// local -#include "history-model.h" -#include "history-timeframe-model.h" - - -class HistoryTimeframeModelTests : public QObject -{ - Q_OBJECT - -private: - HistoryModel* model; - HistoryTimeframeModel* timeframe; - -private Q_SLOTS: - void init() - { - model = new HistoryModel; - model->setDatabasePath(":memory:"); - timeframe = new HistoryTimeframeModel; - timeframe->setSourceModel(model); - } - - void cleanup() - { - delete timeframe; - delete model; - } - - void shouldBeInitiallyEmpty() - { - QCOMPARE(timeframe->rowCount(), 0); - } - - void shouldNotifyWhenChangingSourceModel() - { - QSignalSpy spy(timeframe, SIGNAL(sourceModelChanged())); - timeframe->setSourceModel(model); - QVERIFY(spy.isEmpty()); - HistoryModel* model2 = new HistoryModel; - timeframe->setSourceModel(model2); - QCOMPARE(spy.count(), 1); - QCOMPARE(timeframe->sourceModel(), model2); - timeframe->setSourceModel(0); - QCOMPARE(spy.count(), 2); - QCOMPARE(timeframe->sourceModel(), (HistoryModel*) 0); - delete model2; - } - - void shouldNotifyWhenChangingStart() - { - QSignalSpy spy(timeframe, SIGNAL(startChanged())); - QDateTime start = QDateTime::currentDateTimeUtc(); - timeframe->setStart(start); - QCOMPARE(timeframe->start(), start); - QCOMPARE(spy.count(), 1); - timeframe->setStart(start); - QCOMPARE(spy.count(), 1); - QTest::qWait(100); - timeframe->setStart(QDateTime::currentDateTimeUtc()); - QCOMPARE(spy.count(), 2); - timeframe->setStart(QDateTime()); - QCOMPARE(spy.count(), 3); - } - - void shouldNotifyWhenChangingEnd() - { - QSignalSpy spy(timeframe, SIGNAL(endChanged())); - QDateTime end = QDateTime::currentDateTimeUtc(); - timeframe->setEnd(end); - QCOMPARE(timeframe->end(), end); - QCOMPARE(spy.count(), 1); - timeframe->setEnd(end); - QCOMPARE(spy.count(), 1); - QTest::qWait(100); - timeframe->setEnd(QDateTime::currentDateTimeUtc()); - QCOMPARE(spy.count(), 2); - timeframe->setEnd(QDateTime()); - QCOMPARE(spy.count(), 3); - } - - void shouldMatchAllWhenNoBoundsSet() - { - model->add(QUrl("http://example.org"), "Example Domain", QUrl()); - QTest::qWait(100); - model->add(QUrl("http://example.com"), "Example Domain", QUrl()); - QCOMPARE(timeframe->rowCount(), 2); - } - - void shouldFilterOutOlderEntries() - { - model->add(QUrl("http://example.org"), "Example Domain", QUrl()); - QTest::qWait(100); - QDateTime start = QDateTime::currentDateTimeUtc(); - QTest::qWait(100); - model->add(QUrl("http://example.com"), "Example Domain", QUrl()); - QCOMPARE(timeframe->rowCount(), 2); - timeframe->setStart(start); - QCOMPARE(timeframe->rowCount(), 1); - QCOMPARE(timeframe->data(timeframe->index(0, 0), HistoryModel::Url).toUrl(), - QUrl("http://example.com")); - } - - void shouldFilterOutMoreRecentEntries() - { - model->add(QUrl("http://example.org"), "Example Domain", QUrl()); - QTest::qWait(100); - QDateTime end = QDateTime::currentDateTimeUtc(); - QTest::qWait(100); - model->add(QUrl("http://example.com"), "Example Domain", QUrl()); - QCOMPARE(timeframe->rowCount(), 2); - timeframe->setEnd(end); - QCOMPARE(timeframe->rowCount(), 1); - QCOMPARE(timeframe->data(timeframe->index(0, 0), HistoryModel::Url).toUrl(), - QUrl("http://example.org")); - } - - void shouldFilterOutOlderAndMoreRecentEntries() - { - model->add(QUrl("http://example.org"), "Example Domain", QUrl()); - QTest::qWait(100); - QDateTime start = QDateTime::currentDateTimeUtc(); - QTest::qWait(100); - model->add(QUrl("http://ubuntu.com"), "Ubuntu", QUrl()); - QTest::qWait(100); - QDateTime end = QDateTime::currentDateTimeUtc(); - QTest::qWait(100); - model->add(QUrl("http://example.com"), "Example Domain", QUrl()); - QCOMPARE(timeframe->rowCount(), 3); - timeframe->setStart(start); - timeframe->setEnd(end); - QCOMPARE(timeframe->rowCount(), 1); - QCOMPARE(timeframe->data(timeframe->index(0, 0), HistoryModel::Url).toUrl(), - QUrl("http://ubuntu.com")); - } -}; - -QTEST_MAIN(HistoryTimeframeModelTests) -#include "tst_HistoryTimeframeModelTests.moc" diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/limit-proxy-model/tst_LimitProxyModelTests.cpp webbrowser-app-0.23+16.04.20151204/tests/unittests/limit-proxy-model/tst_LimitProxyModelTests.cpp --- webbrowser-app-0.23+16.04.20151130/tests/unittests/limit-proxy-model/tst_LimitProxyModelTests.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/limit-proxy-model/tst_LimitProxyModelTests.cpp 2015-12-04 11:06:32.000000000 +0000 @@ -17,45 +17,92 @@ */ // Qt +#include +#include #include #include // local -#include "domain-utils.h" -#include "history-model.h" -#include "history-timeframe-model.h" #include "limit-proxy-model.h" -#include "top-sites-model.h" + +class SimpleListModel : public QAbstractListModel { + Q_OBJECT + +public: + enum Roles { + Index = Qt::UserRole + 1, + String + }; + + QHash roleNames() const + { + static QHash roles; + if (roles.isEmpty()) { + roles[Index] = "index"; + roles[String] = "string"; + } + return roles; + } + + int rowCount(const QModelIndex& parent=QModelIndex()) const + { + return m_strings.count(); + } + + QVariant data(const QModelIndex& index, int role) const + { + if (!index.isValid()) { + return QVariant(); + } + switch (role) { + case Index: + return index.row(); + case String: + return m_strings.at(index.row()); + default: + return QVariant(); + } + } + + void append(const QStringList& strings) + { + int index = m_strings.count(); + beginInsertRows(QModelIndex(), index, index + strings.count() - 1); + m_strings << strings; + endInsertRows(); + } + + void remove(int index) + { + beginRemoveRows(QModelIndex(), index, index); + m_strings.removeAt(index); + endRemoveRows(); + } + +private: + QStringList m_strings; +}; class LimitProxyModelTests : public QObject { Q_OBJECT private: - HistoryModel* history; - HistoryTimeframeModel* timeframe; - TopSitesModel* topsites; + SimpleListModel* strings; LimitProxyModel* model; private Q_SLOTS: void init() { - history = new HistoryModel; - history->setDatabasePath(":memory:"); - timeframe = new HistoryTimeframeModel; - timeframe->setSourceModel(history); - topsites = new TopSitesModel; - topsites->setSourceModel(timeframe); + strings = new SimpleListModel; model = new LimitProxyModel; - model->setSourceModel(topsites); + model->setSourceModel(strings); } void cleanup() { delete model; - delete topsites; - delete timeframe; - delete history; + delete strings; } void shouldBeInitiallyEmpty() @@ -71,38 +118,29 @@ void shouldNotifyWhenChangingSourceModel() { QSignalSpy spy(model, SIGNAL(sourceModelChanged())); - model->setSourceModel(topsites); + model->setSourceModel(strings); QVERIFY(spy.isEmpty()); - TopSitesModel* topsites2 = new TopSitesModel; - model->setSourceModel(topsites2); + QStringListModel strings2; + model->setSourceModel(&strings2); QCOMPARE(spy.count(), 1); - QCOMPARE(model->sourceModel(), topsites2); + QCOMPARE(model->sourceModel(), &strings2); model->setSourceModel(0); QCOMPARE(spy.count(), 2); - QCOMPARE(model->sourceModel(), (TopSitesModel*) 0); - delete topsites2; + QCOMPARE(model->sourceModel(), (QAbstractItemModel*) 0); } void shouldLimitEntriesWithLimitSetBeforePopulating() { model->setLimit(2); - - history->add(QUrl("http://example1.org/"), "Example 1 Domain", QUrl()); - history->add(QUrl("http://example2.org/"), "Example 2 Domain", QUrl()); - history->add(QUrl("http://example3.org/"), "Example 3 Domain", QUrl()); - + strings->append({"a", "b", "c"}); QCOMPARE(model->rowCount(), 2); QCOMPARE(model->unlimitedRowCount(), 3); } void shouldLimitEntriesWithLimitSetAfterPopulating() { - history->add(QUrl("http://example1.org/"), "Example 1 Domain", QUrl()); - history->add(QUrl("http://example2.org/"), "Example 2 Domain", QUrl()); - history->add(QUrl("http://example3.org/"), "Example 3 Domain", QUrl()); - + strings->append({"a", "b", "c"}); model->setLimit(2); - QCOMPARE(model->rowCount(), 2); QCOMPARE(model->unlimitedRowCount(), 3); } @@ -110,11 +148,7 @@ void shouldNotLimitEntriesIfLimitIsMinusOne() { model->setLimit(-1); - - history->add(QUrl("http://example1.org/"), "Example 1 Domain", QUrl()); - history->add(QUrl("http://example2.org/"), "Example 2 Domain", QUrl()); - history->add(QUrl("http://example3.org/"), "Example 3 Domain", QUrl()); - + strings->append({"a", "b", "c"}); QCOMPARE(model->unlimitedRowCount(), 3); QCOMPARE(model->rowCount(), model->unlimitedRowCount()); } @@ -122,11 +156,7 @@ void shouldNotLimitEntriesIfLimitIsGreaterThanRowCount() { model->setLimit(4); - - history->add(QUrl("http://example1.org/"), "Example 1 Domain", QUrl()); - history->add(QUrl("http://example2.org/"), "Example 2 Domain", QUrl()); - history->add(QUrl("http://example3.org/"), "Example 3 Domain", QUrl()); - + strings->append({"a", "b", "c"}); QCOMPARE(model->unlimitedRowCount(), 3); QCOMPARE(model->rowCount(), model->unlimitedRowCount()); } @@ -134,25 +164,17 @@ void shouldUpdateRowCountAndNotifyAfterAnEntryIsRemoved() { model->setLimit(2); + strings->append({"a", "b", "c", "d"}); - qRegisterMetaType >(); QSignalSpy spyChanged(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector&))); QSignalSpy spyRemoved(model, SIGNAL(rowsRemoved(QModelIndex, int, int))); - history->add(QUrl("http://example1.org/"), "Example 1 Domain", QUrl()); - history->add(QUrl("http://example2.org/"), "Example 2 Domain", QUrl()); - QTest::qWait(1001); - history->add(QUrl("http://example3.org/"), "Example 3 Domain", QUrl()); - QTest::qWait(1001); - history->add(QUrl("http://example4.org/"), "Example 4 Domain", QUrl()); - - history->removeEntryByUrl(QUrl("http://example1.org/")); - + strings->remove(0); QCOMPARE(spyChanged.count(), 1); - QCOMPARE(spyRemoved.count(), 0); + QVERIFY(spyRemoved.isEmpty()); - QCOMPARE(model->data(model->index(0, 0), HistoryModel::Url).toUrl(), QUrl("http://example2.org/")); - QCOMPARE(model->data(model->index(1, 0), HistoryModel::Url).toUrl(), QUrl("http://example3.org/")); + QCOMPARE(model->data(model->index(0, 0), SimpleListModel::String).toString(), QString("b")); + QCOMPARE(model->data(model->index(1, 0), SimpleListModel::String).toString(), QString("c")); QCOMPARE(model->unlimitedRowCount(), 3); QCOMPARE(model->rowCount(), 2); @@ -160,13 +182,10 @@ void shouldGetItemWithCorrectValues() { - history->add(QUrl("http://example1.org/"), "Example 1 Domain", QUrl()); - + strings->append({"a"}); QVariantMap item = model->get(0); QHash roles = model->roleNames(); - QCOMPARE(roles.count(), item.count()); - Q_FOREACH(int role, roles.keys()) { QString roleName = QString::fromUtf8(roles.value(role)); QCOMPARE(model->data(model->index(0, 0), role), item.value(roleName)); diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/qml/CMakeLists.txt webbrowser-app-0.23+16.04.20151204/tests/unittests/qml/CMakeLists.txt --- webbrowser-app-0.23+16.04.20151130/tests/unittests/qml/CMakeLists.txt 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/qml/CMakeLists.txt 2015-12-04 11:06:32.000000000 +0000 @@ -22,14 +22,11 @@ ${webbrowser-app_SOURCE_DIR}/bookmarks-folderlist-model.cpp ${webbrowser-app_SOURCE_DIR}/file-operations.cpp ${webbrowser-app_SOURCE_DIR}/history-model.cpp - ${webbrowser-app_SOURCE_DIR}/history-lastvisitdate-model.cpp ${webbrowser-app_SOURCE_DIR}/history-lastvisitdatelist-model.cpp - ${webbrowser-app_SOURCE_DIR}/history-timeframe-model.cpp ${webbrowser-app_SOURCE_DIR}/limit-proxy-model.cpp ${webbrowser-app_SOURCE_DIR}/searchengine.cpp ${webbrowser-app_SOURCE_DIR}/tabs-model.cpp ${webbrowser-app_SOURCE_DIR}/text-search-filter-model.cpp - ${webbrowser-app_SOURCE_DIR}/top-sites-model.cpp tst_QmlTests.cpp ) add_executable(${TEST} ${SOURCES}) diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/qml/tst_HistoryViewWide.qml webbrowser-app-0.23+16.04.20151204/tests/unittests/qml/tst_HistoryViewWide.qml --- webbrowser-app-0.23+16.04.20151130/tests/unittests/qml/tst_HistoryViewWide.qml 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/qml/tst_HistoryViewWide.qml 2015-12-04 11:06:32.000000000 +0000 @@ -19,7 +19,6 @@ import QtQuick 2.4 import QtTest 1.0 import Ubuntu.Components 1.3 -import Ubuntu.Components.ListItems 1.3 as ListItems import webbrowserapp.private 0.1 import webbrowsertest.private 0.1 import "../../../src/app/webbrowser" diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/qml/tst_QmlTests.cpp webbrowser-app-0.23+16.04.20151204/tests/unittests/qml/tst_QmlTests.cpp --- webbrowser-app-0.23+16.04.20151130/tests/unittests/qml/tst_QmlTests.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/qml/tst_QmlTests.cpp 2015-12-04 11:06:32.000000000 +0000 @@ -30,14 +30,11 @@ #include "favicon-fetcher.h" #include "file-operations.h" #include "history-model.h" -#include "history-timeframe-model.h" -#include "history-lastvisitdate-model.h" #include "history-lastvisitdatelist-model.h" #include "limit-proxy-model.h" #include "searchengine.h" #include "tabs-model.h" #include "text-search-filter-model.h" -#include "top-sites-model.h" static QObject* FileOperations_singleton_factory(QQmlEngine* engine, QJSEngine* scriptEngine) { @@ -193,12 +190,9 @@ qmlRegisterSingletonType(browserUri, 0, 1, "BookmarksModel", BookmarksModel_singleton_factory); qmlRegisterType(browserUri, 0, 1, "BookmarksFolderListModel"); qmlRegisterSingletonType(browserUri, 0, 1, "HistoryModel", HistoryModel_singleton_factory); - qmlRegisterType(browserUri, 0, 1, "HistoryTimeframeModel"); qmlRegisterType(browserUri, 0, 1, "HistoryLastVisitDateListModel"); - qmlRegisterType(browserUri, 0, 1, "HistoryLastVisitDateModel"); qmlRegisterType(browserUri, 0, 1, "LimitProxyModel"); qmlRegisterType(browserUri, 0, 1, "TextSearchFilterModel"); - qmlRegisterType(browserUri, 0, 1, "TopSitesModel"); qmlRegisterSingletonType(browserUri, 0, 1, "FileOperations", FileOperations_singleton_factory); const char* testUri = "webbrowsertest.private"; diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/tabs-model/tst_TabsModelTests.cpp webbrowser-app-0.23+16.04.20151204/tests/unittests/tabs-model/tst_TabsModelTests.cpp --- webbrowser-app-0.23+16.04.20151130/tests/unittests/tabs-model/tst_TabsModelTests.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/tabs-model/tst_TabsModelTests.cpp 2015-12-04 11:06:37.000000000 +0000 @@ -336,6 +336,42 @@ QCOMPARE(model->currentTab(), tab1); } + void shouldUpdateCurrentTabWhenInsertingAtCurrentIndex() + { + QQuickItem* tab1 = createTab(); + model->insert(tab1, 0); + QCOMPARE(model->currentIndex(), 0); + QCOMPARE(model->currentTab(), tab1); + + QSignalSpy spytab(model, SIGNAL(currentTabChanged())); + QSignalSpy spyindex(model, SIGNAL(currentIndexChanged())); + + QQuickItem* tab2 = createTab(); + model->insert(tab2, 0); + + QVERIFY(spyindex.isEmpty()); + QCOMPARE(spytab.count(), 1); + QCOMPARE(model->currentTab(), tab2); + } + + void shouldUpdateCurrentIndexWhenInsertingBeforeCurrentIndex() + { + model->insert(createTab(), 0); + model->insert(createTab(), 0); + model->setCurrentIndex(1); + QObject* current = model->currentTab(); + + QSignalSpy spytab(model, SIGNAL(currentTabChanged())); + QSignalSpy spyindex(model, SIGNAL(currentIndexChanged())); + + model->insert(createTab(), 0); + + QVERIFY(spytab.isEmpty()); + QCOMPARE(spyindex.count(), 1); + QCOMPARE(model->currentTab(), current); + QCOMPARE(model->currentIndex(), 2); + } + void shouldSetInvalidIndexWhenRemovingLastTab() { // Removing the last item should also set the current index to -1 diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/top-sites-model/CMakeLists.txt webbrowser-app-0.23+16.04.20151204/tests/unittests/top-sites-model/CMakeLists.txt --- webbrowser-app-0.23+16.04.20151130/tests/unittests/top-sites-model/CMakeLists.txt 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/top-sites-model/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -find_package(Qt5Core REQUIRED) -find_package(Qt5Sql REQUIRED) -find_package(Qt5Test REQUIRED) -set(TEST tst_TopSitesModelTests) -add_executable(${TEST} tst_TopSitesModelTests.cpp) -include_directories(${webbrowser-app_SOURCE_DIR}) -target_link_libraries(${TEST} - Qt5::Core - Qt5::Sql - Qt5::Test - webbrowser-app-models -) -add_test(${TEST} ${CMAKE_CURRENT_BINARY_DIR}/${TEST} -xunitxml -o ${TEST}.xml) diff -Nru webbrowser-app-0.23+16.04.20151130/tests/unittests/top-sites-model/tst_TopSitesModelTests.cpp webbrowser-app-0.23+16.04.20151204/tests/unittests/top-sites-model/tst_TopSitesModelTests.cpp --- webbrowser-app-0.23+16.04.20151130/tests/unittests/top-sites-model/tst_TopSitesModelTests.cpp 2015-11-30 14:50:50.000000000 +0000 +++ webbrowser-app-0.23+16.04.20151204/tests/unittests/top-sites-model/tst_TopSitesModelTests.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -/* - * Copyright 2015 Canonical Ltd. - * - * This file is part of webbrowser-app. - * - * webbrowser-app 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; version 3. - * - * webbrowser-app 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 . - */ - -// Qt -#include -#include - -// local -#include "history-model.h" -#include "history-timeframe-model.h" -#include "top-sites-model.h" - -class TopSitesModelTests : public QObject -{ - Q_OBJECT - -private: - HistoryModel* model; - HistoryTimeframeModel* timeframe; - TopSitesModel* topsites; - -private Q_SLOTS: - void init() - { - model = new HistoryModel; - model->setDatabasePath(":memory:"); - timeframe = new HistoryTimeframeModel; - timeframe->setSourceModel(model); - topsites = new TopSitesModel; - topsites->setSourceModel(timeframe); - } - - void cleanup() - { - delete topsites; - delete timeframe; - delete model; - } - - void shouldBeInitiallyEmpty() - { - QCOMPARE(topsites->rowCount(), 0); - } - - void shouldNotifyWhenChangingSourceModel() - { - QSignalSpy spy(topsites, SIGNAL(sourceModelChanged())); - topsites->setSourceModel(timeframe); - QVERIFY(spy.isEmpty()); - HistoryTimeframeModel* timeframe2 = new HistoryTimeframeModel; - topsites->setSourceModel(timeframe2); - QCOMPARE(spy.count(), 1); - QCOMPARE(topsites->sourceModel(), timeframe2); - topsites->setSourceModel(0); - QCOMPARE(spy.count(), 2); - QCOMPARE(topsites->sourceModel(), (HistoryTimeframeModel*) 0); - delete timeframe2; - } - - void shouldMatchAllWhenNothingIsHidden() - { - QSignalSpy spy(topsites, SIGNAL(countChanged())); - model->add(QUrl("http://example.org"), "Example Domain", QUrl()); - model->add(QUrl("http://example.com"), "Example Domain", QUrl()); - QCOMPARE(spy.count(), 2); - QCOMPARE(topsites->rowCount(), 2); - } - - void shouldFilterOutHiddenUrls() - { - QSignalSpy spy(topsites, SIGNAL(countChanged())); - model->add(QUrl("http://example.org"), "Example Domain", QUrl()); - model->add(QUrl("http://example.com"), "Example Domain", QUrl()); - QCOMPARE(spy.count(), 2); - QCOMPARE(topsites->rowCount(), 2); - model->hide(QUrl("http://example.org")); - QCOMPARE(spy.count(), 3); - QCOMPARE(topsites->rowCount(), 1); - QCOMPARE(topsites->data(topsites->index(0, 0), HistoryModel::Url).toUrl(), QUrl("http://example.com")); - } - - void shouldBeSortedByVisits() - { - model->add(QUrl("http://example.org/"), "Example Domain", QUrl()); - model->add(QUrl("http://ubuntu.com/"), "Ubuntu", QUrl()); - model->add(QUrl("http://ubuntu.com/"), "Ubuntu", QUrl()); - QCOMPARE(model->data(model->index(0, 0), HistoryModel::Domain).toString(), QString("ubuntu.com")); - QCOMPARE(model->data(model->index(1, 0), HistoryModel::Domain).toString(), QString("example.org")); - } -}; - -QTEST_MAIN(TopSitesModelTests) -#include "tst_TopSitesModelTests.moc"