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) {