Changeset View
Changeset View
Standalone View
Standalone View
src/kitemviews/kfileitemmodel.cpp
Show First 20 Lines • Show All 1839 Lines • ▼ Show 20 Line(s) | 1838 | case DeletionTimeRole: { | |||
---|---|---|---|---|---|
1840 | const QDateTime dateTimeB = b->values.value("deletiontime").toDateTime(); | 1840 | const QDateTime dateTimeB = b->values.value("deletiontime").toDateTime(); | ||
1841 | if (dateTimeA < dateTimeB) { | 1841 | if (dateTimeA < dateTimeB) { | ||
1842 | result = -1; | 1842 | result = -1; | ||
1843 | } else if (dateTimeA > dateTimeB) { | 1843 | } else if (dateTimeA > dateTimeB) { | ||
1844 | result = +1; | 1844 | result = +1; | ||
1845 | } | 1845 | } | ||
1846 | break; | 1846 | break; | ||
1847 | } | 1847 | } | ||
1848 | 1848 | | |||
1849 | case RatingRole: { | 1849 | case RatingRole: | ||
1850 | result = a->values.value("rating").toInt() - b->values.value("rating").toInt(); | 1850 | case WidthRole: | ||
ngraham: Maybe make it explicit that we're falling through for these with`Q_FALLTHROUGH()` | |||||
TBH, I never heard of Q_FALLTHROUGH() before, so I had to look it up & found this: https://wiki.qt.io/Qt_Coding_Style#Switch_statements Qt advises to not use this if another case follows immediately, but I can obviously still do this if this way is preferred here. xyquadrat: TBH, I never heard of `Q_FALLTHROUGH()` before, so I had to look it up & found this: https… | |||||
Hmm, what do you think @elvisangelaccio? ngraham: Hmm, what do you think @elvisangelaccio? | |||||
elvisangelaccio: Correct, `Q_FALLTHROUGH` is not supposed to be used here. | |||||
ngraham: Gotcha, thanks for the correction! | |||||
1851 | break; | 1851 | case HeightRole: { | ||
1852 | } | 1852 | result = a->values.value(roleForType(m_sortRole)).toInt() - b->values.value(roleForType(m_sortRole)).toInt(); | ||
1853 | | ||||
1854 | case ImageSizeRole: { | | |||
1855 | // Alway use a natural comparing to interpret the numbers of a string like | | |||
1856 | // "1600 x 1200" for having a correct sorting. | | |||
1857 | result = collator.compare(a->values.value("imageSize").toString(), | | |||
1858 | b->values.value("imageSize").toString()); | | |||
1859 | break; | 1853 | break; | ||
Since we are splitting into width/height, we can just convert them to int, no? elvisangelaccio: Since we are splitting into width/height, we can just convert them to int, no? | |||||
1860 | } | 1854 | } | ||
1861 | 1855 | | |||
1862 | default: { | 1856 | default: { | ||
1863 | const QByteArray role = roleForType(m_sortRole); | 1857 | const QByteArray role = roleForType(m_sortRole); | ||
1864 | result = QString::compare(a->values.value(role).toString(), | 1858 | result = QString::compare(a->values.value(role).toString(), | ||
1865 | b->values.value(role).toString()); | 1859 | b->values.value(role).toString()); | ||
1866 | break; | 1860 | break; | ||
1867 | } | 1861 | } | ||
▲ Show 20 Lines • Show All 432 Lines • ▼ Show 20 Line(s) | 2287 | // | role | roleType | role translation | group translation | requires Baloo | requires indexer | |||
2300 | { "type", TypeRole, I18N_NOOP2_NOSTRIP("@label", "Type"), nullptr, nullptr, false, false }, | 2294 | { "type", TypeRole, I18N_NOOP2_NOSTRIP("@label", "Type"), nullptr, nullptr, false, false }, | ||
2301 | { "rating", RatingRole, I18N_NOOP2_NOSTRIP("@label", "Rating"), nullptr, nullptr, true, false }, | 2295 | { "rating", RatingRole, I18N_NOOP2_NOSTRIP("@label", "Rating"), nullptr, nullptr, true, false }, | ||
2302 | { "tags", TagsRole, I18N_NOOP2_NOSTRIP("@label", "Tags"), nullptr, nullptr, true, false }, | 2296 | { "tags", TagsRole, I18N_NOOP2_NOSTRIP("@label", "Tags"), nullptr, nullptr, true, false }, | ||
2303 | { "comment", CommentRole, I18N_NOOP2_NOSTRIP("@label", "Comment"), nullptr, nullptr, true, false }, | 2297 | { "comment", CommentRole, I18N_NOOP2_NOSTRIP("@label", "Comment"), nullptr, nullptr, true, false }, | ||
2304 | { "title", TitleRole, I18N_NOOP2_NOSTRIP("@label", "Title"), I18N_NOOP2_NOSTRIP("@label", "Document"), true, true }, | 2298 | { "title", TitleRole, I18N_NOOP2_NOSTRIP("@label", "Title"), I18N_NOOP2_NOSTRIP("@label", "Document"), true, true }, | ||
2305 | { "wordCount", WordCountRole, I18N_NOOP2_NOSTRIP("@label", "Word Count"), I18N_NOOP2_NOSTRIP("@label", "Document"), true, true }, | 2299 | { "wordCount", WordCountRole, I18N_NOOP2_NOSTRIP("@label", "Word Count"), I18N_NOOP2_NOSTRIP("@label", "Document"), true, true }, | ||
2306 | { "lineCount", LineCountRole, I18N_NOOP2_NOSTRIP("@label", "Line Count"), I18N_NOOP2_NOSTRIP("@label", "Document"), true, true }, | 2300 | { "lineCount", LineCountRole, I18N_NOOP2_NOSTRIP("@label", "Line Count"), I18N_NOOP2_NOSTRIP("@label", "Document"), true, true }, | ||
2307 | { "imageDateTime", ImageDateTimeRole, I18N_NOOP2_NOSTRIP("@label", "Date Photographed"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, | 2301 | { "imageDateTime", ImageDateTimeRole, I18N_NOOP2_NOSTRIP("@label", "Date Photographed"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, | ||
2308 | { "imageSize", ImageSizeRole, I18N_NOOP2_NOSTRIP("@label", "Image Size"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, | 2302 | { "width", WidthRole, I18N_NOOP2_NOSTRIP("@label", "Width"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, | ||
2303 | { "height", HeightRole, I18N_NOOP2_NOSTRIP("@label", "Height"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, | ||||
2309 | { "orientation", OrientationRole, I18N_NOOP2_NOSTRIP("@label", "Orientation"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, | 2304 | { "orientation", OrientationRole, I18N_NOOP2_NOSTRIP("@label", "Orientation"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, | ||
2310 | { "artist", ArtistRole, I18N_NOOP2_NOSTRIP("@label", "Artist"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, | 2305 | { "artist", ArtistRole, I18N_NOOP2_NOSTRIP("@label", "Artist"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, | ||
2311 | { "genre", GenreRole, I18N_NOOP2_NOSTRIP("@label", "Genre"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, | 2306 | { "genre", GenreRole, I18N_NOOP2_NOSTRIP("@label", "Genre"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, | ||
2312 | { "album", AlbumRole, I18N_NOOP2_NOSTRIP("@label", "Album"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, | 2307 | { "album", AlbumRole, I18N_NOOP2_NOSTRIP("@label", "Album"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, | ||
2313 | { "duration", DurationRole, I18N_NOOP2_NOSTRIP("@label", "Duration"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, | 2308 | { "duration", DurationRole, I18N_NOOP2_NOSTRIP("@label", "Duration"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, | ||
2314 | { "bitrate", BitrateRole, I18N_NOOP2_NOSTRIP("@label", "Bitrate"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, | 2309 | { "bitrate", BitrateRole, I18N_NOOP2_NOSTRIP("@label", "Bitrate"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, | ||
2315 | { "track", TrackRole, I18N_NOOP2_NOSTRIP("@label", "Track"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, | 2310 | { "track", TrackRole, I18N_NOOP2_NOSTRIP("@label", "Track"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, | ||
2316 | { "releaseYear", ReleaseYearRole, I18N_NOOP2_NOSTRIP("@label", "Release Year"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, | 2311 | { "releaseYear", ReleaseYearRole, I18N_NOOP2_NOSTRIP("@label", "Release Year"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, | ||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |
Maybe make it explicit that we're falling through for these with`Q_FALLTHROUGH()`