Permalink
Browse files

Add support for the DELETE action to CustomEdit, allows deletion of e…

…xample clauses.
  • Loading branch information...
1 parent 2fc8d40 commit a1c9456e44142c3ddb5df383ef92365c1012ab5a @stuartm stuartm committed Feb 7, 2011
Showing with 34 additions and 1 deletion.
  1. +33 −1 mythtv/programs/mythfrontend/customedit.cpp
  2. +1 −0 mythtv/programs/mythfrontend/customedit.h
@@ -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());
@@ -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;
+}
+
@@ -19,6 +19,7 @@ class CustomEdit : public MythScreenType
~CustomEdit(void);
bool Create();
+ bool keyPressEvent(QKeyEvent *);
void customEvent(QEvent *event);
protected slots:

0 comments on commit a1c9456

Please sign in to comment.