r19932 by jghali - #12460: Undo/Redo is not able to manage multiple "Truncate text" actions

scribus-commit scribus-commit at lists.scribus.net
Mon Mar 16 22:34:15 UTC 2015


Author: jghali
Date: Mon Mar 16 22:34:14 2015
New Revision: 19932

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19932
Log:
#12460: Undo/Redo is not able to manage multiple "Truncate text" actions

Modified:
    trunk/Scribus/scribus/canvasmode_edit.cpp
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribusdoc.cpp

Modified: trunk/Scribus/scribus/canvasmode_edit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19932&path=/trunk/Scribus/scribus/canvasmode_edit.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_edit.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_edit.cpp Mon Mar 16 22:34:14 2015
@@ -531,15 +531,15 @@
 	if (UndoManager::undoEnabled())
 	{
 		SimpleState *ss = dynamic_cast<SimpleState*>(undoManager->getLastUndo());
-		if(ss)
-			ss->set("ETEA",QString(""));
+		if (ss)
+			ss->set("ETEA", QString(""));
 		else
 		{
 			TransactionState *ts = dynamic_cast<TransactionState*>(undoManager->getLastUndo());
-			if(ts)
-				ss = dynamic_cast<SimpleState*>(ts->at(0));
-			if(ss)
-				ss->set("ETEA",QString(""));
+			if (ts)
+				ss = dynamic_cast<SimpleState*>(ts->last());
+			if (ss)
+				ss->set("ETEA", QString(""));
 		}
 	}
 // 	const double mouseX = m->globalX();

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19932&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Mon Mar 16 22:34:14 2015
@@ -4167,14 +4167,14 @@
 		{
 			SimpleState *ss = dynamic_cast<SimpleState*>(undoManager->getLastUndo());
 			if (ss)
-				ss->set("ETEA",QString(""));
+				ss->set("ETEA", QString(""));
 			else
 			{
 				TransactionState *ts = dynamic_cast<TransactionState*>(undoManager->getLastUndo());
 				if (ts)
-					ss = dynamic_cast<SimpleState*>(ts->at(0));
+					ss = dynamic_cast<SimpleState*>(ts->last());
 				if (ss)
-					ss->set("ETEA",QString(""));
+					ss->set("ETEA", QString(""));
 			}
 		}
 	}
@@ -4212,7 +4212,7 @@
 				{
 					SimpleState *ss = dynamic_cast<SimpleState*>(undoManager->getLastUndo());
 					if (ss && ss->get("ETEA") == "insert_frametext")
-							ss->set("TEXT_STR",ss->get("TEXT_STR") + QString(QChar(conv)));
+						ss->set("TEXT_STR",ss->get("TEXT_STR") + QString(QChar(conv)));
 					else {
 						ss = new SimpleState(Um::InsertText,"",Um::ICreate);
 						ss->set("INSERT_FRAMETEXT", "insert_frametext");
@@ -4807,9 +4807,10 @@
 		bool lastIsDelete = false;
 		while (state && state->isTransaction()) {
 			ts = dynamic_cast<TransactionState*>(state);
-			is = dynamic_cast<ScItemState<CharStyle>*>(ts->at(ts->sizet()-1));
-			state = ts->at(0);
-		}
+			is = dynamic_cast<ScItemState<CharStyle>*>(ts->last());
+			state = ts->last();
+		}
+		QString eteaString = (m_Doc->appMode == modeEdit) ? "delete_frametext" : "";
 		UndoTransaction trans = undoManager->beginTransaction(Um::Selection,Um::IDelete,Um::Delete,"",Um::IDelete);
 
 		//find and delete notes and marks in selected text
@@ -4842,7 +4843,7 @@
 			{
 				added = false;
 				lastIsDelete = false;
-				if (is && ts && dynamic_cast<ScItemState<CharStyle>*>(ts->at(0))->get("ETEA") == "delete_frametext" && lastPos < is->getInt("START"))
+				if (is && ts && is->get("ETEA") == "delete_frametext" && lastPos < is->getInt("START"))
 				{
 					if (is->getItem().equiv(lastParent))
 					{
@@ -4852,9 +4853,10 @@
 					}
 					lastIsDelete = true;
 				}
-				else if (is && ts && dynamic_cast<ScItemState<CharStyle>*>(ts->at(0))->get("ETEA") == "delete_frametext"  && lastPos >= is->getInt("START"))
-				{
-					if (is->getItem().equiv(lastParent)){
+				else if (is && ts && is->get("ETEA") == "delete_frametext"  && lastPos >= is->getInt("START"))
+				{
+					if (is->getItem().equiv(lastParent))
+					{
 						is->set("TEXT_STR", is->get("TEXT_STR") + itemText.text(lastPos, i - lastPos));
 						added = true;
 					}
@@ -4868,7 +4870,7 @@
 					{
 						is = new ScItemState<CharStyle>(Um::DeleteText, "", Um::IDelete);
 						is->set("DELETE_FRAMETEXT", "delete_frametext");
-						is->set("ETEA", QString("delete_frametext"));
+						is->set("ETEA", eteaString);
 						is->set("TEXT_STR", itemText.text(lastPos, i - lastPos));
 						is->set("START", start);
 						is->setItem(lastParent);

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19932&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Mon Mar 16 22:34:14 2015
@@ -1485,8 +1485,8 @@
 					if (UndoManager::undoEnabled())
 					{
 						SimpleState *ss = dynamic_cast<SimpleState*>(undoManager->getLastUndo());
-						if(ss && ss->get("ETEA") == "insert_frametext")
-								ss->set("TEXT_STR",ss->get("TEXT_STR") + QString(QChar(unicodevalue)));
+						if (ss && ss->get("ETEA") == "insert_frametext")
+							ss->set("TEXT_STR",ss->get("TEXT_STR") + QString(QChar(unicodevalue)));
 						else {
 							ss = new SimpleState(Um::InsertText,"",Um::ICreate);
 							ss->set("INSERT_FRAMETEXT", "insert_frametext");
@@ -1520,8 +1520,8 @@
 						if (UndoManager::undoEnabled())
 						{
 							SimpleState *ss = dynamic_cast<SimpleState*>(undoManager->getLastUndo());
-							if(ss && ss->get("ETEA") == "insert_frametext")
-									ss->set("TEXT_STR",ss->get("TEXT_STR") + QString(SpecialChars::SHYPHEN));
+							if (ss && ss->get("ETEA") == "insert_frametext")
+								ss->set("TEXT_STR",ss->get("TEXT_STR") + QString(SpecialChars::SHYPHEN));
 							else {
 								ss = new SimpleState(Um::InsertText,"",Um::ICreate);
 								ss->set("INSERT_FRAMETEXT", "insert_frametext");

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19932&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Mon Mar 16 22:34:14 2015
@@ -9522,7 +9522,7 @@
 						SimpleState *ss = NULL;
 						TransactionState *ts = dynamic_cast<TransactionState*>(state);
 						if (state && state->isTransaction())
-							ss = dynamic_cast<SimpleState*>(ts->at(0));
+							ss = dynamic_cast<SimpleState*>(ts->last());
 						if (ss && ss->get("ETEA") == ETEA)
 						{
 							for (uint i=0;i<ts->sizet();i++){




More information about the scribus-commit mailing list