void PlayContextMenu::fillContextMenu( QMenu *menu, const Selection & s, const TemporalScenarioPresenter& pres, const QPoint& pt, const QPointF& scenept) { menu->addAction(m_playFromHere); auto scenPoint = Scenario::ConvertToScenarioPoint(scenept, pres.zoomRatio(), pres.view().height()); m_playFromHere->setData(QVariant::fromValue(scenPoint.date)); if(s.empty()) { menu->addAction(m_recordAction); m_recordAction->setData(QVariant::fromValue(ScenarioRecordInitData{&pres, scenept})); } else { if(std::any_of(s.cbegin(), s.cend(), [] (auto obj) { return dynamic_cast<const StateModel*>(obj.data());})) { menu->addAction(m_playStates); } /* if(std::any_of(s.cbegin(), s.cend(), [] (auto obj) { return dynamic_cast<const ConstraintModel*>(obj);})) { menu->addAction(m_playConstraints); } if(std::any_of(s.cbegin(), s.cend(), [] (auto obj) { return dynamic_cast<const EventModel*>(obj);})) { menu->addAction(m_playEvents); } */ } }
void QDesignerIntegrationPrivate::getSelection(Selection &s) { QDesignerFormEditorInterface *core = q->core(); // Get multiselection from object inspector if (QDesignerObjectInspector *designerObjectInspector = qobject_cast<QDesignerObjectInspector *>(core->objectInspector())) { designerObjectInspector->getSelection(s); // Action editor puts actions that are not on the form yet // into the property editor only. if (s.empty()) if (QObject *object = core->propertyEditor()->object()) s.objects.push_back(object); } else { // Just in case someone plugs in an old-style object inspector: Emulate selection s.clear(); QDesignerFormWindowInterface *formWindow = core->formWindowManager()->activeFormWindow(); if (!formWindow) return; QObject *object = core->propertyEditor()->object(); if (object->isWidgetType()) { QWidget *widget = static_cast<QWidget*>(object); QDesignerFormWindowCursorInterface *cursor = formWindow->cursor(); if (cursor->isWidgetSelected(widget)) { s.managed.push_back(widget); } else { s.unmanaged.push_back(widget); } } else { s.objects.push_back(object); } } }
void CommandUnmark::process(ExecutionEnvironment& env) { Selection sel = env.getSimulation()->findObjectFromPath(target); if (sel.empty()) return; if (env.getSimulation()->getUniverse() != NULL) env.getSimulation()->getUniverse()->unmarkObject(sel, 1); }
void DeepSkyBrowser::slotContextMenu(const QPoint& pos) { QModelIndex index = treeView->indexAt(pos); Selection sel = dsoModel->itemAtRow((unsigned int) index.row()); if (!sel.empty()) { emit selectionContextMenuRequested(treeView->mapToGlobal(pos), sel); } }
void SolarSystemBrowser::slotContextMenu(const QPoint& pos) { QModelIndex index = treeView->indexAt(pos); Selection sel = solarSystemModel->objectAtIndex(index); if (!sel.empty()) { emit selectionContextMenuRequested(treeView->mapToGlobal(pos), sel); } }
void Cloud::restore (const CopyBuffer& copy_buffer, const Selection& selection) { if (selection.empty()) return; const Cloud& copied_cloud = copy_buffer.get(); if (copied_cloud.size() != selection.size()) return; append(copied_cloud); unsigned int pos = cloud_.size(); Selection::const_reverse_iterator rit; for (rit = selection.rbegin(); rit != selection.rend(); ++rit) std::swap(cloud_.points[--pos], cloud_.points[*rit]); }
void SolarSystemBrowser::slotMarkSelected() { #if 0 QItemSelectionModel* sm = treeView->selectionModel(); QModelIndexList rows = sm->selectedRows(); bool labelMarker = labelMarkerBox->checkState() == Qt::Checked; bool convertOK = false; QVariant markerData = markerSymbolBox->itemData(markerSymbolBox->currentIndex()); Marker::Symbol markerSymbol = (Marker::Symbol) markerData.toInt(&convertOK); QColor markerColor = colorSwatch->color(); Color color((float) markerColor.redF(), (float) markerColor.greenF(), (float) markerColor.blueF()); Universe* universe = appCore->getSimulation()->getUniverse(); string label; for (QModelIndexList::const_iterator iter = rows.begin(); iter != rows.end(); iter++) { Selection sel = solarSystemModel->objectAtIndex(*iter); if (!sel.empty()) { if (convertOK) { #if 0 if (labelMarker) { label = universe->getDSOCatalog()->getDSOName(dso); label = ReplaceGreekLetterAbbr(label); } #endif universe->markObject(sel, 10.0f, color, markerSymbol, 1, label); } else { universe->unmarkObject(sel, 1); } } } #endif }
void ScenarioGlobalCommandManager::removeSelection(const ScenarioModel &scenario) { Selection sel = scenario.selectedChildren(); // We have to remove the first / last timenodes / events from the selection. erase_if(sel, [&] (auto&& elt) { return elt == &scenario.startEvent() || elt == &scenario.endEvent() || elt == &scenario.startTimeNode() || elt == &scenario.endTimeNode(); }); if(!sel.empty()) { CommandDispatcher<> dispatcher(m_commandStack); dispatcher.submitCommand(new RemoveSelection(path(scenario), sel)); } }
void QDesignerIntegrationPrivate::addDynamicProperty(const QString &name, const QVariant &value) { QDesignerFormWindowInterface *formWindow = q->core()->formWindowManager()->activeFormWindow(); if (!formWindow) return; Selection selection; getSelection(selection); if (selection.empty()) return; AddDynamicPropertyCommand *cmd = new AddDynamicPropertyCommand(formWindow); if (cmd->init(selection.selection(), propertyEditorObject(), name, value)) { formWindow->commandHistory()->push(cmd); } else { delete cmd; qDebug() << "** WARNING Unable to add dynamic property " << name << '.'; } }
void QDesignerIntegrationPrivate::resetProperty(const QString &name) { QDesignerFormWindowInterface *formWindow = q->core()->formWindowManager()->activeFormWindow(); if (!formWindow) return; Selection selection; getSelection(selection); if (selection.empty()) return; ResetPropertyCommand *cmd = new ResetPropertyCommand(formWindow); // find a reference object to find the right group if (cmd->init(selection.selection(), name, propertyEditorObject())) { formWindow->commandHistory()->push(cmd); } else { delete cmd; qDebug() << "** WARNING Unable to reset property " << name << '.'; } }
void QDesignerIntegrationPrivate::updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling) { QDesignerFormWindowInterface *formWindow = q->core()->formWindowManager()->activeFormWindow(); if (!formWindow) return; Selection selection; getSelection(selection); if (selection.empty()) return; SetPropertyCommand *cmd = new SetPropertyCommand(formWindow); // find a reference object to compare to and to find the right group if (cmd->init(selection.selection(), name, value, propertyEditorObject(), enableSubPropertyHandling)) { formWindow->commandHistory()->push(cmd); } else { delete cmd; qDebug() << "Unable to set property " << name << '.'; } }
/// @brief Recombine void SubtitlesGrid::RecombineLines() { using namespace std; Selection selectedSet = GetSelectedSet(); if (selectedSet.size() < 2) return; AssDialogue *activeLine = GetActiveLine(); vector<AssDialogue*> sel; sel.reserve(selectedSet.size()); copy(selectedSet.begin(), selectedSet.end(), back_inserter(sel)); for_each(sel.begin(), sel.end(), trim_text); sort(sel.begin(), sel.end(), &AssFile::CompStart); typedef vector<AssDialogue*>::iterator diag_iter; diag_iter end = sel.end() - 1; for (diag_iter cur = sel.begin(); cur != end; ++cur) { AssDialogue *d1 = *cur; diag_iter d2 = cur + 1; // 1, 1+2 (or 2+1), 2 gets turned into 1, 2, 2 so kill the duplicate if (d1->Text == (*d2)->Text) { expand_times(d1, *d2); delete d1; context->ass->Line.remove(d1); continue; } // 1, 1+2, 1 turns into 1, 2, [empty] if (d1->Text.empty()) { delete d1; context->ass->Line.remove(d1); continue; } // If d2 is the last line in the selection it'll never hit the above test if (d2 == end && (*d2)->Text.empty()) { delete *d2; context->ass->Line.remove(*d2); continue; } // 1, 1+2 while (d2 <= end && (*d2)->Text.StartsWith(d1->Text, &(*d2)->Text)) { expand_times(*d2, d1); trim_text(*d2); ++d2; } // 1, 2+1 while (d2 <= end && (*d2)->Text.EndsWith(d1->Text, &(*d2)->Text)) { expand_times(*d2, d1); trim_text(*d2); ++d2; } // 1+2, 2 while (d2 <= end && d1->Text.EndsWith((*d2)->Text, &d1->Text)) { expand_times(d1, *d2); trim_text(d1); ++d2; } // 2+1, 2 while (d2 <= end && d1->Text.StartsWith((*d2)->Text, &d1->Text)) { expand_times(d1, *d2); trim_text(d1); ++d2; } } // Remove now non-existent lines from the selection Selection lines; transform(context->ass->Line.begin(), context->ass->Line.end(), inserter(lines, lines.begin()), cast<AssDialogue*>()); Selection newSel; set_intersection(lines.begin(), lines.end(), selectedSet.begin(), selectedSet.end(), inserter(newSel, newSel.begin())); if (newSel.empty()) newSel.insert(*lines.begin()); // Restore selection if (!newSel.count(activeLine)) activeLine = *newSel.begin(); SetSelectionAndActive(newSel, activeLine); context->ass->Commit(_("combining"), AssFile::COMMIT_DIAG_ADDREM | AssFile::COMMIT_DIAG_FULL); }