Ticket #199: 00-199-channelgroups.7.patch
File 00-199-channelgroups.7.patch, 56.9 KB (added by , 15 years ago) |
---|
-
mythtv/themes/classic/tv_settings.xml
71 71 </button> 72 72 73 73 <button> 74 <type>TV_SETTINGS_CHANNEL_GROUP</type> 75 <text>Channel Groups</text> 76 <action>SETTINGS CHANNELGROUPS</action> 77 </button> 78 79 <button> 74 80 <type>TV_SETTINGS_PLAYBACK_GROUPS</type> 75 81 <text>Playback Groups</text> 76 82 <text lang="IT">Gruppi di Riproduzione</text> -
mythtv/themes/DVR/tv_settings.xml
74 74 </button> 75 75 76 76 <button> 77 <type>TV_SETTINGS_CHANNEL_GROUP</type> 78 <text>Channel Groups</text> 79 <action>SETTINGS CHANNELGROUPS</action> 80 </button> 81 82 <button> 77 83 <type>TV_SETTINGS_PLAYBACK_GROUPS</type> 78 84 <text>Playback Groups</text> 79 85 <text lang="SV">Uppspelningsgrupper</text> -
mythtv/themes/defaultmenu/tv_settings.xml
97 97 <action>OSDMENUEDITOR</action> 98 98 </button> 99 99 <button> 100 <type>TV_SETTINGS_CHANNEL_GROUP</type> 101 <text>Channel Groups</text> 102 <action>SETTINGS CHANNELGROUPS</action> 103 </button> 104 105 <button> 100 106 <type>TV_SETTINGS_PLAYBACK_GROUPS</type> 101 107 <text>Playback Groups</text> 102 108 <text lang="IT">Gruppi di Riproduzione</text> -
mythtv/libs/libmythtv/dbchannelinfo.cpp
16 16 DBChannel::DBChannel( 17 17 const QString &_channum, const QString &_callsign, 18 18 uint _chanid, uint _major_chan, uint _minor_chan, 19 uint _ favorite, uint _mplexid, bool _visible,19 uint _mplexid, bool _visible, 20 20 const QString &_name, const QString &_icon) : 21 21 channum(_channum), 22 22 callsign(_callsign), chanid(_chanid), 23 23 major_chan(_major_chan), minor_chan(_minor_chan), 24 favorite(_favorite),mplexid(_mplexid), visible(_visible),24 mplexid(_mplexid), visible(_visible), 25 25 name(_name), icon(_icon) 26 26 { 27 27 channum.detach(); … … 39 39 chanid = other.chanid; 40 40 major_chan = other.major_chan; 41 41 minor_chan = other.minor_chan; 42 favorite = other.favorite;43 42 mplexid = (other.mplexid == 32767) ? 0 : other.mplexid; 44 43 visible = other.visible; 45 44 name = other.name; name.detach(); -
mythtv/libs/libmythtv/channelgroup.h
1 #ifndef CHANNELGROUP_H 2 #define CHANNELGROUP_H 3 4 class 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 }; 21 typedef vector<ChannelGroupItem> ChannelGroupList; 22 23 /** \class ChannelGroup 24 */ 25 class 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
168 168 static QString GetVideoFilters(uint sourceid, const QString &channum) 169 169 { return GetChannelValueStr("videofilters", sourceid, channum); } 170 170 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); 172 172 static void SortChannels(DBChanList &list, const QString &order, 173 173 bool eliminate_duplicates = false); 174 174 static void EliminateDuplicateChanNum(DBChanList &list); -
mythtv/libs/libmythtv/dbchannelinfo.h
21 21 DBChannel(const DBChannel&); 22 22 DBChannel(const QString &_channum, const QString &_callsign, 23 23 uint _chanid, uint _major_chan, uint _minor_chan, 24 uint _ favorite, uint _mplexid, bool _visible,24 uint _mplexid, bool _visible, 25 25 const QString &_name, const QString &_icon); 26 26 DBChannel& operator=(const DBChannel&); 27 27 … … 34 34 uint chanid; 35 35 uint major_chan; 36 36 uint minor_chan; 37 uint favorite;38 37 uint mplexid; 39 38 bool visible; 40 39 QString name; -
mythtv/libs/libmythtv/libmythtv.pro
161 161 HEADERS += viewschdiff.h livetvchain.h 162 162 HEADERS += playgroup.h progdetails.h 163 163 HEADERS += channelsettings.h previewgenerator.h 164 HEADERS += transporteditor.h 164 HEADERS += transporteditor.h 165 165 HEADERS += myth_imgconvert.h 166 HEADERS += channelgroup.h channelgroupsettings.h 166 167 167 168 # Remove when everything is switched to MythUI 168 169 HEADERS += proglist_qt.h … … 186 187 SOURCES += progdetails.cpp 187 188 SOURCES += channelsettings.cpp previewgenerator.cpp 188 189 SOURCES += transporteditor.cpp 190 SOURCES += channelgroup.cpp channelgroupsettings.cpp 189 191 190 192 contains( CONFIG_SWSCALE, yes ) { 191 193 SOURCES += myth_imgconvert.cpp -
mythtv/libs/libmythtv/guidegrid.h
18 18 #include "programinfo.h" 19 19 #include "programlist.h" 20 20 #include "channelutil.h" 21 #include "channelgroup.h" 21 22 22 23 using namespace std; 23 24 … … 84 85 const QString &startChanNum, 85 86 bool thread = false, 86 87 TV *player = NULL, 87 bool allowsecondaryepg = true); 88 bool allowsecondaryepg = true, 89 int *changrpid = NULL); 88 90 89 91 DBChanList GetSelection(void) const; 90 92 … … 134 136 GuideGrid(MythMainWindow *parent, 135 137 uint chanid = 0, QString channum = "", 136 138 TV *player = NULL, bool allowsecondaryepg = true, 137 const char *name = "GuideGrid"); 139 const char *name = "GuideGrid", 140 int changrpid=-1); 138 141 ~GuideGrid(); 139 142 143 int GetChanGrp(void) {return m_changrpid;} 140 144 void paintEvent(QPaintEvent *); 141 145 142 146 private slots: … … 155 159 void paintPrograms(QPainter *); 156 160 void paintCurrentInfo(QPainter *); 157 161 void paintInfo(QPainter *); 162 void paintChanGroupInfo(QPainter *p); 158 163 void paintVideo(QPainter *); 159 164 160 165 void resizeImage(QPixmap *, QString); … … 180 185 QRect infoRect; 181 186 QRect curInfoRect; 182 187 QRect videoRect; 188 QRect changrpRect; 183 189 184 190 void fillChannelInfos(bool gotostartchannel = true); 185 191 int FindChannel(uint chanid, const QString &channum, … … 189 195 190 196 void fillProgramInfos(void); 191 197 void fillProgramRowInfos(unsigned int row); 198 199 void fillChanGroupInfo(void); 192 200 193 201 void setStartChannel(int newStartChannel); 194 202 195 203 void createProgramLabel(int, int); 204 205 int SelectChannelGroup(); 196 206 197 207 PixmapChannel *GetChannelInfo(uint chan_idx, int sel = -1); 198 208 const PixmapChannel *GetChannelInfo(uint chan_idx, int sel = -1) const; … … 222 232 int m_currentCol; 223 233 224 234 bool selectState; 225 bool showFavorites;226 235 bool sortReverse; 227 236 QString channelFormat; 228 237 … … 247 256 QTimer *timeCheck; 248 257 249 258 bool keyDown; 259 260 int m_changrpid; 261 ChannelGroupList m_changrplist; 250 262 251 263 QMutex jumpToChannelLock; 252 264 JumpToChannel *jumpToChannel; -
mythtv/libs/libmythtv/tv_play.h
25 25 #include "videoouttypes.h" 26 26 #include "volumebase.h" 27 27 #include "inputinfo.h" 28 #include "channelgroup.h" 28 29 29 30 #include <qobject.h> 30 31 … … 266 267 void ToggleMute(PlayerContext*); 267 268 268 269 void SetNextProgPIPState(PIPState state) { jumpToProgramPIPState = state; } 270 271 // Channel Groups 272 void SaveChannelGroup(void); 269 273 270 274 // Used for UDPNotify 271 275 bool HasUDPNotifyEvent(void) const; … … 519 523 void FillMenuTimeStretch( const PlayerContext*, OSDGenericTree*) const; 520 524 void FillMenuSleepMode( const PlayerContext*, OSDGenericTree*) const; 521 525 bool FillMenuTracks( const PlayerContext*, OSDGenericTree*, uint type) const; 526 void FillMenuChanGroups( const PlayerContext*, OSDGenericTree*) const; 522 527 528 void processChanGroupEntry(QString action); 529 523 530 void UpdateLCD(void); 524 531 bool HandleLCDTimerEvent(void); 525 532 void ShowLCDChannelInfo(const PlayerContext*); … … 747 754 QMap<int,int> recorderPlaybackInfoTimerId; 748 755 QMap<int,ProgramInfo> recorderPlaybackInfo; 749 756 757 // Channel favorite group stuff 758 int channel_group_id; 759 uint browse_changrp; 760 ChannelGroupList m_changrplist; 761 DBChanList m_channellist; 762 750 763 // Network Control stuff 751 764 MythDeque<QString> networkControlCommands; 752 765 -
mythtv/libs/libmythtv/guidegrid.cpp
34 34 #include "util.h" 35 35 #include "remoteutil.h" 36 36 #include "channelutil.h" 37 #include "guidegrid.h" 37 38 #include "cardutil.h" 38 39 39 40 QWaitCondition epgIsVisibleCond; … … 171 172 const QString &channum, 172 173 bool thread, 173 174 TV *player, 174 bool allowsecondaryepg) 175 bool allowsecondaryepg, 176 int *changrpid) 175 177 { 176 178 DBChanList channel_changed; 179 int channel_group = -1; 177 180 181 if (changrpid != NULL) 182 channel_group = *changrpid; 183 178 184 //if (thread) 179 185 // qApp->lock(); 180 186 … … 182 188 183 189 GuideGrid *gg = new GuideGrid(gContext->GetMainWindow(), 184 190 chanid, channum, 185 player, allowsecondaryepg, "guidegrid"); 191 player, allowsecondaryepg, "guidegrid", 192 channel_group); 186 193 187 194 gg->Show(); 188 195 … … 210 217 //if (thread) 211 218 // qApp->lock(); 212 219 220 if (changrpid != NULL) 221 *changrpid = gg->GetChanGrp(); 222 213 223 delete gg; 214 224 215 225 gContext->removeCurrentLocation(); … … 223 233 GuideGrid::GuideGrid(MythMainWindow *parent, 224 234 uint chanid, QString channum, 225 235 TV *player, bool allowsecondaryepg, 226 const char *name ) :236 const char *name, int changrpid) : 227 237 MythDialog(parent, name), 228 238 m_player(player), 229 239 using_null_video(false), … … 240 250 DISPLAY_TIMES = 30; 241 251 int maxchannel = 0; 242 252 m_currentStartChannel = 0; 253 m_changrpid = changrpid; 254 m_changrplist = ChannelGroup::GetChannelGroups(); 243 255 244 256 m_context = 0; 245 257 … … 252 264 infoRect = QRect(0, 0, 0, 0); 253 265 curInfoRect = QRect(0, 0, 0, 0); 254 266 videoRect = QRect(0, 0, 0, 0); 267 changrpRect = QRect(0, 0, 0, 0); 255 268 256 269 jumpToChannelEnabled = 257 270 gContext->GetNumSetting("EPGEnableJumpToChannel", 1); … … 274 287 EmbedTVWindow(); 275 288 } 276 289 277 showFavorites = gContext->GetNumSetting("EPGShowFavorites", 0);278 290 gridfilltype = gContext->GetNumSetting("EPGFillType", UIGuideType::Alpha); 279 291 if (gridfilltype < (int)UIGuideType::Alpha) 280 292 { // update old settings to new fill types … … 331 343 container->SetDrawFontShadow(false); 332 344 } 333 345 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 334 358 channelOrdering = gContext->GetSetting("ChannelOrdering", "channum"); 335 359 dateformat = gContext->GetSetting("ShortDateFormat", "ddd d"); 336 360 unknownTitle = gContext->GetSetting("UnknownTitle", "Unknown"); … … 703 727 curInfoRect = area; 704 728 if (name.toLower() == "current_video") 705 729 videoRect = area; 730 if (name.toLower() == "channel_group") 731 changrpRect = area; 706 732 } 707 733 708 734 PixmapChannel *GuideGrid::GetChannelInfo(uint chan_idx, int sel) … … 891 917 m_channelInfoIdx.clear(); 892 918 m_currentStartChannel = 0; 893 919 894 DBChanList channels = ChannelUtil::GetChannels(0, true );920 DBChanList channels = ChannelUtil::GetChannels(0, true, "", m_changrpid); 895 921 ChannelUtil::SortChannels(channels, channelOrdering, false); 896 922 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 910 923 typedef vector<uint> uint_list_t; 911 924 QMap<QString,uint_list_t> channum_to_index_map; 912 925 QMap<QString,uint_list_t> callsign_to_index_map; … … 1124 1137 } 1125 1138 } 1126 1139 1140 void 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 1127 1158 void GuideGrid::fillProgramRowInfos(unsigned int row) 1128 1159 { 1129 1160 LayerSet *container = NULL; … … 1401 1432 paintPrograms(&p); 1402 1433 if (r.intersects(curInfoRect)) 1403 1434 paintCurrentInfo(&p); 1435 if (r.intersects(changrpRect)) 1436 paintChanGroupInfo(&p); 1404 1437 1405 1438 // if jumpToChannel has its own rect, use that; 1406 1439 // otherwise use the date's rect … … 1538 1571 p->drawPixmap(dr.topLeft(), pix); 1539 1572 } 1540 1573 1574 void 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 1541 1598 bool GuideGrid::paintChannels(QPainter *p) 1542 1599 { 1543 1600 QRect cr = channelRect; … … 1633 1690 } 1634 1691 1635 1692 QString tmpChannelFormat = channelFormat; 1636 if (chinfo->favorite > 0)1637 {1638 tmpChannelFormat.insert(1639 tmpChannelFormat.indexOf('<'), "<MARK:fav>");1640 }1641 1693 1642 1694 if (unavailable) 1643 1695 { … … 1673 1725 } 1674 1726 } 1675 1727 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 1676 1740 if (container) 1677 1741 { 1678 1742 container->Draw(&tmp, 1, m_context); … … 1808 1872 1809 1873 void GuideGrid::toggleGuideListing() 1810 1874 { 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); 1813 1884 } 1814 1885 1815 1886 void GuideGrid::generateListings() … … 1828 1899 update(fullRect); 1829 1900 } 1830 1901 1902 int 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 1831 1931 void GuideGrid::toggleChannelFavorite() 1832 1932 { 1833 MSqlQuery query(MSqlQuery::InitCon());1933 int grpid; 1834 1934 1935 if (m_changrpid == -1) 1936 { 1937 grpid = SelectChannelGroup(); 1938 1939 if (grpid == -1) 1940 return; 1941 } 1942 else 1943 grpid = m_changrpid; 1944 1835 1945 // Get current channel id, and make sure it exists... 1836 1946 int chanNum = m_currentRow + m_currentStartChannel; 1837 1947 if (chanNum >= (int)m_channelInfos.size()) … … 1842 1952 chanNum = 0; 1843 1953 1844 1954 PixmapChannel *ch = GetChannelInfo(chanNum); 1845 uint favid = ch->favorite;1846 1955 uint chanid = ch->chanid; 1847 1956 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) 1863 1966 generateListings(); 1864 else1865 {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 }1874 1967 } 1875 1968 1876 1969 void GuideGrid::cursorLeft() -
mythtv/libs/libmythtv/channelgroupsettings.h
1 #ifndef CHANNELGROUPSETTINGS_H 2 #define CHANNELGROUPSETTINGS_H 3 4 #include "libmyth/settings.h" 5 6 class 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 16 class 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 16 ChannelGroupItem& ChannelGroupItem::operator=(const ChannelGroupItem &other) 17 { 18 grpid = other.grpid; 19 name = (other.name); 20 21 return *this; 22 } 23 24 ChannelGroupItem::ChannelGroupItem(const ChannelGroupItem &other) 25 { 26 (*this) = other; 27 } 28 29 inline bool lt_group(const ChannelGroupItem &a, const ChannelGroupItem &b) 30 { 31 return QString::localeAwareCompare(a.name, b.name) < 0; 32 } 33 34 bool 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 76 ChannelGroupList 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. 106 int 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 131 QString 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
1570 1570 return true; 1571 1571 } 1572 1572 1573 DBChanList ChannelUtil::GetChannels(uint sourceid, bool vis_only, QString grp )1573 DBChanList ChannelUtil::GetChannels(uint sourceid, bool vis_only, QString grp, int changrpid) 1574 1574 { 1575 1575 DBChanList list; 1576 QMap<uint,uint> favorites;1576 1577 1577 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 else1584 {1585 while (query.next())1586 favorites[query.value(0).toUInt()] = query.value(1).toUInt();1587 }1588 1578 1589 1579 QString qstr = 1590 "SELECT channum, callsign, chan id, "1580 "SELECT channum, callsign, channel.chanid, " 1591 1581 " atsc_major_chan, atsc_minor_chan, " 1592 1582 " name, icon, mplexid, visible " 1593 1583 "FROM channel "; 1594 1584 1585 // Select only channels from the specified channel group 1586 if (changrpid > -1) 1587 qstr += QString(",channelgroup "); 1588 1595 1589 if (sourceid) 1596 1590 qstr += QString("WHERE sourceid='%1' ").arg(sourceid); 1597 1591 else … … 1599 1593 "WHERE cardinput.sourceid = channel.sourceid AND " 1600 1594 " cardinput.cardid = capturecard.cardid "; 1601 1595 1596 if (changrpid > -1) 1597 { 1598 qstr += QString("AND channel.chanid = channelgroup.chanid " 1599 "AND channelgroup.grpid ='%1' ").arg(changrpid); 1600 } 1601 1602 1602 if (vis_only) 1603 1603 qstr += "AND visible=1 "; 1604 1604 … … 1623 1623 query.value(2).toUInt(), /* chanid */ 1624 1624 query.value(3).toUInt(), /* ATSC major */ 1625 1625 query.value(4).toUInt(), /* ATSC minor */ 1626 favorites[query.value(2).toUInt()], /* favid */1627 1626 query.value(7).toUInt(), /* mplexid */ 1628 1627 query.value(8).toBool(), /* visible */ 1629 1628 query.value(5).toString(), /* name */ … … 1806 1805 (mplexid_restriction && 1807 1806 (mplexid_restriction != it->mplexid)))); 1808 1807 } 1809 else if ( CHANNEL_DIRECTION_UP == direction)1808 else if ((CHANNEL_DIRECTION_UP == direction) || (CHANNEL_DIRECTION_FAVORITE == direction)) 1810 1809 { 1811 1810 do 1812 1811 { … … 1819 1818 (mplexid_restriction && 1820 1819 (mplexid_restriction != it->mplexid)))); 1821 1820 } 1822 else if (CHANNEL_DIRECTION_FAVORITE == direction)1823 {1824 do1825 {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 }1836 1821 1837 1822 return it->chanid; 1838 1823 } -
mythtv/libs/libmythtv/tv_play.cpp
347 347 348 348 bool allowrerecord = tv->getAllowRerecord(); 349 349 bool deleterecording = tv->getRequestDelete(); 350 351 tv->SaveChannelGroup(); 350 352 351 353 delete tv; 352 354 … … 422 424 "in the program guide", "0"); 423 425 REG_KEY("TV Frontend", "GUIDE", "Show the Program Guide", "S"); 424 426 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"); 427 429 REG_KEY("TV Frontend", "CHANUPDATE", "Switch channels without exiting " 428 430 "guide in Live TV mode.", "X"); 429 431 REG_KEY("TV Frontend", "VOLUMEDOWN", "Volume down", "[,{,F10,Volume Down"); … … 787 789 osd_general_timeout = gContext->GetNumSetting("OSDGeneralTimeout", 2); 788 790 osd_prog_info_timeout= gContext->GetNumSetting("OSDProgramInfoTimeout", 3); 789 791 tryUnflaggedSkip = gContext->GetNumSetting("TryUnflaggedSkip", 0); 792 channel_group_id = gContext->GetNumSetting("ChannelGroupDefault", -1); 793 browse_changrp = gContext->GetNumSetting("BrowseChannelGroup", 0); 790 794 smartForward = gContext->GetNumSetting("SmartForward", 0); 791 795 stickykeys = gContext->GetNumSetting("StickyKeys"); 792 796 ff_rew_repos = gContext->GetNumSetting("FFRewReposTime", 100)/100.0; … … 801 805 if (!feVBI.isEmpty()) 802 806 vbimode = VBIMode::Parse(gContext->GetSetting(feVBI)); 803 807 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 804 819 if (createWindow) 805 820 { 806 821 MythMainWindow *mainWindow = gContext->GetMainWindow(); … … 967 982 VERBOSE(VB_PLAYBACK, "TV::~TV() -- end"); 968 983 } 969 984 985 void 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 970 994 /** 971 995 * \brief get tv state of active player context 972 996 */ … … 6175 6199 6176 6200 void TV::ToggleChannelFavorite(PlayerContext *ctx) 6177 6201 { 6178 if (ctx->recorder)6179 ctx->recorder->ToggleChannelFavorite();6202 // if (ctx->recorder) 6203 // ctx->recorder->ToggleChannelFavorite(); 6180 6204 } 6181 6205 6182 6206 QString TV::GetQueuedInput(void) const … … 6432 6456 { 6433 6457 bool muted = false; 6434 6458 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 6435 6482 QString oldinputname = ctx->recorder->GetInput(); 6436 6483 6437 6484 ctx->LockDeleteNVP(__FILE__, __LINE__); … … 7603 7650 // Actually show the pop-up UI 7604 7651 DBChanList changeChannel; 7605 7652 ProgramInfo *nextProgram = NULL; 7653 int changrpid = channel_group_id; 7654 7606 7655 switch (editType) 7607 7656 { 7608 7657 case kScheduleProgramGuide: 7609 7658 { 7610 7659 TV *player = (pause_active) ? NULL : this; 7611 7660 changeChannel = GuideGrid::Run( 7612 chanid, channum, false, player, isLiveTV && player );7661 chanid, channum, false, player, isLiveTV && player, &changrpid); 7613 7662 break; 7614 7663 } 7615 7664 case kScheduleProgramFinder: … … 7648 7697 actx = GetPlayerReadLock(-1, __FILE__, __LINE__); 7649 7698 StopEmbedding(actx); // Undo any embedding 7650 7699 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 7651 7716 // If user selected a new channel in the EPG, change to that channel 7652 7717 if (isLiveTV && changeChannel.size()) 7653 7718 ChangeChannel(actx, changeChannel); … … 8497 8562 { 8498 8563 if (!browsemode) 8499 8564 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 } 8500 8595 8501 8596 OSD *osd = GetOSDLock(ctx); 8502 8597 if (ctx->paused || !osd) … … 9401 9496 } 9402 9497 else if (action == "GUIDE") 9403 9498 EditSchedule(actx, kScheduleProgramGuide); 9499 else if (action.left(10) == "CHANGROUP_") 9500 processChanGroupEntry(action); 9404 9501 else if (action == "FINDER") 9405 9502 EditSchedule(actx, kScheduleProgramFinder); 9406 9503 else if (action == "SCHEDULE") … … 9507 9604 ReturnPlayerLock(actx); 9508 9605 } 9509 9606 9607 void 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 9510 9626 void TV::ShowOSDTreeMenu(const PlayerContext *ctx) 9511 9627 { 9512 9628 int osdMenuCount = osdMenuEntries->GetCount(); … … 9578 9694 } 9579 9695 else if (category == "GUIDE") 9580 9696 new OSDGenericTree(treeMenu, tr("Program Guide"), "GUIDE"); 9697 else if (category == "CHANGROUP") 9698 FillMenuChanGroups(ctx, treeMenu); 9581 9699 else if (category == "PIP") 9582 9700 FillMenuPxP(ctx, treeMenu); 9583 9701 else if (category == "INPUTSWITCHING") … … 10126 10244 return true; 10127 10245 } 10128 10246 10247 void 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 10129 10267 void TV::ToggleAutoExpire(PlayerContext *ctx) 10130 10268 { 10131 10269 QString desc = QString::null; -
mythtv/libs/libmythtv/remoteencoder.h
50 50 PictureAdjustType type, PictureAttribute attr, bool up); 51 51 void ChangeChannel(int channeldirection); 52 52 void ChangeDeinterlacer(int deint_mode); 53 void ToggleChannelFavorite(void);54 53 void SetChannel(QString channel); 55 54 int SetSignalMonitoringRate(int msec, bool notifyFrontend = true); 56 55 uint GetSignalLockTimeout(QString input); -
mythtv/libs/libmythtv/tvosdmenuentry.cpp
192 192 curMenuEntries.append( 193 193 new TVOSDMenuEntry("GUIDE", 1, 1, 0, 0, "Program Guide")); 194 194 curMenuEntries.append( 195 new TVOSDMenuEntry("CHANGROUP", 1, 1, 0, 0, "Channel Groups")); 196 curMenuEntries.append( 195 197 new TVOSDMenuEntry("PIP", 1, 1, 1, -1, "Picture-in-Picture")); 196 198 curMenuEntries.append( 197 199 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 17 class 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 36 void 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 67 void 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 80 void ChannelGroupStorage::Save(QString destination) 81 { 82 Save(); 83 } 84 85 class 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 98 ChannelGroupConfig::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 137 ChannelGroupEditor::ChannelGroupEditor(void) : 138 listbox(new ListBoxSetting(this)), lastValue("__CREATE_NEW_GROUP__") 139 { 140 listbox->setLabel(tr("Channel Groups")); 141 addChild(listbox); 142 } 143 144 void 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 176 void 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 221 void 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 239 DialogCode ChannelGroupEditor::exec(void) 240 { 241 while (ConfigurationDialog::exec() == kDialogCodeAccepted) 242 open(listbox->getValue()); 243 244 return kDialogCodeRejected; 245 } 246 247 MythDialog* 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
402 402 return (lastinput.isEmpty()) ? "Error" : lastinput; 403 403 } 404 404 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 413 405 void RemoteEncoder::ChangeChannel(int channeldirection) 414 406 { 415 407 QStringList strlist( QString("QUERY_RECORDER %1").arg(recordernum) ); -
mythtv/libs/libmythtv/tv_rec.cpp
2902 2902 } 2903 2903 } 2904 2904 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 else2954 {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 2964 2905 /** \fn TVRec::ChangePictureAttribute(PictureAdjustType,PictureAttribute,bool) 2965 2906 * \brief Returns current value [0,100] if it succeeds, -1 otherwise. 2966 2907 * -
mythtv/programs/mythfrontend/globalsettings.cpp
3159 3159 return gc; 3160 3160 } 3161 3161 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 }3173 3162 3174 3163 static HostSpinBox *EPGChanDisplay() 3175 3164 { … … 3197 3186 return gc; 3198 3187 } 3199 3188 3189 static 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 3200 static 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 3223 static 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 3235 class 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 3200 3256 // General RecPriorities settings 3201 3257 3202 3258 static GlobalCheckBox *GRSchedMoveHigher() … … 4965 5021 general2->addChild(CategoryOverTimeSettings()); 4966 5022 addChild(general2); 4967 5023 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); 4968 5030 } 4969 5031 4970 5032 EPGSettings::EPGSettings() 4971 5033 { 4972 5034 VerticalConfigurationGroup* epg = new VerticalConfigurationGroup(false); 4973 epg->setLabel(QObject::tr("Program Guide") + " 1/ 2");5035 epg->setLabel(QObject::tr("Program Guide") + " 1/3"); 4974 5036 epg->addChild(EPGFillType()); 4975 5037 epg->addChild(EPGShowCategoryColors()); 4976 5038 epg->addChild(EPGShowCategoryText()); 4977 5039 epg->addChild(EPGScrollType()); 4978 5040 epg->addChild(EPGShowChannelIcon()); 4979 epg->addChild(EPGShowFavorites());4980 5041 epg->addChild(WatchTVGuide()); 4981 5042 epg->addChild(EPGChanDisplay()); 4982 5043 epg->addChild(EPGTimeDisplay()); 4983 5044 addChild(epg); 4984 5045 4985 5046 VerticalConfigurationGroup* gen = new VerticalConfigurationGroup(false); 4986 gen->setLabel(QObject::tr("Program Guide") + " 2/ 2");5047 gen->setLabel(QObject::tr("Program Guide") + " 2/3"); 4987 5048 gen->addChild(UnknownTitle()); 4988 5049 gen->addChild(UnknownCategory()); 4989 5050 gen->addChild(DefaultTVChannel()); 4990 5051 gen->addChild(SelectChangesChannel()); 4991 5052 gen->addChild(EPGRecThreshold()); 4992 5053 gen->addChild(EPGEnableJumpToChannel()); 4993 addChild(gen); 5054 addChild(gen); 4994 5055 } 4995 5056 4996 5057 GeneralRecPrioritiesSettings::GeneralRecPrioritiesSettings() -
mythtv/programs/mythfrontend/main.cpp
52 52 #include "lcddevice.h" 53 53 #include "langsettings.h" 54 54 #include "mythcommandlineparser.h" 55 #include "channelgroupsettings.h" 55 56 56 57 #include "myththemedmenu.h" 57 58 #include "myththemebase.h" … … 517 518 EPGSettings settings; 518 519 settings.exec(); 519 520 } 521 else if (sel == "settings channelgroups") 522 { 523 ChannelGroupEditor editor; 524 editor.exec(); 525 } 520 526 else if (sel == "settings generalrecpriorities") 521 527 { 522 528 GeneralRecPrioritiesSettings settings; -
mythtv/programs/mythbackend/encoderlink.h
84 84 vector<InputInfo> GetFreeInputs(const vector<uint> &excluded_cards) const; 85 85 QString GetInput(void) const; 86 86 QString SetInput(QString); 87 void ToggleChannelFavorite(void);88 87 void ChangeChannel(int channeldirection); 89 88 void SetChannel(const QString &name); 90 89 int GetPictureAttribute(PictureAttribute attr); -
mythtv/programs/mythbackend/mainserver.cpp
3219 3219 ret = (ret.isEmpty()) ? "UNKNOWN" : ret; 3220 3220 retlist << ret; 3221 3221 } 3222 else if (command == "TOGGLE_CHANNEL_FAVORITE")3223 {3224 enc->ToggleChannelFavorite();3225 retlist << "ok";3226 }3227 3222 else if (command == "CHANGE_CHANNEL") 3228 3223 { 3229 3224 int direction = slist[2].toInt(); -
mythtv/programs/mythbackend/encoderlink.cpp
680 680 return QString::null; 681 681 } 682 682 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 else693 VERBOSE(VB_IMPORTANT, "Should be local only query: ToggleChannelFavorite");694 }695 696 683 /** \fn EncoderLink::ChangeChannel(int) 697 684 * \brief Changes to the next or previous channel. 698 685 * <b>This only works on local recorders.</b>