r19366 by jghali - a bit of refactoring

scribus-commit scribus-commit at lists.scribus.net
Wed Jul 23 21:57:19 UTC 2014


Author: jghali
Date: Wed Jul 23 21:57:19 2014
New Revision: 19366

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19366
Log:
a bit of refactoring

Modified:
    trunk/Scribus/scribus/fonts/ftface.h
    trunk/Scribus/scribus/fonts/scface_ps.h
    trunk/Scribus/scribus/scfonts.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/ui/marksmanager.cpp

Modified: trunk/Scribus/scribus/fonts/ftface.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19366&path=/trunk/Scribus/scribus/fonts/ftface.h
==============================================================================
--- trunk/Scribus/scribus/fonts/ftface.h (original)
+++ trunk/Scribus/scribus/fonts/ftface.h Wed Jul 23 21:57:19 2014
@@ -100,8 +100,6 @@
 	mutable QString m_pdfDescender;
 	mutable QString m_italicAngle;
 	mutable QString m_pdfFontBBox;
-	mutable QString StdVW;
-	QString FontEnc;
 
 	mutable int m_encoding;
 

Modified: trunk/Scribus/scribus/fonts/scface_ps.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19366&path=/trunk/Scribus/scribus/fonts/scface_ps.h
==============================================================================
--- trunk/Scribus/scribus/fonts/scface_ps.h (original)
+++ trunk/Scribus/scribus/fonts/scface_ps.h Wed Jul 23 21:57:19 2014
@@ -64,7 +64,6 @@
 //			Descender = tmp.setNum(face->descender);
 //			CapHeight = Ascent;
 //			ItalicAngle = "0";
-//			StdVW = "1";
 //			FontBBox = tmp.setNum(face->bbox.xMin)+" "+tmp2.setNum(face->bbox.yMin)+" "+tmp3.setNum(face->bbox.xMax)+" "+tmp4.setNum(face->bbox.yMax);
 /*
  setBestEncoding(face);

Modified: trunk/Scribus/scribus/scfonts.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19366&path=/trunk/Scribus/scribus/scfonts.cpp
==============================================================================
--- trunk/Scribus/scribus/scfonts.cpp (original)
+++ trunk/Scribus/scribus/scfonts.cpp Wed Jul 23 21:57:19 2014
@@ -669,27 +669,7 @@
 				t.subset(true);
 			t.m->forDocument = DocName;
 			//setBestEncoding(face); //AV
-/*			switch (face->charmap? face->charmap->encoding : -1)
-			{
-				case	 FT_ENCODING_ADOBE_STANDARD: 
-					t->FontEnc = QString("StandardEncoding");
-					break;
-				case	 FT_ENCODING_APPLE_ROMAN: 
-					t->FontEnc = QString("MacRomanEncoding");
-					break;
-				case	 FT_ENCODING_ADOBE_EXPERT: 
-					t->FontEnc = QString("MacExpertEncoding");
-					break;
-				case	 FT_ENCODING_ADOBE_LATIN_1: 
-					t->FontEnc = QString("WinAnsiEncoding");
-					break;
-				case	 FT_ENCODING_UNICODE: 
-					t->FontEnc = QString("Unicode");
-					break;
-				default:
-					t->FontEnc = QString();
-			}
-*/			if (showFontInformation)
+			if (showFontInformation)
 				sDebug(QObject::tr("Font %1 loaded from %2(%3)").arg(t.psName()).arg(filename).arg(faceindex+1));
 
 /*

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19366&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Wed Jul 23 21:57:19 2014
@@ -17543,15 +17543,14 @@
 	for (int a = lastItem +1; a < DocItems.count(); ++a)
 	{
 		item = DocItems.at(a);
-		if ((item != NULL) && item->isTextFrame() && (item->itemText.length() > 0))
-		{
-			for (int i = item->firstInFrame(); i <= item->lastInFrame(); ++i)
-			{
-                if (item->itemText.hasMark(i, mrk))
-				{
-					lastItem = a;
-					return item;
-				}
+		if (!item || !item->isTextFrame() || (item->itemText.length() <= 0))
+			continue;
+		for (int i = item->firstInFrame(); i <= item->lastInFrame(); ++i)
+		{
+			if (item->itemText.hasMark(i, mrk))
+			{
+				lastItem = a;
+				return item;
 			}
 		}
 	}
@@ -17571,7 +17570,7 @@
 			{
 				for (int pos = 0; pos < item->itemText.length(); ++pos)
 				{
-                    if (item->itemText.hasMark(pos, mrk))
+					if (item->itemText.hasMark(pos, mrk))
 					{
 						currItem = item;
 						return pos;
@@ -17613,7 +17612,7 @@
 			}
 			for (; i < end; ++i)
 			{
-                if (currItem->itemText.hasMark(i, mrk))
+				if (currItem->itemText.hasMark(i, mrk))
 					return true;
 			}
 		}
@@ -17709,7 +17708,8 @@
 }
 
 void ScribusDoc::setUndoDelMark(Mark *mrk)
-{ //used by MarksManager
+{
+	//used by MarksManager
 	if (UndoManager::undoEnabled())
 	{
 		ScItemsState* ims = new ScItemsState(Um::DeleteMark,"",Um::IDelete);
@@ -17787,25 +17787,22 @@
 	{
 		foreach (PageItem* item, DocItems)
 		{
-			if (item->isTextFrame() && !item->isNoteFrame())
-			{
-				if (item->prevInChain() == NULL)
+			if (!item->isTextFrame() || item->isNoteFrame())
+				continue;
+			if (item->prevInChain() != NULL)
+				continue;
+			item = item->lastInChain();
+			int pos = item->lastInFrame() + 1;
+			if (pos >= item->itemText.length())
+				continue;
+			for (int i = pos; i < item->itemText.length(); ++i)
+			{
+				if (item->itemText.hasMark(i) && item->itemText.mark(i)->isNoteType())
 				{
-					item = item->lastInChain();
-					int pos = item->lastInFrame() +1;
-					if (pos < item->itemText.length())
-					{
-						for (int i = pos; i < item->itemText.length(); ++i)
-						{
-                            if (item->itemText.hasMark(i) && item->itemText.mark(i)->isNoteType())
-							{
-                                TextNote * note = item->itemText.mark(i)->getNotePtr();
-								note->setNoteMark(NULL);
-								note->masterMark()->setItemPtr(item);
-								note->masterMark()->setItemName(item->itemName());
-							}
-						}
-					}
+					TextNote * note = item->itemText.mark(i)->getNotePtr();
+					note->setNoteMark(NULL);
+					note->masterMark()->setItemPtr(item);
+					note->masterMark()->setItemName(item->itemName());
 				}
 			}
 		}

Modified: trunk/Scribus/scribus/ui/marksmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19366&path=/trunk/Scribus/scribus/ui/marksmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/marksmanager.cpp (original)
+++ trunk/Scribus/scribus/ui/marksmanager.cpp Wed Jul 23 21:57:19 2014
@@ -115,17 +115,18 @@
 {
 	if (m_Doc != NULL)
 		disconnect(m_Doc->scMW(), SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int)));
-	bool hasDoc = (doc != NULL);
+
 	m_Doc = doc;
-	if (hasDoc)
-	{
-		UpdateButton->setEnabled(true);
-		listView->setEnabled(true);
-		updateListView();
-		connect(m_Doc->scMW(), SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int)));
-	}
-	else
+	if (!m_Doc)
+	{
 		listView->clear();
+		return;
+	}
+
+	UpdateButton->setEnabled(true);
+	listView->setEnabled(true);
+	updateListView();
+	connect(m_Doc->scMW(), SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int)));
 }
 
 void MarksManager::languageChange()
@@ -177,51 +178,52 @@
 		if (mrk->isUnique() && !mrk->label.startsWith("UNVISIBLE*") && !m_Doc->isMarkUsed(mrk, true))
 			notUsed.append(mrk);
 	}
-	if (!notUsed.isEmpty())
-	{
-		for (int a=0; a<notUsed.count(); ++a)
-		{
-			Mark* mrk = notUsed.at(a);
-			QString l = "UNVISIBLE*" + mrk->label;
-			getUniqueName(l,m_Doc->marksLabelsList(mrk->getType()),"_");
-			mrk->label = l;
-		}
-		updateListView();
-	}
+
+	if (notUsed.isEmpty())
+		return;
+
+	for (int a=0; a < notUsed.count(); ++a)
+	{
+		Mark* mrk = notUsed.at(a);
+		QString l = "UNVISIBLE*" + mrk->label;
+		getUniqueName(l, m_Doc->marksLabelsList(mrk->getType()), "_");
+		mrk->label = l;
+	}
+	updateListView();
 }
 
 void MarksManager::on_EditButton_clicked()
 {
 	Mark* mrk = getMarkFromListView();
-	if (mrk != NULL)
-	{
-		if (m_Doc->scMW()->editMarkDlg(mrk))
-		{
-			if (mrk->isType(MARKVariableTextType))
-				m_Doc->flag_updateMarksLabels = true;
-//			else
-//				currItem->invalid = true;
-			m_Doc->changed();
-			m_Doc->regionsChanged()->update(QRectF());
-			updateListView();
-		}
-	}
-}
-
-void MarksManager::on_DeleteButton_clicked()
-{
-	Mark* mrk = getMarkFromListView();
-	if (mrk != NULL)
-	{
-		if (mrk->isType(MARKNoteMasterType))
-			m_Doc->setUndoDelNote(mrk->getNotePtr());
-		else
-			m_Doc->setUndoDelMark(mrk);
-		m_Doc->eraseMark(mrk, true, NULL, true);
+	if (mrk == NULL)
+		return;
+
+	if (m_Doc->scMW()->editMarkDlg(mrk))
+	{
+		if (mrk->isType(MARKVariableTextType))
+			m_Doc->flag_updateMarksLabels = true;
+//		else
+//			currItem->invalid = true;
 		m_Doc->changed();
 		m_Doc->regionsChanged()->update(QRectF());
 		updateListView();
 	}
+}
+
+void MarksManager::on_DeleteButton_clicked()
+{
+	Mark* mrk = getMarkFromListView();
+	if (mrk == NULL)
+		return;
+
+	if (mrk->isType(MARKNoteMasterType))
+		m_Doc->setUndoDelNote(mrk->getNotePtr());
+	else
+		m_Doc->setUndoDelMark(mrk);
+	m_Doc->eraseMark(mrk, true, NULL, true);
+	m_Doc->changed();
+	m_Doc->regionsChanged()->update(QRectF());
+	updateListView();
 }
 
 void MarksManager::on_listView_doubleClicked(const QModelIndex &index)




More information about the scribus-commit mailing list