Skip to content

Commit

Permalink
Add support for the DELETE action to CustomEdit, allows deletion of e…
Browse files Browse the repository at this point in the history
…xample clauses.
  • Loading branch information
stuartm committed Feb 7, 2011
1 parent 2fc8d40 commit a1c9456
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
34 changes: 33 additions & 1 deletion mythtv/programs/mythfrontend/customedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ void CustomEdit::storeRule(bool is_search, bool is_new)
void CustomEdit::deleteRule(void)
{
MythUIButtonListItem* item = m_clauseList->GetItemCurrent();
if (!item)
if (!item || m_clauseList->GetCurrentPos() < m_maxex)
return;

MSqlQuery query(MSqlQuery::InitCon());
Expand Down Expand Up @@ -845,3 +845,35 @@ void CustomEdit::customEvent(QEvent *event)
}
}
}

bool CustomEdit::keyPressEvent(QKeyEvent *event)
{
if (GetFocusWidget()->keyPressEvent(event))
return true;

bool handled = false;
QStringList actions;
handled = GetMythMainWindow()->TranslateKeyPress("TV Frontend", event, actions);

for (int i = 0; i < actions.size() && !handled; i++)
{
QString action = actions[i];
handled = true;

if (action == "DELETE")
{
if (GetFocusWidget() == m_clauseList)
deleteRule();
// else if (GetFocusWidget() == m_ruleList)
// deleteRecordingRule();
}
else
handled = false;
}

if (!handled && MythScreenType::keyPressEvent(event))
handled = true;

return handled;
}

1 change: 1 addition & 0 deletions mythtv/programs/mythfrontend/customedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class CustomEdit : public MythScreenType
~CustomEdit(void);

bool Create();
bool keyPressEvent(QKeyEvent *);
void customEvent(QEvent *event);

protected slots:
Expand Down

0 comments on commit a1c9456

Please sign in to comment.