~ubuntu-branches/ubuntu/lucid/mythtv/lucid

« back to all changes in this revision

Viewing changes to programs/mythfrontend/progfind.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mario Limonciello, Mario Limonciello, John Baab
  • Date: 2009-09-29 01:33:23 UTC
  • mfrom: (1.1.35 upstream)
  • Revision ID: james.westby@ubuntu.com-20090929013323-6pvn8encm757zbxw
Tags: 0.22.0~trunk22101-0ubuntu1
[ Mario Limonciello ]
* New upstream checkout (r22101)
* Try to guard and make sure that ~mythtv is read from /etc/passwd 
  rather than assuming it's /home/mythtv.

[ John Baab ]
* debian/mythtv-common.postinst:
  - Added symlink for /home/mythtv/.mythtv/config.xml

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
 
2
#include "progfind.h"
 
3
 
2
4
// qt
3
5
#include <QDateTime>
4
6
#include <QApplication>
7
9
#include <QKeyEvent>
8
10
#include <QEvent>
9
11
 
10
 
// myth
11
 
#include "customedit.h"
12
 
#include "recordinginfo.h"
 
12
// libmythdb
13
13
#include "oldsettings.h"
14
 
#include "tv.h"
15
 
#include "guidegrid.h"
16
14
#include "mythdb.h"
17
 
#include "mythcontext.h"
18
15
#include "mythdbcon.h"
19
 
#include "mythuihelper.h"
20
16
#include "mythdirs.h"
21
 
#include "proglist.h"
 
17
 
 
18
// libmyth
 
19
#include "mythcontext.h"
 
20
 
 
21
// libmythtv
 
22
#include "recordinginfo.h"
 
23
#include "tv.h"
 
24
 
 
25
// libmythui
22
26
#include "mythuitext.h"
23
27
#include "mythuitextedit.h"
24
28
#include "mythuibuttonlist.h"
25
29
#include "mythuibutton.h"
 
30
#include "mythuihelper.h"
26
31
 
27
 
#include "progfind.h"
 
32
// mythfrontend
 
33
#include "guidegrid.h"
 
34
#include "proglist.h"
 
35
#include "customedit.h"
28
36
 
29
37
#define LOC      QString("ProgFinder: ")
30
38
#define LOC_ERR  QString("ProgFinder, Error: ")
51
59
ProgFinder::ProgFinder(MythScreenStack *parentStack, bool allowEPG,
52
60
                       TV *player, bool embedVideo)
53
61
          : ScheduleCommon(parentStack, "ProgFinder"),
54
 
    m_searchStr(QString::null),
55
62
    m_player(player),            m_embedVideo(embedVideo),
56
 
    m_allowEPG(allowEPG),        m_allowKeypress(false),
57
 
    m_dateFormat(QString::null), m_timeFormat(QString::null)
 
63
    m_allowEPG(allowEPG),        m_allowKeypress(true),
 
64
    m_alphabetList(NULL),        m_showList(NULL),
 
65
    m_timesList(NULL),           m_searchText(NULL),
 
66
    m_help1Text(NULL),           m_help2Text(NULL)
58
67
{
59
68
}
60
69
 
90
99
void ProgFinder::Init(void)
91
100
{
92
101
    m_allowKeypress = true;
93
 
 
 
102
    
94
103
    m_timeFormat = gContext->GetSetting("TimeFormat");
95
104
    m_dateFormat = gContext->GetSetting("DateFormat");
96
105
 
170
179
    QStringList actions;
171
180
    handled = GetMythMainWindow()->TranslateKeyPress("TV Frontend", event, actions);
172
181
 
173
 
    for (int i = 0; i < actions.size() && !handled; i++)
 
182
    for (int i = 0; i < actions.size() && !handled; ++i)
174
183
    {
175
184
        QString action = actions[i];
176
185
        handled = true;
270
279
        {
271
280
            if (resulttext == tr("Clear Search"))
272
281
            {
273
 
                m_searchStr = "";
 
282
                m_searchStr.clear();
274
283
                if (m_searchText)
275
284
                    m_searchText->SetText(m_searchStr);
276
285
                updateShowList();
331
340
 
332
341
    if (GetFocusWidget() == m_alphabetList)
333
342
    {
334
 
        QString title = "";
335
 
        QString description = "";
 
343
        QString title;
 
344
        QString description;
336
345
 
337
346
        if (m_showList->GetCount() == 0)
338
347
        {
392
401
    {
393
402
        QString startchannel = gContext->GetSetting("DefaultTVChannel");
394
403
        if (startchannel.isEmpty())
395
 
            startchannel = "3";
 
404
            startchannel = '3';
396
405
        uint startchanid = 0;
397
406
        GuideGrid::RunProgramGuide(startchanid, startchannel, m_player, m_embedVideo, false);
398
407
    }
476
485
            return;
477
486
 
478
487
        MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
479
 
        ProgLister *pl = new ProgLister(mainStack, plTitle, curPick->title, "");
 
488
        ProgLister *pl = new ProgLister(mainStack, plTitle, curPick->title,
 
489
                                        QString());
480
490
        if (pl->Create())
481
491
            mainStack->AddScreen(pl);
482
492
        else
502
512
 
503
513
void ProgFinder::updateTimesList()
504
514
{
505
 
    QString itemText = "";
506
 
 
507
515
    m_timesList->Reset();
508
516
 
509
517
    if (m_showData.size() > 0)
510
518
    {
511
 
        for (uint i = 0; i < m_showData.size(); i++)
 
519
        QString itemText;
 
520
        for (uint i = 0; i < m_showData.size(); ++i)
512
521
        {
513
522
            itemText = m_showData[i]->startts.toString(m_dateFormat)
514
 
                    + " " + m_showData[i]->startts.toString(m_timeFormat);
 
523
                    + ' ' + m_showData[i]->startts.toString(m_timeFormat);
515
524
 
516
525
            MythUIButtonListItem *item = new MythUIButtonListItem(m_timesList, "");
517
526
 
548
557
    m_showList->Reset();
549
558
 
550
559
    QString thequery;
551
 
    QString data;
552
560
    MSqlBindings bindings;
553
561
 
554
562
    MSqlQuery query(MSqlQuery::InitCon());
562
570
        return;
563
571
    }
564
572
 
565
 
    int rows = 0;
566
 
    if (query.next())
567
 
    {
568
 
        typedef QMap<QString,QString> ShowData;
569
 
        ShowData tempList;
570
 
 
571
 
        do
572
 
        {
573
 
            rows++;
574
 
            data = query.value(0).toString();
575
 
 
576
 
            if (formatSelectedData(data))
577
 
                tempList[data.toLower()] = data;
578
 
        }
579
 
        while (query.next());
580
 
 
581
 
        ShowData::Iterator it;
582
 
        for (it = tempList.begin(); it != tempList.end(); ++it)
583
 
        {
584
 
            QString tmpProgData = *it;
585
 
            restoreSelectedData(tmpProgData);
586
 
            new MythUIButtonListItem(m_showList, tmpProgData);
587
 
       }
 
573
    QString data;
 
574
    typedef QMap<QString,QString> ShowData;
 
575
    ShowData tempList; // Assign to temporary map for sorting
 
576
    while (query.next())
 
577
    {
 
578
        data = query.value(0).toString();
 
579
 
 
580
        if (formatSelectedData(data))
 
581
            tempList[data.toLower()] = data;
 
582
    }
 
583
 
 
584
    ShowData::Iterator it;
 
585
    for (it = tempList.begin(); it != tempList.end(); ++it)
 
586
    {
 
587
        QString tmpProgData = *it;
 
588
        restoreSelectedData(tmpProgData);
 
589
        new MythUIButtonListItem(m_showList, tmpProgData);
588
590
    }
589
591
}
590
592
 
611
613
 
612
614
void ProgFinder::initAlphabetList(void)
613
615
{
614
 
    for (int charNum = 48; charNum < 91; charNum++)
 
616
    for (int charNum = 48; charNum < 91; ++charNum)
615
617
    {
616
618
        if (charNum == 58)
617
619
            charNum = 65;
638
640
        if (!m_searchStr.isEmpty())
639
641
        {
640
642
            where += "AND title LIKE :SEARCH ";
641
 
            bindings[":SEARCH"] = "%" + m_searchStr + "%";
 
643
            bindings[":SEARCH"] = '%' + m_searchStr + '%';
642
644
        }
643
645
 
644
646
        where += "ORDER BY title;";
647
649
    }
648
650
    else
649
651
    {
650
 
        QString one = searchChar + "%";
 
652
        QString one = searchChar + '%';
651
653
        QString two = QString("The ") + one;
652
654
        QString three = QString("A ") + one;
653
655
        QString four = QString("An ") + one;
670
672
        bindings[":STARTTIME"] = progStart.toString("yyyy-MM-ddThh:mm:50");
671
673
 
672
674
        if (!m_searchStr.isEmpty())
673
 
            bindings[":SEARCH"] = "%" + m_searchStr + "%";
 
675
            bindings[":SEARCH"] = '%' + m_searchStr + '%';
674
676
    }
675
677
}
676
678
 
776
778
            : ProgFinder(parentStack, gg, player, embedVideo)
777
779
{
778
780
    for (numberOfSearchChars = 0; searchChars[numberOfSearchChars];
779
 
         numberOfSearchChars++)
 
781
         ++numberOfSearchChars)
780
782
         ;
781
783
}
782
784
 
783
785
void JaProgFinder::initAlphabetList()
784
786
{
785
 
    for (int charNum = 0; charNum < numberOfSearchChars; charNum++)
 
787
    for (int charNum = 0; charNum < numberOfSearchChars; ++charNum)
786
788
    {
787
789
        new MythUIButtonListItem(m_alphabetList, QString(searchChars[charNum]));
788
790
    }
843
845
    if (!m_searchStr.isEmpty())
844
846
    {
845
847
        where += "AND title_pronounce LIKE :SEARCH ";
846
 
        bindings[":SEARCH"] = "%" + m_searchStr + "%";
 
848
        bindings[":SEARCH"] = '%' + m_searchStr + '%';
847
849
    }
848
850
 
849
851
    where += "ORDER BY title_pronounce;";
883
885
            : ProgFinder(parentStack, gg, player, embedVideo)
884
886
{
885
887
    for (numberOfSearchChars = 0; searchChars[numberOfSearchChars];
886
 
         numberOfSearchChars++)
 
888
         ++numberOfSearchChars)
887
889
        ;
888
890
}
889
891
 
890
892
void HeProgFinder::initAlphabetList()
891
893
{
892
 
    for (int charNum = 0; charNum < numberOfSearchChars; charNum++)
 
894
    for (int charNum = 0; charNum < numberOfSearchChars; ++charNum)
893
895
    {
894
896
        new MythUIButtonListItem(m_alphabetList, QString(searchChars[charNum]));
895
897
    }
914
916
    }
915
917
    else
916
918
    {
917
 
        QString one = searchChar + "%";
 
919
        QString one = searchChar + '%';
918
920
        bindings[":ONE"] = one;
919
921
        where += "WHERE ( title LIKE :ONE ) ";
920
922
    }
924
926
    if (!m_searchStr.isEmpty())
925
927
    {
926
928
        where += "AND title LIKE :SEARCH ";
927
 
        bindings[":SEARCH"] = "%" + m_searchStr + "%";
 
929
        bindings[":SEARCH"] = '%' + m_searchStr + '%';
928
930
    }
929
931
 
930
932
    where += "ORDER BY title;";