r23134 by craig - Use item Selections isEmpty to clean up code

scribus-commit scribus-commit at lists.scribus.net
Fri Aug 16 15:59:33 UTC 2019


Author: craig
Date: Fri Aug 16 15:59:33 2019
New Revision: 23134

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23134
Log:
Use item Selections isEmpty to clean up code

Modified:
    trunk/Scribus/scribus/canvasgesture_resize.cpp
    trunk/Scribus/scribus/canvasmode.cpp
    trunk/Scribus/scribus/canvasmode_create.cpp
    trunk/Scribus/scribus/canvasmode_edit.cpp
    trunk/Scribus/scribus/canvasmode_nodeedit.cpp
    trunk/Scribus/scribus/canvasmode_normal.cpp
    trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusview.cpp
    trunk/Scribus/scribus/selection.h

Modified: trunk/Scribus/scribus/canvasgesture_resize.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23134&path=/trunk/Scribus/scribus/canvasgesture_resize.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_resize.cpp	(original)
+++ trunk/Scribus/scribus/canvasgesture_resize.cpp	Fri Aug 16 15:59:33 2019
@@ -52,7 +52,7 @@
 	if (framehandle > 0)
 		m_handle = framehandle;
 	
-	if (m_doc->m_Selection->count() == 0)
+	if (m_doc->m_Selection->isEmpty())
 	{
 		m_handle = Canvas::OUTSIDE;
 		return;
@@ -962,7 +962,7 @@
 {
 	FPoint point = m_canvas->globalToCanvas(m->globalPos());
 	m_mousePressPoint = m->globalPos();
-	if (m_doc->m_Selection->count() == 0)
+	if (m_doc->m_Selection->isEmpty())
 	{
 		m_handle = Canvas::OUTSIDE;
 	}

Modified: trunk/Scribus/scribus/canvasmode.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23134&path=/trunk/Scribus/scribus/canvasmode.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode.cpp	(original)
+++ trunk/Scribus/scribus/canvasmode.cpp	Fri Aug 16 15:59:33 2019
@@ -1097,7 +1097,7 @@
 		m_doc->SubMode = -1;
 		m_doc->ElemToLink = nullptr;
 		mainWindow->slotSelect();
-		if (m_doc->m_Selection->count() == 0)
+		if (m_doc->m_Selection->isEmpty())
 			mainWindow->HaveNewSel();
 		prefsManager.appPrefs.uiPrefs.stickyTools = false;
 		scrActions["stickyTools"]->setChecked(false);
@@ -1115,7 +1115,7 @@
 		{
 			ContextMenu* cmen=nullptr;
 			m_view->setCursor(QCursor(Qt::ArrowCursor));
-			if (m_doc->m_Selection->count() == 0)
+			if (m_doc->m_Selection->isEmpty())
 			{
 				//CB We should be able to get this calculated by the canvas.... it is already in m_canvas->globalToCanvas(m->globalPos());
 				FPoint fp = m_canvas->globalToCanvas(QCursor::pos());
@@ -1141,7 +1141,7 @@
 		 * - With Tab, change active document windowActivated
 		 */
 
-		if (m_doc->m_Selection->count() == 0)
+		if (m_doc->m_Selection->isEmpty())
 		{
 			int wheelVal = prefsManager.mouseWheelJump();
 			if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))

Modified: trunk/Scribus/scribus/canvasmode_create.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23134&path=/trunk/Scribus/scribus/canvasmode_create.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_create.cpp	(original)
+++ trunk/Scribus/scribus/canvasmode_create.cpp	Fri Aug 16 15:59:33 2019
@@ -775,7 +775,7 @@
 		break;
 	case modeDrawTable2:
 		// TODO: Figure out what these conditions actually do.
-		if ((m_doc->m_Selection->count() == 0) && (m_view->HaveSelRect) && (!m_view->MidButt))
+		if ((m_doc->m_Selection->isEmpty()) && (m_view->HaveSelRect) && (!m_view->MidButt))
 		{
 			m_view->HaveSelRect = false;
 			// Calculate table rectangle.

Modified: trunk/Scribus/scribus/canvasmode_edit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23134&path=/trunk/Scribus/scribus/canvasmode_edit.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_edit.cpp	(original)
+++ trunk/Scribus/scribus/canvasmode_edit.cpp	Fri Aug 16 15:59:33 2019
@@ -854,7 +854,7 @@
 		}
 	}
 	//CB Drag selection performed here
-	if ((m_doc->m_Selection->count() == 0) && (m_view->HaveSelRect) && (!m_view->MidButt))
+	if ((m_doc->m_Selection->isEmpty()) && (m_view->HaveSelRect) && (!m_view->MidButt))
 	{
 		QRectF Sele = QRectF(Dxp, Dyp, SeRx-Dxp, SeRy-Dyp).normalized();
 		if (!m_doc->masterPageMode())

Modified: trunk/Scribus/scribus/canvasmode_nodeedit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23134&path=/trunk/Scribus/scribus/canvasmode_nodeedit.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_nodeedit.cpp	(original)
+++ trunk/Scribus/scribus/canvasmode_nodeedit.cpp	Fri Aug 16 15:59:33 2019
@@ -53,7 +53,7 @@
 void CanvasMode_NodeEdit::drawControls(QPainter* p) 
 {
 	double x, y;
-	if (m_doc->m_Selection->count() == 0)
+	if (m_doc->m_Selection->isEmpty())
 		return;
 	if (m_doc->nodeEdit.previewMode())
 		return;

Modified: trunk/Scribus/scribus/canvasmode_normal.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23134&path=/trunk/Scribus/scribus/canvasmode_normal.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.cpp	(original)
+++ trunk/Scribus/scribus/canvasmode_normal.cpp	Fri Aug 16 15:59:33 2019
@@ -900,7 +900,7 @@
 			m_view->updatesOn(true);
 			m_doc->m_Selection->delaySignalsOff();
 		}
-		if (((m_doc->m_Selection->count() == 0) || (!shiftSel)) && (m->modifiers() == Qt::ShiftModifier))
+		if (((m_doc->m_Selection->isEmpty()) || (!shiftSel)) && (m->modifiers() == Qt::ShiftModifier))
 		{
 			m_shiftSelItems = true;
 			m_mouseCurrentPoint = m_mousePressPoint = m_mouseSavedPoint = mousePointDoc;
@@ -913,7 +913,7 @@
 	else // !GetItem()
 	{
 		SeleItem(m);
-		if (m_doc->m_Selection->count() == 0)
+		if (m_doc->m_Selection->isEmpty())
 		{
 			m_mouseCurrentPoint = m_mousePressPoint = m_mouseSavedPoint = mousePointDoc;
 			m_view->redrawMarker->setGeometry(m->globalPos().x(), m->globalPos().y(), 1, 1);
@@ -1125,7 +1125,7 @@
 
 
 	//CB Drag selection performed here
-	if (((m_doc->m_Selection->count() == 0) && (m_view->HaveSelRect) && (!m_view->MidButt)) || ((m_shiftSelItems) && (m_view->HaveSelRect) && (!m_view->MidButt)))
+	if (((m_doc->m_Selection->isEmpty()) && (m_view->HaveSelRect) && (!m_view->MidButt)) || ((m_shiftSelItems) && (m_view->HaveSelRect) && (!m_view->MidButt)))
 	{
 		// get newly selection rectangle
 		double dx = m_mouseSavedPoint.x() - m_mousePressPoint.x();

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23134&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp	(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp	Fri Aug 16 15:59:33 2019
@@ -665,7 +665,7 @@
 		return nullptr;
 	}
 	// for current item only
-	if (currentDoc->m_Selection->count() == 0 || (strlen(name) > 0))
+	if (currentDoc->m_Selection->isEmpty() || (strlen(name) > 0))
 	{
 		// Store text selection as clearing object selection
 		// will also clear text selection
@@ -748,7 +748,7 @@
 		return nullptr;
 	}
 	// for current item only
-	if (currentDoc->m_Selection->count() == 0 || (strlen(name) > 0))
+	if (currentDoc->m_Selection->isEmpty() || (strlen(name) > 0))
 	{
 		// Store text selection as clearing object selection
 		// will also clear text selection

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23134&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp	(original)
+++ trunk/Scribus/scribus/scribusdoc.cpp	Fri Aug 16 15:59:33 2019
@@ -11042,7 +11042,8 @@
 	Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
 	assert(itemSelection != nullptr);
 
-	if (itemSelection->count() == 0) return;
+	if (itemSelection->isEmpty())
+		return;
 	
 	if (itemSelection->count() > 1)
 		rotateGroup(angle, itemSelection);
@@ -11449,7 +11450,7 @@
 
 	if (itemSelection->isGUISelection() && !itemSelection->signalsDelayed())
 	{
-		if (itemSelection->count() == 0)
+		if (itemSelection->isEmpty())
 			emit firstSelectedItemType(-1);
 		else
 			itemSelection->itemAt(0)->emitAllToGUI();
@@ -15003,7 +15004,7 @@
 void ScribusDoc::itemSelection_UnGroupObjects(Selection* customSelection)
 {
 	Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
-	if (itemSelection->count() == 0)
+	if (itemSelection->isEmpty())
 		return;
 
 	uint docSelectionCount = itemSelection->count();
@@ -15330,7 +15331,7 @@
 void ScribusDoc::itemSelection_resizeGroupToContents(Selection* customSelection)
 {
 	Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
-	if (itemSelection->count() == 0)
+	if (itemSelection->isEmpty())
 		return;
 	int docSelectionCount = itemSelection->count();
 	for (int a = 0; a < docSelectionCount; ++a)

Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23134&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp	(original)
+++ trunk/Scribus/scribus/scribusview.cpp	Fri Aug 16 15:59:33 2019
@@ -2846,7 +2846,7 @@
 
 void ScribusView::editExtendedImageProperties()
 {
-	if (Doc->m_Selection->count() == 0)
+	if (Doc->m_Selection->isEmpty())
 		return;
 	PageItem *currItem = Doc->m_Selection->itemAt(0);
 	if (!currItem->pixm.imgInfo.valid)

Modified: trunk/Scribus/scribus/selection.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23134&path=/trunk/Scribus/scribus/selection.h
==============================================================================
--- trunk/Scribus/scribus/selection.h	(original)
+++ trunk/Scribus/scribus/selection.h	Fri Aug 16 15:59:33 2019
@@ -125,7 +125,7 @@
 		/**
 		 * \brief Check if the selection is empty.
 		 */
-		bool isEmpty() const { return m_SelList.count()==0; }
+		bool isEmpty() const { return m_SelList.count() == 0; }
 		/**
 		 * \brief Clear a list
 		 */




More information about the scribus-commit mailing list