r18293 by jghali - #11552: Selecting all fonts via Ctrl+A and deleting them in the font substitution dialog doesn't work

scribus-commit scribus-commit at lists.scribus.net
Tue May 28 19:04:25 UTC 2013


Author: jghali
Date: Tue May 28 19:04:25 2013
New Revision: 18293

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18293
Log:
#11552: Selecting all fonts via Ctrl+A and deleting them in the font substitution dialog doesn't work

Modified:
    trunk/Scribus/scribus/ui/prefs_fonts.cpp
    trunk/Scribus/scribus/ui/prefs_fonts.h

Modified: trunk/Scribus/scribus/ui/prefs_fonts.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18293&path=/trunk/Scribus/scribus/ui/prefs_fonts.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_fonts.cpp (original)
+++ trunk/Scribus/scribus/ui/prefs_fonts.cpp Tue May 28 19:04:25 2013
@@ -110,7 +110,7 @@
 	}
 
 	// signals and slots connections
-	connect(fontSubstitutionsTableWidget, SIGNAL(cellClicked(int, int)), this, SLOT(ReplaceSel(int, int)));
+	connect(fontSubstitutionsTableWidget, SIGNAL(itemSelectionChanged()), this, SLOT(ReplaceSel()));
 	connect(deleteSubstitutionButton, SIGNAL(clicked()), this, SLOT(DelEntry()));
 
 
@@ -225,9 +225,10 @@
 
 }
 
-void Prefs_Fonts::ReplaceSel(int, int)
-{
-	deleteSubstitutionButton->setEnabled(true);
+void Prefs_Fonts::ReplaceSel()
+{
+	int selCount = fontSubstitutionsTableWidget->selectedItems().count();
+	deleteSubstitutionButton->setEnabled(selCount > 0);
 }
 
 void Prefs_Fonts::updateFontList()
@@ -255,11 +256,17 @@
 
 void Prefs_Fonts::DelEntry()
 {
-	int r = fontSubstitutionsTableWidget->currentRow();
-	QString tmp = fontSubstitutionsTableWidget->item(r, 0)->text();
-	fontSubstitutionsTableWidget->removeRow(r);
-	delete FlagsRepl.takeAt(r);
-	RList.remove(tmp);
+	// This works a because selection mode is "Full rows"
+	QList<QTableWidgetItem*> selItems = fontSubstitutionsTableWidget->selectedItems();
+	for (int i = 0; i < selItems.count(); ++i)
+	{
+		QTableWidgetItem* item = selItems.at(i);
+		int r = item->row();
+		QString tmp = fontSubstitutionsTableWidget->item(r, 0)->text();
+		fontSubstitutionsTableWidget->removeRow(r);
+		delete FlagsRepl.takeAt(r);
+		RList.remove(tmp);
+	}
 	deleteSubstitutionButton->setEnabled(false);
 }
 

Modified: trunk/Scribus/scribus/ui/prefs_fonts.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18293&path=/trunk/Scribus/scribus/ui/prefs_fonts.h
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_fonts.h (original)
+++ trunk/Scribus/scribus/ui/prefs_fonts.h Tue May 28 19:04:25 2013
@@ -30,7 +30,7 @@
 
 	public slots:
 		void languageChange();
-		void ReplaceSel(int r, int c);
+		void ReplaceSel();
 		void updateFontList();
 		void DelEntry();
 		void SelectPath(QListWidgetItem *c);




More information about the scribus-commit mailing list