Ticket #2878: perchancommflag.patch

File perchancommflag.patch, 4.5 KB (added by talktodan@…, 17 years ago)

allows commercial flagging to be set per-channel

  • libs/libmythtv/dbcheck.cpp

     
    1010#include "mythdbcon.h"
    1111
    1212/// This is the DB schema version expected by the running MythTV instance.
    13 const QString currentDatabaseVersion = "1175";
     13const QString currentDatabaseVersion = "1176";
    1414
    1515static bool UpdateDBVersionNumber(const QString &newnumber);
    1616static bool performActualUpdate(const QString updates[], QString version,
     
    258258those on the BBC and CBC networks. On commercial free channels we
    259259do not need to run the commercial detector.
    260260
     261'commmethod' tells us which commercial flagger to use on the channel, the
     262default is to use the global setting
     263
    261264'visible' tells us whether we should show this channel in the channel
    262265guide.
    263266
     
    28032806            return false;
    28042807    }
    28052808
     2809    if (dbver == "1175")
     2810    {
     2811        const QString updates[] = {
     2812"ALTER TABLE channel ADD COLUMN commmethod INT NOT NULL default '-1';",
     2813""
     2814};
     2815        if (!performActualUpdate(updates, "1176", dbver))
     2816            return false;
     2817    }
     2818
    28062819//"ALTER TABLE cardinput DROP COLUMN preference;" in 0.22
    28072820//"ALTER TABLE channel DROP COLUMN atscsrcid;" in 0.22
    28082821//"ALTER TABLE recordedmarkup DROP COLUMN offset;" in 0.22
     
    29122925"  hue int(11) default '32768',"
    29132926"  tvformat varchar(10) NOT NULL default 'Default',"
    29142927"  commfree tinyint(4) NOT NULL default '0',"
     2928"  commmethod int(11) NOT NULL default '-1',"
    29152929"  visible tinyint(1) NOT NULL default '1',"
    29162930"  outputfilters varchar(255) NOT NULL default '',"
    29172931"  useonairguide tinyint(1) default '0',"
  • libs/libmythtv/channelsettings.cpp

     
    237237    }
    238238};
    239239
     240class CommMethod : public ComboBoxSetting, public ChannelDBStorage
     241{
     242  public:
     243    CommMethod(const ChannelID &id) :
     244       ComboBoxSetting(this), ChannelDBStorage(this, id, "commmethod")
     245    {
     246        setLabel(QObject::tr("Commercial Flagging Method"));
     247        setHelpText(QObject::tr("Changes the method of "
     248               "commercial detection used for recordings on this channel"));
     249        addSelection(QObject::tr("Use Global Setting"), "-1");
     250
     251        /* These settings should probably be consolodated with
     252         * programs/mythfrontend/globalsettings.cpp:391
     253         * however I don't know the appropiate way to do this to fit
     254         * into mythtv frameworks.. so I have left for the experts :)
     255         */
     256        addSelection(QObject::tr("All Available Methods"), "255");
     257        addSelection(QObject::tr("Blank Frame Detection"), "1");
     258        addSelection(QObject::tr("Blank Frame + Scene Change Detection"), "3");
     259        addSelection(QObject::tr("Scene Change Detection"), "2");
     260        addSelection(QObject::tr("Logo Detection"), "4");
     261        addSelection(QObject::tr("Experimental"), "511");
     262
     263    }
     264};
     265
    240266class Visible : public CheckBoxSetting, public ChannelDBStorage
    241267{
    242268  public:
     
    363389
    364390    left->addChild(new Channum(id));
    365391    left->addChild(new Callsign(id));
     392    left->addChild(new CommMethod(id));
    366393    left->addChild(lefthoz);
    367394 
    368395    right->addChild(source);
  • programs/mythcommflag/main.cpp

     
    454454int FlagCommercials(QString chanid, QString starttime)
    455455{
    456456    int breaksFound = 0;
     457
    457458    if (commDetectMethod == COMM_DETECT_UNINIT)
     459    {
     460            MSqlQuery method_query(MSqlQuery::InitCon());
     461            method_query.prepare("SELECT commmethod FROM channel "
     462                                        "WHERE chanid = :CHANID;");
     463            method_query.bindValue(":CHANID", chanid);
     464
     465            if (method_query.exec() && method_query.isActive()
     466                                                && method_query.size() > 0)
     467            {
     468                    method_query.next();
     469                    commDetectMethod = (enum SkipTypes)
     470                                        method_query.value(0).toInt();
     471                    VERBOSE(VB_COMMFLAG,
     472                        QString("Using method: %1 from chaneld %2")
     473                        .arg(commDetectMethod).arg(chanid));
     474            }
     475
     476    }
     477       
     478    if (commDetectMethod == COMM_DETECT_UNINIT)
    458479        commDetectMethod = (enum SkipTypes)gContext->GetNumSetting(
    459480                                    "CommercialSkipMethod", COMM_DETECT_ALL);
    460481    QMap<long long, int> blanks;