r22713 by jghali - Add some const to PageItem::canBeLinkedTo() and remove now unnecessary argument in PageItem::unlinkWithText()

scribus-commit scribus-commit at lists.scribus.net
Sun Sep 30 21:38:09 UTC 2018


Author: jghali
Date: Sun Sep 30 21:38:09 2018
New Revision: 22713

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22713
Log:
Add some const to PageItem::canBeLinkedTo() and remove now unnecessary argument in PageItem::unlinkWithText()

Modified:
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem.h
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusdoc.h

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22713&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp	(original)
+++ trunk/Scribus/scribus/pageitem.cpp	Sun Sep 30 21:38:09 2018
@@ -1295,15 +1295,16 @@
 	return qMin(signed(MaxChars), itemText.length()) - 1;
 }
 
-bool PageItem::canBeLinkedTo(PageItem* nxt)
+bool PageItem::canBeLinkedTo(const PageItem* nxt) const
 {
 	if (this->nextInChain() )
 		return false;
 	if (!nxt || nxt->prevInChain() )
 		return false;
-	for (PageItem* ff=nxt; ff; ff=ff->nextInChain())
-	{
-		if (ff == this)return false;
+	for (const PageItem* ff = nxt; ff; ff = ff->nextInChain())
+	{
+		if (ff == this)
+			return false;
 	}
 	return true;
 }
@@ -1488,7 +1489,7 @@
 
 //unlink selected frame from text chain
 //but copy or cut its content from itemText
-void PageItem::unlinkWithText(bool cutText)
+void PageItem::unlinkWithText()
 {
 	PageItem * Next = NextBox;
 	PageItem * Prev = BackBox;
@@ -1506,7 +1507,7 @@
 		{
 			StoryText content(m_Doc);
 			itemText.select(lastInFrame() +1, length - (lastInFrame() +1));
-			content.insert(0, itemText, cutText);
+			content.insert(0, itemText, true);
 			itemText.removeSelection();
 			unlink(false);
 			Next->itemText.insert(0, content);
@@ -1515,11 +1516,6 @@
 		else
 		{
 			unlink(false);
-			if (!cutText)
-			{
-				Next->itemText.insert(0, itemText);
-				Next->update();
-			}
 		}
 	}
 	else
@@ -1529,8 +1525,7 @@
 		itemText.select(firstInFrame(), length - firstInFrame());
 		StoryText content(m_Doc);
 		content.insert(0, itemText, true);
-		if (cutText)
-			itemText.removeSelection();
+		itemText.removeSelection();
 		Prev->unlink(false);
 		itemText.insert(0, content);
 		update();
@@ -1539,7 +1534,6 @@
 	{
 		ScItemState<QPair<PageItem*, PageItem*> > *is = new ScItemState<QPair<PageItem*, PageItem*> >(Um::UnlinkTextFrame);
 		is->set("UNLINK_TEXT_FRAME");
-		is->set("CUT_TEXT", cutText);
 		is->setItem(qMakePair(Prev, Next));
 		undoManager->action(this, is);
 	}
@@ -7316,28 +7310,19 @@
 		qFatal("PageItem::restoreUnlinkTextFrame: dynamic cast failed");
 	if (is->contains("CUT_TEXT"))
 	{
-		bool cutText = is->getBool("CUT_TEXT");
 		if (isUndo)
 		{
 			PageItem* prev = is->getItem().first;
 			PageItem* next  = is->getItem().second;
 			if (prev != nullptr)
-			{
-				if (!cutText)
-					itemText = StoryText(m_Doc);
 				prev->link(this, false);
-			}
 			else if (next != nullptr)
-			{
-				if (!cutText)
-					this->itemText = StoryText(m_Doc);
 				this->link(next, false);
-			}
 			else
 				Q_ASSERT(prev || next);
 		}
 		else
-			unlinkWithText(cutText);
+			unlinkWithText();
 	}
 	else
 	{

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22713&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h	(original)
+++ trunk/Scribus/scribus/pageitem.h	Sun Sep 30 21:38:09 2018
@@ -461,11 +461,11 @@
 	const PageItem* nextInChain() const { return NextBox; }
 	bool isInChain() { return ((BackBox != nullptr) || (NextBox != nullptr)); }
 
-	bool canBeLinkedTo(PageItem* nextFrame);
+	bool canBeLinkedTo(const PageItem* nextFrame) const;
 	void unlink(bool createUndo = true);
 	void link(PageItem* nextFrame, bool addPARSEP = true);
 	void dropLinks();
-	void unlinkWithText(bool);
+	void unlinkWithText();
 
 	void setSampleItem(bool b) {m_sampleItem=b;}
 	const QVector<double>& dashes() const { return DashValues; }

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22713&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp	(original)
+++ trunk/Scribus/scribus/scribusdoc.cpp	Sun Sep 30 21:38:09 2018
@@ -16158,7 +16158,7 @@
 	}
 }
 
-void ScribusDoc::itemSelection_UnlinkTextFrameAndKeepText( Selection *customSelection, bool cutText)
+void ScribusDoc::itemSelection_UnlinkTextFrameAndCutText( Selection *customSelection)
 {
 	Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
 	assert(itemSelection != nullptr);
@@ -16172,16 +16172,11 @@
 		if (!currItem || !currItem->asTextFrame())
 			continue;
 		if (currItem->nextInChain() || currItem->prevInChain())
-			currItem->unlinkWithText(cutText);
+			currItem->unlinkWithText();
 	}
 	regionsChanged()->update(QRectF());
 	changed();
 	itemSelection->itemAt(0)->emitAllToGUI();
-}
-
-void ScribusDoc::itemSelection_UnlinkTextFrameAndCutText( Selection *customSelection)
-{
-	itemSelection_UnlinkTextFrameAndKeepText(customSelection, true);
 }
 
 void ScribusDoc::itemSelection_UnWeld()

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22713&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h	(original)
+++ trunk/Scribus/scribus/scribusdoc.h	Sun Sep 30 21:38:09 2018
@@ -1474,7 +1474,6 @@
 	void itemSelection_Rotate(double angle, Selection* customSelection = nullptr);
 	void itemSelection_DoHyphenate();
 	void itemSelection_DoDeHyphenate();
-	void itemSelection_UnlinkTextFrameAndKeepText(Selection* customSelection = nullptr, bool cutText=false);
 	void itemSelection_UnlinkTextFrameAndCutText(Selection* customSelection = nullptr);
 	void itemSelection_SendToLayer(int layerID);
 	void itemSelection_SetImageOffset(double x, double y, Selection* customSelection = nullptr);




More information about the scribus-commit mailing list