r18558 by jghali - #11788: Page palette bad update

scribus-commit scribus-commit at lists.scribus.net
Mon Oct 14 21:12:22 UTC 2013


Author: jghali
Date: Mon Oct 14 21:12:22 2013
New Revision: 18558

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18558
Log:
#11788: Page palette bad update

Modified:
    trunk/Scribus/scribus/ui/pagepalette_pages.cpp
    trunk/Scribus/scribus/ui/pagepalette_pages.h
    trunk/Scribus/scribus/ui/pagepalette_widgets.cpp
    trunk/Scribus/scribus/ui/pagepalette_widgets.h

Modified: trunk/Scribus/scribus/ui/pagepalette_pages.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18558&path=/trunk/Scribus/scribus/ui/pagepalette_pages.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette_pages.cpp (original)
+++ trunk/Scribus/scribus/ui/pagepalette_pages.cpp Mon Oct 14 21:12:22 2013
@@ -75,7 +75,7 @@
 	connect(pageView  , SIGNAL(Click(int, int, int))   , this, SLOT(pageView_gotoPage(int, int, int)));
 	connect(pageView  , SIGNAL(movePage(int, int))     , this, SLOT(pageView_movePage(int, int)));
 	connect(pageView  , SIGNAL(DelPage(int))           , m_scMW, SLOT(deletePage2(int)));
-	connect(pageView  , SIGNAL(UseTemp(QString, int))  , m_scMW, SLOT(Apply_MasterPage(QString, int)));
+	connect(pageView  , SIGNAL(UseTemp(QString, int))  , this, SLOT(pageView_applyMasterPage(QString, int)));
 	connect(pageView  , SIGNAL(NewPage(int, QString))  , m_scMW, SLOT(slotNewPageP(int, QString)));
 	connect(trash     , SIGNAL(DelPage(int))           , m_scMW, SLOT(deletePage2(int)));
 	connect(trash     , SIGNAL(DelMaster(QString))     , this, SLOT(deleteMasterPage(QString)));
@@ -119,6 +119,15 @@
 		currView->setContentsPos(storedViewXCoor, storedViewYCoor);
 		currView->DrawNew();
 	}
+}
+
+void PagePalette_Pages::pageView_applyMasterPage(QString masterpageName, int pageIndex)
+{
+	m_scMW->Apply_MasterPage(masterpageName, pageIndex);
+
+	SeItem* pageItem = pageView->GetPageItem(pageIndex);
+	if (pageItem)
+		pageItem->setIcon(createIcon(pageIndex, masterpageName, pix));
 }
 
 void PagePalette_Pages::pageView_movePage(int r, int c)
@@ -263,10 +272,7 @@
 	for (int a = 0; a < currView->Doc->DocPages.count(); ++a)
 	{
 		str = currView->Doc->DocPages.at(a)->MPageNam;
-		QRegExp Exp ("([A-Z]*[0-9]*)( *[\\.|\\-|_] *)(.*)");
-		if (Exp.indexIn(str) != -1)
-			str = Exp.cap(1);
-		SeItem *it = new SeItem(str, a, CreateIcon(a, str, pix));
+		SeItem *it = new SeItem(str, a, createIcon(a, str, pix));
 		pageList.append(it);
 		pageView->setItem(rowcounter*rowmult+rowadd, counter*colmult+coladd, (QTableWidgetItem *)it);
 		pageView->setColumnWidth(counter*colmult+coladd, pix.width());
@@ -343,7 +349,7 @@
 		emit gotoMasterPage(masterPageList->CurItem->text());
 }
 
-QPixmap PagePalette_Pages::CreateIcon(int nr, QString mp, QPixmap pixin)
+QPixmap PagePalette_Pages::createIcon(int nr, QString masterPage, QPixmap pixin)
 {
 	QPainter p;
 	// Necessary on windows to ensure the pixmap is drawable
@@ -362,13 +368,12 @@
 		QString tmp(currView->Doc->getSectionPageNumberForPageIndex(nr));
 		if (tmp.isEmpty())
 			tmp = tmp.setNum(nr+1);
-		//QRect b = p.fontMetrics().boundingRect(tmp);
-		//QRect c = QRect((ret.width() / 2 - b.width() / 2)-2, (ret.height() / 2 - b.height() / 2)-2, b.width()+4, b.height()+4);
-		//p.drawRect(c);
-		//QRect d = QRect((ret.width() / 2 - b.width() / 2), (ret.height() / 2 - b.height() / 2), b.width(), b.height());
+		QRegExp Exp ("([A-Z]*[0-9]*)( *[\\.|\\-|_] *)(.*)");
+		if (Exp.indexIn(masterPage) != -1)
+			masterPage = Exp.cap(1);
 		QRect d = QRect(0, 0, ret.width(), ret.height());
 		p.setFont(QFont("Helvetica", 7, QFont::Normal));
-		p.drawText(d, Qt::AlignCenter, tmp+"\n"+mp);
+		p.drawText(d, Qt::AlignCenter, tmp+"\n"+masterPage);
 		p.end();
 		if( !pixin.mask().isNull() )
 			ret.setMask( pixin.mask() );

Modified: trunk/Scribus/scribus/ui/pagepalette_pages.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18558&path=/trunk/Scribus/scribus/ui/pagepalette_pages.h
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette_pages.h (original)
+++ trunk/Scribus/scribus/ui/pagepalette_pages.h Mon Oct 14 21:12:22 2013
@@ -39,8 +39,6 @@
 public slots:
 	void setView(ScribusView *view);
 	void deleteMasterPage(QString tmp);
-	void pageView_movePage(int r, int c);
-	void pageView_gotoPage(int r, int c, int b);
 	void enablePalette(const bool);
 	void handlePageLayout(int layout);
 	void handleFirstPage(int fp);
@@ -51,8 +49,12 @@
 	void Rebuild();
 	void markPage(uint nr);
 	void selMasterPage();
-	QPixmap CreateIcon(int nr, QString mp, QPixmap pixin);
 	void languageChange();
+
+private slots:
+	void pageView_applyMasterPage(QString masterpageName, int pageIndex);
+	void pageView_movePage(int r, int c);
+	void pageView_gotoPage(int r, int c, int b);
 
 signals:
 	void gotoMasterPage(QString);
@@ -64,6 +66,8 @@
 
 	QList<SeItem*>    pageList;
 	QPixmap pix;
+
+	QPixmap createIcon(int nr, QString mp, QPixmap pixin);
 };
 
 #endif // SEITENPAL_H

Modified: trunk/Scribus/scribus/ui/pagepalette_widgets.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18558&path=/trunk/Scribus/scribus/ui/pagepalette_widgets.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette_widgets.cpp (original)
+++ trunk/Scribus/scribus/ui/pagepalette_widgets.cpp Mon Oct 14 21:12:22 2013
@@ -488,6 +488,23 @@
 	return ret;
 }
 
+SeItem* SeView::GetPageItem(int pageIndex)
+{
+	int rows = this->rowCount();
+	int columns = this->columnCount();
+	for (int i = 0; i < rows; ++i)
+	{
+		for (int j = 0; j < columns; ++j)
+		{
+			QTableWidgetItem* tbItem = item(i, j);
+			SeItem* pageItem = dynamic_cast<SeItem*>(tbItem);
+			if (pageItem && pageItem->pageNumber == pageIndex)
+				return pageItem;
+		}
+	}
+	return 0;
+}
+
 /* Der Muelleimer */
 TrashBin::TrashBin(QWidget * parent) : QLabel(parent)
 {

Modified: trunk/Scribus/scribus/ui/pagepalette_widgets.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18558&path=/trunk/Scribus/scribus/ui/pagepalette_widgets.h
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette_widgets.h (original)
+++ trunk/Scribus/scribus/ui/pagepalette_widgets.h Mon Oct 14 21:12:22 2013
@@ -96,8 +96,10 @@
 public:
 	SeView(QWidget* parent);
 	~SeView() {};
+
 	void ClearPix();
 	int GetPage(int r, int c, bool *last);
+	SeItem* GetPageItem(int pageIndex);
 
 public slots:
 	void ToggleNam();




More information about the scribus-commit mailing list