Skip to content

Commit

Permalink
When merging cells in layout tables, concatenate original cell text
Browse files Browse the repository at this point in the history
Fixes #59611
  • Loading branch information
nyalldawson committed Nov 29, 2024
1 parent 737a835 commit 81fabae
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/gui/tableeditor/qgstableeditorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1377,9 +1377,34 @@ void QgsTableEditorWidget::mergeSelectedCells()
if ( maxCol == -1 || index.column() > maxCol )
maxCol = index.column();
}
QStringList mergedCellText;
for ( int row = minRow; row <= maxRow; ++row )
{
for ( int col = minCol; col <= maxCol; ++col )
{
if ( QTableWidgetItem *i = item( row, col ) )
{
const QString content = i->data( CellContent ).toString();
if ( !content.isEmpty() )
{
mergedCellText.append( content );
}
}
}
}

setSpan( minRow, minCol, maxRow - minRow + 1, maxCol - minCol + 1 );

// set merged cell text to concatenate original cell text
if ( !mergedCellText.isEmpty() )
{
if ( QTableWidgetItem *i = item( minRow, minCol ) )
{
i->setText( mergedCellText.join( ' ' ) );
i->setData( CellContent, i->text() );
}
}

if ( !mBlockSignals )
emit tableChanged();
}
Expand Down

0 comments on commit 81fabae

Please sign in to comment.