Ticket #199: 00-199-channelgroups.7.1.patch
File 00-199-channelgroups.7.1.patch, 57.0 KB (added by , 15 years ago) |
---|
-
mythtv/themes/classic/tv_settings.xml
81 81 </button> 82 82 83 83 <button> 84 <type>TV_SETTINGS_CHANNEL_GROUP</type> 85 <text>Channel Groups</text> 86 <action>SETTINGS CHANNELGROUPS</action> 87 </button> 88 89 <button> 84 90 <type>TV_SETTINGS_PLAYBACK_GROUPS</type> 85 91 <text>Playback Groups</text> 86 92 <text lang="IT">Gruppi di Riproduzione</text> -
mythtv/themes/DVR/tv_settings.xml
84 84 </button> 85 85 86 86 <button> 87 <type>TV_SETTINGS_CHANNEL_GROUP</type> 88 <text>Channel Groups</text> 89 <action>SETTINGS CHANNELGROUPS</action> 90 </button> 91 92 <button> 87 93 <type>TV_SETTINGS_PLAYBACK_GROUPS</type> 88 94 <text>Playback Groups</text> 89 95 <text lang="SV">Uppspelningsgrupper</text> -
mythtv/themes/defaultmenu/tv_settings.xml
95 95 <action>SETTINGS OSD</action> 96 96 </button> 97 97 98 <button>98 <button> 99 99 <type>TV_SETTINGS_OSD_MENU_EDITOR</type> 100 100 <text>OSD Menu Editor</text> 101 101 <action>OSDMENUEDITOR</action> 102 </button> 102 </button> 103 103 104 <button> 105 <type>TV_SETTINGS_CHANNEL_GROUP</type> 106 <text>Channel Groups</text> 107 <action>SETTINGS CHANNELGROUPS</action> 108 </button> 109 110 <button> 104 111 <type>TV_SETTINGS_PLAYBACK_GROUPS</type> 105 112 <text>Playback Groups</text> 106 113 <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 */ … … 6177 6201 6178 6202 void TV::ToggleChannelFavorite(PlayerContext *ctx) 6179 6203 { 6180 if (ctx->recorder)6181 ctx->recorder->ToggleChannelFavorite();6204 // if (ctx->recorder) 6205 // ctx->recorder->ToggleChannelFavorite(); 6182 6206 } 6183 6207 6184 6208 QString TV::GetQueuedInput(void) const … … 6434 6458 { 6435 6459 bool muted = false; 6436 6460 6461 if ((browse_changrp || (direction == CHANNEL_DIRECTION_FAVORITE)) && 6462 (channel_group_id > -1) && (direction != CHANNEL_DIRECTION_SAME)) 6463 { 6464 uint chanid; 6465 6466 // Collect channel info 6467 //DEBUG 6468 //pbinfoLock.lock(); 6469 ctx->LockPlayingInfo(__FILE__, __LINE__); 6470 uint old_chanid = ctx->playingInfo->chanid.toUInt(); 6471 ctx->LockPlayingInfo(__FILE__, __LINE__); 6472 // pbinfoLock.unlock(); 6473 6474 chanid = ChannelUtil::GetNextChannel(m_channellist, old_chanid, 0, direction); 6475 6476 ChangeChannel(ctx, chanid, ""); 6477 return; 6478 } 6479 else if (direction == CHANNEL_DIRECTION_FAVORITE) 6480 { 6481 direction = CHANNEL_DIRECTION_UP; 6482 } 6483 6437 6484 QString oldinputname = ctx->recorder->GetInput(); 6438 6485 6439 6486 ctx->LockDeleteNVP(__FILE__, __LINE__); … … 7605 7652 // Actually show the pop-up UI 7606 7653 DBChanList changeChannel; 7607 7654 ProgramInfo *nextProgram = NULL; 7655 int changrpid = channel_group_id; 7656 7608 7657 switch (editType) 7609 7658 { 7610 7659 case kScheduleProgramGuide: 7611 7660 { 7612 7661 TV *player = (pause_active) ? NULL : this; 7613 7662 changeChannel = GuideGrid::Run( 7614 chanid, channum, false, player, isLiveTV && player );7663 chanid, channum, false, player, isLiveTV && player, &changrpid); 7615 7664 break; 7616 7665 } 7617 7666 case kScheduleProgramFinder: … … 7650 7699 actx = GetPlayerReadLock(-1, __FILE__, __LINE__); 7651 7700 StopEmbedding(actx); // Undo any embedding 7652 7701 DoSetPauseState(actx, was_paused); // Restore pause states 7702 7703 // if channel group was changed in EPG update local info 7704 if ((changrpid != channel_group_id) && (editType == kScheduleProgramGuide)) 7705 { 7706 channel_group_id = changrpid; 7707 7708 if (browse_changrp) 7709 { 7710 VERBOSE(VB_IMPORTANT, LOC + 7711 QString("Reloading channel group list for %1").arg(channel_group_id)); 7712 7713 m_channellist = ChannelUtil::GetChannels(0, true, "channum, callsign", channel_group_id); 7714 ChannelUtil::SortChannels(m_channellist, "channum", true); 7715 } 7716 } 7717 7653 7718 // If user selected a new channel in the EPG, change to that channel 7654 7719 if (isLiveTV && changeChannel.size()) 7655 7720 ChangeChannel(actx, changeChannel); … … 8499 8564 { 8500 8565 if (!browsemode) 8501 8566 BrowseStart(ctx); 8567 8568 VERBOSE(VB_IMPORTANT,"In BrowseDispInfo"); 8569 // if browsing channel groups is enabled or direction if BROWSE_FAVORITES 8570 // Then pick the next channel in the channel group list to browse 8571 // If channel group is ALL CHANNELS (-1), then bypass picking from 8572 // the channel group list 8573 if ((browse_changrp || (direction == BROWSE_FAVORITE)) && 8574 (channel_group_id > -1) && (direction != BROWSE_SAME) && 8575 (direction != BROWSE_RIGHT) && (direction != BROWSE_LEFT)) 8576 { 8577 uint chanid; 8578 int dir; 8579 8580 if ( (direction == BROWSE_UP) || (direction == BROWSE_FAVORITE) ) 8581 dir = CHANNEL_DIRECTION_UP; 8582 else if (direction == BROWSE_DOWN) 8583 dir = CHANNEL_DIRECTION_DOWN; 8584 else // this should never happen, but just in case 8585 dir = direction; 8586 8587 chanid = ChannelUtil::GetNextChannel(m_channellist, browsechanid, 0, dir); 8588 VERBOSE(VB_IMPORTANT, QString("Get channel: %1").arg(chanid)); 8589 browsechanid = chanid; 8590 browsechannum = QString::null; 8591 direction = BROWSE_SAME; 8592 } 8593 else if ((channel_group_id == -1) && (direction == BROWSE_FAVORITE)) 8594 { 8595 direction = BROWSE_UP; 8596 } 8502 8597 8503 8598 OSD *osd = GetOSDLock(ctx); 8504 8599 if (ctx->paused || !osd) … … 9403 9498 } 9404 9499 else if (action == "GUIDE") 9405 9500 EditSchedule(actx, kScheduleProgramGuide); 9501 else if (action.left(10) == "CHANGROUP_") 9502 processChanGroupEntry(action); 9406 9503 else if (action == "FINDER") 9407 9504 EditSchedule(actx, kScheduleProgramFinder); 9408 9505 else if (action == "SCHEDULE") … … 9509 9606 ReturnPlayerLock(actx); 9510 9607 } 9511 9608 9609 void TV::processChanGroupEntry(QString action) 9610 { 9611 if (action == "CHANGROUP_ALL_CHANNELS") 9612 { 9613 channel_group_id = -1; 9614 } 9615 else 9616 { 9617 action.remove("CHANGROUP_"); 9618 channel_group_id = action.toInt(); 9619 9620 if (browse_changrp) 9621 { 9622 m_channellist = ChannelUtil::GetChannels(0, true, "channum, callsign", channel_group_id); 9623 ChannelUtil::SortChannels(m_channellist, "channum", true); 9624 } 9625 } 9626 } 9627 9512 9628 void TV::ShowOSDTreeMenu(const PlayerContext *ctx) 9513 9629 { 9514 9630 int osdMenuCount = osdMenuEntries->GetCount(); … … 9584 9700 } 9585 9701 else if (category == "GUIDE") 9586 9702 new OSDGenericTree(treeMenu, tr("Program Guide"), "GUIDE"); 9703 else if (category == "CHANGROUP") 9704 FillMenuChanGroups(ctx, treeMenu); 9587 9705 else if (category == "PIP") 9588 9706 FillMenuPxP(ctx, treeMenu); 9589 9707 else if (category == "INPUTSWITCHING") … … 10132 10250 return true; 10133 10251 } 10134 10252 10253 void TV::FillMenuChanGroups( 10254 const PlayerContext *ctx, OSDGenericTree *treeMenu) const 10255 { 10256 OSDGenericTree *cg_item = new OSDGenericTree(treeMenu, tr("Channel Groups"), 10257 "CHANGROUP"); 10258 new OSDGenericTree(cg_item, tr("All Channels"), "CHANGROUP_ALL_CHANNELS", 10259 (channel_group_id == -1) ? 1 : 0, 10260 NULL, "CHANNELGROUP"); 10261 10262 ChannelGroupList::const_iterator it; 10263 10264 for (it = m_changrplist.begin(); it != m_changrplist.end(); ++it) 10265 { 10266 QString name = QString("CHANGROUP_%1").arg(it->grpid); 10267 new OSDGenericTree(cg_item, it->name, name, 10268 ((int)(it->grpid) == channel_group_id) ? 1 : 0, 10269 NULL, "CHANNELGROUP"); 10270 } 10271 } 10272 10135 10273 void TV::ToggleAutoExpire(PlayerContext *ctx) 10136 10274 { 10137 10275 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/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/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/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
2907 2907 } 2908 2908 } 2909 2909 2910 /** \fn TVRec::ToggleChannelFavorite()2911 * \brief Toggles whether the current channel should be on our favorites list.2912 */2913 void TVRec::ToggleChannelFavorite(void)2914 {2915 QMutexLocker lock(&stateChangeLock);2916 2917 if (!channel)2918 return;2919 2920 // Get current channel id...2921 uint sourceid = channel->GetCurrentSourceID();2922 QString channum = channel->GetCurrentName();2923 uint chanid = ChannelUtil::GetChanID(sourceid, channum);2924 2925 if (!chanid)2926 {2927 VERBOSE(VB_IMPORTANT, LOC_ERR + QString(2928 "Channel: \'%1\' was not found in the database.\n"2929 "\t\t\tMost likely, your DefaultTVChannel setting is wrong.\n"2930 "\t\t\tCould not toggle favorite.").arg(channum));2931 return;2932 }2933 2934 // Check if favorite exists for that chanid...2935 MSqlQuery query(MSqlQuery::InitCon());2936 query.prepare(2937 "SELECT favorites.favid "2938 "FROM favorites "2939 "WHERE favorites.chanid = :CHANID "2940 "LIMIT 1");2941 query.bindValue(":CHANID", chanid);2942 2943 if (!query.exec() || !query.isActive())2944 {2945 MythDB::DBError("togglechannelfavorite", query);2946 }2947 else if (query.size() > 0)2948 {2949 // We have a favorites record...Remove it to toggle...2950 query.next();2951 QString favid = query.value(0).toString();2952 query.prepare(2953 QString("DELETE FROM favorites "2954 "WHERE favid = '%1'").arg(favid));2955 query.exec();2956 VERBOSE(VB_RECORD, LOC + "Removing Favorite.");2957 }2958 else2959 {2960 // We have no favorites record...Add one to toggle...2961 query.prepare(2962 QString("INSERT INTO favorites (chanid) "2963 "VALUES ('%1')").arg(chanid));2964 query.exec();2965 VERBOSE(VB_RECORD, LOC + "Adding Favorite.");2966 }2967 }2968 2969 2910 /** \fn TVRec::ChangePictureAttribute(PictureAdjustType,PictureAttribute,bool) 2970 2911 * \brief Returns current value [0,100] if it succeeds, -1 otherwise. 2971 2912 * -
mythtv/programs/mythfrontend/globalsettings.cpp
3147 3147 return gc; 3148 3148 } 3149 3149 3150 static HostCheckBox *EPGShowFavorites()3151 {3152 HostCheckBox *gc = new HostCheckBox("EPGShowFavorites");3153 gc->setLabel(QObject::tr("Only display 'favorite' channels"));3154 gc->setHelpText(QObject::tr("If enabled, the EPG will initially display "3155 "only the channels marked as favorites. Pressing "3156 "\"4\" will toggle between displaying favorites and all "3157 "channels."));3158 gc->setValue(false);3159 return gc;3160 }3161 3150 3162 3151 static HostSpinBox *EPGChanDisplay() 3163 3152 { … … 3185 3174 return gc; 3186 3175 } 3187 3176 3177 static HostCheckBox *ChannelGroupRememberLast() 3178 { 3179 HostCheckBox *gc = new HostCheckBox("ChannelGroupRememberLast"); 3180 gc->setLabel(QObject::tr("Remember last channel group")); 3181 gc->setHelpText(QObject::tr("If enabled, the EPG will initially display " 3182 "only the channels from the last channel group selected. Pressing " 3183 "\"4\" will toggle channel group.")); 3184 gc->setValue(false); 3185 return gc; 3186 } 3187 3188 static HostComboBox *ChannelGroupDefault() 3189 { 3190 HostComboBox *gc = new HostComboBox("ChannelGroupDefault"); 3191 gc->setLabel(QObject::tr("Default channel group")); 3192 3193 ChannelGroupList changrplist; 3194 3195 changrplist = ChannelGroup::GetChannelGroups(); 3196 3197 gc->addSelection(QObject::tr("All Channels"), "-1"); 3198 3199 ChannelGroupList::iterator it; 3200 3201 for (it = changrplist.begin(); it < changrplist.end(); ++it) 3202 gc->addSelection(it->name, QString("%1").arg(it->grpid)); 3203 3204 gc->setHelpText(QObject::tr("Default channel group to be shown in the the EPG" 3205 "Pressing " 3206 "\"4\" will toggle channel group.")); 3207 gc->setValue(false); 3208 return gc; 3209 } 3210 3211 static HostCheckBox *BrowseChannelGroup() 3212 { 3213 HostCheckBox *gc = new HostCheckBox("BrowseChannelGroup"); 3214 gc->setLabel(QObject::tr("Browse/Change channels from Channel Group")); 3215 gc->setHelpText(QObject::tr("If enabled, LiveTV will browse or change channels " 3216 "from the selected channel group. \"All Channels\" " 3217 "channel group may be selected to browse all channels.")); 3218 gc->setValue(false); 3219 return gc; 3220 } 3221 3222 // Channel Group Settings 3223 class ChannelGroupSettings : public TriggeredConfigurationGroup 3224 { 3225 public: 3226 ChannelGroupSettings() : TriggeredConfigurationGroup(false, true, false, false) 3227 { 3228 setLabel(QObject::tr("Remember last channel group")); 3229 setUseLabel(false); 3230 3231 Setting* RememberChanGrpEnabled = ChannelGroupRememberLast(); 3232 addChild(RememberChanGrpEnabled); 3233 setTrigger(RememberChanGrpEnabled); 3234 3235 ConfigurationGroup* settings = new VerticalConfigurationGroup(false); 3236 settings->addChild(ChannelGroupDefault()); 3237 addTarget("0", settings); 3238 3239 // show nothing if RememberChanGrpEnabled is on 3240 addTarget("1", new VerticalConfigurationGroup(true)); 3241 }; 3242 }; 3243 3188 3244 // General RecPriorities settings 3189 3245 3190 3246 static GlobalCheckBox *GRSchedMoveHigher() … … 4952 5008 general2->addChild(CategoryOverTimeSettings()); 4953 5009 addChild(general2); 4954 5010 5011 VerticalConfigurationGroup* changrp = new VerticalConfigurationGroup(false); 5012 changrp->setLabel(QObject::tr("General (Channel Groups)")); 5013 ChannelGroupSettings *changroupsettings = new ChannelGroupSettings(); 5014 changrp->addChild(changroupsettings); 5015 changrp->addChild(BrowseChannelGroup()); 5016 addChild(changrp); 4955 5017 } 4956 5018 4957 5019 EPGSettings::EPGSettings() 4958 5020 { 4959 5021 VerticalConfigurationGroup* epg = new VerticalConfigurationGroup(false); 4960 epg->setLabel(QObject::tr("Program Guide") + " 1/ 2");5022 epg->setLabel(QObject::tr("Program Guide") + " 1/3"); 4961 5023 epg->addChild(EPGFillType()); 4962 5024 epg->addChild(EPGShowCategoryColors()); 4963 5025 epg->addChild(EPGShowCategoryText()); 4964 5026 epg->addChild(EPGScrollType()); 4965 5027 epg->addChild(EPGShowChannelIcon()); 4966 epg->addChild(EPGShowFavorites());4967 5028 epg->addChild(WatchTVGuide()); 4968 5029 epg->addChild(EPGChanDisplay()); 4969 5030 epg->addChild(EPGTimeDisplay()); 4970 5031 addChild(epg); 4971 5032 4972 5033 VerticalConfigurationGroup* gen = new VerticalConfigurationGroup(false); 4973 gen->setLabel(QObject::tr("Program Guide") + " 2/ 2");5034 gen->setLabel(QObject::tr("Program Guide") + " 2/3"); 4974 5035 gen->addChild(UnknownTitle()); 4975 5036 gen->addChild(UnknownCategory()); 4976 5037 gen->addChild(DefaultTVChannel()); 4977 5038 gen->addChild(SelectChangesChannel()); 4978 5039 gen->addChild(EPGRecThreshold()); 4979 5040 gen->addChild(EPGEnableJumpToChannel()); 4980 addChild(gen); 5041 addChild(gen); 4981 5042 } 4982 5043 4983 5044 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" … … 519 520 EPGSettings settings; 520 521 settings.exec(); 521 522 } 523 else if (sel == "settings channelgroups") 524 { 525 ChannelGroupEditor editor; 526 editor.exec(); 527 } 522 528 else if (sel == "settings generalrecpriorities") 523 529 { 524 530 GeneralRecPrioritiesSettings settings; -
mythtv/programs/mythbackend/encoderlink.h
111 111 vector<InputInfo> GetFreeInputs(const vector<uint> &excluded_cards) const; 112 112 QString GetInput(void) const; 113 113 QString SetInput(QString); 114 void ToggleChannelFavorite(void);115 114 void ChangeChannel(int channeldirection); 116 115 void SetChannel(const QString &name); 117 116 int GetPictureAttribute(PictureAttribute attr); -
mythtv/programs/mythbackend/mainserver.cpp
3255 3255 ret = (ret.isEmpty()) ? "UNKNOWN" : ret; 3256 3256 retlist << ret; 3257 3257 } 3258 else if (command == "TOGGLE_CHANNEL_FAVORITE")3259 {3260 enc->ToggleChannelFavorite();3261 retlist << "ok";3262 }3263 3258 else if (command == "CHANGE_CHANNEL") 3264 3259 { 3265 3260 int direction = slist[2].toInt(); -
mythtv/programs/mythbackend/encoderlink.cpp
723 723 return QString::null; 724 724 } 725 725 726 /** \fn EncoderLink::ToggleChannelFavorite(void)727 * \brief Toggles whether the current channel should be on our favorites list.728 * <b>This only works on local recorders.</b>729 * \return -1 if query does not succeed, otherwise.730 */731 void EncoderLink::ToggleChannelFavorite(void)732 {733 if (local)734 tv->ToggleChannelFavorite();735 else736 VERBOSE(VB_IMPORTANT, "Should be local only query: ToggleChannelFavorite");737 }738 739 726 /** \fn EncoderLink::ChangeChannel(int) 740 727 * \brief Changes to the next or previous channel. 741 728 * <b>This only works on local recorders.</b>