Ticket #6813: 032-watchrec.sort.1.patch

File 032-watchrec.sort.1.patch, 8.3 KB (added by anonymous, 15 years ago)
  • mythtv/programs/mythfrontend/playbackbox.cpp

    diff -p -r -u -N -X /tmp/diff.exclude -x release.21111.0803bare -x release.21111.0803bareb release.21111.0803bare/mythtv/programs/mythfrontend/playbackbox.cpp release.21111.0803bareb/mythtv/programs/mythfrontend/playbackbox.cpp
    const uint PreviewGenState::minBlockSeco 
    6060
    6161const uint PlaybackBox::previewGeneratorMaxRunning = 2;
    6262
     63static int comp_title(ProgramInfo *a, ProgramInfo *b)
     64{
     65    if (a->sortTitle == b->sortTitle)
     66    {
     67        return (a->recstartts < b->recstartts ? 1 : -1);
     68    }
     69    else
     70        return (a->sortTitle < b->sortTitle ? 1 : -1);
     71}
     72
     73static int comp_title_rev(ProgramInfo *a, ProgramInfo *b)
     74{
     75    return comp_title(b, a);
     76}
     77
    6378static int comp_programid(ProgramInfo *a, ProgramInfo *b)
    6479{
    6580    if (a->programid == b->programid)
    PlaybackBox::PlaybackBox(BoxType ltype,  
    246261      drawListBounds(0, 0, 0, 0),       drawInfoBounds(0, 0, 0, 0),
    247262      drawGroupBounds(0, 0, 0, 0),      drawUsageBounds(0, 0, 0, 0),
    248263      drawVideoBounds(0, 0, 0, 0),      blackholeBounds(0, 0, 0, 0),
    249       drawCurGroupBounds(0, 0, 0, 0),
     264      drawCurGroupBounds(0, 0, 0, 0),   drawSortOrderBounds(0, 0, 0, 0),
    250265      // General popup support
    251266      popup(NULL),                      expectingPopup(false),
    252267      // Recording Group popup support
    PlaybackBox::PlaybackBox(BoxType ltype,  
    308323    if (!drawTransPixmap)
    309324        drawTransPixmap = new QPixmap();
    310325
     326    episodeSort = gContext->GetSetting("PlayBoxEpisodeSort", "Date");
     327
    311328    bool displayCat  = gContext->GetNumSetting("DisplayRecGroupIsCategory", 0);
    312329    int  initialFilt = gContext->GetNumSetting("QueryInitialFilter", 0);
    313330
    void PlaybackBox::parseContainer(QDomEle 
    597614        drawUsageBounds = area;
    598615    if (name.lower() == "cur_group")
    599616        drawCurGroupBounds = area;
     617    if (name.lower() == "sortorder_info")
     618        drawSortOrderBounds = area;
    600619
    601620}
    602621
    void PlaybackBox::paintEvent(QPaintEvent 
    707726        updateUsage(&p);
    708727    }
    709728
     729    if (r.intersects(drawSortOrderBounds) && !paintSkipUpdate)
     730    {
     731        updateSortOrder(&p);
     732    }
     733
    710734    if (r.intersects(drawVideoBounds) && !paintSkipUpdate)
    711735    {
    712736        updateVideo(&p);
    void PlaybackBox::updateCurGroup(QPainte 
    776800    }
    777801}
    778802
     803void PlaybackBox::updateSortOrder(QPainter *p)
     804{
     805    QRect pr = drawSortOrderBounds;
     806    QPixmap pix(pr.size());
     807    pix.fill(this, pr.topLeft());
     808    QPainter tmp(&pix);
     809
     810    LayerSet *container = theme->GetSet("sortorder_info");
     811    if (container)
     812    {
     813        UITextType *type = (UITextType *)container->GetType("sortorder");
     814        if (type)
     815        {
     816            QString newtag = "(2) " + episodeSort;
     817            type->SetText(tr(newtag));
     818        }
     819    }
     820
     821    if (container)
     822    {
     823        container->Draw(&tmp, 4, 0);
     824        container->Draw(&tmp, 5, 0);
     825        container->Draw(&tmp, 6, 0);
     826        container->Draw(&tmp, 7, 0);
     827        container->Draw(&tmp, 8, 0);
     828    }
     829
     830    tmp.end();
     831    p->drawPixmap(pr.topLeft(), pix);
     832}
     833
    779834
    780835void PlaybackBox::updateGroupInfo(QPainter *p, QRect& pr,
    781836                                  QPixmap& pix, QString cont_name)
    bool PlaybackBox::FillList(bool useCache 
    18521907            if (p->title == "")
    18531908                p->title = tr("_NO_TITLE_");
    18541909
     1910            // Set sortTitle
     1911            QString tmptitle = p->title;
     1912            QString tmpsubtitle = p->subtitle;
     1913            tmptitle.remove(QRegExp("^(The |A |An )"));
     1914            tmpsubtitle.remove(QRegExp("^(The |A |An )"));
     1915            p->sortTitle = tmptitle + " - " + tmpsubtitle;
     1916
    18551917            if ((((p->recgroup == recGroup) ||
    18561918                  ((recGroup == "All Programs") &&
    18571919                   (p->recgroup != "Deleted") &&
    bool PlaybackBox::FillList(bool useCache 
    19742036        return 0;
    19752037    }
    19762038
    1977     QString episodeSort = gContext->GetSetting("PlayBoxEpisodeSort", "Date");
    1978 
    19792039    if (episodeSort == "OrigAirDate")
    19802040    {
    19812041        QMap<QString, ProgramList>::Iterator Iprog;
    bool PlaybackBox::FillList(bool useCache 
    20182078            }
    20192079        }
    20202080    }
     2081    else if (episodeSort == "Title")
     2082    {
     2083        QMap<QString, ProgramList>::Iterator Iprog;
     2084        for (Iprog = progLists.begin(); Iprog != progLists.end(); ++Iprog)
     2085        {
     2086            if (!Iprog.key().isEmpty())
     2087            {
     2088                if (listOrder == 0 || type == Delete)
     2089                    Iprog.data().Sort(comp_title_rev);
     2090                else
     2091                    Iprog.data().Sort(comp_title);
     2092            }
     2093        }
     2094    }
    20212095
    20222096    if (progLists[watchGroupLabel].count() > 1)
    20232097    {
    bool PlaybackBox::FillList(bool useCache 
    22782352                            if (oldprogramid > p->programid)
    22792353                                break;
    22802354                        }
    2281                         else
     2355                        else if (episodeSort == "Date")
    22822356                        {
    22832357                            if (oldstartts > p->recstartts)
    22842358                                break;
    22852359                        }
     2360                        else
     2361                        {
     2362                            if (oldsTitle > sTitle)
     2363                                break;
     2364                        }
    22862365                    }
    22872366                    else
    22882367                    {
    bool PlaybackBox::FillList(bool useCache 
    22962375                            if (oldprogramid < p->programid)
    22972376                                break;
    22982377                        }
    2299                         else
     2378                        else if (episodeSort == "Date")
    23002379                        {
    23012380                            if (oldstartts < p->recstartts)
    23022381                                break;
    23032382                        }
     2383                        else
     2384                        {
     2385                            if (oldsTitle > sTitle)
     2386                                break;
     2387                        }
    23042388                    }
    23052389                }
    23062390            }
    void PlaybackBox::keyPressEvent(QKeyEven 
    42694353            exitWin();
    42704354        else if (action == "1" || action == "HELP")
    42714355            showIconHelp();
     4356        else if (action == "2")
     4357        {
     4358            // Update Sort Order
     4359            if (episodeSort == "OrigAirDate") {
     4360                episodeSort = "Id";
     4361            } else if (episodeSort == "Id") {
     4362                episodeSort = "Title";
     4363            } else if (episodeSort == "Title") {
     4364                episodeSort = "Date";
     4365            } else { /* (episodeSort == "Date") */
     4366                episodeSort = "OrigAirDate";
     4367            }
     4368
     4369            connected = FillList(true);
     4370            paintSkipUpdate = false;
     4371            update(drawTotalBounds);
     4372        }
    42724373        else if (action == "MENU")
    42734374            showMenu();
    42744375        else if (action == "NEXTFAV")
  • mythtv/programs/mythfrontend/playbackbox.h

    diff -p -r -u -N -X /tmp/diff.exclude -x release.21111.0803bare -x release.21111.0803bareb release.21111.0803bare/mythtv/programs/mythfrontend/playbackbox.h release.21111.0803bareb/mythtv/programs/mythfrontend/playbackbox.h
    class PlaybackBox : public MythDialog 
    332332    void updateShowTitles(QPainter *);
    333333    void updateInfo(QPainter *);
    334334    void updateUsage(QPainter *);
     335    void updateSortOrder(QPainter *);
    335336    void updateProgramInfo(QPainter *p, QRect& pr, QPixmap& pix);
    336337    void updateCurGroup(QPainter *p);
    337338    void updateGroupInfo(QPainter *p, QRect& pr, QPixmap& pix,
    class PlaybackBox : public MythDialog 
    347348    QString             formatShortDate;
    348349    QString             formatLongDate;
    349350    QString             formatTime;
     351
     352    QString             episodeSort;
    350353    /// titleView controls showing titles in group list
    351354    bool                titleView;
    352355    /// useCategories controls showing categories in group list
    class PlaybackBox : public MythDialog 
    401404    QRect               drawVideoBounds;
    402405    QRect               blackholeBounds;
    403406    QRect               drawCurGroupBounds;
     407    QRect               drawSortOrderBounds;
    404408
    405409    // Popup support //////////////////////////////////////////////////////////
    406410    // General popup support