Skip to content

Commit

Permalink
Add UI for new scheduler filters (see e0122d8 and 5241f65)
Browse files Browse the repository at this point in the history
Themes can now have <button name="filters"> in <window
name="scheduleeditor">, and if that exists, must define <window
name="schedulefiltereditor">

<window name="schedulefiltereditor"> requires <buttonlist name="filters">

I say "can now have", because this change does NOT require all themes to be
updated immediately.  However, at some point I expect gigem to change the
scheduler such that this does become a requirement.

Included in this change-set, are updates to default, default-wide,
MythCenter, MythCenter-wide and Terra to include the new elements.  The
original authors of those themes will probably want to look over the changes
and tweak them to fit their vision better.
  • Loading branch information
jpoet committed Jun 12, 2011
1 parent be25039 commit fec82bc
Show file tree
Hide file tree
Showing 7 changed files with 692 additions and 22 deletions.
169 changes: 161 additions & 8 deletions mythtv/programs/mythfrontend/scheduleeditor.cpp
Expand Up @@ -453,15 +453,18 @@ void ScheduleEditor::ShowPreview(void)
SchedOptEditor::SchedOptEditor(MythScreenStack *parent,
RecordingInfo *recInfo,
RecordingRule *rule)
: MythScreenType(parent, "ScheduleOptionsEditor"),
m_recInfo(NULL), m_recordingRule(rule),
m_backButton(NULL),
m_prioritySpin(NULL), m_inputList(NULL), m_startoffsetSpin(NULL),
m_endoffsetSpin(NULL), m_dupmethodList(NULL), m_dupscopeList(NULL),
m_ruleactiveCheck(NULL)
: MythScreenType(parent, "ScheduleOptionsEditor"),
m_recInfo(NULL), m_recordingRule(rule),
m_backButton(NULL),
m_prioritySpin(NULL), m_inputList(NULL), m_startoffsetSpin(NULL),
m_endoffsetSpin(NULL), m_dupmethodList(NULL), m_dupscopeList(NULL),
m_filtersButton(NULL), m_ruleactiveCheck(NULL)
{
if (recInfo)
m_recInfo = new RecordingInfo(*recInfo);
#if (ALLOW_MISSING_FILTERS)
m_missing_filters = false;
#endif
}

SchedOptEditor::~SchedOptEditor(void)
Expand All @@ -482,8 +485,13 @@ bool SchedOptEditor::Create()
UIUtilE::Assign(this, m_dupmethodList, "dupmethod", &err);
UIUtilE::Assign(this, m_dupscopeList, "dupscope", &err);

UIUtilE::Assign(this, m_ruleactiveCheck, "ruleactive", &err);
#if (ALLOW_MISSING_FILTERS)
UIUtilE::Assign(this, m_filtersButton, "filters", &m_missing_filters);
#else
UIUtilE::Assign(this, m_filtersButton, "filters", &err);
#endif

UIUtilE::Assign(this, m_ruleactiveCheck, "ruleactive", &err);
UIUtilE::Assign(this, m_backButton, "back", &err);

if (err)
Expand All @@ -499,10 +507,16 @@ bool SchedOptEditor::Create()
{
m_dupmethodList->SetEnabled(false);
m_dupscopeList->SetEnabled(false);
m_filtersButton->SetEnabled(false);
}

connect(m_dupmethodList, SIGNAL(itemSelected(MythUIButtonListItem *)),
SLOT(dupMatchChanged(MythUIButtonListItem *)));
SLOT(dupMatchChanged(MythUIButtonListItem *)));

#if (ALLOW_MISSING_FILTERS)
if (!m_missing_filters)
#endif
connect(m_filtersButton, SIGNAL(Clicked()), SLOT(ShowFilters()));

connect(m_backButton, SIGNAL(Clicked()), SLOT(Close()));

Expand Down Expand Up @@ -584,6 +598,10 @@ void SchedOptEditor::Load()
tr("Look for duplicates in previous recordings "
"only"),
ENUM_TO_QVARIANT(kDupsInOldRecorded));
#if (ALLOW_MISSING_FILTERS)
if (m_missing_filters)
{
#endif
new MythUIButtonListItem(m_dupscopeList,
tr("Exclude unidentified episodes"),
ENUM_TO_QVARIANT(kDupsExGeneric | kDupsInAll));
Expand All @@ -599,6 +617,10 @@ void SchedOptEditor::Load()
tr("Record new episode first showings"),
ENUM_TO_QVARIANT(kDupsFirstNew | kDupsInAll));
}
#if (ALLOW_MISSING_FILTERS)
}
#endif

m_dupscopeList->SetValueByData(ENUM_TO_QVARIANT(m_recordingRule->m_dupIn));

// Active/Disabled
Expand Down Expand Up @@ -657,6 +679,137 @@ void SchedOptEditor::Close()
MythScreenType::Close();
}

void SchedOptEditor::ShowFilters(void)
{
MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
SchedFilterEditor *schedfilteredit = new SchedFilterEditor(mainStack,
m_recInfo,
m_recordingRule);
if (schedfilteredit->Create())
mainStack->AddScreen(schedfilteredit);
else
delete schedfilteredit;
}

////////////////////////////////////////////////////////

/** \class SchedFilterEditor
* \brief Select schedule filters
*
*/

SchedFilterEditor::SchedFilterEditor(MythScreenStack *parent,
RecordingInfo *recInfo,
RecordingRule *rule)
: MythScreenType(parent, "ScheduleFilterEditor"),
m_recInfo(NULL), m_recordingRule(rule),
m_backButton(NULL), m_filtersList(NULL)
{
if (recInfo)
m_recInfo = new RecordingInfo(*recInfo);
}

SchedFilterEditor::~SchedFilterEditor(void)
{
}

bool SchedFilterEditor::Create()
{
if (!LoadWindowFromXML("schedule-ui.xml", "schedulefiltereditor", this))
return false;

bool err = false;

UIUtilE::Assign(this, m_filtersList, "filters", &err);
UIUtilE::Assign(this, m_backButton, "back", &err);

if (err)
{
VERBOSE(VB_IMPORTANT, "SchedFilterEditor, theme is missing "
"required elements");
return false;
}

connect(m_backButton, SIGNAL(Clicked()), SLOT(Close()));

connect(m_filtersList, SIGNAL(itemClicked(MythUIButtonListItem *)),
SLOT(ToggleSelected(MythUIButtonListItem *)));
BuildFocusList();

return true;
}

void SchedFilterEditor::Load()
{
MSqlQuery query(MSqlQuery::InitCon());

query.prepare("SELECT filterid, description, newruledefault "
"FROM recordfilter ORDER BY filterid");

if (query.exec())
{
MythUIButtonListItem *button;

while (query.next())
{
uint32_t filterid = query.value(0).toInt();
QString description = query.value(1).toString();
bool filter_default = query.value(2).toInt();

// Fill in list of possible filters
button = new MythUIButtonListItem(m_filtersList,
// tr(description),
description, filterid);
button->setCheckable(true);
if (m_recordingRule->IsLoaded())
button->setChecked(m_recordingRule->m_filter & (1 << filterid) ?
MythUIButtonListItem::FullChecked :
MythUIButtonListItem::NotChecked);
else
button->setChecked(filter_default ?
MythUIButtonListItem::FullChecked :
MythUIButtonListItem::NotChecked);
}
}

InfoMap progMap;
if (m_recInfo)
m_recInfo->ToMap(progMap);
else
m_recordingRule->ToMap(progMap);
SetTextFromMap(progMap);
}

void SchedFilterEditor::ToggleSelected(MythUIButtonListItem *item)
{
item->setChecked(item->state() == MythUIButtonListItem::FullChecked ?
MythUIButtonListItem::NotChecked :
MythUIButtonListItem::FullChecked);
}

void SchedFilterEditor::Save()
{
// Iterate through button list, and build the mask
MythUIButtonListItem *button;
uint32_t filter_mask = 0;
int idx, end;

end = m_filtersList->GetCount();
for (idx = 0; idx < end; ++idx)
{
if ((button = m_filtersList->GetItemAt(idx)) &&
button->state() == MythUIButtonListItem::FullChecked)
filter_mask |= (1 << qVariantValue<uint32_t>(button->GetData()));
}
m_recordingRule->m_filter = filter_mask;
}

void SchedFilterEditor::Close()
{
Save();
MythScreenType::Close();
}

/////////////////////////////

/** \class StoreOptEditor
Expand Down
35 changes: 35 additions & 0 deletions mythtv/programs/mythfrontend/scheduleeditor.h
Expand Up @@ -14,6 +14,10 @@
#include "recordingrule.h"
#include "recordinginfo.h"

#ifndef ALLOW_MISSING_FILTERS
#define ALLOW_MISSING_FILTERS 1
#endif

class ProgramInfo;
class MythUIText;
class MythUIButton;
Expand Down Expand Up @@ -91,6 +95,7 @@ class SchedOptEditor : public MythScreenType

protected slots:
void dupMatchChanged(MythUIButtonListItem *item);
void ShowFilters(void);
void Close(void);

private:
Expand All @@ -108,8 +113,38 @@ class SchedOptEditor : public MythScreenType
MythUISpinBox *m_endoffsetSpin;
MythUIButtonList *m_dupmethodList;
MythUIButtonList *m_dupscopeList;
MythUIButton *m_filtersButton;

MythUICheckBox *m_ruleactiveCheck;

#if (ALLOW_MISSING_FILTERS)
bool m_missing_filters;
#endif
};

class SchedFilterEditor : public MythScreenType
{
Q_OBJECT
public:
SchedFilterEditor(MythScreenStack *parent, RecordingInfo *recinfo,
RecordingRule *rule);
~SchedFilterEditor();

bool Create(void);

protected slots:
void Close(void);
void ToggleSelected(MythUIButtonListItem *item);

private:
void Load(void);
void Save(void);

RecordingInfo *m_recInfo;
RecordingRule *m_recordingRule;

MythUIButton *m_backButton;
MythUIButtonList *m_filtersList;
};

class StoreOptEditor : public MythScreenType
Expand Down
89 changes: 87 additions & 2 deletions mythtv/themes/MythCenter-wide/schedule-ui.xml
Expand Up @@ -1871,19 +1871,104 @@
<helptext></helptext>
</buttonlist>

<checkbox name="ruleactive" from="basecheckbox">
<button name="filters" from="basewidebutton">
<position>250,580</position>
<value>Schedule filters</value>
<helptext></helptext>
</button>

<checkbox name="ruleactive" from="basecheckbox">
<position>620,584</position>
</checkbox>

<textarea name="ruleactivelabel" from="basetextarea">
<area>500,582,300,30</area>
<area>655,586,300,30</area>
<value>Recording Rule Active</value>
</textarea>

<button name="back" from="basebutton">
<position>550,644</position>
<value>Back</value>
</button>

</window>

<window name="schedulefiltereditor">

<shape name="details_background" from="basebackground">
<area>24,24,1230,276</area>
</shape>

<textarea name="title" from="basetextarea">
<area>50,34,1180,46</area>
<font>baselarge</font>
</textarea>

<textarea name="timedate" from="basetextarea">
<area>50,270,440,28</area>
</textarea>

<textarea name="channel" from="basetextarea">
<area>1024,270,200,36</area>
<align>right</align>
</textarea>

<textarea name="description" from="basetextarea">
<area>50,70,1180,200</area>
<multiline>yes</multiline>
<template>%"|SUBTITLE|" %%LONGREPEAT%%(|STARS|) %%DESCRIPTION%</template>
</textarea>

<buttonlist name="filters" from="basebuttonlist">
<area>370,310,540,328</area>
<layout>vertical</layout>
<spacing>0</spacing>
<scrollstyle>free</scrollstyle>
<wrapstyle>items</wrapstyle>
<buttonarea>5,5,530,328</buttonarea>
<statetype name="buttonitem">
<state name="active">
<area>0,0,500,40</area>
<textarea name="buttontext">
<area>50,5,-5,30</area>
</textarea>
<statetype name="buttoncheck">
<position>5,10</position>
<state type="off">
<imagetype name="checkoff">
<filename>lb-check-empty.png</filename>
</imagetype>
</state>
<state type="half">
<imagetype name="checkhalf">
<filename>lb-check-half.png</filename>
</imagetype>
</state>
<state type="full">
<imagetype name="checkfull">
<filename>lb-check-full.png</filename>
</imagetype>
</state>
</statetype>
</state>
<state name="selectedactive" from="active">
<shape name="background" from="baseselectedwidgetshape" />
</state>
<state name="selectedinactive" from="active" />
</statetype>
<statetype name="upscrollarrow">
<position>510,5</position>
</statetype>
<statetype name="downscrollarrow">
<position>510,305</position>
</statetype>
</buttonlist>

<button name="back" from="basebutton">
<position>550,646</position>
<value>Back</value>
</button>

</window>

<window name="storageoptionseditor">
Expand Down

0 comments on commit fec82bc

Please sign in to comment.