2 * Copyright (C) 2014 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17#include "fake_department.h"
19#include "fake_scope.h"
23Department::Department(const QString& departmentId, const QString& label, const QString& allLabel, const QString& parentId, const QString& parentLabel, Scope* scope)
24 : QAbstractListModel()
25 , m_departmentId(departmentId)
27 , m_allLabel(allLabel)
28 , m_parentId(parentId)
29 , m_parentLabel(parentLabel)
33 QTimer::singleShot(1500, this, SLOT(slotLoaded()));
34 connect(scope, SIGNAL(currentDepartmentChanged(QString)), this, SLOT(slotCurrentDepartmentChanged()));
37QString Department::departmentId() const
39 return m_departmentId;
42QString Department::label() const
47QString Department::allLabel() const
52QString Department::parentId() const
57QString Department::parentLabel() const
62void Department::slotLoaded()
65 Q_EMIT loadedChanged(m_loaded);
68bool Department::loaded() const
73int Department::count() const
78int Department::rowCount(const QModelIndex & /*parent*/) const
80 if (m_departmentId.startsWith("child"))
86QHash<int, QByteArray> Department::roleNames() const
88 QHash<int, QByteArray> res;
89 res[RoleDepartmentId] = "departmentId";
90 res[RoleLabel] = "label";
91 res[RoleHasChildren] = "hasChildren";
92 res[RoleIsActive] = "isActive";
96QVariant Department::data(const QModelIndex &index, int role) const
99 case RoleDepartmentId:
100 if (m_departmentId == "root")
101 return QString("middle%1").arg(index.row());
102 else if (m_departmentId.startsWith("middle"))
103 return QString("child%1%2").arg(m_departmentId).arg(index.row());
106 return QString("%1Child%2").arg(m_departmentId).arg(index.row());
108 case RoleHasChildren:
109 return m_departmentId == "root";
112 return m_scope->currentDepartment() == data(index, RoleDepartmentId);
118void Department::slotCurrentDepartmentChanged()
120 // This is wasteful, should only emit it if really something changed in this
121 // deparment, but this is a mock, so no need to optimize
122 Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, 0), QVector<int>() << RoleIsActive);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list