| 71 | // Returns a possibly new widget at given row and column, having a set column span. |
| 72 | // Any existing widgets of other types or other span will be removed. |
| 73 | template <typename W> static W * widgetAt(QGridLayout *grid, int row, int column, int columnSpan = 1) |
| 74 | { |
| 75 | Q_ASSERT(grid->columnCount() <= 2); |
| 76 | QPointer<QWidget> widgets[2]; |
| 77 | for (int j = 0; j < grid->columnCount(); ++j) |
| 78 | { |
| 79 | auto item = grid->itemAtPosition(row, j); |
| 80 | if (item) |
| 81 | widgets[j] = item->widget(); |
| 82 | } |
| 83 | |
| 84 | if (columnSpan == 1 && widgets[0] == widgets[1]) |
| 85 | delete widgets[0]; |
| 86 | if (columnSpan == 2 && widgets[0] != widgets[1]) |
| 87 | for (auto & w : widgets) |
| 88 | delete w; |
| 89 | |
| 90 | auto widget = qobject_cast<W*>(widgets[column]); |
| 91 | if (!widget) |
| 92 | { |
| 93 | // There may be an incompatible widget there. |
| 94 | delete widgets[column]; |
| 95 | widget = new W; |
| 96 | grid->addWidget(widget, row, column, 1, columnSpan, Qt::AlignTop); |
| 97 | } |
| 98 | return widget; |
| 99 | } |
| 100 | |
| 101 | int FileInfoWidget::addInfo(const InfoData &data, int row, int infoIndex) |
| 102 | { |
nothing calls this directly
no test coverage detected