Ticket #199: 00-199-channelgroups.7.patch

File 00-199-channelgroups.7.patch, 56.9 KB (added by Matthew Wire <devel@…>, 15 years ago)

Update for 20043 and remove obsolete favorites code

  • 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/themes/defaultmenu/tv_settings.xml

     
    9797      <action>OSDMENUEDITOR</action>
    9898  </button>
    9999   <button>
     100      <type>TV_SETTINGS_CHANNEL_GROUP</type>
     101      <text>Channel Groups</text>
     102      <action>SETTINGS CHANNELGROUPS</action>
     103   </button>
     104
     105   <button>
    100106      <type>TV_SETTINGS_PLAYBACK_GROUPS</type>
    101107      <text>Playback Groups</text>
    102108      <text lang="IT">Gruppi di Riproduzione</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/channelgroup.h

     
     1#ifndef CHANNELGROUP_H
     2#define CHANNELGROUP_H
     3
     4class ChannelGroupItem
     5{
     6  public:
     7    ChannelGroupItem(const ChannelGroupItem&);
     8    ChannelGroupItem(const uint _grpid,
     9                  const QString &_name) :
     10        grpid(_grpid), name(_name) {}
     11
     12    bool operator == (uint _grpid) const
     13        { return grpid == _grpid; }
     14
     15    ChannelGroupItem& operator=(const ChannelGroupItem&);
     16
     17  public:
     18    uint    grpid;
     19    QString name;
     20};
     21typedef vector<ChannelGroupItem> ChannelGroupList;
     22
     23/** \class ChannelGroup
     24*/
     25class MPUBLIC ChannelGroup
     26{
     27  public:
     28    // ChannelGroup
     29    static ChannelGroupList  GetChannelGroups(void);
     30    static bool              ToggleChannel(uint chanid,int changrpid, int delete_chan);
     31    static int               GetNextChannelGroup(const ChannelGroupList &sorted, int grpid);
     32    static QString           GetChannelGroupName(const ChannelGroupList &sorted, int grpid);
     33
     34   
     35  private:
     36
     37};
     38
     39#endif
  • 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

     
    161161HEADERS += viewschdiff.h            livetvchain.h
    162162HEADERS += playgroup.h              progdetails.h
    163163HEADERS += channelsettings.h        previewgenerator.h
    164 HEADERS += transporteditor.h
     164HEADERS += transporteditor.h       
    165165HEADERS += myth_imgconvert.h
     166HEADERS += channelgroup.h           channelgroupsettings.h
    166167
    167168# Remove when everything is switched to MythUI
    168169HEADERS += proglist_qt.h
     
    186187SOURCES += progdetails.cpp
    187188SOURCES += channelsettings.cpp      previewgenerator.cpp
    188189SOURCES += transporteditor.cpp
     190SOURCES += channelgroup.cpp         channelgroupsettings.cpp
    189191
    190192contains( CONFIG_SWSCALE, yes ) {
    191193    SOURCES += myth_imgconvert.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
     
    266267    void ToggleMute(PlayerContext*);
    267268
    268269    void SetNextProgPIPState(PIPState state) { jumpToProgramPIPState = state; }
     270   
     271    // Channel Groups
     272    void SaveChannelGroup(void);
    269273
    270274    // Used for UDPNotify
    271275    bool HasUDPNotifyEvent(void) const;
     
    519523    void FillMenuTimeStretch(   const PlayerContext*, OSDGenericTree*) const;
    520524    void FillMenuSleepMode(     const PlayerContext*, OSDGenericTree*) const;
    521525    bool FillMenuTracks(        const PlayerContext*, OSDGenericTree*, uint type) const;
     526    void FillMenuChanGroups(    const PlayerContext*, OSDGenericTree*) const;
    522527
     528    void processChanGroupEntry(QString action);
     529
    523530    void UpdateLCD(void);
    524531    bool HandleLCDTimerEvent(void);
    525532    void ShowLCDChannelInfo(const PlayerContext*);
     
    747754    QMap<int,int>             recorderPlaybackInfoTimerId;
    748755    QMap<int,ProgramInfo>     recorderPlaybackInfo;
    749756
     757    // Channel favorite group stuff   
     758    int channel_group_id;
     759    uint browse_changrp;
     760    ChannelGroupList m_changrplist;
     761    DBChanList m_channellist;
     762
    750763    // Network Control stuff
    751764    MythDeque<QString> networkControlCommands;
    752765
  • 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/channelgroupsettings.h

     
     1#ifndef CHANNELGROUPSETTINGS_H
     2#define CHANNELGROUPSETTINGS_H
     3
     4#include "libmyth/settings.h"
     5
     6class MPUBLIC ChannelGroupConfig: public ConfigurationWizard
     7{
     8 public:
     9    ChannelGroupConfig(QString _name);
     10    QString getName(void) const { return name; }
     11
     12 private:
     13    QString name;
     14};
     15
     16class MPUBLIC ChannelGroupEditor : public QObject, public ConfigurationDialog
     17{
     18    Q_OBJECT
     19
     20  public:
     21    ChannelGroupEditor(void);
     22    virtual DialogCode exec(void);
     23    virtual void Load(void);
     24    virtual void Save(void) { };
     25    virtual void Save(QString) { };
     26    virtual MythDialog* dialogWidget(MythMainWindow* parent,
     27                                     const char* widgetName=0);
     28
     29  protected slots:
     30    void open(QString name);
     31    void doDelete(void);
     32
     33  protected:
     34    ListBoxSetting *listbox;
     35    QString         lastValue;
     36};
     37
     38#endif
  • mythtv/libs/libmythtv/channelgroup.cpp

     
     1#include "mythcontext.h"
     2#include "libmythdb/mythdbcon.h"
     3#include <qsqldatabase.h>
     4#include <qcursor.h>
     5#include <qlayout.h>
     6#include <iostream>
     7#include <algorithm>
     8#include "mythstorage.h"
     9#include "mythdb.h"
     10#include "channelutil.h"
     11#include "channelgroup.h"
     12
     13#define LOC QString("Channel Group: ")
     14#define LOC_ERR QString("Channel Group, Error: ")
     15
     16ChannelGroupItem& ChannelGroupItem::operator=(const ChannelGroupItem &other)
     17{
     18    grpid     = other.grpid;
     19    name      = (other.name);
     20 
     21    return *this;
     22}
     23
     24ChannelGroupItem::ChannelGroupItem(const ChannelGroupItem &other)
     25{
     26    (*this) = other;
     27}
     28
     29inline bool lt_group(const ChannelGroupItem &a, const ChannelGroupItem &b)
     30{
     31    return QString::localeAwareCompare(a.name, b.name) < 0;
     32}
     33
     34bool ChannelGroup::ToggleChannel(uint chanid,int changrpid, int delete_chan)
     35{
     36    // Check if it already exists for that chanid...
     37    MSqlQuery query(MSqlQuery::InitCon());
     38    query.prepare(
     39        "SELECT channelgroup.id "
     40        "FROM channelgroup "
     41        "WHERE channelgroup.chanid = :CHANID AND "
     42        "channelgroup.grpid = :GRPID "
     43        "LIMIT 1");
     44    query.bindValue(":CHANID", chanid);
     45    query.bindValue(":GRPID", changrpid);
     46
     47    if (!query.exec() || !query.isActive())
     48    {
     49        MythDB::DBError("ChannelGroup::ToggleChannel", query);
     50        return false;
     51    }
     52    else if ((query.size() > 0) && delete_chan)
     53    {
     54        // We have a record...Remove it to toggle...
     55        query.next();
     56        QString id = query.value(0).toString();
     57        query.prepare(
     58            QString("DELETE FROM channelgroup "
     59                    "WHERE id = '%1'").arg(id));
     60        query.exec();
     61        VERBOSE(VB_IMPORTANT, LOC + QString("Removing channel with id=%1.").arg(id));
     62    }
     63    else if (query.size() == 0)
     64    {
     65        // We have no record...Add one to toggle...
     66        query.prepare(
     67            QString("INSERT INTO channelgroup (chanid,grpid) "
     68                    "VALUES ('%1','%2')").arg(chanid).arg(changrpid));
     69        query.exec();
     70        VERBOSE(VB_IMPORTANT, LOC + QString("Adding channel %1 to group %2.").arg(chanid).arg(changrpid));
     71    }
     72
     73    return true;
     74}
     75
     76ChannelGroupList ChannelGroup::GetChannelGroups(void)
     77{
     78    ChannelGroupList list;
     79   
     80    MSqlQuery query(MSqlQuery::InitCon());
     81   
     82    QString qstr = "SELECT grpid, name FROM channelgroupnames";
     83   
     84    query.prepare(qstr);
     85
     86    if (!query.exec() || !query.isActive())
     87        MythDB::DBError("ChannelGroup::GetChannelGroups", query);
     88    else
     89    {
     90        while (query.next())
     91        {
     92           ChannelGroupItem group(query.value(0).toUInt(),
     93                              query.value(1).toString());
     94           list.push_back(group);
     95        }
     96    }
     97   
     98    stable_sort(list.begin(), list.end(), lt_group);
     99
     100    return list;
     101}
     102
     103// Cycle through the available groups, then all channels
     104// Will cycle through to end then return -1
     105// To signify all channels.
     106int ChannelGroup::GetNextChannelGroup(const ChannelGroupList &sorted, int grpid)
     107{
     108    // If no groups return -1 for all channels
     109    if (sorted.empty())
     110      return -1;
     111   
     112    // If grpid is all channels (-1), then return the first grpid 
     113    if (grpid == -1)
     114      return sorted[0].grpid;
     115     
     116    ChannelGroupList::const_iterator it = find(sorted.begin(), sorted.end(), grpid);
     117
     118    // If grpid is not in the list, return -1 for all channels
     119    if (it == sorted.end())
     120        return -1;
     121
     122    ++it;
     123
     124    // If we reached the end, the next option is all channels (-1)
     125    if (it == sorted.end())
     126       return -1;
     127
     128    return it->grpid;
     129}
     130
     131QString ChannelGroup::GetChannelGroupName(const ChannelGroupList &sorted, int grpid)
     132{
     133    // All Channels
     134    if (grpid == -1)
     135      return "All Channels";
     136
     137    ChannelGroupList::const_iterator it = find(sorted.begin(), sorted.end(), grpid);
     138       
     139    // If grpid wasn't found, return blank.   
     140    if (it == sorted.end())
     141       return "";
     142    else
     143       return it->name;
     144}
  • 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

     
    347347
    348348    bool allowrerecord = tv->getAllowRerecord();
    349349    bool deleterecording = tv->getRequestDelete();
     350   
     351    tv->SaveChannelGroup();
    350352
    351353    delete tv;
    352354
     
    422424            "in the program guide", "0");
    423425    REG_KEY("TV Frontend", "GUIDE", "Show the Program Guide", "S");
    424426    REG_KEY("TV Frontend", "FINDER", "Show the Program Finder", "#");
    425     REG_KEY("TV Frontend", "NEXTFAV", "Toggle showing all channels or just "
    426             "favorites in the program guide.", "/");
     427    REG_KEY("TV Frontend", "NEXTFAV", "Cycle through channel groups and all channels "
     428            "in the program guide.", "/,S");
    427429    REG_KEY("TV Frontend", "CHANUPDATE", "Switch channels without exiting "
    428430            "guide in Live TV mode.", "X");
    429431    REG_KEY("TV Frontend", "VOLUMEDOWN", "Volume down", "[,{,F10,Volume Down");
     
    787789    osd_general_timeout  = gContext->GetNumSetting("OSDGeneralTimeout", 2);
    788790    osd_prog_info_timeout= gContext->GetNumSetting("OSDProgramInfoTimeout", 3);
    789791    tryUnflaggedSkip     = gContext->GetNumSetting("TryUnflaggedSkip", 0);
     792    channel_group_id     = gContext->GetNumSetting("ChannelGroupDefault", -1);
     793    browse_changrp       = gContext->GetNumSetting("BrowseChannelGroup", 0);
    790794    smartForward         = gContext->GetNumSetting("SmartForward", 0);
    791795    stickykeys           = gContext->GetNumSetting("StickyKeys");
    792796    ff_rew_repos         = gContext->GetNumSetting("FFRewReposTime", 100)/100.0;
     
    801805    if (!feVBI.isEmpty())
    802806        vbimode = VBIMode::Parse(gContext->GetSetting(feVBI));
    803807
     808    channel_group_id     = gContext->GetNumSetting("ChannelGroupDefault", -1);
     809    browse_changrp       = gContext->GetNumSetting("BrowseChannelGroup", 0);
     810   
     811    if (browse_changrp && (channel_group_id > -1))
     812    {
     813      m_channellist = ChannelUtil::GetChannels(0, true, "channum, callsign", channel_group_id);
     814      ChannelUtil::SortChannels(m_channellist, "channum", true);
     815    }
     816   
     817    m_changrplist  = ChannelGroup::GetChannelGroups();
     818
    804819    if (createWindow)
    805820    {
    806821        MythMainWindow *mainWindow = gContext->GetMainWindow();
     
    967982    VERBOSE(VB_PLAYBACK, "TV::~TV() -- end");
    968983}
    969984
     985void TV::SaveChannelGroup(void)
     986{
     987    int changrpid             = gContext->GetNumSetting("ChannelGroupDefault", -1);
     988    int remember_last_changrp = gContext->GetNumSetting("ChannelGroupRememberLast", 0);
     989 
     990    if (remember_last_changrp && (changrpid != channel_group_id))
     991       gContext->SaveSetting("ChannelGroupDefault", channel_group_id);
     992}
     993
    970994/**
    971995 * \brief get tv state of active player context
    972996 */
     
    61756199
    61766200void TV::ToggleChannelFavorite(PlayerContext *ctx)
    61776201{
    6178     if (ctx->recorder)
    6179         ctx->recorder->ToggleChannelFavorite();
     6202//    if (ctx->recorder)
     6203//        ctx->recorder->ToggleChannelFavorite();
    61806204}
    61816205
    61826206QString TV::GetQueuedInput(void) const
     
    64326456{
    64336457    bool muted = false;
    64346458
     6459    if ((browse_changrp || (direction == CHANNEL_DIRECTION_FAVORITE)) &&
     6460        (channel_group_id > -1) && (direction != CHANNEL_DIRECTION_SAME))
     6461    {
     6462        uint chanid;
     6463       
     6464        // Collect channel info
     6465        //DEBUG
     6466        //pbinfoLock.lock();
     6467        ctx->LockPlayingInfo(__FILE__, __LINE__);
     6468        uint old_chanid  = ctx->playingInfo->chanid.toUInt();
     6469        ctx->LockPlayingInfo(__FILE__, __LINE__);
     6470//        pbinfoLock.unlock();
     6471 
     6472        chanid = ChannelUtil::GetNextChannel(m_channellist, old_chanid, 0, direction);
     6473 
     6474        ChangeChannel(ctx, chanid, "");     
     6475        return;
     6476    }
     6477    else if (direction == CHANNEL_DIRECTION_FAVORITE)
     6478    {
     6479        direction = CHANNEL_DIRECTION_UP;
     6480    }
     6481
    64356482    QString oldinputname = ctx->recorder->GetInput();
    64366483
    64376484    ctx->LockDeleteNVP(__FILE__, __LINE__);
     
    76037650    // Actually show the pop-up UI
    76047651    DBChanList changeChannel;
    76057652    ProgramInfo *nextProgram = NULL;
     7653    int changrpid = channel_group_id;
     7654   
    76067655    switch (editType)
    76077656    {
    76087657        case kScheduleProgramGuide:
    76097658        {
    76107659            TV *player = (pause_active) ? NULL : this;
    76117660            changeChannel = GuideGrid::Run(
    7612                 chanid, channum, false, player, isLiveTV && player);
     7661                chanid, channum, false, player, isLiveTV && player, &changrpid);
    76137662            break;
    76147663        }
    76157664        case kScheduleProgramFinder:
     
    76487697    actx = GetPlayerReadLock(-1, __FILE__, __LINE__);
    76497698    StopEmbedding(actx);               // Undo any embedding
    76507699    DoSetPauseState(actx, was_paused); // Restore pause states
     7700   
     7701    // if channel group was changed in EPG update local info
     7702    if ((changrpid != channel_group_id) && (editType == kScheduleProgramGuide))
     7703    {
     7704        channel_group_id = changrpid;
     7705       
     7706        if (browse_changrp)
     7707        {
     7708            VERBOSE(VB_IMPORTANT, LOC +
     7709               QString("Reloading channel group list for %1").arg(channel_group_id));
     7710       
     7711            m_channellist = ChannelUtil::GetChannels(0, true, "channum, callsign", channel_group_id);
     7712            ChannelUtil::SortChannels(m_channellist, "channum", true);
     7713        }
     7714    }
     7715
    76517716    // If user selected a new channel in the EPG, change to that channel
    76527717    if (isLiveTV && changeChannel.size())
    76537718        ChangeChannel(actx, changeChannel);
     
    84978562{
    84988563    if (!browsemode)
    84998564        BrowseStart(ctx);
     8565   
     8566    VERBOSE(VB_IMPORTANT,"In BrowseDispInfo");
     8567    // if browsing channel groups is enabled or direction if BROWSE_FAVORITES
     8568    // Then pick the next channel in the channel group list to browse
     8569    // If channel group is ALL CHANNELS (-1), then bypass picking from
     8570    // the channel group list
     8571    if ((browse_changrp || (direction == BROWSE_FAVORITE)) &&
     8572        (channel_group_id > -1) && (direction != BROWSE_SAME) &&
     8573        (direction != BROWSE_RIGHT) && (direction != BROWSE_LEFT))
     8574    {
     8575        uint chanid;
     8576        int  dir;
     8577     
     8578        if ( (direction == BROWSE_UP) || (direction == BROWSE_FAVORITE) )
     8579            dir = CHANNEL_DIRECTION_UP;
     8580        else if (direction == BROWSE_DOWN)
     8581            dir = CHANNEL_DIRECTION_DOWN;
     8582        else // this should never happen, but just in case
     8583            dir = direction;
     8584         
     8585        chanid = ChannelUtil::GetNextChannel(m_channellist, browsechanid, 0, dir);
     8586        VERBOSE(VB_IMPORTANT, QString("Get channel: %1").arg(chanid));
     8587        browsechanid  = chanid;
     8588        browsechannum = QString::null;
     8589        direction     = BROWSE_SAME;
     8590    }
     8591    else if ((channel_group_id == -1) && (direction == BROWSE_FAVORITE))
     8592    {
     8593        direction = BROWSE_UP;
     8594    }
    85008595
    85018596    OSD *osd = GetOSDLock(ctx);
    85028597    if (ctx->paused || !osd)
     
    94019496    }
    94029497    else if (action == "GUIDE")
    94039498        EditSchedule(actx, kScheduleProgramGuide);
     9499    else if (action.left(10) == "CHANGROUP_")
     9500        processChanGroupEntry(action);
    94049501    else if (action == "FINDER")
    94059502        EditSchedule(actx, kScheduleProgramFinder);
    94069503    else if (action == "SCHEDULE")
     
    95079604    ReturnPlayerLock(actx);
    95089605}
    95099606
     9607void TV::processChanGroupEntry(QString action)
     9608{
     9609    if (action == "CHANGROUP_ALL_CHANNELS")
     9610    {
     9611        channel_group_id = -1;
     9612    }
     9613    else
     9614    {
     9615        action.remove("CHANGROUP_");
     9616        channel_group_id = action.toInt();
     9617         
     9618        if (browse_changrp)
     9619        {
     9620           m_channellist = ChannelUtil::GetChannels(0, true, "channum, callsign", channel_group_id);
     9621           ChannelUtil::SortChannels(m_channellist, "channum", true);
     9622        }
     9623    }
     9624}
     9625
    95109626void TV::ShowOSDTreeMenu(const PlayerContext *ctx)
    95119627{
    95129628    int osdMenuCount = osdMenuEntries->GetCount();
     
    95789694    }
    95799695    else if (category == "GUIDE")
    95809696        new OSDGenericTree(treeMenu, tr("Program Guide"), "GUIDE");
     9697    else if (category == "CHANGROUP")
     9698        FillMenuChanGroups(ctx, treeMenu);
    95819699    else if (category ==  "PIP")
    95829700        FillMenuPxP(ctx, treeMenu);
    95839701    else if (category == "INPUTSWITCHING")
     
    1012610244    return true;
    1012710245}
    1012810246
     10247void TV::FillMenuChanGroups(
     10248    const PlayerContext *ctx, OSDGenericTree *treeMenu) const
     10249{
     10250    OSDGenericTree *cg_item = new OSDGenericTree(treeMenu, tr("Channel Groups"),
     10251                                                 "CHANGROUP");
     10252    new OSDGenericTree(cg_item, tr("All Channels"), "CHANGROUP_ALL_CHANNELS",
     10253                                 (channel_group_id == -1) ? 1 : 0,
     10254                                 NULL, "CHANNELGROUP");
     10255
     10256    ChannelGroupList::const_iterator it;
     10257       
     10258    for (it = m_changrplist.begin(); it != m_changrplist.end(); ++it)
     10259    {
     10260        QString name = QString("CHANGROUP_%1").arg(it->grpid);
     10261        new OSDGenericTree(cg_item, it->name, name,
     10262                           ((int)(it->grpid) == channel_group_id) ? 1 : 0,
     10263                           NULL, "CHANNELGROUP");
     10264    }       
     10265}
     10266
    1012910267void TV::ToggleAutoExpire(PlayerContext *ctx)
    1013010268{
    1013110269    QString desc = QString::null;
  • mythtv/libs/libmythtv/remoteencoder.h

     
    5050        PictureAdjustType type, PictureAttribute attr, bool up);
    5151    void ChangeChannel(int channeldirection);
    5252    void ChangeDeinterlacer(int deint_mode);
    53     void ToggleChannelFavorite(void);
    5453    void SetChannel(QString channel);
    5554    int  SetSignalMonitoringRate(int msec, bool notifyFrontend = true);
    5655    uint GetSignalLockTimeout(QString input);
  • mythtv/libs/libmythtv/tvosdmenuentry.cpp

     
    192192    curMenuEntries.append(
    193193        new TVOSDMenuEntry("GUIDE",                     1,  1,  0,  0, "Program Guide"));
    194194    curMenuEntries.append(
     195        new TVOSDMenuEntry("CHANGROUP",                     1,  1,  0,  0, "Channel Groups"));
     196    curMenuEntries.append(
    195197        new TVOSDMenuEntry("PIP",                          1,  1,  1,  -1, "Picture-in-Picture"));
    196198    curMenuEntries.append(
    197199        new TVOSDMenuEntry("INPUTSWITCHING",   1,  -1,  -1,  -1, "Change TV Input"));
  • mythtv/libs/libmythtv/channelgroupsettings.cpp

     
     1#include "mythcontext.h"
     2#include "libmythdb/mythdbcon.h"
     3#include <qsqldatabase.h>
     4#include <qcursor.h>
     5#include <qlayout.h>
     6#include <iostream>
     7#include "mythstorage.h"
     8#include "mythdb.h"
     9#include "channelutil.h"
     10#include "channelgroup.h"
     11#include "channelgroupsettings.h"
     12
     13#define LOC QString("Channel Group Settings: ")
     14#define LOC_ERR QString("Channel Group Settings, Error: ")
     15
     16// Storage class for channel group editor in settings
     17class ChannelGroupStorage : public Storage
     18{
     19  public:
     20    ChannelGroupStorage(Setting *_setting,
     21                    uint _chanid, QString _grpname) :
     22        setting(_setting), chanid(_chanid), grpname(_grpname) {}
     23    virtual ~ChannelGroupStorage() {};
     24
     25    virtual void Load(void);
     26    virtual void Save(void);
     27    virtual void Save(QString destination);
     28
     29  protected:
     30    Setting *setting;
     31    uint    chanid;
     32    QString grpname;
     33    int     grpid;
     34};
     35
     36void ChannelGroupStorage::Load(void)
     37{
     38    setting->setValue("0");
     39    setting->setUnchanged();
     40   
     41    MSqlQuery query(MSqlQuery::InitCon());
     42   
     43    QString qstr = "SELECT grpid FROM channelgroupnames WHERE name = :GRPNAME";
     44   
     45    query.prepare(qstr);
     46    query.bindValue(":GRPNAME", grpname);
     47
     48    if (!query.exec() || !query.isActive())
     49        MythDB::DBError("ChannelGroupStorage::Load", query);
     50    else
     51    {
     52      query.next();
     53      grpid = query.value(0).toUInt();
     54   
     55      qstr = "SELECT * FROM channelgroup WHERE grpid = :GRPID AND chanid = :CHANID";
     56      query.prepare(qstr);
     57      query.bindValue(":GRPID",  grpid);
     58      query.bindValue(":CHANID", chanid);
     59
     60      if (!query.exec() || !query.isActive())
     61          MythDB::DBError("ChannelGroupStorage::Load", query);
     62      else if (query.size() > 0)
     63        setting->setValue("1");
     64    }
     65}
     66
     67void ChannelGroupStorage::Save(void)
     68{
     69    if (!setting->isChanged())
     70      return;
     71   
     72    QString value = setting->getValue();
     73   
     74    if (value == "1")
     75        ChannelGroup::ToggleChannel(chanid, grpid, false);
     76    else
     77        ChannelGroup::ToggleChannel(chanid, grpid, true);   
     78}
     79
     80void ChannelGroupStorage::Save(QString destination)
     81{
     82    Save();
     83}
     84
     85class ChannelCheckBox : public CheckBoxSetting, public ChannelGroupStorage
     86{
     87  public:
     88    ChannelCheckBox(const ChannelGroupConfig& _parent, const uint chanid, const QString channum,
     89               const QString channame, const QString grpname):
     90        CheckBoxSetting(this),
     91        ChannelGroupStorage(this, chanid, grpname)
     92    {
     93        setLabel(QString("%1 %2").arg(channum).arg(channame));
     94        setHelpText(QObject::tr("Select/Unselect channels for this channel group"));
     95    };
     96};
     97
     98ChannelGroupConfig::ChannelGroupConfig(QString _name)
     99    : name(_name)
     100{
     101    VerticalConfigurationGroup   *cgroup;
     102    HorizontalConfigurationGroup *columns;
     103
     104    DBChanList chanlist = ChannelUtil::GetChannels(0, true, "channum, callsign");
     105    ChannelUtil::SortChannels(chanlist, "channum", true);
     106
     107    DBChanList::iterator it = chanlist.begin();
     108    int i,j = 0;
     109    int p = 1;
     110    int pages = (int)((float)chanlist.size() / 8.0 / 3.0 + 0.5);
     111   
     112    do
     113    { 
     114        columns = new HorizontalConfigurationGroup(false,false,false,false);
     115        columns->setLabel(getName() + " " +
     116                          QObject::tr("Channel Group - Page ") + QString("%1").arg(p) +
     117                          QObject::tr("of") + QString("%1").arg(pages));
     118       
     119        for (j = 0; ((j < 3) && (it < chanlist.end())); ++j)
     120        {
     121            cgroup = new VerticalConfigurationGroup(false,false,false,false);
     122           
     123            for (i = 0; ((i < 8) && (it < chanlist.end())); ++i)
     124            {
     125                cgroup->addChild(new ChannelCheckBox(*this, it->chanid, it->channum, it->name, _name));
     126                ++it;
     127            }
     128            columns->addChild(cgroup);
     129        }
     130       
     131        ++p;
     132        addChild(columns);
     133    } while (it < chanlist.end());
     134
     135}
     136
     137ChannelGroupEditor::ChannelGroupEditor(void) :
     138    listbox(new ListBoxSetting(this)), lastValue("__CREATE_NEW_GROUP__")
     139{
     140    listbox->setLabel(tr("Channel Groups"));
     141    addChild(listbox);
     142}
     143
     144void ChannelGroupEditor::open(QString name)
     145{
     146    lastValue = name;
     147    bool created = false;
     148
     149    if (name == "__CREATE_NEW_GROUP__")
     150    {
     151        name = "";
     152       
     153        bool ok = MythPopupBox::showGetTextPopup(gContext->GetMainWindow(),
     154            tr("Create New Channel Group"),
     155            tr("Enter group name or press SELECT to enter text via the "
     156               "On Screen Keyboard"), name);
     157        if (!ok)
     158            return;
     159
     160        MSqlQuery query(MSqlQuery::InitCon());
     161        query.prepare("INSERT INTO channelgroupnames (name) VALUES (:NAME);");
     162        query.bindValue(":NAME", name);
     163        if (!query.exec())
     164            MythDB::DBError("ChannelGroupEditor::open", query);
     165        else
     166            created = true;
     167    }
     168   
     169    ChannelGroupConfig group(name);
     170   
     171    if (group.exec() == QDialog::Accepted || !created)
     172        lastValue = name;
     173
     174};
     175
     176void ChannelGroupEditor::doDelete(void)
     177{
     178    QString name = listbox->getValue();
     179    if (name == "__CREATE_NEW_GROUP__")
     180        return;
     181
     182    QString message = tr("Delete '%1' Channel group?").arg(name);
     183   
     184    DialogCode value = MythPopupBox::Show2ButtonPopup(
     185        gContext->GetMainWindow(),
     186        "", message,
     187        tr("Yes, delete group"),
     188        tr("No, Don't delete group"), kDialogCodeButton1);
     189
     190    if (kDialogCodeButton0 == value)
     191    {
     192        MSqlQuery query(MSqlQuery::InitCon());
     193
     194        // Find out channel group id
     195        query.prepare("SELECT grpid FROM channelgroupnames WHERE name = :NAME;");
     196        query.bindValue(":NAME", name);
     197        if (!query.exec())
     198            MythDB::DBError("ChannelGroupEditor::doDelete", query);
     199        query.next();
     200        uint grpid = query.value(0).toUInt();
     201
     202        // Delete channels from this group
     203        query.prepare("DELETE FROM channelgroup WHERE grpid = :GRPID;");
     204        query.bindValue(":GRPID", grpid);
     205        if (!query.exec())
     206            MythDB::DBError("ChannelGroupEditor::doDelete", query);
     207       
     208        // Now delete the group from channelgroupnames
     209        query.prepare("DELETE FROM channelgroupnames WHERE name = :NAME;");
     210        query.bindValue(":NAME", name);
     211        if (!query.exec())
     212            MythDB::DBError("ChannelGroupEditor::doDelete", query);
     213
     214        lastValue = "__CREATE_NEW_GROUP__";
     215        Load();
     216    }
     217
     218    listbox->setFocus();
     219}
     220
     221void ChannelGroupEditor::Load(void)
     222{
     223    listbox->clearSelections();
     224   
     225    ChannelGroupList changrplist;
     226
     227    changrplist = ChannelGroup::GetChannelGroups();
     228
     229    ChannelGroupList::iterator it;
     230
     231    for (it = changrplist.begin(); it < changrplist.end(); ++it)
     232       listbox->addSelection(it->name);
     233       
     234    listbox->addSelection(tr("(Create new group)"), "__CREATE_NEW_GROUP__");
     235
     236    listbox->setValue(lastValue);
     237}
     238
     239DialogCode ChannelGroupEditor::exec(void)
     240{
     241    while (ConfigurationDialog::exec() == kDialogCodeAccepted)
     242        open(listbox->getValue());
     243
     244    return kDialogCodeRejected;
     245}
     246
     247MythDialog* ChannelGroupEditor::dialogWidget(MythMainWindow* parent,
     248                                          const char* widgetName)
     249{
     250    dialog = ConfigurationDialog::dialogWidget(parent, widgetName);
     251    connect(dialog, SIGNAL(menuButtonPressed()), this, SLOT(doDelete()));
     252    connect(dialog, SIGNAL(deleteButtonPressed()), this, SLOT(doDelete()));
     253    return dialog;
     254}
  • mythtv/libs/libmythtv/remoteencoder.cpp

     
    402402    return (lastinput.isEmpty()) ? "Error" : lastinput;
    403403}
    404404
    405 void RemoteEncoder::ToggleChannelFavorite(void)
    406 {
    407     QStringList strlist( QString("QUERY_RECORDER %1").arg(recordernum) );
    408     strlist << "TOGGLE_CHANNEL_FAVORITE";
    409 
    410     SendReceiveStringList(strlist);
    411 }
    412 
    413405void RemoteEncoder::ChangeChannel(int channeldirection)
    414406{
    415407    QStringList strlist( QString("QUERY_RECORDER %1").arg(recordernum) );
  • mythtv/libs/libmythtv/tv_rec.cpp

     
    29022902    }
    29032903}
    29042904
    2905 /** \fn TVRec::ToggleChannelFavorite()
    2906  *  \brief Toggles whether the current channel should be on our favorites list.
    2907  */
    2908 void TVRec::ToggleChannelFavorite(void)
    2909 {
    2910     QMutexLocker lock(&stateChangeLock);
    2911 
    2912     if (!channel)
    2913         return;
    2914 
    2915     // Get current channel id...
    2916     uint    sourceid = channel->GetCurrentSourceID();
    2917     QString channum  = channel->GetCurrentName();
    2918     uint chanid = ChannelUtil::GetChanID(sourceid, channum);
    2919 
    2920     if (!chanid)
    2921     {
    2922         VERBOSE(VB_IMPORTANT, LOC_ERR + QString(
    2923                 "Channel: \'%1\' was not found in the database.\n"
    2924                 "\t\t\tMost likely, your DefaultTVChannel setting is wrong.\n"
    2925                 "\t\t\tCould not toggle favorite.").arg(channum));
    2926         return;
    2927     }
    2928 
    2929     // Check if favorite exists for that chanid...
    2930     MSqlQuery query(MSqlQuery::InitCon());
    2931     query.prepare(
    2932         "SELECT favorites.favid "
    2933         "FROM favorites "
    2934         "WHERE favorites.chanid = :CHANID "
    2935         "LIMIT 1");
    2936     query.bindValue(":CHANID", chanid);
    2937 
    2938     if (!query.exec() || !query.isActive())
    2939     {
    2940         MythDB::DBError("togglechannelfavorite", query);
    2941     }
    2942     else if (query.size() > 0)
    2943     {
    2944         // We have a favorites record...Remove it to toggle...
    2945         query.next();
    2946         QString favid = query.value(0).toString();
    2947         query.prepare(
    2948             QString("DELETE FROM favorites "
    2949                     "WHERE favid = '%1'").arg(favid));
    2950         query.exec();
    2951         VERBOSE(VB_RECORD, LOC + "Removing Favorite.");
    2952     }
    2953     else
    2954     {
    2955         // We have no favorites record...Add one to toggle...
    2956         query.prepare(
    2957             QString("INSERT INTO favorites (chanid) "
    2958                     "VALUES ('%1')").arg(chanid));
    2959         query.exec();
    2960         VERBOSE(VB_RECORD, LOC + "Adding Favorite.");
    2961     }
    2962 }
    2963 
    29642905/** \fn TVRec::ChangePictureAttribute(PictureAdjustType,PictureAttribute,bool)
    29652906 *  \brief Returns current value [0,100] if it succeeds, -1 otherwise.
    29662907 *
  • mythtv/programs/mythfrontend/globalsettings.cpp

     
    31593159    return gc;
    31603160}
    31613161
    3162 static HostCheckBox *EPGShowFavorites()
    3163 {
    3164     HostCheckBox *gc = new HostCheckBox("EPGShowFavorites");
    3165     gc->setLabel(QObject::tr("Only display 'favorite' channels"));
    3166     gc->setHelpText(QObject::tr("If enabled, the EPG will initially display "
    3167                     "only the channels marked as favorites. Pressing "
    3168                     "\"4\" will toggle between displaying favorites and all "
    3169                     "channels."));
    3170     gc->setValue(false);
    3171     return gc;
    3172 }
    31733162
    31743163static HostSpinBox *EPGChanDisplay()
    31753164{
     
    31973186    return gc;
    31983187}
    31993188
     3189static HostCheckBox *ChannelGroupRememberLast()
     3190{
     3191    HostCheckBox *gc = new HostCheckBox("ChannelGroupRememberLast");
     3192    gc->setLabel(QObject::tr("Remember last channel group"));
     3193    gc->setHelpText(QObject::tr("If enabled, the EPG will initially display "
     3194                    "only the channels from the last channel group selected. Pressing "
     3195                    "\"4\" will toggle channel group."));
     3196    gc->setValue(false);
     3197    return gc;
     3198}
     3199
     3200static HostComboBox *ChannelGroupDefault()
     3201{
     3202    HostComboBox *gc = new HostComboBox("ChannelGroupDefault");
     3203    gc->setLabel(QObject::tr("Default channel group"));
     3204
     3205    ChannelGroupList changrplist;
     3206
     3207    changrplist = ChannelGroup::GetChannelGroups();
     3208
     3209    gc->addSelection(QObject::tr("All Channels"), "-1");
     3210
     3211    ChannelGroupList::iterator it;
     3212
     3213    for (it = changrplist.begin(); it < changrplist.end(); ++it)
     3214       gc->addSelection(it->name, QString("%1").arg(it->grpid));
     3215
     3216    gc->setHelpText(QObject::tr("Default channel group to be shown in the the EPG"
     3217                    "Pressing "
     3218                    "\"4\" will toggle channel group."));
     3219    gc->setValue(false);
     3220    return gc;
     3221}
     3222
     3223static HostCheckBox *BrowseChannelGroup()
     3224{
     3225    HostCheckBox *gc = new HostCheckBox("BrowseChannelGroup");
     3226    gc->setLabel(QObject::tr("Browse/Change channels from Channel Group"));
     3227    gc->setHelpText(QObject::tr("If enabled, LiveTV will browse or change channels "
     3228                    "from the selected channel group. \"All Channels\" "
     3229                    "channel group may be selected to browse all channels."));
     3230    gc->setValue(false);
     3231    return gc;
     3232}
     3233
     3234// Channel Group Settings
     3235class ChannelGroupSettings : public TriggeredConfigurationGroup
     3236{
     3237  public:
     3238    ChannelGroupSettings() : TriggeredConfigurationGroup(false, true, false, false)
     3239    {
     3240         setLabel(QObject::tr("Remember last channel group"));
     3241         setUseLabel(false);
     3242
     3243         Setting* RememberChanGrpEnabled = ChannelGroupRememberLast();
     3244         addChild(RememberChanGrpEnabled);
     3245         setTrigger(RememberChanGrpEnabled);
     3246
     3247         ConfigurationGroup* settings = new VerticalConfigurationGroup(false);
     3248         settings->addChild(ChannelGroupDefault());
     3249         addTarget("0", settings);
     3250
     3251         // show nothing if RememberChanGrpEnabled is on
     3252         addTarget("1", new VerticalConfigurationGroup(true));
     3253     };
     3254};
     3255
    32003256// General RecPriorities settings
    32013257
    32023258static GlobalCheckBox *GRSchedMoveHigher()
     
    49655021    general2->addChild(CategoryOverTimeSettings());
    49665022    addChild(general2);
    49675023
     5024    VerticalConfigurationGroup* changrp = new VerticalConfigurationGroup(false);
     5025    changrp->setLabel(QObject::tr("General (Channel Groups)"));
     5026    ChannelGroupSettings *changroupsettings = new ChannelGroupSettings();
     5027    changrp->addChild(changroupsettings);
     5028    changrp->addChild(BrowseChannelGroup());
     5029    addChild(changrp);
    49685030}
    49695031
    49705032EPGSettings::EPGSettings()
    49715033{
    49725034    VerticalConfigurationGroup* epg = new VerticalConfigurationGroup(false);
    4973     epg->setLabel(QObject::tr("Program Guide") + " 1/2");
     5035    epg->setLabel(QObject::tr("Program Guide") + " 1/3");
    49745036    epg->addChild(EPGFillType());
    49755037    epg->addChild(EPGShowCategoryColors());
    49765038    epg->addChild(EPGShowCategoryText());
    49775039    epg->addChild(EPGScrollType());
    49785040    epg->addChild(EPGShowChannelIcon());
    4979     epg->addChild(EPGShowFavorites());
    49805041    epg->addChild(WatchTVGuide());
    49815042    epg->addChild(EPGChanDisplay());
    49825043    epg->addChild(EPGTimeDisplay());
    49835044    addChild(epg);
    49845045
    49855046    VerticalConfigurationGroup* gen = new VerticalConfigurationGroup(false);
    4986     gen->setLabel(QObject::tr("Program Guide") + " 2/2");
     5047    gen->setLabel(QObject::tr("Program Guide") + " 2/3");
    49875048    gen->addChild(UnknownTitle());
    49885049    gen->addChild(UnknownCategory());
    49895050    gen->addChild(DefaultTVChannel());
    49905051    gen->addChild(SelectChangesChannel());
    49915052    gen->addChild(EPGRecThreshold());
    49925053    gen->addChild(EPGEnableJumpToChannel());
    4993     addChild(gen);
     5054    addChild(gen);   
    49945055}
    49955056
    49965057GeneralRecPrioritiesSettings::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"
     
    517518        EPGSettings settings;
    518519        settings.exec();
    519520    }
     521    else if (sel == "settings channelgroups")
     522    {
     523        ChannelGroupEditor editor;
     524        editor.exec();
     525     }
    520526    else if (sel == "settings generalrecpriorities")
    521527    {
    522528        GeneralRecPrioritiesSettings settings;
  • mythtv/programs/mythbackend/encoderlink.h

     
    8484    vector<InputInfo> GetFreeInputs(const vector<uint> &excluded_cards) const;
    8585    QString GetInput(void) const;
    8686    QString SetInput(QString);
    87     void ToggleChannelFavorite(void);
    8887    void ChangeChannel(int channeldirection);
    8988    void SetChannel(const QString &name);
    9089    int  GetPictureAttribute(PictureAttribute attr);
  • mythtv/programs/mythbackend/mainserver.cpp

     
    32193219        ret = (ret.isEmpty()) ? "UNKNOWN" : ret;
    32203220        retlist << ret;
    32213221    }
    3222     else if (command == "TOGGLE_CHANNEL_FAVORITE")
    3223     {
    3224         enc->ToggleChannelFavorite();
    3225         retlist << "ok";
    3226     }
    32273222    else if (command == "CHANGE_CHANNEL")
    32283223    {
    32293224        int direction = slist[2].toInt();
  • mythtv/programs/mythbackend/encoderlink.cpp

     
    680680    return QString::null;
    681681}
    682682
    683 /** \fn EncoderLink::ToggleChannelFavorite(void)
    684  *  \brief Toggles whether the current channel should be on our favorites list.
    685  *         <b>This only works on local recorders.</b>
    686  *  \return -1 if query does not succeed, otherwise.
    687  */
    688 void EncoderLink::ToggleChannelFavorite(void)
    689 {
    690     if (local)
    691         tv->ToggleChannelFavorite();
    692     else
    693         VERBOSE(VB_IMPORTANT, "Should be local only query: ToggleChannelFavorite");
    694 }
    695 
    696683/** \fn EncoderLink::ChangeChannel(int)
    697684 *  \brief Changes to the next or previous channel.
    698685 *         <b>This only works on local recorders.</b>