1#include "appdrawerproxymodel.h"
5AppDrawerProxyModel::AppDrawerProxyModel(QObject *parent):
6 QSortFilterProxyModel(parent)
8 setSortRole(AppDrawerModelInterface::RoleName);
10 connect(this, &QAbstractListModel::rowsInserted, this, &AppDrawerProxyModel::countChanged);
11 connect(this, &QAbstractListModel::rowsRemoved, this, &AppDrawerProxyModel::countChanged);
12 connect(this, &QAbstractListModel::layoutChanged, this, &AppDrawerProxyModel::countChanged);
15QAbstractItemModel *AppDrawerProxyModel::source() const
20void AppDrawerProxyModel::setSource(QAbstractItemModel *source)
22 if (m_source != source) {
24 setSourceModel(m_source);
26 connect(m_source, &QAbstractItemModel::rowsRemoved, this, &AppDrawerProxyModel::invalidateFilter);
27 connect(m_source, &QAbstractItemModel::rowsInserted, this, &AppDrawerProxyModel::invalidateFilter);
28 Q_EMIT sourceChanged();
32AppDrawerProxyModel::GroupBy AppDrawerProxyModel::group() const
37void AppDrawerProxyModel::setGroup(AppDrawerProxyModel::GroupBy group)
39 if (m_group != group) {
41 Q_EMIT groupChanged();
46QString AppDrawerProxyModel::filterLetter() const
48 return m_filterLetter;
51void AppDrawerProxyModel::setFilterLetter(const QString &filterLetter)
53 if (m_filterLetter != filterLetter) {
54 m_filterLetter = filterLetter;
55 Q_EMIT filterLetterChanged();
60QString AppDrawerProxyModel::filterString() const
62 return m_filterString;
65void AppDrawerProxyModel::setFilterString(const QString &filterString)
67 if (m_filterString != filterString) {
68 m_filterString = filterString;
69 Q_EMIT filterStringChanged();
74int AppDrawerProxyModel::count() const
79QVariant AppDrawerProxyModel::data(const QModelIndex &index, int role) const
81 QModelIndex idx = mapToSource(index);
82 if (role == Qt::UserRole) {
83 QString name = m_source->data(idx, AppDrawerModelInterface::RoleName).toString();
84 return name.length() > 0 ? QString(name.at(0)) : QChar();
86 return m_source->data(idx, role);
89QHash<int, QByteArray> AppDrawerProxyModel::roleNames() const
92 QHash<int, QByteArray> roles = m_source->roleNames();
93 roles.insert(Qt::UserRole, "letter");
96 return QHash<int, QByteArray>();
99bool AppDrawerProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
101 Q_UNUSED(source_parent)
103 if (m_group == GroupByAToZ && source_row > 0) {
104 QString currentName = m_source->data(m_source->index(source_row, 0), AppDrawerModelInterface::RoleName).toString();
105 QChar currentLetter = currentName.length() > 0 ? currentName.at(0) : QChar();
106 QString previousName = m_source->data(m_source->index(source_row - 1,0 ), AppDrawerModelInterface::RoleName).toString();
107 QChar previousLetter = previousName.length() > 0 ? previousName.at(0) : QChar();
108 if (currentLetter == previousLetter) {
111 } else if(m_group == GroupByAll && source_row > 0) {
114 if (!m_filterLetter.isEmpty()) {
115 QString currentName = m_source->data(m_source->index(source_row, 0), AppDrawerModelInterface::RoleName).toString();
116 QString currentLetter = currentName.length() > 0 ? QString(currentName.at(0)) : QString();
117 if (currentLetter != m_filterLetter) {
121 if (!m_filterString.isEmpty()) {
122 QString currentLabel = m_source->data(m_source->index(source_row, 0), AppDrawerModelInterface::RoleName).toString().toLower();
123 if (!currentLabel.startsWith(m_filterString.toLower())) {
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