r25030 by jghali - Code cleanup
scribus-commit
scribus-commit at lists.scribus.net
Sun Mar 13 01:30:02 UTC 2022
Author: jghali
Date: Sun Mar 13 01:30:02 2022
New Revision: 25030
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=25030
Log:
Code cleanup
Modified:
trunk/Scribus/scribus/canvas.cpp
trunk/Scribus/scribus/canvas.h
trunk/Scribus/scribus/canvasgesture_resize.cpp
trunk/Scribus/scribus/guidemanagercore.cpp
trunk/Scribus/scribus/guidemanagercore.h
trunk/Scribus/scribus/third_party/zip/scribus_zip.cpp
trunk/Scribus/scribus/third_party/zip/scribus_zip.h
trunk/Scribus/scribus/ui/charselectenhanced.cpp
trunk/Scribus/scribus/ui/charselectenhanced.h
Modified: trunk/Scribus/scribus/canvas.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25030&path=/trunk/Scribus/scribus/canvas.cpp
==============================================================================
--- trunk/Scribus/scribus/canvas.cpp (original)
+++ trunk/Scribus/scribus/canvas.cpp Sun Mar 13 01:30:02 2022
@@ -103,54 +103,6 @@
// Coordinate Conversion Routines:
-FPoint Canvas::localToCanvas(QPoint p) const
-{
-
-/* Allow the user to select the exact coordinate represented by a ruler mark
- when the mouse is lined up with the ruler, rather than returning the
- coordinate represented by the mathematical centre of the pixel which
- may not be exactly the same as the coordinate represented by the ruler.
-*/
-
-// (xmin, xmax) = canvas top-left
- double xmin = m_doc->minCanvasCoordinate.x();
- double ymin = m_doc->minCanvasCoordinate.y();
-
-// (xoff, yoff) = ruler origin relative to canvas top-left
- double xoff = m_doc->rulerXoffset - xmin;
- double yoff = m_doc->rulerYoffset - ymin;
- if (m_doc->guidesPrefs().rulerMode)
- {
- xoff += m_doc->currentPage()->xOffset();
- yoff += m_doc->currentPage()->yOffset();
- }
-// (xsp, ysp) = spacing of ruler divisions
- double xsp = m_doc->view()->horizRuler->ruleSpacing();
- double ysp = m_doc->view()->vertRuler->ruleSpacing();
-
- double sc = m_viewMode.scale;
-
-// number of ruler divisions from ruler origin to ruler mark closest to the
-// selected mouse coordinate
- double xn = qRound((p.x() / sc - xoff) / xsp);
- double yn = qRound((p.y() / sc - yoff) / ysp);
-
-// xn*xsp + xoff, yn*ysp + yoff = distance in canvas coordinates
-// from canvas top-left to ruler mark closest to selected mouse coordinate
-
-// If these round to the selected mouse coordinate, use these to define
-// (x,y), the coordinates of the desired point relative to the canvas top-left.
-// Otherwise, simply scale the mouse coordinates.
- double x = ( qRound(sc*(xn * xsp + xoff)) == p.x() ?
- xn * xsp + xoff : p.x() / sc );
- double y = ( qRound(sc*(yn * ysp + yoff)) == p.y() ?
- yn * ysp + yoff : p.y() / sc );
-
-// Finally, add xmin,ymin to get the absolute canvas coordinates of the
-// desired point.
- return FPoint(x + xmin, y + ymin);
-}
-
FPoint Canvas::localToCanvas(QPointF p) const
{
@@ -270,11 +222,6 @@
QSize(p.width() * m_viewMode.scale, p.height() * m_viewMode.scale) };
}
-FPoint Canvas::globalToCanvas(QPoint p) const
-{
- return localToCanvas(p - (mapToParent(QPoint(0, 0)) + parentWidget()->mapToGlobal(QPoint(0, 0))));
-}
-
FPoint Canvas::globalToCanvas(QPointF p) const
{
return localToCanvas(p.toPoint() - (mapToParent(QPoint(0, 0)) + parentWidget()->mapToGlobal(QPoint(0, 0))));
@@ -287,7 +234,7 @@
}
-QRectF Canvas::globalToCanvas(QRectF p) const
+QRectF Canvas::globalToCanvas(const QRectF& p) const
{
FPoint org = globalToCanvas(p.topLeft());
return { org.x(), org.y(), p.width() / m_viewMode.scale, p.height() / m_viewMode.scale };
@@ -298,15 +245,7 @@
// Tests for Finding Things:
-bool Canvas::hitsCanvasPoint(QPoint globalPoint, const FPoint& canvasPoint) const
-{
- QPoint localPoint1 = globalPoint - (mapToParent(QPoint(0,0)) + parentWidget()->mapToGlobal(QPoint(0, 0)));
- QPoint localPoint2 = canvasToLocal(canvasPoint);
- int radius = m_doc->guidesPrefs().grabRadius;
- return qAbs(localPoint1.x() - localPoint2.x()) < radius && qAbs(localPoint1.y() - localPoint2.y()) < radius;
-}
-
-bool Canvas::hitsCanvasPoint(QPointF globalPoint, const FPoint& canvasPoint) const
+bool Canvas::hitsCanvasPoint(const QPointF& globalPoint, const FPoint& canvasPoint) const
{
QPointF localPoint1 = globalPoint - (mapToParent(QPointF(0, 0)) + parentWidget()->mapToGlobal(QPointF(0, 0)));
QPointF localPoint2 = canvasToLocalF(canvasPoint);
@@ -314,15 +253,7 @@
return qAbs(localPoint1.x() - localPoint2.x()) < radius && qAbs(localPoint1.y() - localPoint2.y()) < radius;
}
-bool Canvas::hitsCanvasPoint(QPoint globalPoint, QPointF canvasPoint) const
-{
- QPoint localPoint1 = globalPoint - (mapToParent(QPoint(0,0)) + parentWidget()->mapToGlobal(QPoint(0, 0)));
- QPoint localPoint2 = canvasToLocal(canvasPoint);
- int radius = m_doc->guidesPrefs().grabRadius;
- return qAbs(localPoint1.x() - localPoint2.x()) < radius && qAbs(localPoint1.y() - localPoint2.y()) < radius;
-}
-
-bool Canvas::hitsCanvasPoint(QPointF globalPoint, QPointF canvasPoint) const
+bool Canvas::hitsCanvasPoint(const QPointF& globalPoint, const QPointF& canvasPoint) const
{
QPointF localPoint1 = globalPoint - (mapToParent(QPointF(0, 0)) + parentWidget()->mapToGlobal(QPointF(0, 0)));
QPointF localPoint2 = canvasToLocalF(canvasPoint);
@@ -479,7 +410,7 @@
// look for masterpage items first
if (allowMasterItems && !m_doc->masterPageMode() && m_doc->currentPage()->FromMaster.count() != 0)
{
- ScPage* Mp = m_doc->MasterPages.at(m_doc->MasterNames[m_doc->currentPage()->masterPageName()]);
+ const ScPage* Mp = m_doc->MasterPages.at(m_doc->MasterNames[m_doc->currentPage()->masterPageName()]);
// if itemAbove is given, we expect to find it among the masterpage items of this page
int currNr = itemAbove? m_doc->currentPage()->FromMaster.indexOf(itemAbove)-1 : m_doc->currentPage()->FromMaster.count()-1;
if (currNr < 0)
@@ -539,7 +470,7 @@
while (currNr >= 0)
{
currItem = itemList->at(currNr);
- if ((m_doc->masterPageMode()) && (!((currItem->OwnPage == -1) || (currItem->OwnPage == static_cast<int>(m_doc->currentPage()->pageNr())))))
+ if ((m_doc->masterPageMode()) && (!((currItem->OwnPage == -1) || (currItem->OwnPage == m_doc->currentPage()->pageNr()))))
{
--currNr;
continue;
@@ -593,7 +524,7 @@
return nullptr;
}
-bool Canvas::cursorOverTextFrameControl(QPointF globalPos, PageItem* frame)
+bool Canvas::cursorOverTextFrameControl(QPointF globalPos, const PageItem* frame) const
{
FPoint mp = globalToCanvas(globalPos);
qreal sideLength = 10 / qMax(m_viewMode.scale, 1.0);
@@ -604,14 +535,14 @@
return mp.x() > left && mp.x() < right && mp.y() > top && mp.y() < bottom;
}
-bool Canvas::cursorOverFrameControl(QPointF globalPos, const QRectF& targetRect, PageItem* frame)
+bool Canvas::cursorOverFrameControl(QPointF globalPos, const QRectF& targetRect, const PageItem* frame) const
{
FPoint mp = globalToCanvas(globalPos);
QRectF tg = targetRect.translated(frame->xPos(), frame->yPos());
return tg.contains(QPointF(mp.x(), mp.y()));
}
-PageItem* Canvas::itemInGroup(PageItem* group, const QRectF& mouseArea) const
+PageItem* Canvas::itemInGroup(const PageItem* group, const QRectF& mouseArea) const
{
int currNr = group->groupItemList.count() - 1;
while (currNr >= 0)
@@ -643,7 +574,7 @@
return nullptr;
}
-PageItem * Canvas::itemUnderItem(PageItem * item, int& index) const
+PageItem * Canvas::itemUnderItem(const PageItem * item, int& index) const
{
int indice = qMin(index, m_doc->Items->count());
if (index < 0 || indice < 0)
@@ -1058,7 +989,7 @@
{
drawBackgroundPageOutlines(painter, clipx, clipy, clipw, cliph);
m_viewMode.linkedFramesToShow.clear();
- QRectF clip = QRectF(clipx, clipy, clipw, cliph);
+ QRectF clip(clipx, clipy, clipw, cliph);
DrawPageBorder(painter, clip);
if (m_viewMode.viewAsPreview)
{
@@ -1118,7 +1049,7 @@
m_viewMode.linkedFramesToShow.clear();
drawBackgroundMasterpage(painter, clipx, clipy, clipw, cliph);
painter->beginLayer(1.0, 0);
- QRectF clip = QRectF(clipx, clipy, clipw, cliph);
+ QRectF clip(clipx, clipy, clipw, cliph);
DrawPageBorder(painter, clip, true);
int renderStackCount = m_doc->guidesPrefs().renderStackOrder.count();
for (int r = 0; r < renderStackCount; r++)
@@ -1338,7 +1269,7 @@
/**
draws the bezier curve in edit bezier mode
*/
-void Canvas::drawControlsBezierCurve(QPainter* pp, PageItem* currItem)
+void Canvas::drawControlsBezierCurve(QPainter* pp, const PageItem* currItem)
{
pp->setBrush(Qt::NoBrush);
pp->setPen(QPen(Qt::black, 1.0 / m_viewMode.scale, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin));
@@ -1421,7 +1352,7 @@
/**
draws masterpage items of a specific layer
*/
-void Canvas::DrawMasterItems(ScPainter *painter, ScPage *page, ScLayer& layer, QRect clip)
+void Canvas::DrawMasterItems(ScPainter *painter, const ScPage *page, const ScLayer& layer, QRect clip)
{
if ((m_viewMode.previewMode) && (!layer.isPrintable))
return;
@@ -1449,7 +1380,7 @@
currItem = page->FromMaster.at(a);
if (currItem->m_layerID != layer.ID)
continue;
- if ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Mp->pageNr())))
+ if ((currItem->OwnPage != -1) && (currItem->OwnPage != Mp->pageNr()))
continue;
if ((m_viewMode.previewMode) && (!currItem->printEnabled()))
continue;
@@ -1522,7 +1453,7 @@
/**
draws page items contained in a specific Layer
*/
-void Canvas::DrawPageItems(ScPainter *painter, ScLayer& layer, QRect clip, bool notesFramesPass)
+void Canvas::DrawPageItems(ScPainter *painter, const ScLayer& layer, QRect clip, bool notesFramesPass)
{
if ((m_viewMode.previewMode) && (!layer.isPrintable))
return;
@@ -1538,9 +1469,9 @@
QRectF cullingArea = QRectF(static_cast<int>(orig.x()), static_cast<int>(orig.y()),
qRound(clip.width() / m_viewMode.scale + 0.5), qRound(clip.height() / m_viewMode.scale + 0.5));
- PageItem *currItem;
+ PageItem *currItem { nullptr };
int layerCount = m_doc->layerCount();
- int docCurrPageNo=static_cast<int>(m_doc->currentPageNumber());
+ int docCurrPageNo = m_doc->currentPageNumber();
if ((layerCount > 1) && ((layer.blendMode != 0) || (layer.transparency != 1.0)) && (!layer.outlineMode))
painter->beginLayer(layer.transparency, layer.blendMode);
@@ -1586,9 +1517,6 @@
}
if (cullingArea.intersects(currItem->getBoundingRect().adjusted(0.0, 0.0, 1.0, 1.0)))
{
-//FIXME if (!evSpon || forceRedraw)
-// currItem->invalid = true;
-// if ((!m_MouseButtonPressed) || (m_doc->appMode == modeEditClip))
if (((m_viewMode.operItemMoving || m_viewMode.drawSelectedItemsWithControls) && currItem->isSelected()))
{
// qDebug() << "skipping pageitem (move/resizeEdit/selected)" << m_viewMode.operItemMoving << currItem->isSelected();
@@ -1645,7 +1573,7 @@
double y = currentPage->yOffset() * m_viewMode.scale;
double w = currentPage->width() * m_viewMode.scale;
double h = currentPage->height() * m_viewMode.scale;
- QRectF drawRect = QRectF(x, y, w+5, h+5);
+ QRectF drawRect(x, y, w + 5, h + 5);
drawRect.translate(-m_doc->minCanvasCoordinate.x() * m_viewMode.scale, -m_doc->minCanvasCoordinate.y() * m_viewMode.scale);
if (!drawRect.intersects(QRectF(clipx, clipy, clipw, cliph)))
return;
@@ -1675,17 +1603,16 @@
*/
void Canvas::drawBackgroundPageOutlines(ScPainter* painter, int clipx, int clipy, int clipw, int cliph)
{
- int docPagesCount=m_doc->Pages->count();
+ int docPagesCount = m_doc->Pages->count();
if (PrefsManager::instance().appPrefs.displayPrefs.showPageShadow)
{
painter->setBrush(QColor(128,128,128));
painter->setAntialiasing(false);
painter->setPen(Qt::black, 1.0 / m_viewMode.scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
- ScPage *actPg;
MarginStruct pageBleeds;
- for (int a = 0; a < static_cast<int>(docPagesCount); ++a)
- {
- actPg = m_doc->Pages->at(a);
+ for (int a = 0; a < docPagesCount; ++a)
+ {
+ const ScPage* actPg = m_doc->Pages->at(a);
m_doc->getBleeds(actPg, pageBleeds);
if (m_viewMode.viewAsPreview)
pageBleeds.resetToZero();
@@ -1694,7 +1621,7 @@
double blw = (actPg->width() + pageBleeds.left() + pageBleeds.right()) * m_viewMode.scale;
double blh = (actPg->height() + pageBleeds.bottom() + pageBleeds.top()) * m_viewMode.scale;
- QRectF drawRect = QRectF(blx-1, bly-1, blw+6, blh+6);
+ QRectF drawRect(blx - 1, bly - 1, blw + 6, blh + 6);
drawRect.translate(-m_doc->minCanvasCoordinate.x() * m_viewMode.scale, -m_doc->minCanvasCoordinate.y() * m_viewMode.scale);
if (drawRect.intersects(QRectF(clipx, clipy, clipw, cliph)))
{
@@ -1722,11 +1649,11 @@
painter->setAntialiasing(true);
}
painter->setFillMode(ScPainter::Solid);
- ScPage *actPg;
+
MarginStruct pageBleeds;
- for (int a = 0; a < static_cast<int>(docPagesCount); ++a)
- {
- actPg = m_doc->Pages->at(a);
+ for (int a = 0; a < docPagesCount; ++a)
+ {
+ const ScPage* actPg = m_doc->Pages->at(a);
double x = actPg->xOffset();
double y = actPg->yOffset();
double w = actPg->width();
@@ -1744,7 +1671,7 @@
double blw = (actPg->width() + pageBleeds.left() + pageBleeds.right()) * m_viewMode.scale;
double blh = (actPg->height() + pageBleeds.bottom() + pageBleeds.top()) * m_viewMode.scale;
- QRectF drawRect = QRectF(blx, bly, blw+5, blh+5);
+ QRectF drawRect(blx, bly, blw+5, blh+5);
drawRect.translate(-m_doc->minCanvasCoordinate.x() * m_viewMode.scale, -m_doc->minCanvasCoordinate.y() * m_viewMode.scale);
if (drawRect.intersects(QRectF(clipx, clipy, clipw, cliph)))
{
@@ -1828,8 +1755,8 @@
0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0};
for (int j = 0; j < 29; j += 4)
{
- PoLine->addPoint(x + w * rect[j], y + h * rect[j+1]);
- PoLine->addPoint(x + w * rect[j+2], y + h * rect[j+3]);
+ PoLine->addPoint(x + w * rect[j], y + h * rect[j + 1]);
+ PoLine->addPoint(x + w * rect[j + 2], y + h * rect[j + 3]);
}
}
}
@@ -1837,7 +1764,7 @@
/**
draws page border
*/
-void Canvas::DrawPageBorderSub(ScPainter *p, ScPage *page)
+void Canvas::DrawPageBorderSub(ScPainter *p, const ScPage *page)
{
p->save();
p->setAntialiasing(false);
@@ -1857,12 +1784,12 @@
{
if (master)
{
- ScPage *page = m_doc->currentPage();
+ const ScPage *page = m_doc->currentPage();
double x = m_doc->scratch()->left() * m_viewMode.scale;
double y = m_doc->scratch()->top() * m_viewMode.scale;
double w = page->width() * m_viewMode.scale;
double h = page->height() * m_viewMode.scale;
- QRectF drawRect = QRectF(x, y, w+5, h+5);
+ QRectF drawRect(x, y, w + 5, h + 5);
drawRect.translate(-m_doc->minCanvasCoordinate.x() * m_viewMode.scale, -m_doc->minCanvasCoordinate.y() * m_viewMode.scale);
if (drawRect.intersects(clip))
DrawPageBorderSub(p, page);
@@ -1872,8 +1799,8 @@
int docPagesCount = m_doc->Pages->count();
for (int a = 0; a < docPagesCount; ++a)
{
- ScPage *page = m_doc->Pages->at(a);
- QRectF drawRect = QRectF(page->xOffset() * m_viewMode.scale, page->yOffset() * m_viewMode.scale, page->width() * m_viewMode.scale + 5, page->height() * m_viewMode.scale + 5);
+ const ScPage *page = m_doc->Pages->at(a);
+ QRectF drawRect(page->xOffset() * m_viewMode.scale, page->yOffset() * m_viewMode.scale, page->width() * m_viewMode.scale + 5, page->height() * m_viewMode.scale + 5);
drawRect.translate(-m_doc->minCanvasCoordinate.x() * m_viewMode.scale, -m_doc->minCanvasCoordinate.y() * m_viewMode.scale);
if (drawRect.intersects(clip))
DrawPageBorderSub(p, page);
@@ -1884,7 +1811,7 @@
/**
draws margins
*/
-void Canvas::DrawPageMarginsGridSub(ScPainter *p, ScPage *page)
+void Canvas::DrawPageMarginsGridSub(ScPainter *p, const ScPage *page)
{
p->save();
p->setAntialiasing(false);
@@ -1919,12 +1846,12 @@
{
if (master)
{
- ScPage *page = m_doc->currentPage();
+ const ScPage *page = m_doc->currentPage();
double x = m_doc->scratch()->left() * m_viewMode.scale;
double y = m_doc->scratch()->top() * m_viewMode.scale;
double w = page->width() * m_viewMode.scale;
double h = page->height() * m_viewMode.scale;
- QRectF drawRect = QRectF(x, y, w+5, h+5);
+ QRectF drawRect(x, y, w + 5, h + 5);
drawRect.translate(-m_doc->minCanvasCoordinate.x() * m_viewMode.scale, -m_doc->minCanvasCoordinate.y() * m_viewMode.scale);
if (drawRect.intersects(clip))
DrawPageMarginsGridSub(p, page);
@@ -1934,8 +1861,8 @@
int docPagesCount = m_doc->Pages->count();
for (int a = 0; a < docPagesCount; ++a)
{
- ScPage *page = m_doc->Pages->at(a);
- QRectF drawRect = QRectF(page->xOffset() * m_viewMode.scale, page->yOffset() * m_viewMode.scale, page->width() * m_viewMode.scale + 5, page->height() * m_viewMode.scale + 5);
+ const ScPage *page = m_doc->Pages->at(a);
+ QRectF drawRect(page->xOffset() * m_viewMode.scale, page->yOffset() * m_viewMode.scale, page->width() * m_viewMode.scale + 5, page->height() * m_viewMode.scale + 5);
drawRect.translate(-m_doc->minCanvasCoordinate.x() * m_viewMode.scale, -m_doc->minCanvasCoordinate.y() * m_viewMode.scale);
if (drawRect.intersects(clip))
DrawPageMarginsGridSub(p, page);
@@ -1946,7 +1873,7 @@
/**
draws baseline grid
*/
-void Canvas::DrawPageBaselineGridSub(ScPainter *p, ScPage *page)
+void Canvas::DrawPageBaselineGridSub(ScPainter *p, const ScPage *page)
{
if (!m_doc->guidesPrefs().baselineGridShown)
return;
@@ -1973,12 +1900,12 @@
if (master)
{
- ScPage *page = m_doc->currentPage();
+ const ScPage *page = m_doc->currentPage();
double x = m_doc->scratch()->left() * m_viewMode.scale;
double y = m_doc->scratch()->top() * m_viewMode.scale;
double w = page->width() * m_viewMode.scale;
double h = page->height() * m_viewMode.scale;
- QRectF drawRect = QRectF(x, y, w+5, h+5);
+ QRectF drawRect(x, y, w + 5, h + 5);
drawRect.translate(-m_doc->minCanvasCoordinate.x() * m_viewMode.scale, -m_doc->minCanvasCoordinate.y() * m_viewMode.scale);
if (drawRect.intersects(clip))
DrawPageBaselineGridSub(p, page);
@@ -1988,7 +1915,7 @@
int docPagesCount = m_doc->Pages->count();
for (int a = 0; a < docPagesCount; ++a)
{
- ScPage *page = m_doc->Pages->at(a);
+ const ScPage *page = m_doc->Pages->at(a);
QRectF drawRect = QRectF(page->xOffset() * m_viewMode.scale, page->yOffset() * m_viewMode.scale, page->width() * m_viewMode.scale + 5, page->height() * m_viewMode.scale + 5);
drawRect.translate(-m_doc->minCanvasCoordinate.x() * m_viewMode.scale, -m_doc->minCanvasCoordinate.y() * m_viewMode.scale);
if (drawRect.intersects(clip))
@@ -2000,7 +1927,7 @@
/**
draws grid
*/
-void Canvas::DrawPageGridSub(ScPainter *p, ScPage *page, const QRectF& clip)
+void Canvas::DrawPageGridSub(ScPainter *p, const ScPage *page, const QRectF& clip)
{
if (!m_doc->guidesPrefs().gridShown)
return;
@@ -2031,13 +1958,13 @@
p->setPen(m_doc->guidesPrefs().majorGridColor, lineWidth, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
start = floor(lowerBy / i);
start *= i;
- for (double b = start; b <= highBy; b+=i)
+ for (double b = start; b <= highBy; b += i)
{
p->drawLine(FPoint(qMax(lowerBx, 0.0), b), FPoint(qMin(pageWidth, highBx), b));
}
- start=floor(lowerBx/i);
- start*=i;
- for (double b = start; b <= highBx; b+=i)
+ start=floor(lowerBx / i);
+ start *= i;
+ for (double b = start; b <= highBx; b += i)
{
p->drawLine(FPoint(b, qMax(lowerBy, 0.0)), FPoint(b, qMin(pageHeight, highBy)));
}
@@ -2045,13 +1972,13 @@
p->setPen(m_doc->guidesPrefs().minorGridColor, lineWidth, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin);
start = floor(lowerBy / i);
start *= i;
- for (double b = start; b <= highBy; b+=i)
+ for (double b = start; b <= highBy; b += i)
{
p->drawLine(FPoint(qMax(lowerBx, 0.0), b), FPoint(qMin(pageWidth, highBx), b));
}
- start=floor(lowerBx/i);
- start*=i;
- for (double b = start; b <= highBx; b+=i)
+ start=floor(lowerBx / i);
+ start *= i;
+ for (double b = start; b <= highBx; b += i)
{
p->drawLine(FPoint(b, qMax(lowerBy, 0.0)), FPoint(b, qMin(pageHeight, highBy)));
}
@@ -2101,12 +2028,12 @@
if (master)
{
- ScPage *page = m_doc->currentPage();
+ const ScPage *page = m_doc->currentPage();
double x = m_doc->scratch()->left() * m_viewMode.scale;
double y = m_doc->scratch()->top() * m_viewMode.scale;
double w = page->width() * m_viewMode.scale;
double h = page->height() * m_viewMode.scale;
- QRectF drawRect = QRectF(x, y, w+5, h+5);
+ QRectF drawRect(x, y, w + 5, h + 5);
drawRect.translate(-m_doc->minCanvasCoordinate.x() * m_viewMode.scale, -m_doc->minCanvasCoordinate.y() * m_viewMode.scale);
if (drawRect.intersects(clip))
DrawPageGridSub(p, page, clip);
@@ -2116,8 +2043,8 @@
int docPagesCount = m_doc->Pages->count();
for (int a = 0; a < docPagesCount; ++a)
{
- ScPage *page = m_doc->Pages->at(a);
- QRectF drawRect = QRectF(page->xOffset() * m_viewMode.scale, page->yOffset() * m_viewMode.scale, page->width() * m_viewMode.scale + 5, page->height() * m_viewMode.scale + 5);
+ const ScPage *page = m_doc->Pages->at(a);
+ QRectF drawRect(page->xOffset() * m_viewMode.scale, page->yOffset() * m_viewMode.scale, page->width() * m_viewMode.scale + 5, page->height() * m_viewMode.scale + 5);
drawRect.translate(-m_doc->minCanvasCoordinate.x() * m_viewMode.scale, -m_doc->minCanvasCoordinate.y() * m_viewMode.scale);
if (drawRect.intersects(clip))
DrawPageGridSub(p, page, clip);
@@ -2128,7 +2055,7 @@
/**
draws guides
*/
-void Canvas::DrawPageGuidesSub(ScPainter *p, ScPage *page)
+void Canvas::DrawPageGuidesSub(ScPainter *p, const ScPage *page)
{
if (!m_doc->guidesPrefs().guidesShown)
return;
@@ -2152,12 +2079,12 @@
if (master)
{
- ScPage *page = m_doc->currentPage();
+ const ScPage *page = m_doc->currentPage();
double x = m_doc->scratch()->left() * m_viewMode.scale;
double y = m_doc->scratch()->top() * m_viewMode.scale;
double w = page->width() * m_viewMode.scale;
double h = page->height() * m_viewMode.scale;
- QRectF drawRect = QRectF(x, y, w+5, h+5);
+ QRectF drawRect(x, y, w + 5, h + 5);
drawRect.translate(-m_doc->minCanvasCoordinate.x() * m_viewMode.scale, -m_doc->minCanvasCoordinate.y() * m_viewMode.scale);
if (drawRect.intersects(clip))
DrawPageGuidesSub(p, page);
@@ -2167,8 +2094,8 @@
int docPagesCount = m_doc->Pages->count();
for (int a = 0; a < docPagesCount; ++a)
{
- ScPage *page = m_doc->Pages->at(a);
- QRectF drawRect = QRectF(page->xOffset() * m_viewMode.scale, page->yOffset() * m_viewMode.scale, page->width() * m_viewMode.scale + 5, page->height() * m_viewMode.scale + 5);
+ const ScPage *page = m_doc->Pages->at(a);
+ QRectF drawRect(page->xOffset() * m_viewMode.scale, page->yOffset() * m_viewMode.scale, page->width() * m_viewMode.scale + 5, page->height() * m_viewMode.scale + 5);
drawRect.translate(-m_doc->minCanvasCoordinate.x() * m_viewMode.scale, -m_doc->minCanvasCoordinate.y() * m_viewMode.scale);
if (drawRect.intersects(clip))
DrawPageGuidesSub(p, page);
@@ -2179,7 +2106,7 @@
/**
draws actual page indicator frame
*/
-void Canvas::DrawPageIndicatorSub(ScPainter *p, ScPage *page)
+void Canvas::DrawPageIndicatorSub(ScPainter *p, const ScPage *page)
{
p->save();
int fm = p->fillMode();
@@ -2202,12 +2129,12 @@
{
if (master)
{
- ScPage *page = m_doc->currentPage();
+ const ScPage *page = m_doc->currentPage();
double x = m_doc->scratch()->left() * m_viewMode.scale;
double y = m_doc->scratch()->top() * m_viewMode.scale;
double w = page->width() * m_viewMode.scale;
double h = page->height() * m_viewMode.scale;
- QRectF drawRect = QRectF(x, y, w+5, h+5);
+ QRectF drawRect(x, y, w + 5, h + 5);
drawRect.translate(-m_doc->minCanvasCoordinate.x() * m_viewMode.scale, -m_doc->minCanvasCoordinate.y() * m_viewMode.scale);
if (drawRect.intersects(clip))
DrawPageIndicatorSub(p, page);
@@ -2217,10 +2144,10 @@
int docPagesCount = m_doc->Pages->count();
for (int a = 0; a < docPagesCount; ++a)
{
- ScPage *page = m_doc->Pages->at(a);
+ const ScPage *page = m_doc->Pages->at(a);
if (page == m_doc->currentPage())
{
- QRectF drawRect = QRectF(page->xOffset() * m_viewMode.scale, page->yOffset() * m_viewMode.scale, page->width() * m_viewMode.scale + 5, page->height() * m_viewMode.scale + 5);
+ QRectF drawRect(page->xOffset() * m_viewMode.scale, page->yOffset() * m_viewMode.scale, page->width() * m_viewMode.scale + 5, page->height() * m_viewMode.scale + 5);
drawRect.translate(-m_doc->minCanvasCoordinate.x() * m_viewMode.scale, -m_doc->minCanvasCoordinate.y() * m_viewMode.scale);
if (drawRect.intersects(clip))
DrawPageIndicatorSub(p, page);
@@ -2265,7 +2192,7 @@
}
}
}
- else if ((((m_doc->appMode == modeLinkFrames) || (m_doc->appMode == modeUnlinkFrames)) && (currItem != nullptr)))
+ else if (((m_doc->appMode == modeLinkFrames) || (m_doc->appMode == modeUnlinkFrames)) && (currItem != nullptr))
{
PageItem *nextItem = currItem->firstInChain();
while (nextItem != nullptr)
@@ -2288,7 +2215,7 @@
/**
draws one linkline between textframes
*/
-void Canvas::drawLinkFrameLine(ScPainter* painter, FPoint &start, FPoint &end)
+void Canvas::drawLinkFrameLine(ScPainter* painter, const FPoint &start, const FPoint &end)
{
//CB FIXME Add some checking that the painter is setup?
Q_ASSERT(painter!=nullptr);
@@ -2360,26 +2287,26 @@
QPoint out = contentsToViewport(in);
*x = static_cast<double>(out.x());
*y = static_cast<double>(out.y());
- *w = gw* m_viewMode.scale;
- *h = gh* m_viewMode.scale;
-}
-
-
-void Canvas::Transform(PageItem *currItem, QPainter *p)
+ *w = gw * m_viewMode.scale;
+ *h = gh * m_viewMode.scale;
+}
+
+
+void Canvas::Transform(const PageItem *currItem, QPainter *p) const
{
p->translate(currItem->xPos()*m_viewMode.scale, currItem->yPos()*m_viewMode.scale);
p->scale(m_viewMode.scale, m_viewMode.scale);
p->rotate(currItem->rotation());
}
-void Canvas::Transform(PageItem *currItem, QTransform& m)
+void Canvas::Transform(const PageItem *currItem, QTransform& m) const
{
m.translate(currItem->xPos()*m_viewMode.scale, currItem->yPos()*m_viewMode.scale);
m.scale(m_viewMode.scale, m_viewMode.scale);
m.rotate(currItem->rotation());
}
-void Canvas::TransformM(PageItem *currItem, QPainter *p)
+void Canvas::TransformM(const PageItem *currItem, QPainter *p) const
{
if (currItem->imageFlippedH())
{
@@ -2393,7 +2320,7 @@
}
}
-void Canvas::calculateFrameLinkPoints(PageItem *pi1, PageItem *pi2, FPoint & start, FPoint & end)
+void Canvas::calculateFrameLinkPoints(const PageItem *pi1, const PageItem *pi2, FPoint & start, FPoint & end)
{
if (pi1==nullptr || pi2==nullptr)
return;
Modified: trunk/Scribus/scribus/canvas.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25030&path=/trunk/Scribus/scribus/canvas.h
==============================================================================
--- trunk/Scribus/scribus/canvas.h (original)
+++ trunk/Scribus/scribus/canvas.h Sun Mar 13 01:30:02 2022
@@ -156,20 +156,16 @@
QRectF canvasToLocalF(const QRectF& p) const;
QRect canvasToGlobal(const QRectF& p) const;
QRectF canvasToGlobalF(const QRectF& p) const;
- FPoint localToCanvas(QPoint p) const;
FPoint localToCanvas(QPointF p) const;
- FPoint globalToCanvas(QPoint p) const;
FPoint globalToCanvas(QPointF p) const;
QRectF globalToCanvas(QRect p) const;
- QRectF globalToCanvas(QRectF p) const;
- bool hitsCanvasPoint(QPoint globalPoint, const FPoint& canvasPoint) const;
- bool hitsCanvasPoint(QPointF globalPoint, const FPoint& canvasPoint) const;
- bool hitsCanvasPoint(QPoint globalPoint, QPointF canvasPoint) const;
- bool hitsCanvasPoint(QPointF globalPoint, QPointF canvasPoint) const;
+ QRectF globalToCanvas(const QRectF& p) const;
+ bool hitsCanvasPoint(const QPointF& globalPoint, const FPoint& canvasPoint) const;
+ bool hitsCanvasPoint(const QPointF& globalPoint, const QPointF& canvasPoint) const;
bool hitsCanvasPoint(const FPoint& globalPoint, const QPointF& canvasPoint) const;
QRect exposedRect() const;
- bool cursorOverTextFrameControl(QPointF globalPos, PageItem* frame);
- bool cursorOverFrameControl(QPointF globalPos, const QRectF& targetRect, PageItem* frame);
+ bool cursorOverTextFrameControl(QPointF globalPos, const PageItem* frame) const;
+ bool cursorOverFrameControl(QPointF globalPos, const QRectF& targetRect, const PageItem* frame) const;
/** Returns the framehandle or INSIDE if the position falls into the frame. */
FrameHandle frameHitTest(QPointF canvasPoint, PageItem* item) const;
FrameHandle frameHitTest(QPointF canvasPoint, const QRectF& frame) const;
@@ -182,8 +178,8 @@
(this flag is ignored in masterpage mode, since all items are masterpage items then).
*/
PageItem* itemUnderCursor(QPointF globalPos, PageItem* itemAbove=nullptr, bool allowInGroup=false, bool allowMasterItems=false) const;
- PageItem* itemInGroup(PageItem* group, const QRectF& mouseArea) const;
- PageItem* itemUnderItem(PageItem* item, int& index) const;
+ PageItem* itemInGroup(const PageItem* group, const QRectF& mouseArea) const;
+ PageItem* itemUnderItem(const PageItem* item, int& index) const;
const QPolygon& redrawPolygon() const { return m_viewMode.redrawPolygon; }
QPolygon& newRedrawPolygon()
@@ -199,9 +195,9 @@
int previewVisual() const { return m_viewMode.previewVisual; }
void setPreviewVisual(int mode);
- void DrawMasterItems(ScPainter *painter, ScPage *page, ScLayer& layer, QRect clip);
+ void DrawMasterItems(ScPainter *painter, const ScPage *page, const ScLayer& layer, QRect clip);
//notesFramesPass determine if notes frames are drawn or not
- void DrawPageItems(ScPainter *painter, ScLayer& layer, QRect clip, bool notesFramesPass);
+ void DrawPageItems(ScPainter *painter, const ScLayer& layer, QRect clip, bool notesFramesPass);
void paintEvent ( QPaintEvent * p ) override;
void displayXYHUD(QPointF m);
@@ -221,24 +217,24 @@
void setupEditHRuler(PageItem * item, bool forceAndReset = false);
private:
- void DrawPageBorderSub(ScPainter *p, ScPage *page);
+ void DrawPageBorderSub(ScPainter *p, const ScPage *page);
void DrawPageBorder(ScPainter *p, const QRectF& clip, bool master = false);
- void DrawPageMarginsGridSub(ScPainter *p, ScPage *page);
+ void DrawPageMarginsGridSub(ScPainter *p, const ScPage *page);
void DrawPageMargins(ScPainter *p, const QRectF& clip, bool master = false);
- void DrawPageBaselineGridSub(ScPainter *p, ScPage *page);
+ void DrawPageBaselineGridSub(ScPainter *p, const ScPage *page);
void DrawPageBaselineGrid(ScPainter *p, const QRectF& clip, bool master = false);
- void DrawPageGridSub(ScPainter *p, ScPage *page, const QRectF& clip);
+ void DrawPageGridSub(ScPainter *p, const ScPage *page, const QRectF& clip);
void DrawPageGrid(ScPainter *p, const QRectF& clip, bool master = false);
- void DrawPageGuidesSub(ScPainter *p, ScPage *page);
+ void DrawPageGuidesSub(ScPainter *p, const ScPage *page);
void DrawPageGuides(ScPainter *p, const QRectF& clip, bool master = false);
- void DrawPageIndicatorSub(ScPainter *p, ScPage *page);
+ void DrawPageIndicatorSub(ScPainter *p, const ScPage *page);
void DrawPageIndicator(ScPainter *p, const QRectF& clip, bool master = false);
- void drawLinkFrameLine(ScPainter* painter, FPoint &start, FPoint &end);
+ void drawLinkFrameLine(ScPainter* painter, const FPoint &start, const FPoint &end);
void PaintSizeRect(QRect newRect);
void PaintSizeRect(QPolygon newRect);
- void Transform(PageItem *currItem, QPainter *p);
- void Transform(PageItem *currItem, QTransform& m);
- void TransformM(PageItem *currItem, QPainter *p);
+ void Transform(const PageItem *currItem, QPainter *p) const;
+ void Transform(const PageItem *currItem, QTransform& m) const;
+ void TransformM(const PageItem *currItem, QPainter *p) const;
void getGroupRectScreen(double *x, double *y, double *w, double *h);
/**
@@ -256,13 +252,13 @@
void drawFrameLinks(ScPainter* painter);
void drawControls(QPainter* p);
void drawControlsMovingItemsRect(QPainter* pp);
- void drawControlsBezierCurve(QPainter* pp, PageItem* currItem);
+ void drawControlsBezierCurve(QPainter* pp, const PageItem* currItem);
void drawControlsMeasurementLine(QPainter* pp);
void drawControlsDrawLine(QPainter* pp);
void drawControlsFreehandLine(QPainter* pp);
void getLinkedFrames(PageItem* currItem);
void getClipPathForPages(FPointArray* PoLine);
- void calculateFrameLinkPoints(PageItem* pi1, PageItem* pi2, FPoint& start, FPoint& end);
+ void calculateFrameLinkPoints(const PageItem* pi1, const PageItem* pi2, FPoint& start, FPoint& end);
// create a potentially hidpi pixmap
QPixmap createPixmap(double w, double h);
Modified: trunk/Scribus/scribus/canvasgesture_resize.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25030&path=/trunk/Scribus/scribus/canvasgesture_resize.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_resize.cpp (original)
+++ trunk/Scribus/scribus/canvasgesture_resize.cpp Sun Mar 13 01:30:02 2022
@@ -122,7 +122,7 @@
void ResizeGesture::drawControls(QPainter* p)
{
- QColor drawColor = qApp->palette().color(QPalette::Active, QPalette::Highlight);
+ QColor drawColor = QApplication::palette().color(QPalette::Active, QPalette::Highlight);
QRectF localRect = m_canvas->canvasToLocal(m_bounds.normalized());
if (m_doc->m_Selection->isMultipleSelection())
@@ -146,7 +146,7 @@
if (m_doc->m_Selection->count() == 1)
{
p->setBrush(Qt::NoBrush);
- QPen out = QPen(Qt::gray, 1.0 , Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+ QPen out(Qt::gray, 1.0 , Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
out.setCosmetic(true);
p->setPen(out);
PageItem *currItem = m_doc->m_Selection->itemAt(0);
@@ -176,7 +176,7 @@
double scx = localRect.width() / w;
double scy = localRect.height() / h;
uint docSelectionCount = m_doc->m_Selection->count();
- if (docSelectionCount < m_canvas->moveWithBoxesOnlyThreshold)
+ if (docSelectionCount < Canvas::moveWithBoxesOnlyThreshold)
{
PageItem *currItem;
for (uint a = 0; a < docSelectionCount; ++a)
Modified: trunk/Scribus/scribus/guidemanagercore.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25030&path=/trunk/Scribus/scribus/guidemanagercore.cpp
==============================================================================
--- trunk/Scribus/scribus/guidemanagercore.cpp (original)
+++ trunk/Scribus/scribus/guidemanagercore.cpp Sun Mar 13 01:30:02 2022
@@ -156,62 +156,57 @@
}
}
-Guides GuideManagerCore::horizontals(GuideType type)
+Guides GuideManagerCore::horizontals(GuideType type) const
{
switch (type)
{
case Standard:
return m_horizontalStdG;
- break;
+
case Auto:
return m_horizontalAutoG;
- break;
}
// just to prevent the compiler warnings
return m_horizontalStdG;
}
-Guides GuideManagerCore::verticals(GuideType type)
+Guides GuideManagerCore::verticals(GuideType type) const
{
switch (type)
{
case Standard:
return m_verticalStdG;
- break;
case Auto:
return m_verticalAutoG;
- break;
}
return m_verticalStdG;
}
-double GuideManagerCore::horizontal(uint ix, GuideType type)
+double GuideManagerCore::horizontal(uint ix, GuideType type) const
{
switch (type)
{
case Standard:
return m_horizontalStdG[ix];
- break;
case Auto:
break;
}
return -1.0; // just for compiler warning
}
-double GuideManagerCore::vertical(uint ix, GuideType type)
+double GuideManagerCore::vertical(uint ix, GuideType type) const
{
switch (type)
{
case Standard:
return m_verticalStdG[ix];
- break;
case Auto:
break;
}
return -1.0; // just for compiler warning
}
-Guides GuideManagerCore::getAutoHorizontals(ScPage* page)
+Guides GuideManagerCore::getAutoHorizontals(const ScPage* page) const
{
Guides guides;
int value = m_horizontalAutoCount;
@@ -258,7 +253,7 @@
return guides;
}
-Guides GuideManagerCore::getAutoVerticals(ScPage* page)
+Guides GuideManagerCore::getAutoVerticals(const ScPage* page) const
{
Guides guides;
int value = m_verticalAutoCount;
@@ -412,13 +407,13 @@
}
}
-void GuideManagerCore::copy(GuideManagerCore *target)
+void GuideManagerCore::copy(GuideManagerCore *target) const
{
copy(target, Standard);
copy(target, Auto);
}
-void GuideManagerCore::copy(GuideManagerCore *target, GuideType type)
+void GuideManagerCore::copy(GuideManagerCore *target, GuideType type) const
{
switch (type)
{
@@ -443,9 +438,8 @@
}
}
-void GuideManagerCore::drawPage(ScPainter *p, ScribusDoc *doc, double lineWidth)
-{
- Guides::iterator it;
+void GuideManagerCore::drawPage(ScPainter *p, ScribusDoc *doc, double lineWidth) const
+{
const GuideManager* guideManager = ScCore->primaryMainWindow()->guidePalette;
QColor color(doc->guidesPrefs().guideColor);
@@ -460,11 +454,11 @@
// all standard
p->setPen(color, lineWidth, Qt::DashDotLine, Qt::FlatCap, Qt::MiterJoin);
- for (it = m_verticalStdG.begin(); it != m_verticalStdG.end(); ++it)
+ for (auto it = m_verticalStdG.begin(); it != m_verticalStdG.end(); ++it)
// if ((*it) >= 0 && (*it) <= m_page->width())
// p->drawLine(FPoint((*it), 0), FPoint((*it), m_page->height()));
p->drawLine(FPoint((*it), verticalFrom), FPoint((*it), verticalTo));
- for (it = m_horizontalStdG.begin(); it != m_horizontalStdG.end(); ++it)
+ for (auto it = m_horizontalStdG.begin(); it != m_horizontalStdG.end(); ++it)
// if ((*it) >= 0 && (*it) <= m_page->height())
// p->drawLine(FPoint(0, (*it)), FPoint(m_page->width(), (*it)));
p->drawLine(FPoint(horizontalFrom, (*it)), FPoint(horizontalTo, (*it)));
@@ -475,12 +469,12 @@
{
p->setPen(Qt::red, lineWidth, Qt::DashDotLine, Qt::FlatCap, Qt::MiterJoin);
Guides highlight = guideManager->selectedVerticals();
- for (it = highlight.begin(); it != highlight.end(); ++it)
+ for (auto it = highlight.begin(); it != highlight.end(); ++it)
// if ((*it) >= 0 && (*it) <= m_page->width())
// p->drawLine(FPoint((*it), 0), FPoint((*it), m_page->height()));
p->drawLine(FPoint((*it), verticalFrom), FPoint((*it), verticalTo));
highlight = guideManager->selectedHorizontals();
- for (it = highlight.begin(); it != highlight.end(); ++it)
+ for (auto it = highlight.begin(); it != highlight.end(); ++it)
// if ((*it) >= 0 && (*it) <= m_page->height())
// p->drawLine(FPoint(0, (*it)), FPoint(m_page->width(), (*it)));
p->drawLine(FPoint(horizontalFrom, (*it)), FPoint(horizontalTo, (*it)));
@@ -493,17 +487,17 @@
color = doc->guidesPrefs().guideColor;
p->setPen(color, lineWidth, Qt::DashDotLine, Qt::FlatCap, Qt::MiterJoin);
- for (it = m_verticalAutoG.begin(); it != m_verticalAutoG.end(); ++it)
+ for (auto it = m_verticalAutoG.begin(); it != m_verticalAutoG.end(); ++it)
// if ((*it) >= 0 && (*it) <= m_page->width())
// p->drawLine(FPoint((*it), 0), FPoint((*it), m_page->height()));
p->drawLine(FPoint((*it), verticalFrom), FPoint((*it), verticalTo));
- for (it = m_horizontalAutoG.begin(); it != m_horizontalAutoG.end(); ++it)
+ for (auto it = m_horizontalAutoG.begin(); it != m_horizontalAutoG.end(); ++it)
// if ((*it) >= 0 && (*it) <= m_page->height())
// p->drawLine(FPoint(0, (*it)), FPoint(m_page->width(), (*it)));
p->drawLine(FPoint(horizontalFrom, (*it)), FPoint(horizontalTo, (*it)));
}
-int GuideManagerCore::isMouseOnHorizontal(double low, double high, GuideType type)
+int GuideManagerCore::isMouseOnHorizontal(double low, double high, GuideType type) const
{
Guides tmp;
Guides::iterator it;
@@ -526,7 +520,7 @@
return -1;
}
-int GuideManagerCore::isMouseOnVertical(double low, double high, GuideType type)
+int GuideManagerCore::isMouseOnVertical(double low, double high, GuideType type) const
{
Guides tmp;
Guides::iterator it;
@@ -549,27 +543,27 @@
return -1;
}
-QPair<double, double> GuideManagerCore::topLeft(double x, double y)// const
+QPair<double, double> GuideManagerCore::topLeft(double x, double y) const
{
return QPair<double, double>(closestVertLeft(x), closestHorAbove(y));
}
-QPair<double, double> GuideManagerCore::topRight(double x, double y)// const
+QPair<double, double> GuideManagerCore::topRight(double x, double y) const
{
return QPair<double, double>(closestVertRight(x), closestHorAbove(y));
}
-QPair<double, double> GuideManagerCore::bottomLeft(double x, double y)// const
+QPair<double, double> GuideManagerCore::bottomLeft(double x, double y) const
{
return QPair<double, double>(closestVertLeft(x), closestHorBelow(y));
}
-QPair<double, double> GuideManagerCore::bottomRight(double x, double y)// const
+QPair<double, double> GuideManagerCore::bottomRight(double x, double y) const
{
return QPair<double, double>(closestVertRight(x), closestHorBelow(y));
}
-double GuideManagerCore::closestHorAbove(double y)// const
+double GuideManagerCore::closestHorAbove(double y) const
{
double closest = 0.0;
for (int i = 0; i < m_horizontalStdG.size(); ++i)
@@ -592,7 +586,7 @@
return closest;
}
-double GuideManagerCore::closestHorBelow(double y)// const
+double GuideManagerCore::closestHorBelow(double y) const
{
double closest = m_page->height();
for (int i = 0; i < m_horizontalStdG.size(); ++i)
@@ -615,7 +609,7 @@
return closest;
}
-double GuideManagerCore::closestVertLeft(double x)// const
+double GuideManagerCore::closestVertLeft(double x) const
{
double closest = 0.0;
for (int i = 0; i < m_verticalStdG.size(); ++i)
@@ -638,7 +632,7 @@
return closest;
}
-double GuideManagerCore::closestVertRight(double x)// const
+double GuideManagerCore::closestVertRight(double x) const
{
double closest = m_page->width();
for (int i = 0; i < m_verticalStdG.size(); ++i)
@@ -680,7 +674,7 @@
page->guides.addHorizontal(ScCLocale::toDoubleC((*it)), type);
}
-QString GuideManagerIO::writeHorizontalGuides(ScPage *page, GuideManagerCore::GuideType type)
+QString GuideManagerIO::writeHorizontalGuides(const ScPage *page, GuideManagerCore::GuideType type)
{
Guides::iterator it;
QString retval;
@@ -694,7 +688,7 @@
return retval;
}
-QString GuideManagerIO::writeVerticalGuides(ScPage *page, GuideManagerCore::GuideType type)
+QString GuideManagerIO::writeVerticalGuides(const ScPage *page, GuideManagerCore::GuideType type)
{
Guides::iterator it;
QString retval;
@@ -708,7 +702,7 @@
return retval;
}
-QString GuideManagerIO::writeSelection(ScPage *page)
+QString GuideManagerIO::writeSelection(const ScPage *page)
{
return QString("%1 %2 %3 %4").arg(page->guides.gx).arg(page->guides.gy).arg(page->guides.gw).arg(page->guides.gh);
}
Modified: trunk/Scribus/scribus/guidemanagercore.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25030&path=/trunk/Scribus/scribus/guidemanagercore.h
==============================================================================
--- trunk/Scribus/scribus/guidemanagercore.h (original)
+++ trunk/Scribus/scribus/guidemanagercore.h Sun Mar 13 01:30:02 2022
@@ -18,7 +18,8 @@
class ScPainter;
class UndoManager;
class ScribusDoc;
-typedef QList<double> Guides;
+
+using Guides = QList<double>;
/*! \brief Core manipulation with the guides.
Basic idea:
@@ -40,7 +41,7 @@
GuideManagerCore(ScPage* parentPage);
~GuideManagerCore() = default;
- typedef enum {Standard, Auto} GuideType;
+ enum GuideType {Standard, Auto};
void addHorizontal(double value, GuideType type);
void addHorizontals(Guides values, GuideType type);
@@ -51,54 +52,54 @@
void moveHorizontal(double from, double to, GuideType type);
void moveVertical(double from, double to, GuideType type);
- Guides horizontals(GuideType type);
- Guides verticals(GuideType type);
- double horizontal(uint ix, GuideType type);
- double vertical(uint ix, GuideType type);
+ Guides horizontals(GuideType type) const;
+ Guides verticals(GuideType type) const;
+ double horizontal(uint ix, GuideType type) const;
+ double vertical(uint ix, GuideType type) const;
- Guides getAutoHorizontals(ScPage* page = nullptr);
- Guides getAutoVerticals(ScPage* page = nullptr);
+ Guides getAutoHorizontals(const ScPage* page = nullptr) const;
+ Guides getAutoVerticals(const ScPage* page = nullptr) const;
void clearHorizontals(GuideType type);
void clearVerticals(GuideType type);
- void copy(GuideManagerCore *target);
- void copy(GuideManagerCore *target, GuideType type);
+ void copy(GuideManagerCore *target) const;
+ void copy(GuideManagerCore *target, GuideType type) const;
- void drawPage(ScPainter *p, ScribusDoc *doc, double lineWidth);
+ void drawPage(ScPainter *p, ScribusDoc *doc, double lineWidth) const;
- int isMouseOnHorizontal(double low, double high, GuideType type);
- int isMouseOnVertical(double low, double high, GuideType type);
+ int isMouseOnHorizontal(double low, double high, GuideType type) const;
+ int isMouseOnVertical(double low, double high, GuideType type) const;
void setPage(ScPage *p);
- QPair<double, double> topLeft(double x, double y);// const;
- QPair<double, double> topRight(double x, double y);// const;
- QPair<double, double> bottomLeft(double x, double y);// const;
- QPair<double, double> bottomRight(double x, double y);// const;
+ QPair<double, double> topLeft(double x, double y) const;
+ QPair<double, double> topRight(double x, double y) const;
+ QPair<double, double> bottomLeft(double x, double y) const;
+ QPair<double, double> bottomRight(double x, double y) const;
//! \brief Properties for Auto guides remembrance. See GuideManager.
- int horizontalAutoCount() { return m_horizontalAutoCount; }
+ int horizontalAutoCount() const { return m_horizontalAutoCount; }
//! \brief Properties for Auto guides remembrance. See GuideManager.
void setHorizontalAutoCount(int val) { m_horizontalAutoCount = val; }
//! \brief Properties for Auto guides remembrance. See GuideManager.
- int verticalAutoCount() { return m_verticalAutoCount; }
+ int verticalAutoCount() const { return m_verticalAutoCount; }
//! \brief Properties for Auto guides remembrance. See GuideManager.
void setVerticalAutoCount(int val) { m_verticalAutoCount = val; }
//! \brief Properties for Auto guides remembrance. See GuideManager.
- double horizontalAutoGap(){ return m_horizontalAutoGap; }
+ double horizontalAutoGap() const { return m_horizontalAutoGap; }
//! \brief Properties for Auto guides remembrance. See GuideManager.
- double verticalAutoGap(){return m_verticalAutoGap; }
+ double verticalAutoGap() const {return m_verticalAutoGap; }
//! \brief Properties for Auto guides remembrance. See GuideManager.
void setHorizontalAutoGap(double gap){ m_horizontalAutoGap = gap; }
//! \brief Properties for Auto guides remembrance. See GuideManager.
void setVerticalAutoGap(double gap){ m_verticalAutoGap = gap; }
//! \brief Properties for Auto guides remembrance. See GuideManager.
- int horizontalAutoRefer() { return m_horizontalAutoRefer; }
+ int horizontalAutoRefer() const { return m_horizontalAutoRefer; }
//! \brief Properties for Auto guides remembrance. See GuideManager.
void setHorizontalAutoRefer(int val) { m_horizontalAutoRefer = val; }
//! \brief Properties for Auto guides remembrance. See GuideManager.
- int verticalAutoRefer() { return m_verticalAutoRefer; }
+ int verticalAutoRefer() const { return m_verticalAutoRefer; }
//! \brief Properties for Auto guides remembrance. See GuideManager.
void setVerticalAutoRefer(int val) { m_verticalAutoRefer = val; }
@@ -126,10 +127,10 @@
int m_horizontalAutoRefer {0};
int m_verticalAutoRefer {0};
- double closestHorAbove(double y);// const;
- double closestHorBelow(double y);// const;
- double closestVertLeft(double x);// const;
- double closestVertRight(double x);// const;
+ double closestHorAbove(double y) const;
+ double closestHorBelow(double y) const;
+ double closestVertLeft(double x) const;
+ double closestVertRight(double x) const;
};
@@ -171,11 +172,11 @@
GuideManagerCore::GuideType type,
bool useOldGuides=false);
- static QString writeHorizontalGuides(ScPage *page, GuideManagerCore::GuideType type);
- static QString writeVerticalGuides(ScPage *page, GuideManagerCore::GuideType type);
+ static QString writeHorizontalGuides(const ScPage *page, GuideManagerCore::GuideType type);
+ static QString writeVerticalGuides(const ScPage *page, GuideManagerCore::GuideType type);
static void readSelection(const QString& guideString, ScPage *page);
- static QString writeSelection(ScPage *page);
+ static QString writeSelection(const ScPage *page);
};
#endif
Modified: trunk/Scribus/scribus/third_party/zip/scribus_zip.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25030&path=/trunk/Scribus/scribus/third_party/zip/scribus_zip.cpp
==============================================================================
--- trunk/Scribus/scribus/third_party/zip/scribus_zip.cpp (original)
+++ trunk/Scribus/scribus/third_party/zip/scribus_zip.cpp Sun Mar 13 01:30:02 2022
@@ -75,7 +75,7 @@
return retVal;
}
-bool ScZipHandler::contains(const QString& fileName)
+bool ScZipHandler::contains(const QString& fileName) const
{
if (m_uz == nullptr)
return false;
@@ -126,7 +126,7 @@
return retVal;
}
-QStringList ScZipHandler::files()
+QStringList ScZipHandler::files() const
{
QStringList retVal;
if (m_uz != nullptr)
Modified: trunk/Scribus/scribus/third_party/zip/scribus_zip.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25030&path=/trunk/Scribus/scribus/third_party/zip/scribus_zip.h
==============================================================================
--- trunk/Scribus/scribus/third_party/zip/scribus_zip.h (original)
+++ trunk/Scribus/scribus/third_party/zip/scribus_zip.h Sun Mar 13 01:30:02 2022
@@ -41,11 +41,11 @@
bool open(const QString& fileName);
bool close();
- bool contains(const QString& fileName);
+ bool contains(const QString& fileName) const;
bool read(const QString& fileName, QByteArray &buf);
bool write(const QString& dirName);
bool extract(const QString& name, const QString& path, ExtractionOption eo);
- QStringList files();
+ QStringList files() const;
private:
UnZip* m_uz { nullptr };
Modified: trunk/Scribus/scribus/ui/charselectenhanced.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25030&path=/trunk/Scribus/scribus/ui/charselectenhanced.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/charselectenhanced.cpp (original)
+++ trunk/Scribus/scribus/ui/charselectenhanced.cpp Sun Mar 13 01:30:02 2022
@@ -17,9 +17,7 @@
CharSelectEnhanced::CharSelectEnhanced(QWidget* parent)
- : ScrPaletteBase(parent, "CharSelectEnhanced"),
- m_doc(nullptr),
- m_characterClass(0)
+ : ScrPaletteBase(parent, "CharSelectEnhanced")
{
setupUi(this);
@@ -39,10 +37,6 @@
connect(fontSelector, SIGNAL(activated(int)), this, SLOT(newFont(int)));
connect(rangeSelector, SIGNAL(activated(int)), this, SLOT(newCharClass(int)));
connect(hexLineEdit, SIGNAL(returnPressed()), this, SLOT(hexLineEdit_returnPressed()));
-}
-
-CharSelectEnhanced::~CharSelectEnhanced()
-{
}
void CharSelectEnhanced::setDoc(ScribusDoc* doc)
@@ -437,7 +431,7 @@
void CharSelectEnhanced::delEdit()
{
chToIns.clear();
- QPixmap pm(1,28);
+ QPixmap pm(1, 28);
pm.fill(palette().color(QPalette::Window));
sample->setPixmap(pm);
insertButton->setEnabled(false);
@@ -455,7 +449,7 @@
void CharSelectEnhanced::hexLineEdit_returnPressed()
{
- QString tx("0x%1");;
+ QString tx("0x%1");
bool ok = false;
uint code = tx.arg(hexLineEdit->text()).toUInt(&ok, 16);
if ((ok) && (code > 31))
@@ -467,7 +461,7 @@
if (e->type() == QEvent::LanguageChange)
{
Ui::CharSelectEnhanced::retranslateUi(this);
- int i=rangeSelector->currentIndex();
+ int i = rangeSelector->currentIndex();
setupRangeCombo();
disconnect(rangeSelector, SIGNAL(activated(int)), this, SLOT(newCharClass(int)));
rangeSelector->setCurrentIndex(i);
Modified: trunk/Scribus/scribus/ui/charselectenhanced.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25030&path=/trunk/Scribus/scribus/ui/charselectenhanced.h
==============================================================================
--- trunk/Scribus/scribus/ui/charselectenhanced.h (original)
+++ trunk/Scribus/scribus/ui/charselectenhanced.h Sun Mar 13 01:30:02 2022
@@ -23,7 +23,7 @@
public:
CharSelectEnhanced(QWidget* parent);
- ~CharSelectEnhanced();
+ ~CharSelectEnhanced() = default;
void setDoc(ScribusDoc* doc);
QString getUsedFont();
@@ -46,11 +46,11 @@
void changeEvent(QEvent *e) override;
private:
- ScribusDoc* m_doc;
+ ScribusDoc* m_doc { nullptr };
//! \brief Current font name
QString m_fontInUse;
//! \brief Currently selected character category. See usedCharClasses.
- int m_characterClass;
+ int m_characterClass { 0 };
//! \brief m_charTable model
CharTableModel * m_charTableModel;
More information about the scribus-commit
mailing list