Skip to content

Commit

Permalink
mythtv-setup: Change the xmltvid setting to an editable combo and fil…
Browse files Browse the repository at this point in the history
…l with ids.

Attempts to load some xmltvids for the source the channel belongs to make it
easier to set the correct xmltvid for the channel.
  • Loading branch information
Paul Harrison committed May 1, 2011
1 parent 9102f59 commit e73e476
Showing 1 changed file with 52 additions and 7 deletions.
59 changes: 52 additions & 7 deletions mythtv/libs/libmythtv/channelsettings.cpp
@@ -1,9 +1,11 @@
#include <QWidget>
#include <QFile>

#include "channelsettings.h"
#include "cardutil.h"
#include "channelutil.h"
#include "programinfo.h" // for COMM_DETECT*, GetPreferredSkipTypeCombinations()
#include "mythdirs.h"

QString ChannelDBStorage::GetWhereClause(MSqlBindings &bindings) const
{
Expand Down Expand Up @@ -229,12 +231,12 @@ class OutputFilters : public LineEditSetting, public ChannelDBStorage
}
};


class XmltvID : public LineEditSetting, public ChannelDBStorage
class XmltvID : public ComboBoxSetting, public ChannelDBStorage
{
public:
XmltvID(const ChannelID &id) :
LineEditSetting(this), ChannelDBStorage(this, id, "xmltvid")
XmltvID(const ChannelID &id, const QString &_sourceName) :
ComboBoxSetting(this, true), ChannelDBStorage(this, id, "xmltvid"),
sourceName(_sourceName)
{
setLabel(QObject::tr("XMLTV ID"));
setHelpText(QObject::tr(
Expand All @@ -243,6 +245,47 @@ class XmltvID : public LineEditSetting, public ChannelDBStorage
"and a channel in their database. Normally this is "
"set automatically when 'mythfilldatabase' is run."));
}

void Load(void)
{
fillSelections();
ChannelDBStorage::Load();
}

void fillSelections(void)
{
clearSelections();

QString xmltvFile = GetConfDir() + '/' + sourceName + ".xmltv";

if (QFile::exists(xmltvFile))
{
QFile file(xmltvFile);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;

QStringList idList;

while (!file.atEnd())
{
QByteArray line = file.readLine();

if (line.startsWith("channel="))
{
QString id = line.mid(8, -1).trimmed();
idList.append(id);
}
}

idList.sort();

for (int x = 0; x < idList.size(); x++)
addSelection(idList.at(x), idList.at(x));
}
}

private:
QString sourceName;
};

class CommMethod : public ComboBoxSetting, public ChannelDBStorage
Expand Down Expand Up @@ -375,11 +418,12 @@ ChannelOptionsCommon::ChannelOptionsCommon(const ChannelID &id,
addChild(new Name(id));

Source *source = new Source(id, default_sourceid);
source->Load();

HorizontalConfigurationGroup *group1 =
new HorizontalConfigurationGroup(false,false,true,true);
HorizontalConfigurationGroup *bottomhoz =
new HorizontalConfigurationGroup(false, true);
VerticalConfigurationGroup *bottomhoz =
new VerticalConfigurationGroup(false, true);
VerticalConfigurationGroup *left =
new VerticalConfigurationGroup(false, true);
VerticalConfigurationGroup *right =
Expand All @@ -398,7 +442,7 @@ ChannelOptionsCommon::ChannelOptionsCommon(const ChannelID &id,
group1->addChild(right);

bottomhoz->addChild(onairguide = new OnAirGuide(id));
bottomhoz->addChild(xmltvID = new XmltvID(id));
bottomhoz->addChild(xmltvID = new XmltvID(id, source->getSelectionLabel()));
bottomhoz->addChild(new TimeOffset(id));

addChild(group1);
Expand Down Expand Up @@ -465,6 +509,7 @@ void ChannelOptionsCommon::sourceChanged(const QString& sourceid)

onairguide->setEnabled(supports_eit);
xmltvID->setEnabled(!uses_eit_only);
xmltvID->Load();
}

ChannelOptionsFilters::ChannelOptionsFilters(const ChannelID& id) :
Expand Down

0 comments on commit e73e476

Please sign in to comment.