void StatePropertyGridWidget::OnListItemChanged(QListWidgetItem* /*item*/)
{
	ui->stateSelectListWidget->blockSignals(true);
	ui->selectAllCheckbox->blockSignals(true);

	eCheckedState checkedState = GetCheckedState();

	switch (checkedState)
	{
		case STATE_EVERY_ITEM_CHECKED:
			ui->selectAllCheckbox->setCheckState(Qt::Checked);
			break;

		case STATE_EVERY_ITEM_UNCHECKED:
			ui->selectAllCheckbox->setCheckState(Qt::Unchecked);
			ui->stateSelectListWidget->item(0)->setCheckState(Qt::Checked);
			break;

		default:
			break;
	}

	ui->selectAllCheckbox->blockSignals(false);
	ui->stateSelectListWidget->blockSignals(false);

	MultiplyStateSelectionChanged();
}
Example #2
0
void wxTreeListCtrl::UpdateItemParentStateRecursively(wxTreeListItem item)
{
    wxCHECK_RET( item.IsOk(), "Invalid item" );

    wxASSERT_MSG( HasFlag(wxTL_3STATE), "Can only be used with wxTL_3STATE" );

    for ( ;; )
    {
        wxTreeListItem parent = GetItemParent(item);
        if ( parent == GetRootItem() )
        {
            // There is no checked state associated with the root item.
            return;
        }

        // Set parent state to the state of this item if all the other children
        // have the same state too. Otherwise make it indeterminate.
        const wxCheckBoxState stateItem = GetCheckedState(item);
        CheckItem(parent, AreAllChildrenInState(parent, stateItem)
                            ? stateItem
                            : wxCHK_UNDETERMINED);

        // And do the same thing with the parent's parent too.
        item = parent;
    }
}
void StatePropertyGridWidget::SetAllChecked(Qt::CheckState state)
{
	for (int32 i = 0; i < ui->stateSelectListWidget->count(); ++i)
	{
		QListWidgetItem* item = ui->stateSelectListWidget->item(i);
		item->setCheckState(state);
	}

	if (GetCheckedState() == STATE_EVERY_ITEM_UNCHECKED)
	{
		ui->stateSelectListWidget->item(0)->setCheckState(Qt::Checked);
	}
}
Example #4
0
bool
wxTreeListCtrl::AreAllChildrenInState(wxTreeListItem item,
                                      wxCheckBoxState state) const
{
    wxCHECK_MSG( item.IsOk(), false, "Invalid item" );

    for ( wxTreeListItem child = GetFirstChild(item);
          child.IsOk();
          child = GetNextSibling(child) )
    {
        if ( GetCheckedState(child) != state )
            return false;
    }

    return true;
}