r19337 by jghali - #12139, #12503: "Normal" Master Page is duplicated

scribus-commit scribus-commit at lists.scribus.net
Fri Jul 11 23:33:25 UTC 2014


Author: jghali
Date: Fri Jul 11 23:33:25 2014
New Revision: 19337

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19337
Log:
#12139, #12503: "Normal" Master Page is duplicated

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

Modified: trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19337&path=/trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp (original)
+++ trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp Fri Jul 11 23:33:25 2014
@@ -400,12 +400,14 @@
 
 void PagePalette_MasterPages::selectMasterPage(QListWidgetItem *item)
 {
-	m_currentPage = item->text();
-	deleteButton->setEnabled(m_doc->MasterNames.count() == 1 ? false : true);
-	if (m_currentPage == CommonStrings::trMasterPageNormal || m_currentPage == CommonStrings::masterPageNormal)
-		deleteButton->setEnabled(false);
-	else
-		deleteButton->setEnabled(true);
+	m_currentPage = item->data(Qt::UserRole).toString();
+
+	bool deleteEnabled = true;
+	deleteEnabled &= (m_doc->MasterNames.count() > 1);
+	deleteEnabled &= (m_currentPage != CommonStrings::masterPageNormal);
+	deleteEnabled &= (m_currentPage != CommonStrings::trMasterPageNormal);
+	deleteButton->setEnabled(deleteEnabled);
+
 	if (m_doc->appMode == modeEditClip)
 		m_view->requestMode(submodeEndNodeEdit);
 	else if (m_doc->appMode == modeEdit || m_doc->appMode == modeEditGradientVectors)
@@ -420,15 +422,32 @@
 	if (!m_doc || !m_view)
 		return;
 
-	m_currentPage = name;
-	deleteButton->setEnabled(m_doc->MasterNames.count() == 1 ? false : true);
-	if (m_currentPage == CommonStrings::trMasterPageNormal)
-	{
-		m_currentPage = CommonStrings::masterPageNormal;
-		deleteButton->setEnabled(false);
-	}
-	else
-		deleteButton->setEnabled(true);
+	m_currentPage = QString();
+	for (int i = 0; i < masterPageListBox->count(); ++i)
+	{
+		QListWidgetItem* item = masterPageListBox->item(i);
+		QString realPageName  = item->data(Qt::UserRole).toString();
+		if (item->text() == name)
+		{
+			m_currentPage = realPageName;
+			break;
+		}
+		if (realPageName == name)
+		{
+			m_currentPage = name;
+			break;
+		}
+	}
+	
+	if (m_currentPage.isEmpty())
+		m_currentPage = m_doc->MasterPages.at(0)->pageName();
+
+	bool deleteEnabled = true;
+	deleteEnabled &= (m_doc->MasterNames.count() > 1);
+	deleteEnabled &= (m_currentPage != CommonStrings::masterPageNormal);
+	deleteEnabled &= (m_currentPage != CommonStrings::trMasterPageNormal);
+	deleteButton->setEnabled(deleteEnabled);
+
 	if (m_doc->appMode == modeEditClip)
 		m_view->requestMode(submodeEndNodeEdit);
 	m_view->showMasterPage(m_doc->MasterNames[m_currentPage]);

Modified: trunk/Scribus/scribus/ui/pagepalette_masterpages.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19337&path=/trunk/Scribus/scribus/ui/pagepalette_masterpages.h
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette_masterpages.h (original)
+++ trunk/Scribus/scribus/ui/pagepalette_masterpages.h Fri Jul 11 23:33:25 2014
@@ -47,7 +47,6 @@
 	ScribusView *m_view;
 
 protected:
-
 	void connectSignals();
 	void disconnectSignals();
 




More information about the scribus-commit mailing list