2 * Copyright (C) 2013 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 "hudtoolbarmodel.h"
21static const int ActionRole = Qt::UserRole;
22static const int EnabledRole = Qt::UserRole + 1;
24static QString iconForAction(int action)
27 case HUD_CLIENT_QUERY_TOOLBAR_UNDO:
28 return "graphics/undo.png";
29 case HUD_CLIENT_QUERY_TOOLBAR_HELP:
30 return "graphics/help.png";
31 case HUD_CLIENT_QUERY_TOOLBAR_FULLSCREEN:
32 return "graphics/view-fullscreen.png";
33 case HUD_CLIENT_QUERY_TOOLBAR_PREFERENCES:
34 return "graphics/settings.png";
39HudToolBarModel::HudToolBarModel(HudClientQuery *query)
42 m_actions << HUD_CLIENT_QUERY_TOOLBAR_UNDO
43 << HUD_CLIENT_QUERY_TOOLBAR_HELP
44 << HUD_CLIENT_QUERY_TOOLBAR_FULLSCREEN
45 << HUD_CLIENT_QUERY_TOOLBAR_PREFERENCES;
48HudToolBarModel::~HudToolBarModel()
52int HudToolBarModel::rowCount(const QModelIndex &parent) const
57 return m_actions.count();
60QVariant HudToolBarModel::data(const QModelIndex &index, int role) const
62 const int row = index.row();
63 if (row >= m_actions.count())
66 const HudClientQueryToolbarItems action = m_actions[row];
69 case Qt::DecorationRole:
70 return iconForAction(action);
78 return hud_client_query_toolbar_item_active(m_query, action);
84QHash<int,QByteArray> HudToolBarModel::roleNames() const
86 static QHash<int,QByteArray> roles;
87 if (roles.isEmpty()) {
88 roles[Qt::DecorationRole] = "iconPath";
89 roles[ActionRole] = "action";
90 roles[EnabledRole] = "enabled";
95void HudToolBarModel::updatedByBackend()
97 Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, 0), QVector<int>() << EnabledRole);
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