r16034 by fschmid - Don't allow the pattern/symbol currently edited to be used.

scribus-commit scribus-commit at lists.scribus.net
Mon Nov 29 22:27:49 CET 2010


Author: fschmid
Date: Mon Nov 29 21:27:49 2010
New Revision: 16034

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16034
Log:
Don't allow the pattern/symbol currently edited to be used.

Modified:
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/ui/cpalette.cpp
    trunk/Scribus/scribus/ui/cpalette.h
    trunk/Scribus/scribus/ui/paintmanager.cpp
    trunk/Scribus/scribus/ui/symbolpalette.cpp
    trunk/Scribus/scribus/ui/symbolpalette.h
    trunk/Scribus/scribus/ui/transparencypalette.cpp
    trunk/Scribus/scribus/ui/transparencypalette.h

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16034&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Mon Nov 29 21:27:49 2010
@@ -211,6 +211,7 @@
 #include "tocgenerator.h"
 //#include "ui/tocindexprefs.h"
 #include "ui/transformdialog.h"
+#include "ui/transparencypalette.h"
 #include "ui/copypagetomasterpagedialog.h"
 #include "ui/edittoolbar.h"
 #include "ui/filetoolbar.h"
@@ -8566,7 +8567,22 @@
 		scrActions["toolsPDFAnnot3D"]->setEnabled(false);
 #endif
 		pagePalette->enablePalette(false);
-		symbolPalette->editingStart(temp);
+		QStringList patterns2Del;
+		QStringList mainPatterns = doc->docPatterns.keys();
+		for (int a = 0; a < mainPatterns.count(); a++)
+		{
+			if (mainPatterns[a] != temp)
+			{
+				QStringList subPatterns;
+				subPatterns = doc->getUsedPatternsHelper(mainPatterns[a], subPatterns);
+				if (subPatterns.contains(temp))
+					patterns2Del.append(mainPatterns[a]);
+			}
+		}
+		patterns2Del.append(temp);
+		symbolPalette->editingStart(patterns2Del);
+		propertiesPalette->Cpal->hideEditedPatterns(patterns2Del);
+		propertiesPalette->Tpal->hideEditedPatterns(patterns2Del);
 		updateActiveWindowCaption( tr("Editing Symbol: %1").arg(temp));
 	}
 }

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16034&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Mon Nov 29 21:27:49 2010
@@ -2894,19 +2894,20 @@
 		}
 		const QString& pat2 = pat->items.at(c)->strokePattern();
 		if (!pat2.isEmpty() && !results.contains(pat2))
-			results.append(pat->items.at(c)->strokePattern());
+			pats.append(pat->items.at(c)->strokePattern());
 		const QString& pat3 = pat->items.at(c)->patternMask();
 		if (!pat3.isEmpty() && !results.contains(pat3))
-			results.append(pat->items.at(c)->patternMask());
+			pats.append(pat->items.at(c)->patternMask());
 	}
 	if (!pats.isEmpty())
 	{
+		results = pats;
 		for (int c = 0; c < pats.count(); ++c)
 		{
 			getUsedPatternsHelper(pats[c], results);
 		}
 	}
-	return pats;
+	return results;
 }
 
 QStringList ScribusDoc::getUsedSymbols()

Modified: trunk/Scribus/scribus/ui/cpalette.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16034&path=/trunk/Scribus/scribus/ui/cpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/cpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/cpalette.cpp Mon Nov 29 21:27:49 2010
@@ -533,6 +533,19 @@
 	connect(patternBox, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(selectPattern(QListWidgetItem*)));
 }
 
+void Cpalette::hideEditedPatterns(QStringList names)
+{
+	for (int a = 0; a < names.count(); a++)
+	{
+		QList<QListWidgetItem*> items = patternBox->findItems(names[a], Qt::MatchExactly);
+		if (items.count() > 0)
+			items[0]->setHidden(true);
+		items = patternBoxStroke->findItems(names[a], Qt::MatchExactly);
+		if (items.count() > 0)
+			items[0]->setHidden(true);
+	}
+}
+
 void Cpalette::SetPatterns(QMap<QString, ScPattern> *docPatterns)
 {
 	patternList = docPatterns;

Modified: trunk/Scribus/scribus/ui/cpalette.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16034&path=/trunk/Scribus/scribus/ui/cpalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/cpalette.h (original)
+++ trunk/Scribus/scribus/ui/cpalette.h Mon Nov 29 21:27:49 2010
@@ -76,6 +76,7 @@
 	void setNamedGradientStroke(const QString &name);
 	void selectPattern(QListWidgetItem *c);
 	void selectPatternS(QListWidgetItem *c);
+	void hideEditedPatterns(QStringList names);
 	void updatePatternList();
 	void updateGradientList();
 	void setActPattern(QString pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY);

Modified: trunk/Scribus/scribus/ui/paintmanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16034&path=/trunk/Scribus/scribus/ui/paintmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/paintmanager.cpp (original)
+++ trunk/Scribus/scribus/ui/paintmanager.cpp Mon Nov 29 21:27:49 2010
@@ -917,17 +917,43 @@
 	pats.clear();
 	for (int c = 0; c < pat->items.count(); ++c)
 	{
+		if ((pat->items.at(c)->GrType == 8) || (pat->items.at(c)->itemType() == PageItem::Symbol))
+		{
+			const QString& patName = pat->items.at(c)->pattern();
+			if (!patName.isEmpty() && !results.contains(patName))
+				pats.append(patName);
+		}
+		const QString& pat2 = pat->items.at(c)->strokePattern();
+		if (!pat2.isEmpty() && !results.contains(pat2))
+			pats.append(pat->items.at(c)->strokePattern());
+		const QString& pat3 = pat->items.at(c)->patternMask();
+		if (!pat3.isEmpty() && !results.contains(pat3))
+			pats.append(pat->items.at(c)->patternMask());
+	}
+	if (!pats.isEmpty())
+	{
+		results = pats;
+		for (int c = 0; c < pats.count(); ++c)
+		{
+			getUsedPatternsHelper(pats[c], results);
+		}
+	}
+/*	QStringList pats;
+	pats.clear();
+	for (int c = 0; c < pat->items.count(); ++c)
+	{
 		if ((!results.contains(pat->items.at(c)->pattern())) && ((pat->items.at(c)->GrType == 8) || (pat->items.at(c)->itemType() == PageItem::Symbol)))
 			pats.append(pat->items.at(c)->pattern());
 	}
 	if (!pats.isEmpty())
 	{
+		results = pats;
 		for (int c = 0; c < pats.count(); ++c)
 		{
 			getUsedPatternsHelper(pats[c], results);
 		}
-	}
-	return pats;
+	} */
+	return results;
 }
 
 void PaintManagerDialog::removeUnusedColorItem()

Modified: trunk/Scribus/scribus/ui/symbolpalette.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16034&path=/trunk/Scribus/scribus/ui/symbolpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/symbolpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/symbolpalette.cpp Mon Nov 29 21:27:49 2010
@@ -96,8 +96,7 @@
 
 	unsetDoc();
 	m_scMW  = NULL;
-	editItemName = "";
-	editItem = NULL;
+	editItemNames.clear();
 	languageChange();
 	connect(SymbolViewWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
 }
@@ -108,41 +107,21 @@
 		emit startEdit(item->text());
 }
 
-void SymbolPalette::editingStart(QString name)
+void SymbolPalette::editingStart(QStringList names)
 {
-	editItemName = name;
-	QList<QListWidgetItem *> items = SymbolViewWidget->findItems(name, Qt::MatchExactly);
-	if (items.count() > 0)
+	editItemNames = names;
+	for (int a = 0; a < editItemNames.count(); a++)
 	{
-		editItem = items[0];
-		editItem->setFlags(0);
+		QList<QListWidgetItem*> items = SymbolViewWidget->findItems(names[a], Qt::MatchExactly);
+		if (items.count() > 0)
+			items[0]->setFlags(0);
 	}
 }
 
 void SymbolPalette::editingFinished()
 {
-	if (!editItemName.isEmpty())
-	{
-		QPixmap pm;
-		ScPattern pa = currDoc->docPatterns[editItemName];
-		if (pa.getPattern()->width() >= pa.getPattern()->height())
-			pm = QPixmap::fromImage(pa.getPattern()->scaledToWidth(48, Qt::SmoothTransformation));
-		else
-			pm = QPixmap::fromImage(pa.getPattern()->scaledToHeight(48, Qt::SmoothTransformation));
-		QPixmap pm2(48, 48);
-		pm2.fill(palette().color(QPalette::Base));
-		QPainter p;
-		p.begin(&pm2);
-		p.drawPixmap(24 - pm.width() / 2, 24 - pm.height() / 2, pm);
-		p.end();
-		if (editItem != NULL)
-		{
-			editItem->setIcon(pm2);
-			editItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled);
-		}
-	}
-	editItemName = "";
-	editItem = NULL;
+	editItemNames.clear();
+	updateSymbolList();
 }
 
 void SymbolPalette::setMainWindow(ScribusMainWindow *mw)
@@ -188,11 +167,8 @@
 		p.drawPixmap(24 - pm.width() / 2, 24 - pm.height() / 2, pm);
 		p.end();
 		QListWidgetItem *item = new QListWidgetItem(pm2, it.key(), SymbolViewWidget);
-		if (it.key() == editItemName)
-		{
+		if (editItemNames.contains(it.key()))
 			item->setFlags(0);
-			editItem = item;
-		}
 		else
 			item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled);
 	}

Modified: trunk/Scribus/scribus/ui/symbolpalette.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16034&path=/trunk/Scribus/scribus/ui/symbolpalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/symbolpalette.h (original)
+++ trunk/Scribus/scribus/ui/symbolpalette.h Mon Nov 29 21:27:49 2010
@@ -67,7 +67,7 @@
 	void setMainWindow(ScribusMainWindow *mw);
 	void setDoc(ScribusDoc *);
 	void unsetDoc();
-	void editingStart(QString name);
+	void editingStart(QStringList names);
 	void editingFinished();
 	void updateSymbolList();
 	
@@ -86,8 +86,7 @@
 	QVBoxLayout* PaletteLayout;
 	ScribusDoc *currDoc;
 	ScribusMainWindow *m_scMW;
-	QListWidgetItem *editItem;
-	QString editItemName;
+	QStringList editItemNames;
 };
 
 #endif

Modified: trunk/Scribus/scribus/ui/transparencypalette.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16034&path=/trunk/Scribus/scribus/ui/transparencypalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/transparencypalette.cpp (original)
+++ trunk/Scribus/scribus/ui/transparencypalette.cpp Mon Nov 29 21:27:49 2010
@@ -335,6 +335,16 @@
 {
 	if (TGradDia)
 		TGradDia->setValues(x1, y1, x2, y2, fx, fy, sg, sk, 0, 0);
+}
+
+void Tpalette::hideEditedPatterns(QStringList names)
+{
+	for (int a = 0; a < names.count(); a++)
+	{
+		QList<QListWidgetItem*> items = patternBox->findItems(names[a], Qt::MatchExactly);
+		if (items.count() > 0)
+			items[0]->setHidden(true);
+	}
 }
 
 void Tpalette::updatePatternList()

Modified: trunk/Scribus/scribus/ui/transparencypalette.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16034&path=/trunk/Scribus/scribus/ui/transparencypalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/transparencypalette.h (original)
+++ trunk/Scribus/scribus/ui/transparencypalette.h Mon Nov 29 21:27:49 2010
@@ -79,6 +79,7 @@
 	void switchPatternMode();
 	void editGradientVector();
 	void setActiveGradDia(bool active);
+	void hideEditedPatterns(QStringList names);
 	void updatePatternList();
 	void SetPatterns(QMap<QString, ScPattern> *docPatterns);
 	void selectPattern(QListWidgetItem *c);




More information about the scribus-commit mailing list