Ticket #199: channelgroup.2.diff

File channelgroup.2.diff, 48.3 KB (added by Bill <level42@…>, 16 years ago)

Updated for SVN15504

  • libs/libmythtv/channelgroup.cpp

    diff -Naur --exclude='*.orig' --exclude='*.rej' mythtv-orig/libs/libmythtv/channelgroup.cpp mythtv/libs/libmythtv/channelgroup.cpp
    old new  
     1#include "libmyth/mythcontext.h"
     2#include "libmyth/mythdbcon.h"
     3#include <qsqldatabase.h>
     4#include <qheader.h>
     5#include <qcursor.h>
     6#include <qlayout.h>
     7#include <iostream>
     8#include "channelutil.h"
     9#include "channelgroup.h"
     10
     11#define LOC QString("Channel Group: ")
     12#define LOC_ERR QString("Channel Group, Error: ")
     13
     14// Storage class for channel group editor in settings
     15class ChannelGroupStorage : public Storage
     16{
     17  public:
     18    ChannelGroupStorage(Setting *_setting,
     19                    uint _chanid, QString _grpname) :
     20        setting(_setting), chanid(_chanid), grpname(_grpname) {}
     21    virtual ~ChannelGroupStorage() {};
     22
     23    virtual void load(void);
     24    virtual void save(void);
     25    virtual void save(QString destination);
     26
     27  protected:
     28    Setting *setting;
     29    uint    chanid;
     30    QString grpname;
     31    int     grpid;
     32};
     33
     34void ChannelGroupStorage::load(void)
     35{
     36    setting->setValue("0");
     37    setting->setUnchanged();
     38   
     39    MSqlQuery query(MSqlQuery::InitCon());
     40   
     41    QString qstr = "SELECT grpid FROM channelgroupnames WHERE name = :GRPNAME";
     42   
     43    query.prepare(qstr);
     44    query.bindValue(":GRPNAME", grpname);
     45
     46    if (!query.exec() || !query.isActive())
     47        MythContext::DBError("ChannelGroupStorage::load", query);
     48    else
     49    {
     50      query.next();
     51      grpid = query.value(0).toUInt();
     52   
     53      qstr = "SELECT * FROM channelgroup WHERE grpid = :GRPID AND chanid = :CHANID";
     54      query.prepare(qstr);
     55      query.bindValue(":GRPID",  grpid);
     56      query.bindValue(":CHANID", chanid);
     57
     58      if (!query.exec() || !query.isActive())
     59          MythContext::DBError("ChannelGroupStorage::load", query);
     60      else if (query.size() > 0)
     61        setting->setValue("1");
     62    }
     63}
     64
     65void ChannelGroupStorage::save(void)
     66{
     67    if (!setting->isChanged())
     68      return;
     69   
     70    QString value = setting->getValue();
     71   
     72    if (value == "1")
     73        ChannelGroup::ToggleChannel(chanid, grpid, false);
     74    else
     75        ChannelGroup::ToggleChannel(chanid, grpid, true);   
     76}
     77
     78void ChannelGroupStorage::save(QString destination)
     79{
     80    save();
     81}
     82
     83ChannelGroupItem& ChannelGroupItem::operator=(const ChannelGroupItem &other)
     84{
     85    grpid     = other.grpid;
     86    name      = QDeepCopy<QString>(other.name);
     87 
     88    return *this;
     89}
     90
     91ChannelGroupItem::ChannelGroupItem(const ChannelGroupItem &other)
     92{
     93    (*this) = other;
     94}
     95
     96inline bool lt_group(const ChannelGroupItem &a, const ChannelGroupItem &b)
     97{
     98    return QString::localeAwareCompare(a.name, b.name) < 0;
     99}
     100
     101bool ChannelGroup::ToggleChannel(uint chanid,int changrpid, int delete_chan)
     102{
     103    // Check if it already exists for that chanid...
     104    MSqlQuery query(MSqlQuery::InitCon());
     105    query.prepare(
     106        "SELECT channelgroup.id "
     107        "FROM channelgroup "
     108        "WHERE channelgroup.chanid = :CHANID AND "
     109        "channelgroup.grpid = :GRPID "
     110        "LIMIT 1");
     111    query.bindValue(":CHANID", chanid);
     112    query.bindValue(":GRPID", changrpid);
     113
     114    if (!query.exec() || !query.isActive())
     115    {
     116        MythContext::DBError("ChannelGroup::ToggleChannel", query);
     117        return false;
     118    }
     119    else if ((query.size() > 0) && delete_chan)
     120    {
     121        // We have a record...Remove it to toggle...
     122        query.next();
     123        QString id = query.value(0).toString();
     124        query.prepare(
     125            QString("DELETE FROM channelgroup "
     126                    "WHERE id = '%1'").arg(id));
     127        query.exec();
     128        VERBOSE(VB_IMPORTANT, LOC + QString("Removing channel with id=%1.").arg(id));
     129    }
     130    else if (query.size() == 0)
     131    {
     132        // We have no record...Add one to toggle...
     133        query.prepare(
     134            QString("INSERT INTO channelgroup (chanid,grpid) "
     135                    "VALUES ('%1','%2')").arg(chanid).arg(changrpid));
     136        query.exec();
     137        VERBOSE(VB_IMPORTANT, LOC + QString("Adding channel %1 to group %2.").arg(chanid).arg(changrpid));
     138    }
     139
     140    return true;
     141}
     142
     143ChannelGroupList ChannelGroup::GetChannelGroups(void)
     144{
     145    ChannelGroupList list;
     146   
     147    MSqlQuery query(MSqlQuery::InitCon());
     148   
     149    QString qstr = "SELECT grpid, name FROM channelgroupnames";
     150   
     151    query.prepare(qstr);
     152
     153    if (!query.exec() || !query.isActive())
     154        MythContext::DBError("ChannelGroup::GetChannelGroups", query);
     155    else
     156    {
     157        while (query.next())
     158        {
     159           ChannelGroupItem group(query.value(0).toUInt(),
     160                              query.value(1).toString());
     161           list.push_back(group);
     162        }
     163    }
     164   
     165    stable_sort(list.begin(), list.end(), lt_group);
     166
     167    return list;
     168}
     169
     170// Cycle through the available groups, then all channels
     171// Will cycle through to end then return -1
     172// To signify all channels.
     173int ChannelGroup::GetNextChannelGroup(const ChannelGroupList &sorted, int grpid)
     174{
     175    // If no groups return -1 for all channels
     176    if (sorted.empty())
     177      return -1;
     178   
     179    // If grpid is all channels (-1), then return the first grpid 
     180    if (grpid == -1)
     181      return sorted[0].grpid;
     182     
     183    ChannelGroupList::const_iterator it = find(sorted.begin(), sorted.end(), grpid);
     184
     185    // If grpid is not in the list, return -1 for all channels
     186    if (it == sorted.end())
     187        return -1;
     188
     189    ++it;
     190
     191    // If we reached the end, the next option is all channels (-1)
     192    if (it == sorted.end())
     193       return -1;
     194
     195    return it->grpid;
     196}
     197
     198QString ChannelGroup::GetChannelGroupName(const ChannelGroupList &sorted, int grpid)
     199{
     200    // All Channels
     201    if (grpid == -1)
     202      return "All Channels";
     203
     204    ChannelGroupList::const_iterator it = find(sorted.begin(), sorted.end(), grpid);
     205       
     206    // If grpid wasn't found, return blank.   
     207    if (it == sorted.end())
     208       return "";
     209    else
     210       return it->name;
     211}
     212
     213class ChannelCheckBox : public CheckBoxSetting, public ChannelGroupStorage
     214{
     215  public:
     216    ChannelCheckBox(const ChannelGroupConfig& _parent, const uint chanid, const QString channum,
     217               const QString channame, const QString grpname):
     218        CheckBoxSetting(this),
     219        ChannelGroupStorage(this, chanid, grpname)
     220    {
     221        setLabel(QObject::tr(QString("%1 %2").arg(channum).arg(channame)));
     222        setHelpText(QObject::tr("Select/Unselect channels for this channel group"));
     223    };
     224};
     225
     226ChannelGroupConfig::ChannelGroupConfig(QString _name)
     227    : name(_name)
     228{
     229    VerticalConfigurationGroup   *cgroup;
     230    HorizontalConfigurationGroup *columns;
     231
     232    DBChanList chanlist = ChannelUtil::GetChannels(0, true, "channum, callsign");
     233    ChannelUtil::SortChannels(chanlist, "channum", true);
     234
     235    DBChanList::iterator it = chanlist.begin();
     236    int i,j = 0;
     237    int p = 1;
     238    int pages = (int)((float)chanlist.size() / 8.0 / 3.0 + 0.5);
     239   
     240    do
     241    { 
     242        columns = new HorizontalConfigurationGroup(false,false,false,false);
     243        columns->setLabel(getName() + " " +
     244                          QObject::tr("Channel Group - Page ") +
     245                          QObject::tr(QString("%1 of %2").arg(p).arg(pages)));
     246       
     247        for (j = 0; ((j < 3) && (it < chanlist.end())); ++j)
     248        {
     249            cgroup = new VerticalConfigurationGroup(false,false,false,false);
     250           
     251            for (i = 0; ((i < 8) && (it < chanlist.end())); ++i)
     252            {
     253                cgroup->addChild(new ChannelCheckBox(*this, it->chanid, it->channum, it->name, _name));
     254                ++it;
     255            }
     256            columns->addChild(cgroup);
     257        }
     258       
     259        ++p;
     260        addChild(columns);
     261    } while (it < chanlist.end());
     262
     263}
     264
     265ChannelGroupEditor::ChannelGroupEditor(void) :
     266    listbox(new ListBoxSetting(this)), lastValue("__CREATE_NEW_GROUP__")
     267{
     268    listbox->setLabel(tr("Channel Groups"));
     269    addChild(listbox);
     270}
     271
     272void ChannelGroupEditor::open(QString name)
     273{
     274    lastValue = name;
     275    bool created = false;
     276
     277    if (name == "__CREATE_NEW_GROUP__")
     278    {
     279        name = "";
     280       
     281        bool ok = MythPopupBox::showGetTextPopup(gContext->GetMainWindow(),
     282            tr("Create New Channel Group"),
     283            tr("Enter group name or press SELECT to enter text via the "
     284               "On Screen Keyboard"), name);
     285        if (!ok)
     286            return;
     287
     288        MSqlQuery query(MSqlQuery::InitCon());
     289        query.prepare("INSERT INTO channelgroupnames (name) VALUES (:NAME);");
     290        query.bindValue(":NAME", name.utf8());
     291        if (!query.exec())
     292            MythContext::DBError("ChannelGroupEditor::open", query);
     293        else
     294            created = true;
     295    }
     296   
     297    ChannelGroupConfig group(name);
     298   
     299    if (group.exec() == QDialog::Accepted || !created)
     300        lastValue = name;
     301
     302};
     303
     304void ChannelGroupEditor::doDelete(void)
     305{
     306    QString name = listbox->getValue();
     307    if (name == "__CREATE_NEW_GROUP__")
     308        return;
     309
     310    QString message = tr("Delete '%1' Channel group?").arg(name);
     311   
     312    DialogCode value = MythPopupBox::Show2ButtonPopup(
     313        gContext->GetMainWindow(),
     314        "", message,
     315        tr("Yes, delete group"),
     316        tr("No, Don't delete group"), kDialogCodeButton1);
     317
     318    if (kDialogCodeButton0 == value)
     319    {
     320        MSqlQuery query(MSqlQuery::InitCon());
     321
     322        // Find out channel group id
     323        query.prepare("SELECT grpid FROM channelgroupnames WHERE name = :NAME;");
     324        query.bindValue(":NAME", name.utf8());
     325        if (!query.exec())
     326            MythContext::DBError("ChannelGroupEditor::doDelete", query);
     327        query.next();
     328        uint grpid = query.value(0).toUInt();
     329
     330        // Delete channels from this group
     331        query.prepare("DELETE FROM channelgroup WHERE grpid = :GRPID;");
     332        query.bindValue(":GRPID", grpid);
     333        if (!query.exec())
     334            MythContext::DBError("ChannelGroupEditor::doDelete", query);
     335       
     336        // Now delete the group from channelgroupnames
     337        query.prepare("DELETE FROM channelgroupnames WHERE name = :NAME;");
     338        query.bindValue(":NAME", name.utf8());
     339        if (!query.exec())
     340            MythContext::DBError("ChannelGroupEditor::doDelete", query);
     341
     342        lastValue = "__CREATE_NEW_GROUP__";
     343        load();
     344    }
     345
     346    listbox->setFocus();
     347}
     348
     349void ChannelGroupEditor::load(void)
     350{
     351    listbox->clearSelections();
     352   
     353    ChannelGroupList changrplist;
     354
     355    changrplist = ChannelGroup::GetChannelGroups();
     356
     357    ChannelGroupList::iterator it;
     358
     359    for (it = changrplist.begin(); it < changrplist.end(); ++it)
     360       listbox->addSelection(it->name);
     361       
     362    listbox->addSelection(tr("(Create new group)"), "__CREATE_NEW_GROUP__");
     363
     364    listbox->setValue(lastValue);
     365}
     366
     367DialogCode ChannelGroupEditor::exec(void)
     368{
     369    while (ConfigurationDialog::exec() == kDialogCodeAccepted)
     370        open(listbox->getValue());
     371
     372    return kDialogCodeRejected;
     373}
     374
     375MythDialog* ChannelGroupEditor::dialogWidget(MythMainWindow* parent,
     376                                          const char* widgetName)
     377{
     378    dialog = ConfigurationDialog::dialogWidget(parent, widgetName);
     379    connect(dialog, SIGNAL(menuButtonPressed()), this, SLOT(doDelete()));
     380    connect(dialog, SIGNAL(deleteButtonPressed()), this, SLOT(doDelete()));
     381    return dialog;
     382}
  • libs/libmythtv/channelgroup.h

    diff -Naur --exclude='*.orig' --exclude='*.rej' mythtv-orig/libs/libmythtv/channelgroup.h mythtv/libs/libmythtv/channelgroup.h
    old new  
     1#ifndef CHANNELGROUP_H
     2#define CHANNELGROUP_H
     3
     4#include "qstringlist.h"
     5#include "libmyth/settings.h"
     6#include "libmyth/mythwidgets.h"
     7
     8class ChannelGroupItem
     9{
     10  public:
     11    ChannelGroupItem(const ChannelGroupItem&);
     12    ChannelGroupItem(const uint _grpid,
     13                  const QString &_name) :
     14        grpid(_grpid), name(_name) {}
     15
     16    bool operator == (uint _grpid) const
     17        { return grpid == _grpid; }
     18
     19    ChannelGroupItem& operator=(const ChannelGroupItem&);
     20
     21  public:
     22    uint    grpid;
     23    QString name;
     24};
     25typedef vector<ChannelGroupItem> ChannelGroupList;
     26
     27/** \class ChannelGroup
     28*/
     29class MPUBLIC ChannelGroup
     30{
     31  public:
     32    // ChannelGroup
     33    static ChannelGroupList  GetChannelGroups(void);
     34    static bool              ToggleChannel(uint chanid,int changrpid, int delete_chan);
     35    static int               GetNextChannelGroup(const ChannelGroupList &sorted, int grpid);
     36    static QString           GetChannelGroupName(const ChannelGroupList &sorted, int grpid);
     37
     38   
     39  private:
     40
     41};
     42
     43class MPUBLIC ChannelGroupConfig: public ConfigurationWizard
     44{
     45 public:
     46    ChannelGroupConfig(QString _name);
     47    QString getName(void) const { return name; }
     48
     49 private:
     50    QString name;
     51};
     52
     53class MPUBLIC ChannelGroupEditor : public QObject, public ConfigurationDialog
     54{
     55    Q_OBJECT
     56
     57  public:
     58    ChannelGroupEditor(void);
     59    virtual DialogCode exec(void);
     60    virtual void load(void);
     61    virtual void save(void) { };
     62    virtual void save(QString) { };
     63    virtual MythDialog* dialogWidget(MythMainWindow* parent,
     64                                     const char* widgetName=0);
     65
     66  protected slots:
     67    void open(QString name);
     68    void doDelete(void);
     69
     70  protected:
     71    ListBoxSetting *listbox;
     72    QString         lastValue;
     73};
     74
     75#endif
  • libs/libmythtv/channelutil.cpp

    diff -Naur --exclude='*.orig' --exclude='*.rej' mythtv-orig/libs/libmythtv/channelutil.cpp mythtv/libs/libmythtv/channelutil.cpp
    old new  
    14131413                           dvb_transportid, dvb_networkid, dtv_si_std);
    14141414}
    14151415
    1416 DBChanList ChannelUtil::GetChannels(uint sourceid, bool vis_only, QString grp)
     1416DBChanList ChannelUtil::GetChannels(uint sourceid, bool vis_only, QString grp, int changrpid)
    14171417{
    14181418    DBChanList list;
    1419     QMap<uint,uint> favorites;
    14201419    MSqlQuery query(MSqlQuery::InitCon());
    1421     query.prepare(
    1422         "SELECT chanid, favid "
    1423         "FROM favorites");
    1424     if (!query.exec() || !query.isActive())
    1425         MythContext::DBError("get channels -- favorites", query);
    1426     else
    1427     {
    1428         while (query.next())
    1429             favorites[query.value(0).toUInt()] = query.value(1).toUInt();
    1430     }
    14311420
    14321421    QString qstr =
    1433         "SELECT channum, callsign, chanid, "
     1422        "SELECT channum, callsign, channel.chanid, "
    14341423        "       atsc_major_chan, atsc_minor_chan, "
    14351424        "       name, icon, mplexid, visible "
    14361425        "FROM channel ";
    14371426
     1427    // Select only channels from the specified channel group
     1428    if (changrpid > -1)
     1429       qstr += QString(",channelgroup ");
     1430
    14381431    if (sourceid)
    14391432        qstr += QString("WHERE sourceid='%1' ").arg(sourceid);
    14401433    else
     
    14421435            "WHERE cardinput.sourceid = channel.sourceid   AND "
    14431436            "      cardinput.cardid   = capturecard.cardid     ";
    14441437
     1438    if (changrpid > -1)
     1439    {
     1440        qstr += QString("AND channel.chanid = channelgroup.chanid "
     1441                        "AND channelgroup.grpid ='%1' ").arg(changrpid);
     1442    }
     1443
    14451444    if (vis_only)
    14461445        qstr += "AND visible=1 ";
    14471446
     
    14661465            query.value(2).toUInt(),                      /* chanid     */
    14671466            query.value(3).toUInt(),                      /* ATSC major */
    14681467            query.value(4).toUInt(),                      /* ATSC minor */
    1469             favorites[query.value(2).toUInt()],           /* favid      */
     1468            0,                                            /* Was favid, need to remove */
    14701469            query.value(7).toUInt(),                      /* mplexid    */
    14711470            query.value(8).toBool(),                      /* visible    */
    14721471            QString::fromUtf8(query.value(5).toString()), /* name       */
     
    16491648                (mplexid_restriction &&
    16501649                 (mplexid_restriction != it->mplexid))));
    16511650    }
    1652     else if (CHANNEL_DIRECTION_UP == direction)
     1651    else if ((CHANNEL_DIRECTION_UP == direction) || (CHANNEL_DIRECTION_FAVORITE == direction))
    16531652    {
    16541653        do
    16551654        {
     
    16621661                (mplexid_restriction &&
    16631662                 (mplexid_restriction != it->mplexid))));
    16641663    }
    1665     else if (CHANNEL_DIRECTION_FAVORITE == direction)
    1666     {
    1667         do
    1668         {
    1669             it++;
    1670             if (it == sorted.end())
    1671                 it = sorted.begin();
    1672         }
    1673         while ((it != start) &&
    1674                (!it->favorite ||
    1675                 (skip_non_visible && !it->visible) ||
    1676                 (mplexid_restriction &&
    1677                  (mplexid_restriction != it->mplexid))));
    1678     }
     1664//    else if (CHANNEL_DIRECTION_FAVORITE == direction)
     1665//   {
     1666//        do
     1667//        {
     1668//            it++;
     1669//            if (it == sorted.end())
     1670//                it = sorted.begin();
     1671//        }
     1672//        while ((it != start) &&
     1673//               (!it->favorite ||
     1674//                (skip_non_visible && !it->visible) ||
     1675//                (mplexid_restriction &&
     1676//                 (mplexid_restriction != it->mplexid))));
     1677//    }
    16791678
    16801679    return it->chanid;
    16811680}
  • libs/libmythtv/channelutil.h

    diff -Naur --exclude='*.orig' --exclude='*.rej' mythtv-orig/libs/libmythtv/channelutil.h mythtv/libs/libmythtv/channelutil.h
    old new  
    5959    mutable bool    iconLoaded;
    6060};
    6161
    62 
    6362/** \class ChannelUtil
    6463 *  \brief Collection of helper utilities for channel DB use
    6564 */
     
    182181    static QString GetVideoFilters(uint sourceid, const QString &channum)
    183182        { return GetChannelValueStr("videofilters", sourceid, channum); }
    184183
    185     static DBChanList GetChannels(uint srcid, bool vis_only, QString grp="");
     184    static DBChanList GetChannels(uint srcid, bool vis_only, QString grp="", int changrpid=-1);
    186185    static void    SortChannels(DBChanList &list, const QString &order,
    187186                                bool eliminate_duplicates = false);
    188187    static void    EliminateDuplicateChanNum(DBChanList &list);
  • libs/libmythtv/guidegrid.cpp

    diff -Naur --exclude='*.orig' --exclude='*.rej' mythtv-orig/libs/libmythtv/guidegrid.cpp mythtv/libs/libmythtv/guidegrid.cpp
    old new  
    2121
    2222#include "mythcontext.h"
    2323#include "mythdbcon.h"
    24 #include "guidegrid.h"
    2524#include "infostructs.h"
    2625#include "programinfo.h"
    2726#include "scheduledrecording.h"
     
    3433#include "util.h"
    3534#include "remoteutil.h"
    3635#include "channelutil.h"
     36#include "guidegrid.h"
    3737#include "cardutil.h"
    3838
    3939DBChanList GuideGrid::Run(
     
    4141    const QString &channum,
    4242    bool           thread,
    4343    TV            *player,
    44     bool           allowsecondaryepg)
     44    bool           allowsecondaryepg,
     45    int           *changrpid)
    4546{
    4647    DBChanList channel_changed;
     48    int        channel_group  = -1;
     49
     50    if (changrpid != NULL)
     51      channel_group = *changrpid;
    4752
    4853    if (thread)
    4954        qApp->lock();
     
    5257
    5358    GuideGrid *gg = new GuideGrid(gContext->GetMainWindow(),
    5459                                  chanid, channum,
    55                                   player, allowsecondaryepg, "guidegrid");
     60                                  player, allowsecondaryepg, "guidegrid",
     61                                  channel_group);
    5662
    5763    gg->Show();
    5864
     
    7884
    7985    if (thread)
    8086        qApp->lock();
    81 
     87   
     88    if (changrpid != NULL)
     89      *changrpid = gg->GetChanGrp();
     90   
    8291    delete gg;
    8392
    8493    gContext->removeCurrentLocation();
     
    92101GuideGrid::GuideGrid(MythMainWindow *parent,
    93102                     uint chanid, QString channum,
    94103                     TV *player, bool allowsecondaryepg,
    95                      const char *name)
     104                     const char *name, int changrpid)
    96105         : MythDialog(parent, name)
    97106{
    98107    desiredDisplayChans = DISPLAY_CHANS = 6;
    99108    DISPLAY_TIMES = 30;
    100109    int maxchannel = 0;
    101110    m_currentStartChannel = 0;
     111   
     112    m_changrpid = changrpid;
     113    m_changrplist = ChannelGroup::GetChannelGroups();
    102114
    103115    m_player = player;
    104116
     
    113125    infoRect = QRect(0, 0, 0, 0);
    114126    curInfoRect = QRect(0, 0, 0, 0);
    115127    videoRect = QRect(0, 0, 0, 0);
     128    changrpRect = QRect(0, 0, 0, 0);
    116129
    117130    jumpToChannelEnabled = gContext->GetNumSetting("EPGEnableJumpToChannel", 0);
    118131    jumpToChannelActive = false;
     
    133146    if (m_player && m_player->IsRunning() && !allowsecondaryepg)
    134147        videoRect = QRect(0, 0, 1, 1);
    135148
    136     showFavorites = gContext->GetNumSetting("EPGShowFavorites", 0);
    137149    gridfilltype = gContext->GetNumSetting("EPGFillType", UIGuideType::Alpha);
    138150    if (gridfilltype < (int)UIGuideType::Alpha)
    139151    { // update old settings to new fill types
     
    190202            container->SetDrawFontShadow(false);
    191203    }
    192204
     205    container = theme->GetSet("channel_group");
     206    if (container)
     207    {
     208        UITextType *type = (UITextType *)container->GetType("changroup");
     209        QString changroup;
     210       
     211        changroup = ChannelGroup::GetChannelGroupName(m_changrplist, m_changrpid);
     212       
     213        if (type)
     214            type->SetText(changroup);
     215    }
     216
    193217    channelOrdering = gContext->GetSetting("ChannelOrdering", "channum");
    194218    dateformat = gContext->GetSetting("ShortDateFormat", "ddd d");
    195219    unknownTitle = gContext->GetSetting("UnknownTitle", "Unknown");
     
    567591        curInfoRect = area;
    568592    if (name.lower() == "current_video")
    569593        videoRect = area;
     594    if (name.lower() == "channel_group")
     595        changrpRect = area;
    570596}
    571597
    572598PixmapChannel *GuideGrid::GetChannelInfo(uint chan_idx, int sel)
     
    764790    m_channelInfos.clear();
    765791    m_channelInfoIdx.clear();
    766792
    767     DBChanList channels = ChannelUtil::GetChannels(0, true);
     793    DBChanList channels = ChannelUtil::GetChannels(0, true, "", m_changrpid);
    768794    ChannelUtil::SortChannels(channels, channelOrdering, false);
    769795
    770     if (showFavorites)
    771     {
    772         DBChanList tmp;
    773         for (uint i = 0; i < channels.size(); i++)
    774         {
    775             if (channels[i].favorite)
    776                 tmp.push_back(channels[i]);
    777         }
    778 
    779         if (!tmp.empty())
    780             channels = tmp;
    781     }
    782 
    783796    typedef vector<uint> uint_list_t;
    784797    QMap<QString,uint_list_t> channum_to_index_map;
    785798    QMap<QString,uint_list_t> callsign_to_index_map;
     
    916929    }
    917930}
    918931
     932void GuideGrid::fillChanGroupInfo(void)
     933{
     934    LayerSet   *container = NULL;
     935    UITextType *type = NULL;
     936   
     937    container = theme->GetSet("channel_group");
     938    if (container)
     939    {
     940        type = (UITextType *)container->GetType("changroup");
     941        QString changroup;
     942       
     943        changroup = ChannelGroup::GetChannelGroupName(m_changrplist, m_changrpid);
     944       
     945        if (type)
     946            type->SetText(changroup);
     947    }
     948}
     949
    919950void GuideGrid::fillProgramRowInfos(unsigned int row)
    920951{
    921952    LayerSet *container = NULL;
     
    11981229        paintPrograms(&p);
    11991230    if (r.intersects(curInfoRect))
    12001231        paintCurrentInfo(&p);
     1232    if (r.intersects(changrpRect))
     1233        paintChanGroupInfo(&p);
    12011234
    12021235    // if jumpToChannel has its own rect, use that; otherwise use the date's rect
    12031236    if ((jumpToChannelHasRect && r.intersects(jumpToChannelRect)) ||
     
    13111344    p->drawPixmap(dr.topLeft(), pix);
    13121345}
    13131346
     1347void GuideGrid::paintChanGroupInfo(QPainter *p)
     1348{
     1349    QRect dr = changrpRect;
     1350    QPixmap pix(dr.size());
     1351    pix.fill(this, dr.topLeft());
     1352    QPainter tmp(&pix);
     1353
     1354    LayerSet *container = NULL;
     1355    container = theme->GetSet("channel_group");
     1356    if (container)
     1357    {
     1358        container->Draw(&tmp, 1, m_context);
     1359        container->Draw(&tmp, 2, m_context);
     1360        container->Draw(&tmp, 3, m_context);
     1361        container->Draw(&tmp, 4, m_context);
     1362        container->Draw(&tmp, 5, m_context);
     1363        container->Draw(&tmp, 6, m_context);
     1364        container->Draw(&tmp, 7, m_context);
     1365        container->Draw(&tmp, 8, m_context);
     1366    }
     1367    tmp.end();
     1368    p->drawPixmap(dr.topLeft(), pix);
     1369}
     1370
    13141371bool GuideGrid::paintChannels(QPainter *p)
    13151372{
    13161373    QRect cr = channelRect;
     
    13931450        }
    13941451
    13951452        QString tmpChannelFormat = channelFormat;
    1396         if (chinfo->favorite > 0)
    1397         {
    1398             tmpChannelFormat.insert(tmpChannelFormat.find('<'), "* ");
    1399             tmpChannelFormat.insert(tmpChannelFormat.find('>') + 1, " *");
    1400         }
     1453//        if (chinfo->favorite > 0)
     1454//        {
     1455//            tmpChannelFormat.insert(tmpChannelFormat.find('<'), "* ");
     1456//            tmpChannelFormat.insert(tmpChannelFormat.find('>') + 1, " *");
     1457//        }
    14011458
    14021459        if (unavailable)
    14031460            tmpChannelFormat.insert(tmpChannelFormat.find('<'), "X ");
     
    14301487        }
    14311488    }
    14321489
     1490    if (m_channelInfos.size() == 0)
     1491    {
     1492       // if the user has selected a channel group with no channels
     1493       // Reset the text and icon. This will display one blank line
     1494       // to show that the channel group has no channels
     1495       if (type)
     1496       {
     1497         type->SetText(0, "");
     1498         type->ResetImage(0);
     1499       }
     1500    }
     1501
    14331502    if (container)
    14341503    {
    14351504        container->Draw(&tmp, 1, m_context);
     
    15651634
    15661635void GuideGrid::toggleGuideListing()
    15671636{
    1568     showFavorites = (!showFavorites);
    1569     generateListings();
     1637    int oldchangrpid = m_changrpid;
     1638   
     1639    m_changrpid = ChannelGroup::GetNextChannelGroup(m_changrplist, oldchangrpid);
     1640   
     1641    if (oldchangrpid != m_changrpid)
     1642      generateListings();
     1643     
     1644    fillChanGroupInfo();
     1645    update(changrpRect);
    15701646}
    15711647
    15721648void GuideGrid::generateListings()
     
    15851661    update(fullRect);
    15861662}
    15871663
     1664int GuideGrid::SelectChannelGroup()
     1665{
     1666    if (m_changrplist.empty())
     1667    {
     1668      MythPopupBox::showOkPopup(gContext->GetMainWindow(), "",
     1669                                "You don't have any channel groups defined");
     1670
     1671      return -1;
     1672    }
     1673   
     1674    MythPopupBox *popup = new MythPopupBox(gContext->GetMainWindow(), "SelectChannelGroup Popup");
     1675    popup->addLabel("Select Channel Group");
     1676
     1677    for (uint i = 0; i < m_changrplist.size(); i++)
     1678      popup->addButton(m_changrplist[i].name);
     1679
     1680    popup->addButton(tr("Cancel"))->setFocus();
     1681
     1682    DialogCode result = popup->ExecPopup();
     1683   
     1684    popup->deleteLater();
     1685
     1686    // If the user cancelled, return a special value
     1687    if (result == MythDialog::Rejected)
     1688      return -1;
     1689    else
     1690      return m_changrplist[result - kDialogCodeListStart].grpid;
     1691}
     1692
    15881693void GuideGrid::toggleChannelFavorite()
    15891694{
    1590     MSqlQuery query(MSqlQuery::InitCon());
     1695    int grpid;
     1696
     1697    if (m_changrpid == -1)
     1698    {
     1699      grpid = SelectChannelGroup();
     1700     
     1701      if (grpid == -1)
     1702        return;
     1703    }
     1704    else
     1705      grpid = m_changrpid;
    15911706
    15921707    // Get current channel id, and make sure it exists...
    15931708    int chanNum = m_currentRow + m_currentStartChannel;
     
    15991714        chanNum = 0;
    16001715
    16011716    PixmapChannel *ch = GetChannelInfo(chanNum);
    1602     uint favid  = ch->favorite;
    16031717    uint chanid = ch->chanid;
    1604 
    1605     if (favid > 0)
    1606     {
    1607         query.prepare("DELETE FROM favorites WHERE favid = :FAVID ;");
    1608         query.bindValue(":FAVID", favid);
    1609         query.exec();
    1610     }
    1611     else
    1612     {
    1613         // We have no favorites record...Add one to toggle...
    1614         query.prepare("INSERT INTO favorites (chanid) VALUES (:FAVID);");
    1615         query.bindValue(":FAVID", chanid);
    1616         query.exec();
    1617     }
    1618 
    1619     if (showFavorites)
    1620         generateListings();
     1718   
     1719    if (m_changrpid == -1)
     1720       // If currently viewing all channels, allow to add only not delete
     1721       ChannelGroup::ToggleChannel(chanid, grpid, false);
    16211722    else
    1622     {
    1623         int maxchannel = 0;
    1624         DISPLAY_CHANS = desiredDisplayChans;
    1625         fillChannelInfos(false);
    1626         maxchannel = max((int)GetChannelCount() - 1, 0);
    1627         DISPLAY_CHANS = min(DISPLAY_CHANS, maxchannel + 1);
    1628 
    1629         repaint(channelRect, false);
    1630     }
     1723       // Only allow delete if viewing the favorite group in question
     1724       ChannelGroup::ToggleChannel(chanid, grpid, true);
     1725     
     1726    // If viewing favorites, refresh because a channel was removed
     1727    if (m_changrpid != -1)
     1728       generateListings();
    16311729}
    16321730
    16331731void GuideGrid::cursorLeft()
  • libs/libmythtv/guidegrid.h

    diff -Naur --exclude='*.orig' --exclude='*.rej' mythtv-orig/libs/libmythtv/guidegrid.h mythtv/libs/libmythtv/guidegrid.h
    old new  
    1313#include "uitypes.h"
    1414#include "xmlparse.h"
    1515#include "libmythtv/programinfo.h"
     16#include "libmythtv/channelgroup.h"
    1617#include "channelutil.h"
    1718
    1819using namespace std;
     
    3940                          const QString &startChanNum,
    4041                          bool           thread = false,
    4142                          TV            *player = NULL,
    42                           bool           allowsecondaryepg = true);
     43                          bool           allowsecondaryepg = true,
     44                          int           *changrpid = NULL);
    4345
    4446    DBChanList GetSelection(void) const;
    4547
     
    8688    GuideGrid(MythMainWindow *parent,
    8789              uint chanid = 0, QString channum = "",
    8890              TV *player = NULL, bool allowsecondaryepg = true,
    89               const char *name = "GuideGrid");
     91              const char *name = "GuideGrid",
     92              int changrpid=-1);
    9093   ~GuideGrid();
    9194
     95    int  GetChanGrp(void) {return m_changrpid;}
    9296    void paintEvent(QPaintEvent *);
    9397
    9498  private slots:
     
    108112    void paintPrograms(QPainter *);
    109113    void paintCurrentInfo(QPainter *);
    110114    void paintInfo(QPainter *);
     115    void paintChanGroupInfo(QPainter *p);
    111116 
    112117    void resizeImage(QPixmap *, QString);
    113118    void LoadWindow(QDomElement &);
     
    132137    QRect infoRect;
    133138    QRect curInfoRect;
    134139    QRect videoRect;
     140    QRect changrpRect;
    135141
    136142    void fillChannelInfos(bool gotostartchannel = true);
    137143
     
    139145
    140146    void fillProgramInfos(void);
    141147    void fillProgramRowInfos(unsigned int row);
     148   
     149    void fillChanGroupInfo(void);
    142150
    143151    void setStartChannel(int newStartChannel);
    144152
    145153    void createProgramLabel(int, int);
     154   
     155    int SelectChannelGroup();
    146156
    147157    PixmapChannel       *GetChannelInfo(uint chan_idx, int sel = -1);
    148158    const PixmapChannel *GetChannelInfo(uint chan_idx, int sel = -1) const;
     
    172182    int m_currentCol;
    173183
    174184    bool selectState;
    175     bool showFavorites;
    176185    bool sortReverse;
    177186    QString channelFormat;
    178187
     
    195204    QTimer *videoRepaintTimer;
    196205
    197206    bool keyDown;
     207   
     208    int  m_changrpid;
     209    ChannelGroupList m_changrplist;
    198210
    199211    void jumpToChannelResetAndHide();
    200212    void jumpToChannelCancel();
  • libs/libmythtv/libmythtv.pro

    diff -Naur --exclude='*.orig' --exclude='*.rej' mythtv-orig/libs/libmythtv/libmythtv.pro mythtv/libs/libmythtv/libmythtv.pro
    old new  
    142142HEADERS += channeleditor.h          channelsettings.h
    143143HEADERS += previewgenerator.h       transporteditor.h
    144144HEADERS += importicons.h
     145HEADERS += channelgroup.h
    145146
    146147SOURCES += programinfo.cpp          proglist.cpp
    147148SOURCES += storagegroup.cpp
     
    165166SOURCES += channeleditor.cpp        channelsettings.cpp
    166167SOURCES += previewgenerator.cpp     transporteditor.cpp
    167168SOURCES += importicons.cpp
     169SOURCES += channelgroup.cpp
    168170
    169171# DiSEqC
    170172HEADERS += diseqc.h                 diseqcsettings.h
  • libs/libmythtv/tv_play.cpp

    diff -Naur --exclude='*.orig' --exclude='*.rej' mythtv-orig/libs/libmythtv/tv_play.cpp mythtv/libs/libmythtv/tv_play.cpp
    old new  
    8989    bool showDialogs = true;
    9090    bool playCompleted = false;
    9191    ProgramInfo *curProgram = NULL;
    92    
    9392
    9493    if (tvrec)
    9594        curProgram = new ProgramInfo(*tvrec);
     
    229228   
    230229    bool allowrerecord = tv->getAllowRerecord();
    231230    bool deleterecording = tv->getRequestDelete();
    232    
     231
     232    tv->SaveChannelGroup();
     233
    233234    delete tv;
    234235   
    235236    if (curProgram)
     
    283284            "in the program guide", "0");
    284285    REG_KEY("TV Frontend", "GUIDE", "Show the Program Guide", "S");
    285286    REG_KEY("TV Frontend", "FINDER", "Show the Program Finder", "#");
    286     REG_KEY("TV Frontend", "NEXTFAV", "Toggle showing all channels or just "
    287             "favorites in the program guide.", "/");
     287    REG_KEY("TV Frontend", "NEXTFAV", "Cycle through channel groups and all channels "
     288            "in the program guide.", "/,S");
    288289    REG_KEY("TV Frontend", "CHANUPDATE", "Switch channels without exiting "
    289290            "guide in Live TV mode.", "X");
    290291    REG_KEY("TV Frontend", "VOLUMEDOWN", "Volume down", "[,{,F10,Volume Down");
     
    629630    stickykeys           = gContext->GetNumSetting("StickyKeys");
    630631    ff_rew_repos         = gContext->GetNumSetting("FFRewReposTime", 100)/100.0;
    631632    ff_rew_reverse       = gContext->GetNumSetting("FFRewReverse", 1);
     633    channel_group_id     = gContext->GetNumSetting("ChannelGroupDefault", -1);
     634    browse_changrp       = gContext->GetNumSetting("BrowseChannelGroup", 0);
     635   
     636    if (browse_changrp && (channel_group_id > -1))
     637    {
     638      m_channellist = ChannelUtil::GetChannels(0, true, "channum, callsign", channel_group_id);
     639      ChannelUtil::SortChannels(m_channellist, "channum", true);
     640    }
     641   
     642    m_changrplist  = ChannelGroup::GetChannelGroups();
     643
    632644    int def[8] = { 3, 5, 10, 20, 30, 60, 120, 180 };
    633645    for (uint i = 0; i < sizeof(def)/sizeof(def[0]); i++)
    634646        ff_rew_speeds.push_back(
     
    792804    }
    793805}
    794806
     807void TV::SaveChannelGroup(void)
     808{
     809    int changrpid             = gContext->GetNumSetting("ChannelGroupDefault", -1);
     810    int remember_last_changrp = gContext->GetNumSetting("ChannelGroupRememberLast", 0);
     811
     812    if (remember_last_changrp && (changrpid != channel_group_id))
     813       gContext->SaveSetting("ChannelGroupDefault", channel_group_id);
     814}
     815
    795816TVState TV::GetState(void) const
    796817{
    797818    if (InStateChange())
     
    45994620
    46004621void TV::ToggleChannelFavorite(void)
    46014622{
    4602     activerecorder->ToggleChannelFavorite();
     4623//    activerecorder->ToggleChannelFavorite();
    46034624}
    46044625
    46054626void TV::ChangeChannel(int direction)
    46064627{
    46074628    bool muted = false;
    46084629
     4630    if ((browse_changrp || (direction == CHANNEL_DIRECTION_FAVORITE)) &&
     4631        (channel_group_id > -1) && (direction != CHANNEL_DIRECTION_SAME))
     4632    {
     4633      uint    chanid;
     4634     
     4635      // Collect channel info
     4636      pbinfoLock.lock();
     4637      uint    old_chanid  = playbackinfo->chanid.toUInt();
     4638      pbinfoLock.unlock();
     4639
     4640      chanid = ChannelUtil::GetNextChannel(m_channellist, old_chanid, 0, direction);
     4641
     4642      ChangeChannel(chanid, "");     
     4643      return;
     4644    } else if (direction == CHANNEL_DIRECTION_FAVORITE)
     4645       direction = CHANNEL_DIRECTION_UP;
     4646
    46094647    if (nvp)
    46104648    {
    46114649        AudioOutput *aud = nvp->getAudioOutput();
     
    56705708
    56715709    DBChanList changeChannel;
    56725710    ProgramInfo *nextProgram = NULL;
     5711    int changrpid = channel_group_id;
    56735712
    56745713    if (StateIsLiveTV(GetState()))
    56755714    {
     
    56855724
    56865725                // Start up EPG
    56875726                changeChannel = GuideGrid::Run(
    5688                     chanid, channum, true, this, allowsecondary);
     5727                    chanid, channum, true, this, allowsecondary, &changrpid);
    56895728
    56905729                break;
    56915730            }
     
    57285767        {
    57295768            default:
    57305769            case kScheduleProgramGuide:
    5731                 GuideGrid::Run(chanid, channum, true);
     5770                GuideGrid::Run(chanid, channum, true, NULL, true, &changrpid);
    57325771                break;
    57335772            case kScheduleProgramFinder:
    57345773                RunProgramFind(true, false);
     
    57785817            DoPause();
    57795818    }
    57805819
     5820    // if channel group was changed in EPG update local info
     5821    if ((changrpid != channel_group_id) && (editType == kScheduleProgramGuide))
     5822    {
     5823      channel_group_id = changrpid;
     5824     
     5825      if (browse_changrp)
     5826      {
     5827          VERBOSE(VB_IMPORTANT, LOC +
     5828             QString("Reloading channel group list for %1").arg(channel_group_id));
     5829     
     5830          m_channellist = ChannelUtil::GetChannels(0, true, "channum, callsign", channel_group_id);
     5831          ChannelUtil::SortChannels(m_channellist, "channum", true);
     5832      }
     5833    }
     5834
    57815835    // Resize the window back to the MythTV Player size
    57825836    if (!using_gui_size_for_tv)
    57835837    {
     
    64076461{
    64086462    if (!browsemode)
    64096463        BrowseStart();
     6464VERBOSE(VB_IMPORTANT,"In BrowseDispInfo");
     6465    // if browsing channel groups is enabled or direction if BROWSE_FAVORITES
     6466    // Then pick the next channel in the channel group list to browse
     6467    // If channel group is ALL CHANNELS (-1), then bypass picking from
     6468    // the channel group list
     6469    if ((browse_changrp || (direction == BROWSE_FAVORITE)) &&
     6470        (channel_group_id > -1) && (direction != BROWSE_SAME) &&
     6471        (direction != BROWSE_RIGHT) && (direction != BROWSE_LEFT))
     6472    {
     6473      uint chanid;
     6474      int  dir;
     6475     
     6476      if ( (direction == BROWSE_UP) || (direction == BROWSE_FAVORITE) )
     6477        dir = CHANNEL_DIRECTION_UP;
     6478      else if (direction == BROWSE_DOWN)
     6479        dir = CHANNEL_DIRECTION_DOWN;
     6480      else // this should never happen, but just in case
     6481        dir = direction;
     6482       
     6483      chanid = ChannelUtil::GetNextChannel(m_channellist, browsechanid.toUInt(), 0, dir);
     6484      VERBOSE(VB_IMPORTANT, QString("Get channel: %1").arg(chanid));
     6485      browsechanid  = QString("%1").arg(chanid);
     6486      browsechannum = QString::null;
     6487      direction     = BROWSE_SAME;
     6488    }
     6489    else if ((channel_group_id == -1) && (direction == BROWSE_FAVORITE))
     6490      direction = BROWSE_UP;
    64106491
    64116492    InfoMap infoMap;
    64126493    QDateTime curtime  = QDateTime::currentDateTime();
     
    71747255    }
    71757256    else if (action == "GUIDE")
    71767257        EditSchedule(kScheduleProgramGuide);
     7258    else if (action.left(10) == "CHANGROUP_")
     7259        processChanGroupEntry(action);
    71777260    else if (action == "FINDER")
    71787261        EditSchedule(kScheduleProgramFinder);
    71797262    else if (action == "SCHEDULE")
     
    72707353    }
    72717354}
    72727355
     7356void TV::processChanGroupEntry(QString action)
     7357{
     7358    if (action == "CHANGROUP_ALL_CHANNELS")
     7359      channel_group_id = -1;
     7360    else
     7361    {
     7362      action.remove("CHANGROUP_");
     7363      channel_group_id = action.toInt();
     7364         
     7365      if (browse_changrp)
     7366      {
     7367         m_channellist = ChannelUtil::GetChannels(0, true, "channum, callsign", channel_group_id);
     7368         ChannelUtil::SortChannels(m_channellist, "channum", true);
     7369      }
     7370    }
     7371}
     7372
    72737373void TV::ShowOSDTreeMenu(void)
    72747374{
    72757375    BuildOSDTreeMenu();
     
    74517551        freeRecorders = RemoteGetFreeRecorderCount();
    74527552
    74537553    item = new OSDGenericTree(treeMenu, tr("Program Guide"), "GUIDE");
     7554    item = new OSDGenericTree(treeMenu, tr("Channel Groups"), "CHANGROUP");
     7555    subitem = new OSDGenericTree(item, tr("All Channels"),
     7556                                 "CHANGROUP_ALL_CHANNELS",
     7557                                 (channel_group_id == -1) ? 1 : 0,
     7558                                 NULL, "CHANNELGROUP");
     7559       
     7560    ChannelGroupList::iterator it;
     7561       
     7562    for (it = m_changrplist.begin(); it != m_changrplist.end(); ++it)
     7563    {
     7564        QString name = QString("CHANGROUP_%1").arg(it->grpid);
     7565        subitem = new OSDGenericTree(item, it->name, name,
     7566                                     ((int)(it->grpid) == channel_group_id) ? 1 : 0,
     7567                                     NULL, "CHANNELGROUP");
     7568    }   
    74547569
    74557570    if (!gContext->GetNumSetting("JumpToProgramOSD", 1))
    74567571    {
  • libs/libmythtv/tv_play.h

    diff -Naur --exclude='*.orig' --exclude='*.rej' mythtv-orig/libs/libmythtv/tv_play.h mythtv/libs/libmythtv/tv_play.h
    old new  
    1919#include "programinfo.h"
    2020#include "channelutil.h"
    2121#include "videoouttypes.h"
     22#include "channelutil.h"
     23#include "channelgroup.h"
    2224
    2325#include <qobject.h>
    2426
     
    220222    // Used by EPG
    221223    void ChangeVolume(bool up);
    222224    void ToggleMute(void);
     225   
     226    // Channel Groups
     227    void SaveChannelGroup(void);
    223228
    224229  public slots:
    225230    void HandleOSDClosed(int osdType);
     
    392397    void ShowOSDTreeMenu(void);
    393398    void FillMenuLiveTV(OSDGenericTree *treeMenu);
    394399    void FillMenuPlaying(OSDGenericTree *treeMenu);
     400    void processChanGroupEntry(QString action);
    395401
    396402    void UpdateLCD(void);
    397403    void ShowLCDChannelInfo(void);
     
    672678    // Network Control stuff
    673679    QValueList<QString> networkControlCommands;
    674680    QMutex ncLock;
     681   
     682    int channel_group_id;
     683    uint browse_changrp;
     684    ChannelGroupList m_changrplist;
     685    DBChanList m_channellist;
    675686};
    676687
    677688#endif
  • programs/mythfrontend/globalsettings.cpp

    diff -Naur --exclude='*.orig' --exclude='*.rej' mythtv-orig/programs/mythfrontend/globalsettings.cpp mythtv/programs/mythfrontend/globalsettings.cpp
    old new  
    28792879    return gc;
    28802880}
    28812881
    2882 static HostCheckBox *EPGShowFavorites()
    2883 {
    2884     HostCheckBox *gc = new HostCheckBox("EPGShowFavorites");
    2885     gc->setLabel(QObject::tr("Only display 'favorite' channels"));
    2886     gc->setHelpText(QObject::tr("If enabled, the EPG will initially display "
    2887                     "only the channels marked as favorites. Pressing "
    2888                     "\"4\" will toggle between displaying favorites and all "
    2889                     "channels."));
    2890     gc->setValue(false);
    2891     return gc;
    2892 }
    28932882
    28942883static HostSpinBox *EPGChanDisplay()
    28952884{
     
    29172906    return gc;
    29182907}
    29192908
     2909static HostCheckBox *ChannelGroupRememberLast()
     2910{
     2911    HostCheckBox *gc = new HostCheckBox("ChannelGroupRememberLast");
     2912    gc->setLabel(QObject::tr("Remember last channel group"));
     2913    gc->setHelpText(QObject::tr("If enabled, the EPG will initially display "
     2914                    "only the channels from the last channel group selected. Pressing "
     2915                    "\"4\" will toggle channel group."));
     2916    gc->setValue(false);
     2917    return gc;
     2918}
     2919
     2920static HostComboBox *ChannelGroupDefault()
     2921{
     2922    HostComboBox *gc = new HostComboBox("ChannelGroupDefault");
     2923    gc->setLabel(QObject::tr("Default channel group"));
     2924
     2925    ChannelGroupList changrplist;
     2926
     2927    changrplist = ChannelGroup::GetChannelGroups();
     2928
     2929    gc->addSelection(QObject::tr("All Channels"), "-1");
     2930
     2931    ChannelGroupList::iterator it;
     2932
     2933    for (it = changrplist.begin(); it < changrplist.end(); ++it)
     2934       gc->addSelection(it->name, QString("%1").arg(it->grpid));
     2935
     2936    gc->setHelpText(QObject::tr("Default channel group to be shown in the the EPG"
     2937                    "Pressing "
     2938                    "\"4\" will toggle channel group."));
     2939    gc->setValue(false);
     2940    return gc;
     2941}
     2942
     2943static HostCheckBox *BrowseChannelGroup()
     2944{
     2945    HostCheckBox *gc = new HostCheckBox("BrowseChannelGroup");
     2946    gc->setLabel(QObject::tr("Browse/Change channels from Channel Group"));
     2947    gc->setHelpText(QObject::tr("If enabled, LiveTV will browse or change channels "
     2948                    "from the selected channel group. \"All Channels\" "
     2949                    "channel group may be selected to browse all channels."));
     2950    gc->setValue(false);
     2951    return gc;
     2952}
     2953
     2954// Channel Group Settings
     2955class ChannelGroupSettings : public TriggeredConfigurationGroup
     2956{
     2957  public:
     2958    ChannelGroupSettings() : TriggeredConfigurationGroup(false, true, false, false)
     2959    {
     2960         setLabel(QObject::tr("Remember last channel group"));
     2961         setUseLabel(false);
     2962
     2963         Setting* RememberChanGrpEnabled = ChannelGroupRememberLast();
     2964         addChild(RememberChanGrpEnabled);
     2965         setTrigger(RememberChanGrpEnabled);
     2966
     2967         ConfigurationGroup* settings = new VerticalConfigurationGroup(false);
     2968         settings->addChild(ChannelGroupDefault());
     2969         addTarget("0", settings);
     2970
     2971         // show nothing if RememberChanGrpEnabled is on
     2972         addTarget("1", new VerticalConfigurationGroup(true));
     2973     };
     2974};
     2975
    29202976// General RecPriorities settings
    29212977
    29222978static GlobalCheckBox *GRSchedMoveHigher()
     
    46334689    general2->addChild(CategoryOverTimeSettings());
    46344690    addChild(general2);
    46354691
     4692    VerticalConfigurationGroup* changrp = new VerticalConfigurationGroup(false);
     4693    changrp->setLabel(QObject::tr("General (Channel Groups)"));
     4694    ChannelGroupSettings *changroupsettings = new ChannelGroupSettings();
     4695    changrp->addChild(changroupsettings);
     4696    changrp->addChild(BrowseChannelGroup());
     4697    addChild(changrp);
    46364698}
    46374699
    46384700EPGSettings::EPGSettings()
    46394701{
    46404702    VerticalConfigurationGroup* epg = new VerticalConfigurationGroup(false);
    4641     epg->setLabel(QObject::tr("Program Guide") + " 1/2");
     4703    epg->setLabel(QObject::tr("Program Guide") + " 1/3");
    46424704    epg->addChild(EPGFillType());
    46434705    epg->addChild(EPGShowCategoryColors());
    46444706    epg->addChild(EPGShowCategoryText());
    46454707    epg->addChild(EPGScrollType());
    46464708    epg->addChild(EPGShowChannelIcon());
    4647     epg->addChild(EPGShowFavorites());
    46484709    epg->addChild(WatchTVGuide());
    46494710    epg->addChild(EPGChanDisplay());
    46504711    epg->addChild(EPGTimeDisplay());
    46514712    addChild(epg);
    46524713
    46534714    VerticalConfigurationGroup* gen = new VerticalConfigurationGroup(false);
    4654     gen->setLabel(QObject::tr("Program Guide") + " 2/2");
     4715    gen->setLabel(QObject::tr("Program Guide") + " 2/3");
    46554716    gen->addChild(UnknownTitle());
    46564717    gen->addChild(UnknownCategory());
    46574718    gen->addChild(DefaultTVChannel());
    46584719    gen->addChild(SelectChangesChannel());
    46594720    gen->addChild(EPGRecThreshold());
    46604721    gen->addChild(EPGEnableJumpToChannel());
    4661     addChild(gen);
     4722    addChild(gen);   
    46624723}
    46634724
    46644725GeneralRecPrioritiesSettings::GeneralRecPrioritiesSettings()
  • programs/mythfrontend/main.cpp

    diff -Naur --exclude='*.orig' --exclude='*.rej' mythtv-orig/programs/mythfrontend/main.cpp mythtv/programs/mythfrontend/main.cpp
    old new  
    5050#include "statusbox.h"
    5151#include "lcddevice.h"
    5252#include "langsettings.h"
     53#include "channelgroup.h"
    5354
    5455#include "libmythui/myththemedmenu.h"
    5556#include "libmythui/myththemebase.h"
     
    405406    {
    406407        EPGSettings settings;
    407408        settings.exec();
     409    }
     410    else if (sel == "settings channelgroups")
     411    {
     412        ChannelGroupEditor editor;
     413        editor.exec();
    408414    }
    409415    else if (sel == "settings generalrecpriorities")
    410416    {
  • programs/mythfrontend/tv_settings.xml

    diff -Naur --exclude='*.orig' --exclude='*.rej' mythtv-orig/programs/mythfrontend/tv_settings.xml mythtv/programs/mythfrontend/tv_settings.xml
    old new  
    8080      <text>Playback OSD</text>
    8181      <action>SETTINGS OSD</action>
    8282   </button>
     83   
     84   <button>
     85      <type>TV_SETTINGS_CHANNEL_GROUP</type>
     86      <text>Channel Groups</text>
     87      <action>SETTINGS CHANNELGROUPS</action>
     88   </button>
    8389
    8490   <button>
    8591      <type>TV_SETTINGS_PLAYBACK_GROUPS</type>
  • themes/classic/tv_settings.xml

    diff -Naur --exclude='*.orig' --exclude='*.rej' mythtv-orig/themes/classic/tv_settings.xml mythtv/themes/classic/tv_settings.xml
    old new  
    6767   </button>
    6868
    6969   <button>
     70      <type>TV_SETTINGS_CHANNEL_GROUP</type>
     71      <text>Channel Groups</text>
     72      <action>SETTINGS CHANNELGROUPS</action>
     73   </button>
     74
     75   <button>
    7076      <type>TV_SETTINGS_PLAYBACK_GROUPS</type>
    7177      <text>Playback Groups</text>
    7278      <text lang="SV">Uppspelningsgrupper</text>
  • themes/DVR/tv_settings.xml

    diff -Naur --exclude='*.orig' --exclude='*.rej' mythtv-orig/themes/DVR/tv_settings.xml mythtv/themes/DVR/tv_settings.xml
    old new  
    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>