Ticket #691: mythplugins_691.patch

File mythplugins_691.patch, 2.0 KB (added by DanielSherwood, 18 years ago)
  • mythmusic/mythmusic/search.cpp

     
    104104    QString queryString("SELECT filename, artist, album, title, intid "
    105105                        "FROM musicmetadata ");
    106106
     107    QStringList list = QStringList::split(
     108        QRegExp("[>,]"), searchText);
    107109    if (!searchText.isEmpty())
    108110    {
    109         QStringList list = QStringList::split(
    110             QRegExp("[>,]"), searchText);
    111111        whereClause = "";
    112112        if (substringSearch) // alpha
    113113        {
     
    163163        QString text(aComposer + ": " + aTitle + "; " +
    164164                     query.value(3).toString() );
    165165
     166        // Highlight matches as appropriate
     167        if(!searchText.isEmpty()) {
     168            if (substringSearch) // alpha
     169            {
     170                for (uint i = 0; i < list.count(); i++)
     171                {
     172                    QString stxt = list[i].stripWhiteSpace();
     173                    int index = -1;
     174                    while( (index = text.findRev(stxt, index, false)) != -1 ) {
     175                        text.insert(index + stxt.length(), "]");
     176                        text.insert(index, "[");
     177                    }
     178                }
     179            }
     180            else // numeric
     181            {
     182                for (uint i = 0; i < list.count(); i++)
     183                {
     184                    QString stxt = list[i].stripWhiteSpace();
     185                    int index = -1;
     186                    while( (index = text.findRev(QRegExp(stxt, false), index)) != -1 ) {
     187                        text.insert(index + stxt.contains('['), "]");
     188                        text.insert(index, "[");
     189                    }
     190                }
     191            }
     192        }
     193
    166194        // Insert item into listbox, including song identifier
    167195        listbox->insertItem(new SearchListBoxItem(
    168196                                QString::fromUtf8(text),