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_navigation.h"
19#include "fake_scope.h"
24Navigation::Navigation(const QString& navigationId, const QString& label, const QString& allLabel, const QString& parentId, const QString& parentLabel, Scope* scope)
25 : m_navigationId(navigationId)
27 , m_allLabel(allLabel)
28 , m_parentId(parentId)
29 , m_parentLabel(parentLabel)
33 QTimer::singleShot(1500, this, SLOT(slotLoaded()));
34 connect(scope, SIGNAL(currentNavigationIdChanged()), this, SLOT(slotCurrentNavigationChanged()));
35 connect(scope, SIGNAL(currentAltNavigationIdChanged()), this, SLOT(slotCurrentNavigationChanged()));
38QString Navigation::navigationId() const
40 return m_navigationId;
43QString Navigation::label() const
48QString Navigation::allLabel() const
53QString Navigation::parentNavigationId() const
58QString Navigation::parentLabel() const
63void Navigation::slotLoaded()
66 Q_EMIT loadedChanged();
69bool Navigation::loaded() const
74int Navigation::count() const
79bool Navigation::isRoot() const
81 return m_navigationId == "root" || m_navigationId == "altroot";
84bool Navigation::hidden() const
86 return m_navigationId == "altroot";
89int Navigation::rowCount(const QModelIndex & /*parent*/) const
91 if (!m_loaded || m_navigationId.startsWith("child") || m_navigationId == "middle3")
97QVariant Navigation::data(const QModelIndex &index, int role) const
100 case RoleNavigationId:
101 if (m_navigationId == "root")
102 return QString("middle%1").arg(index.row());
103 else if (m_navigationId.startsWith("middle"))
104 return QString("child%1%2").arg(m_navigationId).arg(index.row());
106 return QString("%1Child%2").arg(m_navigationId).arg(index.row());
107 case RoleHasChildren:
108 return m_navigationId == "root" && index.row() != 3;
110 if (m_navigationId.startsWith("alt")) {
111 return m_scope->currentAltNavigationId() == data(index, RoleNavigationId);
113 return m_scope->currentNavigationId() == data(index, RoleNavigationId);
119void Navigation::slotCurrentNavigationChanged()
121 // This is wasteful, should only emit it if really something changed in this
122 // deparment, but this is a mock, so no need to optimize
123 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