Changeset View
Changeset View
Standalone View
Standalone View
src/kitemviews/kfileitemmodel.cpp
Show All 37 Lines | |||||
38 | Q_GLOBAL_STATIC_WITH_ARGS(QMutex, s_collatorMutex, (QMutex::Recursive)) | 38 | Q_GLOBAL_STATIC_WITH_ARGS(QMutex, s_collatorMutex, (QMutex::Recursive)) | ||
39 | 39 | | |||
40 | // #define KFILEITEMMODEL_DEBUG | 40 | // #define KFILEITEMMODEL_DEBUG | ||
41 | 41 | | |||
42 | KFileItemModel::KFileItemModel(QObject* parent) : | 42 | KFileItemModel::KFileItemModel(QObject* parent) : | ||
43 | KItemModelBase("text", parent), | 43 | KItemModelBase("text", parent), | ||
44 | m_dirLister(nullptr), | 44 | m_dirLister(nullptr), | ||
45 | m_sortDirsFirst(true), | 45 | m_sortDirsFirst(true), | ||
46 | m_sortHiddenLast(false), | ||||
46 | m_sortRole(NameRole), | 47 | m_sortRole(NameRole), | ||
47 | m_sortingProgressPercent(-1), | 48 | m_sortingProgressPercent(-1), | ||
48 | m_roles(), | 49 | m_roles(), | ||
49 | m_itemData(), | 50 | m_itemData(), | ||
50 | m_items(), | 51 | m_items(), | ||
51 | m_filter(), | 52 | m_filter(), | ||
52 | m_filteredItems(), | 53 | m_filteredItems(), | ||
53 | m_requestRole(), | 54 | m_requestRole(), | ||
▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Line(s) | 208 | { | |||
211 | } | 212 | } | ||
212 | } | 213 | } | ||
213 | 214 | | |||
214 | bool KFileItemModel::sortDirectoriesFirst() const | 215 | bool KFileItemModel::sortDirectoriesFirst() const | ||
215 | { | 216 | { | ||
216 | return m_sortDirsFirst; | 217 | return m_sortDirsFirst; | ||
217 | } | 218 | } | ||
218 | 219 | | |||
220 | void KFileItemModel::setSortHiddenLast(bool hiddenLast) | ||||
221 | { | ||||
222 | if (hiddenLast != m_sortHiddenLast) { | ||||
223 | m_sortHiddenLast = hiddenLast; | ||||
224 | resortAllItems(); | ||||
225 | } | ||||
226 | } | ||||
227 | | ||||
228 | bool KFileItemModel::sortHiddenLast() const | ||||
229 | { | ||||
230 | return m_sortHiddenLast; | ||||
231 | } | ||||
232 | | ||||
219 | void KFileItemModel::setShowHiddenFiles(bool show) | 233 | void KFileItemModel::setShowHiddenFiles(bool show) | ||
220 | { | 234 | { | ||
221 | m_dirLister->setShowingDotFiles(show); | 235 | m_dirLister->setShowingDotFiles(show); | ||
222 | m_dirLister->emitChanges(); | 236 | m_dirLister->emitChanges(); | ||
223 | if (show) { | 237 | if (show) { | ||
224 | dispatchPendingItemsToInsert(); | 238 | dispatchPendingItemsToInsert(); | ||
225 | } | 239 | } | ||
226 | } | 240 | } | ||
▲ Show 20 Lines • Show All 1482 Lines • ▼ Show 20 Line(s) | 1700 | if (a->parent != b->parent) { | |||
1709 | 1723 | | |||
1710 | // Compare the last parents of a and b which are different. | 1724 | // Compare the last parents of a and b which are different. | ||
1711 | while (a->parent != b->parent) { | 1725 | while (a->parent != b->parent) { | ||
1712 | a = a->parent; | 1726 | a = a->parent; | ||
1713 | b = b->parent; | 1727 | b = b->parent; | ||
1714 | } | 1728 | } | ||
1715 | } | 1729 | } | ||
1716 | 1730 | | |||
1731 | if (m_sortHiddenLast) { | ||||
1732 | const bool isHiddenA = a->item.isHidden(); | ||||
1733 | const bool isHiddenB = b->item.isHidden(); | ||||
1734 | if (isHiddenA && !isHiddenB) { | ||||
1735 | return false; | ||||
1736 | } else if (!isHiddenA && isHiddenB) { | ||||
1737 | return true; | ||||
1738 | } | ||||
1739 | } | ||||
1740 | | ||||
1717 | if (m_sortDirsFirst || m_sortRole == SizeRole) { | 1741 | if (m_sortDirsFirst || m_sortRole == SizeRole) { | ||
1718 | const bool isDirA = a->item.isDir(); | 1742 | const bool isDirA = a->item.isDir(); | ||
1719 | const bool isDirB = b->item.isDir(); | 1743 | const bool isDirB = b->item.isDir(); | ||
1720 | if (isDirA && !isDirB) { | 1744 | if (isDirA && !isDirB) { | ||
1721 | return true; | 1745 | return true; | ||
1722 | } else if (!isDirA && isDirB) { | 1746 | } else if (!isDirA && isDirB) { | ||
1723 | return false; | 1747 | return false; | ||
1724 | } | 1748 | } | ||
▲ Show 20 Lines • Show All 723 Lines • Show Last 20 Lines |