Ticket #2226: mythtv-diseqc-repeat-option.patch

File mythtv-diseqc-repeat-option.patch, 8.5 KB (added by yeasah@…, 18 years ago)

adds diseqc repeat count option to UI (REQUIRES DB CHANGE NOT IN PATCH)

  • libs/libmythtv/diseqc.cpp

     
    11061106    // populate switch parameters from db
    11071107    MSqlQuery query(MSqlQuery::InitCon());
    11081108    query.prepare(
    1109         "SELECT subtype, switch_ports "
     1109        "SELECT subtype, switch_ports, cmd_repeat "
    11101110        "FROM diseqc_tree "
    11111111        "WHERE diseqcid = :DEVID");
    11121112    query.bindValue(":DEVID", GetDeviceID());
     
    11201120    {
    11211121        m_type = SwitchTypeFromString(query.value(0).toString());
    11221122        m_num_ports = query.value(1).toUInt();
     1123        m_repeat = query.value(2).toUInt();
    11231124        m_children.resize(m_num_ports);
    11241125        for (uint i = 0; i < m_num_ports; i++)
    11251126            m_children[i] = NULL;
     
    11691170            "    type         = 'switch', "
    11701171            "    description  = :DESC, "
    11711172            "    subtype      = :TYPE, "
    1172             "    switch_ports = :PORTS "
     1173            "    switch_ports = :PORTS, "
     1174            "    cmd_repeat   = :REPEAT "
    11731175            "WHERE diseqcid = :DEVID");
    11741176    }
    11751177    else
     
    11771179        query.prepare(
    11781180            "INSERT INTO diseqc_tree"
    11791181            " ( parentid,      ordinal,         type, "
    1180             "   description,   subtype,         switch_ports) "
     1182            "   description,   subtype,         switch_ports, "
     1183            "   cmd_repeat )"
    11811184            "VALUES "
    11821185            " (:PARENT,       :ORDINAL,         'switch', "
    1183             "  :DESC,         :TYPE,            :PORTS)");
     1186            "  :DESC,         :TYPE,            :PORTS, "
     1187            "  :REPEAT )");
    11841188    }
    11851189
    11861190    if (m_parent)
     
    11901194    query.bindValue(":DESC",    GetDescription());
    11911195    query.bindValue(":TYPE",    type);
    11921196    query.bindValue(":PORTS",   m_num_ports);
     1197    query.bindValue(":REPEAT",  m_repeat);
    11931198    query.bindValue(":DEVID",   GetDeviceID());
    11941199
    11951200    if (!query.exec())
     
    15551560    MSqlQuery query(MSqlQuery::InitCon());
    15561561    query.prepare(
    15571562        "SELECT subtype,         rotor_positions, "
    1558         "       rotor_hi_speed,  rotor_lo_speed "
     1563        "       rotor_hi_speed,  rotor_lo_speed, "
     1564        "       cmd_repeat "
    15591565        "FROM diseqc_tree "
    15601566        "WHERE diseqcid = :DEVID");
    15611567    query.bindValue(":DEVID", GetDeviceID());
     
    15701576        m_type     = RotorTypeFromString(query.value(0).toString());
    15711577        m_speed_hi = query.value(2).toDouble();
    15721578        m_speed_lo = query.value(3).toDouble();
     1579        m_repeat   = query.value(4).toUInt();
    15731580
    15741581        // form of "angle1=index1:angle2=index2:..."
    15751582        QString positions = query.value(1).toString();
     
    16391646            "    subtype         = :TYPE,    "
    16401647            "    rotor_hi_speed  = :HISPEED, "
    16411648            "    rotor_lo_speed  = :LOSPEED, "
    1642             "    rotor_positions = :POSMAP   "
     1649            "    rotor_positions = :POSMAP,  "
     1650            "    cmd_repeat      = :REPEAT   "
    16431651            "WHERE diseqcid = :DEVID");
    16441652    }
    16451653    else
     
    16481656            "INSERT INTO diseqc_tree "
    16491657            " ( parentid,       ordinal,         type,   "
    16501658            "   description,    subtype,         rotor_hi_speed, "
    1651             "   rotor_lo_speed, rotor_positions ) "
     1659            "   rotor_lo_speed, rotor_positions, cmd_repeat ) "
    16521660            "VALUES "
    16531661            " (:PARENT,         :ORDINAL,        'rotor',  "
    16541662            "  :DESC,           :TYPE,           :HISPEED, "
    1655             "  :LOSPEED,        :POSMAP )");
     1663            "  :LOSPEED,        :POSMAP,         :REPEAT )");
    16561664    }
    16571665
    16581666    if (m_parent)
     
    16641672    query.bindValue(":HISPEED", m_speed_hi);
    16651673    query.bindValue(":LOSPEED", m_speed_lo);
    16661674    query.bindValue(":POSMAP",  posmap);
     1675    query.bindValue(":REPEAT",  m_repeat);
    16671676    query.bindValue(":DEVID",   GetDeviceID());
    16681677
    16691678    if (!query.exec())
     
    18831892    MSqlQuery query(MSqlQuery::InitCon());
    18841893    query.prepare(
    18851894        "SELECT subtype,         lnb_lof_switch, "
    1886         "       lnb_lof_hi,      lnb_lof_lo "
     1895        "       lnb_lof_hi,      lnb_lof_lo, "
     1896        "       cmd_repeat "
    18871897        "FROM diseqc_tree "
    18881898        "WHERE diseqcid = :DEVID");
    18891899    query.bindValue(":DEVID", GetDeviceID());
     
    18991909        m_lof_switch = query.value(1).toInt();
    19001910        m_lof_hi     = query.value(2).toInt();
    19011911        m_lof_lo     = query.value(3).toInt();
     1912        m_repeat     = query.value(4).toUInt();
    19021913    }
    19031914
    19041915    return true;
     
    19211932            "    subtype         = :TYPE,    "
    19221933            "    lnb_lof_switch  = :LOFSW,   "
    19231934            "    lnb_lof_lo      = :LOFLO,   "
    1924             "    lnb_lof_hi      = :LOFHI    "
     1935            "    lnb_lof_hi      = :LOFHI,   "
     1936            "    cmd_repeat      = :REPEAT   "
    19251937            "WHERE diseqcid = :DEVID");
    19261938    }
    19271939    else
     
    19301942            "INSERT INTO diseqc_tree"
    19311943            " ( parentid,      ordinal,         type, "
    19321944            "   description,   subtype,         lnb_lof_switch, "
    1933             "   lnb_lof_lo,    lnb_lof_hi ) "
     1945            "   lnb_lof_lo,    lnb_lof_hi,      cmd_repeat ) "
    19341946            "VALUES "
    19351947            " (:PARENT,       :ORDINAL,         'lnb', "
    19361948            "  :DESC,         :TYPE,            :LOFSW, "
    1937             "  :LOFLO,        :LOFHI ) ");
     1949            "  :LOFLO,        :LOFHI,           :REPEAT ) ");
    19381950    }
    19391951
    19401952    if (m_parent)
     
    19461958    query.bindValue(":LOFSW",   m_lof_switch);
    19471959    query.bindValue(":LOFLO",   m_lof_lo);
    19481960    query.bindValue(":LOFHI",   m_lof_hi);
     1961    query.bindValue(":REPEAT",  m_repeat);
    19491962    query.bindValue(":DEVID",   GetDeviceID());
    19501963
    19511964    // update dev_id
  • libs/libmythtv/diseqc.h

     
    147147    void SetParent(DiSEqCDevDevice* parent)  { m_parent   = parent;  }
    148148    void SetOrdinal(uint ordinal)            { m_ordinal  = ordinal; }
    149149    void SetDescription(const QString &desc) { m_desc     = desc;    }
     150    void SetRepeatCount(uint repeat)         { m_repeat   = repeat;  }
    150151    virtual bool SetChild(uint, DiSEqCDevDevice*){return false;      }
    151152
    152153    // Gets
     
    157158    DiSEqCDevDevice *GetParent(void)   const { return m_parent;      }
    158159    uint          GetOrdinal(void)     const { return m_ordinal;     }
    159160    QString       GetDescription(void) const { return m_desc;        }
     161    uint          GetRepeatCount(void) const { return m_repeat;      }
    160162    virtual uint  GetChildCount(void)  const { return 0;             }
    161163    virtual bool  IsCommandNeeded(
    162164        const DiSEqCDevSettings&)      const { return false;         }
  • libs/libmythtv/diseqcsettings.cpp

     
    9696    DiSEqCDevDevice &m_device;
    9797};
    9898
     99
     100//////////////////////////////////////// DeviceRepeatSetting
     101
     102class DeviceRepeatSetting : public LineEditSetting
     103{
     104  public:
     105    DeviceRepeatSetting(DiSEqCDevDevice &device) : m_device(device)
     106    {
     107        setLabel(DeviceTree::tr("Repeat Count"));
     108        QString help = DeviceTree::tr(
     109            "Number of times to repeat DiSEqC commands sent to this device. "
     110            "Larger values may help with less reliable devices.");
     111        setHelpText(help);
     112    }
     113   
     114    virtual void load(void)
     115    {
     116        setValue(QString::number(m_device.GetRepeatCount()));
     117    }
     118
     119    virtual void save(void)
     120    {
     121        m_device.SetRepeatCount(getValue().toUInt());
     122    }
     123
     124  private:
     125    DiSEqCDevDevice &m_device;
     126};
     127
    99128//////////////////////////////////////// SwitchTypeSetting
    100129
    101130class SwitchTypeSetting : public ComboBoxSetting
     
    171200    group->setLabel(DeviceTree::tr("Switch Configuration"));
    172201
    173202    group->addChild(new DeviceDescrSetting(switch_dev));
     203    group->addChild(new DeviceRepeatSetting(switch_dev));
    174204    m_type = new SwitchTypeSetting(switch_dev);
    175205    group->addChild(m_type);
    176206    m_ports = new SwitchPortsSetting(switch_dev);
     
    408438    group->setLabel(DeviceTree::tr("Rotor Configuration"));
    409439
    410440    group->addChild(new DeviceDescrSetting(rotor));
     441    group->addChild(new DeviceRepeatSetting(rotor));
    411442
    412443    ConfigurationGroup *tgroup =
    413444        new HorizontalConfigurationGroup(false, false, true, true);