Commit 74d8379e authored by finetjul's avatar finetjul
Browse files

STYLE: Minor style changes in qSlicerMouseModeToolBar

Improve readability.

git-svn-id: http://svn.slicer.org/Slicer4/trunk@21534 3bd1e089-480b-0410-8dfb-8563597acbee
parent e450a373
......@@ -37,7 +37,7 @@ int qSlicerMouseModeToolBarTest1(int argc, char * argv[] )
// exercise public slots
mouseToolBar.switchToViewTransformMode();
mouseToolBar.switchPlaceMode();
mouseToolBar.onPersistenceToggled();
mouseToolBar.setPersistence(true);
// without a qSlicerApplication, setting the cursor is a noop
mouseToolBar.changeCursorTo(QCursor(Qt::BusyCursor));
......
......@@ -71,20 +71,14 @@ void qSlicerMouseModeToolBarPrivate::init()
this->PersistenceAction->setToolTip(QObject::tr("Switch between single place and persistent place modes."));
this->PersistenceAction->setCheckable(true);
this->PersistenceAction->setChecked(false);
vtkMRMLInteractionNode * interactionNode = NULL;
if (this->MRMLAppLogic)
vtkMRMLInteractionNode * interactionNode =
this->MRMLAppLogic ? this->MRMLAppLogic->GetInteractionNode() : 0;
if (interactionNode && interactionNode->GetPlaceModePersistence())
{
interactionNode = this->MRMLAppLogic->GetInteractionNode();
this->PersistenceAction->setChecked(true);
}
if (interactionNode)
{
if (interactionNode->GetPlaceModePersistence())
{
this->PersistenceAction->setChecked(true);
}
}
connect(this->PersistenceAction, SIGNAL(triggered()), q,
SLOT(onPersistenceToggled()));
connect(this->PersistenceAction, SIGNAL(triggered(bool)),
q, SLOT(setPersistence(bool)));
// popuplate the create and place menu, with persistence first
this->CreateAndPlaceMenu = new QMenu(QObject::tr("Create and Place"), q);
......@@ -666,25 +660,20 @@ bool qSlicerMouseModeToolBar::isActionTextInMenu(QString actionText, QMenu *menu
}
//---------------------------------------------------------------------------
void qSlicerMouseModeToolBar::onPersistenceToggled()
void qSlicerMouseModeToolBar::setPersistence(bool persistent)
{
Q_D(qSlicerMouseModeToolBar);
vtkMRMLInteractionNode *interactionNode = NULL;
if (d->MRMLAppLogic)
{
interactionNode = d->MRMLAppLogic->GetInteractionNode();
}
vtkMRMLInteractionNode *interactionNode =
d->MRMLAppLogic ? d->MRMLAppLogic->GetInteractionNode() : 0;
if (interactionNode)
{
int newPersistence = !interactionNode->GetPlaceModePersistence();
interactionNode->SetPlaceModePersistence(newPersistence);
interactionNode->SetPlaceModePersistence(persistent ? 1 : 0);
}
else
{
qWarning() << "qSlicerMouseModeToolBar::onPersistenceToggled: "
"no interaction node found to toggle.";
qWarning() << __FUNCTION__ << ": no interaction node found to toggle.";
}
}
......
......@@ -48,6 +48,9 @@ public:
qSlicerMouseModeToolBar(QWidget* parent = 0);
virtual ~qSlicerMouseModeToolBar();
/// For testing, return the active action text
QString activeActionText();
public slots:
void setApplicationLogic(vtkSlicerApplicationLogic* logic);
......@@ -62,11 +65,8 @@ public slots:
void switchPlaceMode();
/// Update the interaction node's persistent place mode from the UI
void onPersistenceToggled();
void setPersistence(bool persistent);
/// For testing, return the active action text
QString activeActionText();
protected:
QScopedPointer<qSlicerMouseModeToolBarPrivate> d_ptr;
......
......@@ -58,14 +58,14 @@ public:
TextColumn = 6
};
virtual void updateItemDataFromNode(QStandardItem* item, vtkMRMLNode* node, int column);
virtual vtkMRMLNode* parentNode(vtkMRMLNode* node)const;
protected:
virtual vtkMRMLNode* parentNode(vtkMRMLNode* node)const;
virtual void updateItemDataFromNode(QStandardItem* item, vtkMRMLNode* node, int column);
virtual void updateNodeFromItemData(vtkMRMLNode* node, QStandardItem* item);
virtual QFlags<Qt::ItemFlag> nodeFlags(vtkMRMLNode* node, int column)const;
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment