#include <commandmodel.h>
|
| int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
| |
| | CommandModel (QObject *parent=nullptr) |
| |
| QVariant | data (const QModelIndex &index, int role) const override |
| |
| void | refresh (QVector< QPair< QString, QAction * > > actionList) |
| |
| int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
| |
| bool | setData (const QModelIndex &index, const QVariant &value, int role) override |
| |
Definition at line 14 of file commandmodel.h.
◆ Role
◆ CommandModel()
| CommandModel::CommandModel |
( |
QObject * | parent = nullptr | ) |
|
◆ columnCount()
| int CommandModel::columnCount |
( |
const QModelIndex & | parent = QModelIndex() | ) |
const |
|
inlineoverride |
Definition at line 38 of file commandmodel.h.
39 {
40 Q_UNUSED(parent);
41 return 2;
42 }
◆ data()
| QVariant CommandModel::data |
( |
const QModelIndex & | index, |
|
|
int | role ) const |
|
override |
Definition at line 30 of file commandmodel.cpp.
31{
32 if (!index.isValid()) {
33 return {};
34 };
35
36 auto entry =
m_rows[index.row()];
37 int col = index.column();
38
39 switch (role) {
40 case Qt::DisplayRole:
41 if (col == 0) {
42 return QString(entry.component + QStringLiteral(": ") + KLocalizedString::removeAcceleratorMarker(entry.action->text()));
43 } else {
44 return entry.action->shortcut().toString();
45 }
46 case Qt::DecorationRole:
47 if (col == 0) {
48 return entry.action->icon();
49 }
50 break;
51 case Qt::TextAlignmentRole:
52 if (col == 0) {
53 return Qt::AlignLeft;
54 } else {
55 return Qt::AlignRight;
56 }
57 case Qt::UserRole: {
59 v.setValue(entry.action);
61 }
63 return entry.score;
64 }
65
66 return {};
67}
References m_rows, Score, and v.
◆ refresh()
| void CommandModel::refresh |
( |
QVector< QPair< QString, QAction * > > | actionList | ) |
|
Definition at line 17 of file commandmodel.cpp.
18{
20 temp.reserve(actionList.size());
21 for (
const auto &action :
std::as_const(actionList)) {
22 temp.push_back({action.first, action.second, 0});
23 }
24
25 beginResetModel();
27 endResetModel();
28}
References m_rows.
◆ rowCount()
| int CommandModel::rowCount |
( |
const QModelIndex & | parent = QModelIndex() | ) |
const |
|
inlineoverride |
Definition at line 30 of file commandmodel.h.
31 {
33 return 0;
34 }
36 }
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
References m_rows.
◆ setData()
| bool CommandModel::setData |
( |
const QModelIndex & | index, |
|
|
const QVariant & | value, |
|
|
int | role ) |
|
inlineoverride |
Definition at line 44 of file commandmodel.h.
45 {
46 if (!index.isValid()) {
47 return false;
48 }
50 auto row = index.row();
52 }
53 return QAbstractTableModel::setData(index,
value, role);
54 }
float value(const T *src, size_t ch)
References m_rows, Score, and value().
◆ m_rows
The documentation for this class was generated from the following files: