r24779 by jghali - Fix table cell style not being applied to all selected cells in table edit mode

scribus-commit scribus-commit at lists.scribus.net
Wed Dec 15 23:22:23 UTC 2021


Author: jghali
Date: Wed Dec 15 23:22:23 2021
New Revision: 24779

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24779
Log:
Fix table cell style not being applied to all selected cells in table edit mode

Modified:
    trunk/Scribus/scribus/ui/propertiespalette_table.cpp

Modified: trunk/Scribus/scribus/ui/propertiespalette_table.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24779&path=/trunk/Scribus/scribus/ui/propertiespalette_table.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_table.cpp	(original)
+++ trunk/Scribus/scribus/ui/propertiespalette_table.cpp	Wed Dec 15 23:22:23 2021
@@ -9,6 +9,7 @@
 #include <QColor>
 #include <QListWidget>
 #include <QListWidgetItem>
+#include <QScopedValueRollback>
 #include <QWidget>
 
 #include "appmodehelper.h"
@@ -218,9 +219,35 @@
 {
 	if (!m_item || !m_item->isTable())
 		return;
-	m_doc->dontResize = true;
-	m_item->asTable()->activeCell().setStyle(name);
-	m_doc->dontResize = true;
+	QScopedValueRollback<bool> dontResizeRb(m_doc->dontResize, true);
+
+	PageItem_Table* table = m_item->asTable();
+	if (m_doc->appMode != modeEditTable)
+	{
+		for (int row = 0; row < table->rows(); ++row)
+		{
+			int colSpan = 0;
+			for (int col = 0; col < table->columns(); col += colSpan)
+			{
+				TableCell currentCell = table->cellAt(row, col);
+				if (row == currentCell.row())
+					currentCell.setStyle(name);
+				colSpan = currentCell.columnSpan();
+			}
+		}
+	}
+	else
+	{
+		QSet<TableCell> cells = table->selectedCells();
+		if (cells.isEmpty())
+			cells.insert(table->activeCell());
+		for (auto cellIter = cells.begin(); cellIter != cells.end(); cellIter++)
+		{
+			TableCell currentCell(*cellIter);
+			currentCell.setStyle(name);
+		}
+	}
+
 	m_item->asTable()->update();
 	showCellStyle(name);
 }
@@ -593,9 +620,35 @@
 {
 	if (!m_item || !m_item->isTable())
 		return;
-	m_doc->dontResize = true;
+	QScopedValueRollback<bool> dontResizeRb(m_doc->dontResize, true);
+
 	PageItem_Table* table = m_item->asTable();
-	table->activeCell().unsetDirectFormatting();
+	if (m_doc->appMode != modeEditTable)
+	{
+		for (int row = 0; row < table->rows(); ++row)
+		{
+			int colSpan = 0;
+			for (int col = 0; col < table->columns(); col += colSpan)
+			{
+				TableCell currentCell = table->cellAt(row, col);
+				if (row == currentCell.row())
+					currentCell.unsetDirectFormatting();
+				colSpan = currentCell.columnSpan();
+			}
+		}
+	}
+	else
+	{
+		QSet<TableCell> cells = table->selectedCells();
+		if (cells.isEmpty())
+			cells.insert(table->activeCell());
+		for (auto cellIter = cells.begin(); cellIter != cells.end(); cellIter++)
+		{
+			TableCell currentCell(*cellIter);
+			currentCell.unsetDirectFormatting();
+		}
+	}
+
 	table->adjustTable();
 	table->update();
 }
@@ -604,11 +657,10 @@
 {
 	if (!m_doc || !m_item || !m_item->isTable())
 		return;
+	QScopedValueRollback<bool> dontResizeRb(m_doc->dontResize, true);
 
 	PageItem_Table* table = m_item->asTable();
 	TableSideSelector::Sides selectedSides = sideSelector->selection();
-
-	m_doc->dontResize = true;
 	if (m_doc->appMode != modeEditTable)
 	{
 		if (selectedSides & TableSideSelector::Left)




More information about the scribus-commit mailing list