void GuiSelectBoundaryCodes::saveSelectionAsGrid() { getSelectedItems(m_Ui.listWidget, m_DisplayBoundaryCodes); QVector <vtkIdType> selected_cells; getSurfaceCells(m_DisplayBoundaryCodes, selected_cells, m_Grid); writeCells(m_Grid, selected_cells, GuiMainWindow::pointer()->getFilePath() + "selection.vtu" ); }
void xQGanttBarViewPort::deleteSelectedItems() { #ifdef _DEBUG_ printf("-> xQGanttBarViewPort::deleteSelectedItems()\n"); #endif QPtrList<KGanttItem> list; observeList(&list); getSelectedItems(_toplevelitem, list); for(KGanttItem *subitem = list.first(); subitem != 0; subitem = list.next()) { #ifdef _DEBUG_ printf(" : %s \n", subitem->getText().latin1()); #endif connect(subitem, SIGNAL(destroyed(KGanttItem *)), this, SLOT(itemDestroyed(KGanttItem *))); } list.remove(_toplevelitem); while(list.count() > 0) { KGanttItem *item = list.getFirst(); delete item; } #ifdef _DEBUG_ printf("<- xQGanttBarViewPort::deleteSelectedItems()\n"); #endif }
void ImHistoryBrowser::removeMessages() { std::list<uint32_t> msgIds; getSelectedItems(msgIds); rsHistory->removeMessages(msgIds); }
Item * ListItems::getCurrentItem() const { QModelIndex index( m_view->selectionModel()->currentIndex()); if( index.isValid()) if( Item::isItemP( index.data())) return Item::toItemP( index.data()); QList<Item*> items = getSelectedItems(); if( items.size()) return items[0]; return NULL; }
bool LLAvatarList::isAvalineItemSelected() { std::vector<LLPanel*> selected_items; getSelectedItems(selected_items); std::vector<LLPanel*>::iterator it = selected_items.begin(); for(; it != selected_items.end(); ++it) { if (dynamic_cast<LLAvalineListItem*>(*it)) return true; } return false; }
void ImHistoryBrowser::itemSelectionChanged() { std::list<uint32_t> msgIds; getSelectedItems(msgIds); if (msgIds.size()) { // activate buttons ui.copyButton->setEnabled(true); ui.removeButton->setEnabled(true); } else { // deactivate buttons ui.copyButton->setDisabled(true); ui.removeButton->setDisabled(true); } }
void ImHistoryBrowser::customContextMenuRequested(QPoint /*pos*/) { std::list<uint32_t> msgIds; getSelectedItems(msgIds); QListWidgetItem *currentItem = ui.listWidget->currentItem(); QMenu contextMnu(this); QAction *selectAll = new QAction(tr("Mark all"), &contextMnu); QAction *copyMessage = new QAction(tr("Copy"), &contextMnu); QAction *removeMessages = new QAction(tr("Delete"), &contextMnu); QAction *clearHistory = new QAction(tr("Clear history"), &contextMnu); QAction *sendItem = NULL; if (textEdit) { sendItem = new QAction(tr("Send"), &contextMnu); if (currentItem) { connect(sendItem, SIGNAL(triggered()), this, SLOT(sendMessage())); } else { sendItem->setDisabled(true); } } if (msgIds.size()) { connect(selectAll, SIGNAL(triggered()), ui.listWidget, SLOT(selectAll())); connect(copyMessage, SIGNAL(triggered()), this, SLOT(copyMessage())); connect(removeMessages, SIGNAL(triggered()), this, SLOT(removeMessages())); connect(clearHistory, SIGNAL(triggered()), this, SLOT(clearHistory())); } else { selectAll->setDisabled(true); copyMessage->setDisabled(true); removeMessages->setDisabled(true); clearHistory->setDisabled(true); } contextMnu.addAction(selectAll); contextMnu.addSeparator(); contextMnu.addAction(copyMessage); contextMnu.addAction(removeMessages); contextMnu.addAction(clearHistory); if (sendItem) { contextMnu.addSeparator(); contextMnu.addAction(sendItem); } contextMnu.exec(QCursor::pos()); }
void xQGanttBarViewPort::getSelectedItems(KGanttItem *item, QPtrList<KGanttItem> &list) { if(item->isSelected()) list.append(item); for(KGanttItem *subitem = item->getSubItems().first(); subitem != 0; subitem = item->getSubItems().next()) { getSelectedItems(subitem, list); } }
/*========================================================================= slot handleRenameAction =========================================================================*/ void KFileBrowser::handleRenameAction (void) { QStringList names = getSelectedItems (); if (names.count() != 1) { error (tr("Please select exactly one file or folder to rename")); } else { QString sourcePath = path + "/" + names[0]; QFileInfo sourceInfo (sourcePath); QDir sourceDir = sourceInfo.dir(); QString sourceFilename = sourceInfo.fileName(); bool ok = false; QString newName = QInputDialog::getText (this, tr("Rename"), tr("Enter new name for") + " " + sourceFilename, QLineEdit::Normal, "", &ok); if (ok && !newName.isEmpty()) { QString targetPath = sourceDir.path() + "/" + newName; bool ok = false; if (sourceInfo.isDir()) { QDir d (sourcePath); ok = sourceDir.rename (sourcePath, targetPath); } else { QFile f(sourcePath); ok = f.rename (targetPath); } if (ok) { emit statusUpdate (tr("Renamed") + " " + sourcePath + " " + tr("to") + " " + targetPath); emit dirContentsChanged(); } else { QString msg = (tr("Failed to rename") + " " + sourcePath + " " + tr("to") + " " + targetPath); emit statusUpdate (msg); error (msg); } } } }
void xQGanttBarViewPort::insertIntoSelectedItem() { QPtrList<KGanttItem> list; getSelectedItems(_toplevelitem, list); for(KGanttItem *subitem = list.first(); subitem != 0; subitem = list.next()) { #ifdef _DEBUG_ printf(" : %s \n", subitem->getText().latin1()); #endif new KGanttItem(subitem, subitem->getText() + "_subitem", subitem->getStart(), subitem->getEnd()); } }
void FileListView::mouseMoveEvent( QMouseEvent* event ) { if( 1000 > _time.elapsed() ) return; QStringList selectedItems; getSelectedItems( selectedItems ); QList<QUrl> urls; foreach( QString item, selectedItems ) urls << QUrl::fromLocalFile( item ); QMimeData* mimeData = new QMimeData(); mimeData->setUrls( urls ); QDrag* drag = new QDrag( this ); drag->setMimeData( mimeData ); drag->exec(); QListView::mouseMoveEvent( event ); }
void GuiNormalExtrusion::operate() { QSet<int> bcs; getSelectedItems(m_Ui.listWidget, bcs); EG_VTKDCC(vtkIntArray, cell_code, m_Grid, "cell_code"); QSet<int> volume_codes; EG_FORALL_CELLS(id_cell, m_Grid) { if (isSurface(id_cell, m_Grid)) { if (bcs.contains(cell_code->GetValue(id_cell))) { vtkIdType id_volume_cell = m_Part.getVolumeCell(id_cell); if (id_volume_cell != -1) { volume_codes.insert(cell_code->GetValue(id_volume_cell)); } } } } EG_VTKSP(vtkEgNormalExtrusion, extr); QVector<double> y; if (m_Ui.radioButtonSimple->isChecked()) { y.resize(m_Ui.lineEditSimpleNumLayers->text().toInt() + 1); double h = m_Ui.lineEditSimpleHeight->text().toDouble(); double f = m_Ui.lineEditSimpleIncrease->text().toDouble(); y[0] = 0.0; for (int i = 1; i < y.size(); ++i) { y[i] = y[i-1] + h; h *= f; } } else if (m_Ui.radioButtonFixedHeights->isChecked()) { y.resize(m_Ui.lineEditFixedHeightsNumLayers->text().toInt() + 1); QVector<double> x(y.size()); for (int i = 0; i < x.size(); ++i) { x[i] = i*1.0/(x.size() - 1); } mat3_t A; clinit(A[0]) = pow(x[1],5.0), pow(x[1],3.0), x[1]; clinit(A[1]) = pow(x[x.size() - 2],5.0), pow(x[x.size() - 2],3.0), x[x.size() - 2]; clinit(A[2]) = pow(x[x.size() - 1],5.0), pow(x[x.size() - 1],3.0), x[x.size() - 1]; vec3_t h; h[0] = m_Ui.lineEditFixedHeightsHeightFirst->text().toDouble(); h[2] = m_Ui.lineEditFixedHeightsTotalHeight->text().toDouble(); h[1] = h[2] - m_Ui.lineEditFixedHeightsHeightLast->text().toDouble(); mat3_t AI = A.inverse(); vec3_t coeff = AI*h; for (int i = 0; i < y.size(); ++i) { y[i] = coeff[0]*pow(x[i],5.0) + coeff[1]*pow(x[i],3.0) + coeff[2]*x[i]; if (i > 0) { if (y[i] < y[i-1]) { EG_ERR_RETURN("unable to compute layer heights"); } } } } extr->SetLayers(y); if (m_Ui.radioButtonFixed->isChecked()) { extr->SetNormal(vec3_t(m_Ui.lineEditFixedNX->text().toDouble(), m_Ui.lineEditFixedNY->text().toDouble(), m_Ui.lineEditFixedNZ->text().toDouble())); double min_dist = m_Ui.lineEditFixedDist->text().toDouble(); if (min_dist <= 0) { extr->SetFixed(); } else { extr->SetPlanar(); extr->SetMinDist(min_dist); } } if (m_Ui.radioButtonCylinder->isChecked()) { extr->SetCylindrical(); extr->SetOrigin(vec3_t(m_Ui.lineEditCylinderX0->text().toDouble(), m_Ui.lineEditCylinderY0->text().toDouble(), m_Ui.lineEditCylinderZ0->text().toDouble())); extr->SetAxis(vec3_t(m_Ui.lineEditCylinderNX->text().toDouble(), m_Ui.lineEditCylinderNY->text().toDouble(), m_Ui.lineEditCylinderNZ->text().toDouble())); } if (m_Ui.radioButtonRotation->isChecked()) { extr->SetRotation(); extr->SetOrigin(vec3_t(m_Ui.lineEditCylinderX0->text().toDouble(), m_Ui.lineEditCylinderY0->text().toDouble(), m_Ui.lineEditCylinderZ0->text().toDouble())); extr->SetAxis(vec3_t(m_Ui.lineEditCylinderNX->text().toDouble(), m_Ui.lineEditCylinderNY->text().toDouble(), m_Ui.lineEditCylinderNZ->text().toDouble())); } if (m_Ui.radioButtonNoRestrict->isChecked()) { extr->SetRestrictNone(); } if (m_Ui.radioButtonXY->isChecked()) { extr->SetRestrictXY(); } if (m_Ui.radioButtonXZ->isChecked()) { extr->SetRestrictXZ(); } if (m_Ui.radioButtonYZ->isChecked()) { extr->SetRestrictYZ(); } if (m_Ui.checkBoxNewVolume->isChecked()) { extr->SetRemoveInternalFacesOff(); } QList<VolumeDefinition> vols = GuiMainWindow::pointer()->getAllVols(); int vc = 1; foreach (VolumeDefinition vol, vols) { vc = max(vc, vol.getVC()); }
void GuiSelectBoundaryCodes::operate() { getSelectedItems(m_Ui.listWidget, m_DisplayBoundaryCodes); }