Пример #1
0
void
UserSelectView::SetAllChecked(bool checked)
{
        int topCount = this->topLevelItemCount();
        for (int i = 0; i < topCount; i++)
        {
                TreeItemType* topi = this->topLevelItem(i);
                int csCount = topi->childCount();
                for (int j = 0; j < csCount; j++)
                {
                        TreeItemType* chld = topi->child(j);
                        chld->setCheckState(0, checked?(Qt::Checked):(Qt::Unchecked));
                }
        }
}
Пример #2
0
QList<UserItem*>
UserSelectView::GetSelectedUserItems()
{
        QList<UserItem*> selList;
        int topCount = this->topLevelItemCount();
        for (int i = 0; i < topCount; i++)
        {
                TreeItemType* topi = this->topLevelItem(i);
                int csCount = topi->childCount();
                for (int j = 0; j < csCount; j++)
                {
                        TreeItemType* chld = topi->child(j);
                        if (chld->checkState(0) == Qt::Checked)
                        {
                                QString const& key = chld->data(0, UserItemRole).toString();
                                if (UserItem* u = m_collection->value(key, 0))
                                {
	                                selList << u;
                                }
                        }
                }
        }
        return selList;
}