21 void QmitkMultiWidgetLayoutSelectionWidget::Init()
25 auto stylesheet =
"QTableWidget::item{background-color: white;}\nQTableWidget::item:selected{background-color: #1C97EA;}";
26 ui.tableWidget->setStyleSheet(stylesheet);
28 connect(ui.tableWidget, &QTableWidget::itemSelectionChanged,
this, &QmitkMultiWidgetLayoutSelectionWidget::OnTableItemSelectionChanged);
29 connect(ui.setLayoutPushButton, &QPushButton::clicked,
this, &QmitkMultiWidgetLayoutSelectionWidget::OnSetLayoutButtonClicked);
32 void QmitkMultiWidgetLayoutSelectionWidget::OnTableItemSelectionChanged()
34 QItemSelectionModel* selectionModel = ui.tableWidget->selectionModel();
38 QModelIndexList indices = selectionModel->selectedIndexes();
39 if (indices.size() > 0)
41 row = indices[0].row();
42 column = indices[0].column();
44 QModelIndex topLeft = ui.tableWidget->model()->index(0, 0, QModelIndex());
45 QModelIndex bottomRight = ui.tableWidget->model()->index(row, column, QModelIndex());
47 QItemSelection cellSelection;
48 cellSelection.select(topLeft, bottomRight);
49 selectionModel->select(cellSelection, QItemSelectionModel::Select);
53 void QmitkMultiWidgetLayoutSelectionWidget::OnSetLayoutButtonClicked()
57 QModelIndexList indices = ui.tableWidget->selectionModel()->selectedIndexes();
58 if (indices.size() > 0)
61 for (
const QModelIndex modelIndex : indices)
63 if (modelIndex.row() > row)
65 row = modelIndex.row();
67 if (modelIndex.column() > column)
69 column = modelIndex.column();