protected:
void onGroupedSortingChanged(bool current) override;
- void onSortRoleChanged(const QByteArray& current, const QByteArray& previous) override;
+ void onSortRoleChanged(const QByteArray& current, const QByteArray& previous, bool resortItems = true) override;
void onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) override;
private slots:
// User visible roles available with Baloo:
CommentRole, TagsRole, RatingRole, WidthRole, HeightRole, ImageDateTimeRole, OrientationRole,
WordCountRole, TitleRole, LineCountRole, ArtistRole, GenreRole, AlbumRole, DurationRole, TrackRole, ReleaseYearRole,
- BitrateRole, OriginUrlRole,
+ BitrateRole, OriginUrlRole, AspectRatioRole, FrameRateRole,
// Non-visible roles:
IsDirRole, IsLinkRole, IsHiddenRole, IsExpandedRole, IsExpandableRole, ExpandedParentsCountRole,
// Mandatory last entry:
QHash<QByteArray, QVariant> retrieveData(const KFileItem& item, const ItemData* parent) const;
+ /**
+ * @return True if role values benefit from natural or case insensitive sorting.
+ */
+ static bool isRoleValueNatural(const RoleType roleType);
+
/**
* @return True if \a a has a KFileItem whose text is 'less than' the one
* of \a b according to QString::operator<(const QString&).
* Sorts the items between \a begin and \a end using the comparison
* function lessThan().
*/
- void sort(QList<ItemData*>::iterator begin, QList<ItemData*>::iterator end) const;
+ void sort(const QList<ItemData*>::iterator &begin, const QList<ItemData*>::iterator &end) const;
/**
* Helper method for lessThan() and expandedParentsCountCompare(): Compares
int stringCompare(const QString& a, const QString& b, const QCollator& collator) const;
- bool useMaximumUpdateInterval() const;
-
QList<QPair<int, QVariant> > nameRoleGroups() const;
QList<QPair<int, QVariant> > sizeRoleGroups() const;
- QList<QPair<int, QVariant> > timeRoleGroups(std::function<QDateTime(const ItemData *)> fileTimeCb) const;
+ QList<QPair<int, QVariant> > timeRoleGroups(const std::function<QDateTime(const ItemData *)> &fileTimeCb) const;
QList<QPair<int, QVariant> > permissionRoleGroups() const;
QList<QPair<int, QVariant> > ratingRoleGroups() const;
QList<QPair<int, QVariant> > genericStringRoleGroups(const QByteArray& typeForRole) const;
// and done step after step in slotCompleted().
QSet<QUrl> m_urlsToExpand;
- friend class KFileItemModelLessThan; // Accesses lessThan() method
friend class KFileItemModelRolesUpdater; // Accesses emitSortProgress() method
friend class KFileItemModelTest; // For unit testing
friend class KFileItemModelBenchmark; // For unit testing
friend class DolphinPart; // Accesses m_dirLister
};
+inline bool KFileItemModel::isRoleValueNatural(RoleType roleType)
+{
+ return (roleType == TypeRole ||
+ roleType == TagsRole ||
+ roleType == CommentRole ||
+ roleType == TitleRole ||
+ roleType == ArtistRole ||
+ roleType == GenreRole ||
+ roleType == AlbumRole ||
+ roleType == PathRole ||
+ roleType == DestinationRole ||
+ roleType == OriginUrlRole ||
+ roleType == OwnerRole ||
+ roleType == GroupRole);
+}
+
inline bool KFileItemModel::nameLessThan(const ItemData* a, const ItemData* b)
{
return a->item.text() < b->item.text();
}
-
inline bool KFileItemModel::isChildItem(int index) const
{
if (m_itemData.at(index)->parent) {