Gui: offer possibility to editing view provider to handle "Select All" command

This commit is contained in:
0penBrain
2024-05-09 23:18:53 +02:00
committed by Chris Hennes
parent 51be8e7b4e
commit b9db90ea20
5 changed files with 26 additions and 1 deletions

View File

@@ -227,7 +227,12 @@ public:
else if (event->type() == QEvent::KeyPress) {
auto ke = static_cast<QKeyEvent*>(event); // NOLINT
if (ke->matches(QKeySequence::SelectAll)) {
static_cast<View3DInventorViewer*>(obj)->selectAll();
auto* viewer3d = static_cast<View3DInventorViewer*>(obj);
auto* editingVP = viewer3d->getEditingViewProvider();
if(!editingVP || !editingVP->selectAll())
{
viewer3d->selectAll();
}
return true;
}
}
@@ -1088,6 +1093,12 @@ bool View3DInventorViewer::isEditingViewProvider() const
return this->editViewProvider != nullptr;
}
/// return currently editing view provider
ViewProvider* View3DInventorViewer::getEditingViewProvider() const
{
return this->editViewProvider;
}
/// display override mode
void View3DInventorViewer::setOverrideMode(const std::string& mode)
{

View File

@@ -220,6 +220,8 @@ public:
void setEditingViewProvider(Gui::ViewProvider* vp, int ModNum);
/// return whether a view provider is edited
bool isEditingViewProvider() const;
/// return currently editing view provider
ViewProvider* getEditingViewProvider() const;
/// reset from edit mode
void resetEditingViewProvider();
void setupEditingRoot(SoNode *node=nullptr, const Base::Matrix4D *mat=nullptr);

View File

@@ -462,6 +462,9 @@ public:
virtual void getTaskViewContent(std::vector<Gui::TaskView::TaskContent*>&) const {}
//@}
/// is called when the provider is in edit and a "Select All" command was issued
/// Provider shall return 'false' is it ignores the command, 'true' otherwise
virtual bool selectAll() { return false; }
/// is called when the provider is in edit and a key event occurs. Only ESC ends edit.
virtual bool keyPressed(bool pressed, int key);
/// Is called by the tree if the user double clicks on the object. It returns the string

View File

@@ -2588,6 +2588,12 @@ void ViewProviderSketch::updateColor()
editCoinManager->updateColor();
}
bool ViewProviderSketch::selectAll()
{
// TODO: eventually implement "select all" logic
return true;
}
bool ViewProviderSketch::doubleClicked()
{
Gui::Application::Instance->activeDocument()->setEdit(this);

View File

@@ -656,6 +656,9 @@ public:
{
return nullptr;
}
/// is called when the provider is in edit and a "Select All" command was issued
/// Provider shall return 'false' is it ignores the command, 'true' otherwise
bool selectAll() override;
/// is called by the tree if the user double clicks on the object
bool doubleClicked() override;
/// is called when the Provider is in edit and the mouse is moved