~cimi/unity8/scope-settings

« back to all changes in this revision

Viewing changes to tests/mocks/Unity/fake_navigation.cpp

  • Committer: Andrea Cimitan
  • Date: 2014-08-07 16:17:06 UTC
  • mfrom: (1109.1.25 unity8)
  • Revision ID: andrea.cimitan@gmail.com-20140807161706-j6ndy7bgz457xn4n
[ Michal Hruby ]
* Work with the scopes-v4 branch + departments->navigation renaming
[ Michał Sawicz ]
* Hardcode art shape size for click scope local and predefined
  categories While at it, drop the fillmode of cards
* Use the correct API in PageHeader. (LP: #1353048)
* Refactor dash activity indicator. (LP: #1351539)
[ Albert Astals ]
* Dash Departments fixes Update maxHeight manually since it depends on
  the position of the item and its parents and it can't know when the
  binding has to be updated Make parent stuff non interactive when the
  department list is shown
* PageHeader: when on search clip y-coordinates otherwise the
  background spills out when on search (LP: #1350398)
* Dash: Implement OverlayColor support in Cards
* Hardcode art shape size for click scope local and predefined
  categories While at it, drop the fillmode of cards
* Make test_departments test more stable There's various
  DashDepartments on the dash, make sure we're working over the one
  that is on screen, otherwise clicks don't end up where they should
* Work with the scopes-v4 branch + departments->navigation renaming
* Fixes for dash as app Load i18n catalog Process command line options
  Add the posibility to have a mouse touch adaptor (LP: #1353351)
* Implement the Expandable Preview Widget Now TextSummary is not
  expandable by itself anymore, you have to use it inside an
  Expandable to get the behaviour
* Add test prefix to xml output, seems CI needs it
[ Antti Kaijanmäki ]
* Indicators: Adds new ModemInfoItem to be used with indicator-network
  (LP: #1329204)
[ Michael Terry ]
* When the edge demo is running, don't show the greeter if the screen
  is turned off. This avoids an odd interaction where parts of the
  greeter are disabled but the edge demo isn't visible until you slide
  the greeter away. (LP: #1283425)
* Don't hardcode the phablet password in our testing script.
[ Ying-Chun Liu ]
* Add divider dots.
[ Mirco Müller ]
* Make sure the TextField of a snap-decision notification has the
  active focus upon creation, thus the osk shows up right away. (LP:
  #1346867)
[ Andrea Cimitan ]
* Add touchdown effect to dash cards.
* Import Ubuntu.Components for preview image gallery to pick up
  default flicking speeds.
[ Michael Zanetti ]
* Split the dash from the shell into a separate app (LP: #1232687)
[ Leo Arias ]
* Update the autopilot tests to work with the new dash app.
[ Daniel d'Andrada ]
* Split the dash from the shell into a separate app (LP: #1232687)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
15
 */
16
16
 
17
 
#include "fake_department.h"
 
17
#include "fake_navigation.h"
18
18
 
19
19
#include "fake_scope.h"
20
20
 
 
21
#include <QDebug>
21
22
#include <QTimer>
22
23
 
23
 
Department::Department(const QString& departmentId, const QString& label, const QString& allLabel, const QString& parentId, const QString& parentLabel, Scope* scope)
24
 
 : m_departmentId(departmentId)
 
24
Navigation::Navigation(const QString& navigationId, const QString& label, const QString& allLabel, const QString& parentId, const QString& parentLabel, Scope* scope)
 
25
 : m_navigationId(navigationId)
25
26
 , m_label(label)
26
27
 , m_allLabel(allLabel)
27
28
 , m_parentId(parentId)
30
31
 , m_scope(scope)
31
32
{
32
33
    QTimer::singleShot(1500, this, SLOT(slotLoaded()));
33
 
    connect(scope, SIGNAL(currentDepartmentIdChanged()), this, SLOT(slotCurrentDepartmentChanged()));
 
34
    connect(scope, SIGNAL(currentNavigationIdChanged()), this, SLOT(slotCurrentNavigationChanged()));
34
35
}
35
36
 
36
 
QString Department::departmentId() const
 
37
QString Navigation::navigationId() const
37
38
{
38
 
    return m_departmentId;
 
39
    return m_navigationId;
39
40
}
40
41
 
41
 
QString Department::label() const
 
42
QString Navigation::label() const
42
43
{
43
44
    return m_label;
44
45
}
45
46
 
46
 
QString Department::allLabel() const
 
47
QString Navigation::allLabel() const
47
48
{
48
49
    return m_allLabel;
49
50
}
50
51
 
51
 
QString Department::parentDepartmentId() const
 
52
QString Navigation::parentNavigationId() const
52
53
{
53
54
    return m_parentId;
54
55
}
55
56
 
56
 
QString Department::parentLabel() const
 
57
QString Navigation::parentLabel() const
57
58
{
58
59
    return m_parentLabel;
59
60
}
60
61
 
61
 
void Department::slotLoaded()
 
62
void Navigation::slotLoaded()
62
63
{
63
64
    m_loaded = true;
64
65
    Q_EMIT loadedChanged();
65
66
}
66
67
 
67
 
bool Department::loaded() const
 
68
bool Navigation::loaded() const
68
69
{
69
70
    return m_loaded;
70
71
}
71
72
 
72
 
int Department::count() const
 
73
int Navigation::count() const
73
74
{
74
75
    return rowCount();
75
76
}
76
77
 
77
 
bool Department::isRoot() const
78
 
{
79
 
    return m_departmentId == "root";
80
 
}
81
 
 
82
 
int Department::rowCount(const QModelIndex & /*parent*/) const
83
 
{
84
 
    if (!m_loaded || m_departmentId.startsWith("child") || m_departmentId == "middle3")
 
78
bool Navigation::isRoot() const
 
79
{
 
80
    return m_navigationId == "root" || m_navigationId == "altroot";
 
81
}
 
82
 
 
83
bool Navigation::hidden() const
 
84
{
 
85
    return m_navigationId == "altroot";
 
86
}
 
87
 
 
88
int Navigation::rowCount(const QModelIndex & /*parent*/) const
 
89
{
 
90
    if (!m_loaded || m_navigationId.startsWith("child") || m_navigationId == "middle3")
85
91
        return 0;
86
92
    else
87
93
        return 8;
88
94
}
89
95
 
90
 
QHash<int, QByteArray> Department::roleNames() const
91
 
{
92
 
    QHash<int, QByteArray> res;
93
 
    res[RoleDepartmentId] = "departmentId";
94
 
    res[RoleLabel] = "label";
95
 
    res[RoleHasChildren] = "hasChildren";
96
 
    res[RoleIsActive] = "isActive";
97
 
    return res;
98
 
}
99
 
 
100
 
QVariant Department::data(const QModelIndex &index, int role) const
 
96
QVariant Navigation::data(const QModelIndex &index, int role) const
101
97
{
102
98
    switch (role) {
103
 
        case RoleDepartmentId:
104
 
            if (m_departmentId == "root")
 
99
        case RoleNavigationId:
 
100
            if (m_navigationId == "root")
105
101
                return QString("middle%1").arg(index.row());
106
 
            else if (m_departmentId.startsWith("middle"))
107
 
                return QString("child%1%2").arg(m_departmentId).arg(index.row());
108
 
            break;
 
102
            else if (m_navigationId.startsWith("middle"))
 
103
                return QString("child%1%2").arg(m_navigationId).arg(index.row());
109
104
        case RoleLabel:
110
 
            return QString("%1Child%2").arg(m_departmentId).arg(index.row());
111
 
            break;
 
105
            return QString("%1Child%2").arg(m_navigationId).arg(index.row());
112
106
        case RoleHasChildren:
113
 
            return m_departmentId == "root" && index.row() != 3;
114
 
            break;
 
107
            return m_navigationId == "root" && index.row() != 3;
115
108
        case RoleIsActive:
116
 
            return m_scope->currentDepartmentId() == data(index, RoleDepartmentId);
117
 
            break;
 
109
            return m_scope->currentNavigationId() == data(index, RoleNavigationId);
118
110
    }
119
111
    return QVariant();
120
112
}
121
113
 
122
 
void Department::slotCurrentDepartmentChanged()
 
114
void Navigation::slotCurrentNavigationChanged()
123
115
{
124
116
    // This is wasteful, should only emit it if really something changed in this
125
117
    // deparment, but this is a mock, so no need to optimize