Ticket #2320: watched_flag.diff

File watched_flag.diff, 21.9 KB (added by stuartm, 18 years ago)
  • themes/G.A.N.T./ui.xml

     
    13151315      </image>
    13161316      <image name="hdtv" draworder="6">
    13171317        <filename>type/hd.png</filename>
    1318         <position>275,195</position>
     1318        <position>265,195</position>
    13191319      </image>
     1320      <image name="watched" draworder="6">
     1321          <filename>type/watched.png</filename>
     1322          <position>300,195</position>
     1323      </image>
    13201324
    13211325
    13221326    </container>
  • themes/default/watched.png

     
     1‰PNG
     2
     3
  • themes/blue/ui.xml

    IHDR  szzôbKGDÞg:è	pHYs
    
    šœtIMEÖ	0
    îtEXtCommentCreated with GIMPWºIDATXÃí—QÃ0Cí(7ØýϚ}UZ5BÁéZ€•ßð\jB€:gC`Ò
    “"§sôDÆØë‘ôX‰
    ‹
    ˆ©Ü®€C‘‰DŽÐ²"³
    •kÁáùEŒ/"a媜ق«£­Úÿê}©
    M±q¹ùß*т§€§€Úœ^>gp-z{eŠÈpL,Ós•Û
    à#ÀZCèYçÙšrЭYPw„$g¯d‘i·rd®ÒV\â]PâetéÛðöx
    QqLoà¥IEND®B`‚
    \ No newline at end of file
    
    Property changes on: themes/default/watched.png
    ___________________________________________________________________
    Name: svn:mime-type
       + image/png
    
     
    883883        <filename>type/hd.png</filename>
    884884        <position>257,106</position>
    885885      </image>
     886      <image name="watched" draworder="6">
     887          <filename>type/watched.png</filename>
     888          <position>302,106</position>
     889      </image>
    886890
    887891      <image name="processing" draworder="6">
    888892        <filename>processing.png</filename>
  • themes/defaultosd/osd.xml

     
    273273      <font>infofont</font>
    274274      <altfont>infofontgray</altfont>
    275275    </textarea>
     276    <textarea name="option5">
     277      <area>85,420,470,30</area>
     278      <font>infofont</font>
     279      <altfont>infofontgray</altfont>
     280    </textarea>
    276281    <positionrects name="selector"> <!-- draws a white rectangle at these
    277282                                         coords indicating the current
    278283                                         selection -->
  • themes/blueosd/osd.xml

     
    310310      <font>infofont</font>
    311311      <altfont>infofontgray</altfont>
    312312    </textarea>
     313    <textarea name="option5">
     314      <area>85,420,470,30</area>
     315      <font>infofont</font>
     316      <altfont>infofontgray</altfont>
     317    </textarea>
    313318    <positionrects name="selector">
    314319      <area>80,296,480,30</area>
    315320      <area>80,326,480,30</area>
  • libs/libmythtv/NuppelVideoPlayer.cpp

     
    36313631                "Audio buffer overflow, audio data lost!");
    36323632}
    36333633
     3634void NuppelVideoPlayer::SetWatched(bool forceWatched)
     3635{
     3636    if (!m_playbackinfo)
     3637        return;
     3638
     3639    int numFrames = totalFrames;
     3640
     3641    if (m_playbackinfo->GetTranscodedStatus() != TRANSCODING_COMPLETE)
     3642        numFrames = (m_playbackinfo->endts.toTime_t() -
     3643                    m_playbackinfo->recstartts.toTime_t()) * video_frame_rate;
     3644
     3645    int offset = (int) round(0.2 * (numFrames / video_frame_rate));
     3646
     3647    if (offset < 300)
     3648        offset = 300; // 5 Minutes Min
     3649    else if (offset > 720)
     3650        offset = 720; // 12 Minutes Max
     3651
     3652    if (forceWatched || framesPlayed > numFrames - (offset * video_frame_rate))
     3653    {
     3654        m_playbackinfo->SetWatchedFlag(true);
     3655        VERBOSE(VB_GENERAL, QString("Marking recording as watched using offset %1 minutes").arg(offset/60));
     3656    }
     3657    else
     3658    {
     3659        m_playbackinfo->SetWatchedFlag(false);
     3660        VERBOSE(VB_GENERAL, "Marking recording as unwatched");
     3661    }
     3662}
     3663
    36343664void NuppelVideoPlayer::SetBookmark(void)
    36353665{
    36363666    if (!m_playbackinfo || !osd)
     
    66896719{
    66906720    osdtheme = QDeepCopy<QString>(themename);
    66916721}
     6722
     6723NuppelVideoPlayer SetLiveTVChain( LiveTVChain * tvchain )
     6724{
     6725}
    66926726// EIA-708 caption support -- end
    66936727
    66946728/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • 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 = "1157";
     13const QString currentDatabaseVersion = "1158";
    1414
    1515static bool UpdateDBVersionNumber(const QString &newnumber);
    1616static bool performActualUpdate(const QString updates[], QString version,
     
    24972497            return false;
    24982498    }
    24992499
     2500    if (dbver == "1157")
     2501    {
     2502        const QString updates[] = {
     2503"ALTER TABLE recorded ADD COLUMN watched TINYINT NOT NULL DEFAULT '0';",
     2504""
     2505};
     2506
     2507        if (!performActualUpdate(updates, "1158", dbver))
     2508            return false;
     2509    }
     2510
    25002511//"ALTER TABLE capturecard DROP COLUMN dvb_recordts;" in 0.21
    25012512//"ALTER TABLE capturecard DROP COLUMN dvb_hw_decoder;" in 0.21
    25022513//"ALTER TABLE cardinput DROP COLUMN preference;" in 0.22
  • libs/libmythtv/NuppelVideoPlayer.h

     
    145145
    146146    void SetTranscoding(bool value);
    147147    void SetWatchingRecording(bool mode);
     148    void SetWatched(bool forceWatched = false);
    148149    void SetBookmark(void);
    149150    void SetKeyframeDistance(int keyframedistance);
    150151    void SetVideoParams(int w, int h, double fps, int keydist,
  • libs/libmythtv/tv_play.cpp

     
    12161216    {
    12171217        VERBOSE(VB_PLAYBACK,LOC + " StopStuff() -- get dvd player out of still frame or wait status");
    12181218        prbuffer->DVD()->IgnoreStillOrWait(true);
    1219     } 
     1219    }
    12201220
    12211221    if (stopRingBuffers)
    12221222    {
     
    21162116                            wantsToQuit = true;
    21172117                            exitPlayer = true;
    21182118                            break;
    2119                         case 3: case 0:
     2119                        case 3:
     2120                            nvp->SetWatched(true);
     2121                            wantsToQuit = true;
     2122                            exitPlayer = true;
     2123                            break;
     2124                        case 4: case 0:
    21202125                            paused = !paused;
    21212126                            DoPause();
    21222127                            break;
    2123                         case 4:
     2128                        case 5:
    21242129                            wantsToQuit = true;
    21252130                            exitPlayer = true;
    21262131                            requestDelete = true;
     
    24862491                QStringList options;
    24872492                options += tr("Save this position and go to the menu");
    24882493                options += tr("Do not save, just exit to the menu");
     2494                options += tr("Mark as watched and go to the menu");
    24892495                options += tr("Keep watching");
    24902496                options += tr("Delete this recording");
    24912497
     
    25202526            {
    25212527                if (nvp && gContext->GetNumSetting("PlaybackExitPrompt") == 2)
    25222528                    nvp->SetBookmark();
     2529                if (nvp && gContext->GetNumSetting("AutomaticSetWatched", 0))
     2530                    nvp->SetWatched();
    25232531                exitPlayer = true;
    25242532                wantsToQuit = true;
    25252533            }
  • libs/libmythtv/programinfo.h

     
    5555    FL_STEREO         = 0x080,
    5656    FL_CC             = 0x100,
    5757    FL_HDTV           = 0x200,
    58     FL_TRANSCODED     = 0x400
     58    FL_TRANSCODED     = 0x400,
     59    FL_WATCHED        = 0x800
    5960};
    6061
    6162enum RecStatusType {
     
    183184    bool IsCommFlagged(void) const;
    184185    bool IsInUse(QString &byWho) const;
    185186    int GetAutoExpireFromRecorded(void) const;
     187    int GetTranscodedStatus(void) const;
    186188    bool GetPreserveEpisodeFromRecorded(void) const;
    187189    bool UsesMaxEpisodes(void) const;
    188190    int getProgramFlags(void) const;
     
    195197    void SetBookmark(long long pos) const;
    196198    void SetEditing(bool edit) const;
    197199    void SetTranscoded(int transFlag) const;
     200    void SetWatchedFlag(bool watchedFlag) const;
    198201    void SetDeleteFlag(bool deleteFlag) const;
    199202    void SetCommFlagged(int flag) const; // 1 = flagged, 2 = processing
    200203    void SetAutoExpire(int autoExpire) const;
  • libs/libmythtv/programinfo.cpp

     
    18081808    return pos;
    18091809}
    18101810
     1811/** \fn ProgramInfo::SetWatchedFlag(bool) const
     1812 *  \brief Set "watched" field in "recorded" table to "watchedFlag".
     1813 *  \param watchedFlag value to set watched field to.
     1814 */
     1815void ProgramInfo::SetWatchedFlag(bool watchedFlag) const
     1816{
     1817    MSqlQuery query(MSqlQuery::InitCon());
     1818
     1819    query.prepare("UPDATE recorded"
     1820                  " SET watched = :WATCHEDFLAG"
     1821                  " WHERE chanid = :CHANID"
     1822                  " AND starttime = :STARTTIME ;");
     1823    query.bindValue(":CHANID", chanid);
     1824    query.bindValue(":STARTTIME", recstartts);
     1825
     1826    if (watchedFlag)
     1827        query.bindValue(":WATCHEDFLAG", 1);
     1828    else
     1829        query.bindValue(":WATCHEDFLAG", 0);
     1830
     1831    if (!query.exec() || !query.isActive())
     1832        MythContext::DBError("Set watched flag", query);
     1833}
     1834
    18111835/** \fn ProgramInfo::IsEditing(void) const
    18121836 *  \brief Queries "recorded" table for its "editing" field
    18131837 *         and returns true if it is set to true.
     
    19501974    return false;
    19511975}
    19521976
     1977/** \fn ProgramInfo::GetTranscodedStatus(void) const
     1978 *  \brief Returns the "transcoded" field in "recorded" table.
     1979 */
     1980int ProgramInfo::GetTranscodedStatus(void) const
     1981{
     1982    MSqlQuery query(MSqlQuery::InitCon());
     1983
     1984    query.prepare("SELECT transcoded FROM recorded"
     1985                 " WHERE chanid = :CHANID"
     1986                 " AND starttime = :STARTTIME ;");
     1987    query.bindValue(":CHANID", chanid);
     1988    query.bindValue(":STARTTIME", recstartts);
     1989
     1990    if (query.exec() && query.isActive() && query.size() > 0)
     1991    {
     1992        query.next();
     1993        return query.value(0).toInt();
     1994    }
     1995
     1996    return false;
     1997}
     1998
    19531999/** \fn ProgramInfo::SetTranscoded(int transFlag) const
    19542000 *  \brief Set "transcoded" field in "recorded" table to "transFlag".
    19552001 *  \param transFlag value to set transcoded field to.
     
    35133559    MSqlQuery query(MSqlQuery::InitCon());
    35143560
    35153561    query.prepare("SELECT commflagged, cutlist, autoexpire, "
    3516                   "editing, bookmark, stereo, closecaptioned, hdtv "
     3562                  "editing, bookmark, stereo, closecaptioned, hdtv, watched "
    35173563                  "FROM recorded LEFT JOIN recordedprogram ON "
    35183564                  "(recorded.chanid = recordedprogram.chanid AND "
    35193565                  "recorded.starttime = recordedprogram.starttime) "
     
    35353581        flags |= (query.value(5).toInt() == 1) ? FL_STEREO : 0;
    35363582        flags |= (query.value(6).toInt() == 1) ? FL_CC : 0;
    35373583        flags |= (query.value(7).toInt() == 1) ? FL_HDTV : 0;
     3584        flags |= (query.value(8).toInt() == 1) ? FL_WATCHED : 0;
    35383585    }
    35393586
    35403587    return flags;
     
    41814228        "recorded.basename, recorded.progstart, "
    41824229        "recorded.progend, recorded.stars, "
    41834230        "recordedprogram.stereo, recordedprogram.hdtv, "
    4184         "recordedprogram.closecaptioned "
     4231        "recordedprogram.closecaptioned, recorded.watched "
    41854232        "FROM recorded "
    41864233        "LEFT JOIN record ON recorded.recordid = record.recordid "
    41874234        "LEFT JOIN channel ON recorded.chanid = channel.chanid "
     
    42744321            flags |= (query.value(32).toInt() == 1)           ? FL_STEREO   : 0;
    42754322            flags |= (query.value(34).toInt() == 1)           ? FL_CC       : 0;
    42764323            flags |= (query.value(33).toInt() == 1)           ? FL_HDTV     : 0;
     4324            flags |= (query.value(35).toInt() == 1)           ? FL_WATCHED  : 0;
    42774325
    42784326            inUseKey = query.value(0).toString() + " " +
    42794327                       query.value(1).toDateTime().toString(Qt::ISODate);
  • programs/mythfrontend/playbackbox.cpp

     
    786786        iconMap["stereo"]      = FL_STEREO;
    787787        iconMap["cc"]          = FL_CC;
    788788        iconMap["hdtv"]        = FL_HDTV;
     789        iconMap["watched"]     = FL_WATCHED;
    789790
    790791        UIImageType *itype;
    791792        for (it = iconMap.begin(); it != iconMap.end(); ++it)
     
    27932794            popup->addButton(tr("Enable Auto Expire"), this, SLOT(doAutoExpire()));
    27942795    }
    27952796
     2797    if (curitem->programflags & FL_WATCHED)
     2798    {
     2799        popup->addButton(tr("Mark as Unwatched"), this,
     2800                                    SLOT(setUnwatched()));
     2801    }
     2802    else
     2803    {
     2804        popup->addButton(tr("Mark as Watched"), this,
     2805                                    SLOT(setWatched()));
     2806    }
     2807
    27962808    popup->addButton(tr("Recording Options"), this, SLOT(showRecordingPopup()));
    27972809    popup->addButton(tr("Job Options"), this, SLOT(showJobPopup()));
    27982810
     
    33043316    return NULL;
    33053317}
    33063318
     3319void PlaybackBox::setUnwatched(void)
     3320{
     3321    if (!expectingPopup && delitem)
     3322        return;
     3323
     3324    cancelPopup();
     3325
     3326    delitem->SetWatchedFlag(0);
     3327
     3328    ProgramInfo *tmpItem = findMatchingProg(delitem);
     3329    if (tmpItem)
     3330        tmpItem->programflags &= ~FL_WATCHED;
     3331
     3332    delete delitem;
     3333    delitem = NULL;
     3334
     3335    previewVideoState = kChanging;
     3336
     3337    update(drawListBounds);
     3338}
     3339
     3340void PlaybackBox::setWatched(void)
     3341{
     3342    if (!expectingPopup)
     3343        return;
     3344
     3345    cancelPopup();
     3346
     3347    delitem->SetWatchedFlag(1);
     3348
     3349    ProgramInfo *tmpItem = findMatchingProg(delitem);
     3350    if (tmpItem)
     3351        tmpItem->programflags |= FL_WATCHED;
     3352
     3353    delete delitem;
     3354    delitem = NULL;
     3355
     3356    previewVideoState = kChanging;
     3357
     3358    update(drawListBounds);
     3359}
     3360
    33073361void PlaybackBox::noAutoExpire(void)
    33083362{
    33093363    if (!expectingPopup && delitem)
  • programs/mythfrontend/globalsettings.cpp

     
    570570    return bc;
    571571}
    572572
     573static GlobalCheckBox *AutoExpireWatchedPriority()
     574{
     575    GlobalCheckBox *bc = new GlobalCheckBox("AutoExpireWatchedPriority");
     576    bc->setLabel(QObject::tr("Auto Expire watched programs before unwatched"));
     577    bc->setValue(false);
     578    bc->setHelpText(QObject::tr("If set, programs that have been marked as "
     579                    "watched will be expired first"));
     580    return bc;
     581}
     582
    573583static GlobalSpinBox *AutoExpireDayPriority()
    574584{
    575585    GlobalSpinBox *bs = new GlobalSpinBox("AutoExpireDayPriority", 1, 400, 1);
     
    620630}
    621631#endif
    622632
     633static GlobalCheckBox *RerecordWatched()
     634{
     635    GlobalCheckBox *bc = new GlobalCheckBox("RerecordWatched");
     636    bc->setLabel(QObject::tr("Re-record watched programs"));
     637    bc->setValue(true);
     638    bc->setHelpText(QObject::tr("If set, programs that have been marked as "
     639                    "watched and are auto-expired will be re-recorded if "
     640                    "they are shown again."));
     641    return bc;
     642}
     643
    623644static GlobalSpinBox *RecordPreRoll()
    624645{
    625646    GlobalSpinBox *bs = new GlobalSpinBox("RecordPreRoll", 0, 600, 60, true);
     
    12261247    return gc;
    12271248}
    12281249
     1250static HostCheckBox *AutomaticSetWatched()
     1251{
     1252    HostCheckBox *gc = new HostCheckBox("AutomaticSetWatched");
     1253    gc->setLabel(QObject::tr("Automatically mark a record watched"));
     1254    gc->setValue(false);
     1255    gc->setHelpText(QObject::tr("If set, when you exit near the end of a "
     1256                    "recording it will be marked as watched. The automatic "
     1257                    "detection is not foolproof, so do not enable this "
     1258                    "setting if you don't want an unwatched recording marked "
     1259                    "as watched."));
     1260    return gc;
     1261}
     1262
    12291263static HostCheckBox *GeneratePreviewPixmaps()
    12301264{
    12311265    HostCheckBox *gc = new HostCheckBox("GeneratePreviewPixmaps");
     
    34163450    gen2->setLabel(QObject::tr("General playback (part 2)"));
    34173451    gen2->addChild(PlaybackExitPrompt());
    34183452    gen2->addChild(EndOfRecordingExitPrompt());
     3453    gen2->addChild(AutomaticSetWatched());
    34193454    gen2->addChild(ClearSavedPosition());
    34203455    gen2->addChild(AltClearSavedPosition());
    34213456#ifdef USING_XV
     
    35403575    VerticalConfigurationGroup* autoexp = new VerticalConfigurationGroup(false);
    35413576    autoexp->setLabel(QObject::tr("General (AutoExpire)"));
    35423577    autoexp->addChild(AutoExpireMethod());
     3578    autoexp->addChild(AutoExpireWatchedPriority());
    35433579    autoexp->addChild(AutoExpireDayPriority());
    35443580    autoexp->addChild(AutoExpireDefault());
    35453581    autoexp->addChild(AutoExpireLiveTVMaxAge());
     3582    autoexp->addChild(RerecordWatched());
    35463583    autoexp->addChild(AutoExpireExtraSpace());
    35473584    addChild(autoexp);
    35483585
  • programs/mythfrontend/playbackbox.h

     
    161161    void doForceDelete();
    162162    void noDelete();
    163163
     164    void setWatched();
     165    void setUnwatched();
     166
    164167    void doAutoExpire();
    165168    void noAutoExpire();
    166169    void doPreserveEpisode();
  • programs/mythtranscode/main.cpp

     
    662662                MythContext::DBError("Error in mythtranscode", query);
    663663
    664664            query.prepare("UPDATE recorded "
    665                           "SET cutlist = :CUTLIST, bookmark = :BOOKMARK "
    666                           "WHERE chanid = :CHANID "
     665                          "SET cutlist = :CUTLIST, bookmark = :BOOKMARK, "
     666                          "watched = :WATCHED WHERE chanid = :CHANID "
    667667                          "AND starttime = :STARTTIME ;");
    668668            query.bindValue(":CUTLIST", "0");
    669669            query.bindValue(":BOOKMARK", "0");
     670            query.bindValue(":WATCHED", "0");
    670671            query.bindValue(":CHANID", pginfo->chanid);
    671672            query.bindValue(":STARTTIME", pginfo->recstartts);
    672673            query.exec();
  • programs/mythbackend/mainserver.cpp

     
    661661            if (pinfo)
    662662            {
    663663                // allow re-record if auto expired but not expired live buffers
    664                 if (pinfo->recgroup != "LiveTV")
     664                if (pinfo->recgroup != "LiveTV" &&
     665                    (gContext->GetNumSetting("RerecordWatched", 0) ||
     666                    (!pinfo->getProgramFlags() & FL_WATCHED)))
    665667                    pinfo->ForgetHistory();
     668
    666669                DoHandleDeleteRecording(pinfo, NULL, false);
    667670            }
    668671            else
     
    10281031        "recorded.progend, recorded.stars, "
    10291032        "recordedprogram.stereo, recordedprogram.hdtv, "
    10301033        "recordedprogram.closecaptioned, transcoded, "
    1031         "recorded.recpriority "
     1034        "recorded.recpriority, watched "
    10321035        "FROM recorded "
    10331036        "LEFT JOIN record ON recorded.recordid = record.recordid "
    10341037        "LEFT JOIN channel ON recorded.chanid = channel.chanid "
     
    11321135            flags |= (query.value(34).toInt() == 1) ? FL_CC : 0;
    11331136            flags |= (query.value(35).toInt() == TRANSCODING_COMPLETE) ?
    11341137                      FL_TRANSCODED : 0;
     1138            flags |= (query.value(37).toInt() == 1) ? FL_WATCHED : 0;
    11351139
    11361140            inUseKey = query.value(0).toString() + " " +
    11371141                       query.value(1).toDateTime().toString(Qt::ISODate);
  • programs/mythbackend/autoexpire.cpp

     
    762762        default:
    763763        case emOldestFirst:
    764764            where = "autoexpire > 0";
    765             orderby = "starttime ASC";
     765            if (gContext->GetNumSetting("AutoExpireWatchedPriority", 0))
     766                orderby = "recorded.watched DESC, ";
     767            orderby += "starttime ASC";
    766768            break;
    767769        case emLowestPriorityFirst:
    768770            where = "autoexpire > 0";
    769             orderby = "recorded.recpriority ASC, starttime ASC";
     771            if (gContext->GetNumSetting("AutoExpireWatchedPriority", 0))
     772                orderby = "recorded.watched DESC, ";
     773            orderby += "recorded.recpriority ASC, starttime ASC";
    770774            break;
    771775        case emWeightedTimePriority:
    772776            where = "autoexpire > 0";
    773             orderby = QString("DATE_ADD(starttime, INTERVAL '%1' * "
     777            if (gContext->GetNumSetting("AutoExpireWatchedPriority", 0))
     778                orderby = "recorded.watched DESC, ";
     779            orderby += QString("DATE_ADD(starttime, INTERVAL '%1' * "
    774780                                        "recorded.recpriority DAY) ASC")
    775781                      .arg(gContext->GetNumSetting("AutoExpireDayPriority", 3));
    776782            break;