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 | m_directoryContentsCounter->scanDirectory(path); | ||
1001 | } else { | 1002 | } else { | ||
1002 | // Probably the sort role is a baloo role - just determine all roles. | 1003 | // Probably the sort role is a baloo role - just determine all roles. | ||
1003 | data = rolesData(item); | 1004 | data = rolesData(item); | ||
1004 | } | 1005 | } | ||
1005 | 1006 | | |||
1006 | disconnect(m_model, &KFileItemModel::itemsChanged, | 1007 | disconnect(m_model, &KFileItemModel::itemsChanged, | ||
1007 | this, &KFileItemModelRolesUpdater::slotItemsChanged); | 1008 | this, &KFileItemModelRolesUpdater::slotItemsChanged); | ||
1008 | m_model->setData(index, data); | 1009 | m_model->setData(index, data); | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 1063 | { | |||
1065 | const bool getSizeRole = m_roles.contains("size"); | 1066 | const bool getSizeRole = m_roles.contains("size"); | ||
1066 | const bool getIsExpandableRole = m_roles.contains("isExpandable"); | 1067 | const bool getIsExpandableRole = m_roles.contains("isExpandable"); | ||
1067 | 1068 | | |||
1068 | if ((getSizeRole || getIsExpandableRole) && item.isDir()) { | 1069 | if ((getSizeRole || getIsExpandableRole) && item.isDir()) { | ||
1069 | if (item.isLocalFile()) { | 1070 | if (item.isLocalFile()) { | ||
1070 | // Tell m_directoryContentsCounter that we want to count the items | 1071 | // Tell m_directoryContentsCounter that we want to count the items | ||
1071 | // inside the directory. The result will be received in slotDirectoryContentsCountReceived. | 1072 | // inside the directory. The result will be received in slotDirectoryContentsCountReceived. | ||
1072 | const QString path = item.localPath(); | 1073 | const QString path = item.localPath(); | ||
1073 | m_directoryContentsCounter->addDirectory(path); | 1074 | m_directoryContentsCounter->scanDirectory(path); | ||
1074 | } else if (getSizeRole) { | 1075 | } else if (getSizeRole) { | ||
1075 | data.insert("size", -1); // -1 indicates an unknown number of items | 1076 | data.insert("size", -1); // -1 indicates an unknown number of items | ||
1076 | } | 1077 | } | ||
1077 | } | 1078 | } | ||
1078 | 1079 | | |||
1079 | if (m_roles.contains("type")) { | 1080 | if (m_roles.contains("type")) { | ||
1080 | data.insert("type", item.mimeComment()); | 1081 | data.insert("type", item.mimeComment()); | ||
1081 | } | 1082 | } | ||
▲ Show 20 Lines • Show All 114 Lines • Show Last 20 Lines |
Why remove these?