r25021 by jghali - More deprecated calls replacement

scribus-commit scribus-commit at lists.scribus.net
Sat Mar 12 17:16:05 UTC 2022


Author: jghali
Date: Sat Mar 12 17:16:05 2022
New Revision: 25021

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=25021
Log:
More deprecated calls replacement

Modified:
    trunk/Scribus/scribus/canvasmode_nodeedit.cpp
    trunk/Scribus/scribus/canvasmode_nodeedit.h
    trunk/Scribus/scribus/canvasmode_normal.cpp
    trunk/Scribus/scribus/ui/hruler.cpp
    trunk/Scribus/scribus/ui/pagepalette_widgets.cpp

Modified: trunk/Scribus/scribus/canvasmode_nodeedit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25021&path=/trunk/Scribus/scribus/canvasmode_nodeedit.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_nodeedit.cpp	(original)
+++ trunk/Scribus/scribus/canvasmode_nodeedit.cpp	Sat Mar 12 17:16:05 2022
@@ -941,16 +941,16 @@
 	}
 	if ((m_doc->nodeEdit.selectionCount() != 0) || ((m_doc->nodeEdit.segP1() != -1) && (m_doc->nodeEdit.segP2() != -1)) || (m_doc->nodeEdit.hasNodeSelected() && (!m_doc->nodeEdit.edPoints())))
 	{
-		m_Mxp = m->x();
-		m_Myp = m->y();
+		m_Mxp = m->position().x();
+		m_Myp = m->position().y();
 		m_canvas->setRenderModeFillBuffer();
 	}
 	else
 	{
-		m_Mxp = m->x();
-		m_Myp = m->y();
-		m_Dxp = qRound(m->x() / m_canvas->scale());  // + m_doc->minCanvasCoordinate.x());
-		m_Dyp = qRound(m->y() / m_canvas->scale());  // + m_doc->minCanvasCoordinate.y());
+		m_Mxp = m->position().x();
+		m_Myp = m->position().y();
+		m_Dxp = qRound(m->position().x() / m_canvas->scale());  // + m_doc->minCanvasCoordinate.x());
+		m_Dyp = qRound(m->position().y() / m_canvas->scale());  // + m_doc->minCanvasCoordinate.y());
 		if (!m_rectangleSelect)
 			m_rectangleSelect = new RectSelect(this);
 		m_rectangleSelect->prepare(m->globalPosition());
@@ -1059,8 +1059,8 @@
 		m_view->startGesture(m_rectangleSelect);
 		return;
 	}
-	int newX = m->position().x();
-	int newY = m->position().y();
+	double newX = m->position().x();
+	double newY = m->position().y();
 	FPoint np(newX - m_Mxp, newY - m_Myp, 0, 0, currItem->rotation(), 1, 1, true);
 	np = np * (1.0 / m_canvas->scale());
 	m_canvas->m_viewMode.operItemMoving = true;

Modified: trunk/Scribus/scribus/canvasmode_nodeedit.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25021&path=/trunk/Scribus/scribus/canvasmode_nodeedit.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_nodeedit.h	(original)
+++ trunk/Scribus/scribus/canvasmode_nodeedit.h	Sat Mar 12 17:16:05 2022
@@ -60,17 +60,17 @@
 		void handleNodeEditDrag(QMouseEvent*, PageItem*);
 		bool handleNodeEditMove(QMouseEvent*, QRect r, PageItem*, const QTransform&);
 
-		ScribusMainWindow* m_ScMW;
+		ScribusMainWindow* m_ScMW { nullptr };
+		RectSelect* m_rectangleSelect { nullptr };
 
-		RectSelect* m_rectangleSelect {nullptr};
-		int m_Mxp {-1}; // last mouse position
-		int m_Myp {-1};
-		int m_Dxp {-1}; // last mouse press position for rectangle select
-		int m_Dyp {-1};
-		int m_GxM {-1}; // guide position
-		int m_GyM {-1};
-		bool m_MoveGX {false};
-		bool m_MoveGY {false};
+		double m_Mxp { -1.0 }; // last mouse position
+		double m_Myp { -1.0 };
+		double m_Dxp { -1.0 }; // last mouse press position for rectangle select
+		double m_Dyp { -1.0 };
+		double m_GxM { -1.0 }; // guide position
+		double m_GyM { -1.0 };
+		bool m_MoveGX { false };
+		bool m_MoveGY { false };
 };
 
 

Modified: trunk/Scribus/scribus/canvasmode_normal.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25021&path=/trunk/Scribus/scribus/canvasmode_normal.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.cpp	(original)
+++ trunk/Scribus/scribus/canvasmode_normal.cpp	Sat Mar 12 17:16:05 2022
@@ -460,8 +460,8 @@
 	m_mouseCurrentPoint = mousePointDoc;
 	if ((GetItem(&currItem)) && (!m_shiftSelItems))
 	{
-		double newX = qRound(mousePointDoc.x()); //m_view->translateToDoc(m->x(), m->y()).x());
-		double newY = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y());
+		double newX = qRound(mousePointDoc.x());
+		double newY = qRound(mousePointDoc.y());
 		// #0007865
 		if (/*(((m_view->dragTimerElapsed()) && (m->buttons() & Qt::LeftButton)) ||*/
 			(m_view->moveTimerElapsed())
@@ -513,8 +513,8 @@
 			if (!m_canvas->m_viewMode.operItemResizing)
 			{
 				//Dragging an item (plus more?)
-				newX = mousePointDoc.x(); //static_cast<int>(m->x()/sc);
-				newY = mousePointDoc.y(); //static_cast<int>(m->y()/sc);
+				newX = mousePointDoc.x();
+				newY = mousePointDoc.y();
 				m_canvas->m_viewMode.operItemMoving = true;
 				if (!(m_doc->drawAsPreview && !m_doc->editOnPreview))
 					m_view->setCursor(Qt::ClosedHandCursor);
@@ -758,7 +758,8 @@
 					break;
 				QTransform p;
 				m_canvas->Transform(currItem, p);
-				QRect mpo = QRect(m->x() - m_doc->guidesPrefs().grabRadius, m->y() - m_doc->guidesPrefs().grabRadius, m_doc->guidesPrefs().grabRadius * 2, m_doc->guidesPrefs().grabRadius * 2);
+				QPoint mouseMoint = m->position().toPoint();
+				QRect mpo = QRect(mouseMoint.x() - m_doc->guidesPrefs().grabRadius, mouseMoint.y() - m_doc->guidesPrefs().grabRadius, m_doc->guidesPrefs().grabRadius * 2, m_doc->guidesPrefs().grabRadius * 2);
 				if (QRegion(p.map(QPolygon(QRect(-3, -3, static_cast<int>(currItem->width() + 6), static_cast<int>(currItem->height() + 6))))).contains(mpo))
 				{
 					QRect tx = p.mapRect(QRect(0, 0, static_cast<int>(currItem->width()), static_cast<int>(currItem->height())));
@@ -1562,10 +1563,8 @@
 	m_canvas->m_viewMode.m_MouseButtonPressed = true;
 	FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPosition());
 	m_mouseCurrentPoint  = mousePointDoc;
-//	double grabRadius = m_doc->guidesPrefs().grabRadius / m_canvas->scale();
-	int MxpS = static_cast<int>(mousePointDoc.x()); //m->x()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.x());
-	int MypS = static_cast<int>(mousePointDoc.y()); //m->y()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.y());
-//	QRectF mpo(m_mouseCurrentPoint.x()-grabRadius, m_mouseCurrentPoint.y()-grabRadius, grabRadius*2, grabRadius*2);
+	int MxpS = static_cast<int>(mousePointDoc.x());
+	int MypS = static_cast<int>(mousePointDoc.y());
 	m_doc->nodeEdit.deselect();
 
 	 // Guides are on foreground and want to be processed first

Modified: trunk/Scribus/scribus/ui/hruler.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25021&path=/trunk/Scribus/scribus/ui/hruler.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/hruler.cpp	(original)
+++ trunk/Scribus/scribus/ui/hruler.cpp	Sat Mar 12 17:16:05 2022
@@ -192,7 +192,7 @@
 			m_currTab = 0;
 			m_rulerCode = rc_tab;
 			updateTabList();
-			qApp->setOverrideCursor(QCursor(Qt::SizeHorCursor));
+			QApplication::setOverrideCursor(QCursor(Qt::SizeHorCursor));
 			emit DocChanged(false);
 		}
 	}
@@ -200,7 +200,7 @@
 	{
 		if (m_doc->guidesPrefs().guidesShown)
 		{
-			qApp->setOverrideCursor(QCursor(Qt::SplitVCursor));
+			QApplication::setOverrideCursor(QCursor(Qt::SplitVCursor));
 			m_view->startGesture(rulerGesture);
 			m_view->registerMousePress(m->globalPosition());
 		}
@@ -293,19 +293,19 @@
 	else if (m_mousePressed && rulerGesture->isActive())
 		rulerGesture->mouseReleaseEvent(m);
 	m_mousePressed = false;
-	qApp->restoreOverrideCursor();
+	QApplication::restoreOverrideCursor();
 }
 
 void Hruler::enterEvent(QEnterEvent* e)
 {
 	if (m_textEditMode)
-		qApp->changeOverrideCursor(IconManager::instance().loadCursor("tab.png", 3));
+		QApplication::changeOverrideCursor(IconManager::instance().loadCursor("tab.png", 3));
 }
 
 void Hruler::leaveEvent(QEvent *m)
 {
 	emit MarkerMoved(0, -1);
-	qApp->restoreOverrideCursor();
+	QApplication::restoreOverrideCursor();
 	m_view->m_canvasMode->setModeCursor();
 }
 
@@ -331,7 +331,7 @@
 		QPointF mousePos = m->position();
 		if ((m_mousePressed) && (mousePos.y() < height()) && (mousePos.y() > 0) && (mousePos.x() > colStart - m_doc->guidesPrefs().grabRadius) && (mousePos.x() < colEnd + m_doc->guidesPrefs().grabRadius))
 		{
-			qApp->changeOverrideCursor(QCursor(Qt::SizeHorCursor));
+			QApplication::changeOverrideCursor(QCursor(Qt::SizeHorCursor));
 			double toplimit = textWidth() + m_distRight - (m_colGap * (m_cols - 1)) - 1;
 			double toplimit2 = textWidth() + m_distLeft - (m_colGap * (m_cols - 1)) - 1;
 			switch (m_rulerCode)
@@ -399,7 +399,7 @@
 			m_mouseX = mousePos.x();
 			return;
 		}
-		if ((!m_mousePressed) && (m->y() < height()) && (m->y() > 0) && (m->x() > colStart - 2*m_doc->guidesPrefs().grabRadius) && (m->x() < colEnd + 2*m_doc->guidesPrefs().grabRadius))
+		if ((!m_mousePressed) && (m->y() < height()) && (m->y() > 0) && (mousePos.x() > colStart - 2 * m_doc->guidesPrefs().grabRadius) && (mousePos.x() < colEnd + 2 * m_doc->guidesPrefs().grabRadius))
 		{
 			setCursor(IconManager::instance().loadCursor("tab.png", 3));
 			switch (findRulerHandle(m->pos(), m_doc->guidesPrefs().grabRadius))

Modified: trunk/Scribus/scribus/ui/pagepalette_widgets.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25021&path=/trunk/Scribus/scribus/ui/pagepalette_widgets.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette_widgets.cpp	(original)
+++ trunk/Scribus/scribus/ui/pagepalette_widgets.cpp	Sat Mar 12 17:16:05 2022
@@ -75,11 +75,11 @@
 {
 	e->accept();
 	m_currItem = nullptr;
-	QListWidgetItem *i = itemAt(e->pos());
+	QListWidgetItem *i = itemAt(e->position().toPoint());
 	if (i)
 	{
 		m_currItem = i;
-		m_mousePos = e->pos();
+		m_mousePos = e->position().toPoint();
 		m_mousePressed = true;
 	}
 	QListWidget::mousePressEvent(e);
@@ -138,7 +138,7 @@
 void SeView::mousePressEvent(QMouseEvent* e)
 {
 	e->accept();
-	m_mousePos = e->pos();
+	m_mousePos = e->position().toPoint();
 	m_mousePressed = true;
 	QTableWidget::mousePressEvent(e);
 }
@@ -148,17 +148,19 @@
 	e->accept();
 	m_mousePressed = false;
 
-	emit Click(rowAt(e->pos().y()), columnAt(e->pos().x()), e->button());
+	QPoint mouseEventPos = e->position().toPoint();
+	emit Click(rowAt(mouseEventPos.y()), columnAt(mouseEventPos.x()), e->button());
 	QTableWidget::mouseReleaseEvent(e);
 }
 
 void SeView::mouseMoveEvent(QMouseEvent* e)
 {
-	if ((m_mousePressed) && ((m_mousePos - e->pos()).manhattanLength() > 4))
+	QPoint mouseEventPos = e->position().toPoint();
+	if ((m_mousePressed) && ((m_mousePos - mouseEventPos).manhattanLength() > 4))
 	{
 		m_mousePressed = false;
-		int a = rowAt(e->pos().y());
-		int b = columnAt(e->pos().x());
+		int a = rowAt(mouseEventPos.y());
+		int b = columnAt(mouseEventPos.x());
 		if ((a != -1) && (b != -1))
 		{
 			QTableWidgetItem* ite = item(a, b);
@@ -191,58 +193,41 @@
 
 void SeView::dropEvent(QDropEvent * e)
 {
-	QString str, tmp;
+	
 	bool lastPage = false;
-	if (e->mimeData()->hasFormat("page/magic"))
-	{
-		e->setDropAction(Qt::MoveAction);
-		e->accept();
-		// HACK to prevent strange Qt4 cursor behaviour after dropping. It's examined by Trolltech now - PV.
-		// It's the one and only reason why to include QApplication here.
-		// But sadly this destroys our normal Cursors
-		// Fixed at least in Qt-4.4.2
-//		QApplication::restoreOverrideCursor();
-		str = e->mimeData()->text();
-		clearPix();
-		if (str.startsWith("1"))
-		{
-			int a = rowAt(e->pos().y());
-			int b = columnAt(e->pos().x());
-			int p;
-			tmp = str.remove(0,1);
-			if ((a == -1) || (b == -1))
-				return;
-			if (a == rowCount() - 1)
-			{
-				emit NewPage(m_pageCount, tmp);
-				return;
-			}
-			p = getPage(a, b, &lastPage);
-			if (columnCount() == 1)
-			{
-				if ((a % 2) == 0)
-					emit NewPage(p, tmp);
-				else
-				{
-					emit UseTemp(tmp, p);
-					QTableWidgetItem* ite = item(a, b);
-					if (ite == nullptr)
-						return;
-					if (ite->type() == 1002)
-					{
-						SeItem* it = (SeItem*)ite;
-						it->pageName = tmp;
-					}
-				}
-				return;
-			}
-			if ((b % 2) == 0)
-			{
-				if (lastPage)
-					emit NewPage(p + 1, tmp);
-				else
-					emit NewPage(p, tmp);
-			}
+	if (!e->mimeData()->hasFormat("page/magic"))
+		return;
+
+	QPoint dropEventPos = e->position().toPoint();
+	e->setDropAction(Qt::MoveAction);
+	e->accept();
+	// HACK to prevent strange Qt4 cursor behaviour after dropping. It's examined by Trolltech now - PV.
+	// It's the one and only reason why to include QApplication here.
+	// But sadly this destroys our normal Cursors
+	// Fixed at least in Qt-4.4.2
+//	QApplication::restoreOverrideCursor();
+	clearPix();
+
+	QString tmp;
+	QString str = e->mimeData()->text();
+	if (str.startsWith("1"))
+	{
+		int a = rowAt(dropEventPos.y());
+		int b = columnAt(dropEventPos.x());
+		int p;
+		tmp = str.remove(0,1);
+		if ((a == -1) || (b == -1))
+			return;
+		if (a == rowCount() - 1)
+		{
+			emit NewPage(m_pageCount, tmp);
+			return;
+		}
+		p = getPage(a, b, &lastPage);
+		if (columnCount() == 1)
+		{
+			if ((a % 2) == 0)
+				emit NewPage(p, tmp);
 			else
 			{
 				emit UseTemp(tmp, p);
@@ -257,52 +242,72 @@
 			}
 			return;
 		}
-		if (str.startsWith("2"))
-		{
-			int st = str.indexOf(" ");
-			int en = str.indexOf(" ", st + 1);
-			tmp = str.mid(en + 1);
-			int dr = QStringView(str).sliced(st, en - st).toInt();
-			int a = rowAt(e->pos().y());
-			int b = columnAt(e->pos().x());
-			if ((a == -1) || (b == -1))
+		if ((b % 2) == 0)
+		{
+			if (lastPage)
+				emit NewPage(p + 1, tmp);
+			else
+				emit NewPage(p, tmp);
+		}
+		else
+		{
+			emit UseTemp(tmp, p);
+			QTableWidgetItem* ite = item(a, b);
+			if (ite == nullptr)
 				return;
-			QTableWidgetItem* ite = item(a, b);
-			int p = getPage(a, b, &lastPage);
-			if (a == rowCount() - 1)
-			{
-				emit movePage(dr, p+1);
-				return;
-			}
-			if (columnCount() == 1)
-			{
-				if ((a % 2) == 0)
-					emit movePage(dr, p);
-				else
-				{
-					emit UseTemp(tmp, p);
-					if (ite == nullptr)
-						return;
-					SeItem* it = (SeItem*)ite;
-					it->pageName = tmp;
-				}
-				return;
-			}
-			if ((b % 2) == 0)
-				emit movePage(dr, lastPage ? p+1 : p);
+			if (ite->type() == 1002)
+			{
+				SeItem* it = (SeItem*)ite;
+				it->pageName = tmp;
+			}
+		}
+		return;
+	}
+	if (str.startsWith("2"))
+	{
+		int st = str.indexOf(" ");
+		int en = str.indexOf(" ", st + 1);
+		tmp = str.mid(en + 1);
+		int dr = QStringView(str).sliced(st, en - st).toInt();
+		int a = rowAt(dropEventPos.y());
+		int b = columnAt(dropEventPos.x());
+		if ((a == -1) || (b == -1))
+			return;
+		QTableWidgetItem* ite = item(a, b);
+		int p = getPage(a, b, &lastPage);
+		if (a == rowCount() - 1)
+		{
+			emit movePage(dr, p+1);
+			return;
+		}
+		if (columnCount() == 1)
+		{
+			if ((a % 2) == 0)
+				emit movePage(dr, p);
 			else
 			{
 				emit UseTemp(tmp, p);
 				if (ite == nullptr)
 					return;
-				if (ite->type() == 1002)
-				{
-					SeItem* it = (SeItem*)ite;
-					it->pageName = tmp;
-				}
-			}
-			return;
-		}
+				SeItem* it = (SeItem*)ite;
+				it->pageName = tmp;
+			}
+			return;
+		}
+		if ((b % 2) == 0)
+			emit movePage(dr, lastPage ? p+1 : p);
+		else
+		{
+			emit UseTemp(tmp, p);
+			if (ite == nullptr)
+				return;
+			if (ite->type() == 1002)
+			{
+				SeItem* it = (SeItem*)ite;
+				it->pageName = tmp;
+			}
+		}
+		return;
 	}
 }
 
@@ -321,12 +326,16 @@
 {
 	if (!e->mimeData()->hasFormat("page/magic"))
 		return;
+
 	e->acceptProposedAction();
-	int row = rowAt(e->pos().y());
-	int col = columnAt(e->pos().x());
 	clearPix();
+
+	QPoint dragEventPos = e->position().toPoint();
+	int row = rowAt(dragEventPos.y());
+	int col = columnAt(dragEventPos.x());
 	if ((row == -1) || (col == -1))
 		return;
+
 	if (columnCount() == 1)
 	{
 		if ((row % 2) == 0)




More information about the scribus-commit mailing list