void NMGMeasureListWidget::selectAllItems(QAbstractItemModel* model, QItemSelectionModel* selectionModel, const QModelIndex& parent) { if(model->hasChildren(parent)) { if(selectionModel->isSelected(parent)) { // this is done because of the removeSelectedItems() behaviour and the signals emitted, // to avoid extra signaling (e.g. extra parent deletion signal done by // removeSelectedItems() due to no more children). selectionModel->select(parent, QItemSelectionModel::Deselect); } QModelIndex topLeft = model->index(0, 0, parent); QModelIndex bottomRight = model->index(model->rowCount(parent)-1, model->columnCount(parent)-1, parent); QItemSelection selection; selection.select(topLeft, bottomRight); selectionModel->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows); QModelIndexList selectedIndexes = selection.indexes(); QModelIndexList::const_iterator it; for(it = selectedIndexes.constBegin(); it != selectedIndexes.constEnd(); it++) { selectAllItems(model, selectionModel, *it); } } }
void AnimationListWidget::translateItemToolTip() { selectAllItems(); QList<QListWidgetItem*> list = selectedItems(); for (int i = 0; i < list.count(); i++) { dynamic_cast<AnimationItem*>(list.at(i))->createAnimationTooltipAsRichText(); } }
/************************************************************************ Handle key down event ************************************************************************/ void ItemListbox::onKeyDown(KeyEventArgs& e) { ScrolledItemListBase::onKeyDown(e); // select all (if allowed) on Ctrl+A if (d_multiSelect) { uint sysKeys = getGUIContext().getSystemKeys().get(); if (e.scancode == Key::A && (sysKeys&Control)) { selectAllItems(); ++e.handled; } } }
void NMGMeasureListWidget::slotDeleteAllItems() { selectAllItems(model(), selectionModel(), QModelIndex()); removeSelectedItems(); }