Changeset View
Changeset View
Standalone View
Standalone View
src/kitemviews/kfileitemmodel.cpp
Show All 16 Lines | |||||
17 | * along with this program; if not, write to the * | 17 | * along with this program; if not, write to the * | ||
18 | * Free Software Foundation, Inc., * | 18 | * Free Software Foundation, Inc., * | ||
19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | ||
20 | *****************************************************************************/ | 20 | *****************************************************************************/ | ||
21 | 21 | | |||
22 | #include "kfileitemmodel.h" | 22 | #include "kfileitemmodel.h" | ||
23 | 23 | | |||
24 | #include "dolphin_generalsettings.h" | 24 | #include "dolphin_generalsettings.h" | ||
25 | #include "dolphin_detailsmodesettings.h" | ||||
25 | #include "dolphindebug.h" | 26 | #include "dolphindebug.h" | ||
26 | #include "private/kfileitemmodeldirlister.h" | 27 | #include "private/kfileitemmodeldirlister.h" | ||
27 | #include "private/kfileitemmodelsortalgorithm.h" | 28 | #include "private/kfileitemmodelsortalgorithm.h" | ||
28 | 29 | | |||
29 | #include <KLocalizedString> | 30 | #include <KLocalizedString> | ||
30 | #include <KUrlMimeData> | 31 | #include <KUrlMimeData> | ||
31 | 32 | | |||
32 | #include <QElapsedTimer> | 33 | #include <QElapsedTimer> | ||
▲ Show 20 Lines • Show All 1726 Lines • ▼ Show 20 Line(s) | 1759 | case NameRole: | |||
1759 | // The name role is handled as default fallback after the switch | 1760 | // The name role is handled as default fallback after the switch | ||
1760 | break; | 1761 | break; | ||
1761 | 1762 | | |||
1762 | case SizeRole: { | 1763 | case SizeRole: { | ||
1763 | if (itemA.isDir()) { | 1764 | if (itemA.isDir()) { | ||
1764 | // See "if (m_sortFoldersFirst || m_sortRole == SizeRole)" in KFileItemModel::lessThan(): | 1765 | // See "if (m_sortFoldersFirst || m_sortRole == SizeRole)" in KFileItemModel::lessThan(): | ||
1765 | Q_ASSERT(itemB.isDir()); | 1766 | Q_ASSERT(itemB.isDir()); | ||
1766 | 1767 | | |||
1767 | const QVariant valueA = a->values.value("size"); | 1768 | QVariant valueA, valueB; | ||
1768 | const QVariant valueB = b->values.value("size"); | 1769 | if (DetailsModeSettings::recursiveDirectorySizeLimit() > 0) { | ||
1770 | // use dir size then | ||||
1771 | valueA = a->values.value("size"); | ||||
1772 | valueB = b->values.value("size"); | ||||
1773 | } else { | ||||
1774 | valueA = a->values.value("count"); | ||||
1775 | valueB = b->values.value("count"); | ||||
1776 | } | ||||
1769 | if (valueA.isNull() && valueB.isNull()) { | 1777 | if (valueA.isNull() && valueB.isNull()) { | ||
1770 | result = 0; | 1778 | result = 0; | ||
1771 | } else if (valueA.isNull()) { | 1779 | } else if (valueA.isNull()) { | ||
1772 | result = -1; | 1780 | result = -1; | ||
1773 | } else if (valueB.isNull()) { | 1781 | } else if (valueB.isNull()) { | ||
1774 | result = +1; | 1782 | result = +1; | ||
1775 | } else { | 1783 | } else { | ||
1776 | result = valueA.toInt() - valueB.toInt(); | 1784 | if (valueA < valueB) { | ||
1785 | return -1; | ||||
1786 | } else { | ||||
1787 | return +1; | ||||
1788 | } | ||||
1777 | } | 1789 | } | ||
1778 | } else { | 1790 | } else { | ||
1779 | // See "if (m_sortFoldersFirst || m_sortRole == SizeRole)" in KFileItemModel::lessThan(): | 1791 | // See "if (m_sortFoldersFirst || m_sortRole == SizeRole)" in KFileItemModel::lessThan(): | ||
1780 | Q_ASSERT(!itemB.isDir()); | 1792 | Q_ASSERT(!itemB.isDir()); | ||
1781 | const KIO::filesize_t sizeA = itemA.size(); | 1793 | const KIO::filesize_t sizeA = itemA.size(); | ||
1782 | const KIO::filesize_t sizeB = itemB.size(); | 1794 | const KIO::filesize_t sizeB = itemB.size(); | ||
1783 | if (sizeA > sizeB) { | 1795 | if (sizeA > sizeB) { | ||
1784 | result = +1; | 1796 | result = +1; | ||
▲ Show 20 Lines • Show All 658 Lines • Show Last 20 Lines |