Ticket #199: changroups.19873.3.diff

File changroups.19873.3.diff, 35.0 KB (added by bander.ajba@…, 15 years ago)

ignore the previous patch. this one works -- trunk svn 19873

  • mythtv/themes/classic/tv_settings.xml

     
    7171   </button>
    7272
    7373   <button>
     74      <type>TV_SETTINGS_CHANNEL_GROUP</type>
     75      <text>Channel Groups</text>
     76      <action>SETTINGS CHANNELGROUPS</action>
     77   </button>
     78
     79   <button>
    7480      <type>TV_SETTINGS_PLAYBACK_GROUPS</type>
    7581      <text>Playback Groups</text>
    7682      <text lang="IT">Gruppi di Riproduzione</text>
  • mythtv/themes/DVR/tv_settings.xml

     
    7474   </button>
    7575
    7676   <button>
     77      <type>TV_SETTINGS_CHANNEL_GROUP</type>
     78      <text>Channel Groups</text>
     79      <action>SETTINGS CHANNELGROUPS</action>
     80   </button>
     81
     82   <button>
    7783      <type>TV_SETTINGS_PLAYBACK_GROUPS</type>
    7884      <text>Playback Groups</text>
    7985      <text lang="SV">Uppspelningsgrupper</text>
  • mythtv/libs/libmythtv/dbchannelinfo.cpp

     
    1616DBChannel::DBChannel(
    1717    const QString &_channum, const QString &_callsign,
    1818    uint _chanid, uint _major_chan, uint _minor_chan,
    19     uint _favorite, uint _mplexid, bool _visible,
     19    uint _mplexid, bool _visible,
    2020    const QString &_name, const QString &_icon) :
    2121    channum(_channum),
    2222    callsign(_callsign), chanid(_chanid),
    2323    major_chan(_major_chan), minor_chan(_minor_chan),
    24     favorite(_favorite), mplexid(_mplexid), visible(_visible),
     24    mplexid(_mplexid), visible(_visible),
    2525    name(_name), icon(_icon)
    2626{
    2727    channum.detach();
     
    3939    chanid     = other.chanid;
    4040    major_chan = other.major_chan;
    4141    minor_chan = other.minor_chan;
    42     favorite   = other.favorite;
    4342    mplexid    = (other.mplexid == 32767) ? 0 : other.mplexid;
    4443    visible    = other.visible;
    4544    name       = other.name; name.detach();
  • mythtv/libs/libmythtv/channelutil.h

     
    168168    static QString GetVideoFilters(uint sourceid, const QString &channum)
    169169        { return GetChannelValueStr("videofilters", sourceid, channum); }
    170170
    171     static DBChanList GetChannels(uint srcid, bool vis_only, QString grp="");
     171    static DBChanList GetChannels(uint srcid, bool vis_only, QString grp="", int changrpid=-1);
    172172    static void    SortChannels(DBChanList &list, const QString &order,
    173173                                bool eliminate_duplicates = false);
    174174    static void    EliminateDuplicateChanNum(DBChanList &list);
  • mythtv/libs/libmythtv/dbchannelinfo.h

     
    2121    DBChannel(const DBChannel&);
    2222    DBChannel(const QString &_channum, const QString &_callsign,
    2323              uint _chanid, uint _major_chan, uint _minor_chan,
    24               uint _favorite, uint _mplexid, bool _visible,
     24              uint _mplexid, bool _visible,
    2525              const QString &_name, const QString &_icon);
    2626    DBChannel& operator=(const DBChannel&);
    2727
     
    3434    uint    chanid;
    3535    uint    major_chan;
    3636    uint    minor_chan;
    37     uint    favorite;
    3837    uint    mplexid;
    3938    bool    visible;
    4039    QString name;
  • mythtv/libs/libmythtv/libmythtv.pro

     
    156156HEADERS += channeleditor.h          channelsettings.h
    157157HEADERS += previewgenerator.h       transporteditor.h
    158158HEADERS += importicons.h
     159HEADERS += channelgroup.h           channelgroupsettings.h
    159160
    160161# Remove when everything is switched to MythUI
    161162HEADERS += proglist_qt.h
     
    181182SOURCES += channeleditor.cpp        channelsettings.cpp
    182183SOURCES += previewgenerator.cpp     transporteditor.cpp
    183184SOURCES += importicons.cpp
     185SOURCES += channelgroup.cpp         channelgroupsettings.cpp
    184186
    185187# Remove when everything is switched to MythUI
    186188SOURCES += proglist_qt.cpp
  • mythtv/libs/libmythtv/guidegrid.h

     
    1818#include "programinfo.h"
    1919#include "programlist.h"
    2020#include "channelutil.h"
     21#include "channelgroup.h"
    2122
    2223using namespace std;
    2324
     
    8485                          const QString &startChanNum,
    8586                          bool           thread = false,
    8687                          TV            *player = NULL,
    87                           bool           allowsecondaryepg = true);
     88                          bool           allowsecondaryepg = true,
     89                          int           *changrpid = NULL);
    8890
    8991    DBChanList GetSelection(void) const;
    9092
     
    134136    GuideGrid(MythMainWindow *parent,
    135137              uint chanid = 0, QString channum = "",
    136138              TV *player = NULL, bool allowsecondaryepg = true,
    137               const char *name = "GuideGrid");
     139              const char *name = "GuideGrid",
     140              int changrpid=-1);
    138141   ~GuideGrid();
    139142
     143    int  GetChanGrp(void) {return m_changrpid;}
    140144    void paintEvent(QPaintEvent *);
    141145
    142146  private slots:
     
    155159    void paintPrograms(QPainter *);
    156160    void paintCurrentInfo(QPainter *);
    157161    void paintInfo(QPainter *);
     162    void paintChanGroupInfo(QPainter *p);
    158163    void paintVideo(QPainter *);
    159164 
    160165    void resizeImage(QPixmap *, QString);
     
    180185    QRect infoRect;
    181186    QRect curInfoRect;
    182187    QRect videoRect;
     188    QRect changrpRect;
    183189
    184190    void fillChannelInfos(bool gotostartchannel = true);
    185191    int  FindChannel(uint chanid, const QString &channum,
     
    189195
    190196    void fillProgramInfos(void);
    191197    void fillProgramRowInfos(unsigned int row);
     198   
     199    void fillChanGroupInfo(void);
    192200
    193201    void setStartChannel(int newStartChannel);
    194202
    195203    void createProgramLabel(int, int);
     204   
     205    int SelectChannelGroup();
    196206
    197207    PixmapChannel       *GetChannelInfo(uint chan_idx, int sel = -1);
    198208    const PixmapChannel *GetChannelInfo(uint chan_idx, int sel = -1) const;
     
    222232    int m_currentCol;
    223233
    224234    bool selectState;
    225     bool showFavorites;
    226235    bool sortReverse;
    227236    QString channelFormat;
    228237
     
    247256    QTimer *timeCheck;
    248257
    249258    bool keyDown;
     259   
     260    int  m_changrpid;
     261    ChannelGroupList m_changrplist;
    250262
    251263    QMutex         jumpToChannelLock;
    252264    JumpToChannel *jumpToChannel;
  • mythtv/libs/libmythtv/tv_play.h

     
    2525#include "videoouttypes.h"
    2626#include "volumebase.h"
    2727#include "inputinfo.h"
     28#include "channelgroup.h"
    2829
    2930#include <qobject.h>
    3031
     
    264265    void ChangeVolume(PlayerContext*, bool up);
    265266    void ToggleMute(PlayerContext*);
    266267
     268    // Channel Groups
     269    void SaveChannelGroup(void);
     270
     271
    267272    void SetNextProgPIPState(PIPState state) { jumpToProgramPIPState = state; }
    268273
    269274    // Used for UDPNotify
     
    509514
    510515    void FillOSDTreeMenu(       const PlayerContext*, OSDGenericTree*) const;
    511516    void FillMenuPlaying(       const PlayerContext*, OSDGenericTree*) const;
     517    void processChanGroupEntry(QString action);
    512518    void FillMenuPxP(           const PlayerContext*, OSDGenericTree*) const;
    513519    void FillMenuInputSwitching(const PlayerContext*, OSDGenericTree*) const;
    514520    void FillMenuVideoAspect(   const PlayerContext*, OSDGenericTree*) const;
     
    745751    QMap<int,int>             recorderPlaybackInfoTimerId;
    746752    QMap<int,ProgramInfo>     recorderPlaybackInfo;
    747753
     754    // Channel favorite group stuff   
     755    int channel_group_id;
     756    uint browse_changrp;
     757    ChannelGroupList m_changrplist;
     758    DBChanList m_channellist;
     759
    748760    // Network Control stuff
    749761    MythDeque<QString> networkControlCommands;
    750762
  • mythtv/libs/libmythtv/guidegrid.cpp

     
    3434#include "util.h"
    3535#include "remoteutil.h"
    3636#include "channelutil.h"
     37//#include "guidegrid.h"
    3738#include "cardutil.h"
    3839
    3940QWaitCondition epgIsVisibleCond;
     
    171172    const QString &channum,
    172173    bool           thread,
    173174    TV            *player,
    174     bool           allowsecondaryepg)
     175    bool           allowsecondaryepg,
     176    int           *changrpid)
    175177{
    176178    DBChanList channel_changed;
     179    int        channel_group  = -1;
    177180
     181    if (changrpid != NULL)
     182      channel_group = *changrpid;
     183
    178184    //if (thread)
    179185    //    qApp->lock();
    180186
     
    182188
    183189    GuideGrid *gg = new GuideGrid(gContext->GetMainWindow(),
    184190                                  chanid, channum,
    185                                   player, allowsecondaryepg, "guidegrid");
     191                                  player, allowsecondaryepg, "guidegrid",
     192                                  channel_group);
    186193
    187194    gg->Show();
    188195
     
    210217    //if (thread)
    211218    //    qApp->lock();
    212219
     220    if (changrpid != NULL)
     221      *changrpid = gg->GetChanGrp();
     222
    213223    delete gg;
    214224
    215225    gContext->removeCurrentLocation();
     
    223233GuideGrid::GuideGrid(MythMainWindow *parent,
    224234                     uint chanid, QString channum,
    225235                     TV *player, bool allowsecondaryepg,
    226                      const char *name) :
     236                     const char *name, int changrpid) :
    227237    MythDialog(parent, name),
    228238    m_player(player),
    229239    using_null_video(false),
     
    240250    DISPLAY_TIMES = 30;
    241251    int maxchannel = 0;
    242252    m_currentStartChannel = 0;
     253    m_changrpid = changrpid;
     254    m_changrplist = ChannelGroup::GetChannelGroups();
    243255
    244256    m_context = 0;
    245257
     
    252264    infoRect = QRect(0, 0, 0, 0);
    253265    curInfoRect = QRect(0, 0, 0, 0);
    254266    videoRect = QRect(0, 0, 0, 0);
     267    changrpRect = QRect(0, 0, 0, 0);
    255268
    256269    jumpToChannelEnabled =
    257270        gContext->GetNumSetting("EPGEnableJumpToChannel", 1);
     
    274287            EmbedTVWindow();
    275288    }
    276289
    277     showFavorites = gContext->GetNumSetting("EPGShowFavorites", 0);
    278290    gridfilltype = gContext->GetNumSetting("EPGFillType", UIGuideType::Alpha);
    279291    if (gridfilltype < (int)UIGuideType::Alpha)
    280292    { // update old settings to new fill types
     
    331343            container->SetDrawFontShadow(false);
    332344    }
    333345
     346    container = theme->GetSet("channel_group");
     347    if (container)
     348    {
     349        UITextType *type = (UITextType *)container->GetType("changroup");
     350        QString changroup;
     351       
     352        changroup = ChannelGroup::GetChannelGroupName(m_changrplist, m_changrpid);
     353       
     354        if (type)
     355            type->SetText(changroup);
     356    }
     357
    334358    channelOrdering = gContext->GetSetting("ChannelOrdering", "channum");
    335359    dateformat = gContext->GetSetting("ShortDateFormat", "ddd d");
    336360    unknownTitle = gContext->GetSetting("UnknownTitle", "Unknown");
     
    703727        curInfoRect = area;
    704728    if (name.toLower() == "current_video")
    705729        videoRect = area;
     730    if (name.toLower() == "channel_group")
     731        changrpRect = area;
    706732}
    707733
    708734PixmapChannel *GuideGrid::GetChannelInfo(uint chan_idx, int sel)
     
    891917    m_channelInfoIdx.clear();
    892918    m_currentStartChannel = 0;
    893919
    894     DBChanList channels = ChannelUtil::GetChannels(0, true);
     920    DBChanList channels = ChannelUtil::GetChannels(0, true, "", m_changrpid);
    895921    ChannelUtil::SortChannels(channels, channelOrdering, false);
    896922
    897     if (showFavorites)
    898     {
    899         DBChanList tmp;
    900         for (uint i = 0; i < channels.size(); i++)
    901         {
    902             if (channels[i].favorite)
    903                 tmp.push_back(channels[i]);
    904         }
    905 
    906         if (!tmp.empty())
    907             channels = tmp;
    908     }
    909 
    910923    typedef vector<uint> uint_list_t;
    911924    QMap<QString,uint_list_t> channum_to_index_map;
    912925    QMap<QString,uint_list_t> callsign_to_index_map;
     
    11241137    }
    11251138}
    11261139
     1140void GuideGrid::fillChanGroupInfo(void)
     1141{
     1142    LayerSet   *container = NULL;
     1143    UITextType *type = NULL;
     1144   
     1145    container = theme->GetSet("channel_group");
     1146    if (container)
     1147    {
     1148        type = (UITextType *)container->GetType("changroup");
     1149        QString changroup;
     1150       
     1151        changroup = ChannelGroup::GetChannelGroupName(m_changrplist, m_changrpid);
     1152       
     1153        if (type)
     1154            type->SetText(changroup);
     1155    }
     1156}
     1157
    11271158void GuideGrid::fillProgramRowInfos(unsigned int row)
    11281159{
    11291160    LayerSet *container = NULL;
     
    14011432        paintPrograms(&p);
    14021433    if (r.intersects(curInfoRect))
    14031434        paintCurrentInfo(&p);
     1435    if (r.intersects(changrpRect))
     1436        paintChanGroupInfo(&p);
    14041437
    14051438    // if jumpToChannel has its own rect, use that;
    14061439    // otherwise use the date's rect
     
    15381571    p->drawPixmap(dr.topLeft(), pix);
    15391572}
    15401573
     1574void GuideGrid::paintChanGroupInfo(QPainter *p)
     1575{
     1576    QRect dr = changrpRect;
     1577    QPixmap pix(dr.size());
     1578    pix.fill(this, dr.topLeft());
     1579    QPainter tmp(&pix);
     1580
     1581    LayerSet *container = NULL;
     1582    container = theme->GetSet("channel_group");
     1583    if (container)
     1584    {
     1585        container->Draw(&tmp, 1, m_context);
     1586        container->Draw(&tmp, 2, m_context);
     1587        container->Draw(&tmp, 3, m_context);
     1588        container->Draw(&tmp, 4, m_context);
     1589        container->Draw(&tmp, 5, m_context);
     1590        container->Draw(&tmp, 6, m_context);
     1591        container->Draw(&tmp, 7, m_context);
     1592        container->Draw(&tmp, 8, m_context);
     1593    }
     1594    tmp.end();
     1595    p->drawPixmap(dr.topLeft(), pix);
     1596}
     1597
    15411598bool GuideGrid::paintChannels(QPainter *p)
    15421599{
    15431600    QRect cr = channelRect;
     
    16331690        }
    16341691
    16351692        QString tmpChannelFormat = channelFormat;
    1636         if (chinfo->favorite > 0)
    1637         {
    1638             tmpChannelFormat.insert(
    1639                 tmpChannelFormat.indexOf('<'), "<MARK:fav>");
    1640         }
    16411693
    16421694        if (unavailable)
    16431695        {
     
    16731725        }
    16741726    }
    16751727
     1728    if (m_channelInfos.size() == 0)
     1729    {
     1730       // if the user has selected a channel group with no channels
     1731       // Reset the text and icon. This will display one blank line
     1732       // to show that the channel group has no channels
     1733       if (type)
     1734       {
     1735         type->SetText(0, "");
     1736         type->ResetImage(0);
     1737       }
     1738    }
     1739
    16761740    if (container)
    16771741    {
    16781742        container->Draw(&tmp, 1, m_context);
     
    18081872
    18091873void GuideGrid::toggleGuideListing()
    18101874{
    1811     showFavorites = (!showFavorites);
    1812     generateListings();
     1875    int oldchangrpid = m_changrpid;
     1876   
     1877    m_changrpid = ChannelGroup::GetNextChannelGroup(m_changrplist, oldchangrpid);
     1878   
     1879    if (oldchangrpid != m_changrpid)
     1880      generateListings();
     1881     
     1882    fillChanGroupInfo();
     1883    update(changrpRect);
    18131884}
    18141885
    18151886void GuideGrid::generateListings()
     
    18281899    update(fullRect);
    18291900}
    18301901
     1902int GuideGrid::SelectChannelGroup()
     1903{
     1904    if (m_changrplist.empty())
     1905    {
     1906      MythPopupBox::showOkPopup(gContext->GetMainWindow(), "",
     1907                                "You don't have any channel groups defined");
     1908
     1909      return -1;
     1910    }
     1911   
     1912    MythPopupBox *popup = new MythPopupBox(gContext->GetMainWindow(), "SelectChannelGroup Popup");
     1913    popup->addLabel("Select Channel Group");
     1914
     1915    for (uint i = 0; i < m_changrplist.size(); i++)
     1916      popup->addButton(m_changrplist[i].name);
     1917
     1918    popup->addButton(tr("Cancel"))->setFocus();
     1919
     1920    DialogCode result = popup->ExecPopup();
     1921   
     1922    popup->deleteLater();
     1923
     1924    // If the user cancelled, return a special value
     1925    if (result == MythDialog::Rejected)
     1926      return -1;
     1927    else
     1928      return m_changrplist[result - kDialogCodeListStart].grpid;
     1929}
     1930
    18311931void GuideGrid::toggleChannelFavorite()
    18321932{
    1833     MSqlQuery query(MSqlQuery::InitCon());
     1933    int grpid;
    18341934
     1935    if (m_changrpid == -1)
     1936    {
     1937      grpid = SelectChannelGroup();
     1938     
     1939      if (grpid == -1)
     1940        return;
     1941    }
     1942    else
     1943      grpid = m_changrpid;
     1944
    18351945    // Get current channel id, and make sure it exists...
    18361946    int chanNum = m_currentRow + m_currentStartChannel;
    18371947    if (chanNum >= (int)m_channelInfos.size())
     
    18421952        chanNum = 0;
    18431953
    18441954    PixmapChannel *ch = GetChannelInfo(chanNum);
    1845     uint favid  = ch->favorite;
    18461955    uint chanid = ch->chanid;
    18471956
    1848     if (favid > 0)
    1849     {
    1850         query.prepare("DELETE FROM favorites WHERE favid = :FAVID ;");
    1851         query.bindValue(":FAVID", favid);
    1852         query.exec();
    1853     }
    1854     else
    1855     {
    1856         // We have no favorites record...Add one to toggle...
    1857         query.prepare("INSERT INTO favorites (chanid) VALUES (:FAVID);");
    1858         query.bindValue(":FAVID", chanid);
    1859         query.exec();
    1860     }
    1861 
    1862     if (showFavorites)
     1957    if (m_changrpid == -1)
     1958        // If currently viewing all channels, allow to add only not delete
     1959        ChannelGroup::ToggleChannel(chanid, grpid, false);
     1960     else
     1961        // Only allow delete if viewing the favorite group in question
     1962        ChannelGroup::ToggleChannel(chanid, grpid, true);
     1963     
     1964    // If viewing favorites, refresh because a channel was removed
     1965    if (m_changrpid != -1)
    18631966        generateListings();
    1864     else
    1865     {
    1866         int maxchannel = 0;
    1867         DISPLAY_CHANS = desiredDisplayChans;
    1868         fillChannelInfos(false);
    1869         maxchannel = max((int)GetChannelCount() - 1, 0);
    1870         DISPLAY_CHANS = min(DISPLAY_CHANS, maxchannel + 1);
    1871 
    1872         repaint(channelRect);
    1873     }
    18741967}
    18751968
    18761969void GuideGrid::cursorLeft()
  • mythtv/libs/libmythtv/channelutil.cpp

     
    15701570    return true;
    15711571}
    15721572
    1573 DBChanList ChannelUtil::GetChannels(uint sourceid, bool vis_only, QString grp)
     1573DBChanList ChannelUtil::GetChannels(uint sourceid, bool vis_only, QString grp, int changrpid)
    15741574{
    15751575    DBChanList list;
    1576     QMap<uint,uint> favorites;
     1576   
    15771577    MSqlQuery query(MSqlQuery::InitCon());
    1578     query.prepare(
    1579         "SELECT chanid, favid "
    1580         "FROM favorites");
    1581     if (!query.exec() || !query.isActive())
    1582         MythDB::DBError("get channels -- favorites", query);
    1583     else
    1584     {
    1585         while (query.next())
    1586             favorites[query.value(0).toUInt()] = query.value(1).toUInt();
    1587     }
    15881578
    15891579    QString qstr =
    1590         "SELECT channum, callsign, chanid, "
     1580        "SELECT channum, callsign, channel.chanid, "
    15911581        "       atsc_major_chan, atsc_minor_chan, "
    15921582        "       name, icon, mplexid, visible "
    15931583        "FROM channel ";
    15941584
     1585    // Select only channels from the specified channel group
     1586    if (changrpid > -1)
     1587        qstr += QString(",channelgroup ");
     1588
    15951589    if (sourceid)
    15961590        qstr += QString("WHERE sourceid='%1' ").arg(sourceid);
    15971591    else
     
    15991593            "WHERE cardinput.sourceid = channel.sourceid   AND "
    16001594            "      cardinput.cardid   = capturecard.cardid     ";
    16011595
     1596    if (changrpid > -1)
     1597    {
     1598        qstr += QString("AND channel.chanid = channelgroup.chanid "
     1599                        "AND channelgroup.grpid ='%1' ").arg(changrpid);
     1600    }
     1601
    16021602    if (vis_only)
    16031603        qstr += "AND visible=1 ";
    16041604
     
    16231623            query.value(2).toUInt(),                      /* chanid     */
    16241624            query.value(3).toUInt(),                      /* ATSC major */
    16251625            query.value(4).toUInt(),                      /* ATSC minor */
    1626             favorites[query.value(2).toUInt()],           /* favid      */
    16271626            query.value(7).toUInt(),                      /* mplexid    */
    16281627            query.value(8).toBool(),                      /* visible    */
    16291628            query.value(5).toString(),                    /* name       */
     
    18061805                (mplexid_restriction &&
    18071806                 (mplexid_restriction != it->mplexid))));
    18081807    }
    1809     else if (CHANNEL_DIRECTION_UP == direction)
     1808    else if ((CHANNEL_DIRECTION_UP == direction) || (CHANNEL_DIRECTION_FAVORITE == direction))
    18101809    {
    18111810        do
    18121811        {
     
    18191818                (mplexid_restriction &&
    18201819                 (mplexid_restriction != it->mplexid))));
    18211820    }
    1822     else if (CHANNEL_DIRECTION_FAVORITE == direction)
    1823     {
    1824         do
    1825         {
    1826             it++;
    1827             if (it == sorted.end())
    1828                 it = sorted.begin();
    1829         }
    1830         while ((it != start) &&
    1831                (!it->favorite ||
    1832                 (skip_non_visible && !it->visible) ||
    1833                 (mplexid_restriction &&
    1834                  (mplexid_restriction != it->mplexid))));
    1835     }
    18361821
    18371822    return it->chanid;
    18381823}
  • mythtv/libs/libmythtv/tv_play.cpp

     
    346346
    347347    bool allowrerecord = tv->getAllowRerecord();
    348348    bool deleterecording = tv->getRequestDelete();
     349   
     350    tv->SaveChannelGroup();
    349351
    350352    delete tv;
    351353
     
    421423            "in the program guide", "0");
    422424    REG_KEY("TV Frontend", "GUIDE", "Show the Program Guide", "S");
    423425    REG_KEY("TV Frontend", "FINDER", "Show the Program Finder", "#");
    424     REG_KEY("TV Frontend", "NEXTFAV", "Toggle showing all channels or just "
    425             "favorites in the program guide.", "/");
     426    REG_KEY("TV Frontend", "NEXTFAV", "Cycle through channel groups and all channels "
     427            "in the program guide.", "/,S");
    426428    REG_KEY("TV Frontend", "CHANUPDATE", "Switch channels without exiting "
    427429            "guide in Live TV mode.", "X");
    428430    REG_KEY("TV Frontend", "VOLUMEDOWN", "Volume down", "[,{,F10,Volume Down");
     
    784786    osd_general_timeout  = gContext->GetNumSetting("OSDGeneralTimeout", 2);
    785787    osd_prog_info_timeout= gContext->GetNumSetting("OSDProgramInfoTimeout", 3);
    786788    tryUnflaggedSkip     = gContext->GetNumSetting("TryUnflaggedSkip", 0);
     789    channel_group_id     = gContext->GetNumSetting("ChannelGroupDefault", -1);
     790    browse_changrp       = gContext->GetNumSetting("BrowseChannelGroup", 0);
    787791    smartForward         = gContext->GetNumSetting("SmartForward", 0);
    788792    stickykeys           = gContext->GetNumSetting("StickyKeys");
    789793    ff_rew_repos         = gContext->GetNumSetting("FFRewReposTime", 100)/100.0;
     
    798802    if (!feVBI.isEmpty())
    799803        vbimode = VBIMode::Parse(gContext->GetSetting(feVBI));
    800804
     805    channel_group_id     = gContext->GetNumSetting("ChannelGroupDefault", -1);
     806    browse_changrp       = gContext->GetNumSetting("BrowseChannelGroup", 0);
     807   
     808    if (browse_changrp && (channel_group_id > -1))
     809    {
     810      m_channellist = ChannelUtil::GetChannels(0, true, "channum, callsign", channel_group_id);
     811      ChannelUtil::SortChannels(m_channellist, "channum", true);
     812    }
     813   
     814    m_changrplist  = ChannelGroup::GetChannelGroups();
     815
    801816    if (createWindow)
    802817    {
    803818        MythMainWindow *mainWindow = gContext->GetMainWindow();
     
    973988    return ret;
    974989}
    975990
     991void TV::SaveChannelGroup(void)
     992{
     993    int changrpid             = gContext->GetNumSetting("ChannelGroupDefault", -1);
     994    int remember_last_changrp = gContext->GetNumSetting("ChannelGroupRememberLast", 0);
     995     if (remember_last_changrp && (changrpid != channel_group_id))
     996       gContext->SaveSetting("ChannelGroupDefault", channel_group_id);
     997}
     998
     999
    9761000/**
    9771001 * \brief get tv state of active player context
    9781002 */
     
    61536177void TV::ToggleChannelFavorite(PlayerContext *ctx)
    61546178{
    61556179    if (ctx->recorder)
    6156         ctx->recorder->ToggleChannelFavorite();
     6180        ;//ctx->recorder->ToggleChannelFavorite();
    61576181}
    61586182
    61596183QString TV::GetQueuedInput(void) const
     
    64086432void TV::ChangeChannel(PlayerContext *ctx, int direction)
    64096433{
    64106434    bool muted = false;
     6435    if ((browse_changrp || (direction == CHANNEL_DIRECTION_FAVORITE)) &&
     6436        (channel_group_id > -1) && (direction != CHANNEL_DIRECTION_SAME))
     6437    {
     6438       uint    chanid;
     6439       // Collect channel info
     6440       ctx->LockPlayingInfo(__FILE__, __LINE__);
     6441       uint    old_chanid  = ctx->playingInfo->chanid.toUInt();
     6442       ctx->UnlockPlayingInfo(__FILE__, __LINE__);
     6443       chanid = ChannelUtil::GetNextChannel(m_channellist, old_chanid, 0, direction);
     6444       ChangeChannel(ctx,chanid, "");
     6445       return;
     6446    } else if (direction == CHANNEL_DIRECTION_FAVORITE)
     6447        direction = CHANNEL_DIRECTION_UP;
    64116448
    64126449    QString oldinputname = ctx->recorder->GetInput();
    64136450
     
    75797616
    75807617    // Actually show the pop-up UI
    75817618    DBChanList changeChannel;
     7619    int changrpid = channel_group_id;
    75827620    ProgramInfo *nextProgram = NULL;
     7621   
    75837622    switch (editType)
    75847623    {
    75857624        case kScheduleProgramGuide:
    75867625        {
    75877626            TV *player = (pause_active) ? NULL : this;
    75887627            changeChannel = GuideGrid::Run(
    7589                 chanid, channum, false, player, isLiveTV && player);
     7628                chanid, channum, false, player, isLiveTV && player,&changrpid);
    75907629            break;
    75917630        }
    75927631        case kScheduleProgramFinder:
     
    76257664    actx = GetPlayerReadLock(-1, __FILE__, __LINE__);
    76267665    StopEmbedding(actx);               // Undo any embedding
    76277666    DoSetPauseState(actx, was_paused); // Restore pause states
     7667
     7668    // if channel group was changed in EPG update local info
     7669    if ((changrpid != channel_group_id) && (editType == kScheduleProgramGuide))
     7670    {
     7671        channel_group_id = changrpid;
     7672        if (browse_changrp)
     7673        {
     7674            VERBOSE(VB_IMPORTANT, LOC +
     7675               QString("Reloading channel group list for %1").arg(channel_group_id));
     7676            m_channellist = ChannelUtil::GetChannels(0, true, "channum, callsign", channel_group_id);
     7677            ChannelUtil::SortChannels(m_channellist, "channum", true);
     7678        }
     7679    }
     7680   
     7681
    76287682    // If user selected a new channel in the EPG, change to that channel
    76297683    if (isLiveTV && changeChannel.size())
    76307684        ChangeChannel(actx, changeChannel);
     
    84748528{
    84758529    if (!browsemode)
    84768530        BrowseStart(ctx);
     8531     if ((browse_changrp || (direction == BROWSE_FAVORITE)) &&
     8532         (channel_group_id > -1) && (direction != BROWSE_SAME) &&
     8533         (direction != BROWSE_RIGHT) && (direction != BROWSE_LEFT))
     8534     {
     8535       uint chanid;
     8536       int  dir;
    84778537
     8538       if ( (direction == BROWSE_UP) || (direction == BROWSE_FAVORITE) )
     8539         dir = CHANNEL_DIRECTION_UP;
     8540       else if (direction == BROWSE_DOWN)
     8541         dir = CHANNEL_DIRECTION_DOWN;
     8542       else // this should never happen, but just in case
     8543         dir = direction;
     8544
     8545       chanid = ChannelUtil::GetNextChannel(m_channellist, browsechanid, 0, dir);
     8546       VERBOSE(VB_IMPORTANT, QString("Get channel: %1").arg(chanid));
     8547       browsechanid  = chanid;
     8548       browsechannum = QString::null;
     8549       direction     = BROWSE_SAME;
     8550     }
     8551     else if ((channel_group_id == -1) && (direction == BROWSE_FAVORITE))
     8552       direction = BROWSE_UP;
    84788553    OSD *osd = GetOSDLock(ctx);
    84798554    if (ctx->paused || !osd)
    84808555    {
     
    93769451    {
    93779452        ToggleAdjustFill(actx, (AdjustFillMode) action.right(1).toInt());
    93789453    }
     9454    else if (action.left(10) == "CHANGROUP_")
     9455        processChanGroupEntry(action);
    93799456    else if (action == "GUIDE")
    93809457        EditSchedule(actx, kScheduleProgramGuide);
    93819458    else if (action == "FINDER")
     
    95259602    }
    95269603}
    95279604
     9605void TV::processChanGroupEntry(QString action)
     9606{
     9607    if (action == "CHANGROUP_ALL_CHANNELS")
     9608      channel_group_id = -1;
     9609    else
     9610    {
     9611      action.remove("CHANGROUP_");
     9612      channel_group_id = action.toInt();
     9613       if (browse_changrp)
     9614      {
     9615         m_channellist = ChannelUtil::GetChannels(0, true, "channum, callsign", channel_group_id);
     9616         ChannelUtil::SortChannels(m_channellist, "channum", true);
     9617      }
     9618    }
     9619}
     9620
    95289621void TV::FillOSDTreeMenu(
    95299622    const PlayerContext *ctx, OSDGenericTree *treeMenu) const
    95309623{
    95319624    new OSDGenericTree(treeMenu, tr("Program Guide"), "GUIDE");
     9625    OSDGenericTree *cg_item = new OSDGenericTree(treeMenu, tr("Channel Groups"),"CHANGROUP");
     9626    new OSDGenericTree(cg_item, tr("All Channels"), "CHANGROUP_ALL_CHANNELS",(channel_group_id == -1) ? 1 : 0,NULL, "CHANNELGROUP");
     9627    ChannelGroupList::const_iterator it = m_changrplist.begin();
     9628    for (; it != m_changrplist.end(); ++it)
     9629    {
     9630        QString name = QString("CHANGROUP_%1").arg(it->grpid);
     9631        new OSDGenericTree(cg_item, it->name, name,
     9632                           ((int)(it->grpid) == channel_group_id) ? 1 : 0,
     9633                           NULL, "CHANNELGROUP");
     9634    }
    95329635
    95339636    FillMenuPxP(ctx, treeMenu);
    95349637
  • mythtv/programs/mythfrontend/globalsettings.cpp

     
    31563156    return gc;
    31573157}
    31583158
    3159 static HostCheckBox *EPGShowFavorites()
    3160 {
    3161     HostCheckBox *gc = new HostCheckBox("EPGShowFavorites");
    3162     gc->setLabel(QObject::tr("Only display 'favorite' channels"));
    3163     gc->setHelpText(QObject::tr("If enabled, the EPG will initially display "
    3164                     "only the channels marked as favorites. Pressing "
    3165                     "\"4\" will toggle between displaying favorites and all "
    3166                     "channels."));
    3167     gc->setValue(false);
    3168     return gc;
    3169 }
    31703159
    31713160static HostSpinBox *EPGChanDisplay()
    31723161{
     
    31943183    return gc;
    31953184}
    31963185
     3186static HostCheckBox *ChannelGroupRememberLast()
     3187{
     3188    HostCheckBox *gc = new HostCheckBox("ChannelGroupRememberLast");
     3189    gc->setLabel(QObject::tr("Remember last channel group"));
     3190    gc->setHelpText(QObject::tr("If enabled, the EPG will initially display "
     3191                    "only the channels from the last channel group selected. Pressing "
     3192                    "\"4\" will toggle channel group."));
     3193    gc->setValue(false);
     3194    return gc;
     3195}
     3196
     3197static HostComboBox *ChannelGroupDefault()
     3198{
     3199    HostComboBox *gc = new HostComboBox("ChannelGroupDefault");
     3200    gc->setLabel(QObject::tr("Default channel group"));
     3201
     3202    ChannelGroupList changrplist;
     3203
     3204    changrplist = ChannelGroup::GetChannelGroups();
     3205
     3206    gc->addSelection(QObject::tr("All Channels"), "-1");
     3207
     3208    ChannelGroupList::iterator it;
     3209
     3210    for (it = changrplist.begin(); it < changrplist.end(); ++it)
     3211       gc->addSelection(it->name, QString("%1").arg(it->grpid));
     3212
     3213    gc->setHelpText(QObject::tr("Default channel group to be shown in the the EPG"
     3214                    "Pressing "
     3215                    "\"4\" will toggle channel group."));
     3216    gc->setValue(false);
     3217    return gc;
     3218}
     3219
     3220static HostCheckBox *BrowseChannelGroup()
     3221{
     3222    HostCheckBox *gc = new HostCheckBox("BrowseChannelGroup");
     3223    gc->setLabel(QObject::tr("Browse/Change channels from Channel Group"));
     3224    gc->setHelpText(QObject::tr("If enabled, LiveTV will browse or change channels "
     3225                    "from the selected channel group. \"All Channels\" "
     3226                    "channel group may be selected to browse all channels."));
     3227    gc->setValue(false);
     3228    return gc;
     3229}
     3230
     3231// Channel Group Settings
     3232class ChannelGroupSettings : public TriggeredConfigurationGroup
     3233{
     3234  public:
     3235    ChannelGroupSettings() : TriggeredConfigurationGroup(false, true, false, false)
     3236    {
     3237         setLabel(QObject::tr("Remember last channel group"));
     3238         setUseLabel(false);
     3239
     3240         Setting* RememberChanGrpEnabled = ChannelGroupRememberLast();
     3241         addChild(RememberChanGrpEnabled);
     3242         setTrigger(RememberChanGrpEnabled);
     3243
     3244         ConfigurationGroup* settings = new VerticalConfigurationGroup(false);
     3245         settings->addChild(ChannelGroupDefault());
     3246         addTarget("0", settings);
     3247
     3248         // show nothing if RememberChanGrpEnabled is on
     3249         addTarget("1", new VerticalConfigurationGroup(true));
     3250     };
     3251};
     3252
    31973253// General RecPriorities settings
    31983254
    31993255static GlobalCheckBox *GRSchedMoveHigher()
     
    49625018    general2->addChild(CategoryOverTimeSettings());
    49635019    addChild(general2);
    49645020
     5021    VerticalConfigurationGroup* changrp = new VerticalConfigurationGroup(false);
     5022    changrp->setLabel(QObject::tr("General (Channel Groups)"));
     5023    ChannelGroupSettings *changroupsettings = new ChannelGroupSettings();
     5024    changrp->addChild(changroupsettings);
     5025    changrp->addChild(BrowseChannelGroup());
     5026    addChild(changrp);
    49655027}
    49665028
    49675029EPGSettings::EPGSettings()
    49685030{
    49695031    VerticalConfigurationGroup* epg = new VerticalConfigurationGroup(false);
    4970     epg->setLabel(QObject::tr("Program Guide") + " 1/2");
     5032    epg->setLabel(QObject::tr("Program Guide") + " 1/3");
    49715033    epg->addChild(EPGFillType());
    49725034    epg->addChild(EPGShowCategoryColors());
    49735035    epg->addChild(EPGShowCategoryText());
    49745036    epg->addChild(EPGScrollType());
    49755037    epg->addChild(EPGShowChannelIcon());
    4976     epg->addChild(EPGShowFavorites());
    49775038    epg->addChild(WatchTVGuide());
    49785039    epg->addChild(EPGChanDisplay());
    49795040    epg->addChild(EPGTimeDisplay());
    49805041    addChild(epg);
    49815042
    49825043    VerticalConfigurationGroup* gen = new VerticalConfigurationGroup(false);
    4983     gen->setLabel(QObject::tr("Program Guide") + " 2/2");
     5044    gen->setLabel(QObject::tr("Program Guide") + " 2/3");
    49845045    gen->addChild(UnknownTitle());
    49855046    gen->addChild(UnknownCategory());
    49865047    gen->addChild(DefaultTVChannel());
    49875048    gen->addChild(SelectChangesChannel());
    49885049    gen->addChild(EPGRecThreshold());
    49895050    gen->addChild(EPGEnableJumpToChannel());
    4990     addChild(gen);
     5051    addChild(gen);   
    49915052}
    49925053
    49935054GeneralRecPrioritiesSettings::GeneralRecPrioritiesSettings()
  • mythtv/programs/mythfrontend/main.cpp

     
    5252#include "lcddevice.h"
    5353#include "langsettings.h"
    5454#include "mythcommandlineparser.h"
     55#include "channelgroupsettings.h"
    5556
    5657#include "myththemedmenu.h"
    5758#include "myththemebase.h"
     
    500501        EPGSettings settings;
    501502        settings.exec();
    502503    }
     504    else if (sel == "settings channelgroups")
     505    {
     506        ChannelGroupEditor editor;
     507        editor.exec();
     508     }
    503509    else if (sel == "settings generalrecpriorities")
    504510    {
    505511        GeneralRecPrioritiesSettings settings;
  • mythtv/programs/mythfrontend/tv_settings.xml

     
    9090      <text lang="DE">Wiedergabe OSD</text>
    9191      <action>SETTINGS OSD</action>
    9292   </button>
     93   
     94   <button>
     95      <type>TV_SETTINGS_CHANNEL_GROUP</type>
     96      <text>Channel Groups</text>
     97      <action>SETTINGS CHANNELGROUPS</action>
     98   </button>
    9399
    94100   <button>
    95101      <type>TV_SETTINGS_PLAYBACK_GROUPS</type>