2 * Copyright (C) 2017 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/>.
18#include "PromptsModel.h"
20PromptsModel::PromptsModel(QObject* parent)
21 : QAbstractListModel(parent)
23 m_roleNames[TypeRole] = "type";
24 m_roleNames[TextRole] = "text";
27PromptsModel& PromptsModel::operator=(const PromptsModel &other)
30 m_prompts = other.m_prompts;
32 Q_EMIT countChanged();
36int PromptsModel::rowCount(const QModelIndex &parent) const
41 return m_prompts.size();
44QVariant PromptsModel::data(const QModelIndex &index, int role) const
46 if (!index.isValid() || index.column() > 0 || index.row() >= m_prompts.size())
50 case Qt::DisplayRole: // fallthrough
51 case TextRole: return m_prompts[index.row()].prompt;
52 case TypeRole: return m_prompts[index.row()].type;
53 default: return QVariant();
57QHash<int, QByteArray> PromptsModel::roleNames() const
62void PromptsModel::prepend(const QString &text, PromptType type)
64 beginInsertRows(QModelIndex(), 0, 0);
65 m_prompts.prepend(PromptInfo{text, type});
68 Q_EMIT countChanged();
71void PromptsModel::append(const QString &text, PromptType type)
73 beginInsertRows(QModelIndex(), m_prompts.size(), m_prompts.size());
74 m_prompts.append(PromptInfo{text, type});
77 Q_EMIT countChanged();
80void PromptsModel::clear()
86 Q_EMIT countChanged();
89bool PromptsModel::hasPrompt() const
91 Q_FOREACH(const PromptInfo &info, m_prompts) {
92 if (info.type == PromptType::Secret || info.type == PromptType::Question) {
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