15 using namespace swift::misc::input;
19 CActionHotkeyListModel::CActionHotkeyListModel(QObject *parent) : QAbstractTableModel(parent) {}
27 if (!index.isValid()) {
return QVariant(); }
28 if (index.row() >= m_actionHotkeys.
size() || index.row() < 0) {
return QVariant(); }
30 if (role == Qt::DisplayRole)
32 const int col = index.column();
35 const CIdentifier identifier = m_actionHotkeys[index.row()].getApplicableMachine();
44 if (col == 2) {
return m_actionHotkeys[index.row()].getAction(); }
46 else if (role == ActionHotkeyRole)
48 const auto hotkey = m_actionHotkeys[index.row()];
49 return QVariant::fromValue(hotkey);
56 if (role == Qt::DisplayRole)
58 if (orientation == Qt::Horizontal)
62 case 0:
return QStringLiteral(
"Machine");
63 case 1:
return QStringLiteral(
"Combination");
64 case 2:
return QStringLiteral(
"Action");
74 beginInsertRows(QModelIndex(), position, position + rows - 1);
85 beginRemoveRows(QModelIndex(), position, position + rows - 1);
87 Q_ASSERT(position + rows - 1 < m_actionHotkeys.
size());
89 for (
int row = 0; row < rows; ++row)
91 auto toRemove = m_actionHotkeys[position + row];
92 m_actionHotkeys.
remove(toRemove);
101 if (index.isValid() && role == ActionHotkeyRole)
104 emit dataChanged(index, index);
113 m_actionHotkeys.
clear();
bool removeRows(int position, int rows, const QModelIndex &index)
QVariant headerData(int section, Qt::Orientation orientation, int role) const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
int rowCount(const QModelIndex &parent=QModelIndex()) const
bool setData(const QModelIndex &index, const QVariant &var, int role)
int columnCount(const QModelIndex &parent=QModelIndex()) const
bool insertRows(int position, int rows, const QModelIndex &index)
Value object encapsulating information identifying a component of a modular distributed swift process...
const QString & getMachineName() const
Machine name.
size_type size() const
Returns number of elements in the sequence.
void push_back(const T &value)
Appends an element at the end of the sequence.
void clear()
Removes all elements in the sequence.
int remove(const T &object)
Remove all elements equal to the given object, if it is contained.
Models to be used with views, mainly QTableView.
Free functions in swift::misc.