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 1718 Lines • ▼ Show 20 Line(s) | 1751 | case NameRole: | |||
1751 | // The name role is handled as default fallback after the switch | 1752 | // The name role is handled as default fallback after the switch | ||
1752 | break; | 1753 | break; | ||
1753 | 1754 | | |||
1754 | case SizeRole: { | 1755 | case SizeRole: { | ||
1755 | if (itemA.isDir()) { | 1756 | if (itemA.isDir()) { | ||
1756 | // See "if (m_sortFoldersFirst || m_sortRole == SizeRole)" in KFileItemModel::lessThan(): | 1757 | // See "if (m_sortFoldersFirst || m_sortRole == SizeRole)" in KFileItemModel::lessThan(): | ||
1757 | Q_ASSERT(itemB.isDir()); | 1758 | Q_ASSERT(itemB.isDir()); | ||
1758 | 1759 | | |||
1759 | const QVariant valueA = a->values.value("size"); | 1760 | QVariant valueA, valueB; | ||
1760 | const QVariant valueB = b->values.value("size"); | 1761 | if (DetailsModeSettings::recursiveDirectorySizeLimit() > 0) { | ||
1762 | // use dir size then | ||||
1763 | valueA = a->values.value("size"); | ||||
1764 | valueB = b->values.value("size"); | ||||
1765 | } else { | ||||
1766 | valueA = a->values.value("count"); | ||||
1767 | valueB = b->values.value("count"); | ||||
1768 | } | ||||
1761 | if (valueA.isNull() && valueB.isNull()) { | 1769 | if (valueA.isNull() && valueB.isNull()) { | ||
1762 | result = 0; | 1770 | result = 0; | ||
1763 | } else if (valueA.isNull()) { | 1771 | } else if (valueA.isNull()) { | ||
1764 | result = -1; | 1772 | result = -1; | ||
1765 | } else if (valueB.isNull()) { | 1773 | } else if (valueB.isNull()) { | ||
1766 | result = +1; | 1774 | result = +1; | ||
1767 | } else { | 1775 | } else { | ||
1768 | result = valueA.toInt() - valueB.toInt(); | 1776 | if (valueA < valueB) { | ||
1777 | return -1; | ||||
1778 | } else { | ||||
1779 | return +1; | ||||
1780 | } | ||||
1769 | } | 1781 | } | ||
1770 | } else { | 1782 | } else { | ||
1771 | // See "if (m_sortFoldersFirst || m_sortRole == SizeRole)" in KFileItemModel::lessThan(): | 1783 | // See "if (m_sortFoldersFirst || m_sortRole == SizeRole)" in KFileItemModel::lessThan(): | ||
1772 | Q_ASSERT(!itemB.isDir()); | 1784 | Q_ASSERT(!itemB.isDir()); | ||
1773 | const KIO::filesize_t sizeA = itemA.size(); | 1785 | const KIO::filesize_t sizeA = itemA.size(); | ||
1774 | const KIO::filesize_t sizeB = itemB.size(); | 1786 | const KIO::filesize_t sizeB = itemB.size(); | ||
1775 | if (sizeA > sizeB) { | 1787 | if (sizeA > sizeB) { | ||
1776 | result = +1; | 1788 | result = +1; | ||
▲ Show 20 Lines • Show All 656 Lines • Show Last 20 Lines |