NS_IMETHODIMP nsARIAGridAccessible::GetSelectedRowIndices(PRUint32 *arowCount, PRInt32 **aRows) { NS_ENSURE_ARG_POINTER(arowCount); *arowCount = 0; NS_ENSURE_ARG_POINTER(aRows); *aRows = nsnull; if (IsDefunct()) return NS_ERROR_FAILURE; PRInt32 rowCount = 0; GetRowCount(&rowCount); if (!rowCount) return NS_OK; nsTArray<PRInt32> selRows(rowCount); AccIterator rowIter(this, filters::GetRow); nsAccessible *row = nsnull; for (PRInt32 rowIdx = 0; (row = rowIter.GetNext()); rowIdx++) { if (nsAccUtils::IsARIASelected(row)) { selRows.AppendElement(rowIdx); continue; } AccIterator cellIter(row, filters::GetCell); nsAccessible *cell = cellIter.GetNext(); if (!cell) continue; PRBool isRowSelected = PR_TRUE; do { if (!nsAccUtils::IsARIASelected(cell)) { isRowSelected = PR_FALSE; break; } } while ((cell = cellIter.GetNext())); if (isRowSelected) selRows.AppendElement(rowIdx); } PRUint32 selrowCount = selRows.Length(); if (!selrowCount) return NS_OK; *aRows = static_cast<PRInt32*>( nsMemory::Clone(selRows.Elements(), selrowCount * sizeof(PRInt32))); NS_ENSURE_TRUE(*aRows, NS_ERROR_OUT_OF_MEMORY); *arowCount = selrowCount; return NS_OK; }
void TableEditor::contextMenu(int,int,const QPoint &pos) { Q3PopupMenu *menu = new Q3PopupMenu(viewport()); menu->insertItem(tr("Copy"),1); menu->insertItem(tr("Paste"),2); int nSelRows=0; Q3MemArray<int> selRows(numRows()); for(int r=0;r<numRows()-1;r++) if(isRowSelected(r,1)) selRows[nSelRows++]=r; selRows.resize(nSelRows); if(nSelRows) menu->insertItem(tr("Delete rows"),3); //menu->insertItem("Clear",3); int r=menu->exec(pos,0); switch(r) { case 1: copy(); break; case 2: paste(); break; case 3: removeRows(selRows); break; } }