Ticket #690: mythtv.watch_recordings.3.diff

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

update to [r8514]

  • programs/mythfrontend/playbackbox.cpp

     
    9999        return (dt1 > dt2 ? 1 : -1);
    100100}
    101101
     102static PlaybackBox::ViewMask viewMaskToggle(PlaybackBox::ViewMask mask,
     103        PlaybackBox::ViewMask toggle)
     104{
     105    // only works for single-bit toggle values
     106    if ((mask & toggle))
     107        return (PlaybackBox::ViewMask)(mask & ~toggle);
     108    return (PlaybackBox::ViewMask)(mask | toggle);
     109}
     110
     111static QString sortTitle(QString title, PlaybackBox::ViewMask viewmask,
     112        PlaybackBox::ViewTitleSort titleSort, int recpriority)
     113{
     114    if (title == "")
     115        return title;
     116
     117    QRegExp prefixes = QObject::tr("^(The |A |An )");
     118    QString sTitle = title;
     119
     120    sTitle.remove(prefixes);
     121    if (viewmask == PlaybackBox::VIEW_TITLES &&
     122            titleSort == PlaybackBox::TitleSortRecPriority)
     123    {
     124        // Also incorporate recpriority (reverse numeric sort). In
     125        // case different episodes of a recording schedule somehow
     126        // have different recpriority values (e.g., manual fiddling
     127        // with database), the title will appear once for each
     128        // distinct recpriority value among its episodes.
     129        //
     130        // Take advantage of QMap sorting. Positive recpriority values
     131        // have a '+' prefix (sorts before '-'). Positive recpriority
     132        // values are "inverted" by substracting them from 1000, so
     133        // that high recpriorities are sorted first.
     134        //
     135        // For example (first column is sort key; second column is
     136        // recpriority):
     137        //
     138        //      +905     95
     139        //      +910     90
     140        //      +911     89
     141        //      +999      1
     142        //      -000      0
     143        //      -005     -5
     144        //      -010    -10
     145        //      -099    -99
     146
     147        QString sortprefix;
     148        if (recpriority > 0)
     149            sortprefix.sprintf("+%03u", 1000 - recpriority);
     150        else
     151            sortprefix.sprintf("-%03u", -recpriority);
     152
     153        sTitle = sortprefix + "-" + sTitle;
     154    }
     155    return sTitle;
     156}
     157
    102158PlaybackBox::PlaybackBox(BoxType ltype, MythMainWindow *parent,
    103159                         const char *name)
    104160           : MythDialog(parent, name)
     
    147203
    148204    recGroupPopup = NULL;
    149205
    150     // titleView controls showing titles in group list
    151     titleView = true;
     206    viewMask = VIEW_TITLES;
    152207
    153     // useCategories controls showing categories in group list
    154     useCategories = false;
    155 
    156     // useRecGroups controls showing of recording groups in group list
    157     useRecGroups = false;
    158 
    159208    if (gContext->GetNumSetting("UseArrowAccels", 1))
    160209        arrowAccel = true;
    161210    else
     
    186235    else
    187236        recGroupType[recGroup] = "recgroup";
    188237
    189     setDefaultView(gContext->GetNumSetting("DisplayGroupDefaultView", 0));
     238    setDefaultView((ViewType)gContext->GetNumSetting("DisplayGroupDefaultView",
     239                TitlesOnly));
    190240
    191241    fullRect = QRect(0, 0, size().width(), size().height());
    192242    listRect = QRect(0, 0, 0, 0);
     
    314364    }
    315365}
    316366
    317 void PlaybackBox::setDefaultView(int defaultView)
     367void PlaybackBox::setDefaultView(ViewType defaultView)
    318368{
     369    int mask;
     370
    319371    switch (defaultView)
    320372    {
    321373        default:
    322         case TitlesOnly: titleView = true; useCategories = false;
    323                          useRecGroups = false; break;
    324         case TitlesCategories: titleView = true; useCategories = true;
    325                                useRecGroups = false; break;
    326         case TitlesCategoriesRecGroups: titleView = true; useCategories = true;
    327                                         useRecGroups = true; break;
    328         case TitlesRecGroups: titleView = true; useCategories = false;
    329                               useRecGroups = true; break;
    330         case Categories: titleView = false; useCategories = true;
    331                          useRecGroups = false; break;
    332         case CategoriesRecGroups: titleView = false; useCategories = true;
    333                                   useRecGroups = true; break;
    334         case RecGroups: titleView = false; useCategories = false;
    335                         useRecGroups = true; break;
     374        case TitlesOnly:
     375            mask = VIEW_TITLES;
     376            break;
     377        case TitlesCategories:
     378            mask = VIEW_TITLES |    VIEW_CATEGORIES;
     379            break;
     380        case TitlesCategoriesRecGroups:
     381            mask = VIEW_TITLES |    VIEW_CATEGORIES |   VIEW_RECGROUPS;
     382            break;
     383        case TitlesRecGroups:
     384            mask = VIEW_TITLES |                        VIEW_RECGROUPS;
     385            break;
     386        case Categories:
     387            mask =                  VIEW_CATEGORIES;
     388            break;
     389        case CategoriesRecGroups:
     390            mask =                  VIEW_CATEGORIES |   VIEW_RECGROUPS;
     391            break;
     392        case RecGroups:
     393            mask =                                      VIEW_RECGROUPS;
     394            break;
    336395    }
     396    viewMask = (PlaybackBox::ViewMask)mask;
    337397}
    338398
    339399/* blocks until playing has stopped */
     
    11371197
    11381198                tempInfo = plist->at(skip+cnt);
    11391199
    1140                 if ((titleList[titleIndex] == "") || (!(titleView)))
     1200                if (titleList[titleIndex] == "" || !(viewMask & VIEW_TITLES))
    11411201                    tempSubTitle = tempInfo->title;
    11421202                else
    11431203                    tempSubTitle = tempInfo->subtitle;
    11441204                if (tempSubTitle.stripWhiteSpace().length() == 0)
    11451205                    tempSubTitle = tempInfo->title;
    11461206                if ((tempInfo->subtitle).stripWhiteSpace().length() > 0
    1147                     && ((titleList[titleIndex] == "") || (!(titleView))))
     1207                    && (titleList[titleIndex] == ""
     1208                        || !(viewMask & VIEW_TITLES)))
    11481209                {
    11491210                    tempSubTitle = tempSubTitle + " - \"" +
    11501211                        tempInfo->subtitle + "\"";
     
    13551416    QString oldprogramid;
    13561417    QDate oldoriginalAirDate;
    13571418    QDateTime oldstartts;
     1419    int oldrecpriority = 0;
    13581420    p = progLists[oldtitle].at(progIndex);
    13591421    if (p)
    13601422    {
     
    13621424        oldstartts = p->recstartts;
    13631425        oldprogramid = p->programid;
    13641426        oldoriginalAirDate = p->originalAirDate;
     1427        oldrecpriority = p->recpriority;
    13651428    }
    13661429
    13671430    QMap<QString, AvailableStatusType> asCache;
     
    13811444
    13821445    fillRecGroupPasswordCache();
    13831446
     1447    ViewTitleSort titleSort = (ViewTitleSort)gContext->GetNumSetting(
     1448            "DisplayGroupTitleSort", TitleSortAlphabetical);
     1449
    13841450    QMap<QString, QString> sortedList;
    1385     QRegExp prefixes = tr("^(The |A |An )");
    13861451    QString sTitle = "";
    13871452
    13881453    bool LiveTVInAllPrograms = gContext->GetNumSetting("LiveTVInAllPrograms",0);
     
    14041469                 (p->category == recGroup ) &&
    14051470                 ( !recGroupPwCache.contains(p->recgroup))))
    14061471            {
    1407                 if ((titleView) || (useCategories) || (useRecGroups))
     1472                if (viewMask != VIEW_NONE)
    14081473                    progLists[""].prepend(p);
    14091474
    14101475                asKey = p->MakeUniqueKey();
     
    14131478                else
    14141479                    p->availableStatus = asAvailable;
    14151480
    1416                 if (titleView) // Normal title view
     1481                if ((viewMask & VIEW_TITLES)) // Show titles
    14171482                {
    14181483                    progLists[p->title].prepend(p);
    1419                     sTitle = p->title;
    1420                     sTitle.remove(prefixes);
     1484                    sTitle = sortTitle(p->title, viewMask, titleSort,
     1485                            p->recpriority);
    14211486                    sortedList[sTitle.lower()] = p->title;
    14221487                }
    14231488
    1424                 if (useRecGroups && p->recgroup != "") // Show recording groups                 
     1489                if ((viewMask & VIEW_RECGROUPS) &&
     1490                    p->recgroup != "") // Show recording groups                 
    14251491                {
    14261492                    progLists[p->recgroup].prepend(p);
    14271493                    sortedList[p->recgroup.lower()] = p->recgroup;
    14281494
    1429                     // If another view is also used, unset autodelete as another group will do it.
    1430                     if ((useCategories) || (titleView))
     1495                    // If another view is also used, unset autodelete as
     1496                    // another group will do it.
     1497                    if ((viewMask & ~VIEW_RECGROUPS))
    14311498                        progLists[p->recgroup].setAutoDelete(false);
    14321499                }
    14331500
    1434                 if (useCategories && p->category != "") // Show categories
     1501                if ((viewMask & VIEW_CATEGORIES) &&
     1502                    p->category != "") // Show categories
    14351503                {
    14361504                    progLists[p->category].prepend(p);
    14371505                    sortedList[p->category.lower()] = p->category;
    1438                     // If another view is also used, unset autodelete as another group will do it
    1439                     if ((useRecGroups) || (titleView))
     1506                    // If another view is also used, unset autodelete as
     1507                    // another group will do it
     1508                    if ((viewMask & ~VIEW_CATEGORIES))
    14401509                        progLists[p->category].setAutoDelete(false);
    14411510                }
    14421511            }
     
    14571526        return 0;
    14581527    }
    14591528
    1460     titleList = sortedList.values();
    1461 
    14621529    QString episodeSort = gContext->GetSetting("PlayBoxEpisodeSort", "Date");
    14631530
    14641531    if (episodeSort == "OrigAirDate")
     
    14941561    // titles backwards until we find where we were or go past.  This
    14951562    // is somewhat inefficient, but it works.
    14961563
    1497     QString oldsTitle = oldtitle;
    1498     oldsTitle.remove(prefixes);
     1564    QStringList sTitleList = sortedList.keys();
     1565    titleList = sortedList.values();
     1566
     1567    QString oldsTitle = sortTitle(oldtitle, viewMask, titleSort,
     1568            oldrecpriority);
    14991569    titleIndex = titleList.count() - 1;
    1500     for (int i = titleIndex; i >= 0; i--)
     1570    for (titleIndex = titleList.count() - 1; titleIndex >= 0; titleIndex--)
    15011571    {
    1502         sTitle = titleList[i];
    1503         sTitle.remove(prefixes);
     1572        sTitle = sTitleList[titleIndex];
    15041573       
    15051574        if (oldsTitle > sTitle)
     1575        {
     1576            if (titleIndex + 1 < (int)titleList.count())
     1577                titleIndex++;
    15061578            break;
     1579        }
    15071580
    1508         titleIndex = i;
    1509 
    15101581        if (oldsTitle == sTitle)
    15111582            break;
    15121583    }
     
    22132284 
    22142285    if (inTitle)
    22152286    {
    2216         if (titleView)
     2287        if ((viewMask & VIEW_TITLES))
    22172288            popup->addButton(tr("Toggle playlist for this Category/Title"),
    22182289                             this, SLOT(togglePlayListTitle()));
    22192290        else
     
    31203191    if (expectingPopup)
    31213192        cancelPopup();
    31223193
    3123     if (titleView) titleView = false;
    3124     else titleView = true;
     3194    viewMask = viewMaskToggle(viewMask, VIEW_TITLES);
    31253195
    31263196    playList.clear();
    31273197    connected = FillList();     
     
    32733343        }
    32743344        else if (action == "TOGGLERECORD")
    32753345        {
    3276             if (titleView) titleView = false;
    3277             else titleView = true;
     3346            viewMask = viewMaskToggle(viewMask, VIEW_TITLES);
    32783347            connected = FillList();
    32793348            skipUpdate = false;
    32803349            update(fullRect);
     
    37813850    int result = recGroupPopup->ExecPopup();
    37823851
    37833852    if (result == MythDialog::Accepted)
    3784         setDefaultView(recGroupComboBox->currentItem());
     3853        setDefaultView((ViewType)recGroupComboBox->currentItem());
    37853854
    37863855    delete recGroupComboBox;
    37873856
     
    44454514    else
    44464515        recGroupOkButton->setEnabled(false);
    44474516}
     4517
     4518// vim:set sw=4 ts=4 expandtab:
  • programs/mythfrontend/globalsettings.cpp

     
    44#include "dbsettings.h"
    55#include "langsettings.h"
    66#include "mpeg/iso639.h"
     7#include "playbackbox.h"
    78#include "globalsettings.h"
    89#include "recordingprofile.h"
    910#include "scheduledrecording.h"
     
    302303    HostComboBox *gc = new HostComboBox("DisplayGroupDefaultView");
    303304    gc->setLabel(QObject::tr("Default View"));
    304305
    305     gc->addSelection(QObject::tr("Show Titles only"), "0");
    306     gc->addSelection(QObject::tr("Show Titles and Categories"), "1");
    307     gc->addSelection(QObject::tr("Show Titles, Categories, and Recording Groups"), "2");
    308     gc->addSelection(QObject::tr("Show Titles and Recording Groups"), "3");
    309     gc->addSelection(QObject::tr("Show Categories only"), "4");
    310     gc->addSelection(QObject::tr("Show Categories and Recording Groups"), "5");
    311     gc->addSelection(QObject::tr("Show Recording Groups only"), "6");
     306    gc->addSelection(QObject::tr("Show Titles only"),
     307            QString::number(PlaybackBox::TitlesOnly));
     308    gc->addSelection(QObject::tr("Show Titles and Categories"),
     309            QString::number(PlaybackBox::TitlesCategories));
     310    gc->addSelection(QObject::tr(
     311                "Show Titles, Categories, and Recording Groups"),
     312            QString::number(PlaybackBox::TitlesCategoriesRecGroups));
     313    gc->addSelection(QObject::tr("Show Titles and Recording Groups"),
     314            QString::number(PlaybackBox::TitlesRecGroups));
     315    gc->addSelection(QObject::tr("Show Categories only"),
     316            QString::number(PlaybackBox::Categories));
     317    gc->addSelection(QObject::tr("Show Categories and Recording Groups"),
     318            QString::number(PlaybackBox::CategoriesRecGroups));
     319    gc->addSelection(QObject::tr("Show Recording Groups only"),
     320            QString::number(PlaybackBox::RecGroups));
    312321
    313322    gc->setHelpText(QObject::tr("Select what type of grouping to show on the Watch Recordings screen "
    314323                    "by default."));
     
    22292238    return gc;
    22302239}
    22312240
     2241class DefaultViewSettings: public VerticalConfigurationGroup,
     2242                           public TriggeredConfigurationGroup {
     2243public:
     2244    DefaultViewSettings():
     2245            VerticalConfigurationGroup(false, false, true, true),
     2246            TriggeredConfigurationGroup(false) {
     2247
     2248        HostComboBox *defaultView = DefaultView();
     2249        addChild(defaultView);
     2250        setTrigger(defaultView);
     2251
     2252        HostComboBox *titleSort = new HostComboBox("DisplayGroupTitleSort");
     2253        titleSort->setLabel(tr("Sort Titles"));
     2254        titleSort->addSelection(tr("Alphabetically"),
     2255                QString::number(PlaybackBox::TitleSortAlphabetical));
     2256        titleSort->addSelection(tr("By Recording Priority"),
     2257                QString::number(PlaybackBox::TitleSortRecPriority));
     2258
     2259        for (unsigned int ii = 0; ii < PlaybackBox::ViewTypes; ii++)
     2260        {
     2261            if (ii == PlaybackBox::TitlesOnly)
     2262                addTarget(QString::number(ii), titleSort);
     2263            else
     2264                addTarget(QString::number(ii),
     2265                        new VerticalConfigurationGroup(false, false));
     2266        }
     2267    }
     2268};
     2269
    22322270static HostCheckBox *PVR350OutputEnable()
    22332271{
    22342272    HostCheckBox *gc = new HostCheckBox("PVR350OutputEnable");
     
    30433081    pbox2->addChild(RememberRecGroup());
    30443082    pbox2->addChild(UseGroupNameAsAllPrograms());
    30453083    pbox2->addChild(LiveTVInAllPrograms());
    3046     pbox2->addChild(DefaultView());
     3084    pbox2->addChild(new DefaultViewSettings());
    30473085    addChild(pbox2);
    30483086
    30493087    addChild(new HwDecSettings());
     
    32683306    addChild(xboxset);
    32693307}
    32703308
     3309// 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
     
    3233    Q_OBJECT
    3334  public:
    3435    typedef enum { Play, Delete } BoxType;
    35     typedef enum { TitlesOnly, TitlesCategories, TitlesCategoriesRecGroups,
    36                    TitlesRecGroups, Categories, CategoriesRecGroups, RecGroups} ViewType;
    3736
     37    // ViewType values cannot change; they are stored in the database.
     38    typedef enum {
     39        TitlesOnly = 0,
     40        TitlesCategories = 1,
     41        TitlesCategoriesRecGroups = 2,
     42        TitlesRecGroups = 3,
     43        Categories = 4,
     44        CategoriesRecGroups = 5,
     45        RecGroups = 6,
     46        ViewTypes,                  // placeholder value, not in database
     47    } ViewType;
    3848
     49    // Sort function when TitlesOnly. Values are stored in database.
     50    typedef enum {
     51        TitleSortAlphabetical = 0,
     52        TitleSortRecPriority = 1,
     53        TitleSortMethods,           // placeholder value, not in database
     54    } ViewTitleSort;
     55
     56    typedef enum {
     57        VIEW_NONE       =  0x00,
     58        VIEW_TITLES     =  0x01,
     59        VIEW_CATEGORIES =  0x02,
     60        VIEW_RECGROUPS  =  0x04,
     61        VIEW_ALL        = ~0x00,
     62    } ViewMask;
     63
    3964    PlaybackBox(BoxType ltype, MythMainWindow *parent, const char *name = 0);
    4065   ~PlaybackBox(void);
    4166   
     
    326351    int listOrder;
    327352
    328353    bool playingSomething;
    329     bool titleView;
    330354
    331     bool useRecGroups;
    332     bool useCategories;
    333     void setDefaultView(int defaultView);
     355    ViewMask viewMask;
     356    void setDefaultView(ViewType defaultView);
    334357
    335358    yuv2rgb_fun    conv_yuv2rgba;
    336359    unsigned char *conv_rgba_buf;
  • programs/mythbackend/mainserver.cpp

     
    960960                       "recorded.lastmodified, recorded.findid, "
    961961                       "recorded.originalairdate, recorded.playgroup, "
    962962                       "recorded.basename, recorded.progstart, "
    963                        "recorded.progend "
     963                       "recorded.progend, recorded.recpriority "
    964964                       "FROM recorded "
    965965                       "LEFT JOIN record ON recorded.recordid = record.recordid "
    966966                       "LEFT JOIN channel ON recorded.chanid = channel.chanid "
     
    10721072            proginfo->recgroup = query.value(16).toString();
    10731073            proginfo->playgroup = query.value(27).toString();
    10741074
     1075            proginfo->recpriority = query.value(31).toInt();
     1076
    10751077            proginfo->recstatus = rsRecorded;
    10761078            if (proginfo->recendts > rectime)
    10771079            {