1 #include "HistoryTreeWidget.h" 6 #include "ProgressBar.h" 21 headers.append(
"Operation");
22 headers.append(
"Progress");
23 headers.append(
"Time Executed");
25 setHeaderLabels(headers);
27 connect(m_project, SIGNAL(workOrderStarting(
WorkOrder *)),
29 connect(m_project, SIGNAL(projectLoaded(
Project *)),
31 connect(m_project->
undoStack(), SIGNAL(indexChanged(
int)),
60 QFontMetrics metrics(invisibleRootItem()->font(1));
61 int dateTimeColumnWidth = qRound(metrics.width(QDateTime::currentDateTime().toString()) * 1.10);
63 int progressBarColumnWidth = 200;
67 int operationColumnWidth = width() - dateTimeColumnWidth - progressBarColumnWidth - 12;
69 if (operationColumnWidth > 0) {
71 result = operationColumnWidth;
73 result = progressBarColumnWidth;
75 result = dateTimeColumnWidth;
87 resizeColumnToContents(0);
88 resizeColumnToContents(1);
89 resizeColumnToContents(2);
97 updateStatus(workOrder);
109 QString data = workOrder->
bestText();
112 connect(workOrder, SIGNAL(destroyed(
QObject *)),
116 columnData.append(data);
117 columnData.append(
"");
121 newItem->setData(0, Qt::UserRole, qVariantFromValue(workOrder));
125 QFont saveFont = newItem->font(0);
126 saveFont.setBold(
true);
127 saveFont.setItalic(
true);
128 newItem->setFont(0, saveFont);
129 newItem->setForeground(0, Qt::gray);
133 QFont progressFont = newItem->font(1);
134 progressFont.setItalic(
true);
135 newItem->setFont(1, progressFont);
136 newItem->setForeground(1, Qt::gray);
138 this->insertTopLevelItem(0, newItem);
140 connect(workOrder, SIGNAL(statusChanged(
WorkOrder *)),
142 connect(workOrder, SIGNAL(creatingProgress(
WorkOrder *)),
144 connect(workOrder, SIGNAL(deletingProgress(
WorkOrder *)),
153 this->setItemWidget(newItem, 1, workOrder->
progressBar() );
155 scrollToItem(newItem);
167 QString data = historyEntry;
170 columnData.append(data);
176 QFont progressFont = newItem->font(1);
177 progressFont.setItalic(
true);
178 newItem->setFont(1, progressFont);
179 newItem->setForeground(1, Qt::gray);
181 this->insertTopLevelItem(0, newItem);
192 scrollToItem(newItem);
206 if( !m_project->clearing() ){
207 for (
int i = 0; i < invisibleRootItem()->childCount(); i++) {
209 if (item->data(0, Qt::UserRole).toString() !=
"") {
211 if (workOrder && itemWidget(item, 1) != workOrder->
progressBar()) {
228 treeItem->setForeground(0, Qt::black);
229 updateStatus(treeItem);
242 treeItem->setForeground(0, Qt::gray);
243 updateStatus(treeItem);
253 m_project->
undoStack()->command(newIndex - 1));
261 scrollToItem(prevItem);
262 scrollToItem(curItem);
274 int indexToDelete = invisibleRootItem()->indexOfChild(itemToRemove);
275 if (indexToDelete < invisibleRootItem()->childCount()) {
278 setItemWidget(invisibleRootItem()->child(indexToDelete), 1, NULL);
281 delete invisibleRootItem()->takeChild(indexToDelete);
297 for (
int i = invisibleRootItem()->childCount() - 1; !result && i >= 0; i--) {
299 if (item->data(0, Qt::UserRole).toString() !=
"" ) {
302 if (undoCommand == workOrder)
328 void HistoryTreeWidget::updateStatus(
WorkOrder *workOrder) {
QString bestText() const
Generate unique action names We don't use action text anymore because Directory likes to rename our a...
void addToHistory(QString historyEntry)
Add a non-workorder history to the display.
The main project for ipce.
void markUndone(QTreeWidgetItem *)
Display the item as an item that has been undone.
QList< WorkOrder * > workOrderHistory()
Get the entire list of work orders that have executed.
void markNotUndone(QTreeWidgetItem *)
Display the item as not an item that has been undone - it's working or done.
QUndoStack * undoStack()
Returns the Projects stack of QUndoCommands.
HistoryTreeWidget(Project *project, QWidget *parent=0)
Construct a history tree widget.
virtual ~HistoryTreeWidget()
Clean up allocated memory.
int sizeHintForColumn(int column) const
Get the preferred size of a given column.
void handleUndoIndexChanged(int)
The project's undo stack has changed.
Provide Undo/redo abilities, serialization, and history for an operation.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
void removeFromHistory(QObject *)
A work order was lost...
bool createsCleanState() const
Returns the CleanState status (whether the Project has been saved to disk or not).
void updateProgressWidgets()
We need to manually manage these progress widgets because QTreeWidget does a poor job of it...
void showHistory()
This resets the tree widget and re-initializes.
void refit()
This resizes the columns to an okay width for viewing all of the data cleanly.
QTreeWidgetItem * undoCommandToTreeItem(const QUndoCommand *)
Get the QTreeWidgetItem associated with the given undo command (work order).
QString statusText() const
WorkOrder::statusText.
QDateTime executionTime() const
Gets the execution time of this WorkOrder.
Namespace for ISIS/Bullet specific routines.
ProgressBar * progressBar()
Returns the ProgressBar.
bool isUndoable() const
Returns true if this work order is undoable, otherwise false.