r19530 by jghali - some refactoring

scribus-commit scribus-commit at lists.scribus.net
Tue Sep 23 21:44:05 UTC 2014


Author: jghali
Date: Tue Sep 23 21:44:05 2014
New Revision: 19530

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19530
Log:
some refactoring

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

Modified: trunk/Scribus/scribus/ui/paintmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19530&path=/trunk/Scribus/scribus/ui/paintmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/paintmanager.cpp (original)
+++ trunk/Scribus/scribus/ui/paintmanager.cpp Tue Sep 23 21:44:05 2014
@@ -795,126 +795,125 @@
 	else
 	{
 		QTreeWidgetItem* it = dataTree->currentItem();
-		if (it)
-		{
-			if ((it->parent() == gradientItems) || (it == gradientItems))
-			{
-				if (it == gradientItems)
-				{
-					int t = QMessageBox::warning(this, CommonStrings::trWarning, tr("Do you really want to clear all your gradients?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
-					if (t == QMessageBox::No)
-						return;
-					replaceMap.clear();
-					for (QHash<QString, VGradient>::Iterator it = dialogGradients.begin(); it != dialogGradients.end(); ++it)
+		if (!it)
+			return;
+		if ((it->parent() == gradientItems) || (it == gradientItems))
+		{
+			if (it == gradientItems)
+			{
+				int t = QMessageBox::warning(this, CommonStrings::trWarning, tr("Do you really want to clear all your gradients?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+				if (t == QMessageBox::No)
+					return;
+				replaceMap.clear();
+				for (QHash<QString, VGradient>::Iterator it = dialogGradients.begin(); it != dialogGradients.end(); ++it)
+				{
+					replaceMap.insert(it.key(), "");
+				}
+				dialogGradients.clear();
+			}
+			else
+			{
+				dialogGradients.remove(it->text(0));
+				replaceMap.insert(it->text(0), "");
+			}
+		}
+		else if ((it->parent() == colorItems) || (it == colorItems))
+		{
+			if (it == colorItems)
+			{
+				int t = QMessageBox::warning(this, CommonStrings::trWarning, tr("Do you really want to clear all your colors and gradients?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+				if (t == QMessageBox::No)
+					return;
+				replaceMap.clear();
+				for (QHash<QString, VGradient>::Iterator it = dialogGradients.begin(); it != dialogGradients.end(); ++it)
+				{
+					replaceMap.insert(it.key(), "");
+				}
+				replaceColorMap.clear();
+				for (ColorList::Iterator it = m_colorList.begin(); it != m_colorList.end(); ++it)
+				{
+					replaceColorMap.insert(it.key(), "Black");
+				}
+				dialogPatterns.clear();
+				dialogGradients.clear();
+				m_colorList.clear();
+				m_colorList.ensureDefaultColors();
+			}
+			else
+			{
+				QString dColor = it->text(0);
+				ColorList UsedCG = getGradientColors();
+				if (inDocUsedColors.contains(dColor) || UsedCG.contains(dColor))
+				{
+					DelColor *dia = new DelColor(this, m_colorList, dColor, true);
+					if (dia->exec())
 					{
-						replaceMap.insert(it.key(), "");
+						QString replacementColor(dia->getReplacementColor());
+						if (replacementColor == CommonStrings::tr_NoneColor)
+							replacementColor = CommonStrings::None;
+						if (replaceColorMap.values().contains(dColor))
+						{
+							QMap<QString,QString>::Iterator itt;
+							for (itt = replaceColorMap.begin(); itt != replaceColorMap.end(); ++itt)
+							{
+								if (itt.value() == dColor)
+									itt.value() = replacementColor;
+							}
+						}
+						replaceColorMap.insert(dColor, replacementColor);
+						m_colorList.remove(dColor);
+						updateGradientColors(replacementColor, dColor);
 					}
-					dialogGradients.clear();
+					delete dia;
 				}
 				else
 				{
-					dialogGradients.remove(it->text(0));
-					replaceMap.insert(it->text(0), "");
-				}
-			}
-			else if ((it->parent() == colorItems) || (it == colorItems))
-			{
-				if (it == colorItems)
-				{
-					int t = QMessageBox::warning(this, CommonStrings::trWarning, tr("Do you really want to clear all your colors and gradients?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
-					if (t == QMessageBox::No)
-						return;
-					replaceMap.clear();
-					for (QHash<QString, VGradient>::Iterator it = dialogGradients.begin(); it != dialogGradients.end(); ++it)
+					replaceColorMap.insert(dColor, "Black");
+					updateGradientColors("Black", dColor);
+					m_colorList.remove(dColor);
+				}
+			}
+		}
+		else if ((it->parent() == patternItems) || (it == patternItems))
+		{
+			if (it == patternItems)
+			{
+				int t = QMessageBox::warning(this, CommonStrings::trWarning, tr("Do you really want to clear all your patterns?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+				if (t == QMessageBox::No)
+					return;
+				replaceMapPatterns.clear();
+				for (QHash<QString, ScPattern>::Iterator it = dialogPatterns.begin(); it != dialogPatterns.end(); ++it)
+				{
+					replaceMapPatterns.insert(it.key(), "");
+				}
+				dialogPatterns.clear();
+			}
+			else if (it->parent() == patternItems)
+			{
+				QStringList patterns2Del;
+				QStringList mainPatterns = dialogPatterns.keys();
+				for (int a = 0; a < mainPatterns.count(); a++)
+				{
+					if (mainPatterns[a] != it->text(0))
 					{
-						replaceMap.insert(it.key(), "");
+						QStringList subPatterns;
+						subPatterns = getUsedPatternsHelper(mainPatterns[a], subPatterns);
+						if (subPatterns.contains(it->text(0)))
+							patterns2Del.append(mainPatterns[a]);
 					}
-					replaceColorMap.clear();
-					for (ColorList::Iterator it = m_colorList.begin(); it != m_colorList.end(); ++it)
-					{
-						replaceColorMap.insert(it.key(), "Black");
-					}
-					dialogPatterns.clear();
-					dialogGradients.clear();
-					m_colorList.clear();
-					m_colorList.ensureDefaultColors();
-				}
-				else
-				{
-					QString dColor = it->text(0);
-					ColorList UsedCG = getGradientColors();
-					if (inDocUsedColors.contains(dColor) || UsedCG.contains(dColor))
-					{
-						DelColor *dia = new DelColor(this, m_colorList, dColor, true);
-						if (dia->exec())
-						{
-							QString replacementColor(dia->getReplacementColor());
-							if (replacementColor == CommonStrings::tr_NoneColor)
-								replacementColor = CommonStrings::None;
-							if (replaceColorMap.values().contains(dColor))
-							{
-								QMap<QString,QString>::Iterator itt;
-								for (itt = replaceColorMap.begin(); itt != replaceColorMap.end(); ++itt)
-								{
-									if (itt.value() == dColor)
-										itt.value() = replacementColor;
-								}
-							}
-							replaceColorMap.insert(dColor, replacementColor);
-							m_colorList.remove(dColor);
-							updateGradientColors(replacementColor, dColor);
-						}
-						delete dia;
-					}
-					else
-					{
-						replaceColorMap.insert(dColor, "Black");
-						updateGradientColors("Black", dColor);
-						m_colorList.remove(dColor);
-					}
-				}
-			}
-			else if ((it->parent() == patternItems) || (it == patternItems))
-			{
-				if (it == patternItems)
-				{
-					int t = QMessageBox::warning(this, CommonStrings::trWarning, tr("Do you really want to clear all your patterns?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
-					if (t == QMessageBox::No)
-						return;
-					replaceMapPatterns.clear();
-					for (QHash<QString, ScPattern>::Iterator it = dialogPatterns.begin(); it != dialogPatterns.end(); ++it)
-					{
-						replaceMapPatterns.insert(it.key(), "");
-					}
-					dialogPatterns.clear();
-				}
-				else if (it->parent() == patternItems)
-				{
-					QStringList patterns2Del;
-					QStringList mainPatterns = dialogPatterns.keys();
-					for (int a = 0; a < mainPatterns.count(); a++)
-					{
-						if (mainPatterns[a] != it->text(0))
-						{
-							QStringList subPatterns;
-							subPatterns = getUsedPatternsHelper(mainPatterns[a], subPatterns);
-							if (subPatterns.contains(it->text(0)))
-								patterns2Del.append(mainPatterns[a]);
-						}
-					}
-					patterns2Del.append(it->text(0));
-					for (int a = 0; a < patterns2Del.count(); a++)
-					{
-						dialogPatterns.remove(patterns2Del[a]);
-					}
-				}
-			}
-			updatePatternList();
-			updateGradientList();
-			updateColorList();
-			itemSelected(0);
-			modified = true;
-		}
+				}
+				patterns2Del.append(it->text(0));
+				for (int a = 0; a < patterns2Del.count(); a++)
+				{
+					dialogPatterns.remove(patterns2Del[a]);
+				}
+			}
+		}
+		updatePatternList();
+		updateGradientList();
+		updateColorList();
+		itemSelected(0);
+		modified = true;
 	}
 }
 




More information about the scribus-commit mailing list