Ejemplo n.º 1
0
/** \fn KeyBindings::CommitAction(const ActionID&)
 *  \brief Commit an action to the database, and reload its keybindings.
 */
void KeyBindings::CommitAction(const ActionID &id)
{
    MSqlQuery query(MSqlQuery::InitCon());
    query.prepare(
        "UPDATE keybindings "
        "SET keylist = :KEYLIST "
        "WHERE hostname = :HOSTNAME AND "
        "      action   = :ACTION   AND "
        "      context  = :CONTEXT");

    QString keys = m_actionSet.GetKeyString(id);
    query.bindValue(":KEYLIST",  keys);
    query.bindValue(":HOSTNAME", m_hostname);
    query.bindValue(":CONTEXT",  id.GetContext());
    query.bindValue(":ACTION",   id.GetAction());

    if (!query.exec() || !query.isActive())
    {
        MythDB::DBError("KeyBindings::CommitAction", query);
        return;
    }

    GetMythMainWindow()->ClearKey(id.GetContext(), id.GetAction());
    GetMythMainWindow()->BindKey(id.GetContext(), id.GetAction(), keys);
}
Ejemplo n.º 2
0
/** \fn ActionSet::AddAction(const ActionID&, const QString&, const QString&)
 *  \brief Add an action.
 *
 *   If the action has already been added, it will not be added
 *   again. There are no duplicate actions in the action set.
 *
 *  \param id The action identifier.
 *  \param description The action description.
 *  \param keys The keys for this action.
 *  \return true if the action on success, false otherwise.
 */
bool ActionSet::AddAction(const ActionID &id,
                          const QString  &description,
                          const QString  &keys)
{
    ContextMap::iterator cit = m_contexts.find(id.GetContext());
    if (cit == m_contexts.end())
        cit = m_contexts.insert(id.GetContext(), Context());
    else if ((*cit).find(id.GetAction()) != (*cit).end())
        return false;

    Action *a = new Action(description, keys);
    (*cit).insert(id.GetAction(), a);

    const QStringList keylist = a->GetKeys();
    QStringList::const_iterator it = keylist.begin();
    for (; it != keylist.end(); ++it)
        m_keyToActionMap[*it].push_back(id);

    return true;
}
Ejemplo n.º 3
0
/** \fn ActionSet::GetDescription(const ActionID&) const
 *  \brief Returns the description of an action by its identifier.
 */
QString ActionSet::GetDescription(const ActionID &id) const
{
    ContextMap::const_iterator cit = m_contexts.find(id.GetContext());
    if (cit == m_contexts.end())
        return QString();

    Context::const_iterator it = (*cit).find(id.GetAction());
    if (it != (*cit).end())
        return (*it)->GetDescription();

    return QString();
}
Ejemplo n.º 4
0
/** \fn KeyBindings::CommitJumppoint(const ActionID&)
 *  \brief Commit a jumppoint to the database.
 *
 *   TODO FIXME This does not reload the jumppoint.
 */
void KeyBindings::CommitJumppoint(const ActionID &id)
{
    MSqlQuery query(MSqlQuery::InitCon());
    query.prepare(
        "UPDATE jumppoints "
        "SET keylist = :KEYLIST "
        "WHERE hostname    = :HOSTNAME AND"
        "      destination = :DESTINATION");

    QString keys = m_actionSet.GetKeyString(id);
    query.bindValue(":KEYLIST",     keys);
    query.bindValue(":HOSTNAME",    m_hostname);
    query.bindValue(":DESTINATION", id.GetAction());

    if (!query.exec() || !query.isActive())
    {
        MythDB::DBError("KeyBindings::CommitJumppoint", query);
        return;
    }

    GetMythMainWindow()->ClearJump(id.GetAction());
    GetMythMainWindow()->BindJump(id.GetAction(), keys);
}
Ejemplo n.º 5
0
/** \fn ActionSet::GetKeys(const ActionID&) const
 *  \brief Get the keys bound to an action by its identifier.
 */
QStringList ActionSet::GetKeys(const ActionID &id) const
{
    QStringList keys;

    ContextMap::const_iterator cit = m_contexts.find(id.GetContext());
    if (cit == m_contexts.end())
        return keys;

    Context::const_iterator it = (*cit).find(id.GetAction());
    if (it != (*cit).end())
        keys = (*it)->GetKeys();

    keys.detach();
    return keys;
}