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 1729 Lines • ▼ Show 20 Line(s) | 1762 | case NameRole: | |||
| 1762 | // The name role is handled as default fallback after the switch | 1763 | // The name role is handled as default fallback after the switch | ||
| 1763 | break; | 1764 | break; | ||
| 1764 | 1765 | | |||
| 1765 | case SizeRole: { | 1766 | case SizeRole: { | ||
| 1766 | if (itemA.isDir()) { | 1767 | if (itemA.isDir()) { | ||
| 1767 | // See "if (m_sortFoldersFirst || m_sortRole == SizeRole)" in KFileItemModel::lessThan(): | 1768 | // See "if (m_sortFoldersFirst || m_sortRole == SizeRole)" in KFileItemModel::lessThan(): | ||
| 1768 | Q_ASSERT(itemB.isDir()); | 1769 | Q_ASSERT(itemB.isDir()); | ||
| 1769 | 1770 | | |||
| 1770 | const QVariant valueA = a->values.value("size"); | 1771 | QVariant valueA, valueB; | ||
| 1771 | const QVariant valueB = b->values.value("size"); | 1772 | if (DetailsModeSettings::directorySizeCount()) { | ||
| 1773 | // use dir size then | ||||
| 1774 | valueA = a->values.value("size"); | ||||
| 1775 | valueB = b->values.value("size"); | ||||
| 1776 | } else { | ||||
| 1777 | valueA = a->values.value("count"); | ||||
| 1778 | valueB = b->values.value("count"); | ||||
| 1779 | } | ||||
| 1772 | if (valueA.isNull() && valueB.isNull()) { | 1780 | if (valueA.isNull() && valueB.isNull()) { | ||
| 1773 | result = 0; | 1781 | result = 0; | ||
| 1774 | } else if (valueA.isNull()) { | 1782 | } else if (valueA.isNull()) { | ||
| 1775 | result = -1; | 1783 | result = -1; | ||
| 1776 | } else if (valueB.isNull()) { | 1784 | } else if (valueB.isNull()) { | ||
| 1777 | result = +1; | 1785 | result = +1; | ||
| 1778 | } else { | 1786 | } else { | ||
| 1779 | result = valueA.toInt() - valueB.toInt(); | 1787 | if (valueA < valueB) { | ||
| 1788 | return -1; | ||||
| 1789 | } else { | ||||
| 1790 | return +1; | ||||
| 1791 | } | ||||
| 1780 | } | 1792 | } | ||
| 1781 | } else { | 1793 | } else { | ||
| 1782 | // See "if (m_sortFoldersFirst || m_sortRole == SizeRole)" in KFileItemModel::lessThan(): | 1794 | // See "if (m_sortFoldersFirst || m_sortRole == SizeRole)" in KFileItemModel::lessThan(): | ||
| 1783 | Q_ASSERT(!itemB.isDir()); | 1795 | Q_ASSERT(!itemB.isDir()); | ||
| 1784 | const KIO::filesize_t sizeA = itemA.size(); | 1796 | const KIO::filesize_t sizeA = itemA.size(); | ||
| 1785 | const KIO::filesize_t sizeB = itemB.size(); | 1797 | const KIO::filesize_t sizeB = itemB.size(); | ||
| 1786 | if (sizeA > sizeB) { | 1798 | if (sizeA > sizeB) { | ||
| 1787 | result = +1; | 1799 | result = +1; | ||
| ▲ Show 20 Lines • Show All 660 Lines • Show Last 20 Lines | |||||