r23940 by jghali - Rename StoryText::isSelected() to more syntactically correct hasSelection()

scribus-commit scribus-commit at lists.scribus.net
Mon Jul 20 09:32:14 UTC 2020


Author: jghali
Date: Mon Jul 20 09:32:14 2020
New Revision: 23940

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23940
Log:
Rename StoryText::isSelected() to more syntactically correct hasSelection()

Modified:
    trunk/Scribus/scribus/canvasmode_edit.cpp
    trunk/Scribus/scribus/hyphenator.cpp
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp
    trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusview.cpp
    trunk/Scribus/scribus/text/storytext.cpp
    trunk/Scribus/scribus/text/storytext.h
    trunk/Scribus/scribus/ui/search.cpp

Modified: trunk/Scribus/scribus/canvasmode_edit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23940&path=/trunk/Scribus/scribus/canvasmode_edit.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_edit.cpp	(original)
+++ trunk/Scribus/scribus/canvasmode_edit.cpp	Mon Jul 20 09:32:14 2020
@@ -379,7 +379,7 @@
 					currItem->itemText.selectWord(oldCp);
 				}
 			}
-			currItem->HasSel = currItem->itemText.isSelected();
+			currItem->HasSel = currItem->itemText.hasSelection();
 		}
 	}
 	else
@@ -640,7 +640,7 @@
 				//<<CB Add in shift select to text frames
 				if (m->modifiers() & Qt::ShiftModifier)
 				{
-					if (currItem->itemText.isSelected())
+					if (currItem->itemText.hasSelection())
 					{
 						if (currItem->itemText.cursorPosition() < (currItem->itemText.startOfSelection() + currItem->itemText.endOfSelection()) / 2)
 						{
@@ -942,7 +942,7 @@
 		m_doc->nodeEdit.finishTransaction(currItem);
 	}
 	if (GetItem(&currItem) && currItem->isTextFrame())
-		m_ScMW->setCopyCutEnabled(currItem->itemText.isSelected());
+		m_ScMW->setCopyCutEnabled(currItem->itemText.hasSelection());
 }
 
 //CB-->Doc/Fix

Modified: trunk/Scribus/scribus/hyphenator.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23940&path=/trunk/Scribus/scribus/hyphenator.cpp
==============================================================================
--- trunk/Scribus/scribus/hyphenator.cpp	(original)
+++ trunk/Scribus/scribus/hyphenator.cpp	Mon Jul 20 09:32:14 2020
@@ -140,7 +140,7 @@
 	QString text = "";
 
 	int startC = 0;
-	if (it->itemText.isSelected())
+	if (it->itemText.hasSelection())
 	{
 		startC = it->itemText.startOfSelection();
 		text = it->itemText.text(startC, it->itemText.selectionLength());
@@ -343,7 +343,7 @@
 	if (!(it->isTextFrame()) || (it ->itemText.length() == 0))
 		return;
 
-	if (it->itemText.isSelected())
+	if (it->itemText.hasSelection())
 		it->itemText.hyphenateWord(it->itemText.startOfSelection(), it->itemText.selectionLength(), nullptr);
 	else
 	{

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23940&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp	(original)
+++ trunk/Scribus/scribus/pageitem.cpp	Mon Jul 20 09:32:14 2020
@@ -1364,7 +1364,7 @@
 const ParagraphStyle& PageItem::currentStyle() const
 {
 	int cursorPosition = itemText.cursorPosition();
-	if (itemText.isSelected())
+	if (itemText.hasSelection())
 	{
 		int firstSelected = itemText.startOfSelection();
 		int lastSelected  = qMax(itemText.endOfSelection() - 1, 0);
@@ -1380,7 +1380,7 @@
 ParagraphStyle& PageItem::changeCurrentStyle()
 {
 	int cursorPosition = itemText.cursorPosition();
-	if (itemText.isSelected())
+	if (itemText.hasSelection())
 	{
 		int firstSelected = itemText.startOfSelection();
 		int lastSelected  = qMax(itemText.endOfSelection() - 1, 0);
@@ -1396,7 +1396,7 @@
 const CharStyle& PageItem::currentCharStyle() const
 {
 	int cursorPosition = itemText.cursorPosition();
-	if (itemText.isSelected())
+	if (itemText.hasSelection())
 	{
 		int firstSelected = itemText.startOfSelection();
 		int lastSelected  = qMax(itemText.endOfSelection() - 1, 0);
@@ -1415,7 +1415,7 @@
 	parStyle = curStyle;
 
 	int position = itemText.cursorPosition();
-	if (itemText.isSelected())
+	if (itemText.hasSelection())
 		position = qMin(qMax(itemText.endOfSelection() - 1, 0), qMax(position, itemText.startOfSelection()));
 
 	// Note: cursor position can be past last characters, don't use frameDisplays() here

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23940&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp	Mon Jul 20 09:32:14 2020
@@ -3789,7 +3789,7 @@
 	{
 		ParagraphStyle defaultStyle = this->itemText.defaultStyle();
 		int pos = itemText.cursorPosition();
-		if (!itemText.isSelected())
+		if (!itemText.hasSelection())
 		{
 			itemText.select(maxCharsInFrame(), itemText.length() - maxCharsInFrame(), true);
 			deleteSelectedTextFromFrame();
@@ -3924,7 +3924,7 @@
 				UndoTransaction trans;
 				if (UndoManager::undoEnabled())
 					trans = undoManager->beginTransaction(Um::Selection,Um::ITextFrame,Um::InsertText,"",Um::IDelete);
-				if (itemText.isSelected())
+				if (itemText.hasSelection())
 					deleteSelectedTextFromFrame();
 				if (conv < 31)
 					conv = 32;
@@ -4232,7 +4232,7 @@
 	case Qt::Key_Delete:
 		if (itemText.cursorPosition() == itemText.length())
 		{
-			if (itemText.isSelected())
+			if (itemText.hasSelection())
 			{
 				deleteSelectedTextFromFrame();
 				m_Doc->scMW()->setTBvals(this);
@@ -4256,7 +4256,7 @@
 			keyRepeat = false;
 			return;
 		}
-		if (!itemText.isSelected())
+		if (!itemText.hasSelection())
 		{
 			int pos1 = itemText.cursorPosition();
 			itemText.moveCursorForward();
@@ -4290,7 +4290,7 @@
 	case Qt::Key_Backspace:
 		if (itemText.cursorPosition() == 0)
 		{
-			if (itemText.isSelected())
+			if (itemText.hasSelection())
 			{
 				deleteSelectedTextFromFrame();
 				m_Doc->scMW()->setTBvals(this);
@@ -4309,7 +4309,7 @@
 		}
 		if (itemText.length() == 0)
 			break;
-		if (!itemText.isSelected())
+		if (!itemText.hasSelection())
 		{
 			itemText.setCursorPosition(-1, true);
 			itemText.select(itemText.cursorPosition(), 1, true);
@@ -4357,7 +4357,7 @@
 			break; //avoid inserting chars before first note mark
 		bool doUpdate = false;
 		UndoTransaction activeTransaction;
-		if (itemText.isSelected()) //(kk < 0x1000)
+		if (itemText.hasSelection()) //(kk < 0x1000)
 		{
 			bool x11Hack=false;
 			bool controlCharHack=false;
@@ -4523,7 +4523,7 @@
 {
 	if (itemText.length() <= 0)
 		return;
-	if (!itemText.isSelected())
+	if (!itemText.hasSelection())
 	{
 		itemText.select(itemText.cursorPosition(), 1);
 		HasSel = true;
@@ -4874,7 +4874,7 @@
 	{
 		itemText.extendSelection(oldPos, itemText.cursorPosition());
 	}
-	HasSel = itemText.isSelected();
+	HasSel = itemText.hasSelection();
 	m_Doc->scMW()->setCopyCutEnabled(HasSel);
 	cursorBiasBackward = (oldPos > itemText.cursorPosition());
 
@@ -4885,7 +4885,7 @@
 
 void PageItem_TextFrame::deselectAll()
 {
-	if (itemText.isSelected())
+	if (itemText.hasSelection())
 	{
 		itemText.deselectAll();
 		PageItem *item = this;
@@ -5541,7 +5541,7 @@
 	int stop = 0;
 	if (onlySelection)
 	{
-		if (itemText.isSelected())
+		if (itemText.hasSelection())
 		{
 			//only selection
 			start = itemText.startOfSelection();
@@ -5592,7 +5592,7 @@
 	int stop = itemText.length();
 	if (onlySelection)
 	{
-		if (itemText.isSelected())
+		if (itemText.hasSelection())
 		{
 			start = itemText.startOfSelection();
 			stop = start + itemText.selectionLength();

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23940&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp	(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp	Mon Jul 20 09:32:14 2020
@@ -325,7 +325,7 @@
 	
 	const StoryText& story = item->itemText;
 	QString text;
-	text.reserve(story.isSelected() ? story.selectionLength() : story.length());
+	text.reserve(story.hasSelection() ? story.selectionLength() : story.length());
 	for (int i = item->firstInFrame(); i <= item->lastInFrame(); ++i)
 	{
 		if (item->HasSel)
@@ -360,7 +360,7 @@
 	// collect all chars from a storytext
 	const StoryText& story = item->itemText;
 	QString text;
-	text.reserve(story.isSelected() ? story.selectionLength() : story.length());
+	text.reserve(story.hasSelection() ? story.selectionLength() : story.length());
 	for (int i = 0; i < story.length(); i++)
 	{
 		if (item->HasSel)

Modified: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23940&path=/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.cpp	(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.cpp	Mon Jul 20 09:32:14 2020
@@ -325,7 +325,7 @@
 	
 	const StoryText& story = item->itemText;
 	QString text;
-	text.reserve(story.isSelected() ? story.selectionLength() : story.length());
+	text.reserve(story.hasSelection() ? story.selectionLength() : story.length());
 	for (int i = item->firstInFrame(); i <= item->lastInFrame(); ++i)
 	{
 		if (item->HasSel)
@@ -360,7 +360,7 @@
 	// collect all chars from a storytext
 	const StoryText& story = item->itemText;
 	QString text;
-	text.reserve(story.isSelected() ? story.selectionLength() : story.length());
+	text.reserve(story.hasSelection() ? story.selectionLength() : story.length());
 	for (int i = 0; i < story.length(); i++)
 	{
 		if (item->HasSel)

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23940&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp	(original)
+++ trunk/Scribus/scribus/scribusdoc.cpp	Mon Jul 20 09:32:14 2020
@@ -9203,7 +9203,7 @@
 			int length = currItem->lastInFrame() - start + 1;
 			if ((appMode == modeEdit) || (appMode == modeEditTable))
 			{
-				if (currItem->itemText.isSelected())
+				if (currItem->itemText.hasSelection())
 				{
 					start = currItem->itemText.startOfSelection();
 					length = currItem->itemText.endOfSelection() - start;
@@ -9334,7 +9334,7 @@
 			int length = currItem->lastInFrame() - start + 1;
 			if ((appMode == modeEdit) || (appMode == modeEditTable))
 			{
-				if (currItem->itemText.isSelected())
+				if (currItem->itemText.hasSelection())
 				{
 					start = currItem->itemText.startOfSelection();
 					length = currItem->itemText.endOfSelection() - start;
@@ -9414,7 +9414,7 @@
 			int length = currItem->lastInFrame() - start + 1;
 			if ((appMode == modeEdit) || (appMode == modeEditTable))
 			{
-				if (currItem->itemText.isSelected())
+				if (currItem->itemText.hasSelection())
 				{
 					start = currItem->itemText.startOfSelection();
 					length = currItem->itemText.endOfSelection() - start;

Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23940&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp	(original)
+++ trunk/Scribus/scribus/scribusview.cpp	Mon Jul 20 09:32:14 2020
@@ -1725,7 +1725,7 @@
 		if (textFrame->itemText.length() > 0)
 		{
 			int pos = qMax(0, qMin(textFrame->itemText.cursorPosition(), textFrame->itemText.length()));
-			if (textFrame->itemText.isSelected())
+			if (textFrame->itemText.hasSelection())
 			{
 				int firstSelected = textFrame->itemText.startOfSelection();
 				int lastSelected  = qMax(textFrame->itemText.endOfSelection() - 1, 0);

Modified: trunk/Scribus/scribus/text/storytext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23940&path=/trunk/Scribus/scribus/text/storytext.cpp
==============================================================================
--- trunk/Scribus/scribus/text/storytext.cpp	(original)
+++ trunk/Scribus/scribus/text/storytext.cpp	Mon Jul 20 09:32:14 2020
@@ -1854,10 +1854,7 @@
 	return pos;
 }
 
-
-
 // selection
-
 int StoryText::startOfSelection() const
 {
 	return d->selFirst <= d->selLast? d->selFirst : 0;
@@ -1879,7 +1876,7 @@
 	return d->selFirst <= last? last - d->selFirst + 1 : 0;
 }
 
-bool StoryText::isSelected() const
+bool StoryText::hasSelection() const
 {
 	return selectionLength() > 0;
 }

Modified: trunk/Scribus/scribus/text/storytext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23940&path=/trunk/Scribus/scribus/text/storytext.h
==============================================================================
--- trunk/Scribus/scribus/text/storytext.h	(original)
+++ trunk/Scribus/scribus/text/storytext.h	Mon Jul 20 09:32:14 2020
@@ -257,7 +257,7 @@
 	int startOfSelection() const;
 	int endOfSelection() const;
 	int selectionLength() const;
-	bool isSelected() const;
+	bool hasSelection() const;
 	
 	// break iterators
 	static icu::BreakIterator* getGraphemeIterator();

Modified: trunk/Scribus/scribus/ui/search.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23940&path=/trunk/Scribus/scribus/ui/search.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/search.cpp	(original)
+++ trunk/Scribus/scribus/ui/search.cpp	Mon Jul 20 09:32:14 2020
@@ -759,7 +759,7 @@
 			m_doc->itemSelection_SetFont(RFontVal->currentText());
 		if (RSize->isChecked())
 			m_doc->itemSelection_SetFontSize(qRound(RSizeVal->value() * 10.0));
-		if (REffect->isChecked() && (m_item->itemText.isSelected()))
+		if (REffect->isChecked() && (m_item->itemText.hasSelection()))
 		{
 			int s = REffVal->getStyle() & ScStyle_UserStyles;
 			m_doc->currentStyle.charStyle().setFeatures(static_cast<StyleFlag>(s).featureList()); // ???
@@ -1077,7 +1077,7 @@
 	}
 	replaceEnabled |= RText->isChecked();
 	if (m_itemMode)
-		replaceEnabled &= (m_item->itemText.isSelected());
+		replaceEnabled &= (m_item->itemText.hasSelection());
 	else if (m_doc->scMW()->CurrStED != nullptr)
 		replaceEnabled &= m_doc->scMW()->CurrStED->Editor->textCursor().hasSelection();
 	else




More information about the scribus-commit mailing list