| 3863 | } |
| 3864 | |
| 3865 | int StructuredDataItemModel::rowCount(const QModelIndex &parent) const |
| 3866 | { |
| 3867 | if(!parent.isValid()) |
| 3868 | return m_Objects.count(); |
| 3869 | |
| 3870 | Index decodedIdx = decodeIndex(parent); |
| 3871 | |
| 3872 | SDObject *obj = NULL; |
| 3873 | |
| 3874 | // if this is a page node, it either has PageSize children if it's not the last one, or the |
| 3875 | // remainder |
| 3876 | if(decodedIdx.tag == PageNode) |
| 3877 | { |
| 3878 | size_t pageBase = decodedIdx.indexInArray; |
| 3879 | |
| 3880 | return qMin(ArrayPageSize, int(decodedIdx.obj->NumChildren() - pageBase)); |
| 3881 | } |
| 3882 | else if(decodedIdx.tag == ArrayMember) |
| 3883 | { |
| 3884 | obj = decodedIdx.obj->GetChild(decodedIdx.indexInArray); |
| 3885 | } |
| 3886 | else |
| 3887 | { |
| 3888 | obj = decodedIdx.obj; |
| 3889 | } |
| 3890 | |
| 3891 | if(obj) |
| 3892 | { |
| 3893 | if(isLargeArray(obj)) |
| 3894 | { |
| 3895 | return (int(obj->NumChildren()) + ArrayPageSize - 1) / ArrayPageSize; |
| 3896 | } |
| 3897 | else |
| 3898 | { |
| 3899 | if(obj->type.flags & SDTypeFlags::HiddenChildren) |
| 3900 | { |
| 3901 | // if this node has hidden children, count the *actual* number of children |
| 3902 | int numChildren = 0; |
| 3903 | for(size_t i = 0; i < obj->NumChildren(); i++) |
| 3904 | { |
| 3905 | if(obj->GetChild(i)->type.flags & SDTypeFlags::Hidden) |
| 3906 | continue; |
| 3907 | |
| 3908 | numChildren++; |
| 3909 | } |
| 3910 | |
| 3911 | return numChildren; |
| 3912 | } |
| 3913 | else |
| 3914 | { |
| 3915 | return (int)obj->NumChildren(); |
| 3916 | } |
| 3917 | } |
| 3918 | } |
| 3919 | |
| 3920 | return 0; |
| 3921 | } |
| 3922 |
no test coverage detected