Ticket #3740: upcoming.patch

File upcoming.patch, 5.9 KB (added by Bill <cizek@…>, 17 years ago)
  • mythtv/programs/mythfrontend/viewscheduled.cpp

    diff -r -u -X diff.exclude myth.13871.0712a/mythtv/programs/mythfrontend/viewscheduled.cpp myth.13871.0712b/mythtv/programs/mythfrontend/viewscheduled.cpp
     
    5858        exit(FRONTEND_BUGGY_EXIT_NO_SELECTOR);
    5959    }
    6060
    61     updateBackground();
     61    curView = -1;
     62    fillViewList("time");
     63
     64    if (curView < 0)
     65        QApplication::postEvent(this, new MythEvent("CHOOSE_VIEW"));
     66
    6267
    6368    inEvent = false;
    6469    inFill = false;
     
    7075    maxinput = 0;
    7176    listPos  = 0;
    7277    FillList();
     78
     79    updateBackground();
    7380 
    7481    setNoErase();
    7582
     
    127134                setShowAll(true);
    128135            else if (action == "2")
    129136                setShowAll(false);
     137
     138            else if (action == "4")
     139            {
     140                if (viewList[curView] == "sort by time")
     141                    curView = viewList.findIndex("reverse time");
     142                else
     143                    curView = viewList.findIndex("sort by time");
     144
     145                needFill = true;
     146            }
     147            else if (action == "5")
     148            {
     149                if (viewList[curView] == "sort by title")
     150                    curView = viewList.findIndex("reverse title");
     151                else
     152                    curView = viewList.findIndex("sort by title");
     153
     154                needFill = true;
     155            }
     156
    130157            else if (action == "PREVVIEW" || action == "NEXTVIEW")
    131158                setShowAll(!showAll);
    132159            else if (action == "VIEWCARD")
     
    254281    }
    255282}
    256283
     284class pbTitleSort
     285{
     286    public:
     287        pbTitleSort(bool reverseSort = false) {m_reverse = reverseSort;}
     288
     289        bool operator()(const ProgramInfo *a, const ProgramInfo *b)
     290        {
     291            if (a->sortTitle == b->sortTitle)
     292            {
     293                if (a->programid == b->programid)
     294                    return (a->startts < b->startts);
     295                else
     296                    return (a->programid < b->programid);
     297            }
     298            else if (m_reverse)
     299                return (a->sortTitle > b->sortTitle);
     300            else
     301                return (a->sortTitle < b->sortTitle);
     302        }
     303
     304    private:
     305        bool m_reverse;
     306};
     307
     308class pbTimeSort
     309{
     310    public:
     311        pbTimeSort(bool reverseSort = false) {m_reverse = reverseSort;}
     312
     313        bool operator()(const ProgramInfo *a, const ProgramInfo *b)
     314        {
     315            if (m_reverse)
     316                return (a->startts > b->startts);
     317            else
     318                return (a->startts < b->startts);
     319        }
     320
     321    private:
     322        bool m_reverse;
     323};
     324
     325
    257326void ViewScheduled::FillList(void)
    258327{
    259328    inFill = true;
     
    303372        }
    304373    }
    305374
     375    if (recList.count() > 0) {
     376        // Sort the list
     377        ProgramInfo *s = recList.first();
     378        vector<ProgramInfo *> sortedList;
     379        while (recList.count())
     380        {
     381            s = recList.take();
     382            s->sortTitle = s->title;
     383            s->sortTitle.remove(QRegExp("^(The |A |An )"));
     384            sortedList.push_back(s);
     385        }
     386
     387        if (viewList[curView] == "reverse time")
     388            sort(sortedList.begin(), sortedList.end(), pbTimeSort(true));
     389        else if (viewList[curView] == "sort by time")
     390            sort(sortedList.begin(), sortedList.end(), pbTimeSort(false));
     391        else if (viewList[curView] == "reverse title")
     392            sort(sortedList.begin(), sortedList.end(), pbTitleSort(true));
     393        else
     394            sort(sortedList.begin(), sortedList.end(), pbTitleSort(false));
     395
     396        vector<ProgramInfo *>::iterator i = sortedList.begin();
     397        for (; i != sortedList.end(); i++)
     398            recList.append(*i);
     399    }
     400
    306401    if (!callsign.isNull())
    307402    {
    308403        listPos = recList.count() - 1;
     
    520615        UITextType *type = (UITextType *)container->GetType("showlevel");
    521616        if (type)
    522617        {
     618            QString newtag;
     619
     620            if (viewList[curView] == "sort by time")
     621                newtag += "+Time";
     622            else if (viewList[curView] == "reverse time")
     623                newtag += "-Time";
     624            else if (viewList[curView] == "sort by title")
     625                newtag += "+Title";
     626            else if (viewList[curView] == "reverse title")
     627                newtag += "-Title";
     628
    523629            if (showAll)
    524                 type->SetText(tr("All"));
     630                newtag += " All";
    525631            else
    526                 type->SetText(tr("Important"));
     632                newtag += " Important";
     633
     634
     635            type->SetText(tr(newtag));
    527636        }
    528637    }
    529638
     
    676785        p->showDetails();
    677786}
    678787
     788void ViewScheduled::fillViewList(const QString &view)
     789{
     790    viewList.clear();
     791    viewTextList.clear();
     792
     793    viewList << "sort by time";
     794    viewTextList << tr("Sort by Time");
     795
     796    viewList << "reverse time";
     797    viewTextList << tr("Reverse Time");
     798
     799    viewList << "sort by title";
     800    viewTextList << tr("Sort by Title");
     801
     802    viewList << "reverse title";
     803    viewTextList << tr("Reverse Title");
     804
     805    curView = viewList.findIndex(view);
     806
     807    if (curView < 0)
     808        curView = 0;
     809}
     810
    679811void ViewScheduled::selected()
    680812{
    681813    ProgramInfo *p = recList[listPos];
  • mythtv/programs/mythfrontend/viewscheduled.h

    diff -r -u -X diff.exclude myth.13871.0712a/mythtv/programs/mythfrontend/viewscheduled.h myth.13871.0712b/mythtv/programs/mythfrontend/viewscheduled.h
     
    7070    int listsize;
    7171
    7272    bool showAll;
     73    int curView;
     74    QStringList viewList;
     75    QStringList viewTextList;
     76
     77    MythPopupBox *choosePopup;
     78    MythListBox *chooseListBox;
     79    void fillViewList(const QString &view);
     80
     81
    7382
    7483    bool inEvent;
    7584    bool inFill;