Ticket #2793: 2793-v4.patch

File 2793-v4.patch, 14.1 KB (added by danielk, 17 years ago)

Updated patch

  • libs/libmythtv/videosource.h

     
    588588{
    589589    Q_OBJECT
    590590  public:
    591     CardInput(bool is_dtv_card, bool is_dvb_card, int cardid);
     591    CardInput(bool is_dtv_card, bool is_dvb_card,
     592              bool is_new_input, int cardid);
    592593    ~CardInput();
    593594
    594595    int getInputID(void) const { return id->intValue(); };
     
    605606  public slots:
    606607    void channelScanner();
    607608    void sourceFetch();
    608     void diseqcConfig();
    609609    void SetSourceID(const QString &sourceid);
    610610
    611611  private:
  • libs/libmythtv/cardutil.cpp

     
    766766    QStringList::iterator it = inputs.begin();
    767767    for (; it != inputs.end(); ++it)
    768768    {
    769         CardInput* cardinput = new CardInput(is_dtv, false, cardid);
     769        CardInput* cardinput = new CardInput(is_dtv, false, false, cardid);
    770770        cardinput->loadByInput(rcardid, (*it));
    771771        cardinput->SetChildCardID((parentid) ? cardid : 0);
    772772        inputLabels.push_back(
     
    787787        InputNames::const_iterator it;
    788788        for (it = list.begin(); it != list.end(); ++it)
    789789        {
    790             CardInput *cardinput = new CardInput(is_dtv, true, rcardid);
     790            CardInput *cardinput = new CardInput(is_dtv, true, false, rcardid);
    791791            cardinput->loadByInput(rcardid, *it);
    792792            cardinput->SetChildCardID(parentid ? cardid : 0);
    793793            inputLabels.push_back(
     
    799799        // plus add one "new" input
    800800        if (needs_conf)
    801801        {
    802             CardInput *newcard = new CardInput(is_dtv, true, rcardid);
     802            CardInput *newcard = new CardInput(is_dtv, true, true, rcardid);
    803803            QString newname = QString("DVBInput #%1").arg(list.size() + 1);
    804804            newcard->loadByInput(rcardid, newname);
    805805            newcard->SetChildCardID((parentid) ? cardid : 0);
  • libs/libmythtv/videosource.cpp

     
    17361736    };
    17371737};
    17381738
    1739 CardInput::CardInput(bool isDTVcard, bool isDVBcard, int _cardid) :
     1739CardInput::CardInput(bool isDTVcard,  bool isDVBcard,
     1740                     bool isNewInput, int _cardid) :
     1741    id(new ID()),
     1742    cardid(new CardID(*this)),
     1743    childid(),
     1744    inputname(new InputName(*this)),
     1745    sourceid(new SourceID(*this)),
     1746    startchan(new StartingChannel(*this)),
     1747    scan(new TransButtonSetting()),
     1748    srcfetch(new TransButtonSetting()),
    17401749    externalInputSettings(new DiSEqCDevSettings())
    17411750{
    1742     (void) _cardid;
     1751    addChild(id);
    17431752
    1744     addChild(id = new ID());
     1753    if (CardUtil::IsInNeedOfExternalInputConf(_cardid))
     1754    {
     1755        addChild(new DTVDeviceConfigGroup(*externalInputSettings,
     1756                                          _cardid, isNewInput));
     1757    }
    17451758
    17461759    ConfigurationGroup *group =
    17471760        new VerticalConfigurationGroup(false, false, true, true);
     
    17501763
    17511764    HorizontalConfigurationGroup *ci;
    17521765    ci = new HorizontalConfigurationGroup(false, false);
    1753     ci->addChild(cardid = new CardID(*this));
    1754     ci->addChild(inputname = new InputName(*this));
     1766    ci->addChild(cardid);
     1767    ci->addChild(inputname);
    17551768    group->addChild(ci);
    17561769    group->addChild(new InputDisplayName(*this));
    1757     group->addChild(sourceid = new SourceID(*this));
     1770    group->addChild(sourceid);
    17581771    if (!isDVBcard)
    17591772    {
    17601773        group->addChild(new ExternalChannelCommand(*this));
     
    17701783        group->addChild(chgroup);
    17711784    }
    17721785
    1773 #ifdef USING_DVB
    17741786    if (isDVBcard)
    17751787    {
    1776         TransButtonSetting *diseqc = new TransButtonSetting();
    1777         diseqc->setLabel(tr("DVB-S"));
    1778         diseqc->setHelpText(tr("Input and satellite settings."));
    1779         diseqc->setVisible(CardUtil::IsInNeedOfExternalInputConf(_cardid));
    1780         group->addChild(diseqc);
    1781         connect(diseqc, SIGNAL(pressed()), SLOT(diseqcConfig()));
    1782    
    17831788        ConfigurationGroup *chgroup =
    17841789            new HorizontalConfigurationGroup(false, false, true, true);
    17851790        chgroup->addChild(new RadioServices(*this));
    17861791        chgroup->addChild(new DishNetEIT(*this));
    17871792        group->addChild(chgroup);
    17881793    }
    1789 #endif
    17901794
    1791     scan = new TransButtonSetting();
    17921795    scan->setLabel(tr("Scan for channels"));
    17931796    scan->setHelpText(
    17941797        tr("Use channel scanner to find channels for this input."));
    17951798
    1796     srcfetch = new TransButtonSetting();
    17971799    srcfetch->setLabel(tr("Fetch channels from listings source"));
    17981800    srcfetch->setHelpText(
    17991801        tr("This uses the listings data source to "
     
    18061808    sgrp->addChild(srcfetch);
    18071809    group->addChild(sgrp);
    18081810
    1809     startchan = new StartingChannel(*this);
    18101811    group->addChild(startchan);
    18111812    group->addChild(new InputPriority(*this));
    18121813
     
    19221923    }
    19231924}
    19241925
    1925 void CardInput::diseqcConfig(void)
    1926 {
    1927 #ifdef USING_DVB
    1928     DTVDeviceConfigWizard wizard(*externalInputSettings,
    1929                                  cardid->getValue().toUInt());
    1930     wizard.exec();
    1931 #endif // USING_DVB
    1932 }
    1933 
    19341926QString CardInputDBStorage::whereClause(MSqlBindings& bindings)
    19351927{
    19361928    QString cardinputidTag(":WHERECARDINPUTID");
  • libs/libmythtv/diseqcsettings.cpp

     
    356356    return str;
    357357}
    358358
    359 static double AngleToFloat(const QString &angle)
     359static double AngleToEdit(double angle, QString &hemi)
    360360{
     361    if (angle > 0.0)
     362    {
     363        hemi = "E";
     364        return angle;
     365    }
     366
     367    hemi = "W";
     368    return -angle;
     369}
     370
     371static double AngleToFloat(const QString &angle, bool translated = true)
     372{
    361373    if (angle.length() < 2)
    362374        return 0.0;
    363375
     
    366378    if (postfix.isLetter())
    367379    {
    368380        pos = angle.left(angle.length() - 1).toDouble();
    369         if (postfix.upper() == DeviceTree::tr("W", "Western Hemisphere"))
     381        if ((translated &&
     382             (postfix.upper() == DeviceTree::tr("W", "Western Hemisphere"))) ||
     383            (!translated && (postfix.upper() == "W")))
     384        {
    370385            pos = -pos;
     386        }
    371387    }
    372388    else
    373389        pos = angle.toDouble();
     
    11631179
    11641180//////////////////////////////////////// USALSRotorSetting
    11651181
    1166 class USALSRotorSetting : public LineEditSetting, public Storage
     1182class USALSRotorSetting : public HorizontalConfigurationGroup
    11671183{
    11681184  public:
    11691185    USALSRotorSetting(DiSEqCDevDevice &node, DiSEqCDevSettings &settings) :
    1170         LineEditSetting(this), m_node(node), m_settings(settings)
     1186        HorizontalConfigurationGroup(false, false, true, true),
     1187        numeric(new TransLineEditSetting()),
     1188        hemisphere(new TransComboBoxSetting(false)),
     1189        m_node(node), m_settings(settings)
    11711190    {
    1172         setLabel(node.GetDescription());
    1173         QString help = DeviceTree::tr(
    1174             "The longitude of the satellite you are aiming at, in degrees. "
    1175             "In the Western hemisphere use 'W' as the suffix. "
    1176             "In the Eastern hemisphere use 'E' as the suffix. ");
    1177         setHelpText(help);
     1191        QString help =
     1192            DeviceTree::tr(
     1193                "Locates the satelite you wish to point to "
     1194                "with the longitude along the Clarke Belt of"
     1195                "the satellite [-180..180] and its hemisphere.");
     1196
     1197        numeric->setLabel(DeviceTree::tr("Longitude (degrees)"));
     1198        numeric->setHelpText(help);
     1199        hemisphere->setLabel(DeviceTree::tr("Hemisphere"));
     1200        hemisphere->addSelection(DeviceTree::tr("Eastern"), "E", false);
     1201        hemisphere->addSelection(DeviceTree::tr("Western"), "W", true);
     1202        hemisphere->setHelpText(help);
     1203
     1204        addChild(numeric);
     1205        addChild(hemisphere);
    11781206    }
    11791207
    11801208    virtual void load(void)
    11811209    {
    1182         setValue(AngleToString(m_settings.GetValue(m_node.GetDeviceID())));
     1210        double  val  = m_settings.GetValue(m_node.GetDeviceID());
     1211        QString hemi = QString::null;
     1212        double  eval = AngleToEdit(val, hemi);
     1213        numeric->setValue(QString::number(eval));
     1214        hemisphere->setValue(hemisphere->getValueIndex(hemi));
    11831215    }
    11841216
    11851217    virtual void save(void)
    11861218    {
    1187         m_settings.SetValue(m_node.GetDeviceID(), AngleToFloat(getValue()));
     1219        QString val = QString::number(numeric->getValue().toDouble());
     1220        val += hemisphere->getValue();
     1221        m_settings.SetValue(m_node.GetDeviceID(), AngleToFloat(val, false));
    11881222    }
    11891223
    11901224    virtual void save(QString /*destination*/) { }
    11911225
    11921226  private:
    1193     DiSEqCDevDevice   &m_node;
    1194     DiSEqCDevSettings &m_settings;
     1227    TransLineEditSetting *numeric;
     1228    TransComboBoxSetting *hemisphere;
     1229    DiSEqCDevDevice      &m_node;
     1230    DiSEqCDevSettings    &m_settings;
    11951231};
    11961232
    1197 //////////////////////////////////////// DTVDeviceConfigWizard
     1233//////////////////////////////////////// DTVDeviceConfigGroup
    11981234
    1199 DTVDeviceConfigWizard::DTVDeviceConfigWizard(DiSEqCDevSettings &settings,
    1200                                              uint cardid)
    1201     : m_settings(settings)
     1235DTVDeviceConfigGroup::DTVDeviceConfigGroup(
     1236    DiSEqCDevSettings &settings, uint cardid, bool switches_enabled) :
     1237    VerticalConfigurationGroup(false, false, true, true),
     1238    m_settings(settings), m_switches_enabled(switches_enabled)
    12021239{
    1203     ConfigurationGroup *group =
    1204         new VerticalConfigurationGroup(false, false);
    1205     group->setLabel(DeviceTree::tr("DTV Device Configuration"));
     1240    setLabel(DeviceTree::tr("DTV Device Configuration"));
    12061241
    12071242    // load
    12081243    m_tree.Load(cardid);
    12091244
    12101245    // initial UI setup
    1211     AddNodes(*group, m_tree.Root());
    1212     SelectNodes();
    1213 
    1214     addChild(group);
     1246    AddNodes(this, QString::null, m_tree.Root());
    12151247}
    12161248
    1217 DTVDeviceConfigWizard::~DTVDeviceConfigWizard(void)
     1249DTVDeviceConfigGroup::~DTVDeviceConfigGroup(void)
    12181250{
    12191251}
    12201252
    1221 void DTVDeviceConfigWizard::AddNodes(ConfigurationGroup &group,
    1222                                      DiSEqCDevDevice    *node)
     1253void DTVDeviceConfigGroup::AddNodes(
     1254    ConfigurationGroup *group, const QString &trigger, DiSEqCDevDevice *node)
    12231255{
    12241256    if (!node)
    12251257        return;
     
    12291261    {
    12301262        case DiSEqCDevDevice::kTypeSwitch:
    12311263            setting = new SwitchSetting(*node, m_settings);
    1232             connect(setting, SIGNAL(valueChanged(const QString&)),
    1233                     SLOT(SelectNodes()));
     1264            setting->setEnabled(m_switches_enabled);
    12341265            break;
    12351266        case DiSEqCDevDevice::kTypeRotor:
    12361267        {
     
    12451276            break;
    12461277    }
    12471278
    1248     if (setting)
     1279    if (!setting)
    12491280    {
    1250         // add this node
    1251         m_devs[node->GetDeviceID()] = setting;
    1252         group.addChild(setting);
     1281        AddChild(group, trigger, new TransLabelSetting());
     1282        return;
    12531283    }
    12541284
    1255     // add children
     1285    m_devs[node->GetDeviceID()] = setting;
     1286
    12561287    uint num_ch = node->GetChildCount();
    1257     for (uint ch = 0; ch < num_ch; ch++)
    1258         AddNodes(group, node->GetChild(ch));
    1259 }
     1288    if (DiSEqCDevDevice::kTypeSwitch == node->GetDeviceType())
     1289    {
     1290        bool useframe = (node != m_tree.Root());
     1291        bool zerospace = !useframe;
     1292        TriggeredConfigurationGroup *cgrp = new TriggeredConfigurationGroup(
     1293            false, useframe, true, true, false, false, true, zerospace);
    12601294
    1261 void DTVDeviceConfigWizard::SelectNodes(void)
    1262 {
    1263     ConfigurationWizard::save();
     1295        cgrp->addChild(setting);
     1296        cgrp->setTrigger(setting);
    12641297
    1265     QMap<uint,bool> active;
    1266     DiSEqCDevDevice *node = m_tree.Root();
    1267     while (node)
     1298        for (uint i = 0; i < num_ch; i++)
     1299            AddNodes(cgrp, QString::number(i), node->GetChild(i));
     1300
     1301        AddChild(group, trigger, cgrp);
     1302        return;
     1303    }
     1304
     1305    if (!num_ch)
    12681306    {
    1269         active[node->GetDeviceID()] = true;
    1270         node = node->GetSelectedChild(m_settings);
     1307        AddChild(group, trigger, setting);
     1308        return;
    12711309    }
    12721310
    1273     devid_to_setting_t::iterator it = m_devs.begin();
    1274     for (; it != m_devs.end(); ++it)
    1275         (*it)->setEnabled(active[it.key()]);
     1311    VerticalConfigurationGroup *cgrp =
     1312        new VerticalConfigurationGroup(false, false, true, true);
     1313
     1314    AddChild(cgrp, QString::null, setting);
     1315    for (uint i = 0; i < num_ch; i++)
     1316        AddNodes(cgrp, QString::null, node->GetChild(i));
     1317
     1318    AddChild(group, trigger, cgrp);
    12761319}
    12771320
     1321void DTVDeviceConfigGroup::AddChild(
     1322    ConfigurationGroup *group, const QString &trigger, Setting *setting)
     1323{
     1324    TriggeredConfigurationGroup *grp =
     1325        dynamic_cast<TriggeredConfigurationGroup*>(group);
     1326
     1327    if (grp && !trigger.isEmpty())
     1328        grp->addTarget(trigger, setting);
     1329    else
     1330        group->addChild(setting);
     1331}
     1332
    12781333//////////////////////////////////////// Database Upgrade
    12791334
    12801335enum OLD_DISEQC_TYPES
  • libs/libmythtv/diseqcsettings.h

     
    133133    virtual int exec(void);
    134134};
    135135
    136 class DTVDeviceConfigWizard : public QObject, public ConfigurationWizard
     136class DTVDeviceConfigGroup : public VerticalConfigurationGroup
    137137{
    138     Q_OBJECT
    139 
    140138  public:
    141     DTVDeviceConfigWizard(DiSEqCDevSettings &settings, uint cardid);
    142     ~DTVDeviceConfigWizard(void);
     139    DTVDeviceConfigGroup(DiSEqCDevSettings &settings, uint cardid,
     140                         bool switches_enabled);
     141    ~DTVDeviceConfigGroup(void);
    143142   
    144   public slots:
    145     void SelectNodes(void);
    146  
    147143  protected:
    148     void AddNodes(ConfigurationGroup &group, DiSEqCDevDevice *node);
     144    void AddNodes(ConfigurationGroup *group, const QString &trigger,
     145                  DiSEqCDevDevice *node);
     146
     147    void AddChild(ConfigurationGroup *group, const QString &trigger,
     148                  Setting *setting);
    149149   
    150150  private:
    151151    DiSEqCDevTree       m_tree;
    152152    DiSEqCDevSettings  &m_settings;
    153153    devid_to_setting_t  m_devs;
     154    bool                m_switches_enabled;
    154155};
    155156
    156157#endif // _DISEQCSETTINGS_H_