Ticket #13500: 13500-deleted1.patch

File 13500-deleted1.patch, 56.6 KB (added by gigem, 5 months ago)
  • mythtv/libs/libmyth/programinfo.cpp

    commit 615ac9a108c4574000357f032b8132bfa048e738 (HEAD -> visible)
    Author: David Engel <dengel@mythtv.org>
    Date:   Thu Oct 10 10:29:28 2019 -0500
    
        First cut at channel.deleted.
    
    diff --git a/mythtv/libs/libmyth/programinfo.cpp b/mythtv/libs/libmyth/programinfo.cpp
    index 010603df83..29c3a74c68 100644
    a b bool LoadFromProgram(ProgramList &destination, 
    54815481    // queries (no defaults.)
    54825482
    54835483    if (!queryStr.contains("WHERE"))
    5484         queryStr += " WHERE visible != 0 ";
     5484        queryStr += " WHERE deleted IS NULL AND visible != 0 ";
    54855485
    54865486    // NOTE: Any GROUP BY clause with a LIMIT is slow, adding at least
    54875487    // a couple of seconds to the query execution time
  • mythtv/libs/libmythbase/mythversion.h

    diff --git a/mythtv/libs/libmythbase/mythversion.h b/mythtv/libs/libmythbase/mythversion.h
    index 0f4d4bb64f..f2609dc245 100644
    a b  
    7575 *      mythtv/bindings/php/MythBackend.php
    7676 */
    7777
    78 #define MYTH_DATABASE_VERSION "1352"
     78#define MYTH_DATABASE_VERSION "1353"
    7979
    8080
    8181 MBASE_PUBLIC  const char *GetMythSourceVersion();
  • mythtv/libs/libmythprotoserver/requesthandler/fileserverhandler.cpp

    diff --git a/mythtv/libs/libmythprotoserver/requesthandler/fileserverhandler.cpp b/mythtv/libs/libmythprotoserver/requesthandler/fileserverhandler.cpp
    index 39ba133438..3f47ee6a21 100644
    a b QString FileServerHandler::LocalFilePath(const QString &path, 
    7575        lpath = "";
    7676
    7777        MSqlQuery query(MSqlQuery::InitCon());
    78         query.prepare("SELECT icon FROM channel WHERE icon LIKE :FILENAME ;");
     78        query.prepare("SELECT icon FROM channel "
     79                      "WHERE icon LIKE :FILENAME ;");
    7980        query.bindValue(":FILENAME", QString("%/") + file);
    8081
    8182        if (query.exec() && query.next())
  • mythtv/libs/libmythtv/channelutil.cpp

    diff --git a/mythtv/libs/libmythtv/channelutil.cpp b/mythtv/libs/libmythtv/channelutil.cpp
    index 8eabaa8695..f41b641128 100644
    a b uint ChannelUtil::GetMplexID(uint sourceid, const QString &channum) 
    466466    query.prepare(
    467467        "SELECT mplexid "
    468468        "FROM channel "
    469         "WHERE sourceid  = :SOURCEID  AND "
     469        "WHERE deleted   IS NULL AND "
     470        "      sourceid  = :SOURCEID  AND "
    470471        "      channum   = :CHANNUM");
    471472
    472473    query.bindValue(":SOURCEID",  sourceid);
    QString ChannelUtil::GetChannelValueStr(const QString &channel_field, 
    955956        QString(
    956957            "SELECT channel.%1 "
    957958            "FROM channel "
    958             "WHERE channum  = :CHANNUM AND "
     959            "WHERE deleted  IS NULL AND "
     960            "      channum  = :CHANNUM AND "
    959961            "      sourceid = :SOURCEID")
    960962        .arg(channel_field));
    961963
    static QStringList get_valid_recorder_list(const QString &channum) 
    10591061        "SELECT capturecard.cardid "
    10601062        "FROM channel "
    10611063        "LEFT JOIN capturecard ON channel.sourceid = capturecard.sourceid "
    1062         "WHERE channel.channum = :CHANNUM AND "
     1064        "WHERE channel.deleted IS NULL AND "
     1065        "      channel.channum = :CHANNUM AND "
    10631066        "      capturecard.livetvorder > 0 "
    10641067        "ORDER BY capturecard.livetvorder, capturecard.cardid");
    10651068    query.bindValue(":CHANNUM", channum);
    vector<uint> ChannelUtil::GetConflicting(const QString &channum, uint sourceid) 
    11031106    {
    11041107        query.prepare(
    11051108            "SELECT chanid from channel "
    1106             "WHERE sourceid = :SOURCEID AND "
     1109            "WHERE deleted  IS NULL AND "
     1110            "      sourceid = :SOURCEID AND "
    11071111            "      channum  = :CHANNUM");
    11081112        query.bindValue(":SOURCEID", sourceid);
    11091113    }
    vector<uint> ChannelUtil::GetConflicting(const QString &channum, uint sourceid) 
    11111115    {
    11121116        query.prepare(
    11131117            "SELECT chanid from channel "
    1114             "WHERE channum = :CHANNUM");
     1118            "WHERE deleted IS NULL AND "
     1119            "      channum = :CHANNUM");
    11151120    }
    11161121
    11171122    query.bindValue(":CHANNUM",  channum);
    QString ChannelUtil::GetDefaultAuthority(uint chanid) 
    11831188                "SELECT chanid, m.default_authority "
    11841189                "FROM channel c "
    11851190                "LEFT JOIN dtv_multiplex m "
    1186                 "ON (c.mplexid = m.mplexid)");
     1191                "ON (c.mplexid = m.mplexid) "
     1192                "WHERE deleted IS NULL");
    11871193            if (query.exec())
    11881194            {
    11891195                while (query.next())
    QString ChannelUtil::GetDefaultAuthority(uint chanid) 
    12031209
    12041210            query.prepare(
    12051211                "SELECT chanid, default_authority "
    1206                 "FROM channel");
     1212                "FROM channel "
     1213                "WHERE deleted IS NULL");
    12071214            if (query.exec())
    12081215            {
    12091216                while (query.next())
    int ChannelUtil::GetChanID(int mplexid, int service_transport_id, 
    13211328
    13221329    // find a proper ATSC channel
    13231330    query.prepare("SELECT chanid FROM channel,dtv_multiplex "
    1324                   "WHERE channel.sourceid          = :SOURCEID AND "
     1331                  "WHERE channel.deleted           IS NULL AND "
     1332                  "      channel.sourceid          = :SOURCEID AND "
    13251333                  "      atsc_major_chan           = :MAJORCHAN AND "
    13261334                  "      atsc_minor_chan           = :MINORCHAN AND "
    13271335                  "      dtv_multiplex.transportid = :TRANSPORTID AND "
    int ChannelUtil::GetChanID(int mplexid, int service_transport_id, 
    13411349    // Find manually inserted/edited channels in order of scariness.
    13421350    // find renamed channel, where atsc is valid
    13431351    query.prepare("SELECT chanid FROM channel "
    1344                   "WHERE sourceid = :SOURCEID AND "
     1352                  "WHERE deleted IS NULL AND "
     1353                  "sourceid = :SOURCEID AND "
    13451354                  "atsc_major_chan = :MAJORCHAN AND "
    13461355                  "atsc_minor_chan = :MINORCHAN");
    13471356
    int ChannelUtil::GetChanID(int mplexid, int service_transport_id, 
    13541363
    13551364        // find based on mpeg program number and mplexid alone
    13561365    query.prepare("SELECT chanid FROM channel "
    1357                   "WHERE sourceid = :SOURCEID AND "
     1366                  "WHERE deleted IS NULL AND "
     1367                  "sourceid = :SOURCEID AND "
    13581368                  "serviceID = :SERVICEID AND "
    13591369                  "mplexid = :MPLEXID");
    13601370
    uint ChannelUtil::FindChannel(uint sourceid, const QString &freqid) 
    13731383    MSqlQuery query(MSqlQuery::InitCon());
    13741384    query.prepare("SELECT chanid "
    13751385                  "FROM channel "
    1376                   "WHERE sourceid = :SOURCEID AND "
     1386                  "WHERE deleted  IS NULL AND "
     1387                  "      sourceid = :SOURCEID AND "
    13771388                  "      freqid   = :FREQID");
    13781389
    13791390    query.bindValue(":SOURCEID", sourceid);
    uint ChannelUtil::FindChannel(uint sourceid, const QString &freqid) 
    13901401
    13911402static uint get_max_chanid(uint sourceid)
    13921403{
    1393     QString qstr = "SELECT MAX(chanid) FROM channel ";
    1394     qstr += (sourceid) ? "WHERE sourceid = :SOURCEID" : "";
     1404    QString qstr =
     1405        "SELECT MAX(chanid) FROM channel ";
     1406    if (sourceid)
     1407        qstr += "AND sourceid = :SOURCEID";
    13951408
    13961409    MSqlQuery query(MSqlQuery::ChannelCon());
    13971410    query.prepare(qstr);
    bool ChannelUtil::DeleteChannel(uint channel_id) 
    17541767{
    17551768    MSqlQuery query(MSqlQuery::InitCon());
    17561769    query.prepare(
    1757         "DELETE FROM channel "
     1770        "UPDATE channel "
     1771        "SET deleted = NOW() "
    17581772        "WHERE chanid = :ID");
    17591773    query.bindValue(":ID", channel_id);
    17601774
    bool ChannelUtil::GetATSCChannel(uint sourceid, const QString &channum, 
    18471861    query.prepare(
    18481862        "SELECT atsc_major_chan, atsc_minor_chan "
    18491863        "FROM channel "
    1850         "WHERE channum  = :CHANNUM AND "
     1864        "WHERE deleted  IS NULL AND "
     1865        "      channum  = :CHANNUM AND "
    18511866        "      sourceid = :SOURCEID");
    18521867
    18531868    query.bindValue(":SOURCEID", sourceid);
    bool ChannelUtil::GetChannelData( 
    18981913        "       atsc_major_chan, atsc_minor_chan, serviceid, "
    18991914        "       chanid,  visible "
    19001915        "FROM channel, videosource "
    1901         "WHERE videosource.sourceid = channel.sourceid AND "
     1916        "WHERE channel.deleted      IS NULL            AND "
     1917        "      videosource.sourceid = channel.sourceid AND "
    19021918        "      channum              = :CHANNUM         AND "
    19031919        "      channel.sourceid     = :SOURCEID "
    19041920        "ORDER BY channel.visible DESC, channel.chanid ");
    ChannelInfoList ChannelUtil::GetChannelsInternal( 
    20552071        " %1  JOIN capturecard  ON capturecard.sourceid = channel.sourceid ")
    20562072        .arg((include_disconnected) ? "LEFT" : "");
    20572073
    2058     QString cond = " WHERE ";
     2074    qstr += "WHERE deleted IS NULL ";
    20592075
    20602076    if (sourceid)
    2061     {
    2062         qstr += QString("WHERE channel.sourceid='%1' ").arg(sourceid);
    2063         cond = " AND ";
    2064     }
     2077        qstr += QString("AND channel.sourceid='%1' ").arg(sourceid);
    20652078
    20662079    // Select only channels from the specified channel group
    20672080    if (channel_groupid > 0)
    2068     {
    2069         qstr += QString("%1 channelgroup.grpid = '%2' ")
    2070             .arg(cond).arg(channel_groupid);
    2071         cond = " AND ";
    2072     }
     2081        qstr += QString("AND channelgroup.grpid = '%1' ").arg(channel_groupid);
    20732082
    20742083    if (visible_only)
    2075     {
    2076         qstr += QString("%1 visible=1 ").arg(cond);
    2077         cond = " AND ";
    2078     }
     2084        qstr += QString("AND visible = 1 ");
    20792085
    20802086    qstr += " GROUP BY chanid";
    20812087
    vector<uint> ChannelUtil::GetChanIDs(int sourceid, bool onlyVisible) 
    21292135{
    21302136    MSqlQuery query(MSqlQuery::InitCon());
    21312137
    2132     QString select = "SELECT chanid FROM channel ";
     2138    QString select = "SELECT chanid FROM channel WHERE deleted IS NULL ";
    21332139    // Yes, this a little ugly
    21342140    if (onlyVisible || sourceid > 0)
    21352141    {
    2136         select += "WHERE ";
    21372142        if (onlyVisible)
    2138             select += "visible = 1 ";
     2143            select += "AND visible = 1 ";
    21392144        if (sourceid > 0)
    2140         {
    2141             if (onlyVisible)
    2142                 select += "AND ";
    2143             select += "sourceid=" + QString::number(sourceid);
    2144         }
     2145            select += "AND sourceid=" + QString::number(sourceid);
    21452146    }
    21462147
    21472148    vector<uint> list;
    2148     if (!query.exec(select))
     2149    query.prepare(select);
     2150    if (!query.exec())
    21492151    {
    21502152        MythDB::DBError("SourceUtil::GetChanIDs()", query);
    21512153        return list;
    uint ChannelUtil::GetChannelCount(int sourceid) 
    22562258    QString   select;
    22572259
    22582260
    2259     select = "SELECT chanid FROM channel";
     2261    select = "SELECT chanid FROM channel WHERE deleted IS NULL ";
    22602262    if (sourceid >= 0)
    2261         select += " WHERE sourceid=" + QString::number(sourceid);
     2263        select += "AND sourceid=" + QString::number(sourceid);
    22622264    select += ';';
    22632265
    22642266    query.prepare(select);
    ChannelInfoList ChannelUtil::LoadChannels(uint startIndex, uint count, 
    24292431    sql += QString("%1 JOIN capturecard ON capturecard.sourceid = channel.sourceid ")
    24302432                   .arg(ignoreUntunable ? "INNER" : "LEFT");
    24312433
    2432     QStringList cond;
     2434    sql += "WHERE channel.deleted IS NULL ";
    24332435    if (ignoreHidden)
    2434         cond << "channel.visible = :VISIBLE ";
     2436        sql += "AND channel.visible = 1 ";
    24352437
    24362438    if (channelGroupID > 0)
    2437         cond << "channelgroup.grpid = :CHANGROUPID ";
     2439        sql += "AND channelgroup.grpid = :CHANGROUPID ";
    24382440
    24392441    if (sourceID > 0)
    2440         cond << "channel.sourceid = :SOURCEID ";
     2442        sql += "AND channel.sourceid = :SOURCEID ";
    24412443
    24422444    if (liveTVOnly)
    2443         cond << "capturecard.livetvorder > 0 ";
    2444 
    2445     if (!cond.isEmpty())
    2446         sql += QString("WHERE %1").arg(cond.join("AND "));
     2445        sql += "AND capturecard.livetvorder > 0 ";
    24472446
    24482447    if (groupBy == kChanGroupByCallsign)
    24492448        sql += "GROUP BY channel.callsign ";
    ChannelInfoList ChannelUtil::LoadChannels(uint startIndex, uint count, 
    24812480
    24822481    query.prepare(sql);
    24832482
    2484     if (ignoreHidden)
    2485         query.bindValue(":VISIBLE", 1);
    2486 
    24872483    if (channelGroupID > 0)
    24882484        query.bindValue(":CHANGROUPID", channelGroupID);
    24892485
  • mythtv/libs/libmythtv/dbcheck.cpp

    diff --git a/mythtv/libs/libmythtv/dbcheck.cpp b/mythtv/libs/libmythtv/dbcheck.cpp
    index 67fa418f8e..d272a6dd96 100644
    a b nullptr 
    34623462            return false;
    34633463    }
    34643464
     3465    if (dbver == "1352")
     3466    {
     3467        const char *updates[] = {
     3468            "ALTER TABLE channel ADD COLUMN deleted TIMESTAMP NULL",
     3469            nullptr
     3470        };
     3471        if (!performActualUpdate(updates, "1353", dbver))
     3472            return false;
     3473    }
     3474
    34653475    return true;
    34663476}
    34673477
  • mythtv/libs/libmythtv/dtvmultiplex.cpp

    diff --git a/mythtv/libs/libmythtv/dtvmultiplex.cpp b/mythtv/libs/libmythtv/dtvmultiplex.cpp
    index 5cd092095b..aedfddc1bb 100644
    a b bool ScanDTVTransport::FillFromDB(DTVTunerType type, uint mplexid) 
    572572        "       d.transportid,   d.networkid,       c.default_authority,"
    573573        "       c.service_type "
    574574        "FROM channel AS c, dtv_multiplex AS d "
    575         "WHERE c.mplexid = :MPLEXID AND"
     575        "WHERE c.deleted IS NULL AND "
     576        "      c.mplexid = :MPLEXID AND"
    576577        "      c.mplexid = d.mplexid");
    577578    query.bindValue(":MPLEXID", mplexid);
    578579
  • mythtv/libs/libmythtv/eithelper.cpp

    diff --git a/mythtv/libs/libmythtv/eithelper.cpp b/mythtv/libs/libmythtv/eithelper.cpp
    index ae60a23b65..9420ce3fb6 100644
    a b static uint get_chan_id_from_db_atsc(uint sourceid, 
    863863    query.prepare(
    864864            "SELECT chanid, useonairguide "
    865865            "FROM channel "
    866             "WHERE atsc_major_chan = :MAJORCHAN AND "
     866            "WHERE deleted         IS NULL AND "
     867            "      atsc_major_chan = :MAJORCHAN AND "
    867868            "      atsc_minor_chan = :MINORCHAN AND "
    868869            "      sourceid        = :SOURCEID");
    869870    query.bindValue(":MAJORCHAN", atsc_major);
    static uint get_chan_id_from_db_dvb(uint sourceid, uint serviceid, 
    893894    QString qstr =
    894895        "SELECT chanid, useonairguide, channel.sourceid "
    895896        "FROM channel, dtv_multiplex "
    896         "WHERE serviceid        = :SERVICEID   AND "
     897        "WHERE deleted          IS NULL        AND "
     898        "      serviceid        = :SERVICEID   AND "
    897899        "      networkid        = :NETWORKID   AND "
    898900        "      transportid      = :TRANSPORTID AND "
    899901        "      channel.mplexid  = dtv_multiplex.mplexid";
    static uint get_chan_id_from_db_dvb(uint sourceid, uint serviceid, 
    912914        qstr =
    913915            "SELECT chanid, useonairguide, channel.sourceid "
    914916            "FROM channel, dtv_multiplex "
    915             "WHERE serviceid        = :SERVICEID   AND "
     917            "WHERE deleted          IS NULL        AND "
     918            "      serviceid        = :SERVICEID   AND "
    916919            "      networkid        = :NETWORKID   AND "
    917920            "      channel.mplexid  = dtv_multiplex.mplexid";
    918921
    static uint get_chan_id_from_db_dtv(uint sourceid, uint serviceid, 
    962965    QString qstr =
    963966        "SELECT c1.chanid, c1.useonairguide, c1.sourceid "
    964967        "FROM channel c1, dtv_multiplex m, channel c2 "
    965         "WHERE c1.serviceid        = :SERVICEID   AND "
     968        "WHERE c1.deleted IS NULL AND "
     969        "      c1.serviceid = :SERVICEID   AND "
    966970        "      c1.mplexid  = m.mplexid AND "
    967971        "      m.mplexid = c2.mplexid AND "
    968972        "      c2.chanid = :CHANID";
  • mythtv/libs/libmythtv/eitscanner.cpp

    diff --git a/mythtv/libs/libmythtv/eitscanner.cpp b/mythtv/libs/libmythtv/eitscanner.cpp
    index 4f9553f66e..817b168946 100644
    a b void EITScanner::StartActiveScan(TVRec *_rec, uint max_seconds_per_source) 
    242242        query.prepare(
    243243            "SELECT channum, MIN(chanid) "
    244244            "FROM channel, capturecard, videosource "
    245             "WHERE capturecard.sourceid = channel.sourceid AND "
     245            "WHERE deleted              IS NULL            AND "
     246            "      capturecard.sourceid = channel.sourceid AND "
    246247            "      videosource.sourceid = channel.sourceid AND "
    247248            "      channel.mplexid        IS NOT NULL      AND "
    248249            "      visible              = 1                AND "
  • mythtv/libs/libmythtv/mhi.cpp

    diff --git a/mythtv/libs/libmythtv/mhi.cpp b/mythtv/libs/libmythtv/mhi.cpp
    index 900fd2260e..abf18ac5cb 100644
    a b bool MHIContext::LoadChannelCache() 
    881881    query.prepare(
    882882        "SELECT networkid, serviceid, transportid, chanid "
    883883        "FROM channel, dtv_multiplex "
    884         "WHERE channel.mplexid  = dtv_multiplex.mplexid "
     884        "WHERE channel.deleted  IS NULL "
     885        "  AND channel.mplexid  = dtv_multiplex.mplexid "
    885886        "  AND channel.sourceid = dtv_multiplex.sourceid "
    886887        "  AND channel.sourceid = :SOURCEID ;" );
    887888    query.bindValue(":SOURCEID", m_currentSource);
    int MHIContext::GetChannelIndex(const QString &str) 
    963964            MSqlQuery query(MSqlQuery::InitCon());
    964965            query.prepare("SELECT chanid "
    965966                          "FROM channel "
    966                           "WHERE channum = :CHAN AND "
     967                          "WHERE deleted IS NULL AND "
     968                          "      channum = :CHAN AND "
    967969                          "      channel.sourceid = :SOURCEID");
    968970            query.bindValue(":CHAN", channelNo);
    969971            query.bindValue(":SOURCEID", m_currentSource);
  • mythtv/libs/libmythtv/programdata.cpp

    diff --git a/mythtv/libs/libmythtv/programdata.cpp b/mythtv/libs/libmythtv/programdata.cpp
    index 3740083bb6..55977a0e57 100644
    a b void ProgramData::HandlePrograms( 
    14741474        query.prepare(
    14751475            "SELECT chanid "
    14761476            "FROM channel "
    1477             "WHERE sourceid = :ID AND "
     1477            "WHERE deleted  IS NULL AND "
     1478            "      sourceid = :ID AND "
    14781479            "      xmltvid  = :XMLTVID");
    14791480        query.bindValue(":ID",      sourceid);
    14801481        query.bindValue(":XMLTVID", mapiter.key());
  • mythtv/libs/libmythtv/recorders/channelbase.cpp

    diff --git a/mythtv/libs/libmythtv/recorders/channelbase.cpp b/mythtv/libs/libmythtv/recorders/channelbase.cpp
    index ebfde88120..a5b830e908 100644
    a b int ChannelBase::GetChanID(void) const 
    492492    MSqlQuery query(MSqlQuery::InitCon());
    493493
    494494    query.prepare("SELECT chanid,visible FROM channel "
    495                   "WHERE channum  = :CHANNUM AND "
     495                  "WHERE deleted  IS NULL AND "
     496                  "      channum  = :CHANNUM AND "
    496497                  "      sourceid = :SOURCEID");
    497498    query.bindValueNoNull(":CHANNUM", m_curchannelname);
    498499    query.bindValue(":SOURCEID", m_sourceid);
    bool ChannelBase::CheckChannel(const QString &channum) const 
    660661    query.prepare(
    661662        "SELECT channel.chanid "
    662663        "FROM channel, capturecard "
    663         "WHERE channel.channum       = :CHANNUM             AND "
     664        "WHERE channel.deleted       IS NULL                AND "
     665        "      channel.channum       = :CHANNUM             AND "
    664666        "      channel.sourceid      = capturecard.sourceid AND "
    665667        "      capturecard.cardid    = :INPUTID             AND "
    666668        "      capturecard.hostname  = :HOSTNAME");
  • mythtv/libs/libmythtv/recorders/dvbchannel.cpp

    diff --git a/mythtv/libs/libmythtv/recorders/dvbchannel.cpp b/mythtv/libs/libmythtv/recorders/dvbchannel.cpp
    index 94d1577930..f6bfd27946 100644
    a b int DVBChannel::GetChanID() const 
    959959
    960960    query.prepare("SELECT chanid,visible "
    961961                  "FROM channel, capturecard "
    962                   "WHERE capturecard.sourceid = channel.sourceid AND "
     962                  "WHERE channel.deleted IS NULL AND "
     963                  "      capturecard.sourceid = channel.sourceid AND "
    963964                  "      channel.channum = :CHANNUM AND "
    964965                  "      capturecard.cardid = :INPUTID");
    965966
  • mythtv/libs/libmythtv/recorders/v4lchannel.cpp

    diff --git a/mythtv/libs/libmythtv/recorders/v4lchannel.cpp b/mythtv/libs/libmythtv/recorders/v4lchannel.cpp
    index 4462e19232..3a2ca73ce5 100644
    a b QString V4LChannel::GetFormatForChannel(const QString& channum, const QString& i 
    481481    query.prepare(
    482482        "SELECT tvformat "
    483483        "FROM channel, capturecard "
    484         "WHERE channum              = :CHANNUM   AND "
     484        "WHERE deleted              IS NULL      AND "
     485        "      channum              = :CHANNUM   AND "
    485486        "      inputname            = :INPUTNAME AND "
    486487        "      capturecard.cardid   = :INPUTID   AND "
    487488        "      capturecard.sourceid = channel.sourceid");
  • mythtv/libs/libmythtv/sourceutil.cpp

    diff --git a/mythtv/libs/libmythtv/sourceutil.cpp b/mythtv/libs/libmythtv/sourceutil.cpp
    index 5313c53913..24b2442ae9 100644
    a b bool SourceUtil::HasDigitalChannel(uint sourceid) 
    1818    query.prepare(
    1919        "SELECT mplexid, atsc_minor_chan, serviceid "
    2020        "FROM channel "
    21         "WHERE sourceid = :SOURCEID");
     21        "WHERE deleted IS NULL AND "
     22        "      sourceid = :SOURCEID");
    2223    query.bindValue(":SOURCEID", sourceid);
    2324
    2425    if (!query.exec())
    QString SourceUtil::GetChannelSeparator(uint sourceid) 
    6970    MSqlQuery query(MSqlQuery::InitCon());
    7071    query.prepare("SELECT channum "
    7172                  "FROM channel "
    72                   "WHERE sourceid = :SOURCEID");
     73                  "WHERE deleted IS NULL AND "
     74                  "      sourceid = :SOURCEID");
    7375    query.bindValue(":SOURCEID", sourceid);
    7476
    7577    if (query.exec() && query.isActive() && query.size() > 0)
    uint SourceUtil::GetChannelCount(uint sourceid) 
    111113    MSqlQuery query(MSqlQuery::InitCon());
    112114    query.prepare("SELECT sum(1) "
    113115                  "FROM channel "
    114                   "WHERE sourceid = :SOURCEID");
     116                  "WHERE deleted IS NULL AND "
     117                  "      sourceid = :SOURCEID");
    115118    query.bindValue(":SOURCEID", sourceid);
    116119    if (query.exec() && query.isActive() && query.next())
    117120        return query.value(0).toUInt();
    bool SourceUtil::IsEncoder(uint sourceid, bool strict) 
    296299    query.prepare(
    297300        "SELECT atsc_minor_chan, serviceid "
    298301        "FROM channel "
    299         "WHERE sourceid = :SOURCEID");
     302        "WHERE deleted IS NULL AND "
     303        "      sourceid = :SOURCEID");
    300304    query.bindValue(":SOURCEID", sourceid);
    301305
    302306    bool has_any_chan = false;
    bool SourceUtil::DeleteSource(uint sourceid) 
    490494    MSqlQuery query(MSqlQuery::InitCon());
    491495
    492496    // Delete the channels associated with the source
    493     query.prepare("DELETE FROM channel "
    494                   "WHERE sourceid = :SOURCEID");
     497    query.prepare("UPDATE channel "
     498                  "SET deleted = NOW() "
     499                  "WHERE deleted IS NULL AND "
     500                  "      sourceid = :SOURCEID");
    495501    query.bindValue(":SOURCEID", sourceid);
    496502
    497503    if (!query.exec() || !query.isActive())
    bool SourceUtil::DeleteSource(uint sourceid) 
    500506        return false;
    501507    }
    502508
    503     // Delete the multiplexes associated with the source
    504     query.prepare("DELETE FROM dtv_multiplex "
    505                   "WHERE sourceid = :SOURCEID");
    506     query.bindValue(":SOURCEID", sourceid);
    507 
    508     if (!query.exec() || !query.isActive())
    509     {
    510         MythDB::DBError("Deleting Multiplexes", query);
    511         return false;
    512     }
    513 
    514509    // Detach the inputs associated with the source
    515510    query.prepare("UPDATE capturecard "
    516511                  "SET sourceid = 0 "
  • mythtv/libs/libmythtv/transporteditor.cpp

    diff --git a/mythtv/libs/libmythtv/transporteditor.cpp b/mythtv/libs/libmythtv/transporteditor.cpp
    index 40ff3582be..c4291a830c 100644
    a b void TransportListEditor::Delete(TransportSetting *transport) 
    316316            if (!query.exec() || !query.isActive())
    317317                MythDB::DBError("TransportEditor -- delete multiplex", query);
    318318
    319             query.prepare("DELETE FROM channel WHERE mplexid = :MPLEXID");
     319            query.prepare("UPDATE channel SET deleted = NOW() "
     320                          "WHERE deleted IS NULL AND mplexid = :MPLEXID");
    320321            query.bindValue(":MPLEXID", mplexid);
    321322
    322323            if (!query.exec() || !query.isActive())
  • mythtv/libs/libmythtv/tv_rec.cpp

    diff --git a/mythtv/libs/libmythtv/tv_rec.cpp b/mythtv/libs/libmythtv/tv_rec.cpp
    index 1c9639f7b4..2706e233be 100644
    a b QString TVRec::GetStartChannel(uint inputid) 
    17451745    query.prepare(
    17461746        "SELECT channum "
    17471747        "FROM capturecard, channel "
    1748         "WHERE channel.sourceid   = capturecard.sourceid AND "
     1748        "WHERE deleted            IS NULL AND "
     1749        "      channel.sourceid   = capturecard.sourceid AND "
    17491750        "      capturecard.cardid = :INPUTID");
    17501751    query.bindValue(":INPUTID",    inputid);
    17511752
    QString TVRec::GetStartChannel(uint inputid) 
    17691770    query.prepare(
    17701771        "SELECT channum, inputname "
    17711772        "FROM capturecard, channel "
    1772         "WHERE channel.sourceid   = capturecard.sourceid AND "
     1773        "WHERE deleted            IS NULL AND "
     1774        "      channel.sourceid   = capturecard.sourceid AND "
    17731775        "      capturecard.cardid = :INPUTID");
    17741776    query.bindValue(":INPUTID", inputid);
    17751777
    bool TVRec::ShouldSwitchToAnotherInput(const QString& chanid) 
    21972199    query.prepare(
    21982200        "SELECT channel.channum "
    21992201        "FROM channel, capturecard "
    2200         "WHERE ( channel.chanid = :CHANID OR             "
     2202        "WHERE deleted IS NULL AND "
     2203        "      ( channel.chanid = :CHANID OR             "
    22012204        "        ( channel.channum  = :CHANNUM AND       "
    22022205        "          channel.callsign = :CALLSIGN    )     "
    22032206        "      )                                     AND "
    bool TVRec::ShouldSwitchToAnotherInput(const QString& chanid) 
    22232226    query.prepare(
    22242227        "SELECT channel.channum, capturecard.cardid "
    22252228        "FROM channel, capturecard "
    2226         "WHERE ( channel.chanid = :CHANID OR              "
     2229        "WHERE deleted IS NULL AND "
     2230        "      ( channel.chanid = :CHANID OR              "
    22272231        "        ( channel.channum  = :CHANNUM AND        "
    22282232        "          channel.callsign = :CALLSIGN    )      "
    22292233        "      )                                      AND "
    bool TVRec::CheckChannelPrefix(const QString &prefix, 
    23232327    QString basequery = QString(
    23242328        "SELECT channel.chanid, channel.channum, capturecard.cardid "
    23252329        "FROM channel, capturecard "
    2326         "WHERE channel.channum LIKE '%1%'            AND "
     2330        "WHERE deleted IS NULL AND "
     2331        "      channel.channum LIKE '%1%'            AND "
    23272332        "      channel.sourceid = capturecard.sourceid");
    23282333
    23292334    QString inputquery[2] =
  • mythtv/programs/mythbackend/backendhousekeeper.cpp

    diff --git a/mythtv/programs/mythbackend/backendhousekeeper.cpp b/mythtv/programs/mythbackend/backendhousekeeper.cpp
    index 526d34902d..082c962dc6 100644
    a b bool CleanupTask::DoRun(void) 
    115115    CleanupInUsePrograms();
    116116    CleanupOrphanedLiveTV();
    117117    CleanupRecordedTables();
     118    CleanupChannelTables();
    118119    CleanupProgramListings();
    119120    return true;
    120121}
    void CleanupTask::CleanupRecordedTables(void) 
    277278                                "(deleting temporary table)", query);
    278279}
    279280
     281void CleanupTask::CleanupChannelTables(void)
     282{
     283    MSqlQuery query(MSqlQuery::InitCon());
     284    MSqlQuery deleteQuery(MSqlQuery::InitCon());
     285
     286    query.prepare(QString("DELETE channel "
     287                          "FROM channel "
     288                          "LEFT JOIN recorded r "
     289                          "    ON r.chanid = channel.chanid "
     290                          "LEFT JOIN oldrecorded o "
     291                          "    ON o.chanid = channel.chanid "
     292                          "WHERE channel.deleted IS NOT NULL "
     293                          "      AND channel.deleted < "
     294                          "          DATE_SUB(NOW(), INTERVAL 1 DAY) "
     295                          "      AND r.chanid IS NULL "
     296                          "      AND o.chanid IS NULL"));
     297    if (!query.exec())
     298        MythDB::DBError("CleanupTask::CleanupChannelTables "
     299                        "(channel table)", query);
     300
     301    query.prepare(QString("DELETE dtv_multiplex "
     302                          "FROM dtv_multiplex "
     303                          "LEFT JOIN channel c "
     304                          "    ON c.mplexid = dtv_multiplex.mplexid "
     305                          "WHERE c.chanid IS NULL"));
     306    if (!query.exec())
     307        MythDB::DBError("CleanupTask::CleanupChannelTables "
     308                        "(dtv_multiplex table)", query);
     309}
     310
    280311void CleanupTask::CleanupProgramListings(void)
    281312{
    282313    MSqlQuery query(MSqlQuery::InitCon());
  • mythtv/programs/mythbackend/backendhousekeeper.h

    diff --git a/mythtv/programs/mythbackend/backendhousekeeper.h b/mythtv/programs/mythbackend/backendhousekeeper.h
    index 59dc8a476b..b48a54e4be 100644
    a b class CleanupTask : public DailyHouseKeeperTask 
    2323    void CleanupInUsePrograms(void);
    2424    void CleanupOrphanedLiveTV(void);
    2525    void CleanupRecordedTables(void);
     26    void CleanupChannelTables(void);
    2627    void CleanupProgramListings(void);
    2728};
    2829
  • mythtv/programs/mythbackend/mainserver.cpp

    diff --git a/mythtv/programs/mythbackend/mainserver.cpp b/mythtv/programs/mythbackend/mainserver.cpp
    index a9b044217e..002f18f4bb 100644
    a b QString MainServer::LocalFilePath(const QString &path, const QString &wantgroup) 
    80908090        lpath = "";
    80918091
    80928092        MSqlQuery query(MSqlQuery::InitCon());
    8093         query.prepare("SELECT icon FROM channel WHERE icon LIKE :FILENAME ;");
     8093        query.prepare("SELECT icon FROM channel "
     8094                      "WHERE deleted IS NULL AND icon LIKE :FILENAME ;");
    80948095        query.bindValue(":FILENAME", QString("%/") + file);
    80958096
    80968097        if (query.exec() && query.next())
  • mythtv/programs/mythbackend/scheduler.cpp

    diff --git a/mythtv/programs/mythbackend/scheduler.cpp b/mythtv/programs/mythbackend/scheduler.cpp
    index c65c6a3f34..659e6f319f 100644
    a b void Scheduler::UpdateManuals(uint recordid) 
    37213721                  query.value(6).toTime(), Qt::UTC));
    37223722
    37233723    query.prepare("SELECT chanid from channel "
    3724                   "WHERE callsign = :STATION");
     3724                  "WHERE deleted IS NULL AND callsign = :STATION");
    37253725    query.bindValue(":STATION", station);
    37263726    if (!query.exec())
    37273727    {
    void Scheduler::UpdateMatches(uint recordid, uint sourceid, uint mplexid, 
    40784078"FROM (RECTABLE, program INNER JOIN channel "
    40794079"      ON channel.chanid = program.chanid) ") + fromclauses[clause] + QString(
    40804080" WHERE ") + whereclauses[clause] +
    4081     QString(" AND channel.visible = 1 ") +
     4081    QString(" AND channel.deleted IS NULL "
     4082            " AND channel.visible = 1 ") +
    40824083    filterClause + QString(" AND "
    40834084
    40844085"("
    void Scheduler::GetAllScheduled(RecList &proglist, SchedSortColumn sortBy, 
    49134914        "       channel.commmethod                      " // 25
    49144915        "FROM record "
    49154916        "LEFT JOIN channel ON channel.callsign = record.station "
     4917        "WHERE deleted IS NULL "
    49164918        "GROUP BY recordid "
    49174919        "ORDER BY %1 %2");
    49184920
  • mythtv/programs/mythbackend/services/guide.cpp

    diff --git a/mythtv/programs/mythbackend/services/guide.cpp b/mythtv/programs/mythbackend/services/guide.cpp
    index 8ba90868d6..e9d2464891 100644
    a b DTC::ProgramList* Guide::GetProgramList(int nStartIndex, 
    224224                + sSQL
    225225                + "oldprogram.oldtitle IS NULL AND ";
    226226
     227    sSQL += "deleted IS NULL AND ";
     228
    227229    if (!bWithInvisible)
    228230        sSQL += "visible != 0 AND ";
    229231
  • mythtv/programs/mythfilldatabase/filldata.cpp

    diff --git a/mythtv/programs/mythfilldatabase/filldata.cpp b/mythtv/programs/mythfilldatabase/filldata.cpp
    index b8141fe7eb..b9383ed3cf 100644
    a b bool FillData::Run(SourceList &sourcelist) 
    260260            continue;
    261261        }
    262262
    263         query.prepare("SELECT MAX(endtime) FROM program p LEFT JOIN channel c "
    264                       "ON p.chanid=c.chanid WHERE c.sourceid= :SRCID "
    265                       "AND manualid = 0 AND c.xmltvid != '';");
     263        query.prepare("SELECT MAX(endtime) "
     264                      "FROM program p "
     265                      "LEFT JOIN channel c ON p.chanid=c.chanid "
     266                      "WHERE c.deleted IS NULL AND c.sourceid= :SRCID "
     267                      "      AND manualid = 0 AND c.xmltvid != '';");
    266268        query.bindValue(":SRCID", (*it).id);
    267269
    268270        if (query.exec() && query.next())
    bool FillData::Run(SourceList &sourcelist) 
    305307                                  .arg(xmltv_grabber));
    306308
    307309        query.prepare(
    308             "SELECT COUNT(chanid) FROM channel WHERE sourceid = "
    309              ":SRCID AND xmltvid != ''");
     310            "SELECT COUNT(chanid) FROM channel "
     311            "WHERE deleted IS NULL AND "
     312            "      sourceid = :SRCID AND xmltvid != ''");
    310313        query.bindValue(":SRCID", (*it).id);
    311314
    312315        if (query.exec() && query.next())
    bool FillData::Run(SourceList &sourcelist) 
    481484                                   "INTERVAL '%1' DAY), INTERVAL '20' HOUR) "
    482485                               "  AND starttime < DATE_ADD(CURRENT_DATE(), "
    483486                                   "INTERVAL '%2' DAY) "
    484                                "WHERE c.sourceid = %3 AND c.xmltvid != '' "
     487                               "WHERE c.deleted IS NULL AND c.sourceid = %3 AND c.xmltvid != '' "
    485488                               "GROUP BY c.chanid;";
    486489
    487490                    if (query.exec(querystr.arg(i-1).arg(i).arg((*it).id)) &&
    bool FillData::Run(SourceList &sourcelist) 
    650653            break;
    651654        }
    652655
    653         query.prepare("SELECT MAX(endtime) FROM program p LEFT JOIN channel c "
    654                       "ON p.chanid=c.chanid WHERE c.sourceid= :SRCID "
     656        query.prepare("SELECT MAX(endtime) FROM program p "
     657                      "LEFT JOIN channel c ON p.chanid=c.chanid "
     658                      "WHERE c.deleted IS NULL AND c.sourceid= :SRCID "
    655659                      "AND manualid = 0 AND c.xmltvid != '';");
    656660        query.bindValue(":SRCID", (*it).id);
    657661
  • mythtv/programs/mythfilldatabase/main.cpp

    diff --git a/mythtv/programs/mythfilldatabase/main.cpp b/mythtv/programs/mythfilldatabase/main.cpp
    index 1ee7370865..cce54ab65d 100644
    a b int main(int argc, char *argv[]) 
    290290        updateLastRunStatus(status);
    291291
    292292        MSqlQuery query(MSqlQuery::InitCon());
    293         query.prepare("SELECT MAX(endtime) FROM program p LEFT JOIN channel c "
    294                       "ON p.chanid=c.chanid WHERE c.sourceid= :SRCID "
     293        query.prepare("SELECT MAX(endtime) FROM program p "
     294                      "LEFT JOIN channel c ON p.chanid=c.chanid "
     295                      "WHERE c.deleted IS NULL AND c.sourceid= :SRCID "
    295296                      "AND manualid = 0 AND c.xmltvid != '';");
    296297        query.bindValue(":SRCID", fromfile_id);
    297298
    int main(int argc, char *argv[]) 
    309310
    310311        updateLastRunEnd();
    311312
    312         query.prepare("SELECT MAX(endtime) FROM program p LEFT JOIN channel c "
    313                       "ON p.chanid=c.chanid WHERE c.sourceid= :SRCID "
     313        query.prepare("SELECT MAX(endtime) FROM program p "
     314                      "LEFT JOIN channel c ON p.chanid=c.chanid "
     315                      "WHERE c.deleted IS NULL AND c.sourceid= :SRCID "
    314316                      "AND manualid = 0 AND c.xmltvid != '';");
    315317        query.bindValue(":SRCID", fromfile_id);
    316318
    int main(int argc, char *argv[]) 
    554556                    "      FROM program p, channel c "
    555557                    "      WHERE p.programid <> '' "
    556558                    "            AND p.chanid = c.chanid "
     559                    "            AND c.deleted IS NULL "
    557560                    "            AND c.visible = 1 "
    558561                    "      GROUP BY p.programid "
    559562                    "     ) AS firsts "
    int main(int argc, char *argv[]) 
    570573                    "      FROM program p, channel c "
    571574                    "      WHERE p.programid = '' "
    572575                    "            AND p.chanid = c.chanid "
     576                    "            AND c.deleted IS NULL "
    573577                    "            AND c.visible = 1 "
    574578                    "      GROUP BY p.title, p.subtitle, partdesc "
    575579                    "     ) AS firsts "
    int main(int argc, char *argv[]) 
    590594                    "      FROM program p, channel c "
    591595                    "      WHERE p.programid <> '' "
    592596                    "            AND p.chanid = c.chanid "
     597                    "            AND c.deleted IS NULL "
    593598                    "            AND c.visible = 1 "
    594599                    "      GROUP BY p.programid "
    595600                    "     ) AS lasts "
    int main(int argc, char *argv[]) 
    606611                    "      FROM program p, channel c "
    607612                    "      WHERE p.programid = '' "
    608613                    "            AND p.chanid = c.chanid "
     614                    "            AND c.deleted IS NULL "
    609615                    "            AND c.visible = 1 "
    610616                    "      GROUP BY p.title, p.subtitle, partdesc "
    611617                    "     ) AS lasts "
  • mythtv/programs/mythfrontend/channelrecpriority.cpp

    diff --git a/mythtv/programs/mythfrontend/channelrecpriority.cpp b/mythtv/programs/mythfrontend/channelrecpriority.cpp
    index 5c06147444..718c576711 100644
    a b void ChannelRecPriority::FillList(void) 
    251251        }
    252252    }
    253253    result.prepare("SELECT chanid, channum, sourceid, callsign, "
    254                    "icon, recpriority, name FROM channel WHERE visible=1;");
     254                   "icon, recpriority, name FROM channel "
     255                   "WHERE deleted IS NULL AND visible = 1");
    255256
    256257    if (result.exec())
    257258    {
  • mythtv/programs/mythfrontend/globalsettings.cpp

    diff --git a/mythtv/programs/mythfrontend/globalsettings.cpp b/mythtv/programs/mythfrontend/globalsettings.cpp
    index 9dc4afedab..99c3ed61b5 100644
    a b void ChannelGroupSetting::Load() 
    47014701        "SELECT channel.chanid, channum, name, grpid FROM channel "
    47024702        "LEFT JOIN channelgroup "
    47034703        "ON (channel.chanid = channelgroup.chanid AND grpid = :GRPID) "
     4704        "WHERE deleted IS NULL "
    47044705        "ORDER BY channum+0; "; //to order by numeric value of channel number
    47054706
    47064707    query.prepare(qstr);
  • mythtv/programs/mythfrontend/networkcontrol.cpp

    diff --git a/mythtv/programs/mythfrontend/networkcontrol.cpp b/mythtv/programs/mythfrontend/networkcontrol.cpp
    index e344e29270..256dcdb819 100644
    a b QString NetworkControl::listChannels(const uint start, const uint limit) const 
    17421742    if (sqlStart > 0)
    17431743        sqlStart--;
    17441744
    1745     queryStr = "select chanid, callsign, name from channel where visible=1";
    1746     queryStr += " ORDER BY callsign";
     1745    queryStr = "select chanid, callsign, name from channel "
     1746        "where deleted IS NULL and visible = 1 "
     1747        "ORDER BY callsign";
    17471748
    17481749    if (limit > 0)  // only if a limit is specified, we limit the results
    17491750    {
  • mythtv/programs/mythfrontend/progfind.cpp

    diff --git a/mythtv/programs/mythfrontend/progfind.cpp b/mythtv/programs/mythfrontend/progfind.cpp
    index 9cd6766300..55a4884f89 100644
    a b void ProgFinder::selectShowData(QString progTitle, int newCurShow) 
    509509    MSqlBindings bindings;
    510510    QString querystr = "WHERE program.title = :TITLE "
    511511                       "  AND program.endtime > :ENDTIME "
     512                       "  AND channel.deleted IS NULL "
    512513                       "  AND channel.visible = 1 ";
    513514    bindings[":TITLE"] = progTitle;
    514515    bindings[":ENDTIME"] = progStart.addSecs(50 - progStart.time().second());
    void ProgFinder::whereClauseGetSearchData(QString &where, MSqlBindings &bindings 
    546547    {
    547548        where = "SELECT DISTINCT title FROM program "
    548549                "LEFT JOIN channel ON program.chanid = channel.chanid "
    549                 "WHERE channel.visible = 1 AND "
     550                "WHERE channel.deleted IS NULL AND "
     551                "      channel.visible = 1 AND "
    550552                "( title NOT REGEXP '^[A-Z0-9]' AND "
    551553                "  title NOT REGEXP '^The [A-Z0-9]' AND "
    552554                "  title NOT REGEXP '^A [A-Z0-9]' AND "
    void ProgFinder::whereClauseGetSearchData(QString &where, MSqlBindings &bindings 
    572574
    573575        where = "SELECT DISTINCT title FROM program "
    574576                "LEFT JOIN channel ON program.chanid = channel.chanid "
    575                 "WHERE channel.visible = 1 "
     577                "WHERE channel.deleted IS NULL "
     578                "AND   channel.visible = 1 "
    576579                "AND ( title LIKE :ONE OR title LIKE :TWO "
    577580                "      OR title LIKE :THREE "
    578581                "      OR title LIKE :FOUR ) "
    void JaProgFinder::whereClauseGetSearchData(QString &where, MSqlBindings &bindin 
    736739
    737740    where = "SELECT DISTINCT title FROM program "
    738741            "LEFT JOIN channel ON program.chanid = channel.chanid "
    739             "WHERE channel.visible = 1 ";
     742            "WHERE channel.deleted IS NULL AND channel.visible = 1 ";
    740743
    741744    switch (charNum) {
    742745    case 0:
    void HeProgFinder::whereClauseGetSearchData(QString &where, MSqlBindings &bindin 
    858861
    859862    where = "SELECT DISTINCT title FROM program "
    860863            "LEFT JOIN channel ON program.chanid = channel.chanid "
    861             "WHERE channel.visible = 1 ";
     864            "WHERE channel.deleted IS NULL AND channel.visible = 1 ";
    862865
    863866    if (searchChar.contains('E'))
    864867    {
    void RuProgFinder::whereClauseGetSearchData(QString &where, MSqlBindings 
    974977   {
    975978       where = "SELECT DISTINCT title FROM program "
    976979               "LEFT JOIN channel ON program.chanid = channel.chanid "
    977                "WHERE channel.visible = 1 AND "
     980               "WHERE channel.deleted IS NULL AND "
     981               "      channel.visible = 1 AND "
    978982               "( "
    979983                  "title NOT REGEXP '^[A-Z0-9]' AND "
    980984                  "title NOT REGEXP '^The [A-Z0-9]' AND "
    void RuProgFinder::whereClauseGetSearchData(QString &where, MSqlBindings 
    10021006
    10031007       where = "SELECT DISTINCT title FROM program "
    10041008               "LEFT JOIN channel ON program.chanid = channel.chanid "
    1005                "WHERE channel.visible = 1 "
     1009               "WHERE channel.deleted IS NULL "
     1010               "AND   channel.visible = 1 "
    10061011               "AND ( title LIKE :ONE OR title LIKE :TWO "
    10071012               "      OR title LIKE :THREE "
    10081013               "      OR title LIKE :FOUR  "
  • mythtv/programs/mythfrontend/proglist.cpp

    diff --git a/mythtv/programs/mythfrontend/proglist.cpp b/mythtv/programs/mythfrontend/proglist.cpp
    index 34142e2fd5..9213dfe796 100644
    a b void ProgLister::FillItemList(bool restorePosition, bool updateDisp) 
    10961096
    10971097    if (m_type == plTitle) // per title listings
    10981098    {
    1099         where = "WHERE channel.visible = 1 "
     1099        where = "WHERE channel.deleted IS NULL "
     1100            "  AND channel.visible = 1 "
    11001101            "  AND program.endtime > :PGILSTART "
    11011102            "  AND (program.title = :PGILPHRASE0 OR "
    11021103            "       (program.seriesid <> '' AND "
    void ProgLister::FillItemList(bool restorePosition, bool updateDisp) 
    11081109    {
    11091110        where = "LEFT JOIN oldprogram ON "
    11101111            "  oldprogram.oldtitle = program.title "
    1111             "WHERE channel.visible = 1 "
     1112            "WHERE channel.deleted IS NULL "
     1113            "  AND channel.visible = 1 "
    11121114            "  AND program.endtime > :PGILSTART "
    11131115            "  AND oldprogram.oldtitle IS NULL "
    11141116            "  AND program.manualid = 0 ";
    void ProgLister::FillItemList(bool restorePosition, bool updateDisp) 
    11451147    }
    11461148    else if (m_type == plTitleSearch) // keyword search
    11471149    {
    1148         where = "WHERE channel.visible = 1 "
     1150        where = "WHERE channel.deleted IS NULL "
     1151            "  AND channel.visible = 1 "
    11491152            "  AND program.endtime > :PGILSTART "
    11501153            "  AND program.title LIKE :PGILLIKEPHRASE0 ";
    11511154        bindings[":PGILLIKEPHRASE0"] = QString("%") + qphrase + '%';
    11521155    }
    11531156    else if (m_type == plKeywordSearch) // keyword search
    11541157    {
    1155         where = "WHERE channel.visible = 1 "
     1158        where = "WHERE channel.deleted IS NULL "
     1159            "  AND channel.visible = 1 "
    11561160            "  AND program.endtime > :PGILSTART "
    11571161            "  AND (program.title LIKE :PGILLIKEPHRASE1 "
    11581162            "    OR program.subtitle LIKE :PGILLIKEPHRASE2 "
    void ProgLister::FillItemList(bool restorePosition, bool updateDisp) 
    11631167    }
    11641168    else if (m_type == plPeopleSearch) // people search
    11651169    {
    1166         where = ", people, credits WHERE channel.visible = 1 "
     1170        where = ", people, credits "
     1171            "WHERE channel.deleted IS NULL "
     1172            "  AND channel.visible = 1 "
    11671173            "  AND program.endtime > :PGILSTART "
    11681174            "  AND people.name LIKE :PGILPHRASE1 "
    11691175            "  AND credits.person = people.person "
    void ProgLister::FillItemList(bool restorePosition, bool updateDisp) 
    11851191                                "program.chanid = programgenres.chanid AND "
    11861192                                "program.starttime = programgenres.starttime ");
    11871193
    1188             where += QString("WHERE channel.visible = 1 "
     1194            where += QString("WHERE channel.deleted IS NULL "
     1195                             "  AND channel.visible = 1 "
    11891196                             "  AND program.endtime > :PGILSTART "
    11901197                             "  AND ( ") + powerWhere + " ) ";
    11911198            MSqlAddMoreBindings(bindings, powerBindings);
    void ProgLister::FillItemList(bool restorePosition, bool updateDisp) 
    11941201    else if (m_type == plSQLSearch) // complex search
    11951202    {
    11961203        qphrase.remove(QRegExp("^\\s*AND\\s+", Qt::CaseInsensitive));
    1197         where = QString("WHERE channel.visible = 1 "
     1204        where = QString("WHERE channel.deleted iS NULL "
     1205                        "  AND channel.visible = 1 "
    11981206                        "  AND program.endtime > :PGILSTART "
    11991207                        "  AND ( %1 ) ").arg(qphrase);
    12001208        if (!m_extraArg.isEmpty())
    void ProgLister::FillItemList(bool restorePosition, bool updateDisp) 
    12021210    }
    12031211    else if (m_type == plChannel) // list by channel
    12041212    {
    1205         where = "WHERE channel.visible = 1 "
     1213        where = "WHERE channel.deleted IS NULL "
     1214            "  AND channel.visible = 1 "
    12061215            "  AND program.endtime > :PGILSTART "
    12071216            "  AND channel.chanid = :PGILPHRASE2 ";
    12081217        bindings[":PGILPHRASE2"] = qphrase;
    void ProgLister::FillItemList(bool restorePosition, bool updateDisp) 
    12111220    {
    12121221        if (!m_useGenres)
    12131222        {
    1214             where = "WHERE channel.visible = 1 "
     1223            where = "WHERE channel.deleted IS NULL "
     1224                "  AND channel.visible = 1 "
    12151225                "  AND program.endtime > :PGILSTART "
    12161226                "  AND program.category = :PGILPHRASE3 ";
    12171227            bindings[":PGILPHRASE3"] = qphrase;
    void ProgLister::FillItemList(bool restorePosition, bool updateDisp) 
    12221232                "  program.chanid = g.chanid AND "
    12231233                "  program.starttime = g.starttime AND "
    12241234                "  genre = :PGILPHRASE4 "
    1225                 "WHERE channel.visible = 1 "
     1235                "WHERE channel.deleted IS NULL "
     1236                "  AND channel.visible = 1 "
    12261237                "  AND program.endtime > :PGILSTART ";
    12271238            bindings[":PGILPHRASE4"] = qphrase;
    12281239        }
    void ProgLister::FillItemList(bool restorePosition, bool updateDisp) 
    12361247                "  program.chanid = g2.chanid AND "
    12371248                "  program.starttime = g2.starttime AND "
    12381249                "  g2.genre = :GENRE2 "
    1239                 "WHERE channel.visible = 1 "
     1250                "WHERE channel.deleted IS NULL "
     1251                "  AND channel.visible = 1 "
    12401252                "  AND program.endtime > :PGILSTART ";
    12411253            bindings[":GENRE1"] = m_viewList[m_curView].section(":/:", 0, 0);
    12421254            bindings[":GENRE2"] = m_viewList[m_curView].section(":/:", 1, 1);
    void ProgLister::FillItemList(bool restorePosition, bool updateDisp) 
    12441256    }
    12451257    else if (m_type == plMovies) // list movies
    12461258    {
    1247         where = "WHERE channel.visible = 1 "
     1259        where = "WHERE channel.deleted IS NULL "
     1260            "  AND channel.visible = 1 "
    12481261            "  AND program.endtime > :PGILSTART "
    12491262            "  AND program.category_type = 'movie' "
    12501263            "  AND program.stars " + qphrase + ' ';
    void ProgLister::FillItemList(bool restorePosition, bool updateDisp) 
    12541267        QDateTime searchTime(m_searchTime);
    12551268        searchTime.setTime(QTime(searchTime.time().hour(), 0, 0));
    12561269        bindings[":PGILSEARCHTIME1"] = searchTime;
    1257         where = "WHERE channel.visible = 1 "
     1270        where = "WHERE channel.deleted IS NULL "
     1271            "  AND channel.visible = 1 "
    12581272            "  AND program.starttime >= :PGILSEARCHTIME1 ";
    12591273        if (m_titleSort)
    12601274        {
    void ProgLister::FillItemList(bool restorePosition, bool updateDisp) 
    12681282        where = "JOIN recordmatch ON "
    12691283            " (program.starttime = recordmatch.starttime "
    12701284            "  AND program.chanid = recordmatch.chanid) "
    1271             "WHERE channel.visible = 1 "
     1285            "WHERE channel.deleted IS NULL "
     1286            "  AND channel.visible = 1 "
    12721287            "  AND program.endtime > :PGILSTART "
    12731288            "  AND recordmatch.recordid = :PGILPHRASE5 ";
    12741289        bindings[":PGILPHRASE5"] = qphrase;
    void ProgLister::FillItemList(bool restorePosition, bool updateDisp) 
    12851300            QString fromc = query.value(0).toString();
    12861301            QString wherec = query.value(1).toString();
    12871302
    1288             where = QString("WHERE channel.visible = 1 "
     1303            where = QString("WHERE channel.deleted IS NULL "
     1304                            "  AND channel.visible = 1 "
    12891305                            "  AND program.endtime > :PGILSTART "
    12901306                            "  AND ( %1 ) ").arg(wherec);
    12911307            if (!fromc.isEmpty())
  • mythtv/programs/mythtv-setup/channeleditor.cpp

    diff --git a/mythtv/programs/mythtv-setup/channeleditor.cpp b/mythtv/programs/mythtv-setup/channeleditor.cpp
    index e8e0984af4..9a13b4775b 100644
    a b void ChannelEditor::fillList(void) 
    252252                       "LEFT JOIN videosource ON "
    253253                       "(channel.sourceid = videosource.sourceid) "
    254254                       "LEFT JOIN dtv_multiplex ON "
    255                        "(channel.mplexid = dtv_multiplex.mplexid)";
     255                       "(channel.mplexid = dtv_multiplex.mplexid) "
     256                       "WHERE deleted IS NULL ";
    256257
    257258    if (m_sourceFilter == FILTER_ALL)
    258259    {
    void ChannelEditor::fillList(void) 
    260261    }
    261262    else
    262263    {
    263         querystr += QString(" WHERE channel.sourceid='%1' ")
     264        querystr += QString("AND channel.sourceid='%1' ")
    264265                           .arg(m_sourceFilter);
    265266        fAllSources = false;
    266267    }
    void ChannelEditor::customEvent(QEvent *event) 
    710711                else
    711712                {
    712713                    tmp = tmp.left(tmp.length() - 1);
    713                     query.prepare(QString("DELETE FROM channel "
    714                     "WHERE sourceid NOT IN (%1)").arg(tmp));
     714                    query.prepare(QString("UPDATE channel "
     715                    "SET deleted = NOW() "
     716                    "WHERE deleted IS NULL AND "
     717                    "      sourceid NOT IN (%1)").arg(tmp));
    715718                }
    716719            }
    717720            else
    718721            {
    719                 query.prepare("DELETE FROM channel "
    720                 "WHERE sourceid = :SOURCEID");
     722                query.prepare("UPDATE channel "
     723                "SET deleted = NOW() "
     724                "WHERE deleted IS NULL AND sourceid = :SOURCEID");
    721725                query.bindValue(":SOURCEID", m_sourceFilter);
    722726            }
    723727
  • mythtv/programs/mythtv-setup/checksetup.cpp

    diff --git a/mythtv/programs/mythtv-setup/checksetup.cpp b/mythtv/programs/mythtv-setup/checksetup.cpp
    index c1301289d1..9c76541b93 100644
    a b bool checkChannelPresets(QStringList &probs) 
    212212        MSqlQuery channelExists(MSqlQuery::InitCon());
    213213        QString   channelQuery;
    214214        channelQuery = QString("SELECT chanid FROM channel"
    215                                " WHERE channum='%1' AND sourceid=%2;")
     215                               " WHERE deleted IS NULL AND "
     216                               "       channum = '%1' AND "
     217                               "       sourceid = %2;")
    216218                              .arg(startchan).arg(sourceid);
    217219        channelExists.prepare(channelQuery);
    218220
  • mythtv/programs/mythtv-setup/importicons.cpp

    diff --git a/mythtv/programs/mythtv-setup/importicons.cpp b/mythtv/programs/mythtv-setup/importicons.cpp
    index 6774814d4d..5c0d7f1235 100644
    a b bool ImportIconsWizard::initialLoad(const QString& name) 
    287287                        "dtv_multiplex.mplexid, channel.icon, channel.visible "
    288288                        "FROM channel LEFT JOIN dtv_multiplex "
    289289                        "ON channel.mplexid = dtv_multiplex.mplexid "
    290                         "WHERE ");
     290                        "WHERE deleted IS NULL AND ");
    291291    if (!name.isEmpty())
    292292        querystring.append("name=\"" + name + "\"");
    293293    else
  • mythtv/programs/mythutil/eitutils.cpp

    diff --git a/mythtv/programs/mythutil/eitutils.cpp b/mythtv/programs/mythutil/eitutils.cpp
    index 9422c7cc57..fb2e43ac48 100644
    a b static int ClearEIT(const MythUtilCommandLineParser &cmdline) 
    3232
    3333        // delete program for all channels that use EIT on sources that use EIT
    3434        sql = "DELETE FROM program WHERE chanid IN ("
    35               "SELECT chanid FROM channel WHERE useonairguide=1 AND sourceid IN ("
     35              "SELECT chanid FROM channel "
     36              "WHERE deleted IS NULL AND "
     37              "      useonairguide = 1 AND "
     38              "      sourceid IN ("
    3639              "SELECT sourceid FROM videosource WHERE useeit=1";
    3740        if (-1 != sourceid)
    3841        {
    static int ClearEIT(const MythUtilCommandLineParser &cmdline) 
    5457
    5558        // delete programrating for all channels that use EIT on sources that use EIT
    5659        sql = "DELETE FROM programrating WHERE chanid IN ("
    57               "SELECT chanid FROM channel WHERE useonairguide=1 AND sourceid IN ("
     60              "SELECT chanid FROM channel "
     61              "WHERE deleted IS NULL AND "
     62              "      useonairguide = 1 AND "
     63              "      sourceid IN ("
    5864              "SELECT sourceid FROM videosource WHERE useeit=1";
    5965        if (-1 != sourceid)
    6066        {
    static int ClearEIT(const MythUtilCommandLineParser &cmdline) 
    7682
    7783        // delete credits for all channels that use EIT on sources that use EIT
    7884        sql = "DELETE FROM credits WHERE chanid IN ("
    79               "SELECT chanid FROM channel WHERE useonairguide=1 AND sourceid IN ("
     85              "SELECT chanid FROM channel "
     86              "WHERE deleted IS NULL AND "
     87              "      useonairguide = 1 AND "
     88              "      sourceid IN ("
    8089              "SELECT sourceid FROM videosource WHERE useeit=1";
    8190        if (-1 != sourceid)
    8291        {
    static int ClearEIT(const MythUtilCommandLineParser &cmdline) 
    98107
    99108        // delete program genres for all channels that use EIT on sources that use EIT
    100109        sql = "DELETE FROM programgenres WHERE chanid IN ("
    101               "SELECT chanid FROM channel WHERE useonairguide=1 AND sourceid IN ("
     110              "SELECT chanid FROM channel "
     111              "WHERE deleted IS NULL AND "
     112              "      useonairguide = 1 AND "
     113              "      sourceid IN ("
    102114              "SELECT sourceid FROM videosource WHERE useeit=1";
    103115        if (-1 != sourceid)
    104116        {