//----------------------------------------------------------------------------------------
// UpdateActionStates
//----------------------------------------------------------------------------------------
void
CZPAssetsTVActionComponent::UpdateActionStates(
	IActiveContext* ac, IActionStateList *listToUpdate, GSysPoint mousePoint, IPMUnknown* widget)
{
	do
	{
		int actionIDListLen = listToUpdate->Length();
		for(int i=0; i < actionIDListLen; ++i)
		{
			ActionID actionID = listToUpdate->GetNthAction(i);
			int16 state = listToUpdate->GetNthActionState(i);
			switch (actionID.Get())
			{
				case kIZPRenameAssetActionID:
				{
					if (this->CanRenameAsset(widget))
						state = kEnabledAction;
					else
						state = kDisabled_Unselected;
					break;
				}
				default:
					break;
			}
			listToUpdate->SetNthActionState(i, state);
		}
	}while(kFalse);
}
Esempio n. 2
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();
}
Esempio n. 3
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;
}
Esempio n. 4
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;
}
Esempio n. 5
0
/** \fn KeyBindings::CommitChanges(void)
 *  \brief Commit all changes made to the keybindings.
 *
 *   This method will write the changes to the database, unbind %MythTV's
 *   current bindings for those actions that changed, and setup the
 *   new bindings.
 */
void KeyBindings::CommitChanges(void)
{
    ActionList modified = m_actionSet.GetModified();

    while (modified.size() > 0)
    {
        ActionID id = modified.front();

        // commit either a jumppoint or an action
        if (id.GetContext() == ActionSet::kJumpContext)
            CommitJumppoint(id);
        else
            CommitAction(id);

        // tell the action set that the action is no longer modified
        m_actionSet.SetModifiedFlag(id, false);

        modified.pop_front();
    }
}
Esempio n. 6
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);
}
Esempio n. 7
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);
}
//----------------------------------------------------------------------------------------
// DoAction
//----------------------------------------------------------------------------------------
void
CZPAssetsTVActionComponent::DoAction(
	IActiveContext* ac, ActionID actionID, GSysPoint mousePoint, IPMUnknown* widget)
{
	LogFunctionEnterExit;
	
	switch (actionID.Get())
	{
		case kIZPRenameAssetActionID:
		{
			this->RenameAsset(widget);
			break;
		}
		default:
			break;
	}
}
/* DoAction
*/
void IDShortcutsActionComponent::DoAction(IActiveContext* ac, ActionID actionID, GSysPoint mousePoint, IPMUnknown* widget)
{
	switch (actionID.Get())
	{

		case kIDShortcutsPopupAboutThisActionID:
		case kIDShortcutsAboutActionID:
		{
			this->DoAbout();
			break;
		}
					


		default:
		{
			break;
		}
	}
}
//----------------------------------------------------------------------------------------
// RebuildMenu
//----------------------------------------------------------------------------------------
void
CZPTVHeaderDynamicMenu::RebuildMenu(
	ActionID					dynamicActionID,
	IPMUnknown*					widget)
{

	do
	{
		InterfacePtr<IActiveContext> ac(gSession->GetActiveContext(), UseDefaultIID());
		if(!ac)
			break;

		switch (dynamicActionID.Get())
		{
			case kIZMTVHeaderShowColumnsActionID:
				this->RebuildShowColumnsMenu( dynamicActionID, widget );
				break;
		}
	}while( false );
}
//----------------------------------------------------------------------------------------
// IsActionHidden
//----------------------------------------------------------------------------------------
bool16
CZPUISuppressedActions::IsActionHidden(
	ActionID action) const
{
	switch( action.Get() )
	{
		case kSLRelinkAssignmentActionID:					//Change assignment location.
		case kSLAssignmentOptionsActionID:					//Hide assignment options
		case kPackageAssignmentActionID:					//All package relation actions
		case kPackageAndEmailAssignmentActionID:
		case kForwardPackagedAssignmentActionID:
		case kForwardAndEmailPackagedAssignmentActionID:
		case kReturnPackagedAssignmentActionID:
		case kReturnAndEmailPackagedAssignmentActionID:
		case kOpenPackagedAssignmentActionID:
		case kCancelPackagedAssignmentActionID:
			return kTrue;
	}
	return kFalse;
}