r19188 by craig - #12332: Apply Ale's patch for adding truncate to last text frame in chain, and add white space to overflow tooltip

scribus-commit scribus-commit at lists.scribus.net
Sat Jun 7 11:37:38 UTC 2014


Author: craig
Date: Sat Jun  7 11:37:38 2014
New Revision: 19188

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19188
Log:
#12332: Apply Ale's patch for adding truncate to last text frame in chain, and add white space to overflow tooltip

Modified:
    trunk/Scribus/scribus/actionmanager.cpp
    trunk/Scribus/scribus/canvasmode_normal.cpp
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem.h
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/pageitem_textframe.h
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusdoc.h
    trunk/Scribus/scribus/ui/contextmenu.cpp
    trunk/Scribus/scribus/undomanager.cpp
    trunk/Scribus/scribus/undomanager.h

Modified: trunk/Scribus/scribus/actionmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19188&path=/trunk/Scribus/scribus/actionmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/actionmanager.cpp (original)
+++ trunk/Scribus/scribus/actionmanager.cpp Sat Jun  7 11:37:38 2014
@@ -214,6 +214,8 @@
 	scrActions->insert(name, new ScrAction(loadIcon("16/edit-paste.png"), loadIcon("22/edit-paste.png"), "", defaultKey(name), mainWindow));
 	name="editClearContents";
 	scrActions->insert(name, new ScrAction(loadIcon("16/edit-delete.png"), loadIcon("22/edit-delete.png"), "", defaultKey(name), mainWindow));
+	name="editTruncateContents";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
 	name="editSelectAll";
 	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
 	name="editSelectAllOnLayer";
@@ -1304,6 +1306,7 @@
 	disconnect( (*scrActions)["itemPreviewNormal"], SIGNAL(triggeredData(int)) , 0, 0);
 	disconnect( (*scrActions)["itemPreviewFull"], SIGNAL(triggeredData(int)) , 0, 0);
 	disconnect( (*scrActions)["editClearContents"], 0, 0, 0);
+	disconnect( (*scrActions)["editTruncateContents"], 0, 0, 0);
 }
 
 void ActionManager::connectNewSelectionActions(ScribusView* /*currView*/, ScribusDoc* currDoc)
@@ -1313,6 +1316,7 @@
 	connect( (*scrActions)["itemPreviewNormal"], SIGNAL(triggeredData(int)), currDoc, SLOT(itemSelection_ChangePreviewResolution(int)) );
 	connect( (*scrActions)["itemPreviewFull"], SIGNAL(triggeredData(int)), currDoc, SLOT(itemSelection_ChangePreviewResolution(int)) );
 	connect( (*scrActions)["editClearContents"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_ClearItem()) );
+	connect( (*scrActions)["editTruncateContents"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_TruncateItem()) );
 }
 
 void ActionManager::saveActionShortcutsPreEditMode()
@@ -1477,6 +1481,7 @@
 	(*scrActions)["editPasteContentsAbs"]->setTexts( tr("Paste (&Absolute)"));
 	(*scrActions)["editPasteImageFromClipboard"]->setTexts( tr("Paste Image from Clipboard"));
 	(*scrActions)["editClearContents"]->setTexts( tr("C&lear"));
+	(*scrActions)["editTruncateContents"]->setTexts( tr("T&runcate"));
 	(*scrActions)["editSelectAll"]->setTexts( tr("Select &All"));
 	(*scrActions)["editSelectAllOnLayer"]->setTexts( tr("Advanced Select All..."));
 	(*scrActions)["editDeselectAll"]->setTexts( tr("&Deselect All"));
@@ -2032,6 +2037,7 @@
 		<< "editPasteContentsAbs"
 		<< "editPasteImageFromClipboard"
 		<< "editClearContents"
+		<< "editTruncateContents"
 		<< "editSelectAll"
 		<< "editSelectAllOnLayer"
 		<< "editDeselectAll"
@@ -2530,6 +2536,7 @@
 	(*scrActions)["editPaste"]->setEnabled(false);
 //	scrMenuMgr->setMenuEnabled("EditPasteRecent", false);
 	(*scrActions)["editClearContents"]->setEnabled(false);
+	(*scrActions)["editTruncateContents"]->setEnabled(false);
 	(*scrActions)["editSelectAll"]->setEnabled(false);
 	(*scrActions)["editSelectAllOnLayer"]->setEnabled(false);
 	(*scrActions)["editDeselectAll"]->setEnabled(false);

Modified: trunk/Scribus/scribus/canvasmode_normal.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19188&path=/trunk/Scribus/scribus/canvasmode_normal.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_normal.cpp Sat Jun  7 11:37:38 2014
@@ -434,7 +434,7 @@
 				{
 					if (m_canvas->cursorOverTextFrameControl(m->globalPos(), hoveredItem))
 					{
-						QToolTip::showText(m->globalPos() + QPoint(5, 5), tr("Overflow Characters: %1").arg(hoveredItem->frameOverflowCount()), m_canvas);
+						QToolTip::showText(m->globalPos() + QPoint(5, 5), tr("Overflow Characters: %1 (%2 White Spaces)").arg(hoveredItem->frameOverflowCount()).arg(hoveredItem->frameOverflowBlankCount()), m_canvas);
 					}
 				}
 				else

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19188&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Sat Jun  7 11:37:38 2014
@@ -1173,6 +1173,14 @@
 	return 0;
 }
 
+int PageItem::frameOverflowBlankCount() const
+{
+	if (frameOverflows())
+		return itemText.plainText().right(itemText.length() - MaxChars).count(QRegularExpression("\\s+"));
+
+	return 0;
+}
+
 int PageItem::maxCharsInFrame()
 {
 	return MaxChars;

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19188&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Sat Jun  7 11:37:38 2014
@@ -297,6 +297,7 @@
 	 * The view does when these are called.
 	 */
 	virtual void clearContents() {}
+	virtual void truncateContents() {}
 
 	//>> ********* Functions to work on the contents of the items *********
 
@@ -378,6 +379,7 @@
 	bool frameOverflows() const;
 	bool frameUnderflows() const;
 	int frameOverflowCount() const;
+	int frameOverflowBlankCount() const;
 	/// Draws the overflow marker.
 	void drawOverflowMarker(ScPainter *p);
 	/// returns index of first char displayed in this frame, used to be 0

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19188&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Sat Jun  7 11:37:38 2014
@@ -4054,6 +4054,25 @@
 	}
 }
 
+void PageItem_TextFrame::truncateContents()
+{
+	if ((this->nextInChain() == NULL) && frameOverflows())
+	{
+		ParagraphStyle defaultStyle = this->itemText.defaultStyle();
+		int pos = itemText.cursorPosition();
+		if (itemText.lengthOfSelection() == 0)
+		{
+			itemText.select(maxCharsInFrame(), itemText.length() - maxCharsInFrame(), true);
+			deleteSelectedTextFromFrame();
+		}
+		itemText.setCursorPosition(pos, true);
+
+		if(UndoManager::undoEnabled() && undoManager->getLastUndo())
+			undoManager->getLastUndo()->setName(Um::TruncateText);
+		this->itemText.setDefaultStyle(defaultStyle);
+	}
+}
+
 void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat)
 {
 	if (frameUnderflows())
@@ -5269,6 +5288,8 @@
 	if (textLayout.lines() != 0)
 	{
 		actionList << "editClearContents";
+		if ((this->nextInChain() == NULL) && frameOverflows())
+			actionList << "editTruncateContents";
 		actionList << "itemAdjustFrameHeightToText";
 	}
 }

Modified: trunk/Scribus/scribus/pageitem_textframe.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19188&path=/trunk/Scribus/scribus/pageitem_textframe.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.h (original)
+++ trunk/Scribus/scribus/pageitem_textframe.h Sat Jun  7 11:37:38 2014
@@ -55,6 +55,7 @@
 	virtual bool isTextFrame() const { return true; }
 	
 	virtual void clearContents();
+	virtual void truncateContents();
 	
 	/**
 	* \brief Handle keyboard interaction with the text frame while in edit mode

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19188&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Sat Jun  7 11:37:38 2014
@@ -799,6 +799,7 @@
 	scrMenuMgr->addMenuItemString("editPasteContents", "EditContents");
 	scrMenuMgr->addMenuItemString("editPasteContentsAbs", "EditContents");
 	scrMenuMgr->addMenuItemString("editClearContents", "EditContents");
+	scrMenuMgr->addMenuItemString("editTruncateContents", "EditTruncateContents");
 	scrMenuMgr->addMenuItemString("itemDelete", "Edit");
 	scrMenuMgr->addMenuItemString("SEPARATOR", "Edit");
 	scrMenuMgr->addMenuItemString("editSelectAll", "Edit");
@@ -2767,6 +2768,7 @@
 		scrActions["editCopy"]->setEnabled(true);
 		scrMenuMgr->setMenuEnabled("EditContents", true);
 		scrActions["editClearContents"]->setEnabled(true);
+		scrActions["editTruncateContents"]->setEnabled(true);
 		scrActions["editSearchReplace"]->setEnabled(false);
 		scrActions["extrasHyphenateText"]->setEnabled(false);
 		scrActions["extrasDeHyphenateText"]->setEnabled(false);
@@ -2821,6 +2823,7 @@
 		scrActions["editCopy"]->setEnabled(true);
 		scrMenuMgr->setMenuEnabled("EditContents", true);
 		scrActions["editClearContents"]->setEnabled(true);
+		scrActions["editTruncateContents"]->setEnabled(true);
 		scrActions["editSearchReplace"]->setEnabled(currItem->itemText.length() != 0);
 		scrActions["extrasHyphenateText"]->setEnabled(true);
 		scrActions["extrasDeHyphenateText"]->setEnabled(true);
@@ -2939,6 +2942,7 @@
 		scrActions["editCut"]->setEnabled(true);
 		scrActions["editCopy"]->setEnabled(true);
 		scrActions["editClearContents"]->setEnabled(false);
+		scrActions["editTruncateContents"]->setEnabled(false);
 		scrActions["editSearchReplace"]->setEnabled(false);
 		scrActions["extrasHyphenateText"]->setEnabled(false);
 		scrActions["extrasDeHyphenateText"]->setEnabled(false);
@@ -3005,6 +3009,7 @@
 		scrActions["editCopy"]->setEnabled(true);
 		scrMenuMgr->setMenuEnabled("EditContents", false);
 		scrActions["editClearContents"]->setEnabled(false);
+		scrActions["editTruncateContents"]->setEnabled(false);
 		scrActions["editSearchReplace"]->setEnabled(false);
 
 		scrActions["extrasHyphenateText"]->setEnabled(false);
@@ -3197,6 +3202,7 @@
 			scrActions["itemSendToInline"]->setEnabled(true);
 			scrActions["editCut"]->setEnabled(false);
 			scrActions["editClearContents"]->setEnabled(false);
+			scrActions["editTruncateContents"]->setEnabled(false);
 			scrActions["toolsRotate"]->setEnabled(false);
 		}
 		else
@@ -6495,6 +6501,7 @@
 			zoomSpinBox->setFocusPolicy(Qt::ClickFocus);
 			pageSelector->setFocusPolicy(Qt::ClickFocus);
 			scrActions["editClearContents"]->setEnabled(false);
+			scrActions["editTruncateContents"]->setEnabled(false);
 			charPalette->setEnabled(false, 0);
 //			view->slotDoCurs(false);
 			if (currItem != 0)
@@ -6588,6 +6595,7 @@
 				scrActions["editCut"]->setEnabled(currItem->HasSel);
 				scrActions["editCopy"]->setEnabled(currItem->HasSel);
 				scrActions["editClearContents"]->setEnabled(currItem->HasSel);
+				scrActions["editTruncateContents"]->setEnabled(currItem->HasSel);
 				scrActions["editSearchReplace"]->setEnabled(true);
 
 				// Why the hell do you want to update the item here? - pm

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19188&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Sat Jun  7 11:37:38 2014
@@ -11647,6 +11647,23 @@
 	changed();
 }
 
+void ScribusDoc::itemSelection_TruncateItem(Selection* customSelection)
+{
+	Selection* itemSelection = (customSelection != 0) ? customSelection : m_Selection;
+	assert(itemSelection != 0);
+
+	uint selectedItemCount = itemSelection->count();
+	if (selectedItemCount <= 0)
+		return;
+	for (uint i = 0; i < selectedItemCount; ++i)
+	{
+		PageItem *currItem = itemSelection->itemAt(i);
+		currItem->truncateContents();
+	}
+	regionsChanged()->update(QRectF());
+	changed();
+}
+
 QList<PageItem*>* ScribusDoc::GroupOfItem(QList<PageItem*>* itemList, PageItem* item)
 {
 	if (itemList->contains(item))

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19188&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Sat Jun  7 11:37:38 2014
@@ -1446,6 +1446,7 @@
 	void item_setFrameShape(PageItem* item, int frameType, int count, double* points); 
 
 	void itemSelection_ClearItem(Selection* customSelection=0);
+	void itemSelection_TruncateItem(Selection* customSelection=0);
 	//! Delete the items in the current selection. When force is true, we do not warn the user and make SE happy too. Force is used from @sa Page::restorePageItemCreation
 	void itemSelection_DeleteItem(Selection* customSelection=0, bool forceDeletion=false);
 	void itemSelection_SetItemTextReversed(bool reversed, Selection* customSelection=0);

Modified: trunk/Scribus/scribus/ui/contextmenu.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19188&path=/trunk/Scribus/scribus/ui/contextmenu.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/contextmenu.cpp (original)
+++ trunk/Scribus/scribus/ui/contextmenu.cpp Sat Jun  7 11:37:38 2014
@@ -192,6 +192,8 @@
 	}
 	if (m_actionList.contains("editClearContents"))
 		menuEditContents->addAction(m_ScMW->scrActions["editClearContents"]);
+	if (m_actionList.contains("editTruncateContents"))
+		menuEditContents->addAction(m_ScMW->scrActions["editTruncateContents"]);
 	if (menuEditContents->actions().count()>0)
 	{
 		QAction *act = addMenu(menuEditContents);

Modified: trunk/Scribus/scribus/undomanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19188&path=/trunk/Scribus/scribus/undomanager.cpp
==============================================================================
--- trunk/Scribus/scribus/undomanager.cpp (original)
+++ trunk/Scribus/scribus/undomanager.cpp Sat Jun  7 11:37:38 2014
@@ -1003,6 +1003,7 @@
 	UndoManager::AppendText         = tr("Append text");
 	UndoManager::ImportText         = tr("Import text");
 	UndoManager::ClearText          = tr("Clear text");
+	UndoManager::TruncateText       = tr("Truncate text");
 	UndoManager::AddLoremIpsum      = tr("Add Lorem Ipsum");
 	UndoManager::InsertMark         = tr("Insert mark");
 	UndoManager::InsertNote         = tr("Insert note");
@@ -1282,6 +1283,7 @@
 QString UndoManager::AppendText         = "";
 QString UndoManager::ImportText         = "";
 QString UndoManager::ClearText          = "";
+QString UndoManager::TruncateText       = "";
 QString UndoManager::ReplaceText        = "";
 QString UndoManager::InsertText         = "";
 QString UndoManager::AddLoremIpsum      = "";

Modified: trunk/Scribus/scribus/undomanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19188&path=/trunk/Scribus/scribus/undomanager.h
==============================================================================
--- trunk/Scribus/scribus/undomanager.h (original)
+++ trunk/Scribus/scribus/undomanager.h Sat Jun  7 11:37:38 2014
@@ -584,6 +584,7 @@
 	static QString AppendText;
 	static QString ImportText;
 	static QString ClearText;
+	static QString TruncateText;
 	static QString AddLoremIpsum;
 	static QString DeleteText;
 	static QString InsertText;




More information about the scribus-commit mailing list