Changeset View
Changeset View
Standalone View
Standalone View
src/kitemviews/kfileitemmodelrolesupdater.cpp
Show First 20 Lines • Show All 744 Lines • ▼ Show 20 Line(s) | 744 | connect(m_model, &KFileItemModel::itemsChanged, | |||
---|---|---|---|---|---|
745 | this, &KFileItemModelRolesUpdater::slotItemsChanged); | 745 | this, &KFileItemModelRolesUpdater::slotItemsChanged); | ||
746 | #else | 746 | #else | ||
747 | #ifndef Q_CC_MSVC | 747 | #ifndef Q_CC_MSVC | ||
748 | Q_UNUSED(item) | 748 | Q_UNUSED(item) | ||
749 | #endif | 749 | #endif | ||
750 | #endif | 750 | #endif | ||
751 | } | 751 | } | ||
752 | 752 | | |||
753 | void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QString& path, int count) | 753 | void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QString& path, int count, long size) | ||
754 | { | 754 | { | ||
755 | const bool getSizeRole = m_roles.contains("size"); | 755 | const bool getSizeRole = m_roles.contains("size"); | ||
756 | const bool getIsExpandableRole = m_roles.contains("isExpandable"); | 756 | const bool getIsExpandableRole = m_roles.contains("isExpandable"); | ||
757 | 757 | | |||
758 | if (getSizeRole || getIsExpandableRole) { | 758 | if (getSizeRole || getIsExpandableRole) { | ||
759 | const int index = m_model->index(QUrl::fromLocalFile(path)); | 759 | const int index = m_model->index(QUrl::fromLocalFile(path)); | ||
760 | if (index >= 0) { | 760 | if (index >= 0) { | ||
761 | QHash<QByteArray, QVariant> data; | 761 | QHash<QByteArray, QVariant> data; | ||
762 | 762 | | |||
763 | if (getSizeRole) { | 763 | if (getSizeRole) { | ||
764 | data.insert("size", count); | 764 | data.insert("count", count); | ||
765 | data.insert("size", QVariant::fromValue(size)); | ||||
765 | } | 766 | } | ||
766 | if (getIsExpandableRole) { | 767 | if (getIsExpandableRole) { | ||
767 | data.insert("isExpandable", count > 0); | 768 | data.insert("isExpandable", count > 0); | ||
768 | } | 769 | } | ||
769 | 770 | | |||
770 | disconnect(m_model, &KFileItemModel::itemsChanged, | 771 | disconnect(m_model, &KFileItemModel::itemsChanged, | ||
771 | this, &KFileItemModelRolesUpdater::slotItemsChanged); | 772 | this, &KFileItemModelRolesUpdater::slotItemsChanged); | ||
772 | m_model->setData(index, data); | 773 | m_model->setData(index, data); | ||
773 | connect(m_model, &KFileItemModel::itemsChanged, | 774 | connect(m_model, &KFileItemModel::itemsChanged, | ||
774 | this, &KFileItemModelRolesUpdater::slotItemsChanged); | 775 | this, &KFileItemModelRolesUpdater::slotItemsChanged); | ||
elvisangelaccio: Why remove these? | |||||
To allow the slotItemsChanged to be called when new data about fileSize arrives. meven: To allow the slotItemsChanged to be called when new data about fileSize arrives.
It is needed… | |||||
I see. Please do mention this "progressive ordering" in the commit message. elvisangelaccio: I see. Please do mention this "progressive ordering" in the commit message. | |||||
775 | } | 776 | } | ||
776 | } | 777 | } | ||
777 | } | 778 | } | ||
778 | 779 | | |||
779 | void KFileItemModelRolesUpdater::startUpdating() | 780 | void KFileItemModelRolesUpdater::startUpdating() | ||
780 | { | 781 | { | ||
781 | if (m_state == Paused) { | 782 | if (m_state == Paused) { | ||
782 | return; | 783 | return; | ||
▲ Show 20 Lines • Show All 209 Lines • ▼ Show 20 Line(s) | 989 | { | |||
992 | if (m_model->sortRole() == "type") { | 993 | if (m_model->sortRole() == "type") { | ||
993 | if (!item.isMimeTypeKnown()) { | 994 | if (!item.isMimeTypeKnown()) { | ||
994 | item.determineMimeType(); | 995 | item.determineMimeType(); | ||
995 | } | 996 | } | ||
996 | 997 | | |||
997 | data.insert("type", item.mimeComment()); | 998 | data.insert("type", item.mimeComment()); | ||
998 | } else if (m_model->sortRole() == "size" && item.isLocalFile() && item.isDir()) { | 999 | } else if (m_model->sortRole() == "size" && item.isLocalFile() && item.isDir()) { | ||
999 | const QString path = item.localPath(); | 1000 | const QString path = item.localPath(); | ||
1000 | data.insert("size", m_directoryContentsCounter->countDirectoryContentsSynchronously(path)); | 1001 | auto res = m_directoryContentsCounter->countDirectoryContentsSynchronously(path); | ||
1002 | data.insert("size", QVariant::fromValue(res.size)); | ||||
1003 | data.insert("count", res.count); | ||||
1001 | } else { | 1004 | } else { | ||
1002 | // Probably the sort role is a baloo role - just determine all roles. | 1005 | // Probably the sort role is a baloo role - just determine all roles. | ||
1003 | data = rolesData(item); | 1006 | data = rolesData(item); | ||
1004 | } | 1007 | } | ||
1005 | 1008 | | |||
1006 | disconnect(m_model, &KFileItemModel::itemsChanged, | 1009 | disconnect(m_model, &KFileItemModel::itemsChanged, | ||
1007 | this, &KFileItemModelRolesUpdater::slotItemsChanged); | 1010 | this, &KFileItemModelRolesUpdater::slotItemsChanged); | ||
1008 | m_model->setData(index, data); | 1011 | m_model->setData(index, data); | ||
▲ Show 20 Lines • Show All 187 Lines • Show Last 20 Lines |
Why remove these?