Author: jghali
Date: Fri Feb  4 22:45:00 2022
New Revision: 24904

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24904
Log:
Qt6: avoid useless calls to mouseEvent->position()

Modified:
    trunk/Scribus/scribus/ui/colorchart.cpp
    trunk/Scribus/scribus/ui/dasheditor.cpp
    trunk/Scribus/scribus/ui/gradientpreview.cpp
    trunk/Scribus/scribus/ui/hruler.cpp

Modified: trunk/Scribus/scribus/ui/colorchart.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=24904&path=/trunk/Scribus/scribus/ui/colorchart.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/colorchart.cpp     (original)
+++ trunk/Scribus/scribus/ui/colorchart.cpp     Fri Feb  4 22:45:00 2022
@@ -50,29 +50,32 @@
 
 void ColorChart::mouseMoveEvent(QMouseEvent *m)
 {
-       drawMark(m->position().x(), m->position().y());
-       if (drawMode > 0)
-               emit ColorVal(m->position().x() * 256 / width() - 128, 256 - 
(m->position().y() * 256 / height()) - 128, true);
-       else
-               emit ColorVal(m->position().x() * 359 / width(), 
m->position().y() * 255 / height(), true);
+       QPointF eventPos = m->position();
+       drawMark(eventPos.x(), eventPos.y());
+       if (drawMode > 0)
+               emit ColorVal(eventPos.x() * 256 / width() - 128, 256 - 
(eventPos.y() * 256 / height()) - 128, true);
+       else
+               emit ColorVal(eventPos.x() * 359 / width(), eventPos.y() * 255 
/ height(), true);
 }
 
 void ColorChart::mousePressEvent(QMouseEvent *m)
 {
-       drawMark(m->position().x(), m->position().y());
-       if (drawMode > 0)
-               emit ColorVal(m->position().x() * 256 / width() - 128, 256 - 
(m->position().y() * 256 / height()) - 128, true);
-       else
-               emit ColorVal(m->position().x() * 359 / width(), 
m->position().y() * 255 / height(), true);
+       QPointF eventPos = m->position();
+       drawMark(eventPos.x(), eventPos.y());
+       if (drawMode > 0)
+               emit ColorVal(eventPos.x() * 256 / width() - 128, 256 - 
(eventPos.y() * 256 / height()) - 128, true);
+       else
+               emit ColorVal(eventPos.x() * 359 / width(), eventPos.y() * 255 
/ height(), true);
 }
 
 void ColorChart::mouseReleaseEvent(QMouseEvent *m)
 {
-       drawMark(m->position().x(), m->position().y());
-       if (drawMode > 0)
-               emit ColorVal(m->position().x() * 256 / width() - 128, 256 - 
(m->position().y() * 256 / height()) - 128, true);
-       else
-               emit ColorVal(m->position().x() * 359 / width(), 
m->position().y() * 255 / height(), true);
+       QPointF eventPos = m->position();
+       drawMark(eventPos.x(), eventPos.y());
+       if (drawMode > 0)
+               emit ColorVal(eventPos.x() * 256 / width() - 128, 256 - 
(eventPos.y() * 256 / height()) - 128, true);
+       else
+               emit ColorVal(eventPos.x() * 359 / width(), eventPos.y() * 255 
/ height(), true);
 }
 
 void ColorChart::paintEvent(QPaintEvent *e)

Modified: trunk/Scribus/scribus/ui/dasheditor.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=24904&path=/trunk/Scribus/scribus/ui/dasheditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/dasheditor.cpp     (original)
+++ trunk/Scribus/scribus/ui/dasheditor.cpp     Fri Feb  4 22:45:00 2022
@@ -139,7 +139,8 @@
 {
        m->accept();
        qApp->restoreOverrideCursor();
-       if ((m_mousePressed) && (m_stops.count() > 2) && (m_outside || 
m->position().y() > 30))
+       QPointF mousePos = m->position();
+       if ((m_mousePressed) && (m_stops.count() > 2) && (m_outside || 
mousePos.y() > 30))
        {
                m_stops.removeAt(m_currentStop);
                m_dashValues.clear();
@@ -158,7 +159,7 @@
                emit dashChanged();
                return;
        }
-       if ((m->position().y() < height()) && (m->position().y() > 16) && 
(m->position().x() > 9) && (m->position().x() < width() - 9))
+       if ((mousePos.y() < height()) && (mousePos.y() > 16) && (mousePos.x() > 
9) && (mousePos.x() < width() - 9))
        {
                if (m_currentStop != -1)
                {
@@ -167,12 +168,12 @@
                                m_mousePressed = false;
                                return;
                        }
-                       m_stops[m_currentStop] = m->position().x() - 10;
+                       m_stops[m_currentStop] = mousePos.x() - 10;
                }
                else
                {
                        if (m_dashValues.count() < 10)
-                               m_stops.append(m->position().x() - 10);
+                               m_stops.append(mousePos.x() - 10);
                        std::sort(m_stops.begin(), m_stops.end());
                        m_currentStop = 0;
                        for (int i = 0; i < m_stops.count(); ++i)
@@ -206,7 +207,8 @@
        m->accept();
 
        QRect fpo;
-       if ((!m_mousePressed) && (m->position().y() < height()) && 
(m->position().y() > 16) && (m->position().x() > 9) && (m->position().x() < 
width() - 9) && (m_dashValues.count() < 10))
+       QPointF mousePos = m->position();
+       if ((!m_mousePressed) && (mousePos.y() < height()) && (mousePos.y() > 
16) && (mousePos.x() > 9) && (mousePos.x() < width() - 9) && 
(m_dashValues.count() < 10))
        {
                setCursor(IconManager::instance().loadCursor("AddPoint.png", 1, 
1));
                for (int i = 0; i < m_stops.count(); ++i)
@@ -219,20 +221,20 @@
                        }
                }
        }
-       if ((m_mousePressed) && (m->position().y() < height()) && 
(m->position().y() > 16) && (m->position().x() > 9) && (m->position().x() < 
width() - 9) && (m_currentStop != -1))
+       if ((m_mousePressed) && (mousePos.y() < height()) && (mousePos.y() > 
16) && (mousePos.x() > 9) && (mousePos.x() < width() - 9) && (m_currentStop != 
-1))
        {
                qApp->changeOverrideCursor(QCursor(Qt::SizeHorCursor));
                if (m_currentStop > 1)
                {
-                       if (static_cast<int>(m_stops[m_currentStop - 1] + 10) + 
2 >= m->position().x())
+                       if (static_cast<int>(m_stops[m_currentStop - 1] + 10) + 
2 >= mousePos.x())
                                return;
                }
                if (m_currentStop < static_cast<int>(m_stops.count() - 2))
                {
-                       if (static_cast<int>(m_stops[m_currentStop + 1] + 10) - 
2 < m->position().x())
+                       if (static_cast<int>(m_stops[m_currentStop + 1] + 10) - 
2 < mousePos.x())
                                return;
                }
-               m_stops[m_currentStop] = m->position().x() - 10;
+               m_stops[m_currentStop] = mousePos.x() - 10;
                m_dashValues.clear();
                double startX = 0.0;
                for (int i = 0; i < m_stops.count(); ++i)
@@ -250,7 +252,7 @@
                }
                emit currStep(m_stops[m_currentStop] / 10.0 - startX);
        }
-       if ((m_mousePressed) && (m_outside || m->position().y() > 30) && 
(m_currentStop >= 0) && (m_stops.count() > 2))
+       if ((m_mousePressed) && (m_outside || mousePos.y() > 30) && 
(m_currentStop >= 0) && (m_stops.count() > 2))
                
qApp->changeOverrideCursor(IconManager::instance().loadCursor("DelPoint.png", 
1, 1));
 }
 

Modified: trunk/Scribus/scribus/ui/gradientpreview.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=24904&path=/trunk/Scribus/scribus/ui/gradientpreview.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/gradientpreview.cpp        (original)
+++ trunk/Scribus/scribus/ui/gradientpreview.cpp        Fri Feb  4 22:45:00 2022
@@ -168,6 +168,7 @@
        if (isEditable)
        {
                QRect fpo;
+               QPointF mousePos = m->position();
                if (m->button() == Qt::LeftButton)
                {
                        if ((Mpressed) && (ActStop > 0) && (ActStop != 
static_cast<int>(StopM.count()-1)) && (outside || 
!insideRect.contains(m->pos())))
@@ -179,10 +180,10 @@
                                QList<VColorStop*> cstops = 
fill_gradient.colorStops();
                                emit selectedStop(cstops.at(ActStop));
                        }
-                       if ((m->position().y() < height()) && 
(m->position().y() > 43) && (m->position().x() > 0) && (m->position().x() < 
width()) && (ActStop == -1))
+                       if ((mousePos.y() < height()) && (mousePos.y() > 43) && 
(mousePos.x() > 0) && (mousePos.x() < width()) && (ActStop == -1))
                        {
                                QList<VColorStop*> cstops = 
fill_gradient.colorStops();
-                               double  newStop = 
static_cast<double>((m->position().x() - 10)) / (static_cast<double>(width()) - 
20);
+                               double  newStop = 
static_cast<double>((mousePos.x() - 10)) / (static_cast<double>(width()) - 20);
                                QColor  stopColor = (cstops.count() > 0) ? 
cstops.at(0)->color : QColor(255, 255, 255);
                                QString stopName  = (cstops.count() > 0) ? 
cstops.at(0)->name  : QString("White");
                                int     stopShade = (cstops.count() > 0) ? 
cstops.at(0)->shade : 100;
@@ -243,8 +244,9 @@
        if (isEditable)
        {
                QRect fpo;
+               QPointF mousePos = m->position();
                qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
-               if ((!Mpressed) && (m->position().y() < height()) && 
(m->position().y() > 43) && (m->position().x() > 9) && (m->position().x() < 
width()-9))
+               if ((!Mpressed) && (mousePos.y() < height()) && (mousePos.y() > 
43) && (mousePos.x() > 9) && (mousePos.x() < width()-9))
                {
                        
setCursor(IconManager::instance().loadCursor("AddPoint.png", 1, 1));
                        for (int yg = 0; yg < static_cast<int>(StopM.count()); 
++yg)
@@ -259,21 +261,21 @@
                }
                if (m->buttons() & Qt::LeftButton)
                {
-                       if ((Mpressed) && (m->position().y() < height()) && 
(m->position().y() > 43) && (m->position().x() > 9) && (m->position().x() < 
width() - 9) && (ActStop != -1))
+                       if ((Mpressed) && (mousePos.y() < height()) && 
(mousePos.y() > 43) && (mousePos.x() > 9) && (mousePos.x() < width() - 9) && 
(ActStop != -1))
                        {
                                
qApp->changeOverrideCursor(QCursor(Qt::SizeHorCursor));
-                               double newStop = 
static_cast<double>((m->position().x() - 10)) / (static_cast<double>(width()) - 
20);
+                               double newStop = 
static_cast<double>((mousePos.x() - 10)) / (static_cast<double>(width()) - 20);
                                if (ActStop > 1)
                                {
-                                       if (StopM[ActStop-1]+2 >= 
m->position().x())
+                                       if (StopM[ActStop-1]+2 >= mousePos.x())
                                                return;
                                }
                                if (ActStop < static_cast<int>(StopM.count()-2))
                                {
-                                       if (StopM[ActStop+1]-2 < 
m->position().x())
+                                       if (StopM[ActStop+1]-2 < mousePos.x())
                                                return;
                                }
-                               StopM[ActStop] = m->position().x();
+                               StopM[ActStop] = mousePos.x();
                                QList<VColorStop*> cstops = 
fill_gradient.colorStops();
                                cstops.at(ActStop)->rampPoint = newStop;
                                std::sort(cstops.begin(), cstops.end());

Modified: trunk/Scribus/scribus/ui/hruler.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=24904&path=/trunk/Scribus/scribus/ui/hruler.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/hruler.cpp (original)
+++ trunk/Scribus/scribus/ui/hruler.cpp Fri Feb  4 22:45:00 2022
@@ -328,7 +328,8 @@
                        ColStart = textPosToLocal((colWidth + m_colGap) * 
(m_currCol- 1));
                        ColEnd   = textPosToLocal((colWidth + m_colGap) * 
(m_currCol- 1) + colWidth);
                }
-               if ((m_mousePressed) && (m->position().y() < height()) && 
(m->position().y() > 0) && (m->position().x() > ColStart - 
m_doc->guidesPrefs().grabRadius) && (m->position().x() < ColEnd + 
m_doc->guidesPrefs().grabRadius))
+               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));
                        double toplimit = textWidth() + m_distRight - (m_colGap 
* (m_cols - 1)) - 1;
@@ -336,7 +337,7 @@
                        switch (m_rulerCode)
                        {
                                case rc_leftFrameDist:
-                                       m_distLeft -= (m_mouseX - 
m->position().x()) / m_scaling;
+                                       m_distLeft -= (m_mouseX - mousePos.x()) 
/ m_scaling;
                                        if (m_distLeft < 0)
                                                m_distLeft = 0;
                                        if (m_distLeft > toplimit2)
@@ -345,7 +346,7 @@
                                        repaint();
                                        break;
                                case rc_rightFrameDist:
-                                       m_distRight += (m_mouseX - 
m->position().x()) / m_scaling;
+                                       m_distRight += (m_mouseX - 
mousePos.x()) / m_scaling;
                                        if (m_distRight < 0)
                                                m_distRight = 0;
                                        if (m_distRight > toplimit)
@@ -354,7 +355,7 @@
                                        repaint();
                                        break;
                                case rc_indentFirst:
-                                       m_firstIndent -= (m_mouseX - 
m->position().x()) / m_scaling;
+                                       m_firstIndent -= (m_mouseX - 
mousePos.x()) / m_scaling;
                                        if (m_firstIndent + m_leftMargin < 0)
                                                m_firstIndent = -m_leftMargin;
                                        if (m_firstIndent + m_leftMargin > 
colWidth)
@@ -364,7 +365,7 @@
                                        break;
                                case rc_leftMargin:
                                        oldInd = m_leftMargin + m_firstIndent;
-                                       m_leftMargin -= (m_mouseX - 
m->position().x()) / m_scaling;
+                                       m_leftMargin -= (m_mouseX - 
mousePos.x()) / m_scaling;
                                        if (m_leftMargin < 0)
                                                m_leftMargin = 0;
                                        if (m_leftMargin > colWidth - 1)
@@ -374,7 +375,7 @@
                                        repaint();
                                        break;
                                case rc_rightMargin:
-                                       m_rightMargin -= (m_mouseX - 
m->position().x()) / m_scaling;
+                                       m_rightMargin -= (m_mouseX - 
mousePos.x()) / m_scaling;
                                        if (m_rightMargin < 0)
                                                m_rightMargin = 0;
                                        if (m_rightMargin > colWidth - 1)
@@ -383,7 +384,7 @@
                                        repaint();
                                        break;
                                case rc_tab:
-                                       m_tabValues[m_currTab].tabPosition -= 
(m_mouseX - m->position().x()) / m_scaling;
+                                       m_tabValues[m_currTab].tabPosition -= 
(m_mouseX - mousePos.x()) / m_scaling;
                                        if (m_tabValues[m_currTab].tabPosition 
< 0)
                                                
m_tabValues[m_currTab].tabPosition = 0;
                                        if (m_tabValues[m_currTab].tabPosition 
> colWidth - 1)
@@ -395,7 +396,7 @@
                                default:
                                        break;
                        }
-                       m_mouseX = m->position().x();
+                       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))
@@ -422,12 +423,12 @@
                                        setCursor(QCursor(Qt::SizeHorCursor));
                                        break;
                        }
-                       draw(m->position().x());
-                       double marker = localToTextPos(m->position().x());
+                       draw(mousePos.x());
+                       double marker = localToTextPos(mousePos.x());
                        emit MarkerMoved(textBase(), marker);
                        return;
                }
-               if ((m_mousePressed) && (m_rulerCode == rc_tab) && 
((m->position().y() > height()) || (m->position().y() < 0)))
+               if ((m_mousePressed) && (m_rulerCode == rc_tab) && 
((mousePos.y() > height()) || (mousePos.y() < 0)))
                {
                        
setCursor(IconManager::instance().loadCursor("DelPoint.png", 1, 1));
                        return;


_______________________________________________
scribus-commit mailing list
[email protected]
http://lists.scribus.net/mailman/listinfo/scribus-commit

Reply via email to