Merge lp:~schwann/ubuntu-ui-extras/extras-facebook-share-lazy-load into lp:~ubuntu-sdk-team/ubuntu-ui-extras/trunk

Proposed by Günter Schwann on 2013-10-18
Status: Merged
Approved by: Ugo Riboni on 2013-10-21
Approved revision: 55
Merged at revision: 55
Proposed branch: lp:~schwann/ubuntu-ui-extras/extras-facebook-share-lazy-load
Merge into: lp:~ubuntu-sdk-team/ubuntu-ui-extras/trunk
Diff against target: 69 lines (+30/-7)
2 files modified
modules/Ubuntu/Components/Extras/plugin/share/accounts.cpp (+25/-2)
modules/Ubuntu/Components/Extras/plugin/share/accounts.h (+5/-5)
To merge this branch: bzr merge lp:~schwann/ubuntu-ui-extras/extras-facebook-share-lazy-load
Reviewer Review Type Date Requested Status
Ugo Riboni (community) 2013-10-18 Approve on 2013-10-21
PS Jenkins bot continuous-integration Approve on 2013-10-18
Review via email: mp+191786@code.launchpad.net

Commit message

Use lazy loading for facebook id and name

Description of the change

Use lazy loading for facebook id and name

To post a comment you must log in.
Ugo Riboni (uriboni) wrote :

Everything seems proper

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/Extras/plugin/share/accounts.cpp'
2--- modules/Ubuntu/Components/Extras/plugin/share/accounts.cpp 2013-10-16 09:36:37 +0000
3+++ modules/Ubuntu/Components/Extras/plugin/share/accounts.cpp 2013-10-18 11:44:17 +0000
4@@ -22,7 +22,30 @@
5 QObject(parent),
6 m_accountId(-1)
7 {
8- update();
9+}
10+
11+/*!
12+ * \brief FacebookAccount::id
13+ * \return ID for that account
14+ */
15+int FacebookAccount::id() const
16+{
17+ if (m_accountId < 0)
18+ update();
19+
20+ return m_accountId;
21+}
22+
23+/*!
24+ * \brief FacebookAccount::name
25+ * \return display name for that account
26+ */
27+const QString &FacebookAccount::name() const
28+{
29+ if (m_accountName.isEmpty())
30+ update();
31+
32+ return m_accountName;
33 }
34
35 /* Since we can't get a notification when the Accounts::AccountIdList changed
36@@ -31,7 +54,7 @@
37 * This is sufficient for now since this class is only a temporary hack anyway
38 * until we support all types of accounts and not just hardcode Facebook support.
39 */
40-void FacebookAccount::update()
41+void FacebookAccount::update() const
42 {
43 Accounts::Manager manager;
44 Accounts::AccountIdList list = manager.accountList();
45
46=== modified file 'modules/Ubuntu/Components/Extras/plugin/share/accounts.h'
47--- modules/Ubuntu/Components/Extras/plugin/share/accounts.h 2013-10-16 09:36:37 +0000
48+++ modules/Ubuntu/Components/Extras/plugin/share/accounts.h 2013-10-18 11:44:17 +0000
49@@ -29,15 +29,15 @@
50
51 public:
52 explicit FacebookAccount(QObject *parent = 0);
53- int id() const { return m_accountId; }
54- QString name() const { return m_accountName; }
55+ int id() const;
56+ const QString &name() const;
57
58 public Q_SLOTS:
59- void update();
60+ void update() const;
61
62 private:
63- int m_accountId;
64- QString m_accountName;
65+ mutable int m_accountId;
66+ mutable QString m_accountName;
67 };
68
69 #endif // ACCOUNTSQML_H

Subscribers

People subscribed via source and target branches