Ticket #2594: multiselect_mythtv_r12703.patch

File multiselect_mythtv_r12703.patch, 62.1 KB (added by mythtv@…, 17 years ago)

Patch refresh against head revision 12703

  • libs/libmythtv/channeleditor.cpp

     
    251251    src->addChild(source);
    252252    src->addChild(del);
    253253
    254     sort->setValue(sort->getValueIndex(list->getSortMode()));
    255     source->setValue(source->getValueIndex(list->getSourceID()));
     254    sort->setCurrentValue(list->getSortMode());
     255    source->setCurrentValue(list->getSourceID());
    256256    hide->setValue(list->getHideMode());
    257257
    258258    addChild(sort);
  • libs/libmythtv/playgroup.cpp

     
    254254
    255255void PlayGroupEditor::doDelete(void)
    256256{
    257     QString name = listbox->getValue();
     257    QString name = listbox->getSelectionValues().first();
     258
    258259    if (name.isEmpty() || name == "Default")
    259260        return;
    260261
     
    274275        if (!query.exec())
    275276            MythContext::DBError("PlayGroupEditor::doDelete", query);
    276277
    277         int lastIndex = listbox->getValueIndex(name);
     278        int lastIndex = listbox->getSelectionIndices().first();
    278279        lastValue = "";
    279280        load();
    280         listbox->setValue(lastIndex);
     281        listbox->setCurrent(lastIndex);
    281282    }
    282283
    283284    listbox->setFocus();
     
    298299
    299300    listbox->addSelection(tr("(Create new group)"), "");
    300301
    301     listbox->setValue(lastValue);
     302    listbox->setCurrentValue(lastValue);
    302303}
    303304
    304305int PlayGroupEditor::exec(void)
  • libs/libmythtv/scanwizardhelpers.h

     
    763763
    764764    void SetDefaultATSCFormat(const QString &d)
    765765    {
    766         int val = atsc_format->getValueIndex(d);
    767         atsc_format->setValue(val);
     766        atsc_format->setCurrentValue(d);
    768767    }
    769768
    770769  protected:
     
    821820
    822821    void SetDefaultATSCFormat(const QString &d)
    823822    {
    824         int val = atsc_format->getValueIndex(d);
    825         atsc_format->setValue(val);
     823        atsc_format->setCurrentValue(d);
    826824    }
    827825
    828826    void SetSourceID(uint sourceid)
     
    868866
    869867    void SetDefaultATSCFormat(const QString &d)
    870868    {
    871         int val = atsc_format->getValueIndex(d);
    872         atsc_format->setValue(val);
     869        atsc_format->setCurrentValue(d);
    873870    }
    874871
    875872  private:
  • libs/libmythtv/storagegroup.cpp

     
    434434        if (!query.exec())
    435435            MythContext::DBError("StorageGroupEditor::doDelete", query);
    436436
    437         int lastIndex = listbox->getValueIndex(name);
     437        int lastIndex = listbox->getSelectionIndices().first();
    438438        lastValue = "";
    439439        load();
    440         listbox->setValue(lastIndex);
     440        listbox->setCurrent(lastIndex);
    441441    }
    442442
    443443    listbox->setFocus();
     
    470470
    471471    listbox->addSelection(tr("(Add New Directory)"), "");
    472472
    473     listbox->setValue(lastValue);
     473    listbox->setCurrentValue(lastValue);
    474474}
    475475
    476476int StorageGroupEditor::exec() {
     
    561561        if (!query.exec())
    562562            MythContext::DBError("StorageGroupListEditor::doDelete", query);
    563563
    564         int lastIndex = listbox->getValueIndex(name);
     564        int lastIndex = listbox->getSelectionIndices().first();
    565565        lastValue = "";
    566566        load();
    567         listbox->setValue(lastIndex);
     567        listbox->setCurrent(lastIndex);
    568568    }
    569569
    570570    listbox->setFocus();
     
    657657        }
    658658    }
    659659
    660     listbox->setValue(lastValue);
     660    listbox->setCurrentValue(lastValue);
    661661}
    662662
    663663int StorageGroupListEditor::exec() {
  • libs/libmythtv/videosource.cpp

     
    101101
    102102    if (initial_sourceid)
    103103    {
    104         if (cnt)
    105             setValue(sel);
     104        setCurrent(sel);
    106105        setEnabled(false);
    107106    }
    108107}
     
    199198
    200199void TransFreqTableSelector::load(void)
    201200{
    202     int idx = getValueIndex(gContext->GetSetting("FreqTable"));
    203     if (idx >= 0)
    204         setValue(idx);
     201    setCurrentValue(gContext->GetSetting("FreqTable"));
    205202
    206203    if (!sourceid)
    207204        return;
     
    227224        if (!loaded_freq_table.isEmpty() &&
    228225            (loaded_freq_table.lower() != "default"))
    229226        {
    230             int idx = getValueIndex(loaded_freq_table);
    231             if (idx >= 0)
    232                 setValue(idx);
     227            setCurrentValue(loaded_freq_table);
    233228        }
    234229    }
    235230}
     
    997992
    998993#ifdef USING_FIREWIRE
    999994    AVCInfo info = guid->GetAVCInfo(_guid);
    1000     QString model = FirewireDevice::GetModelName(info.vendorid, info.modelid);
    1001     setValue(max(getValueIndex(model), 0));
     995    setCurrentValue(FirewireDevice::GetModelName(info.vendorid, info.modelid));
    1002996#endif // USING_FIREWIRE
    1003997}
    1004998
     
    18491843
    18501844QString CardInput::getSourceName(void) const
    18511845{
    1852     return sourceid->getSelectionLabel();
     1846    return sourceid->getSelectionLabels().first();
    18531847}
    18541848
    18551849void CardInput::SetChildCardID(uint ccid)
     
    19741968    else
    19751969    { // create new input connection
    19761970        load();
    1977         cardid->setValue(QString::number(_cardid));
     1971        cardid->setCurrentLabel(QString::number(_cardid));
    19781972        inputname->setValue(_inputname);
    19791973    }
    19801974}
  • libs/libmythtv/diseqcsettings.cpp

     
    5555
    5656    virtual void load(void)
    5757    {
    58         QString tmp = QString::number((uint) m_device.GetDeviceType());
    59         setValue(getValueIndex(tmp));
     58        setCurrentValue(QString::number((uint) m_device.GetDeviceType()));
    6059    }
    6160
    6261    virtual void save(void)
     
    163162
    164163    virtual void load(void)
    165164    {
    166         setValue(getValueIndex(QString::number((uint) m_switch.GetType())));
     165        setCurrentValue(QString::number((uint) m_switch.GetType()));
    167166    }
    168167
    169168    virtual void save(void)
     
    266265
    267266    virtual void load(void)
    268267    {
    269         setValue(getValueIndex(QString::number((uint)m_rotor.GetType())));
     268        setCurrentValue(QString::number((uint)m_rotor.GetType()));
    270269    }
    271270
    272271    virtual void save(void)
     
    434433
    435434void RotorPosMap::PopulateList(void)
    436435{
    437     int old_sel = getValueIndex(getValue());
     436    int old_sel = getSelectionIndices().first();
    438437    clearSelections();
    439438    uint num_pos = 64;
    440439    for (uint pos = 1; pos < num_pos; pos++)
     
    447446        addSelection(DeviceTree::tr("Position #%1 (%2)").arg(pos).arg(posval),
    448447                     QString::number(pos));
    449448    }
    450     setCurrentItem(old_sel);
     449    setCurrent(old_sel);
    451450}
    452451
    453452//////////////////////////////////////// RotorPosConfig
     
    597596
    598597    virtual void load(void)
    599598    {
    600         setValue(FindPreset(m_lnb));
     599        setCurrent(FindPreset(m_lnb));
    601600    }
    602601
    603602    virtual void save(void)
     
    635634
    636635    virtual void load(void)
    637636    {
    638         setValue(getValueIndex(QString::number((uint) m_lnb.GetType())));
     637        setCurrentValue(QString::number((uint) m_lnb.GetType()));
    639638    }
    640639
    641640    virtual void save(void)
     
    814813    }
    815814    else
    816815    {
    817         m_type->setValue(m_type->getValueIndex(
    818                              QString::number((uint)preset.type)));
     816        m_type->setCurrentValue(QString::number((uint)preset.type));
    819817        m_lof_switch->setValue(QString::number(preset.lof_sw / 1000));
    820818        m_lof_lo->setValue(QString::number(preset.lof_lo / 1000));
    821819        m_lof_hi->setValue(QString::number(preset.lof_hi / 1000));
     
    10441042
    10451043void DeviceTree::PopulateTree(void)
    10461044{
    1047     int old_sel = getValueIndex(getValue());
     1045    int old_sel = getSelectionIndices().first();
    10481046    clearSelections();
    10491047    PopulateTree(m_tree.Root());
    1050     setCurrentItem(old_sel);
     1048    setCurrent(old_sel);
    10511049}
    10521050
    10531051void DeviceTree::PopulateTree(DiSEqCDevDevice *node,
     
    11211119    virtual void load(void)
    11221120    {
    11231121        double value = m_settings.GetValue(m_node.GetDeviceID());
    1124         setValue((uint)value);
     1122        setCurrent((uint)value);
    11251123    }
    11261124
    11271125    virtual void save(void)
     
    11611159            addSelection(AngleToString(*it), QString::number(*it));
    11621160
    11631161        double angle = m_settings.GetValue(m_node.GetDeviceID());
    1164         setValue(getValueIndex(QString::number(angle)));
     1162        setCurrentValue(QString::number(angle));
    11651163    }
    11661164
    11671165    virtual void save(void)
     
    12111209        QString hemi = QString::null;
    12121210        double  eval = AngleToEdit(val, hemi);
    12131211        numeric->setValue(QString::number(eval));
    1214         hemisphere->setValue(hemisphere->getValueIndex(hemi));
     1212        hemisphere->setCurrentValue(hemi);
    12151213    }
    12161214
    12171215    virtual void save(void)
  • libs/libmythtv/channelsettings.cpp

     
    6868        {
    6969            uint which = sourceid_to_index[default_sourceid];
    7070            if (which)
    71                 setValue(which);
     71                setCurrent(which);
    7272        }
    7373    }
    7474
  • libs/libmythtv/scheduledrecording.cpp

     
    631631            case kChannelRecord:
    632632                label = QString("%1 on channel %2")
    633633                    .arg(sr.title->getValue())
    634                     .arg(sr.channel->getSelectionLabel());
     634                    .arg(sr.channel->getSelectionLabels().first());
    635635                break;
    636636            case kWeekslotRecord:
    637637                weekly = QDate(sr.startDate->dateValue()).toString("dddd")+"s ";
    638638            case kTimeslotRecord:
    639639                label = QString("%1 on channel %2 (%3%4 - %5)")
    640640                    .arg(sr.title->getValue())
    641                     .arg(sr.channel->getSelectionLabel())
     641                    .arg(sr.channel->getSelectionLabels().first())
    642642                    .arg(weekly)
    643643                    .arg(sr.startTime->timeValue().toString())
    644644                    .arg(sr.endTime->timeValue().toString());
     
    648648            case kDontRecord:
    649649                label = QString("%1 on channel %2 (%3 %4 - %5)")
    650650                    .arg(sr.title->getValue())
    651                     .arg(sr.channel->getSelectionLabel())
     651                    .arg(sr.channel->getSelectionLabels().first())
    652652                    .arg(sr.startDate->dateValue().toString())
    653653                    .arg(sr.startTime->timeValue().toString())
    654654                    .arg(sr.endTime->timeValue().toString());
     
    803803    title->setValue("");
    804804    subtitle->setValue("");
    805805    description->setValue("");
    806     channel->setValue("");
     806    channel->setCurrent(0);
     807    channel->setState(0, false);
    807808    station->setValue("");
    808809    startDate->setValue(date);
    809810    startTime->setValue(time);
     
    871872        title->setValue(proginfo->title);
    872873        subtitle->setValue(proginfo->subtitle);
    873874        description->setValue(proginfo->description);
    874         channel->setValue(proginfo->chanid);
     875        channel->setCurrentValue(proginfo->chanid);
    875876        station->setValue(proginfo->chansign);
    876877        startDate->setValue(proginfo->startts.date());
    877878        startTime->setValue(proginfo->startts.time());
  • libs/libmythtv/recordingprofile.cpp

     
    122122        else
    123123        {
    124124            addSelection("48000");
     125            setEnabled(false);
    125126            //addSelection("44100");
    126127            //addSelection("32000");
    127128        }
     
    134135class MPEG2audType : public ComboBoxSetting, public CodecParamStorage
    135136{
    136137  public:
    137     MPEG2audType(const RecordingProfile &parent) :
    138         ComboBoxSetting(this), CodecParamStorage(this, parent, "mpeg2audtype")
     138    MPEG2audType(const RecordingProfile &parent,
     139                 bool layer1, bool layer2, bool layer3) :
     140        ComboBoxSetting(this), CodecParamStorage(this, parent, "mpeg2audtype"),
     141        allow_layer1(layer1), allow_layer2(layer2), allow_layer3(layer3)
    139142    {
    140143        setLabel(QObject::tr("Type"));
     144
     145        if (allow_layer1)
     146            addSelection("Layer I");
     147        if (allow_layer2)
     148            addSelection("Layer II");
     149        if (allow_layer3)
     150            addSelection("Layer III");
     151
     152        uint allowed_cnt = 0;
     153        allowed_cnt += ((allow_layer1) ? 1 : 0);
     154        allowed_cnt += ((allow_layer2) ? 1 : 0);
     155        allowed_cnt += ((allow_layer3) ? 1 : 0);
     156
     157        if (1 == allowed_cnt)
     158            setEnabled(false);
     159
    141160        setHelpText(QObject::tr("Sets the audio type"));
    142161    }
     162
     163    void load(void)
     164    {
     165        CodecParamStorage::load();
     166        QString val = getValue();
     167
     168        if ((val == "Layer I") && !allow_layer1)
     169        {
     170            val = (allow_layer2) ? "Layer II" :
     171                ((allow_layer3) ? "Layer III" : val);
     172        }
     173
     174        if ((val == "Layer II") && !allow_layer2)
     175        {
     176            val = (allow_layer3) ? "Layer III" :
     177                ((allow_layer1) ? "Layer I" : val);
     178        }
     179
     180        if ((val == "Layer III") && !allow_layer3)
     181        {
     182            val = (allow_layer2) ? "Layer II" :
     183                ((allow_layer1) ? "Layer I" : val);
     184        }
     185
     186        setCurrentValue(val);
     187    }
     188
     189  private:
     190    bool allow_layer1;
     191    bool allow_layer2;
     192    bool allow_layer3;
    143193};
    144194
    145195class MPEG2audBitrateL1 : public ComboBoxSetting, public CodecParamStorage
     
    150200        CodecParamStorage(this, parent, "mpeg2audbitratel1")
    151201    {
    152202        setLabel(QObject::tr("Bitrate"));
    153        
     203
    154204        addSelection("32 kbps", "32");
    155205        addSelection("64 kbps", "64");
    156206        addSelection("96 kbps", "96");
     
    165215        addSelection("384 kbps", "384");
    166216        addSelection("416 kbps", "416");
    167217        addSelection("448 kbps", "448");
    168         setValue(13);
     218        setCurrent(13);
    169219        setHelpText(QObject::tr("Sets the audio bitrate"));
    170220    };
    171221};
     
    178228        CodecParamStorage(this, parent, "mpeg2audbitratel2")
    179229    {
    180230        setLabel(QObject::tr("Bitrate"));
    181        
     231
    182232        addSelection("32 kbps", "32");
    183233        addSelection("48 kbps", "48");
    184234        addSelection("56 kbps", "56");
     
    193243        addSelection("256 kbps", "256");
    194244        addSelection("320 kbps", "320");
    195245        addSelection("384 kbps", "384");
    196         setValue(13);
     246        setCurrent(13);
    197247        setHelpText(QObject::tr("Sets the audio bitrate"));
    198248    };
    199249};
    200250
     251class MPEG2audBitrateL3 : public ComboBoxSetting, public CodecParamStorage
     252{
     253  public:
     254    MPEG2audBitrateL3(const RecordingProfile &parent) :
     255        ComboBoxSetting(this),
     256        CodecParamStorage(this, parent, "mpeg2audbitratel3")
     257    {
     258        setLabel(QObject::tr("Bitrate"));
     259
     260        addSelection("32 kbps", "32");
     261        addSelection("40 kbps", "40");
     262        addSelection("48 kbps", "48");
     263        addSelection("56 kbps", "56");
     264        addSelection("64 kbps", "64");
     265        addSelection("80 kbps", "80");
     266        addSelection("96 kbps", "96");
     267        addSelection("112 kbps", "112");
     268        addSelection("128 kbps", "128");
     269        addSelection("160 kbps", "160");
     270        addSelection("192 kbps", "192");
     271        addSelection("224 kbps", "224");
     272        addSelection("256 kbps", "256");
     273        addSelection("320 kbps", "320");
     274        setCurrent(10);
     275        setHelpText(QObject::tr("Sets the audio bitrate"));
     276    };
     277};
     278
    201279class MPEG2audVolume : public SliderSetting, public CodecParamStorage
    202280{
    203281  public:
     
    215293class MPEG2AudioBitrateSettings : public TriggeredConfigurationGroup
    216294{
    217295  public:
    218     MPEG2AudioBitrateSettings(const RecordingProfile &parent) :
     296    MPEG2AudioBitrateSettings(const RecordingProfile &parent,
     297                              bool layer1, bool layer2, bool layer3,
     298                              uint default_layer) :
    219299        TriggeredConfigurationGroup(false, true, true, true)
    220300    {
     301        const QString layers[3] = { "Layer I", "Layer II", "Layer III", };
     302
    221303        SetVertical(false);
    222304        setLabel(QObject::tr("Bitrate Settings"));
    223         MPEG2audType* audType = new MPEG2audType(parent);
     305
     306        MPEG2audType *audType = new MPEG2audType(
     307            parent, layer1, layer2, layer3);
     308
    224309        addChild(audType);
    225310        setTrigger(audType);
    226311
    227         ConfigurationGroup *audbr =
    228             new VerticalConfigurationGroup(false, true, true, true);
    229         audbr->addChild(new MPEG2audBitrateL1(parent));
    230         audbr->setLabel("Layer I");
    231         addTarget("Layer I", audbr);
    232         audType->addSelection("Layer I");
     312        addTarget(layers[0], new MPEG2audBitrateL1(parent));
     313        addTarget(layers[1], new MPEG2audBitrateL2(parent));
     314        addTarget(layers[2], new MPEG2audBitrateL3(parent));
    233315
    234         audbr = new VerticalConfigurationGroup(false, true, true, true);
    235         audbr->addChild(new MPEG2audBitrateL2(parent));
    236         audbr->setLabel("Layer II");
    237         addTarget("Layer II", audbr);
    238         audType->addSelection("Layer II");
    239         audType->setValue(1);
     316        uint desired_layer = max(min(3U, default_layer), 1U) - 1;
     317        audType->setCurrentValue(layers[desired_layer]);
    240318    };
    241319};
    242320
     
    252330        addSelection(QObject::tr("SAP Language"),  "1");
    253331        addSelection(QObject::tr("Dual"),          "2");
    254332
    255         setValue(0);
     333        setCurrent(0);
    256334        setHelpText(QObject::tr(
    257335                        "Chooses the language(s) to record when "
    258336                        "two languages are broadcast. Only Layer II "
     
    288366        params = new VerticalConfigurationGroup(false, false, true, true);
    289367        params->setLabel("MPEG-2 Hardware Encoder");
    290368        params->addChild(new SampleRate(parent, false));
    291         params->addChild(new MPEG2AudioBitrateSettings(parent));
     369        params->addChild(new MPEG2AudioBitrateSettings(
     370                             parent, false, true, false, 2));
    292371        params->addChild(new MPEG2Language(parent));
    293372        params->addChild(new MPEG2audVolume(parent));
    294373        addTarget("MPEG-2 Hardware Encoder", params);
     
    566645        CodecParamStorage(this, parent, "mpeg2streamtype")
    567646    {
    568647        setLabel(QObject::tr("Stream Type"));
    569        
     648
    570649        addSelection("MPEG-2 PS");
    571650        addSelection("MPEG-2 TS");
    572651        addSelection("MPEG-1 VCD");
     
    576655        addSelection("DVD");
    577656        addSelection("DVD-Special 1");
    578657        addSelection("DVD-Special 2");
    579         setValue(0);
     658        setCurrent(0);
    580659        setHelpText(QObject::tr("Sets the type of stream generated by "
    581660                    "your PVR."));
    582661    };
     
    590669        CodecParamStorage(this, parent, "mpeg2aspectratio")
    591670    {
    592671        setLabel(QObject::tr("Aspect Ratio"));
    593        
     672
    594673        addSelection(QObject::tr("Square"), "Square");
    595674        addSelection("4:3");
    596675        addSelection("16:9");
    597676        addSelection("2.21:1");
    598         setValue(1);
     677        setCurrent(1);
    599678        setHelpText(QObject::tr("Sets the aspect ratio of stream generated "
    600679                    "by your PVR."));
    601680    };
     
    625704        addSelection("1");
    626705        addSelection("2");
    627706        addSelection("4");
    628         setValue(2);
     707        setCurrent(2);
    629708    };
    630709};
    631710
     
    640719        addSelection("1");
    641720        addSelection("2");
    642721        addSelection("4");
    643         setValue(2);
     722        setCurrent(2);
    644723    };
    645724};
    646725
     
    821900        addSelection(QObject::tr("Normal"),     "all");
    822901        addSelection(QObject::tr("TV Only"),    "tv");
    823902        addSelection(QObject::tr("Audio Only"), "audio");
    824         setValue(0);
     903        setCurrent(0);
    825904    };
    826905};
    827906
     
    847926    class Width : public SpinBoxSetting, public CodecParamStorage
    848927    {
    849928      public:
    850         Width(const RecordingProfile &parent, int maxwidth = 704,
     929        Width(const RecordingProfile &parent,
     930              uint defaultwidth, uint maxwidth,
    851931              bool transcoding = false) :
    852932            SpinBoxSetting(this, transcoding ? 0 : 160,
    853933                           maxwidth, 16, false,
     
    855935            CodecParamStorage(this, parent, "width")
    856936        {
    857937            setLabel(QObject::tr("Width"));
    858             setValue(480);
    859             if (transcoding)
    860                 setHelpText(QObject::tr("If the width is set to 'Auto', "
    861                             "the width will be calculated based on the height "
    862                             "and the recording's physical aspect ratio."));
     938            setValue(defaultwidth);
     939
     940            QString help = (transcoding) ?
     941                QObject::tr("If the width is set to 'Auto', the width "
     942                            "will be calculated based on the height and "
     943                            "the recording's physical aspect ratio.") :
     944                QObject::tr("Width to use for encoding. "
     945                            "Note: PVR-x50 cards may produce ghosting if "
     946                            "this is not set to 720 or 768 for NTSC and "
     947                            "PAL, respectively.");
     948
     949            setHelpText(help);
    863950        };
    864951    };
    865952
    866953    class Height: public SpinBoxSetting, public CodecParamStorage
    867954    {
    868955      public:
    869         Height(const RecordingProfile &parent, int maxheight=576,
     956        Height(const RecordingProfile &parent,
     957               uint defaultheight, uint maxheight,
    870958               bool transcoding = false):
    871959            SpinBoxSetting(this, transcoding ? 0 : 160,
    872960                           maxheight, 16, false,
     
    874962            CodecParamStorage(this, parent, "height")
    875963        {
    876964            setLabel(QObject::tr("Height"));
    877             setValue(480);
    878             if (transcoding)
    879                 setHelpText(QObject::tr("If the height is set to 'Auto', "
    880                             "the height will be calculated based on the width "
    881                             "and the recording's physical aspect ratio."));
     965            setValue(defaultheight);
     966
     967            QString help = (transcoding) ?
     968                QObject::tr("If the height is set to 'Auto', the height "
     969                            "will be calculated based on the width and "
     970                            "the recording's physical aspect ratio.") :
     971                QObject::tr("Height to use for encoding. "
     972                            "Note: PVR-x50 cards may produce ghosting if "
     973                            "this is not set to 480 or 576 for NTSC and "
     974                            "PAL, respectively.");
     975
     976            setHelpText(help);
    882977        };
    883978    };
    884979
     
    894989            labelName = profName + "->" + QObject::tr("Image size");
    895990        setLabel(labelName);
    896991
    897         QString fullsize, halfsize;
    898         int maxwidth, maxheight;
    899         bool transcoding = false;
    900         if (profName.left(11) == "Transcoders") {
    901             maxwidth = 1920;
    902             maxheight = 1088;
    903             transcoding = true;
    904         } else if ((tvFormat.lower() == "ntsc") ||
    905                    (tvFormat.lower() == "ntsc-jp")) {
    906             maxwidth = 720;
    907             maxheight = 480;
    908         } else if (tvFormat.lower() == "atsc") {
    909             maxwidth = 1920;
    910             maxheight = 1088;
    911         } else {
    912             maxwidth = 768;
    913             maxheight = 576;
     992        QSize defaultsize(768, 576), maxsize(768, 576);
     993        bool transcoding = profName.left(11) == "Transcoders";
     994        bool ivtv = profName.left(34) == "MPEG-2 Encoders (PVR-x50, PVR-500)";
     995
     996        if (transcoding)
     997        {
     998            maxsize     = QSize(1920, 1088);
     999            defaultsize = QSize(480, 480);
    9141000        }
     1001        else if (tvFormat.lower().left(4) == "ntsc")
     1002        {
     1003            maxsize     = QSize(720, 480);
     1004            defaultsize = (ivtv) ? QSize(720, 480) : QSize(480, 480);
     1005        }
     1006        else if (tvFormat.lower() == "atsc")
     1007        {
     1008            maxsize     = QSize(1920, 1088);
     1009            defaultsize = QSize(1920, 1088);
     1010        }
     1011        else
     1012        {
     1013            maxsize     = QSize(768, 576);
     1014            defaultsize = (ivtv) ? QSize(720, 576) : QSize(480, 576);
     1015        }
    9151016
    916         imgSize->addChild(new Width(parent, maxwidth, transcoding));
    917         imgSize->addChild(new Height(parent, maxheight, transcoding));
     1017        imgSize->addChild(new Width(parent, defaultsize.width(),
     1018                                    maxsize.width(), transcoding));
     1019        imgSize->addChild(new Height(parent, defaultsize.height(),
     1020                                     maxsize.height(), transcoding));
     1021
    9181022        addChild(imgSize);
    9191023    };
    9201024};
     
    10011105{
    10021106    MSqlQuery result(MSqlQuery::InitCon());
    10031107    result.prepare(
    1004         "SELECT cardtype "
     1108        "SELECT cardtype, profilegroups.name "
    10051109        "FROM profilegroups, recordingprofiles "
    10061110        "WHERE profilegroups.id     = recordingprofiles.profilegroup AND "
    10071111        "      recordingprofiles.id = :PROFILEID");
     
    10131117    else if (result.next())
    10141118    {
    10151119        type = result.value(0).toString();
     1120        if (profileName.isEmpty())
     1121            profileName = result.value(1).toString();
    10161122        isEncoder = CardUtil::IsEncoder(type);
    10171123    }
    10181124
  • libs/libmythtv/scanwizardhelpers.cpp

     
    294294    }
    295295
    296296    if (cnt)
    297         setValue(which);
     297        setCurrent(which);
    298298}
    299299
    300300void InputSelector::SetSourceID(const QString &_sourceid)
     
    770770    return scanConfig->GetATSCFormat(dfl);
    771771}
    772772
    773 LogList::LogList() : ListBoxSetting(this), n(0)
     773LogList::LogList() : ListBoxSetting(this, MythListBox::NoSelection), n(0)
    774774{
    775     setSelectionMode(MythListBox::NoSelection);
    776775}
    777776
    778777void LogList::updateText(const QString& status)
    779778{
    780779    addSelection(status,QString::number(n));
    781     setCurrentItem(n);
    782     n++;
     780    setCurrent(n++);
    783781}
  • libs/libmyth/settings.cpp

     
    505505    return widget;
    506506}
    507507
    508 void SelectSetting::addSelection(const QString& label, QString value, bool select) {
     508void SelectSetting::addSelection(const QString& label, QString value, bool state)
     509{
    509510    if (value == QString::null)
    510511        value = label;
    511    
    512     bool found = false;
    513     for(unsigned i = 0 ; i < values.size() ; ++i)
    514         if ((values[i] == value) &&
    515             (labels[i] == label)) {
    516             found = true;
    517             break;
    518         }
    519512
    520     if (!found)
     513    int index = values.findIndex(value);
     514
     515    if (index == -1)
    521516    {
    522         labels.push_back(label);
    523         values.push_back(value);
    524    
    525         emit selectionAdded(label, value);
    526    
    527         if (select || !isSet)
    528             setValue(value);
     517        labels.append(label);
     518        values.append(value);
     519        states.append(state);
     520
     521        emit selectionAdded(label, value, state);
     522
     523        if (state)
     524        {
     525            selectionIndices.append(states.count() - 1);
     526            selectionLabels.append(label);
     527            selectionValues.append(value);
     528            updateValue();
     529        }
    529530    }
     531    else
     532    {
     533        setState(index, state);
     534    }
    530535}
    531536
    532537void SelectSetting::fillSelectionsFromDir(const QDir& dir, bool absPath) {
     
    544549             addSelection(fi->fileName());
    545550}
    546551
    547 void SelectSetting::clearSelections(void) {
     552void SelectSetting::clearSelections()
     553{
    548554    labels.clear();
    549555    values.clear();
    550     isSet = false;
     556    states.clear();
     557    selectionIndices.clear();
     558    selectionLabels.clear();
     559    selectionValues.clear();
     560    updateValue();
    551561    emit selectionsCleared();
    552562}
    553563
    554 void SelectSetting::setValue(const QString& newValue)  {
    555     bool found = false;
    556     for(unsigned i = 0 ; i < values.size() ; ++i)
    557         if (values[i] == newValue) {
    558             current = i;
    559             found = true;
    560             isSet = true;
    561             break;
     564void SelectSetting::setCurrent(uint which)
     565{
     566    if (which < labels.count())
     567    {
     568        for(uint i = 0 ; i < states.size() ; ++i)
     569            states[i] = false;
     570        selectionIndices.clear();
     571        selectionLabels.clear();
     572        selectionValues.clear();
     573        selectionIndices.append(which);
     574        selectionLabels.append(labels[which]);
     575        selectionValues.append(values[which]);
     576        states[which] = true;
     577        updateValue();
     578    }
     579    else
     580    {
     581        VERBOSE(VB_IMPORTANT, QString("SelectSetting(%1)::setCurrent(%2) - invalid value")
     582                .arg(getName())
     583                .arg(which));
     584    }
     585}
     586
     587void SelectSetting::setCurrentLabel(const QString& label)
     588{
     589    int index = labels.findIndex(label);
     590
     591    if (index == -1)
     592    {
     593        if (expand)
     594        {
     595            for(uint j = 0 ; j < states.size() ; ++j)
     596                states[j] = false;
     597            selectionIndices.clear();
     598            selectionLabels.clear();
     599            selectionValues.clear();
     600
     601            addSelection(label, label, true);
    562602        }
    563     if (found)
    564         Setting::setValue(newValue);
     603        else
     604        {
     605            VERBOSE(VB_IMPORTANT, QString("SelectSetting(%1)::setCurrentLabel(%2) - invalid label")
     606                    .arg(getName())
     607                    .arg(label));
     608        }
     609    }
    565610    else
    566         addSelection(newValue, newValue, true);
     611    {
     612        setCurrent(index);
     613    }
    567614}
    568615
    569 void SelectSetting::setValue(int which)
     616void SelectSetting::setCurrentValue(const QString& value)
    570617{
    571     if ((unsigned)which > values.size()-1 || which < 0) {
    572         VERBOSE(VB_IMPORTANT,
    573                 "SelectSetting::setValue(): invalid index " << which);
    574         return;
     618    int index = values.findIndex(value);
     619
     620    if (index == -1)
     621    {
     622        if (expand)
     623        {
     624            for(uint j = 0 ; j < states.size() ; ++j)
     625                states[j] = false;
     626            selectionIndices.clear();
     627            selectionLabels.clear();
     628            selectionValues.clear();
     629
     630            addSelection(value, value, true);
     631        }
     632        else
     633        {
     634            VERBOSE(VB_IMPORTANT, QString("SelectSetting(%1)::setCurrent(%2) - invalid value")
     635                    .arg(getName())
     636                    .arg(value));
     637        }
    575638    }
    576     current = which;
    577     isSet = true;
    578     Setting::setValue(values[current]);
     639    else
     640    {
     641        setCurrent(index);
     642    }
    579643}
    580644
     645void SelectSetting::setState(uint which, bool state)
     646{
     647    if (which < labels.count())
     648    {
     649        if (states[which] != state)
     650        {
     651            states[which] = state;
     652            if (!states[which])
     653            {
     654                selectionIndices.remove(which);
     655                selectionLabels.remove(labels[which]);
     656                selectionValues.remove(values[which]);
     657            }
     658            else
     659            {
     660                selectionIndices.append(which);
     661                selectionLabels.append(labels[which]);
     662                selectionValues.append(values[which]);
     663            }
     664            updateValue();
     665        }
     666    }
     667    else
     668    {
     669        VERBOSE(VB_IMPORTANT, QString("SelectSetting(%1)::setState(%2, %3) - invalid value")
     670                .arg(getName())
     671                .arg(which)
     672                .arg(state));
     673    }
     674}
     675
     676void SelectSetting::setStateLabel(const QString& label, bool state)
     677{
     678    int index = labels.findIndex(label);
     679
     680    if (index == -1)
     681    {
     682        if (expand)
     683        {
     684            addSelection(label, label, true);
     685        }
     686        else
     687        {
     688            VERBOSE(VB_IMPORTANT, QString("SelectSetting(%1)::setStateLabel(%2, %3) - invalid label")
     689                    .arg(getName())
     690                    .arg(label)
     691                    .arg(state));
     692        }
     693    }
     694    else
     695    {
     696        setState(index, state);
     697    }
     698}
     699
     700void SelectSetting::setStateValue(const QString& value, bool state)
     701{
     702    int index = values.findIndex(value);
     703
     704    if (index == -1)
     705    {
     706        if (expand)
     707        {
     708            addSelection(value, value, true);
     709        }
     710        else
     711        {
     712            VERBOSE(VB_IMPORTANT, QString("SelectSetting(%1)::setStateValue(%2, %3) - invalid value")
     713                    .arg(getName())
     714                    .arg(value)
     715                    .arg(state));
     716        }
     717    }
     718    else
     719    {
     720        setState(index, state);
     721    }
     722}
     723
     724void SelectSetting::setValue(const QString& newValue)
     725{
     726    for(uint i = 0 ; i < states.size() ; ++i)
     727        states[i] = false;
     728    selectionIndices.clear();
     729    selectionLabels.clear();
     730    selectionValues.clear();
     731
     732    selectionValues = QStringList::split(';', newValue);
     733
     734    for (QStringList::iterator iter = selectionValues.begin(); iter != selectionValues.end(); iter++)
     735    {
     736        int index = values.findIndex(*iter);
     737
     738        if (index == -1)
     739        {
     740            if (expand)
     741            {
     742                labels.append(*iter);
     743                values.append(*iter);
     744                states.append(true);
     745
     746                emit selectionAdded(*iter, *iter, true);
     747
     748                selectionIndices.append(states.count() - 1);
     749                selectionLabels.append(*iter);
     750           }
     751            else
     752            {
     753                VERBOSE(VB_IMPORTANT,
     754                        "SelectSetting(" << getName() << ")::setValue(" << *iter << "): invalid value ");
     755                iter = selectionValues.erase(iter);
     756                iter--;
     757            }
     758        }
     759        else
     760        {
     761            selectionIndices.append(index);
     762            selectionLabels.append(labels[index]);
     763            states[index] = true;
     764        }
     765    }
     766
     767    updateValue();
     768}
     769
     770void SelectSetting::updateValue()
     771{
     772    QString newValue("");
     773    for (QStringList::const_iterator iter = selectionValues.begin(); iter != selectionValues.end(); iter++)
     774    {
     775        if (!newValue.isEmpty())
     776            newValue.append(';');
     777        newValue.append(*iter);
     778     }
     779     Setting::setValue(newValue);
     780     emit selectionChanged();
     781}
     782
    581783QWidget* LabelSetting::configWidget(ConfigurationGroup *cg, QWidget* parent,
    582784                                    const char* widgetName) {
    583785    (void)cg;
     
    779981    }
    780982
    781983    QLabel* value = new QLabel(widget);
    782     value->setText(labels[current]);
     984    value->setText(getValue());
    783985    value->setBackgroundOrigin(QWidget::WindowOrigin);
    784986
    785987    connect(this, SIGNAL(valueChanged(const QString&)),
     
    788990    return widget;
    789991}
    790992
     993ComboBoxSetting::ComboBoxSetting(Storage *_storage, bool _rw, int _step) :
     994    SelectSetting(_storage, _rw),
     995    rw(_rw),
     996    widget(NULL),
     997    step(_step)
     998{
     999    connect(this, SIGNAL(selectionAdded(const QString&, const QString&, bool)),
     1000            this, SLOT(selectionAdded(const QString&, const QString&, bool)));
     1001    connect(this, SIGNAL(selectionChanged()),
     1002            this, SLOT(selectionChanged()));
     1003}
     1004
    7911005QWidget* ComboBoxSetting::configWidget(ConfigurationGroup *cg, QWidget* parent,
    7921006                                       const char* widgetName) {
    7931007    QHBox* box;
     
    8161030    box->setStretchFactor(widget, 1);
    8171031
    8181032    for(unsigned int i = 0 ; i < labels.size() ; ++i)
     1033    {
    8191034        widget->insertItem(labels[i]);
     1035        if (states[i])
     1036            widget->setCurrentItem(i);
     1037    }
    8201038
    821     if (isSet)
    822         widget->setCurrentItem(current);
     1039    setState(widget->currentItem(), true);
    8231040
    8241041    if (1 < step)
    8251042        widget->setStep(step);
    8261043
    827     if (rw)
    828         connect(widget, SIGNAL(highlighted(const QString &)),
    829                 this, SLOT(setValue(const QString &)));
    830     else
    831         connect(widget, SIGNAL(highlighted(int)),
    832                 this, SLOT(setValue(int)));
    833 
     1044    connect(widget, SIGNAL(highlighted(const QString &)),
     1045            this, SLOT(setCurrentLabel(const QString &)));
    8341046    connect(widget, SIGNAL(destroyed()),
    8351047            this, SLOT(widgetDestroyed()));
    8361048    connect(this, SIGNAL(selectionsCleared()),
     
    8631075    }
    8641076}
    8651077
    866 void ComboBoxSetting::setValue(QString newValue)
     1078void ComboBoxSetting::selectionAdded(const QString& label, const QString&, bool)
    8671079{
    868     if (!rw)
     1080    if (widget)
    8691081    {
    870         VERBOSE(VB_IMPORTANT, "ComboBoxSetting::setValue(QString): "
    871                 "BUG: attempted to set value of read-only ComboBox");
    872         return;
     1082        widget->insertItem(label);
    8731083    }
    874     Setting::setValue(newValue);
    875     if (widget)
    876         widget->setCurrentItem(current);
    877 };
     1084}
    8781085
    879 void ComboBoxSetting::setValue(int which)
     1086void ComboBoxSetting::selectionChanged()
    8801087{
    8811088    if (widget)
    882         widget->setCurrentItem(which);
    883     SelectSetting::setValue(which);
    884 };
     1089    {
     1090        widget->setCurrentItem(getSelectionIndices().first());
     1091    }
     1092}
    8851093
    8861094void HostRefreshRateComboBox::ChangeResolution(const QString& resolution)
    8871095{
    8881096    clearSelections();
    889    
     1097
    8901098    const vector<short> list = GetRefreshRates(resolution);
    8911099    addSelection(QObject::tr("Any"), "0");
    8921100    int hz50 = -1, hz60 = -1;
    8931101    for (uint i=0; i<list.size(); ++i)
    894     {       
     1102    {
    8951103        QString sel = QString::number(list[i]);
    8961104        addSelection(sel+" Hz", sel);
    8971105        hz50 = (50 == list[i]) ? i : hz50;
    8981106        hz60 = (60 == list[i]) ? i : hz60;
    8991107    }
    900    
    901     setValue(0);
     1108
    9021109    if ("640x480" == resolution || "720x480" == resolution)
    903         setValue(hz60+1);
    904     if ("640x576" == resolution || "720x576" == resolution)
    905         setValue(hz50+1);
    906    
     1110        setCurrent(hz60 + 1);
     1111    else if ("640x576" == resolution || "720x576" == resolution)
     1112        setCurrent(hz50 + 1);
     1113    else
     1114        setCurrent(0);
     1115
    9071116    setEnabled(list.size());
    9081117}
    9091118
     
    9831192        QRadioButton* button = new QRadioButton(widget, NULL);
    9841193        button->setBackgroundOrigin(QWidget::WindowOrigin);
    9851194        button->setText(labels[i]);
    986         if (isSet && i == current)
     1195        if (states[i])
    9871196            button->setDown(true);
    9881197    }
    9891198
     1199    setState(widget->selectedId(), true);
     1200
    9901201    cg = cg;
    9911202
    9921203    return widget;
     
    12801491    save(table);
    12811492}
    12821493
    1283 void ListBoxSetting::setEnabled(bool b)
     1494
     1495ListBoxSetting::ListBoxSetting(Storage *_storage, MythListBox::SelectionMode mode) :
     1496    SelectSetting(_storage),
     1497    selectionMode(mode),
     1498    widget(NULL)
    12841499{
    1285     Configurable::setEnabled(b);
    1286     if (widget)
    1287         widget->setEnabled(b);
     1500    connect(this, SIGNAL(selectionAdded(const QString&, const QString&, bool)),
     1501            this, SLOT(selectionAdded(const QString&, const QString&, bool)));
     1502    connect(this, SIGNAL(selectionChanged()),
     1503            this, SLOT(selectionChanged()));
    12881504}
    12891505
    12901506void ListBoxSetting::addSelection(
     
    13091525
    13101526    widget = new MythListBox(box);
    13111527    widget->setBackgroundOrigin(QWidget::WindowOrigin);
     1528    widget->setSelectionMode(selectionMode);
    13121529    widget->setHelpText(getHelpText());
    13131530
    1314     for(unsigned int i = 0 ; i < labels.size() ; ++i) {
     1531    for(uint i = 0 ; i < labels.size() ; ++i) {
    13151532        widget->insertItem(labels[i]);
    1316         if (isSet && current == i)
    1317             widget->setCurrentItem(i);
     1533        widget->setSelected(i, states[i]);
    13181534    }
    13191535
    13201536    connect(widget, SIGNAL(destroyed()),
     
    13291545            this, SIGNAL(editButtonPressed(int)));
    13301546    connect(widget, SIGNAL(deleteButtonPressed(int)),
    13311547            this, SIGNAL(deleteButtonPressed(int)));
    1332     connect(this, SIGNAL(valueChanged(const QString&)),
    1333             widget, SLOT(setCurrentItem(const QString&)));
    1334     connect(widget, SIGNAL(highlighted(int)),
    1335             this, SLOT(setValueByIndex(int)));
     1548    connect(widget, SIGNAL(selectionChanged()),
     1549            this, SLOT(updateSelection()));
    13361550
    13371551    if (cg)
    13381552        connect(widget, SIGNAL(changeHelpText(QString)), cg,
    13391553                SIGNAL(changeHelpText(QString)));
    13401554
    13411555    widget->setFocus();
    1342     widget->setSelectionMode(selectionMode);
    13431556
    13441557    return box;
    13451558}
    13461559
    1347 void ListBoxSetting::setSelectionMode(MythListBox::SelectionMode mode)
     1560void ListBoxSetting::setEnabled(bool b)
    13481561{
    1349    selectionMode = mode;
    1350    if (widget)
    1351        widget->setSelectionMode(selectionMode);
     1562    Configurable::setEnabled(b);
     1563    if (widget)
     1564        widget->setEnabled(b);
    13521565}
    13531566
    1354 void ListBoxSetting::setValueByIndex(int index)
     1567void ListBoxSetting::selectionAdded(const QString& label, const QString&, bool)
    13551568{
    1356     if (((uint)index) < values.size())
    1357         setValue(values[index]);
     1569    if (widget)
     1570    {
     1571        widget->insertItem(label);
     1572    }
    13581573}
    13591574
    1360 void ImageSelectSetting::addImageSelection(const QString& label,
    1361                                            QImage* image,
    1362                                            QString value,
    1363                                            bool select) {
    1364     images.push_back(image);
    1365     addSelection(label, value, select);
     1575void ListBoxSetting::selectionChanged()
     1576{
     1577    if (widget)
     1578        for (uint i = 0; i < states[i]; ++i)
     1579            widget->setSelected(i, states[i]);
    13661580}
    13671581
    1368 ImageSelectSetting::~ImageSelectSetting() {
    1369     while (images.size() > 0) {
    1370         delete images.back();
    1371         images.pop_back();
    1372     }
     1582void ListBoxSetting::updateSelection()
     1583{
     1584    if (widget)
     1585        for (uint i = 0; i < widget->count(); ++i)
     1586            setState(i, widget->item(i)->isSelected());
    13731587}
    13741588
    1375 void ImageSelectSetting::imageSet(int num)
     1589
     1590ImageSelectSetting::ImageSelectSetting(Storage *_storage) :
     1591    ComboBoxSetting(_storage),
     1592    imagelabel(NULL)
    13761593{
    1377     if (num >= (int)images.size())
    1378         return;
    1379 
    1380     if (!images[current])
    1381         return;
    1382 
    1383     QImage temp = *(images[current]);
    1384     temp = temp.smoothScale((int)(184 * m_hmult), (int)(138 * m_hmult),
    1385                             QImage::ScaleMin);
    1386 
    1387     QPixmap tmppix(temp);
    1388     imagelabel->setPixmap(tmppix);
     1594    images.setAutoDelete(true);
    13891595}
    13901596
    13911597QWidget* ImageSelectSetting::configWidget(ConfigurationGroup *cg,
     
    13961602
    13971603    gContext->GetScreenSettings(width, m_wmult, height, m_hmult);
    13981604
    1399     QHBox* box;
    1400     if (labelAboveWidget)
    1401     {
    1402         box = dynamic_cast<QHBox*>(new QVBox(parent, widgetName));
    1403         box->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,
    1404                                        QSizePolicy::Maximum));
    1405     }
    1406     else
    1407         box = new QHBox(parent, widgetName);
    1408 
     1605    QHBox* box = new QHBox(parent, widgetName);
    14091606    box->setBackgroundOrigin(QWidget::WindowOrigin);
     1607    box->setSpacing(100);
    14101608
    1411     if (getLabel() != "")
    1412     {
    1413         QLabel* label = new QLabel(box);
    1414         label->setText(getLabel() + ":");
    1415         label->setBackgroundOrigin(QWidget::WindowOrigin);
    1416     }
     1609    ComboBoxSetting::configWidget(cg, box);
    14171610
    1418     MythComboBox *widget = new MythComboBox(false, box);
    1419     widget->setBackgroundOrigin(QWidget::WindowOrigin);
    1420 
    1421     QLabel *testlabel = new QLabel(box);
    1422     testlabel->setText("  ");
    1423     testlabel->setBackgroundOrigin(QWidget::WindowOrigin);
    1424 
    14251611    imagelabel = new QLabel(box);
    14261612    imagelabel->setBackgroundOrigin(QWidget::WindowOrigin);
    14271613
    1428     for (unsigned int i = 0 ; i < images.size() ; ++i)
    1429         widget->insertItem(labels[i]);
     1614    selectionChanged();
    14301615
    1431     if (isSet)
    1432         widget->setCurrentItem(current);
    1433     else
    1434         current = 0;
     1616    connect(widget, SIGNAL(highlighted(int)), this, SLOT(imageSet(int)));
    14351617
    1436     if (images.size() != 0 && current < images.size() && images[current])
    1437     {
    1438         QImage temp = *(images[current]);
    1439         temp = temp.smoothScale((int)(184 * m_hmult), (int)(138 * m_hmult),
    1440                                 QImage::ScaleMin);
    1441  
    1442         QPixmap tmppix(temp);
    1443         imagelabel->setPixmap(tmppix);
     1618    return box;
     1619}
     1620
     1621void ImageSelectSetting::addSelection(const QString& label,
     1622                                      QImage* image,
     1623                                      QString value,
     1624                                      bool select)
     1625{
     1626    if (labels.find(label) == labels.end())
     1627    {
     1628        images.append(image);
     1629        SelectSetting::addSelection(label, value, select);
    14441630    }
    1445     else
     1631}
     1632
     1633void ImageSelectSetting::imageSet(int num)
     1634{
     1635    if (imagelabel)
    14461636    {
    14471637        QPixmap tmppix((int)(184 * m_hmult), (int)(138 * m_hmult));
    1448         tmppix.fill(black);
    14491638
     1639        if (num < (int)images.count() && images.at(num))
     1640            tmppix = images.at(num)->smoothScale((int)(184 * m_hmult),
     1641                                                 (int)(138 * m_hmult),
     1642                                                  QImage::ScaleMin);
     1643        else
     1644            tmppix.fill(black);
     1645
    14501646        imagelabel->setPixmap(tmppix);
    14511647    }
     1648}
    14521649
    1453     connect(widget, SIGNAL(highlighted(int)), this, SLOT(setValue(int)));
    1454     connect(widget, SIGNAL(highlighted(int)), this, SLOT(imageSet(int)));
     1650void ImageSelectSetting::selectionChanged()
     1651{
     1652    imageSet(getSelectionIndices().first());
     1653    ComboBoxSetting::selectionChanged();
     1654}
    14551655
    1456     connect(this, SIGNAL(selectionsCleared()),
    1457             widget, SLOT(clear()));
    14581656
    1459     if (cg)
    1460         connect(widget, SIGNAL(changeHelpText(QString)), cg,
    1461                 SIGNAL(changeHelpText(QString)));
    1462 
    1463     return box;
    1464 }
    1465 
    14661657HostnameSetting::HostnameSetting(Storage *storage) : Setting(storage)
    14671658{
    14681659    setVisible(false);
  • libs/libmyth/dbsettings.cpp

     
    7474    VerticalConfigurationGroup(false, true, false, false)
    7575{
    7676    setLabel(QObject::tr("Database Configuration") + " 1/2");
    77    
     77
    7878    info = new TransLabelSetting();
    7979
    8080    MSqlQuery query(MSqlQuery::InitCon());
     
    8686                                   "Please verify your database settings "
    8787                                   "below."));
    8888    addChild(info);
    89    
     89
    9090    dbHostName = new TransLineEditSetting(true);
    9191    dbHostName->setLabel(QObject::tr("Host name"));
    9292    dbHostName->setHelpText(QObject::tr("The host name or IP address of "
     
    100100                                    "on, if it's not the default database "
    101101                                    "port."));
    102102    addChild(dbPort);
    103    
     103
    104104    dbName = new TransLineEditSetting(true);
    105105    dbName->setLabel(QObject::tr("Database"));
    106106    dbName->setHelpText(QObject::tr("The name of the database. "
     
    113113                                        "connecting to the database. "
    114114                                        "This information is required."));
    115115    addChild(dbUserName);
    116    
     116
    117117    dbPassword = new TransLineEditSetting(true);
    118118    dbPassword->setLabel(QObject::tr("Password"));
    119119    dbPassword->setHelpText(QObject::tr("The password to use while "
    120120                                        "connecting to the database. "
    121121                                        "This information is required."));
    122122    addChild(dbPassword);
    123    
     123
    124124    dbType = new TransComboBoxSetting(false);
    125125    dbType->setLabel(QObject::tr("Database type"));
    126126    dbType->addSelection(QObject::tr("MySQL"), "QMYSQL3");
    127127    //dbType->addSelection(QObject::tr("PostgreSQL"), "QPSQL7");
    128     dbType->setValue(0);
     128    dbType->setCurrent(0);
    129129    dbType->setHelpText(QObject::tr("The database implementation used "
    130130                                    "for your server."));
    131131    addChild(dbType);
     
    203203void MythDbSettings1::load()
    204204{
    205205    DatabaseParams params = gContext->GetDatabaseParams();
    206    
     206
    207207    if (params.dbHostName.isEmpty() ||
    208208        params.dbUserName.isEmpty() ||
    209209        params.dbPassword.isEmpty() ||
    210210        params.dbName.isEmpty())
    211211        info->setValue(info->getValue() + "\nRequired fields are marked "
    212212                                          "with an asterisk (*).");
    213    
     213
    214214    dbHostName->setValue(params.dbHostName);
    215215    if (params.dbHostName.isEmpty())
    216216        dbHostName->setLabel("* " + dbHostName->getLabel());
     
    227227    dbName->setValue(params.dbName);
    228228    if (params.dbName.isEmpty())
    229229        dbName->setLabel("* " + dbName->getLabel());
    230        
     230
    231231    if (params.dbType == "QMYSQL3")
    232         dbType->setValue(0);
     232        dbType->setCurrent(0);
    233233    else if (params.dbType == "QPSQL7")
    234         dbType->setValue(1);
     234        dbType->setCurrent(1);
    235235}
    236236
    237237void MythDbSettings2::load()
  • libs/libmyth/mythwidgets.cpp

     
    12731273void MythListBox::polish(void)
    12741274{
    12751275    QListBox::polish();
    1276    
     1276
    12771277    QPalette pal = palette();
    12781278    QColorGroup::ColorRole role = QColorGroup::Highlight;
    12791279    pal.setColor(QPalette::Active, role, pal.active().button());
    12801280    pal.setColor(QPalette::Inactive, role, pal.active().button());
    12811281    pal.setColor(QPalette::Disabled, role, pal.active().button());
    1282    
     1282
    12831283    setPalette(pal);
    12841284}
    12851285
     
    13181318                }
    13191319            }
    13201320            else
    1321             {   
     1321            {
    13221322                if (text(i).lower() == matchText.lower())
    13231323                {
    13241324                    setCurrentItem(i);
    13251325                    break;
    13261326                }
    1327             }       
     1327            }
    13281328        }
    1329     }           
     1329    }
    13301330}
    13311331
    13321332void MythListBox::keyPressEvent(QKeyEvent* e)
     
    13511351                        handled = true;
    13521352                        continue;
    13531353                    }
    1354                    
     1354
    13551355                    key = Key_Up;
    13561356                }
    13571357                else if (action == "DOWN")
     
    13631363                        handled = true;
    13641364                        continue;
    13651365                    }
    1366                    
     1366
    13671367                    key = Key_Down;
    13681368                }
    13691369                else if (action == "LEFT")
    13701370                {
    1371                     focusNextPrevChild(false);
     1371                    if (selectionMode() == Multi)
     1372                        toggleCurrentItem();
    13721373                    handled = true;
    13731374                    continue;
    13741375                }
    13751376                else if (action == "RIGHT")
    13761377                {
    1377                     focusNextPrevChild(true);
     1378                    if (selectionMode() == Multi)
     1379                        toggleCurrentItem();
    13781380                    handled = true;
    13791381                    continue;
    13801382                }
     
    14061408
    14071409void MythListBox::focusOutEvent(QFocusEvent *e)
    14081410{
     1411    if (selectionMode() == Single)
     1412        setSelected(currentItem(), false);
     1413
    14091414    QPalette pal = palette();
    14101415    QColorGroup::ColorRole role = QColorGroup::Highlight;
    14111416    pal.setColor(QPalette::Active, role, pal.active().button());
    14121417    pal.setColor(QPalette::Inactive, role, pal.active().button());
    14131418    pal.setColor(QPalette::Disabled, role, pal.active().button());
    1414    
     1419
    14151420    setPalette(pal);
    14161421    QListBox::focusOutEvent(e);
    14171422}
     
    14191424void MythListBox::focusInEvent(QFocusEvent *e)
    14201425{
    14211426    this->unsetPalette();
    1422    
     1427
    14231428    emit changeHelpText(helptext);
    14241429    QListBox::focusInEvent(e);
     1430
     1431    if (selectionMode() == Single)
     1432        setSelected(currentItem(), true);
    14251433}
    14261434
    14271435/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • libs/libmyth/settings.h

     
    287287{
    288288    Q_OBJECT
    289289
    290   protected:
    291     SelectSetting(Storage *_storage) :
    292         Setting(_storage), current(0), isSet(false) { }
     290protected:
     291    SelectSetting(Storage *_storage, bool _expand = false) :
     292        Setting(_storage), expand(_expand) { };
    293293
    294   public:
     294public:
    295295    virtual void addSelection(const QString& label,
    296                               QString value=QString::null,
    297                               bool select=false);
     296                              QString value = QString::null,
     297                              bool state = false);
    298298
    299     virtual void clearSelections(void);
     299    virtual const QValueList<uint> getSelectionIndices() const {return selectionIndices;}
     300    virtual const QStringList&     getSelectionLabels() const  {return selectionLabels;}
     301    virtual const QStringList&     getSelectionValues() const  {return selectionValues;}
    300302
     303    virtual void clearSelections();
     304
    301305    virtual void fillSelectionsFromDir(const QDir& dir, bool absPath=true);
    302306
    303307signals:
    304     void selectionAdded(const QString& label, QString value);
    305     void selectionsCleared(void);
     308    void selectionAdded(const QString& label, const QString& value, bool state);
     309    void selectionChanged();
     310    void selectionsCleared();
    306311
    307312public slots:
     313    virtual void setCurrent(uint which);
     314    virtual void setCurrentLabel(const QString& label);
     315    virtual void setCurrentValue(const QString& value);
     316    virtual void setState(uint which, bool state);
     317    virtual void setStateLabel(const QString& label, bool state);
     318    virtual void setStateValue(const QString& value, bool state);
    308319
     320private slots:
    309321    virtual void setValue(const QString& newValue);
    310     virtual void setValue(int which);
    311322
    312     virtual QString getSelectionLabel(void) const {
    313         if (!isSet)
    314             return QString::null;
    315         return labels[current];
    316     };
     323protected:
     324    virtual void updateValue();
    317325
    318     virtual int getValueIndex(QString value) {
    319         selectionList::iterator iter = values.begin();
    320         int ret = 0;
    321         while (iter != values.end()) {
    322             if (*iter == value) {
    323                 return ret;
    324             } else {
    325                 ret++;
    326                 iter++;
    327             }
    328         }
    329         return 0;
    330     };
    331 
    332326protected:
    333     typedef vector<QString> selectionList;
    334     selectionList labels;
    335     selectionList values;
    336     unsigned current;
    337     bool isSet;
     327    bool             expand;            // whether to expand selections via 'set' calls
     328    QStringList      labels;            // strings that are displayed
     329    QStringList      values;            // strings that are used internally
     330    QValueList<bool> states;            // states of possible selections
     331    QValueList<uint> selectionIndices;  // indices of currently selected items
     332    QStringList      selectionLabels;   // labels of currently selected items
     333    QStringList      selectionValues;   // values of currently selected items
    338334};
    339335
    340336class MPUBLIC SelectLabelSetting : public SelectSetting
     
    350346class MPUBLIC ComboBoxSetting: public SelectSetting {
    351347    Q_OBJECT
    352348
    353 protected:
    354     ComboBoxSetting(Storage *_storage, bool _rw = false, int _step = 1) :
    355         SelectSetting(_storage), rw(_rw), widget(NULL), step(_step) { }
    356 
    357349public:
    358     virtual void setValue(QString newValue);
    359     virtual void setValue(int which);
     350    ComboBoxSetting(Storage *_storage, bool _rw = false, int _step = 1);
    360351
     352public:
    361353    virtual QWidget* configWidget(ConfigurationGroup *cg, QWidget* parent,
    362354                                  const char* widgetName = 0);
    363355
     
    366358    virtual void setEnabled(bool b);
    367359    virtual void setVisible(bool b);
    368360
    369 public slots:
    370     void addSelection(const QString& label,
    371                       QString value=QString::null,
    372                       bool select=false) {
    373         if (widget != NULL)
    374             widget->insertItem(label);
    375         SelectSetting::addSelection(label, value, select);
    376     };
    377361protected slots:
     362    virtual void selectionAdded(const QString& label, const QString&, bool state);
     363    virtual void selectionChanged();
    378364    void widgetDestroyed() { widget=NULL; };
    379365
    380 private:
     366protected:
    381367    bool rw;
    382368    MythComboBox *widget;
    383 
    384 protected:
    385369    int step;
    386370};
    387371
    388372class MPUBLIC ListBoxSetting: public SelectSetting {
    389373    Q_OBJECT
     374
    390375public:
    391     ListBoxSetting(Storage *_storage) :
    392         SelectSetting(_storage), widget(NULL),
    393         selectionMode(MythListBox::Single) { }
     376    ListBoxSetting(Storage *_storage, MythListBox::SelectionMode mode = MythListBox::Single);
    394377
     378public:
    395379    virtual QWidget* configWidget(ConfigurationGroup *cg, QWidget* parent,
    396380                                  const char* widgetName = 0);
    397381
    398382    void setFocus() { if (widget) widget->setFocus(); }
    399     void setSelectionMode(MythListBox::SelectionMode mode);
    400     void setCurrentItem(int i) { if (widget) widget->setCurrentItem(i); }
    401     void setCurrentItem(const QString& str)  { if (widget) widget->setCurrentItem(str); }
    402383
    403384    virtual void setEnabled(bool b);
    404385
     
    414395                      bool           select = false);
    415396
    416397protected slots:
    417     void setValueByIndex(int index);
     398    virtual void selectionAdded(const QString& label, const QString&, bool state);
     399    virtual void selectionChanged();
     400    virtual void updateSelection();
     401
    418402    void widgetDestroyed() { widget=NULL; };
     403
    419404protected:
    420     MythListBox* widget;
    421405    MythListBox::SelectionMode selectionMode;
     406    MythListBox* widget;
    422407};
    423408
    424409class MPUBLIC RadioSetting : public SelectSetting
     
    429414                                  const char* widgetName = 0);
    430415};
    431416
    432 class MPUBLIC ImageSelectSetting: public SelectSetting {
     417class MPUBLIC ImageSelectSetting: public ComboBoxSetting {
    433418    Q_OBJECT
     419
     420protected:
     421    ImageSelectSetting(Storage *_storage);
     422
    434423public:
    435     ImageSelectSetting(Storage *_storage) : SelectSetting(_storage) { }
    436     virtual ~ImageSelectSetting();
    437424    virtual QWidget* configWidget(ConfigurationGroup *cg, QWidget* parent,
    438425                                  const char* widgetName = 0);
    439426
    440     virtual void addImageSelection(const QString& label,
    441                                    QImage* image,
    442                                    QString value=QString::null,
    443                                    bool select=false);
     427    virtual void addSelection(const QString& label,
     428                              QImage* image,
     429                              QString value = QString::null,
     430                              bool select = false);
     431private:
     432    virtual void addSelection(const QString&, QString, bool) {}
     433
    444434protected slots:
     435    virtual void selectionChanged();
    445436    void imageSet(int);
    446437
    447438protected:
    448     vector<QImage*> images;
    449     QLabel *imagelabel;
     439    QPtrList<QImage> images;
     440    QLabel* imagelabel;
    450441    float m_hmult, m_wmult;
    451442};
    452443
     
    738729        LineEditSetting(this, rw), HostDBStorage(this, name) { }
    739730};
    740731
     732class MPUBLIC HostListBox: public ListBoxSetting, public HostDBStorage
     733{
     734  public:
     735    HostListBox(const QString &name, MythListBox::SelectionMode mode = MythListBox::Single) :
     736        ListBoxSetting(this, mode), HostDBStorage(this, name) { }
     737};
     738
    741739class MPUBLIC HostImageSelect : public ImageSelectSetting, public HostDBStorage
    742740{
    743741  public:
  • libs/libmyth/mythwidgets.h

     
    367367    void focusInEvent(QFocusEvent *e);
    368368};
    369369
    370 class MPUBLIC MythListBox: public QListBox {
     370class MPUBLIC MythListBox: public QListBox
     371{
    371372    Q_OBJECT
    372373  public:
    373374    MythListBox(QWidget* parent);
  • programs/mythfrontend/globalsettings.cpp

     
    541541                                "shows to delete first.  LiveTV recordings "
    542542                                "will always expire before normal "
    543543                                "recordings."));
    544     bc->setValue(1);
     544    bc->setCurrent(1);
    545545    return bc;
    546546}
    547547
     
    700700    for (int i = 0; i < 4; i++)
    701701        gc->addSelection(str[i], QString::number(i));
    702702
    703     gc->setValue(1);
     703    gc->setCurrent(1);
    704704    gc->setHelpText(help);
    705705
    706706    return gc;
     
    14691469        gc->addSelection(QString::number(i), QString::number(i));
    14701470    gc->addSelection(QObject::tr("All"), QString::number(-1));
    14711471    gc->setLabel(QObject::tr("Xinerama screen"));
    1472     gc->setValue(0);
     1472    gc->setCurrent(0);
    14731473    gc->setHelpText(QObject::tr("Run on the specified screen or "
    14741474                    "spanning all screens."));
    14751475    return gc;
     
    16481648        DisplayResScreen dscr(w, h, -1, -1, -1.0, 0);
    16491649        short rate = -1;
    16501650        int i = DisplayResScreen::FindBestMatch(scr, dscr, rate);
    1651         gc->setValue((i >= 0) ? i : scr.size()-1);
     1651        gc->setCurrent((i >= 0) ? i : scr.size()-1);
    16521652    }
    16531653
    16541654    return gc;
     
    19481948            continue;
    19491949        }
    19501950
    1951         addImageSelection(theme->fileName(), previewImage);
     1951        addSelection(theme->fileName(), previewImage);
    19521952    }
    19531953
    1954     setValue("G.A.N.T.");
     1954    setCurrent(0);
    19551955}
    19561956
    19571957class StyleSetting: public HostComboBox {
     
    19921992    gc->addSelection(QObject::tr("callsign"), "<sign>");
    19931993    gc->addSelection(QObject::tr("name"), "<name>");
    19941994    gc->setHelpText(QObject::tr("Your preferred channel format."));
    1995     gc->setValue(1);
     1995    gc->setCurrent(1);
    19961996    return gc;
    19971997}
    19981998
     
    20062006    gc->addSelection(QObject::tr("callsign"), "<sign>");
    20072007    gc->addSelection(QObject::tr("name"), "<name>");
    20082008    gc->setHelpText(QObject::tr("Your preferred long channel format."));
    2009     gc->setValue(2);
     2009    gc->setCurrent(2);
    20102010    return gc;
    20112011}
    20122012
  • programs/mythfrontend/main.cpp

     
    511511        themename = themelist[rand() % themelist.size()];
    512512
    513513    ThemeSelector Theme;
    514     Theme.setValue(themename);
     514    Theme.setCurrentValue(themename);
    515515    Theme.save();
    516516
    517517    return themename;
  • programs/mythtv-setup/backendsettings.cpp

     
    218218    GlobalComboBox *gc = new GlobalComboBox("EITTimeOffset");
    219219    gc->setLabel(QObject::tr("Time offset for EIT listings"));
    220220    init_time_offsets(gc);
    221     gc->setValue(1);
     221    gc->setCurrent(1);
    222222    QString helptext = QObject::tr(
    223223        "Adjust the relative timezone of the EIT EPG data.  "
    224224        "'Auto' converts the EIT time to local time using your "