108 /* |
108 /* |
109 * Add the Delete and Edit row buttons. |
109 * Add the Delete and Edit row buttons. |
110 * Not for water agents, these are set on the water tab. |
110 * Not for water agents, these are set on the water tab. |
111 */ |
111 */ |
112 if (product->miscs.at(i).m_type == MISC_TYPES_WATER_AGENT) { |
112 if (product->miscs.at(i).m_type == MISC_TYPES_WATER_AGENT) { |
|
113 ui->miscsTable->removeCellWidget(i, 6); /* to remove the unneeded button */ |
113 item = new QTableWidgetItem(""); |
114 item = new QTableWidgetItem(""); |
114 item->setToolTip(tr("Edit this from the water tab")); |
115 item->setToolTip(tr("Edit this from the water tab")); |
115 ui->miscsTable->setItem(i, 6, item); |
116 ui->miscsTable->setItem(i, 6, item); |
|
117 ui->miscsTable->removeCellWidget(i, 7); |
116 item = new QTableWidgetItem(""); |
118 item = new QTableWidgetItem(""); |
117 item->setToolTip(tr("Edit this from the water tab")); |
119 item->setToolTip(tr("Edit this from the water tab")); |
118 ui->miscsTable->setItem(i, 7, item); |
120 ui->miscsTable->setItem(i, 7, item); |
119 } else { |
121 } else { |
|
122 if (ui->miscsTable->item(i, 6)) { |
|
123 ui->miscsTable->takeItem(i, 6); /* to remove the old tooltip */ |
|
124 } |
|
125 if (ui->miscsTable->item(i, 7)) { |
|
126 ui->miscsTable->takeItem(i, 7); |
|
127 } |
120 pWidget = new QWidget(); |
128 pWidget = new QWidget(); |
121 QPushButton* btn_dele = new QPushButton(); |
129 QPushButton* btn_dele = new QPushButton(); |
122 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
130 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
123 btn_dele->setText(tr("Delete")); |
131 btn_dele->setText(tr("Delete")); |
124 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteMiscRow_clicked())); |
132 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteMiscRow_clicked())); |
460 if (product->miscs.at(product->miscs_row).m_inventory < product->miscs.at(product->miscs_row).m_amount) |
468 if (product->miscs.at(product->miscs_row).m_inventory < product->miscs.at(product->miscs_row).m_amount) |
461 item->setForeground(QBrush(QColor(Qt::red))); |
469 item->setForeground(QBrush(QColor(Qt::red))); |
462 ui->miscsTable->setItem(product->miscs_row, 5, item); |
470 ui->miscsTable->setItem(product->miscs_row, 5, item); |
463 |
471 |
464 is_changed(); |
472 is_changed(); |
465 emit refreshAll(); |
473 qDebug() << "before" << product->miscs_row; |
|
474 refreshMiscs(); |
|
475 /* |
|
476 * The order of the list is changed, lookup the item we just added. |
|
477 */ |
|
478 for (int i = 0; i < product->miscs.size(); i++) { |
|
479 if ((product->miscs.at(i).m_name == query.value(0).toString()) && |
|
480 (product->miscs.at(i).m_type == query.value(1).toInt()) && |
|
481 (product->miscs.at(i).m_use_use == query.value(2).toInt())) { |
|
482 product->miscs_row = i; |
|
483 break; |
|
484 } |
|
485 } |
|
486 qDebug() << "after" << product->miscs_row; |
466 } |
487 } |
467 |
488 |
468 |
489 |
469 void EditProduct::misc_instock_changed(bool val) |
490 void EditProduct::misc_instock_changed(bool val) |
470 { |
491 { |