Ticket #4501: browse_tuners.patch
File browse_tuners.patch, 8.6 KB (added by , 16 years ago) |
---|
-
libs/libmythtv/tv_play.h
19 19 #include "programinfo.h" 20 20 #include "channelutil.h" 21 21 #include "videoouttypes.h" 22 #include "channelutil.h" 22 23 23 24 #include <qobject.h> 24 25 … … 384 385 void ToggleRecord(void); 385 386 void BrowseChannel(const QString &channum); 386 387 388 uint GetChanIDAnyTuner(const QString &chan); 389 void GetNextProgramAnyTuner(int direction, InfoMap &infoMap); 390 QString GetProgramTunerStatus(InfoMap &infoMap); 391 uint FindAvailableTuner(const QString &chanid); 392 387 393 void DoTogglePictureAttribute(PictureAdjustType type); 388 394 void DoChangePictureAttribute( 389 395 PictureAdjustType type, PictureAttribute attr, bool up); … … 568 574 QString browsechannum; 569 575 QString browsechanid; 570 576 QString browsestarttime; 577 bool browsealltuners; 578 DBChanList allchannels; 571 579 572 580 // Program Info for currently playing video 573 581 // (or next video if InChangeState() is true) -
libs/libmythtv/tv_play.cpp
545 545 browsemode(false), persistentbrowsemode(false), 546 546 browseTimer(new QTimer(this)), 547 547 browsechannum(""), browsechanid(""), browsestarttime(""), 548 browsealltuners(false), 548 549 // Program Info for currently playing video 549 550 recorderPlaybackInfo(NULL), 550 551 playbackinfo(NULL), playbackLen(0), … … 634 635 ff_rew_speeds.push_back( 635 636 gContext->GetNumSetting(QString("FFRewSpeed%1").arg(i), def[i])); 636 637 638 browsealltuners = gContext->GetNumSetting("BrowseAllTuners", 0); 639 if (browsealltuners) 640 { 641 QString channelOrdering = gContext->GetSetting("ChannelOrdering", "channum"); 642 allchannels = ChannelUtil::GetChannels(0, true, "channum, callsign"); 643 ChannelUtil::SortChannels(allchannels, channelOrdering, true); 644 }; 645 637 646 vbimode = VBIMode::Parse(gContext->GetSetting("VbiFormat")); 638 647 639 648 if (createWindow) … … 5611 5620 return false; 5612 5621 } 5613 5622 5623 uint TV::GetChanIDAnyTuner(const QString &chan) 5624 { 5625 for (uint i = 0; i < allchannels.size(); ++i) 5626 if (allchannels[i].channum == chan) 5627 return allchannels[i].chanid; 5628 return 0; 5629 }; 5630 5631 void TV::GetNextProgramAnyTuner(int direction, InfoMap &infoMap) 5632 { 5633 uint chanid = infoMap["chanid"].toUInt(); 5634 if (infoMap["chanid"] == "") 5635 chanid = GetChanIDAnyTuner(infoMap["channum"]); 5636 5637 int chandir = -1; 5638 switch(direction) 5639 { 5640 case BROWSE_UP: chandir = CHANNEL_DIRECTION_UP; break; 5641 case BROWSE_DOWN: chandir = CHANNEL_DIRECTION_DOWN; break; 5642 case BROWSE_FAVORITE: chandir = CHANNEL_DIRECTION_FAVORITE; break; 5643 }; 5644 if (direction != -1) 5645 chanid = ChannelUtil::GetNextChannel(allchannels, chanid, 0, chandir); 5646 5647 infoMap["chanid"] = QString("%1").arg(chanid); 5648 infoMap["channum"] = ChannelUtil::GetChanNum(chanid); 5649 5650 5651 QDateTime nowtime = QDateTime::currentDateTime(); 5652 QDateTime latesttime = nowtime.addSecs(6*60*60); 5653 QDateTime browsetime = QDateTime::fromString(infoMap["dbstarttime"], Qt::ISODate); 5654 5655 MSqlBindings bindings; 5656 bindings[":CHANID"] = chanid; 5657 bindings[":NOWTS"] = nowtime.toString("yyyy-MM-ddThh:mm:ss"); 5658 bindings[":LATESTTS"] = latesttime.toString("yyyy-MM-ddThh:mm:ss"); 5659 bindings[":BROWSETS"] = browsetime.toString("yyyy-MM-ddThh:mm:ss"); 5660 5661 QString querystr = " WHERE program.chanid = :CHANID "; 5662 switch(direction) 5663 { 5664 case BROWSE_LEFT: 5665 querystr += " AND program.endtime <= :BROWSETS " 5666 " AND program.endtime > :NOWTS "; 5667 break; 5668 5669 case BROWSE_RIGHT: 5670 querystr += " AND program.starttime > :BROWSETS " 5671 " AND program.starttime < :LATESTTS "; 5672 break; 5673 5674 default: 5675 querystr += " AND program.starttime <= :BROWSETS " 5676 " AND program.endtime > :BROWSETS "; 5677 }; 5678 5679 ProgramList progList; 5680 progList.FromProgram(querystr, bindings); 5681 5682 if (progList.isEmpty()) 5683 { 5684 infoMap["dbstarttime"] = ""; 5685 return; 5686 }; 5687 5688 ProgramInfo* prog = (direction == BROWSE_LEFT) ? progList.last() 5689 : progList.first(); 5690 5691 infoMap["dbstarttime"] = prog->startts.toString(Qt::ISODate); 5692 } 5693 5694 QString TV::GetProgramTunerStatus(InfoMap &infoMap) 5695 { 5696 infoMap["tuner"] = infoMap["notuner"] = ""; 5697 5698 uint cardid = FindAvailableTuner(infoMap["chanid"]); 5699 5700 QString status; 5701 if (!cardid) 5702 { 5703 infoMap["notuner"] = tr("No Tuner Available"); 5704 status = "unavailable"; 5705 } 5706 else if (cardid == (uint)activerecorder->GetRecorderNumber()) 5707 { 5708 infoMap["tuner"] = tr("Current Tuner"); 5709 status = "current"; 5710 } 5711 else 5712 { 5713 infoMap["tuner"] = tr("Tuner")+QString(" %1").arg(cardid); 5714 status = "available"; 5715 } 5716 5717 return status; 5718 }; 5719 5720 uint TV::FindAvailableTuner(const QString &chanid) 5721 { 5722 if (!activerecorder->ShouldSwitchToAnotherCard(chanid)) 5723 return activerecorder->GetRecorderNumber(); 5724 5725 QStringList validlist = GetValidRecorderList(chanid.toUInt()); 5726 QStringList freelist = "GET_FREE_RECORDER_LIST"; 5727 if (!gContext->SendReceiveStringList(freelist, true)) 5728 return 0; 5729 5730 QStringList::iterator recIter; 5731 for (recIter = validlist.begin(); recIter != validlist.end(); ++recIter) 5732 { 5733 if (freelist.find(*recIter) == freelist.end()) 5734 continue; 5735 5736 return (*recIter).toInt(); 5737 } 5738 5739 return 0; 5740 }; 5741 5614 5742 void TV::EmbedOutput(WId wid, int x, int y, int w, int h) 5615 5743 { 5616 5744 embedWinID = wid; … … 6428 6556 infoMap["channum"] = browsechannum; 6429 6557 infoMap["chanid"] = browsechanid; 6430 6558 6431 GetNextProgram(activerecorder, direction, infoMap); 6559 if (browsealltuners) 6560 GetNextProgramAnyTuner(direction, infoMap); 6561 else 6562 GetNextProgram(activerecorder, direction, infoMap); 6432 6563 6433 6564 browsechannum = infoMap["channum"]; 6434 6565 browsechanid = infoMap["chanid"]; … … 6446 6577 if (program_info) 6447 6578 program_info->ToMap(infoMap); 6448 6579 6580 QString tunerstatus = GetProgramTunerStatus(infoMap); 6581 6449 6582 GetOSD()->ClearAllText("browse_info"); 6583 GetOSD()->SetFontFunction("browse_info", "tuner", tunerstatus); 6450 6584 GetOSD()->SetText("browse_info", infoMap, -1); 6451 6585 6452 6586 delete program_info; … … 6493 6627 ProgramInfo::GetProgramAtDateTime(browsechanid, startts); 6494 6628 program_info->ToggleRecord(); 6495 6629 program_info->ToMap(infoMap); 6630 QString tunerstatus = GetProgramTunerStatus(infoMap); 6496 6631 6497 6632 if (GetOSD()) 6498 6633 { 6499 6634 GetOSD()->ClearAllText("browse_info"); 6635 GetOSD()->SetFontFunction("browse_info", "tuner", tunerstatus); 6500 6636 GetOSD()->SetText("browse_info", infoMap, -1); 6501 6637 6502 6638 if (activenvp == nvp) … … 6543 6679 6544 6680 void TV::BrowseChannel(const QString &chan) 6545 6681 { 6546 if (!activerecorder->CheckChannel(chan)) 6682 if (browsealltuners) 6683 { 6684 if (!GetChanIDAnyTuner(chan)) 6685 return; 6686 } 6687 else if (!activerecorder->CheckChannel(chan)) 6547 6688 return; 6548 6689 6549 6690 browsechannum = chan; -
programs/mythfrontend/globalsettings.cpp
1792 1792 return gc; 1793 1793 } 1794 1794 1795 static HostCheckBox *BrowseAllTuners() 1796 { 1797 HostCheckBox *gc = new HostCheckBox("BrowseAllTuners"); 1798 gc->setLabel(QObject::tr("Browse channels from all tuners")); 1799 gc->setValue(true); 1800 gc->setHelpText(QObject::tr("By default, browse mode only shows channels " 1801 "on the currently active tuner. If enabled, browse mode " 1802 "will shows all channels, no matter what tuner they " 1803 "exist on.")); 1804 return gc; 1805 } 1806 1795 1807 static HostCheckBox *AggressiveBuffer() 1796 1808 { 1797 1809 HostCheckBox *gc = new HostCheckBox("AggressiveSoundcardBuffer"); … … 4562 4574 osd->addChild(CCBackground()); 4563 4575 osd->addChild(DefaultCCMode()); 4564 4576 osd->addChild(PersistentBrowseMode()); 4577 osd->addChild(BrowseAllTuners()); 4565 4578 addChild(osd); 4566 4579 4567 4580 addChild(OSDCC708Settings());