QChar extractLetter(QChar c) { QString decomposition = c.decomposition(); if (decomposition.isEmpty()) return c; int length = decomposition.length(); for (int i = 0; i < length; i++) if (decomposition.at(i).isLetter()) return decomposition.at(i); return c; }
static bool to8bit(const QChar ch, QCString *rstr) { bool converted = FALSE; if( ch.isMark() ) return TRUE; // ignore marks for conversion if ( ch.row() ) { if ( ch.row() == 0x05 ) { if ( ch.cell() > 0x91 ) converted = TRUE; // 0x0591 - 0x05cf: Hebrew punctuation... dropped if ( ch.cell() >= 0xD0 ) *rstr += (char)unicode_to_heb_05[ch.cell()- 0xD0]; } else if ( ch.row() == 0x20 ) { if ( ch.cell() == 0x3E ) { *rstr += (char)0xAF; converted = TRUE; } else if ( ch.cell() == 0x17 ) { *rstr += (char)0xCF; converted = TRUE; } } else { converted = FALSE; } } else { if ( ch.cell() < 0x80 ) { *rstr += (char)ch.cell(); converted = TRUE; } else if( ch.cell() < 0xA0 ) { *rstr += (char)unicode_to_heb_00[ch.cell() - 0x80]; converted = TRUE; } } if(converted) return TRUE; // couldn't convert the char... lets try its decomposition QString d = ch.decomposition(); if(d.isNull()) return FALSE; int l = d.length(); for (int i=0; i<l; i++) { const QChar ch = d[i]; if(to8bit(ch, rstr)) converted = TRUE; } return converted; }
QString LibraryModel::DividerKey(GroupBy type, LibraryItem* item) const { // Items which are to be grouped under the same divider must produce the // same divider key. This will only get called for top-level items. if (item->sort_text.isEmpty()) return QString(); switch (type) { case GroupBy_Album: case GroupBy_Artist: case GroupBy_Composer: case GroupBy_Performer: case GroupBy_Disc: case GroupBy_Grouping: case GroupBy_Genre: case GroupBy_AlbumArtist: case GroupBy_FileType: { QChar c = item->sort_text[0]; if (c.isDigit()) return "0"; if (c == ' ') return QString(); if (c.decompositionTag() != QChar::NoDecomposition) return QChar(c.decomposition()[0]); return c; } case GroupBy_Year: case GroupBy_OriginalYear: return SortTextForNumber(item->sort_text.toInt() / 10 * 10); case GroupBy_YearAlbum: return SortTextForNumber(item->metadata.year()); case GroupBy_OriginalYearAlbum: return SortTextForNumber(item->metadata.effective_originalyear()); case GroupBy_Bitrate: return SortTextForNumber(item->metadata.bitrate()); case GroupBy_None: return QString(); } qLog(Error) << "Unknown GroupBy type" << type << "for item" << item->display_text; return QString(); }