Ticket #199: favorites_update.diff

File favorites_update.diff, 49.5 KB (added by Bill <level42@…>, 16 years ago)

Updated for SVN 14755; Added favorite channel editor

  • libs/libmythtv/channelutil.cpp

    diff -Nur --exclude='*.lib' --exclude='*.o' mythtv/libs/libmythtv/channelutil.cpp mythtv-guide/libs/libmythtv/channelutil.cpp
    old new  
    12961296                           dvb_transportid, dvb_networkid, dtv_si_std);
    12971297}
    12981298
    1299 DBChanList ChannelUtil::GetChannels(uint sourceid, bool vis_only, QString grp)
     1299DBChanList ChannelUtil::GetChannels(uint sourceid, bool vis_only, QString grp, int favgrpid)
    13001300{
    13011301    DBChanList list;
    1302     QMap<uint,uint> favorites;
    13031302    MSqlQuery query(MSqlQuery::InitCon());
    1304     query.prepare(
    1305         "SELECT chanid, favid "
    1306         "FROM favorites");
    1307     if (!query.exec() || !query.isActive())
    1308         MythContext::DBError("get channels -- favorites", query);
    1309     else
    1310     {
    1311         while (query.next())
    1312             favorites[query.value(0).toUInt()] = query.value(1).toUInt();
     1303   
     1304    QString qstr = "SELECT channum, callsign, channel.chanid, "
     1305           "       atsc_major_chan, atsc_minor_chan, "
     1306           "       name, icon, visible "
     1307           "FROM channel";
     1308
     1309
     1310    if (favgrpid > -1)
     1311    {
     1312       // Select only favorite channels from the specified group
     1313       
     1314       if (sourceid)
     1315           qstr += QString(",favorites WHERE sourceid='%1' AND ").arg(sourceid);
     1316       else
     1317           qstr += ",cardinput,capturecard,favorites "
     1318                   "WHERE cardinput.sourceid = channel.sourceid   AND "
     1319                   "      cardinput.cardid   = capturecard.cardid AND ";
     1320                   
     1321       qstr += QString("channel.chanid = favorites.chanid AND favorites.favgrpid ='%1' ").arg(favgrpid);
    13131322    }
    1314 
    1315     QString qstr =
    1316         "SELECT channum, callsign, chanid, "
    1317         "       atsc_major_chan, atsc_minor_chan, "
    1318         "       name, icon, visible "
    1319         "FROM channel ";
    1320 
    1321     if (sourceid)
    1322         qstr += QString("WHERE sourceid='%1' ").arg(sourceid);
    13231323    else
    1324         qstr += ",cardinput,capturecard "
    1325             "WHERE cardinput.sourceid = channel.sourceid   AND "
    1326             "      cardinput.cardid   = capturecard.cardid     ";
     1324    {
     1325       // Select All channels
     1326       
     1327       if (sourceid)
     1328           qstr += QString(" WHERE sourceid='%1' ").arg(sourceid);
     1329       else
     1330           qstr += ",cardinput,capturecard "
     1331                   "WHERE cardinput.sourceid = channel.sourceid   AND "
     1332                   "      cardinput.cardid   = capturecard.cardid     ";
     1333    }
    13271334
    13281335    if (vis_only)
    13291336        qstr += "AND visible=1 ";
     
    13491356            query.value(2).toUInt(),                      /* chanid     */
    13501357            query.value(3).toUInt(),                      /* ATSC major */
    13511358            query.value(4).toUInt(),                      /* ATSC minor */
    1352             favorites[query.value(2).toUInt()],           /* favid      */
     1359            0,                                            /* favid      */
    13531360            query.value(7).toBool(),                      /* visible    */
    13541361            QString::fromUtf8(query.value(5).toString()), /* name       */
    13551362            query.value(6).toString());                   /* icon       */
     
    15191526        } while ((it != start) && skip_non_visible && !it->visible);
    15201527
    15211528    }
    1522     else if (CHANNEL_DIRECTION_UP == direction)
     1529    else if ((CHANNEL_DIRECTION_UP == direction) || (CHANNEL_DIRECTION_FAVORITE == direction))
    15231530    {
    15241531        do
    15251532        {
     
    15281535                it = sorted.begin();
    15291536        } while ((it != start) && skip_non_visible && !it->visible);
    15301537    }
    1531     else if (CHANNEL_DIRECTION_FAVORITE == direction)
    1532     {
    1533         do
    1534         {
    1535             it++;
    1536             if (it == sorted.end())
    1537                 it = sorted.begin();
    1538 
    1539         } while ((it != start) &&
    1540                  (!it->favorite || (skip_non_visible && !it->visible)));
    1541     }
     1538//    else if (CHANNEL_DIRECTION_FAVORITE == direction)
     1539//    {
     1540//        do
     1541//        {
     1542//            it++;
     1543//            if (it == sorted.end())
     1544//                it = sorted.begin();
     1545
     1546//        } while ((it != start) &&
     1547//                 (!it->favorite || (skip_non_visible && !it->visible)));
     1548//    }
    15421549
    15431550    return it->chanid;
    15441551}
  • libs/libmythtv/channelutil.h

    diff -Nur --exclude='*.lib' --exclude='*.o' mythtv/libs/libmythtv/channelutil.h mythtv-guide/libs/libmythtv/channelutil.h
    old new  
    4343};
    4444typedef vector<DBChannel> DBChanList;
    4545
    46 
    4746/** \class ChannelUtil
    4847 *  \brief Collection of helper utilities for channel DB use
    4948 */
     
    164163    static QString GetVideoFilters(uint sourceid, const QString &channum)
    165164        { return GetChannelValueStr("videofilters", sourceid, channum); }
    166165
    167     static DBChanList GetChannels(uint srcid, bool vis_only, QString grp="");
     166    static DBChanList GetChannels(uint srcid, bool vis_only, QString grp="", int favgrpid=-1);
    168167    static void    SortChannels(DBChanList &list, const QString &order,
    169168                                bool eliminate_duplicates = false);
    170169    static void    EliminateDuplicateChanNum(DBChanList &list);
  • libs/libmythtv/favoritegroup.cpp

    diff -Nur --exclude='*.lib' --exclude='*.o' mythtv/libs/libmythtv/favoritegroup.cpp mythtv-guide/libs/libmythtv/favoritegroup.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 "favoritegroup.h"
     10
     11#define LOC QString("Favorites: ")
     12#define LOC_ERR QString("Favorites, Error: ")
     13
     14// Storage class for favorite group channel editor in settings
     15class FavoriteStorage : public Storage
     16{
     17  public:
     18    FavoriteStorage(Setting *_setting,
     19                    uint _chanid, QString _grpname) :
     20        setting(_setting), chanid(_chanid), grpname(_grpname) {}
     21    virtual ~FavoriteStorage() {};
     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 FavoriteStorage::load(void)
     35{
     36    setting->setValue("0");
     37    setting->setUnchanged();
     38   
     39    MSqlQuery query(MSqlQuery::InitCon());
     40   
     41    QString qstr = "SELECT favgrpid FROM favoritegroups WHERE name = :GRPNAME";
     42   
     43    query.prepare(qstr);
     44    query.bindValue(":GRPNAME", grpname);
     45
     46    if (!query.exec() || !query.isActive())
     47        MythContext::DBError("get favoriate Groups", query);
     48    else
     49    {
     50      query.next();
     51      grpid = query.value(0).toUInt();
     52   
     53      qstr = "SELECT * FROM favorites WHERE favgrpid = :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("get favoriate Groups", query);
     60      else if (query.size() > 0)
     61        setting->setValue("1");
     62    }
     63}
     64
     65void FavoriteStorage::save(void)
     66{
     67    if (!setting->isChanged())
     68      return;
     69   
     70    QString value = setting->getValue();
     71   
     72    if (value == "1")
     73        Favorites::ToggleFavorite(chanid, grpid, false);
     74    else
     75        Favorites::ToggleFavorite(chanid, grpid, true);   
     76}
     77
     78void FavoriteStorage::save(QString destination)
     79{
     80    save();
     81}
     82
     83FavoriteGroup& FavoriteGroup::operator=(const FavoriteGroup &other)
     84{
     85    grpid     = other.grpid;
     86    name      = QDeepCopy<QString>(other.name);
     87 
     88    return *this;
     89}
     90
     91FavoriteGroup::FavoriteGroup(const FavoriteGroup &other)
     92{
     93    (*this) = other;
     94}
     95
     96inline bool lt_group(const FavoriteGroup &a, const FavoriteGroup &b)
     97{
     98    return QString::localeAwareCompare(a.name, b.name) < 0;
     99}
     100
     101bool Favorites::ToggleFavorite(uint chanid,int favgrpid, int delete_fav)
     102{
     103    // Check if favorite exists for that chanid...
     104    MSqlQuery query(MSqlQuery::InitCon());
     105    query.prepare(
     106        "SELECT favorites.favid "
     107        "FROM favorites "
     108        "WHERE favorites.chanid = :CHANID AND "
     109        "favorites.favgrpid = :GRPID "
     110        "LIMIT 1");
     111    query.bindValue(":CHANID", chanid);
     112    query.bindValue(":GRPID", favgrpid);
     113
     114    if (!query.exec() || !query.isActive())
     115    {
     116        MythContext::DBError("togglechannelfavorite", query);
     117        return false;
     118    }
     119    else if ((query.size() > 0) && delete_fav)
     120    {
     121        // We have a favorites record...Remove it to toggle...
     122        query.next();
     123        QString favid = query.value(0).toString();
     124        query.prepare(
     125            QString("DELETE FROM favorites "
     126                    "WHERE favid = '%1'").arg(favid));
     127        query.exec();
     128        VERBOSE(VB_IMPORTANT, LOC + "Removing Favorite.");
     129    }
     130    else if (query.size() == 0)
     131    {
     132        // We have no favorites record...Add one to toggle...
     133        query.prepare(
     134            QString("INSERT INTO favorites (chanid,favgrpid) "
     135                    "VALUES ('%1','%2')").arg(chanid).arg(favgrpid));
     136        query.exec();
     137        VERBOSE(VB_IMPORTANT, LOC + "Adding Favorite.");
     138    }
     139
     140    return true;
     141}
     142
     143FavoriteGroupList Favorites::GetFavoriteGroups(void)
     144{
     145    FavoriteGroupList list;
     146   
     147    MSqlQuery query(MSqlQuery::InitCon());
     148   
     149    QString qstr = "SELECT favgrpid, name FROM favoritegroups";
     150   
     151    query.prepare(qstr);
     152
     153    if (!query.exec() || !query.isActive())
     154        MythContext::DBError("get favoriate Groups", query);
     155    else
     156    {
     157        while (query.next())
     158        {
     159           FavoriteGroup 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 Favorites::GetNextFavoriteGroup(const FavoriteGroupList &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    FavoriteGroupList::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 Favorites::GetFavoriteGroupName(const FavoriteGroupList &sorted, int grpid)
     199{
     200    // All Channels
     201    if (grpid == -1)
     202      return "All Channels";
     203
     204    FavoriteGroupList::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 FavChannel : public CheckBoxSetting, public FavoriteStorage
     214{
     215  public:
     216    FavChannel(const FavoriteChannelGroup& _parent, const uint chanid, const QString channum,
     217               const QString channame, const QString grpname):
     218        CheckBoxSetting(this),
     219        FavoriteStorage(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 favorite group"));
     223    };
     224};
     225
     226FavoriteChannelGroup::FavoriteChannelGroup(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 Favorite 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 FavChannel(*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
     265FavoriteGroupEditor::FavoriteGroupEditor(void) :
     266    listbox(new ListBoxSetting(this)), lastValue("__CREATE_NEW_GROUP__")
     267{
     268    listbox->setLabel(tr("Channel Favorite Groups"));
     269    addChild(listbox);
     270}
     271
     272void FavoriteGroupEditor::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 Favorite 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 favoritegroups (name) VALUES (:NAME);");
     290        query.bindValue(":NAME", name.utf8());
     291        if (!query.exec())
     292            MythContext::DBError("FavoriteGroupEditor::open", query);
     293        else
     294            created = true;
     295    }
     296   
     297    FavoriteChannelGroup group(name);
     298   
     299    if (group.exec() == QDialog::Accepted || !created)
     300        lastValue = name;
     301
     302};
     303
     304void FavoriteGroupEditor::doDelete(void)
     305{
     306    QString name = listbox->getValue();
     307    if (name == "__CREATE_NEW_GROUP__")
     308        return;
     309
     310    QString message = tr("Delete favorite group:") +
     311        QString("\n'%1'?").arg(name);
     312
     313    int value = MythPopupBox::show2ButtonPopup(gContext->GetMainWindow(),
     314                                               "", message,
     315                                               tr("Yes, delete group"),
     316                                               tr("No, Don't delete group"), 2);
     317
     318    if (value == 0)
     319    {
     320        MSqlQuery query(MSqlQuery::InitCon());
     321
     322        // Find out favorite group id
     323        query.prepare("SELECT favgrpid FROM favoritegroups WHERE name = :NAME;");
     324        query.bindValue(":NAME", name.utf8());
     325        if (!query.exec())
     326            MythContext::DBError("FavoriteGroupEditor::doDelete", query);
     327        query.next();
     328        uint grpid = query.value(0).toUInt();
     329
     330        // Delete favorite channels from favorites for this group
     331        query.prepare("DELETE FROM favorites WHERE favgrpid = :GRPID;");
     332        query.bindValue(":GRPID", grpid);
     333        if (!query.exec())
     334            MythContext::DBError("FavoriteGroupEditor::doDelete", query);
     335       
     336        // Now delete the group from favoritegroups
     337        query.prepare("DELETE FROM favoritegroups WHERE name = :NAME;");
     338        query.bindValue(":NAME", name.utf8());
     339        if (!query.exec())
     340            MythContext::DBError("FavoriteGroupEditor::doDelete", query);
     341
     342        lastValue = "__CREATE_NEW_GROUP__";
     343        load();
     344    }
     345
     346    listbox->setFocus();
     347}
     348
     349void FavoriteGroupEditor::load(void)
     350{
     351    listbox->clearSelections();
     352   
     353    FavoriteGroupList favgrplist;
     354
     355    favgrplist = Favorites::GetFavoriteGroups();
     356
     357    FavoriteGroupList::iterator it;
     358
     359    for (it = favgrplist.begin(); it < favgrplist.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
     367int FavoriteGroupEditor::exec(void)
     368{
     369    while (ConfigurationDialog::exec() == QDialog::Accepted)
     370        open(listbox->getValue());
     371
     372    return QDialog::Rejected;
     373}
     374
     375MythDialog* FavoriteGroupEditor::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/favoritegroup.h

    diff -Nur --exclude='*.lib' --exclude='*.o' mythtv/libs/libmythtv/favoritegroup.h mythtv-guide/libs/libmythtv/favoritegroup.h
    old new  
     1#ifndef FAVORITEGROUP_H
     2#define FAVORITEGROUP_H
     3
     4#include "qstringlist.h"
     5#include "libmyth/settings.h"
     6#include "libmyth/mythwidgets.h"
     7
     8class FavoriteGroup
     9{
     10  public:
     11    FavoriteGroup(const FavoriteGroup&);
     12    FavoriteGroup(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    FavoriteGroup& operator=(const FavoriteGroup&);
     20
     21  public:
     22    uint    grpid;
     23    QString name;
     24};
     25typedef vector<FavoriteGroup> FavoriteGroupList;
     26
     27/** \class Favorites
     28*/
     29class MPUBLIC Favorites
     30{
     31  public:
     32    // Favorite
     33    static FavoriteGroupList GetFavoriteGroups(void);
     34    static bool              ToggleFavorite(uint chanid,int favgrpid, int delete_fav);
     35    static int               GetNextFavoriteGroup(const FavoriteGroupList &sorted, int grpid);
     36    static QString           GetFavoriteGroupName(const FavoriteGroupList &sorted, int grpid);
     37
     38   
     39  private:
     40
     41};
     42
     43class MPUBLIC FavoriteChannelGroup: public ConfigurationWizard
     44{
     45 public:
     46    FavoriteChannelGroup(QString _name);
     47    QString getName(void) const { return name; }
     48
     49 private:
     50    QString name;
     51};
     52
     53class MPUBLIC FavoriteGroupEditor : public QObject, public ConfigurationDialog
     54{
     55    Q_OBJECT
     56
     57  public:
     58    FavoriteGroupEditor(void);
     59    virtual int 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
  • mythtv/libs/libmythtv/guidegrid.cpp

    old new using namespace std; 
    2020
    2121#include "mythcontext.h"
    2222#include "mythdbcon.h"
    23 #include "guidegrid.h"
    2423#include "infostructs.h"
    2524#include "programinfo.h"
    2625#include "scheduledrecording.h"
    using namespace std; 
    3231#include "customedit.h"
    3332#include "util.h"
    3433#include "remoteutil.h"
    35 #include "channelutil.h"
     34#include "guidegrid.h"
    3635
    3736bool RunProgramGuide(uint &chanid, QString &channum,
    3837                     bool thread, TV *player,
    39                      bool allowsecondaryepg)
     38                     bool allowsecondaryepg, int *favgrpid)
    4039{
    4140    bool channel_changed = false;
     41    int  favorite_group  = -1;
     42   
     43    if (favgrpid != NULL)
     44      favorite_group = *favgrpid;
    4245
    4346    if (thread)
    4447        qApp->lock();
    bool RunProgramGuide(uint &chanid, QStri 
    4750
    4851    GuideGrid *gg = new GuideGrid(gContext->GetMainWindow(),
    4952                                  chanid, channum,
    50                                   player, allowsecondaryepg, "guidegrid");
     53                                  player, allowsecondaryepg, "guidegrid",
     54                                  favorite_group);
    5155
    5256    gg->Show();
    5357
    bool RunProgramGuide(uint &chanid, QStri 
    7074
    7175    if (thread)
    7276        qApp->lock();
    73 
     77   
     78    if (favgrpid != NULL)
     79      *favgrpid = gg->GetFavGrp();
     80   
    7481    delete gg;
    7582
    7683    gContext->removeCurrentLocation();
    bool RunProgramGuide(uint &chanid, QStri 
    8491GuideGrid::GuideGrid(MythMainWindow *parent,
    8592                     uint chanid, QString channum,
    8693                     TV *player, bool allowsecondaryepg,
    87                      const char *name)
     94                     const char *name, int favgrpid)
    8895         : MythDialog(parent, name)
    8996{
    9097    desiredDisplayChans = DISPLAY_CHANS = 6;
    9198    DISPLAY_TIMES = 30;
    9299    int maxchannel = 0;
    93100    m_currentStartChannel = 0;
     101   
     102    m_favgrpid = favgrpid;
     103    m_favgrplist = Favorites::GetFavoriteGroups();
    94104
    95105    m_player = player;
    96106
    GuideGrid::GuideGrid(MythMainWindow *par 
    105115    infoRect = QRect(0, 0, 0, 0);
    106116    curInfoRect = QRect(0, 0, 0, 0);
    107117    videoRect = QRect(0, 0, 0, 0);
     118    favRect = QRect(0, 0, 0, 0);
    108119
    109120    jumpToChannelEnabled = gContext->GetNumSetting("EPGEnableJumpToChannel", 0);
    110121    jumpToChannelActive = false;
    GuideGrid::GuideGrid(MythMainWindow *par 
    125136    if (m_player && m_player->IsRunning() && !allowsecondaryepg)
    126137        videoRect = QRect(0, 0, 1, 1);
    127138
    128     showFavorites = gContext->GetNumSetting("EPGShowFavorites", 0);
    129139    gridfilltype = gContext->GetNumSetting("EPGFillType", UIGuideType::Alpha);
    130140    if (gridfilltype < (int)UIGuideType::Alpha)
    131141    { // update old settings to new fill types
    GuideGrid::GuideGrid(MythMainWindow *par 
    181191            container->SetDrawFontShadow(false);
    182192    }
    183193
     194    container = theme->GetSet("favorite_group");
     195    if (container)
     196    {
     197        UITextType *type = (UITextType *)container->GetType("favgroup");
     198        QString favgroup;
     199       
     200        favgroup = Favorites::GetFavoriteGroupName(m_favgrplist, m_favgrpid);
     201       
     202        if (type)
     203            type->SetText(favgroup);
     204    }
     205
    184206    channelOrdering = gContext->GetSetting("ChannelOrdering", "channum");
    185207    dateformat = gContext->GetSetting("ShortDateFormat", "ddd d");
    186208    unknownTitle = gContext->GetSetting("UnknownTitle", "Unknown");
    void GuideGrid::parseContainer(QDomEleme 
    552574        curInfoRect = area;
    553575    if (name.lower() == "current_video")
    554576        videoRect = area;
     577    if (name.lower() == "favorite_group")
     578        favRect = area;
    555579}
    556580
    557581QString GuideGrid::GetChanNum(void)
    void GuideGrid::fillChannelInfos(bool go 
    611635    m_channelInfos.clear();
    612636
    613637    DBChanList channels = ChannelUtil::GetChannels(0, true,
    614                                                    "channum, callsign");
     638                                                   "channum, callsign", m_favgrpid);
    615639    ChannelUtil::SortChannels(channels, channelOrdering, true);
    616640
    617     if (showFavorites)
    618     {
    619         DBChanList tmp;
    620         for (uint i = 0; i < channels.size(); i++)
    621         {
    622             if (channels[i].favorite)
    623                 tmp.push_back(channels[i]);
    624         }
    625 
    626         if (!tmp.empty())
    627             channels = tmp;
    628     }
    629 
    630641    bool startingset = false;
    631642    for (uint i = 0; i < channels.size(); i++)
    632643    {
    void GuideGrid::fillChannelInfos(bool go 
    634645        val.chanstr  = channels[i].channum;
    635646        val.chanid   = channels[i].chanid;
    636647        val.callsign = channels[i].callsign;
    637         val.favid    = channels[i].favorite;
     648//        val.favid    = channels[i].favorite;
    638649        val.channame = channels[i].name;
    639650        val.iconpath = channels[i].icon;
    640651        val.iconload = false;
    void GuideGrid::fillProgramInfos(void) 
    734745    }
    735746}
    736747
     748void GuideGrid::fillFavGroupInfo(void)
     749{
     750    LayerSet   *container = NULL;
     751    UITextType *type = NULL;
     752   
     753    container = theme->GetSet("favorite_group");
     754    if (container)
     755    {
     756        type = (UITextType *)container->GetType("favgroup");
     757        QString favgroup;
     758       
     759        favgroup = Favorites::GetFavoriteGroupName(m_favgrplist, m_favgrpid);
     760       
     761        if (type)
     762            type->SetText(favgroup);
     763    }
     764}
     765
    737766void GuideGrid::fillProgramRowInfos(unsigned int row)
    738767{
    739768    LayerSet *container = NULL;
    void GuideGrid::paintEvent(QPaintEvent * 
    10101039        paintPrograms(&p);
    10111040    if (r.intersects(curInfoRect))
    10121041        paintCurrentInfo(&p);
     1042    if (r.intersects(favRect))
     1043        paintFavGroupInfo(&p);
    10131044
    10141045    // if jumpToChannel has its own rect, use that; otherwise use the date's rect
    10151046    if ((jumpToChannelHasRect && r.intersects(jumpToChannelRect)) ||
    void GuideGrid::paintCurrentInfo(QPainte 
    11231154    p->drawPixmap(dr.topLeft(), pix);
    11241155}
    11251156
     1157void GuideGrid::paintFavGroupInfo(QPainter *p)
     1158{
     1159    QRect dr = favRect;
     1160    QPixmap pix(dr.size());
     1161    pix.fill(this, dr.topLeft());
     1162    QPainter tmp(&pix);
     1163
     1164    LayerSet *container = NULL;
     1165    container = theme->GetSet("favorite_group");
     1166    if (container)
     1167    {
     1168        container->Draw(&tmp, 1, m_context);
     1169        container->Draw(&tmp, 2, m_context);
     1170        container->Draw(&tmp, 3, m_context);
     1171        container->Draw(&tmp, 4, m_context);
     1172        container->Draw(&tmp, 5, m_context);
     1173        container->Draw(&tmp, 6, m_context);
     1174        container->Draw(&tmp, 7, m_context);
     1175        container->Draw(&tmp, 8, m_context);
     1176    }
     1177    tmp.end();
     1178    p->drawPixmap(dr.topLeft(), pix);
     1179}
     1180
    11261181void GuideGrid::paintChannels(QPainter *p)
    11271182{
    11281183    QRect cr = channelRect;
    void GuideGrid::paintChannels(QPainter * 
    11801235        }
    11811236
    11821237        QString tmpChannelFormat = channelFormat;
    1183         if (chinfo->favid > 0)
    1184         {
    1185             tmpChannelFormat.insert(tmpChannelFormat.find('<'), "* ");
    1186             tmpChannelFormat.insert(tmpChannelFormat.find('>') + 1, " *");
    1187         }
     1238//        if (chinfo->favid > 0)
     1239//        {
     1240//            tmpChannelFormat.insert(tmpChannelFormat.find('<'), "* ");
     1241//            tmpChannelFormat.insert(tmpChannelFormat.find('>') + 1, " *");
     1242//        }
    11881243
    11891244        if (type)
    11901245        {
    void GuideGrid::paintChannels(QPainter * 
    12141269        }
    12151270    }
    12161271
     1272    if (m_channelInfos.size() == 0)
     1273    {
     1274       // if the user has selected a favorite list with no channels
     1275       // Reset the text and icon. This will display one blank line
     1276       // to show that the favorite group has no channels
     1277       if (type)
     1278       {
     1279         type->SetText(0, "");
     1280         type->ResetImage(0);
     1281       }
     1282    }
     1283
    12171284    if (container)
    12181285    {
    12191286        container->Draw(&tmp, 1, m_context);
    void GuideGrid::paintInfo(QPainter *p) 
    13481415
    13491416void GuideGrid::toggleGuideListing()
    13501417{
    1351     showFavorites = (!showFavorites);
    1352     generateListings();
     1418    int oldfavgrpid = m_favgrpid;
     1419   
     1420    m_favgrpid = Favorites::GetNextFavoriteGroup(m_favgrplist, oldfavgrpid);
     1421   
     1422    if (oldfavgrpid != m_favgrpid)
     1423      generateListings();
     1424     
     1425    fillFavGroupInfo();
     1426    update(favRect);
    13531427}
    13541428
    13551429void GuideGrid::generateListings()
    void GuideGrid::generateListings() 
    13681442    update(fullRect);
    13691443}
    13701444
     1445int GuideGrid::SelectFavoriteGroup()
     1446{
     1447    if (m_favgrplist.empty())
     1448    {
     1449      MythPopupBox::showOkPopup(gContext->GetMainWindow(), "",
     1450                                "You don't have any favorite groups defined");
     1451
     1452      return -1;
     1453    }
     1454   
     1455    MythPopupBox box(gContext->GetMainWindow(), "SelectFavoriteGroup Popup");
     1456    box.addLabel("Select Favorite Group");
     1457
     1458    for (uint i = 0; i < m_favgrplist.size(); i++)
     1459      box.addButton(m_favgrplist[i].name);
     1460
     1461    box.addButton(tr("Cancel"))->setFocus();
     1462
     1463    int ret = box.ExecPopup();
     1464   
     1465    // If the user cancelled, return a special value
     1466    if (ret < 0)
     1467      return -1;
     1468    else
     1469      return m_favgrplist[ret].grpid;
     1470}
     1471
    13711472void GuideGrid::toggleChannelFavorite()
    13721473{
    1373     MSqlQuery query(MSqlQuery::InitCon());
     1474    int grpid;
     1475
     1476    if (m_favgrpid == -1)
     1477    {
     1478      grpid = SelectFavoriteGroup();
     1479     
     1480      if (grpid == -1)
     1481        return;
     1482    }
     1483    else
     1484      grpid = m_favgrpid;
    13741485
    13751486    // Get current channel id, and make sure it exists...
    13761487    int chanNum = m_currentRow + m_currentStartChannel;
    void GuideGrid::toggleChannelFavorite() 
    13811492    if (chanNum < 0)
    13821493        chanNum = 0;
    13831494
    1384     int favid = m_channelInfos[chanNum].favid;
    13851495    int chanid = m_channelInfos[chanNum].chanid;
    1386 
    1387     if (favid > 0)
    1388     {
    1389         query.prepare("DELETE FROM favorites WHERE favid = :FAVID ;");
    1390         query.bindValue(":FAVID", favid);
    1391         query.exec();
    1392     }
    1393     else
    1394     {
    1395         // We have no favorites record...Add one to toggle...
    1396         query.prepare("INSERT INTO favorites (chanid) VALUES (:FAVID);");
    1397         query.bindValue(":FAVID", chanid);
    1398         query.exec();
    1399     }
    1400 
    1401     if (showFavorites)
    1402         generateListings();
     1496   
     1497    if (m_favgrpid == -1)
     1498       // If currently viewing all channels, allow to add only not delete
     1499       Favorites::ToggleFavorite(chanid, grpid, false);
    14031500    else
    1404     {
    1405         int maxchannel = 0;
    1406         DISPLAY_CHANS = desiredDisplayChans;
    1407         fillChannelInfos(false);
    1408         maxchannel = max((int)m_channelInfos.size() - 1, 0);
    1409         DISPLAY_CHANS = min(DISPLAY_CHANS, maxchannel + 1);
    1410 
    1411         repaint(channelRect, false);
    1412     }
     1501       // Only allow delete if viewing the favorite group in question
     1502       Favorites::ToggleFavorite(chanid, grpid, true);
     1503     
     1504    // If viewing favorites, refresh because a channel was removed
     1505    if (m_favgrpid != -1)
     1506       generateListings();
    14131507}
    14141508
    14151509void GuideGrid::cursorLeft()
  • libs/libmythtv/guidegrid.h

    diff -Nur --exclude='*.lib' --exclude='*.o' mythtv/libs/libmythtv/guidegrid.h mythtv-guide/libs/libmythtv/guidegrid.h
    old new  
    1212#include "uitypes.h"
    1313#include "xmlparse.h"
    1414#include "libmythtv/programinfo.h"
     15#include "libmythtv/favoritegroup.h"
     16#include "libmythtv/favoritegroup.h"
    1517
    1618using namespace std;
    1719
     
    2931MPUBLIC
    3032bool RunProgramGuide(uint &startChanId, QString &startChanNum,
    3133                     bool thread = false, TV *player = NULL,
    32                      bool allowsecondaryepg = true);
     34                     bool allowsecondaryepg = true, int *favgrpid = NULL);
    3335
    3436
    3537class GuideGrid : public MythDialog
     
    3941    GuideGrid(MythMainWindow *parent,
    4042              uint chanid = 0, QString channum = "",
    4143              TV *player = NULL, bool allowsecondaryepg = true,
    42               const char *name = "GuideGrid");
     44              const char *name = "GuideGrid", int favgrpid = -1);
    4345   ~GuideGrid();
    4446
    4547    uint    GetChanID(void);
    4648    QString GetChanNum(void);
     49    int     GetFavGrp(void) {return m_favgrpid;}
    4750
    4851  protected slots:
    4952    void cursorLeft();
     
    104107    void paintPrograms(QPainter *);
    105108    void paintCurrentInfo(QPainter *);
    106109    void paintInfo(QPainter *);
     110    void paintFavGroupInfo(QPainter *p);
    107111 
    108112    void resizeImage(QPixmap *, QString);
    109113    void LoadWindow(QDomElement &);
     
    128132    QRect infoRect;
    129133    QRect curInfoRect;
    130134    QRect videoRect;
     135    QRect favRect;
    131136
    132137    void fillChannelInfos(bool gotostartchannel = true);
    133138
     
    135140
    136141    void fillProgramInfos(void);
    137142    void fillProgramRowInfos(unsigned int row);
     143   
     144    void fillFavGroupInfo(void);
    138145
    139146    void setStartChannel(int newStartChannel);
    140147
    141148    void createProgramLabel(int, int);
     149   
     150    int SelectFavoriteGroup();
    142151
    143152    vector<ChannelInfo> m_channelInfos;
    144153    TimeInfo *m_timeInfos[MAX_DISPLAY_TIMES];
     
    157166    int m_currentCol;
    158167
    159168    bool selectState;
    160     bool showFavorites;
    161169    QString channelFormat;
    162170
    163171    int desiredDisplayChans;
     
    180188    QTimer *videoRepaintTimer;
    181189
    182190    bool keyDown;
     191   
     192    int     m_favgrpid;
     193    FavoriteGroupList m_favgrplist;
    183194
    184195    void jumpToChannelResetAndHide();
    185196    void jumpToChannelCancel();
  • libs/libmythtv/libmythtv.pro

    diff -Nur --exclude='*.lib' --exclude='*.o' mythtv/libs/libmythtv/libmythtv.pro mythtv-guide/libs/libmythtv/libmythtv.pro
    old new  
    149149HEADERS += playgroup.h              progdetails.h
    150150HEADERS += channeleditor.h          channelsettings.h
    151151HEADERS += previewgenerator.h       transporteditor.h
     152HEADERS += favoritegroup.h
    152153
    153154SOURCES += programinfo.cpp          proglist.cpp
    154155SOURCES += storagegroup.cpp
     
    171172SOURCES += progdetails.cpp
    172173SOURCES += channeleditor.cpp        channelsettings.cpp
    173174SOURCES += previewgenerator.cpp     transporteditor.cpp
     175SOURCES += favoritegroup.cpp
    174176
    175177# DiSEqC
    176178HEADERS += diseqc.h                 diseqcsettings.h
  • libs/libmythtv/tv_play.cpp

    diff -Nur --exclude='*.lib' --exclude='*.o' mythtv/libs/libmythtv/tv_play.cpp mythtv-guide/libs/libmythtv/tv_play.cpp
    old new  
    8181    bool showDialogs = true;
    8282    bool playCompleted = false;
    8383    ProgramInfo *curProgram = NULL;
    84    
    8584
    8685    if (tvrec)
    8786        curProgram = new ProgramInfo(*tvrec);
     
    223222   
    224223    bool allowrerecord = tv->getAllowRerecord();
    225224    bool deleterecording = tv->getRequestDelete();
    226    
     225
     226    tv->SaveFavoriteGroup();
     227
    227228    delete tv;
    228229   
    229230    if (curProgram)
     
    268269            ">,.");
    269270    REG_KEY("TV Frontend", "TOGGLEFAV", "Toggle the current channel as a "
    270271            "favorite", "?");
    271     REG_KEY("TV Frontend", "NEXTFAV", "Toggle showing all channels or just "
    272             "favorites in the program guide.", "/");
     272    REG_KEY("TV Frontend", "NEXTFAV", "Cycle through favorite groups and all channels "
     273            "in the program guide.", "/,S");
    273274    REG_KEY("TV Frontend", "CHANUPDATE", "Switch channels without exiting "
    274275            "guide in Live TV mode.", "X");
    275276    REG_KEY("TV Frontend", "VOLUMEDOWN", "Volume down", "[,{,F10");
     
    608609    stickykeys           = gContext->GetNumSetting("StickyKeys");
    609610    ff_rew_repos         = gContext->GetNumSetting("FFRewReposTime", 100)/100.0;
    610611    ff_rew_reverse       = gContext->GetNumSetting("FFRewReverse", 1);
     612    favorite_group_id    = gContext->GetNumSetting("FavoritesDefaultGroup", -1);
     613    browse_favorites     = gContext->GetNumSetting("FavoritesChangeChannel", 0);
     614   
     615    if (browse_favorites && (favorite_group_id > -1))
     616    {
     617      m_channellist = ChannelUtil::GetChannels(0, true, "channum, callsign", favorite_group_id);
     618      ChannelUtil::SortChannels(m_channellist, "channum", true);
     619    }
     620   
     621    m_favgrplist  = Favorites::GetFavoriteGroups();
     622
    611623    int def[8] = { 3, 5, 10, 20, 30, 60, 120, 180 };
    612624    for (uint i = 0; i < sizeof(def)/sizeof(def[0]); i++)
    613625        ff_rew_speeds.push_back(
     
    770782    }
    771783}
    772784
     785void TV::SaveFavoriteGroup(void)
     786{
     787    int favgrpid          = gContext->GetNumSetting("FavoritesDefaultGroup", -1);
     788    int remember_last_fav = gContext->GetNumSetting("FavoritesRememberLast", 0);
     789
     790    if (remember_last_fav && (favgrpid != favorite_group_id))
     791       gContext->SaveSetting("FavoritesDefaultGroup", favorite_group_id);
     792}
     793
    773794TVState TV::GetState(void) const
    774795{
    775796    if (InStateChange())
     
    40974138
    40984139void TV::ToggleChannelFavorite(void)
    40994140{
    4100     activerecorder->ToggleChannelFavorite();
     4141//    activerecorder->ToggleChannelFavorite();
    41014142}
    41024143
    41034144void TV::ChangeChannel(int direction)
    41044145{
    41054146    bool muted = false;
    41064147
     4148    if ((browse_favorites || (direction == CHANNEL_DIRECTION_FAVORITE)) &&
     4149        (favorite_group_id > -1) && (direction != CHANNEL_DIRECTION_SAME))
     4150    {
     4151      uint    chanid;
     4152     
     4153      // Collect channel info
     4154      pbinfoLock.lock();
     4155      uint    old_chanid  = playbackinfo->chanid.toUInt();
     4156      pbinfoLock.unlock();
     4157
     4158      chanid = ChannelUtil::GetNextChannel(m_channellist, old_chanid, direction);
     4159
     4160      ChangeChannel(chanid, "");     
     4161      return;
     4162    } else if (direction == CHANNEL_DIRECTION_FAVORITE)
     4163       direction = CHANNEL_DIRECTION_UP;
     4164
    41074165    if (nvp)
    41084166    {
    41094167        AudioOutput *aud = nvp->getAudioOutput();
     
    51335191
    51345192    bool changeChannel = false;
    51355193    ProgramInfo *nextProgram = NULL;
     5194    int favgrpid = favorite_group_id;
    51365195
    51375196    if (StateIsLiveTV(GetState()))
    51385197    {
     
    51475206                    allowsecondary = nvp->getVideoOutput()->AllowPreviewEPG();
    51485207
    51495208                // Start up EPG
    5150                 changeChannel = RunProgramGuide(chanid, channum, true, this, allowsecondary);
     5209                changeChannel = RunProgramGuide(chanid, channum, true, this, allowsecondary,
     5210                                                &favgrpid);
    51515211                break;
    51525212            }
    51535213            case kPlaybackBox:
     
    51895249        {
    51905250            default:
    51915251            case kScheduleProgramGuide:
    5192                 RunProgramGuide(chanid, channum, true);
     5252                RunProgramGuide(chanid, channum, true, NULL, true, &favgrpid);
    51935253                break;
    51945254            case kScheduleProgramFinder:
    51955255                RunProgramFind(true, false);
     
    52395299            DoPause();
    52405300    }
    52415301
     5302    // if favorite group was changed in EPG update local info
     5303    if ((favgrpid != favorite_group_id) && (editType == kScheduleProgramGuide))
     5304    {
     5305      favorite_group_id = favgrpid;
     5306     
     5307      if (browse_favorites)
     5308      {
     5309          VERBOSE(VB_IMPORTANT, LOC +
     5310             QString("Reloading favorite channel list for %1").arg(favorite_group_id));
     5311     
     5312          m_channellist = ChannelUtil::GetChannels(0, true, "channum, callsign", favorite_group_id);
     5313          ChannelUtil::SortChannels(m_channellist, "channum", true);
     5314      }
     5315    }
     5316
    52425317    // Resize the window back to the MythTV Player size
    52435318    if (!using_gui_size_for_tv)
    52445319    {
     
    58635938{
    58645939    if (!browsemode)
    58655940        BrowseStart();
     5941VERBOSE(VB_IMPORTANT,"In BrowseDispInfo");
     5942    // if browsing favorites is enabled or direction if BROWSE_FAVORITES
     5943    // Then pick the next channel in the channel favorite list to browse
     5944    // If favorite group is ALL CHANNELS (-1), then bypass picking from
     5945    // the channel favorite list
     5946    if ((browse_favorites || (direction == BROWSE_FAVORITE)) &&
     5947        (favorite_group_id > -1) && (direction != BROWSE_SAME) &&
     5948        (direction != BROWSE_RIGHT) && (direction != BROWSE_LEFT))
     5949    {
     5950      uint chanid;
     5951      int  dir;
     5952     
     5953      if ( (direction == BROWSE_UP) || (direction == BROWSE_FAVORITE) )
     5954        dir = CHANNEL_DIRECTION_UP;
     5955      else if (direction == BROWSE_DOWN)
     5956        dir = CHANNEL_DIRECTION_DOWN;
     5957      else // this should never happen, but just in case
     5958        dir = direction;
     5959       
     5960      chanid = ChannelUtil::GetNextChannel(m_channellist, browsechanid.toUInt(), dir);
     5961      VERBOSE(VB_IMPORTANT, QString("Get channel: %1").arg(chanid));
     5962      browsechanid  = QString("%1").arg(chanid);
     5963      browsechannum = QString::null;
     5964      direction     = BROWSE_SAME;
     5965    }
     5966    else if ((favorite_group_id == -1) && (direction == BROWSE_FAVORITE))
     5967      direction = BROWSE_UP;
    58665968
    58675969    InfoMap infoMap;
    58685970    QDateTime curtime  = QDateTime::currentDateTime();
     
    66076709    }
    66086710    else if (action == "GUIDE")
    66096711        EditSchedule(kScheduleProgramGuide);
     6712    else if (action.left(10) == "FAVORITES_")
     6713        processFavoritesEntry(action);
    66106714    else if (action == "FINDER")
    66116715        EditSchedule(kScheduleProgramFinder);
    66126716    else if (action == "SCHEDULE")
     
    67016805    }
    67026806}
    67036807
     6808void TV::processFavoritesEntry(QString action)
     6809{
     6810    if (action == "FAVORITES_ALL_CHANNELS")
     6811      favorite_group_id = -1;
     6812    else
     6813    {
     6814      action.remove("FAVORITES_");
     6815      favorite_group_id = action.toInt();
     6816         
     6817      if (browse_favorites)
     6818      {
     6819         m_channellist = ChannelUtil::GetChannels(0, true, "channum, callsign", favorite_group_id);
     6820         ChannelUtil::SortChannels(m_channellist, "channum", true);
     6821      }
     6822    }
     6823}
     6824
    67046825void TV::ShowOSDTreeMenu(void)
    67056826{
    67066827    BuildOSDTreeMenu();
     
    67366857            freeRecorders = RemoteGetFreeRecorderCount();
    67376858
    67386859        item = new OSDGenericTree(treeMenu, tr("Program Guide"), "GUIDE");
     6860        item = new OSDGenericTree(treeMenu, tr("Favorites"), "FAVORITES");
     6861        subitem = new OSDGenericTree(item, tr("All Channels"),
     6862                                     "FAVORITES_ALL_CHANNELS",
     6863                                     (favorite_group_id == -1) ? 1 : 0,
     6864                                     NULL, "FAVORITEGROUP");
     6865       
     6866        FavoriteGroupList::iterator it;
     6867       
     6868        for (it = m_favgrplist.begin(); it != m_favgrplist.end(); ++it)
     6869        {
     6870           QString name = QString("FAVORITES_%1").arg(it->grpid);
     6871           subitem = new OSDGenericTree(item, it->name, name,
     6872                                       ((int)(it->grpid) == favorite_group_id) ? 1 : 0,
     6873                                        NULL, "FAVORITEGROUP");
     6874        }   
     6875
    67396876        if (!gContext->GetNumSetting("JumpToProgramOSD", 1))
    67406877        {
    67416878            item = new OSDGenericTree(treeMenu, tr("Jump to Program"));
  • libs/libmythtv/tv_play.h

    diff -Nur --exclude='*.lib' --exclude='*.o' mythtv/libs/libmythtv/tv_play.h mythtv-guide/libs/libmythtv/tv_play.h
    old new  
    1616#include "util.h"
    1717#include "programinfo.h"
    1818#include "videoouttypes.h"
     19#include "channelutil.h"
     20#include "favoritegroup.h"
    1921
    2022#include <qobject.h>
    2123
     
    191193    // Used by EPG
    192194    void ChangeVolume(bool up);
    193195    void ToggleMute(void);
     196   
     197    // Favorites
     198    void SaveFavoriteGroup(void);
    194199
    195200  public slots:
    196201    void HandleOSDClosed(int osdType);
     
    358363
    359364    void BuildOSDTreeMenu(void);
    360365    void ShowOSDTreeMenu(void);
     366   
     367    void processFavoritesEntry(QString action);
    361368
    362369    void UpdateLCD(void);
    363370    void ShowLCDChannelInfo(void);
     
    626633    // Network Control stuff
    627634    QValueList<QString> networkControlCommands;
    628635    QMutex ncLock;
     636   
     637    int favorite_group_id;
     638    uint browse_favorites;
     639    FavoriteGroupList m_favgrplist;
     640    DBChanList m_channellist;
    629641};
    630642
    631643#endif
  • programs/mythfrontend/globalsettings.cpp

    diff -Nur --exclude='*.lib' --exclude='*.o' mythtv/programs/mythfrontend/globalsettings.cpp mythtv-guide/programs/mythfrontend/globalsettings.cpp
    old new  
    28052805    return gc;
    28062806}
    28072807
    2808 static HostCheckBox *EPGShowFavorites()
    2809 {
    2810     HostCheckBox *gc = new HostCheckBox("EPGShowFavorites");
    2811     gc->setLabel(QObject::tr("Only display 'favorite' channels"));
    2812     gc->setHelpText(QObject::tr("If enabled, the EPG will initially display "
    2813                     "only the channels marked as favorites. Pressing "
    2814                     "\"4\" will toggle between displaying favorites and all "
    2815                     "channels."));
    2816     gc->setValue(false);
    2817     return gc;
    2818 }
    28192808
    28202809static HostSpinBox *EPGChanDisplay()
    28212810{
     
    28432832    return gc;
    28442833}
    28452834
     2835static HostCheckBox *FavoritesRememberLast()
     2836{
     2837    HostCheckBox *gc = new HostCheckBox("FavoritesRememberLast");
     2838    gc->setLabel(QObject::tr("Remember channel favorite group"));
     2839    gc->setHelpText(QObject::tr("If enabled, the EPG will initially display "
     2840                    "only the channels from the last favorite group selected. Pressing "
     2841                    "\"4\" will toggle favorites group."));
     2842    gc->setValue(false);
     2843    return gc;
     2844}
     2845
     2846static HostComboBox *FavoritesDefaultGroup()
     2847{
     2848    HostComboBox *gc = new HostComboBox("FavoritesDefaultGroup");
     2849    gc->setLabel(QObject::tr("Default channel favorite group"));
     2850
     2851    FavoriteGroupList favgrplist;
     2852
     2853    favgrplist = Favorites::GetFavoriteGroups();
     2854
     2855    gc->addSelection(QObject::tr("All Channels"), "-1");
     2856
     2857    FavoriteGroupList::iterator it;
     2858
     2859    for (it = favgrplist.begin(); it < favgrplist.end(); ++it)
     2860       gc->addSelection(it->name, QString("%1").arg(it->grpid));
     2861
     2862    gc->setHelpText(QObject::tr("The EPG will initially display "
     2863                    "only the channels from the last favorite group selected. Pressing "
     2864                    "\"4\" will toggle favorites group."));
     2865    gc->setValue(false);
     2866    return gc;
     2867}
     2868
     2869static HostCheckBox *FavoritesChangeChannel()
     2870{
     2871    HostCheckBox *gc = new HostCheckBox("FavoritesChangeChannel");
     2872    gc->setLabel(QObject::tr("Browse/Change channels with Favorites"));
     2873    gc->setHelpText(QObject::tr("If enabled, LiveTV will browse or change channels "
     2874                    "from the selected favorite group. \"All Channels\" "
     2875                    "favorite group may be selected to browse all channels."));
     2876    gc->setValue(false);
     2877    return gc;
     2878}
     2879
     2880// Favorite Settings
     2881class FavoriteSettings : public TriggeredConfigurationGroup
     2882{
     2883  public:
     2884    FavoriteSettings() : TriggeredConfigurationGroup(false, true, false, false)
     2885    {
     2886         setLabel(QObject::tr("Remember last channel favorite group"));
     2887         setUseLabel(false);
     2888
     2889         Setting* RememberFavoriteEnabled = FavoritesRememberLast();
     2890         addChild(RememberFavoriteEnabled);
     2891         setTrigger(RememberFavoriteEnabled);
     2892
     2893         ConfigurationGroup* settings = new VerticalConfigurationGroup(false);
     2894         settings->addChild(FavoritesDefaultGroup());
     2895         addTarget("0", settings);
     2896
     2897         // show nothing if RememberFavoriteEnabled is on
     2898         addTarget("1", new VerticalConfigurationGroup(true));
     2899     };
     2900};
     2901
    28462902// General RecPriorities settings
    28472903
    28482904static GlobalCheckBox *GRSchedMoveHigher()
     
    45244580    general2->addChild(HDRingbufferSize());
    45254581    addChild(general2);
    45264582
     4583    VerticalConfigurationGroup* fav = new VerticalConfigurationGroup(false);
     4584    fav->setLabel(QObject::tr("General (Favorites)"));
     4585    FavoriteSettings *favoritesettings = new FavoriteSettings();
     4586    fav->addChild(favoritesettings);
     4587    fav->addChild(FavoritesChangeChannel());
     4588    addChild(fav);
    45274589}
    45284590
    45294591EPGSettings::EPGSettings()
    45304592{
    45314593    VerticalConfigurationGroup* epg = new VerticalConfigurationGroup(false);
    4532     epg->setLabel(QObject::tr("Program Guide") + " 1/2");
     4594    epg->setLabel(QObject::tr("Program Guide") + " 1/3");
    45334595    epg->addChild(EPGFillType());
    45344596    epg->addChild(EPGShowCategoryColors());
    45354597    epg->addChild(EPGShowCategoryText());
    45364598    epg->addChild(EPGScrollType());
    45374599    epg->addChild(EPGShowChannelIcon());
    4538     epg->addChild(EPGShowFavorites());
    45394600    epg->addChild(WatchTVGuide());
    45404601    epg->addChild(EPGChanDisplay());
    45414602    epg->addChild(EPGTimeDisplay());
    45424603    addChild(epg);
    45434604
    45444605    VerticalConfigurationGroup* gen = new VerticalConfigurationGroup(false);
    4545     gen->setLabel(QObject::tr("Program Guide") + " 2/2");
     4606    gen->setLabel(QObject::tr("Program Guide") + " 2/3");
    45464607    gen->addChild(UnknownTitle());
    45474608    gen->addChild(UnknownCategory());
    45484609    gen->addChild(DefaultTVChannel());
    45494610    gen->addChild(SelectChangesChannel());
    45504611    gen->addChild(EPGRecThreshold());
    45514612    gen->addChild(EPGEnableJumpToChannel());
    4552     addChild(gen);
     4613    addChild(gen);   
    45534614}
    45544615
    45554616GeneralRecPrioritiesSettings::GeneralRecPrioritiesSettings()
  • programs/mythfrontend/main.cpp

    diff -Nur --exclude='*.lib' --exclude='*.o' mythtv/programs/mythfrontend/main.cpp mythtv-guide/programs/mythfrontend/main.cpp
    old new  
    4747#include "statusbox.h"
    4848#include "lcddevice.h"
    4949#include "langsettings.h"
     50#include "favoritegroup.h"
    5051
    5152#include "libmythui/myththemedmenu.h"
    5253#include "libmythui/myththemebase.h"
     
    398399    {
    399400        EPGSettings settings;
    400401        settings.exec();
     402    }
     403    else if (sel == "settings favorites")
     404    {
     405        FavoriteGroupEditor editor;
     406        editor.exec();
    401407    }
    402408    else if (sel == "settings generalrecpriorities")
    403409    {
  • programs/mythfrontend/tv_settings.xml

    diff -Nur --exclude='*.lib' --exclude='*.o' mythtv/programs/mythfrontend/tv_settings.xml mythtv-guide/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_FAVORITE</type>
     86      <text>Channel Favorite Groups</text>
     87      <action>SETTINGS FAVORITES</action>
     88   </button>
    8389
    8490   <button>
    8591      <type>TV_SETTINGS_PLAYBACK_GROUPS</type>
  • themes/classic/tv_settings.xml

    diff -Nur --exclude='*.o' --exclude='moc_*' --exclude='Makefil*' mythtv-orig/themes/classic/tv_settings.xml mythtv/themes/classic/tv_settings.xml
    old new  
    6666   </button>
    6767
    6868   <button>
     69      <type>TV_SETTINGS_FAVORITE</type>
     70      <text>Channel Favorite Groups</text>
     71      <action>SETTINGS FAVORITES</action>
     72   </button>
     73
     74   <button>
    6975      <type>TV_SETTINGS_PLAYBACK_GROUPS</type>
    7076      <text>Playback Groups</text>
    7177      <text lang="SV">Uppspelningsgrupper</text>
  • themes/DVR/tv_settings.xml

    diff -Nur --exclude='*.o' --exclude='moc_*' --exclude='Makefil*' mythtv-orig/themes/DVR/tv_settings.xml mythtv/themes/DVR/tv_settings.xml
    old new  
    7474   </button>
    7575
    7676   <button>
     77      <type>TV_SETTINGS_FAVORITE</type>
     78      <text>Channel Favorite Groups</text>
     79      <action>SETTINGS FAVORITES</action>
     80   </button>
     81
     82   <button>
    7783      <type>TV_SETTINGS_PLAYBACK_GROUPS</type>
    7884      <text>Playback Groups</text>
    7985      <text lang="SV">Uppspelningsgrupper</text>