Isis 3 Programmer Reference
Isis::HistoryTreeWidget Class Reference

History Widget for ipce. More...

#include <HistoryTreeWidget.h>

Inheritance diagram for Isis::HistoryTreeWidget:
Inheritance graph
Collaboration diagram for Isis::HistoryTreeWidget:
Collaboration graph

Public Member Functions

 HistoryTreeWidget (Project *project, QWidget *parent=0)
 Construct a history tree widget. More...
 
virtual ~HistoryTreeWidget ()
 Clean up allocated memory. More...
 
void addToHistory (QString historyEntry)
 Add a non-workorder history to the display. More...
 

Protected Member Functions

int sizeHintForColumn (int column) const
 Get the preferred size of a given column. More...
 

Private Slots

void addToHistory (WorkOrder *)
 Add a single work order to the display. More...
 
void updateProgressWidgets ()
 We need to manually manage these progress widgets because QTreeWidget does a poor job of it. More...
 
void markNotUndone (QTreeWidgetItem *)
 Display the item as not an item that has been undone - it's working or done. More...
 
void markUndone (QTreeWidgetItem *)
 Display the item as an item that has been undone. More...
 
void handleUndoIndexChanged (int)
 The project's undo stack has changed. More...
 
void removeFromHistory (QObject *)
 A work order was lost... More...
 
void showHistory ()
 This resets the tree widget and re-initializes. More...
 
void updateStatus (WorkOrder *)
 
QTreeWidgetItemundoCommandToTreeItem (const QUndoCommand *)
 Get the QTreeWidgetItem associated with the given undo command (work order). More...
 

Private Member Functions

void refit ()
 This resizes the columns to an okay width for viewing all of the data cleanly. More...
 
void updateStatus (QTreeWidgetItem *)
 
 Q_DISABLE_COPY (HistoryTreeWidget)
 

Private Attributes

QMutex m_mutex
 
Projectm_project
 

Detailed Description

History Widget for ipce.

This widget shows the history of work orders performed on the project.

Author
2012-07-23 Steven Lambright
History:

2012-07-23 Steven Lambright - Added/fixed documentation, improved implementation of addToHistory to look for alternative text/not display blank items.

2012-07-23 Steven Lambright and Stuart Sides - Added display of undo stack

2012-07-27 Kimberly Oyama and Steven Lambright - Added resizeEvent() and improved implementation of refit().

2012-07-31 Kimberly Oyama - Added comments to some of the methods.

2017-02-06 Tracie Sucharski - Work orders that are not on the QUndoStack are greyed out and italicized.

2017-04-05 Tracie Sucharski - For the last change, method name was changed from onUndoStack to isUndoable.

2017-07-24 Cole Neubauer - Added check in addToHistory() to check if a WorkOrder should be added to the HistoryTree Fixes #4715

2017-08-10 Tyler Wilson - Changed some code in addToHistory function which was causing a segfault. This is a bandaid fix which addresses the immediate problem, but will have to be tackled in a future ticket. Fixes #5096. References #4492.

2017-08-11 Cole Neubauer - Added some checks to avoid segfaults Fixes #5064

2017-11-08 Tyler Wilson - Reverted the code change in #5096 to restore the ProgressBar, and changed code in OpenRecentProjectsWorkOrder.cpp to prevent the segfault which #5096 was addressing. Fixes #5149.

2018-04-07 Tracie Sucharski - Added method to force a history entry using a string rather than a WorkOrder. This should be a temporary method until saving a control is turned into a WorkOrder. This was done for the alpha release simply to notify the user that the control was saved. However, this history entry is not saved/restored to a project.

2018-06-28 Makayla Shepherd - Restored the ProgressBar. Fixes #5228.

Definition at line 50 of file HistoryTreeWidget.h.

Constructor & Destructor Documentation

◆ HistoryTreeWidget()

Isis::HistoryTreeWidget::HistoryTreeWidget ( Project project,
QWidget parent = 0 
)

Construct a history tree widget.

Parameters
projectThe project to show history for
parentThe Qt-relationship parent

Definition at line 17 of file HistoryTreeWidget.cpp.

References addToHistory(), handleUndoIndexChanged(), refit(), showHistory(), and Isis::Project::undoStack().

◆ ~HistoryTreeWidget()

Isis::HistoryTreeWidget::~HistoryTreeWidget ( )
virtual

Clean up allocated memory.

Definition at line 43 of file HistoryTreeWidget.cpp.

Member Function Documentation

◆ addToHistory() [1/2]

void Isis::HistoryTreeWidget::addToHistory ( QString  historyEntry)

Add a non-workorder history to the display.

Parameters
(QString)historyEntry The string displayed in the history tree

Definition at line 165 of file HistoryTreeWidget.cpp.

References refit().

Referenced by HistoryTreeWidget(), and showHistory().

◆ addToHistory [2/2]

void Isis::HistoryTreeWidget::addToHistory ( WorkOrder workOrder)
privateslot

Add a single work order to the display.

This uses the QUndoCommand text (if it's blank, it uses the QAction text). If there is no text, this does nothing.

Parameters
workOrderThe work order to display the history for

Definition at line 107 of file HistoryTreeWidget.cpp.

References Isis::WorkOrder::bestText(), Isis::WorkOrder::createsCleanState(), Isis::WorkOrder::executionTime(), Isis::WorkOrder::isUndoable(), Isis::WorkOrder::progressBar(), refit(), removeFromHistory(), and updateProgressWidgets().

◆ handleUndoIndexChanged

void Isis::HistoryTreeWidget::handleUndoIndexChanged ( int  newIndex)
privateslot

The project's undo stack has changed.

Display the changed states appropriately.

Definition at line 251 of file HistoryTreeWidget.cpp.

References markNotUndone(), markUndone(), undoCommandToTreeItem(), and Isis::Project::undoStack().

Referenced by HistoryTreeWidget().

◆ markNotUndone

void Isis::HistoryTreeWidget::markNotUndone ( QTreeWidgetItem treeItem)
privateslot

Display the item as not an item that has been undone - it's working or done.

This colors it black and sets the text to completed (only visible if there is no progress bar).

Parameters
treeItemThe given GUI tree item/row to color appropriately.

Definition at line 226 of file HistoryTreeWidget.cpp.

Referenced by handleUndoIndexChanged().

◆ markUndone

void Isis::HistoryTreeWidget::markUndone ( QTreeWidgetItem treeItem)
privateslot

Display the item as an item that has been undone.

This colors it gray and sets the text to Undone.

Parameters
treeItemThe given GUI tree item/row to color appropriately.

Definition at line 240 of file HistoryTreeWidget.cpp.

Referenced by handleUndoIndexChanged().

◆ refit()

void Isis::HistoryTreeWidget::refit ( )
private

This resizes the columns to an okay width for viewing all of the data cleanly.

This method depends on sizeHintForColumn() for good column sizes.

Definition at line 86 of file HistoryTreeWidget.cpp.

Referenced by addToHistory(), and HistoryTreeWidget().

◆ removeFromHistory

void Isis::HistoryTreeWidget::removeFromHistory ( QObject deletedObject)
privateslot

A work order was lost...

compensate by removing it from the tree.

Definition at line 269 of file HistoryTreeWidget.cpp.

References undoCommandToTreeItem().

Referenced by addToHistory().

◆ showHistory

void Isis::HistoryTreeWidget::showHistory ( )
privateslot

This resets the tree widget and re-initializes.

See also
addToHistory()

Definition at line 317 of file HistoryTreeWidget.cpp.

References addToHistory(), and Isis::Project::workOrderHistory().

Referenced by HistoryTreeWidget().

◆ sizeHintForColumn()

int Isis::HistoryTreeWidget::sizeHintForColumn ( int  column) const
protected

Get the preferred size of a given column.

This is used by resizeColumnToContents().

The work order name column prefers space not taken by other columns. The progress column prefers 200. The date column prefers a little more than the text size of a date.

Returns
The preferred width of the given column

Definition at line 57 of file HistoryTreeWidget.cpp.

◆ undoCommandToTreeItem

QTreeWidgetItem * Isis::HistoryTreeWidget::undoCommandToTreeItem ( const QUndoCommand undoCommand)
privateslot

Get the QTreeWidgetItem associated with the given undo command (work order).

Returns NULL if none found or given NULL.

Parameters
undoCommandA work order
Returns
The QTreeWidgetItem that represents (is associated with) the undoCommand

Definition at line 294 of file HistoryTreeWidget.cpp.

Referenced by handleUndoIndexChanged(), and removeFromHistory().

◆ updateProgressWidgets

void Isis::HistoryTreeWidget::updateProgressWidgets ( )
privateslot

We need to manually manage these progress widgets because QTreeWidget does a poor job of it.

This should be called when the progress bar instances have changed (new progress, lost a progress, etc...). This is not necessary when the progress values have changed.

Failing to call this method results in seg faults when other events occur - such as a resize event.

Definition at line 205 of file HistoryTreeWidget.cpp.

References Isis::WorkOrder::progressBar().

Referenced by addToHistory().


The documentation for this class was generated from the following files: