Ticket #8807: Cyrrilic_specific_program_finder.patch

File Cyrrilic_specific_program_finder.patch, 6.0 KB (added by sandybigboy@…, 14 years ago)
  • programs/mythfrontend/progfind.cpp

    diff -Nupr mythtv-0.23/programs/mythfrontend/progfind.cpp mythtv-0.23.old/programs/mythfrontend/progfind.cpp
    old new void RunProgramFinder(TV *player, bool e 
    3838        programFind = new JaProgFinder(mainStack, allowEPG, player, embedVideo);
    3939    else if (GetMythUI()->GetLanguage() == "he")
    4040        programFind = new HeProgFinder(mainStack, allowEPG, player, embedVideo);
     41    else if (GetMythUI()->GetLanguage() == "ru")
     42        programFind = new RuProgFinder(mainStack, allowEPG, player, embedVideo);
    4143    else // default
    4244        programFind = new ProgFinder(mainStack, allowEPG, player, embedVideo);
    4345
    void ProgFinder::getShowNames() 
    553555    while (query.next())
    554556    {
    555557        data = query.value(0).toString();
    556 
    557         if (formatSelectedData(data))
     558         if (formatSelectedData(data))
    558559            m_showNames[data.toLower()] = data;
    559560    }
    560561}
    void HeProgFinder::restoreSelectedData(Q 
    946947
    947948//////////////////////////////////////////////////////////////////////////////
    948949
     950// Cyrrilic specific program finder
     951// Cyrrilic alphabet list and more
     952const char* RuProgFinder::searchChars[] = {
     953    "А", "Б", "В", "Г", "Д", "Е", "Ё", "Ж", "З", "И",
     954    "Й", "К", "Л", "М", "Н", "О", "П", "Р", "С", "Т",
     955    "У", "Ѐ", "Ð¥", "Њ", "Ч", "К", "Щ", "Ъ", "Ы", "ь",
     956    "Э", "Ю", "Я", "0", "1", "2", "3", "4", "5", "6",
     957    "7", "8", "9", "@", "A", "B", "C", "D", "E", "F",
     958    "G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
     959    "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", 0 };
     960
     961RuProgFinder::RuProgFinder(MythScreenStack *parentStack, bool gg,
     962                           TV *player, bool embedVideo)
     963            : ProgFinder(parentStack, gg, player, embedVideo)
     964{
     965    for (numberOfSearchChars = 0; searchChars[numberOfSearchChars];
     966         ++numberOfSearchChars)
     967        ;
     968}
     969
     970void RuProgFinder::initAlphabetList()
     971{
     972    for (int charNum = 0; charNum < numberOfSearchChars; ++charNum)
     973    {
     974        new MythUIButtonListItem(m_alphabetList, QString::fromUtf8(searchChars[charNum]));
     975    }
     976}
     977
     978// search by cyrillic and latin alphabet
     979// @ all programm
     980void RuProgFinder::whereClauseGetSearchData(QString &where, MSqlBindings
     981&bindings)
     982{
     983   QDateTime progStart = QDateTime::currentDateTime();
     984   QString searchChar = m_alphabetList->GetValue();
     985
     986   if (searchChar.isEmpty())
     987       searchChar = searchChars[0];
     988
     989
     990  if (searchChar.contains('@'))
     991   {
     992       where = "SELECT DISTINCT title FROM program WHERE ( "
     993                  "title NOT REGEXP '^[A-Z0-9]' AND "
     994                  "title NOT REGEXP '^The [A-Z0-9]' AND "
     995                  "title NOT REGEXP '^A [A-Z0-9]' AND "
     996                  "title NOT REGEXP '^[0-9]' AND "
     997                  "starttime > :STARTTIME ) ";
     998       if (!m_searchStr.isEmpty())
     999       {
     1000           where += "AND title LIKE :SEARCH ";
     1001           bindings[":SEARCH"] = '%' + m_searchStr + '%';
     1002       }
     1003
     1004       where += "ORDER BY title;";
     1005
     1006       bindings[":STARTTIME"] = progStart.toString("yyyy-MM-ddThh:mm:50");
     1007   }
     1008   else
     1009   {
     1010       QString one = searchChar + '%';
     1011       QString two = QString("The ") + one;
     1012       QString three = QString("A ") + one;
     1013       QString four = QString("An ") + one;
     1014       QString five = QString("\"") + one;
     1015
     1016       where = "SELECT DISTINCT title "
     1017               "FROM program "
     1018               "WHERE ( title LIKE :ONE OR title LIKE :TWO "
     1019               "        OR title LIKE :THREE "
     1020               "        OR title LIKE :FOUR  "
     1021               "        OR title LIKE :FIVE )"
     1022               "AND starttime > :STARTTIME ";
     1023       if (!m_searchStr.isEmpty())
     1024           where += "AND title LIKE :SEARCH ";
     1025
     1026       where += "ORDER BY title;";
     1027
     1028       bindings[":ONE"] = one;
     1029       bindings[":TWO"] = two;
     1030       bindings[":THREE"] = three;
     1031       bindings[":FOUR"] = four;
     1032       bindings[":FIVE"] = five;
     1033       bindings[":STARTTIME"] = progStart.toString("yyyy-MM-ddThh:mm:50");
     1034
     1035       if (!m_searchStr.isEmpty())
     1036           bindings[":SEARCH"] = '%' + m_searchStr + '%';
     1037   }
     1038}
     1039
     1040bool RuProgFinder::formatSelectedData(QString& data)
     1041{
     1042    (void)data;
     1043    return true;
     1044}
     1045
     1046bool RuProgFinder::formatSelectedData(QString& data, int charNum)
     1047{
     1048    (void)data;
     1049    (void)charNum;
     1050    return true;
     1051}
     1052
     1053void RuProgFinder::restoreSelectedData(QString& data)
     1054{
     1055    (void)data;
     1056}
     1057//////////////////////////////////////////////////////////////////////////////
     1058
    9491059SearchInputDialog::SearchInputDialog(MythScreenStack *parent,
    9501060                                     const QString &defaultValue)
    9511061                 : MythTextInputDialog(parent, "", FilterNone,
  • programs/mythfrontend/progfind.h

    diff -Nupr mythtv-0.23/programs/mythfrontend/progfind.h mythtv-0.23.old/programs/mythfrontend/progfind.h
    old new class HeProgFinder : public ProgFinder 
    130130    static const char* searchChars[];
    131131    int numberOfSearchChars;
    132132};
     133///////////////////////////////
     134class RuProgFinder : public ProgFinder
     135{
     136  public:
     137    explicit RuProgFinder(MythScreenStack *parentStack, bool gg = false,
     138                       TV *player = NULL, bool embedVideo = false);
     139                       
     140  protected:
     141    virtual void initAlphabetList();
     142    virtual bool formatSelectedData(QString &data);
     143    virtual bool formatSelectedData(QString &data, int charNum);
     144    virtual void restoreSelectedData(QString &data);
     145    virtual void whereClauseGetSearchData(QString &where, MSqlBindings &bindings);
     146                                             
     147  private:
     148    static const char* searchChars[];
     149    int numberOfSearchChars;
     150};
     151///////////////////////////////////
    133152
    134153class SearchInputDialog : public MythTextInputDialog
    135154{