bool FileOrganiserWidget::parentIndexExists(const QModelIndex &pIndex, const QModelIndexList &pIndexes) const { // Recursively determine whether one of the parents of the given index is in // the provided list QModelIndex parentIndex = pIndex.parent(); if (parentIndex.isValid()) { // The current index has a valid parent, so check whether the parent is // in the list if (pIndexes.indexOf(parentIndex) != -1) // The parent index could be found, so... return true; else // The parent index couldn't be found, but what about the parent // index's parent? return parentIndexExists(parentIndex, pIndexes); } else { // The current index doesn't have a valid parent, so... return false; } }
QModelIndexList NBFolderView::getSelection() { QModelIndexList selectedList; selectedList << IconView->selection(); foreach( QModelIndex idx, selectedList ) if ( idx.column() ) selectedList.removeAt( selectedList.indexOf( idx ) ); return selectedList; };
void QmitkPointListView::OnListViewSelectionChanged(const QItemSelection &selected, const QItemSelection & /*deselected*/) { if (m_SelfCall) return; mitk::PointSet *pointSet = const_cast<mitk::PointSet *>(m_PointListModel->GetPointSet()); if (pointSet == nullptr) return; // (take care that this widget doesn't react to self-induced changes by setting m_SelfCall) m_SelfCall = true; // update selection of all points in pointset: select the one(s) that are selected in the view, deselect all others QModelIndexList selectedIndexes = selected.indexes(); for (mitk::PointSet::PointsContainer::Iterator it = pointSet->GetPointSet(m_PointListModel->GetTimeStep())->GetPoints()->Begin(); it != pointSet->GetPointSet(m_PointListModel->GetTimeStep())->GetPoints()->End(); ++it) { QModelIndex index; if (m_PointListModel->GetModelIndexForPointID(it->Index(), index)) { if (selectedIndexes.indexOf(index) != -1) // index is found in the selected indices list { pointSet->SetSelectInfo(it->Index(), true, m_PointListModel->GetTimeStep()); mitk::Point3D p = pointSet->GetPoint(it->Index(), m_PointListModel->GetTimeStep()); for (auto snc : m_Sncs) snc->SelectSliceByPoint(p); } else { pointSet->SetSelectInfo(it->Index(), false, m_PointListModel->GetTimeStep()); } } } m_SelfCall = false; emit SignalPointSelectionChanged(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); }
void Options::removeKey() { QItemSelectionModel *selModel = ui->keys->selectionModel(); if (!selModel->hasSelection()) { return; } QModelIndexList indexes = selModel->selectedIndexes(); QModelIndexList pkeys; // Key IDs foreach (QModelIndex index, indexes) { // Every selection contains all columns. Need to work only with first if (index.column() > 0) { continue; } // Choose only primary keys QModelIndex pIndex = index; if (index.parent().isValid()) { pIndex = index.parent(); } if (pkeys.indexOf(pIndex) < 0) { pkeys << pIndex; } } if (!pkeys.isEmpty()) { if (QMessageBox::question(this, tr("Delete"), tr("Do you want to delete the selected keys?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) { return; } } // Remove primary keys foreach (QModelIndex key, pkeys) { GpgProcess gpg; QStringList arguments; arguments << "--yes" << "--batch" << "--delete-secret-and-public-key" << "0x" + key.sibling(key.row(), Model::Fingerprint).data().toString(); gpg.start(arguments); gpg.waitForFinished(); }