[vlc-devel] [PATCH 05/33] QML: add sections to the MusicTrackListDisplay
Adrien Maglo
magsoft at videolan.org
Wed Jun 12 18:00:59 CEST 2019
On 12/06/2019 15:01, Hugo Beauzée-Luyssen wrote:
>> +QString MLAlbumTrackModel::getFirstSymbol( const QString str )
>> +{
>> + QString ret("#");
>> + if ( str.length() > 0 && str[0].isLetter() )
>> + ret = str[0].toUpper();
>> + return ret;
>> +}
>
> Can't this be achieved in JS/qml without exposing an additional property?
Not as far as I know.
With the "section.property" ListView property you can specify a model
property for the header section. With the "section.criteria" you can
choose whether you want the section being created by the first character
of the model property (ViewSection.FirstCharacter) or the full string
(ViewSection.FullString).
As I wanted to merge all the non-letter characters into a "#" section, I
have not found an other way than defining new model properties and
choose ViewSection.FullString as the "section.criteria"
Ref: https://doc.qt.io/qt-5/qml-qtquick-listview.html#section.property-prop
>> diff --git
>> a/modules/gui/qt/components/mediacenter/mlalbumtrackmodel.hpp
>> b/modules/gui/qt/components/mediacenter/mlalbumtrackmodel.hpp
>> index 4314ff229a..179fb1a383 100644
>> --- a/modules/gui/qt/components/mediacenter/mlalbumtrackmodel.hpp
>> +++ b/modules/gui/qt/components/mediacenter/mlalbumtrackmodel.hpp
>> @@ -49,5 +49,7 @@ private:
>> virtual void onVlcMlEvent( const vlc_ml_event_t* event ) override;
>>
>> static QHash<QByteArray, vlc_ml_sorting_criteria_t>
>> M_names_to_criteria;
>> +
>> + static QString getFirstSymbol( const QString str );
>
> (And in case you need the property, you probably meant "const QString& str" here!)
Ok, will be fixed.
Thanks,
--
MagSoft
More information about the vlc-devel
mailing list