bool AssociationsDialog::eventFilter(QObject *object, QEvent *e) { QTableWidgetItem* it = (QTableWidgetItem*)object; if (!it) return false; if (e->type() == QEvent::MouseButtonPress){ if (((QCheckBox*)it)->isChecked() || !((QCheckBox*)it)->isEnabled()) return true; int col = 0, row = 0; for (int j=1; j<table->columnCount(); j++){ for (int i=0; i < table->rowCount(); i++ ){ QCheckBox* cb = (QCheckBox*)table->cellWidget(i, j); if ( cb == (QCheckBox *)object){ row = i; col = j; break; } } } uncheckCol(col); ((QCheckBox*)it)->setChecked(true); updatePlotAssociation(row, col); return true; } else if (e->type() == QEvent::MouseButtonDblClick) return true; else return false; }
void AssociationsDialog::processStateChange(QTableWidgetItem *item) { // Ignore the header column if (item->column() == 0) return; // Ignore uncheck events if (item->checkState() == Qt::Unchecked) return; // Make sure that's the only checked item in the columns uncheckCol(item->column()); item->setCheckState(Qt::Checked); // Update association updatePlotAssociation(item->row(), item->column()); }