r17336 by fschmid - Tables: erasing direct table and cell formatting works now. Enabled setting of borderlines for cells.

scribus-commit scribus-commit at lists.scribus.net
Sat Feb 25 21:59:25 UTC 2012


Author: fschmid
Date: Sat Feb 25 21:59:25 2012
New Revision: 17336

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17336
Log:
Tables: erasing direct table and cell formatting works now. Enabled setting of borderlines for cells.

Modified:
    trunk/Scribus/scribus/pageitem_table.cpp
    trunk/Scribus/scribus/pageitem_table.h
    trunk/Scribus/scribus/tablecell.cpp
    trunk/Scribus/scribus/tablecell.h
    trunk/Scribus/scribus/ui/propertiespalette_table.cpp
    trunk/Scribus/scribus/ui/propertiespalette_table.h

Modified: trunk/Scribus/scribus/pageitem_table.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17336&path=/trunk/Scribus/scribus/pageitem_table.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_table.cpp (original)
+++ trunk/Scribus/scribus/pageitem_table.cpp Sat Feb 25 21:59:25 2012
@@ -835,6 +835,20 @@
 {
 	doc()->dontResize = true;
 	m_style.setParent("");
+	updateCells();
+	doc()->dontResize = false;
+	emit changed();
+}
+
+void PageItem_Table::unsetDirectFormatting()
+{
+	doc()->dontResize = true;
+	QString parentStyle = m_style.parent();
+	m_style.setParent("");
+	m_style.erase();
+	m_style.setParent(parentStyle);
+	adjustTableToFrame();
+	adjustFrameToTable();
 	updateCells();
 	doc()->dontResize = false;
 	emit changed();

Modified: trunk/Scribus/scribus/pageitem_table.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17336&path=/trunk/Scribus/scribus/pageitem_table.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_table.h (original)
+++ trunk/Scribus/scribus/pageitem_table.h Sat Feb 25 21:59:25 2012
@@ -439,6 +439,9 @@
 	/// Unsets the style of this table.
 	void unsetStyle();
 
+	/// Unsets direct formatting
+	void unsetDirectFormatting();
+
 	/// Returns the style of this table.
 	QString style() const;
 

Modified: trunk/Scribus/scribus/tablecell.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17336&path=/trunk/Scribus/scribus/tablecell.cpp
==============================================================================
--- trunk/Scribus/scribus/tablecell.cpp (original)
+++ trunk/Scribus/scribus/tablecell.cpp Sat Feb 25 21:59:25 2012
@@ -122,6 +122,14 @@
 {
 	d->style.setParent(style);
 	d->table->updateCells();
+}
+
+void TableCell::unsetDirectFormatting()
+{
+	QString parentStyle = d->style.parent();
+	d->style.setParent("");
+	d->style.erase();
+	d->style.setParent(parentStyle);
 }
 
 void TableCell::updateContent()

Modified: trunk/Scribus/scribus/tablecell.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17336&path=/trunk/Scribus/scribus/tablecell.h
==============================================================================
--- trunk/Scribus/scribus/tablecell.h (original)
+++ trunk/Scribus/scribus/tablecell.h Sat Feb 25 21:59:25 2012
@@ -198,6 +198,8 @@
 	/// Sets the cell style for this cell to @a style.
 	void setStyle(const QString& style);
 
+	void unsetDirectFormatting();
+
 	/// Returns the named cell style for this cell.
 	QString style() const { return d->style.parent(); }
 

Modified: trunk/Scribus/scribus/ui/propertiespalette_table.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17336&path=/trunk/Scribus/scribus/ui/propertiespalette_table.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_table.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_table.cpp Sat Feb 25 21:59:25 2012
@@ -82,8 +82,6 @@
 
 void PropertiesPalette_Table::setItem(PageItem* item)
 {
-	tableStyleCombo->updateFormatList();
-	cellStyleCombo->updateFormatList();
 	m_item = item;
 	if (item->isTable())
 		connect(m_item->asTable(), SIGNAL(selectionChanged()), this, SLOT(handleCellSelectionChanged()));
@@ -160,7 +158,7 @@
 		}
 		else
 		{
-			displayTableStyle(table->style());
+//			displayTableStyle(table->style());
 			displayCellStyle(table->activeCell().style());
 		}
 	}
@@ -284,7 +282,6 @@
 void PropertiesPalette_Table::updateBorderLineList()
 {
 	borderLineList->clear();
-
 	foreach (const TableBorderLine& borderLine, m_currentBorder.borderLines())
 	{
 		QPixmap *icon = getWidePixmap(getColor(borderLine.color(), borderLine.shade()));
@@ -294,11 +291,7 @@
 			.arg(CommonStrings::translatePenStyleName(borderLine.style()));
 		borderLineList->addItem(new QListWidgetItem(*icon, text, borderLineList));
 	}
-
-	/*if (borderLineList->count() > 0)
-		borderLineList->setCurrentItem(borderLineList->item(0));
-	else
-		on_borderLineList_currentRowChanged(-1);*/
+	removeBorderLineButton->setEnabled(borderLineList->count() > 1);
 }
 
 void PropertiesPalette_Table::updateBorderLineListItem()
@@ -416,10 +409,8 @@
 void PropertiesPalette_Table::on_removeBorderLineButton_clicked()
 {
 	int index = borderLineList->currentRow();
-
 	borderLineList->removeItemWidget(borderLineList->currentItem());
 	m_currentBorder.removeBorderLine(index);
-
 	updateBorderLineList();
 }
 
@@ -513,6 +504,26 @@
 	table->update();
 }
 
+void PropertiesPalette_Table::on_buttonClearTableStyle_clicked()
+{
+	if (!m_item || !m_item->isTable())
+		return;
+	PageItem_Table* table = m_item->asTable();
+	table->unsetDirectFormatting();
+	table->update();
+}
+
+void PropertiesPalette_Table::on_buttonClearCellStyle_clicked()
+{
+	if (!m_item || !m_item->isTable())
+		return;
+	m_doc->dontResize = true;
+	PageItem_Table* table = m_item->asTable();
+	table->activeCell().unsetDirectFormatting();
+	table->adjustTable();
+	table->update();
+}
+
 void PropertiesPalette_Table::updateBorders()
 {
 	if (!m_doc || !m_item || !m_item->isTable())
@@ -522,14 +533,29 @@
 	TableSideSelector::Sides selectedSides = sideSelector->selection();
 
 	m_doc->dontResize = true;
-	if (selectedSides & TableSideSelector::Left)
-		table->setLeftBorder(m_currentBorder);
-	if (selectedSides & TableSideSelector::Right)
-		table->setRightBorder(m_currentBorder);
-	if (selectedSides & TableSideSelector::Top)
-		table->setTopBorder(m_currentBorder);
-	if (selectedSides & TableSideSelector::Bottom)
-		table->setBottomBorder(m_currentBorder);
+	if (m_doc->appMode != modeEditTable)
+	{
+		if (selectedSides & TableSideSelector::Left)
+			table->setLeftBorder(m_currentBorder);
+		if (selectedSides & TableSideSelector::Right)
+			table->setRightBorder(m_currentBorder);
+		if (selectedSides & TableSideSelector::Top)
+			table->setTopBorder(m_currentBorder);
+		if (selectedSides & TableSideSelector::Bottom)
+			table->setBottomBorder(m_currentBorder);
+	}
+	else
+	{
+		TableCell cell = table->activeCell();
+		if (selectedSides & TableSideSelector::Left)
+			cell.setLeftBorder(m_currentBorder);
+		if (selectedSides & TableSideSelector::Right)
+			cell.setRightBorder(m_currentBorder);
+		if (selectedSides & TableSideSelector::Top)
+			cell.setTopBorder(m_currentBorder);
+		if (selectedSides & TableSideSelector::Bottom)
+			cell.setBottomBorder(m_currentBorder);
+	}
 	table->adjustTable();
 	table->update();
 }
@@ -538,8 +564,8 @@
 {
 	cellStyleCombo->setToolTip( tr("Cell style of currently selected cell"));
 	tableStyleCombo->setToolTip( tr("Table style of currently selected table"));
-	labelCells->setToolTip( tr("Remove Direct Cell Formatting"));
-	labelTable->setToolTip( tr("Remove Direct Table Formatting"));
+	buttonClearCellStyle->setToolTip( tr("Remove Direct Cell Formatting"));
+	buttonClearTableStyle->setToolTip( tr("Remove Direct Table Formatting"));
 }
 
 void PropertiesPalette_Table::unitChange()

Modified: trunk/Scribus/scribus/ui/propertiespalette_table.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17336&path=/trunk/Scribus/scribus/ui/propertiespalette_table.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_table.h (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_table.h Sat Feb 25 21:59:25 2012
@@ -87,6 +87,8 @@
 	void on_fillColor_activated(const QString& colorName);
 	/// Handles table fill shade changes.
 	void on_fillShade_valueChanged(int shade);
+	void on_buttonClearTableStyle_clicked();
+	void on_buttonClearCellStyle_clicked();
 
 private:
 	/// This enum represents three states. Used for three-state logic.




More information about the scribus-commit mailing list