Commit b4193fac authored by Nicolas Fella's avatar Nicolas Fella

Port away from deprecated QPrinter functions

This implies changing from QPrinter::Orientation to QPageLayout::Orientation. The actual values are the same tough.
parent 60d63759
Pipeline #33705 passed with stage
in 22 minutes and 2 seconds
...@@ -805,7 +805,7 @@ void CalPrintDay::print(QPainter &p, int width, int height) ...@@ -805,7 +805,7 @@ void CalPrintDay::print(QPainter &p, int width, int height)
QString line1 = local.toString(mFromDate, QLocale::ShortFormat); QString line1 = local.toString(mFromDate, QLocale::ShortFormat);
QString line2 = local.toString(mToDate, QLocale::ShortFormat); QString line2 = local.toString(mToDate, QLocale::ShortFormat);
QString title; QString title;
if (orientation() == QPrinter::Landscape) { if (orientation() == QPageLayout::Landscape) {
title = i18nc("date from-to", "%1 - %2", line1, line2); title = i18nc("date from-to", "%1 - %2", line1, line2);
} else { } else {
title = i18nc("date from-\nto", "%1 -\n%2", line1, line2); title = i18nc("date from-\nto", "%1 -\n%2", line1, line2);
...@@ -1050,14 +1050,14 @@ void CalPrintWeek::saveConfig() ...@@ -1050,14 +1050,14 @@ void CalPrintWeek::saveConfig()
} }
} }
QPrinter::Orientation CalPrintWeek::defaultOrientation() const QPageLayout::Orientation CalPrintWeek::defaultOrientation() const
{ {
if (mWeekPrintType == Filofax) { if (mWeekPrintType == Filofax) {
return QPrinter::Portrait; return QPageLayout::Portrait;
} else if (mWeekPrintType == SplitWeek) { } else if (mWeekPrintType == SplitWeek) {
return QPrinter::Portrait; return QPageLayout::Portrait;
} else { } else {
return QPrinter::Landscape; return QPageLayout::Landscape;
} }
} }
...@@ -1099,7 +1099,7 @@ void CalPrintWeek::print(QPainter &p, int width, int height) ...@@ -1099,7 +1099,7 @@ void CalPrintWeek::print(QPainter &p, int width, int height)
do { do {
line1 = local.toString(curWeek.addDays(-6), QLocale::ShortFormat); line1 = local.toString(curWeek.addDays(-6), QLocale::ShortFormat);
line2 = local.toString(curWeek, QLocale::ShortFormat); line2 = local.toString(curWeek, QLocale::ShortFormat);
if (orientation() == QPrinter::Landscape) { if (orientation() == QPageLayout::Landscape) {
title = i18nc("date from-to", "%1 - %2", line1, line2); title = i18nc("date from-to", "%1 - %2", line1, line2);
} else { } else {
title = i18nc("date from-\nto", "%1 -\n%2", line1, line2); title = i18nc("date from-\nto", "%1 -\n%2", line1, line2);
...@@ -1126,7 +1126,7 @@ void CalPrintWeek::print(QPainter &p, int width, int height) ...@@ -1126,7 +1126,7 @@ void CalPrintWeek::print(QPainter &p, int width, int height)
do { do {
line1 = local.toString(curWeek.addDays(-6), QLocale::ShortFormat); line1 = local.toString(curWeek.addDays(-6), QLocale::ShortFormat);
line2 = local.toString(curWeek, QLocale::ShortFormat); line2 = local.toString(curWeek, QLocale::ShortFormat);
if (orientation() == QPrinter::Landscape) { if (orientation() == QPageLayout::Landscape) {
title = i18nc("date from - to (week number)", "%1 - %2 (Week %3)", title = i18nc("date from - to (week number)", "%1 - %2 (Week %3)",
line1, line2, curWeek.weekNumber()); line1, line2, curWeek.weekNumber());
} else { } else {
......
...@@ -53,9 +53,9 @@ public: ...@@ -53,9 +53,9 @@ public:
} }
QWidget *createConfigWidget(QWidget *) override; QWidget *createConfigWidget(QWidget *) override;
Q_REQUIRED_RESULT QPrinter::Orientation defaultOrientation() const override Q_REQUIRED_RESULT QPageLayout::Orientation defaultOrientation() const override
{ {
return QPrinter::Portrait; return QPageLayout::Portrait;
} }
public: public:
...@@ -166,7 +166,7 @@ public: ...@@ -166,7 +166,7 @@ public:
/** /**
Returns the default orientation for the eWeekPrintType. Returns the default orientation for the eWeekPrintType.
*/ */
QPrinter::Orientation defaultOrientation() const override; QPageLayout::Orientation defaultOrientation() const override;
public: public:
void print(QPainter &p, int width, int height) override; void print(QPainter &p, int width, int height) override;
...@@ -222,9 +222,9 @@ public: ...@@ -222,9 +222,9 @@ public:
} }
QWidget *createConfigWidget(QWidget *) override; QWidget *createConfigWidget(QWidget *) override;
QPrinter::Orientation defaultOrientation() const override QPageLayout::Orientation defaultOrientation() const override
{ {
return QPrinter::Landscape; return QPageLayout::Landscape;
} }
public: public:
......
...@@ -126,13 +126,13 @@ void CalPrinter::doPrint(PrintPlugin *selectedStyle, CalPrinter::ePrintOrientati ...@@ -126,13 +126,13 @@ void CalPrinter::doPrint(PrintPlugin *selectedStyle, CalPrinter::ePrintOrientati
QPrinter printer; QPrinter printer;
switch (dlgorientation) { switch (dlgorientation) {
case eOrientPlugin: case eOrientPlugin:
printer.setOrientation(selectedStyle->defaultOrientation()); printer.setPageOrientation(selectedStyle->defaultOrientation());
break; break;
case eOrientPortrait: case eOrientPortrait:
printer.setOrientation(QPrinter::Portrait); printer.setPageOrientation(QPageLayout::Portrait);
break; break;
case eOrientLandscape: case eOrientLandscape:
printer.setOrientation(QPrinter::Landscape); printer.setPageOrientation(QPageLayout::Landscape);
break; break;
case eOrientPrinter: case eOrientPrinter:
break; break;
......
...@@ -232,9 +232,9 @@ void CalPrintPluginBase::setPrintFooter(bool printFooter) ...@@ -232,9 +232,9 @@ void CalPrintPluginBase::setPrintFooter(bool printFooter)
mPrintFooter = printFooter; mPrintFooter = printFooter;
} }
QPrinter::Orientation CalPrintPluginBase::orientation() const QPageLayout::Orientation CalPrintPluginBase::orientation() const
{ {
return mPrinter ? mPrinter->orientation() : QPrinter::Portrait; return mPrinter ? mPrinter->pageLayout().orientation() : QPageLayout::Portrait;
} }
QColor CalPrintPluginBase::getTextColor(const QColor &c) const QColor CalPrintPluginBase::getTextColor(const QColor &c) const
...@@ -326,7 +326,7 @@ int CalPrintPluginBase::headerHeight() const ...@@ -326,7 +326,7 @@ int CalPrintPluginBase::headerHeight() const
{ {
if (mHeaderHeight >= 0) { if (mHeaderHeight >= 0) {
return mHeaderHeight; return mHeaderHeight;
} else if (orientation() == QPrinter::Portrait) { } else if (orientation() == QPageLayout::Portrait) {
return PORTRAIT_HEADER_HEIGHT; return PORTRAIT_HEADER_HEIGHT;
} else { } else {
return LANDSCAPE_HEADER_HEIGHT; return LANDSCAPE_HEADER_HEIGHT;
...@@ -356,7 +356,7 @@ int CalPrintPluginBase::footerHeight() const ...@@ -356,7 +356,7 @@ int CalPrintPluginBase::footerHeight() const
if (mFooterHeight >= 0) { if (mFooterHeight >= 0) {
return mFooterHeight; return mFooterHeight;
} else if (orientation() == QPrinter::Portrait) { } else if (orientation() == QPageLayout::Portrait) {
return PORTRAIT_FOOTER_HEIGHT; return PORTRAIT_FOOTER_HEIGHT;
} else { } else {
return LANDSCAPE_FOOTER_HEIGHT; return LANDSCAPE_FOOTER_HEIGHT;
......
...@@ -108,7 +108,7 @@ public: ...@@ -108,7 +108,7 @@ public:
*/ */
static int weekdayColumn(int weekday); static int weekdayColumn(int weekday);
QPrinter::Orientation orientation() const; QPageLayout::Orientation orientation() const;
/** Returns the height of the page header. If the height was explicitly /** Returns the height of the page header. If the height was explicitly
set using setHeaderHeight, that value is returned, otherwise a set using setHeaderHeight, that value is returned, otherwise a
......
...@@ -140,9 +140,9 @@ public: ...@@ -140,9 +140,9 @@ public:
config settings), implement this function in your subclass and config settings), implement this function in your subclass and
return the desired orientation. return the desired orientation.
*/ */
virtual QPrinter::Orientation defaultOrientation() const virtual QPageLayout::Orientation defaultOrientation() const
{ {
return QPrinter::Portrait; return QPageLayout::Portrait;
} }
/** /**
......
...@@ -82,9 +82,9 @@ void CalPrintYear::saveConfig() ...@@ -82,9 +82,9 @@ void CalPrintYear::saveConfig()
} }
} }
QPrinter::Orientation CalPrintYear::defaultOrientation() const QPageLayout::Orientation CalPrintYear::defaultOrientation() const
{ {
return (mPages == 1) ? QPrinter::Landscape : QPrinter::Portrait; return (mPages == 1) ? QPageLayout::Landscape : QPageLayout::Portrait;
} }
void CalPrintYear::setDateRange(const QDate &from, const QDate &to) void CalPrintYear::setDateRange(const QDate &from, const QDate &to)
...@@ -131,7 +131,7 @@ void CalPrintYear::print(QPainter &p, int width, int height) ...@@ -131,7 +131,7 @@ void CalPrintYear::print(QPainter &p, int width, int height)
QString stdate = locale.toString(start, QLocale::ShortFormat); QString stdate = locale.toString(start, QLocale::ShortFormat);
QString endate = locale.toString(end, QLocale::ShortFormat); QString endate = locale.toString(end, QLocale::ShortFormat);
QString title; QString title;
if (orientation() == QPrinter::Landscape) { if (orientation() == QPageLayout::Landscape) {
title = i18nc("date from - to", "%1 - %2", stdate, endate); title = i18nc("date from - to", "%1 - %2", stdate, endate);
} else { } else {
title = i18nc("date from -\nto", "%1 -\n%2", stdate, endate); title = i18nc("date from -\nto", "%1 -\n%2", stdate, endate);
......
...@@ -48,7 +48,7 @@ public: ...@@ -48,7 +48,7 @@ public:
} }
QWidget *createConfigWidget(QWidget *) override; QWidget *createConfigWidget(QWidget *) override;
Q_REQUIRED_RESULT QPrinter::Orientation defaultOrientation() const override; Q_REQUIRED_RESULT QPageLayout::Orientation defaultOrientation() const override;
public: public:
void print(QPainter &p, int width, int height) override; void print(QPainter &p, int width, int height) override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment