Ticket #690: mythtv.watch_recordings.5.diff

File mythtv.watch_recordings.5.diff, 19.2 KB (added by Robert Tsai <rtsai1111>, 18 years ago)

sync to [9247]

  • programs/mythfrontend/playbackbox.cpp

     
    104104        return (dt1 > dt2 ? 1 : -1);
    105105}
    106106
     107static PlaybackBox::ViewMask viewMaskToggle(PlaybackBox::ViewMask mask,
     108        PlaybackBox::ViewMask toggle)
     109{
     110    // can only toggle a single bit at a time
     111    if ((mask & toggle))
     112        return (PlaybackBox::ViewMask)(mask & ~toggle);
     113    return (PlaybackBox::ViewMask)(mask | toggle);
     114}
     115
     116static QString sortTitle(QString title, PlaybackBox::ViewMask viewmask,
     117        PlaybackBox::ViewTitleSort titleSort, int recpriority)
     118{
     119    if (title == "")
     120        return title;
     121
     122    QRegExp prefixes = QObject::tr("^(The |A |An )");
     123    QString sTitle = title;
     124
     125    sTitle.remove(prefixes);
     126    if (viewmask == PlaybackBox::VIEW_TITLES &&
     127            titleSort == PlaybackBox::TitleSortRecPriority)
     128    {
     129        // Also incorporate recpriority (reverse numeric sort). In
     130        // case different episodes of a recording schedule somehow
     131        // have different recpriority values (e.g., manual fiddling
     132        // with database), the title will appear once for each
     133        // distinct recpriority value among its episodes.
     134        //
     135        // Take advantage of QMap sorting. Positive recpriority values
     136        // have a '+' prefix (sorts before '-'). Positive recpriority
     137        // values are "inverted" by substracting them from 1000, so
     138        // that high recpriorities are sorted first.
     139        //
     140        // For example (first column is sort key; second column is
     141        // recpriority):
     142        //
     143        //      +905     95
     144        //      +910     90
     145        //      +911     89
     146        //      +999      1
     147        //      -000      0
     148        //      -005     -5
     149        //      -010    -10
     150        //      -099    -99
     151
     152        QString sortprefix;
     153        if (recpriority > 0)
     154            sortprefix.sprintf("+%03u", 1000 - recpriority);
     155        else
     156            sortprefix.sprintf("-%03u", -recpriority);
     157
     158        sTitle = sortprefix + "-" + sTitle;
     159    }
     160    return sTitle;
     161}
     162
    107163PlaybackBox::PlaybackBox(BoxType ltype, MythMainWindow *parent,
    108164                         const char *name)
    109165    : MythDialog(parent, name),
     
    119175      groupDisplayName(tr("All Programs")),
    120176      recGroup("All Programs"),
    121177      recGroupPassword(""),             curGroupPassword(""),
     178      viewMask(VIEW_TITLES),
    122179      // Theme parsing
    123180      theme(new XMLParse()),
    124181      // Non-volatile drawing variables
     
    181238        drawTransPixmap = new QPixmap();
    182239
    183240    bool displayCat  = gContext->GetNumSetting("DisplayRecGroupIsCategory", 0);
    184     int  defaultView = gContext->GetNumSetting("DisplayGroupDefaultView", 0);
     241    ViewType defaultView = (ViewType)gContext->GetNumSetting(
     242            "DisplayGroupDefaultView", TitlesOnly);
    185243    int  initialFilt = gContext->GetNumSetting("QueryInitialFilter", 0);
    186244
    187245    progLists[""];
     
    346404    }
    347405}
    348406
    349 void PlaybackBox::setDefaultView(int defaultView)
     407void PlaybackBox::setDefaultView(ViewType defaultView)
    350408{
     409    int mask;
     410
    351411    switch (defaultView)
    352412    {
    353413        default:
    354         case TitlesOnly: titleView = true; useCategories = false;
    355                          useRecGroups = false; break;
    356         case TitlesCategories: titleView = true; useCategories = true;
    357                                useRecGroups = false; break;
    358         case TitlesCategoriesRecGroups: titleView = true; useCategories = true;
    359                                         useRecGroups = true; break;
    360         case TitlesRecGroups: titleView = true; useCategories = false;
    361                               useRecGroups = true; break;
    362         case Categories: titleView = false; useCategories = true;
    363                          useRecGroups = false; break;
    364         case CategoriesRecGroups: titleView = false; useCategories = true;
    365                                   useRecGroups = true; break;
    366         case RecGroups: titleView = false; useCategories = false;
    367                         useRecGroups = true; break;
     414        case TitlesOnly:
     415            mask = VIEW_TITLES;
     416            break;
     417        case TitlesCategories:
     418            mask = VIEW_TITLES |    VIEW_CATEGORIES;
     419            break;
     420        case TitlesCategoriesRecGroups:
     421            mask = VIEW_TITLES |    VIEW_CATEGORIES |   VIEW_RECGROUPS;
     422            break;
     423        case TitlesRecGroups:
     424            mask = VIEW_TITLES |                        VIEW_RECGROUPS;
     425            break;
     426        case Categories:
     427            mask =                  VIEW_CATEGORIES;
     428            break;
     429        case CategoriesRecGroups:
     430            mask =                  VIEW_CATEGORIES |   VIEW_RECGROUPS;
     431            break;
     432        case RecGroups:
     433            mask =                                      VIEW_RECGROUPS;
     434            break;
    368435    }
     436    viewMask = (PlaybackBox::ViewMask)mask;
    369437}
    370438
    371439/* blocks until playing has stopped */
     
    571639        tmp->fillRect(QRect(QPoint(0, 0), size()),
    572640                      QBrush(QColor(10, 10, 10), Dense4Pattern));
    573641    else if (transparentFlag == 1)
    574         tmp->drawPixmap(0, 0, *drawTransPixmap, 0, 0, (int)(800*wmult),
    575                         (int)(600*hmult));
     642    {
     643        int ww, hh;
     644
     645        if (d->IsWideMode())
     646        {
     647            ww = 1280;
     648            hh = 720;
     649        }
     650        else
     651        {
     652            ww = 800;
     653            hh = 600;
     654        }
     655        tmp->drawPixmap(0, 0, *drawTransPixmap, 0, 0, (int)(ww*wmult),
     656                        (int)(hh*hmult));
     657    }
    576658*/
    577659}
    578660void PlaybackBox::updateCurGroup(QPainter *p)
     
    11151197                    ((titleList[titleIndex] != tempInfo->title) &&
    11161198                     ((titleList[titleIndex] == tempInfo->recgroup) ||
    11171199                      (titleList[titleIndex] == tempInfo->category))) ||
    1118                     (!(titleView)))
     1200                    (!(viewMask & VIEW_TITLES)))
    11191201                    tempSubTitle = tempInfo->title;
    11201202                else
    11211203                    tempSubTitle = tempInfo->subtitle;
     
    11261208                        ((titleList[titleIndex] != tempInfo->title) &&
    11271209                         ((titleList[titleIndex] == tempInfo->recgroup) ||
    11281210                          (titleList[titleIndex] == tempInfo->category))) ||
    1129                         (!(titleView))))
     1211                        (!(viewMask & VIEW_TITLES))))
    11301212                {
    11311213                    tempSubTitle = tempSubTitle + " - \"" +
    11321214                        tempInfo->subtitle + "\"";
     
    13371419    QString oldprogramid;
    13381420    QDate oldoriginalAirDate;
    13391421    QDateTime oldstartts;
     1422    int oldrecpriority = 0;
    13401423    p = progLists[oldtitle].at(progIndex);
    13411424    if (p)
    13421425    {
     
    13441427        oldstartts = p->recstartts;
    13451428        oldprogramid = p->programid;
    13461429        oldoriginalAirDate = p->originalAirDate;
     1430        oldrecpriority = p->recpriority;
    13471431    }
    13481432
    13491433    QMap<QString, AvailableStatusType> asCache;
     
    13641448
    13651449    fillRecGroupPasswordCache();
    13661450
     1451    ViewTitleSort titleSort = (ViewTitleSort)gContext->GetNumSetting(
     1452            "DisplayGroupTitleSort", TitleSortAlphabetical);
     1453
    13671454    QMap<QString, QString> sortedList;
    1368     QRegExp prefixes = tr("^(The |A |An )");
    13691455    QString sTitle = "";
    13701456
    13711457    bool LiveTVInAllPrograms = gContext->GetNumSetting("LiveTVInAllPrograms",0);
     
    13881474                 (p->category == recGroup ) &&
    13891475                 ( !recGroupPwCache.contains(p->recgroup))))
    13901476            {
    1391                 if ((titleView) || (useCategories) || (useRecGroups))
     1477                if (viewMask != VIEW_NONE)
    13921478                    progLists[""].prepend(p);
    13931479
    13941480                asKey = p->MakeUniqueKey();
     
    13971483                else
    13981484                    p->availableStatus = asAvailable;
    13991485
    1400                 if (titleView) // Normal title view
     1486                if ((viewMask & VIEW_TITLES)) // Show titles
    14011487                {
    14021488                    progLists[p->title].prepend(p);
    1403                     sTitle = p->title;
    1404                     sTitle.remove(prefixes);
     1489                    sTitle = sortTitle(p->title, viewMask, titleSort,
     1490                            p->recpriority);
    14051491                    sTitle = sTitle.lower();
    14061492                    sortedList[sTitle] = p->title;
    14071493                }
    14081494
    1409                 if (useRecGroups && p->recgroup != "") // Show recording groups                 
     1495                if ((viewMask & VIEW_RECGROUPS) &&
     1496                    p->recgroup != "") // Show recording groups                 
    14101497                {
    14111498                    progLists[p->recgroup].prepend(p);
    14121499                    sortedList[p->recgroup.lower()] = p->recgroup;
    14131500
    1414                     // If another view is also used, unset autodelete as another group will do it.
    1415                     if ((useCategories) || (titleView))
     1501                    // If another view is also used, unset autodelete as
     1502                    // another group will do it.
     1503                    if ((viewMask & ~VIEW_RECGROUPS))
    14161504                        progLists[p->recgroup].setAutoDelete(false);
    14171505                }
    14181506
    1419                 if (useCategories && p->category != "") // Show categories
     1507                if ((viewMask & VIEW_CATEGORIES) &&
     1508                    p->category != "") // Show categories
    14201509                {
    14211510                    progLists[p->category].prepend(p);
    14221511                    sortedList[p->category.lower()] = p->category;
    1423                     // If another view is also used, unset autodelete as another group will do it
    1424                     if ((useRecGroups) || (titleView))
     1512                    // If another view is also used, unset autodelete as
     1513                    // another group will do it
     1514                    if ((viewMask & ~VIEW_CATEGORIES))
    14251515                        progLists[p->category].setAutoDelete(false);
    14261516                }
    14271517            }
     
    14421532        return 0;
    14431533    }
    14441534
    1445     titleList = sortedList.values();
    1446 
    14471535    QString episodeSort = gContext->GetSetting("PlayBoxEpisodeSort", "Date");
    14481536
    14491537    if (episodeSort == "OrigAirDate")
     
    14791567    // titles backwards until we find where we were or go past.  This
    14801568    // is somewhat inefficient, but it works.
    14811569
    1482     QString oldsTitle = oldtitle;
    1483     oldsTitle.remove(prefixes);
     1570    QStringList sTitleList = sortedList.keys();
     1571    titleList = sortedList.values();
     1572
     1573    QString oldsTitle = sortTitle(oldtitle, viewMask, titleSort,
     1574            oldrecpriority);
    14841575    oldsTitle = oldsTitle.lower();
    14851576    titleIndex = titleList.count() - 1;
    1486     for (int i = titleIndex; i >= 0; i--)
     1577    for (titleIndex = titleList.count() - 1; titleIndex >= 0; titleIndex--)
    14871578    {
    1488         sTitle = titleList[i];
    1489         sTitle.remove(prefixes);
     1579        sTitle = sTitleList[titleIndex];
    14901580        sTitle = sTitle.lower();
    14911581       
    14921582        if (oldsTitle > sTitle)
     1583        {
     1584            if (titleIndex + 1 < (int)titleList.count())
     1585                titleIndex++;
    14931586            break;
     1587        }
    14941588
    1495         titleIndex = i;
    1496 
    14971589        if (oldsTitle == sTitle)
    14981590            break;
    14991591    }
     
    22302322 
    22312323    if (inTitle)
    22322324    {
    2233         if (titleView)
     2325        if ((viewMask & VIEW_TITLES))
    22342326            popup->addButton(tr("Toggle playlist for this Category/Title"),
    22352327                             this, SLOT(togglePlayListTitle()));
    22362328        else
     
    31523244    if (expectingPopup)
    31533245        cancelPopup();
    31543246
    3155     if (titleView) titleView = false;
    3156     else titleView = true;
     3247    viewMask = viewMaskToggle(viewMask, VIEW_TITLES);
    31573248
    31583249    playList.clear();
    31593250    connected = FillList();     
     
    34023493        }
    34033494        else if (action == "TOGGLERECORD")
    34043495        {
    3405             if (titleView) titleView = false;
    3406             else titleView = true;
     3496            viewMask = viewMaskToggle(viewMask, VIEW_TITLES);
    34073497            connected = FillList();
    34083498            paintSkipUpdate = false;
    34093499            update(drawTotalBounds);
     
    38713961    int result = recGroupPopup->ExecPopup();
    38723962
    38733963    if (result == MythDialog::Accepted)
    3874         setDefaultView(recGroupComboBox->currentItem());
     3964        setDefaultView((ViewType)recGroupComboBox->currentItem());
    38753965
    38763966    delete recGroupComboBox;
    38773967
  • programs/mythfrontend/globalsettings.cpp

     
    1313#include "dbsettings.h"
    1414#include "langsettings.h"
    1515#include "mpeg/iso639.h"
     16#include "playbackbox.h"
    1617#include "globalsettings.h"
    1718#include "recordingprofile.h"
    1819#include "scheduledrecording.h"
     
    304305    HostComboBox *gc = new HostComboBox("DisplayGroupDefaultView");
    305306    gc->setLabel(QObject::tr("Default View"));
    306307
    307     gc->addSelection(QObject::tr("Show Titles only"), "0");
    308     gc->addSelection(QObject::tr("Show Titles and Categories"), "1");
    309     gc->addSelection(QObject::tr("Show Titles, Categories, and Recording Groups"), "2");
    310     gc->addSelection(QObject::tr("Show Titles and Recording Groups"), "3");
    311     gc->addSelection(QObject::tr("Show Categories only"), "4");
    312     gc->addSelection(QObject::tr("Show Categories and Recording Groups"), "5");
    313     gc->addSelection(QObject::tr("Show Recording Groups only"), "6");
     308    gc->addSelection(QObject::tr("Show Titles only"),
     309            QString::number(PlaybackBox::TitlesOnly));
     310    gc->addSelection(QObject::tr("Show Titles and Categories"),
     311            QString::number(PlaybackBox::TitlesCategories));
     312    gc->addSelection(QObject::tr(
     313                "Show Titles, Categories, and Recording Groups"),
     314            QString::number(PlaybackBox::TitlesCategoriesRecGroups));
     315    gc->addSelection(QObject::tr("Show Titles and Recording Groups"),
     316            QString::number(PlaybackBox::TitlesRecGroups));
     317    gc->addSelection(QObject::tr("Show Categories only"),
     318            QString::number(PlaybackBox::Categories));
     319    gc->addSelection(QObject::tr("Show Categories and Recording Groups"),
     320            QString::number(PlaybackBox::CategoriesRecGroups));
     321    gc->addSelection(QObject::tr("Show Recording Groups only"),
     322            QString::number(PlaybackBox::RecGroups));
    314323
    315324    gc->setHelpText(QObject::tr("Select what type of grouping to show on the Watch Recordings screen "
    316325                    "by default."));
     
    23062315    return gc;
    23072316}
    23082317
     2318class DefaultViewSettings: public VerticalConfigurationGroup,
     2319                           public TriggeredConfigurationGroup {
     2320public:
     2321    DefaultViewSettings():
     2322            VerticalConfigurationGroup(false, false, true, true),
     2323            TriggeredConfigurationGroup(false) {
     2324
     2325        HostComboBox *defaultView = DefaultView();
     2326        addChild(defaultView);
     2327        setTrigger(defaultView);
     2328
     2329        HostComboBox *titleSort = new HostComboBox("DisplayGroupTitleSort");
     2330        titleSort->setLabel(tr("Sort Titles"));
     2331        titleSort->addSelection(tr("Alphabetically"),
     2332                QString::number(PlaybackBox::TitleSortAlphabetical));
     2333        titleSort->addSelection(tr("By Recording Priority"),
     2334                QString::number(PlaybackBox::TitleSortRecPriority));
     2335
     2336        for (unsigned int ii = 0; ii < PlaybackBox::ViewTypes; ii++)
     2337        {
     2338            if (ii == PlaybackBox::TitlesOnly)
     2339                addTarget(QString::number(ii), titleSort);
     2340            else
     2341                addTarget(QString::number(ii),
     2342                        new VerticalConfigurationGroup(false, false));
     2343        }
     2344    }
     2345};
     2346
    23092347static HostCheckBox *PVR350OutputEnable()
    23102348{
    23112349    HostCheckBox *gc = new HostCheckBox("PVR350OutputEnable");
     
    31243162    pbox2->addChild(RememberRecGroup());
    31253163    pbox2->addChild(UseGroupNameAsAllPrograms());
    31263164    pbox2->addChild(LiveTVInAllPrograms());
    3127     pbox2->addChild(DefaultView());
     3165    pbox2->addChild(new DefaultViewSettings());
    31283166    addChild(pbox2);
    31293167
    31303168    addChild(new HwDecSettings());
     
    33513389    addChild(xboxset);
    33523390}
    33533391
     3392// vim:set sw=4 ts=4 expandtab:
  • programs/mythfrontend/playbackbox.h

     
    11// -*- Mode: c++ -*-
     2// vim:set sw=4 ts=4 expandtab:
    23#ifndef PLAYBACKBOX_H_
    34#define PLAYBACKBOX_H_
    45
     
    4142        Delete,
    4243    } BoxType;
    4344
    44     typedef enum
    45     {
    46         TitlesOnly,
    47         TitlesCategories,
    48         TitlesCategoriesRecGroups,
    49         TitlesRecGroups,
    50         Categories,
    51         CategoriesRecGroups,
    52         RecGroups,
     45    // ViewType values cannot change; they are stored in the database.
     46    typedef enum {
     47        TitlesOnly = 0,
     48        TitlesCategories = 1,
     49        TitlesCategoriesRecGroups = 2,
     50        TitlesRecGroups = 3,
     51        Categories = 4,
     52        CategoriesRecGroups = 5,
     53        RecGroups = 6,
     54        ViewTypes,                  // placeholder value, not in database
    5355    } ViewType;
    5456
     57    // Sort function when TitlesOnly. Values are stored in database.
     58    typedef enum {
     59        TitleSortAlphabetical = 0,
     60        TitleSortRecPriority = 1,
     61        TitleSortMethods,           // placeholder value, not in database
     62    } ViewTitleSort;
     63
     64    typedef enum {
     65        VIEW_NONE       =  0x00,
     66        VIEW_TITLES     =  0x01,
     67        VIEW_CATEGORIES =  0x02,
     68        VIEW_RECGROUPS  =  0x04,
     69        VIEW_ALL        = ~0x00,
     70    } ViewMask;
     71
    5572    typedef enum
    5673    {
    5774        EndOfRecording,
     
    260277    void updateCurGroup(QPainter *p);
    261278    void updateGroupInfo(QPainter *p, QRect& pr, QPixmap& pix,
    262279                         QString cont_name = "group_info");
    263     void setDefaultView(int defaultView);
     280    void setDefaultView(ViewType defaultView);
    264281
    265282    // Settings ///////////////////////////////////////////////////////////////
    266283    /// If "Play"  this is a recording playback selection UI,
     
    292309    QString             recGroup;
    293310    QString             recGroupPassword;
    294311    QString             curGroupPassword;
     312    ViewMask            viewMask;
    295313
    296314    // Theme parsing variables
    297315    XMLParse           *theme;
  • programs/mythbackend/mainserver.cpp

     
    960960                       "recorded.basename, recorded.progstart, "
    961961                       "recorded.progend, recorded.stars, "
    962962                       "recordedprogram.stereo, recordedprogram.hdtv, "
    963                        "recordedprogram.closecaptioned, transcoded "
     963                       "recordedprogram.closecaptioned, transcoded, "
     964                       "recorded.recpriority "
    964965                       "FROM recorded "
    965966                       "LEFT JOIN record ON recorded.recordid = record.recordid "
    966967                       "LEFT JOIN channel ON recorded.chanid = channel.chanid "
     
    10791080            proginfo->recgroup = query.value(16).toString();
    10801081            proginfo->playgroup = query.value(27).toString();
    10811082
     1083            proginfo->recpriority = query.value(36).toInt();
     1084
    10821085            proginfo->recstatus = rsRecorded;
    10831086            if (proginfo->recendts > rectime)
    10841087            {