Added "mark to recompute" action to tree view

This commit is contained in:
Yorik van Havre 2016-10-12 17:35:01 -03:00
parent ba4f981f3b
commit 33c7ec80c8
2 changed files with 22 additions and 0 deletions

View File

@ -86,6 +86,11 @@ TreeWidget::TreeWidget(QWidget* parent)
this->finishEditingAction->setStatusTip(tr("Finish editing object"));
connect(this->finishEditingAction, SIGNAL(triggered()),
this, SLOT(onFinishEditing()));
this->markRecomputeAction = new QAction(this);
this->markRecomputeAction->setText(tr("Mark to recompute"));
this->markRecomputeAction->setStatusTip(tr("Mark this object to be recomputed"));
connect(this->markRecomputeAction, SIGNAL(triggered()),
this, SLOT(onMarkRecompute()));
// Setup connections
Application::Instance->signalNewDocument.connect(boost::bind(&TreeWidget::slotNewDocument, this, _1));
@ -173,6 +178,7 @@ void TreeWidget::contextMenuEvent (QContextMenuEvent * e)
if (!contextMenu.actions().isEmpty())
contextMenu.addSeparator();
contextMenu.addAction(this->relabelObjectAction);
contextMenu.addAction(this->markRecomputeAction);
// if only one item is selected setup the edit menu
if (this->selectedItems().size() == 1) {
@ -300,6 +306,17 @@ void TreeWidget::onFinishEditing()
}
}
void TreeWidget::onMarkRecompute()
{
if (this->contextItem && this->contextItem->type() == ObjectType) {
DocumentObjectItem* objitem = static_cast<DocumentObjectItem*>
(this->contextItem);
App::DocumentObject* obj = objitem->object()->getObject();
if (!obj) return;
obj->touch();
}
}
void TreeWidget::onActivateDocument(QAction* active)
{
// activate the specified document
@ -721,6 +738,9 @@ void TreeWidget::changeEvent(QEvent *e)
this->finishEditingAction->setText(tr("Finish editing"));
this->finishEditingAction->setStatusTip(tr("Finish editing object"));
this->markRecomputeAction->setText(tr("Mark to recompute"));
this->markRecomputeAction->setStatusTip(tr("Mark this object to be recomputed"));
}
QTreeWidget::changeEvent(e);

View File

@ -101,6 +101,7 @@ protected Q_SLOTS:
void onActivateDocument(QAction*);
void onStartEditing();
void onFinishEditing();
void onMarkRecompute();
private Q_SLOTS:
void onItemSelectionChanged(void);
@ -122,6 +123,7 @@ private:
QAction* createGroupAction;
QAction* relabelObjectAction;
QAction* finishEditingAction;
QAction* markRecomputeAction;
QTreeWidgetItem* contextItem;
QTreeWidgetItem* rootItem;