Пример #1
0
void AssociationsDialog::updatePlotAssociation(int row, int col) {
  int index = associations->currentRow();
  QString text = associations->currentItem()->text();
  QStringList lst = text.split(": ", QString::SkipEmptyParts);
  QStringList cols = lst[1].split(",", QString::SkipEmptyParts);

  if (col == 1) {
    cols[0] = table->item(row, 0)->text() + "(X)";
    text = lst[0] + ": " + cols.join(",");
  } else if (col == 2) {
    if (cols.count() >= 2) {
      cols[1] = table->item(row, 0)->text() + "(Y)";
      text = lst[0] + ": " + cols.join(",");
    } else // box or pie plots
      text = lst[0] + ": " + table->item(row, 0)->text();
  } else if (col == 3) {
    if (text.contains("(A)")) { // vect XYAM curve
      cols[2] = table->item(row, 0)->text() + "(A)";
      text = lst[0] + ": " + cols.join(",");
    } else if (!text.contains("(A)") && text.count("(X)") == 1) {
      cols[2] = table->item(row, 0)->text() + "(xErr)";
      text = lst[0] + ": " + cols.join(",");
      uncheckCol(4);
    } else if (text.count("(X)") == 2) { // vect XYXY curve
      cols[2] = table->item(row, 0)->text() + "(X)";
      text = lst[0] + ": " + cols.join(",");
    }
  } else if (col == 4) {
    if (text.contains("(M)")) { // vect XYAM curve
      cols[3] = table->item(row, 0)->text() + "(M)";
      text = lst[0] + ": " + cols.join(",");
    } else if (!text.contains("(M)") && text.count("(X)") == 1) {
      cols[2] = table->item(row, 0)->text() + "(yErr)";
      text = lst[0] + ": " + cols.join(",");
      uncheckCol(3);
    } else if (text.count("(Y)") == 2) { // vect XYXY curve
      cols[3] = table->item(row, 0)->text() + "(Y)";
      text = lst[0] + ": " + cols.join(",");
    }
  }

  // change associations for error bars depending on the curve "index"
  QString old_as = plotAssociationsList[index];
  for (int i = 0; i < (int)plotAssociationsList.count(); i++) {
    QString as = plotAssociationsList[i];
    if (as.contains(old_as) &&
        (as.contains("(xErr)") || as.contains("(yErr)"))) {
      QStringList ls = as.split(",", QString::SkipEmptyParts);
      as = text + "," + ls[2];
      plotAssociationsList[i] = as;
    }
  }

  plotAssociationsList[index] = text;
  associations->item(index)->setText(text);
}
Пример #2
0
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;
}
Пример #3
0
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());
}