Skip to content

Commit

Permalink
Allow to set a dependence on a StateType object
Browse files Browse the repository at this point in the history
A dependence is based on the StateType being visible, and all the children of that state to be visible
  • Loading branch information
jyavenard committed Jul 14, 2013
1 parent a098e4e commit 593b26a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions mythtv/libs/libmythui/mythuistatetype.cpp
Expand Up @@ -16,6 +16,7 @@ MythUIStateType::MythUIStateType(MythUIType *parent, const QString &name)
{
m_CurrentState = NULL;
m_ShowEmpty = true;
emit DependChanged(false);
}

MythUIStateType::~MythUIStateType()
Expand Down Expand Up @@ -112,6 +113,7 @@ bool MythUIStateType::DisplayState(const QString &name)
m_CurrentState->SetVisible(true);
}
}
AdjustDependence();

return (m_CurrentState != NULL);
}
Expand Down Expand Up @@ -141,6 +143,7 @@ bool MythUIStateType::DisplayState(StateType type)
m_CurrentState->SetVisible(true);
}
}
AdjustDependence();

return (m_CurrentState != NULL);
}
Expand Down Expand Up @@ -364,3 +367,23 @@ void MythUIStateType::RecalculateArea(bool recurse)
}
}

void MythUIStateType::AdjustDependence(void)
{
if (m_CurrentState == NULL || !m_CurrentState->IsVisible())
{
emit DependChanged(true);
return;
}
QList<MythUIType *> *children = m_CurrentState->GetAllChildren();
QList<MythUIType *>::iterator it = children->begin();

for (; it != children->end(); ++it)
{
if ((*it)->IsVisible())
{
emit DependChanged(false);
return;
}
}
emit DependChanged(true);
}
1 change: 1 addition & 0 deletions mythtv/libs/libmythui/mythuistatetype.h
Expand Up @@ -56,6 +56,7 @@ class MUI_PUBLIC MythUIStateType : public MythUIType
virtual void CopyFrom(MythUIType *base);
virtual void CreateCopy(MythUIType *parent);
virtual void Finalize(void);
virtual void AdjustDependence(void);

QMap<QString, MythUIType *> m_ObjectsByName;
QMap<int, MythUIType *> m_ObjectsByState;
Expand Down

0 comments on commit 593b26a

Please sign in to comment.