Skip to content

Commit

Permalink
Fix a couple of problems that was making the <group> widget unusable.
Browse files Browse the repository at this point in the history
This fixes MythUIType::GetChild() to search not only the immediate children
but will also search the children of any groups.

Also fixes MythScreenType::SetTextFromMap() and MythScreenType::ResetMap()
to work properly with groups.
  • Loading branch information
Paul Harrison committed Dec 27, 2010
1 parent a55b7bd commit 1c69f1b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
29 changes: 24 additions & 5 deletions mythtv/libs/libmythui/mythscreentype.cpp
Expand Up @@ -13,6 +13,7 @@
#include "mythmainwindow.h"
#include "mythuihelper.h"
#include "mythprogressdialog.h"
#include "mythuigroup.h"

QEvent::Type ScreenLoadCompletionEvent::kEventType =
(QEvent::Type) QEvent::registerEventType();
Expand All @@ -32,7 +33,6 @@ class ScreenLoadTask : public QRunnable
MythScreenType *m_parent;
};


MythScreenType::MythScreenType(MythScreenStack *parent, const QString &name,
bool fullscreen)
: MythUIType(parent, name)
Expand Down Expand Up @@ -358,9 +358,9 @@ void MythScreenType::ShowMenu(void)
// Virtual
}

void MythScreenType::SetTextFromMap(QHash<QString, QString> &infoMap)
static void DoSetTextFromMap(MythUIType *UItype, QHash<QString, QString> &infoMap)
{
QList<MythUIType *> *children = GetAllChildren();
QList<MythUIType *> *children = UItype->GetAllChildren();

MythUIText *textType;

Expand All @@ -374,15 +374,25 @@ void MythScreenType::SetTextFromMap(QHash<QString, QString> &infoMap)
textType = dynamic_cast<MythUIText *> (type);
if (textType && infoMap.contains(textType->objectName()))
textType->SetTextFromMap(infoMap);


MythUIGroup *group = dynamic_cast<MythUIGroup *> (type);
if (group)
DoSetTextFromMap(type, infoMap);
}
}

void MythScreenType::ResetMap(QHash<QString, QString> &infoMap)
void MythScreenType::SetTextFromMap(QHash<QString, QString> &infoMap)
{
DoSetTextFromMap((MythUIType*) this, infoMap);
}

static void DoResetMap(MythUIType *UItype, QHash<QString, QString> &infoMap)
{
if (infoMap.isEmpty())
return;

QList<MythUIType *> *children = GetAllChildren();
QList<MythUIType *> *children = UItype->GetAllChildren();

MythUIText *textType;
QMutableListIterator<MythUIType *> i(*children);
Expand All @@ -395,9 +405,18 @@ void MythScreenType::ResetMap(QHash<QString, QString> &infoMap)
textType = dynamic_cast<MythUIText *> (type);
if (textType && infoMap.contains(textType->objectName()))
textType->Reset();

MythUIGroup *group = dynamic_cast<MythUIGroup *> (type);
if (group)
DoResetMap(type, infoMap);
}
}

void MythScreenType::ResetMap(QHash<QString, QString> &infoMap)
{
DoResetMap(this, infoMap);
}

bool MythScreenType::keyPressEvent(QKeyEvent *event)
{
if (m_CurrentFocusWidget && m_CurrentFocusWidget->keyPressEvent(event))
Expand Down
5 changes: 3 additions & 2 deletions mythtv/libs/libmythui/mythuitype.cpp
Expand Up @@ -112,7 +112,8 @@ static QObject *qChildHelper(const char *objName, const char *inheritsClass,
else if ((!inheritsClass || obj->inherits(inheritsClass))
&& (!objName || obj->objectName() == oName))
return obj;
if (recursiveSearch && (obj = qChildHelper(objName, inheritsClass,
if (recursiveSearch && (dynamic_cast<MythUIGroup *>(obj) != NULL)
&& (obj = qChildHelper(objName, inheritsClass,
recursiveSearch,
obj->children())))
return obj;
Expand All @@ -128,7 +129,7 @@ static QObject *qChildHelper(const char *objName, const char *inheritsClass,
*/
MythUIType *MythUIType::GetChild(const QString &name) const
{
QObject *ret = qChildHelper(name.toAscii().constData(), NULL, false, children());
QObject *ret = qChildHelper(name.toAscii().constData(), NULL, true, children());
if (ret)
return dynamic_cast<MythUIType *>(ret);

Expand Down

0 comments on commit 1c69f1b

Please sign in to comment.