/* cpView() copies input QListView and add it on the main interface */ void CovariatesView::copyTree(const CovariatesView* aCovView, bool aShowAll) { clearSelection(); // Copy the input tree, select 1st selectable covariate and set baseIndex Q3ListViewItemIterator it(const_cast<CovariatesView*> (aCovView)); while (it.current()) { // Copy the current item Q3ListViewItem *newItem; Q3ListViewItem *inputItem = it.current(); if (inputItem->text(2).isEmpty()) { if (!inputItem->childCount()) return; if (inputItem->depth() == 0) newItem = new Q3ListViewItem(this, lastChild(), inputItem->text(0)); else newItem = new Q3ListViewItem(findParent(inputItem), lastChild(findParent(inputItem)), inputItem->text(0)); newItem->setOpen(true); newItem->setEnabled(false); return; } if (inputItem->depth() == 0) newItem = new Q3ListViewItem(this, lastChild(), inputItem->text(0), inputItem->text(1), inputItem->text(2)); else newItem = new Q3ListViewItem(findParent(inputItem), lastChild(findParent(inputItem)), inputItem->text(0), inputItem->text(1), inputItem->text(2)); // By default, only enable type I covariates if (newItem->text(1) != "I") newItem->setEnabled(false); ++it; } Q3ListViewItemIterator all(this, Q3ListViewItemIterator::Selectable); if (!aShowAll) showInterestOnly(); }
/*! \reimp */ QAccessible::State QAccessibleListView::state(int child) const { State state = Q3AccessibleScrollView::state(child); Q3ListViewItem *item; if (!child || !(item = findLVItem(listView(), child))) return state; if (item->isSelectable()) { if (listView()->selectionMode() == Q3ListView::Multi) state |= MultiSelectable; else if (listView()->selectionMode() == Q3ListView::Extended) state |= ExtSelectable; else if (listView()->selectionMode() == Q3ListView::Single) state |= Selectable; if (item->isSelected()) state |= Selected; } if (listView()->focusPolicy() != Qt::NoFocus) { state |= Focusable; if (item == listView()->currentItem()) state |= Focused; } if (item->childCount()) { if (item->isOpen()) state |= Expanded; else state |= Collapsed; } if (!listView()->itemRect(item).isValid()) state |= Invisible; if (item->rtti() == Q3CheckListItem::RTTI) { if (((Q3CheckListItem*)item)->isOn()) state|=Checked; } return state; }
std::vector<const CCopasiObject * > * CCopasiSimpleSelectionTree::getTreeSelection() { std::vector<const CCopasiObject * > * selection = new std::vector<const CCopasiObject * >(); std::map< std::string, const CCopasiObject * > SelectionMap; if (selectionMode() == Q3ListView::Single && selectedItem()) { selection->push_back(treeItems[selectedItem()]); } else { // go through the whole tree and check for selected items. // if the selected item has children, add all children that are leaves // and are connected to an object. // If the item is a leave and is connected to an object, add it directly Q3ListViewItemIterator it(this); Q3ListViewItem* currentItem = it.current(); while (currentItem) { if (currentItem->isSelected()) { if (currentItem->childCount() == 0) { if (treeItems.find(currentItem) != treeItems.end()) SelectionMap[treeItems[currentItem]->getObjectDisplayName()] = treeItems[currentItem]; } else { Q3ListViewItemIterator it2(currentItem); Q3ListViewItem* tmpItem = it2.current(); Q3ListViewItem* Ancestor; while (tmpItem) { if ((tmpItem->childCount() == 0) && (treeItems.find(tmpItem) != treeItems.end())) SelectionMap[treeItems[tmpItem]->getObjectDisplayName()] = treeItems[tmpItem]; ++it2; tmpItem = it2.current(); if (!tmpItem) break; // We continue as long as the current item is an // ancestor of the tmp item, i.e., it is in the branch // originating from current item. for (Ancestor = tmpItem->parent(); Ancestor != currentItem && Ancestor; Ancestor = Ancestor->parent()); if (!Ancestor) break; } } } ++it; currentItem = it.current(); } // Copy the selection set to the selection selection->resize(SelectionMap.size()); std::vector< const CCopasiObject * >::iterator itSelection = selection->begin(); std::map< std::string, const CCopasiObject * >::const_iterator itSet = SelectionMap.begin(); std::map< std::string, const CCopasiObject * >::const_iterator endSet = SelectionMap.end(); for (; itSet != endSet; ++itSet, ++itSelection) *itSelection = itSet->second; } return selection; }