Merge lp:~osomon/webbrowser-app/domain-with-only-one-entry into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Günter Schwann
Approved revision: 343
Merged at revision: 343
Proposed branch: lp:~osomon/webbrowser-app/domain-with-only-one-entry
Merge into: lp:webbrowser-app
Diff against target: 94 lines (+34/-1)
4 files modified
src/Ubuntu/Components/Extras/Browser/history-domain-model.cpp (+10/-0)
src/Ubuntu/Components/Extras/Browser/history-domain-model.h (+7/-0)
src/app/TimelineView.qml (+5/-1)
tests/unittests/history-domain-model/tst_HistoryDomainModelTests.cpp (+12/-0)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/domain-with-only-one-entry
Reviewer Review Type Date Requested Status
Günter Schwann (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+187455@code.launchpad.net

Commit message

Go directly to the entry instead of expanding the timeline view when there is only one entry for a given domain.
This change has been requested by design.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Günter Schwann (schwann) wrote :

works fine

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/Extras/Browser/history-domain-model.cpp'
2--- src/Ubuntu/Components/Extras/Browser/history-domain-model.cpp 2013-08-06 15:45:18 +0000
3+++ src/Ubuntu/Components/Extras/Browser/history-domain-model.cpp 2013-09-25 07:54:26 +0000
4@@ -79,6 +79,16 @@
5 return m_lastVisit;
6 }
7
8+const int HistoryDomainModel::count() const
9+{
10+ return rowCount();
11+}
12+
13+const QUrl HistoryDomainModel::firstUrl() const
14+{
15+ return data(index(0, 0), HistoryModel::Url).toUrl();
16+}
17+
18 bool HistoryDomainModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
19 {
20 if (m_domain.isEmpty()) {
21
22=== modified file 'src/Ubuntu/Components/Extras/Browser/history-domain-model.h'
23--- src/Ubuntu/Components/Extras/Browser/history-domain-model.h 2013-08-06 15:45:18 +0000
24+++ src/Ubuntu/Components/Extras/Browser/history-domain-model.h 2013-09-25 07:54:26 +0000
25@@ -23,6 +23,7 @@
26 #include <QtCore/QDateTime>
27 #include <QtCore/QSortFilterProxyModel>
28 #include <QtCore/QString>
29+#include <QtCore/QUrl>
30
31 class HistoryTimeframeModel;
32
33@@ -33,6 +34,8 @@
34 Q_PROPERTY(HistoryTimeframeModel* sourceModel READ sourceModel WRITE setSourceModel NOTIFY sourceModelChanged)
35 Q_PROPERTY(QString domain READ domain WRITE setDomain NOTIFY domainChanged)
36 Q_PROPERTY(QDateTime lastVisit READ lastVisit NOTIFY lastVisitChanged)
37+ Q_PROPERTY(int count READ count)
38+ Q_PROPERTY(QUrl firstUrl READ firstUrl)
39
40 public:
41 HistoryDomainModel(QObject* parent=0);
42@@ -45,6 +48,10 @@
43
44 const QDateTime& lastVisit() const;
45
46+ const int count() const;
47+
48+ const QUrl firstUrl() const;
49+
50 Q_SIGNALS:
51 void sourceModelChanged() const;
52 void domainChanged() const;
53
54=== modified file 'src/app/TimelineView.qml'
55--- src/app/TimelineView.qml 2013-09-24 10:03:11 +0000
56+++ src/app/TimelineView.qml 2013-09-25 07:54:26 +0000
57@@ -288,9 +288,13 @@
58 timeline.currentIndex = -1
59 } else {
60 domainsView.currentIndex = index
61- timeline.currentIndex = timelineIndex
62 entriesView.domain = model.domain
63 entriesView.model = model.entries
64+ if (model.entries.count === 1) {
65+ historyEntryClicked(model.entries.firstUrl)
66+ } else {
67+ timeline.currentIndex = timelineIndex
68+ }
69 }
70 }
71 }
72
73=== modified file 'tests/unittests/history-domain-model/tst_HistoryDomainModelTests.cpp'
74--- tests/unittests/history-domain-model/tst_HistoryDomainModelTests.cpp 2013-07-12 13:49:42 +0000
75+++ tests/unittests/history-domain-model/tst_HistoryDomainModelTests.cpp 2013-09-25 07:54:26 +0000
76@@ -105,6 +105,18 @@
77 model->setDomain("");
78 QCOMPARE(model->rowCount(), 2);
79 }
80+
81+ void shouldExposeCountAndFirstUrl()
82+ {
83+ QCOMPARE(model->count(), 0);
84+ QVERIFY(model->firstUrl().isEmpty());
85+ history->add(QUrl("http://example.org"), "Example Domain", QUrl());
86+ QCOMPARE(model->count(), 1);
87+ QCOMPARE(model->firstUrl(), QUrl("http://example.org"));
88+ history->add(QUrl("http://example.com"), "Example Domain", QUrl());
89+ QCOMPARE(model->count(), 2);
90+ QCOMPARE(model->firstUrl(), QUrl("http://example.com"));
91+ }
92 };
93
94 QTEST_MAIN(HistoryDomainModelTests)

Subscribers

People subscribed via source and target branches

to status/vote changes: