Commit a7663dc7 authored by Tomaz  Canabrava's avatar Tomaz Canabrava Committed by Kurt Hindenburg
Browse files

Fix edit profile shortcuts

parent 28ba920c
...@@ -77,8 +77,10 @@ QVariant ProfileModel::data(const QModelIndex& idx, int role) const ...@@ -77,8 +77,10 @@ QVariant ProfileModel::data(const QModelIndex& idx, int role) const
} }
break; break;
case SHORTCUT: { case SHORTCUT: {
auto shortcut = ProfileManager::instance()->shortcut(profile);
switch (role) { switch (role) {
case Qt::DisplayRole: return ProfileManager::instance()->shortcut(profile).toString(); case Qt::DisplayRole: return shortcut;
case Qt::EditRole: return shortcut;
case Qt::ToolTipRole: return i18nc("@info:tooltip", "Double click to change shortcut"); case Qt::ToolTipRole: return i18nc("@info:tooltip", "Double click to change shortcut");
} }
break; break;
...@@ -100,6 +102,7 @@ Qt::ItemFlags ProfileModel::flags(const QModelIndex& idx) const ...@@ -100,6 +102,7 @@ Qt::ItemFlags ProfileModel::flags(const QModelIndex& idx) const
switch(idx.column()) { switch(idx.column()) {
case NAME: return currentFlags & (~Qt::ItemIsEditable); case NAME: return currentFlags & (~Qt::ItemIsEditable);
case SHORTCUT: return currentFlags | Qt::ItemIsEditable;
default: return currentFlags; default: return currentFlags;
} }
return currentFlags; return currentFlags;
...@@ -111,22 +114,23 @@ bool ProfileModel::setData(const QModelIndex &idx, const QVariant &value, int ro ...@@ -111,22 +114,23 @@ bool ProfileModel::setData(const QModelIndex &idx, const QVariant &value, int ro
return false; return false;
} }
if (idx.row() != SHORTCUT) { if (idx.column() != SHORTCUT) {
return false; return false;
} }
if (role != Qt::EditRole) { if (role != Qt::EditRole && role != Qt::DisplayRole) {
return false; return false;
} }
auto profile = m_profiles.at(idx.row()); auto profile = m_profiles.at(idx.row());
if (idx.row() == SHORTCUT) { if (idx.column() == SHORTCUT) {
QKeySequence sequence = QKeySequence::fromString(value.toString()); auto sequence = QKeySequence::fromString(value.toString());
ProfileManager::instance()->setShortcut(profile, sequence); ProfileManager::instance()->setShortcut(profile, sequence);
emit dataChanged(idx, idx, {Qt::DisplayRole}); emit dataChanged(idx, idx, {Qt::DisplayRole});
return true;
} }
return true; return false;
} }
void ProfileModel::populate() void ProfileModel::populate()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment