Permalink
Browse files

Allow to set a dependence on a StateType object

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 593b26ab85dc3fed0db26d9c22a4beb52686f312
Showing with 24 additions and 0 deletions.
  1. +23 −0 mythtv/libs/libmythui/mythuistatetype.cpp
  2. +1 −0 mythtv/libs/libmythui/mythuistatetype.h
@@ -16,6 +16,7 @@ MythUIStateType::MythUIStateType(MythUIType *parent, const QString &name)
{
m_CurrentState = NULL;
m_ShowEmpty = true;
emit DependChanged(false);
}
MythUIStateType::~MythUIStateType()
@@ -112,6 +113,7 @@ bool MythUIStateType::DisplayState(const QString &name)
m_CurrentState->SetVisible(true);
}
}
AdjustDependence();
return (m_CurrentState != NULL);
}
@@ -141,6 +143,7 @@ bool MythUIStateType::DisplayState(StateType type)
m_CurrentState->SetVisible(true);
}
}
AdjustDependence();
return (m_CurrentState != NULL);
}
@@ -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);
}
@@ -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;

0 comments on commit 593b26a

Please sign in to comment.