Commit 71de5525 authored by Glen Ditchfield's avatar Glen Ditchfield 🐛 Committed by Glen Ditchfield
Browse files

Move drawJournal() to the only class that might call it.

parent fa779e9a
Pipeline #69116 passed with stage
in 6 minutes and 1 second
......@@ -2154,48 +2154,6 @@ void CalPrintPluginBase::drawTextLines(QPainter &p, const QString &entry, int x,
}
}
void CalPrintPluginBase::drawJournal(const KCalendarCore::Journal::Ptr &journal, QPainter &p, int x, int &y, int width, int pageHeight)
{
QFont oldFont(p.font());
p.setFont(QFont(QStringLiteral("sans-serif"), 15));
QString headerText;
QString dateText(QLocale::system().toString(journal->dtStart().toLocalTime().date(), QLocale::LongFormat));
if (journal->summary().isEmpty()) {
headerText = dateText;
} else {
headerText = i18nc("Description - date", "%1 - %2", journal->summary(), dateText);
}
QRect rect(p.boundingRect(x, y, width, -1, Qt::TextWordWrap, headerText));
if (rect.bottom() > pageHeight) {
if (mPrintFooter) {
drawFooter(p, {0, pageHeight, width, footerHeight()});
}
// Start new page...
y = 0;
mPrinter->newPage();
rect = p.boundingRect(x, y, width, -1, Qt::TextWordWrap, headerText);
}
QRect newrect;
p.drawText(rect, Qt::TextWordWrap, headerText, &newrect);
p.setFont(oldFont);
y = newrect.bottom() + 4;
p.drawLine(x + 3, y, x + width - 6, y);
y += 5;
if (!(journal->organizer().fullName().isEmpty())) {
drawTextLines(p, i18n("Person: %1", journal->organizer().fullName()), x, y, width, pageHeight, false);
y += 7;
}
if (!(journal->description().isEmpty())) {
drawTextLines(p, journal->description(), x, y, width, pageHeight, journal->descriptionIsRich());
y += 7;
}
y += 10;
}
void CalPrintPluginBase::drawSplitHeaderRight(QPainter &p, QDate fd, QDate td, QDate, int width, int height)
{
QFont oldFont(p.font());
......
......@@ -623,20 +623,6 @@ public:
const KCalendarCore::Todo::List &todoList,
TodoParentStart *r);
/**
Draws single journal item.
Obeys configuration options #mExcludeConfidential, #excludePrivate.
@param journal The item to be printed.
@param p QPainter of the printout
@param x x-coordinate of the upper left coordinate of the first item
@param y y-coordinate of the upper left coordinate of the first item
@param width width of the whole list
@param pageHeight Total height allowed for the list on a page. If an item
would be below that line, a new page is started.
*/
void drawJournal(const KCalendarCore::Journal::Ptr &journal, QPainter &p, int x, int &y, int width, int pageHeight);
/**
Draws text lines splitting on page boundaries.
@param p QPainter of the printout
......
......@@ -89,6 +89,48 @@ void CalPrintJournal::setDateRange(const QDate &from, const QDate &to)
}
}
void CalPrintJournal::drawJournal(const KCalendarCore::Journal::Ptr &journal, QPainter &p, int x, int &y, int width, int pageHeight)
{
QFont oldFont(p.font());
p.setFont(QFont(QStringLiteral("sans-serif"), 15));
QString headerText;
QString dateText(QLocale::system().toString(journal->dtStart().toLocalTime().date(), QLocale::LongFormat));
if (journal->summary().isEmpty()) {
headerText = dateText;
} else {
headerText = i18nc("Description - date", "%1 - %2", journal->summary(), dateText);
}
QRect rect(p.boundingRect(x, y, width, -1, Qt::TextWordWrap, headerText));
if (rect.bottom() > pageHeight) {
if (mPrintFooter) {
drawFooter(p, {0, pageHeight, width, footerHeight()});
}
// Start new page...
y = 0;
mPrinter->newPage();
rect = p.boundingRect(x, y, width, -1, Qt::TextWordWrap, headerText);
}
QRect newrect;
p.drawText(rect, Qt::TextWordWrap, headerText, &newrect);
p.setFont(oldFont);
y = newrect.bottom() + 4;
p.drawLine(x + 3, y, x + width - 6, y);
y += 5;
if (!(journal->organizer().fullName().isEmpty())) {
drawTextLines(p, i18n("Person: %1", journal->organizer().fullName()), x, y, width, pageHeight, false);
y += 7;
}
if (!(journal->description().isEmpty())) {
drawTextLines(p, journal->description(), x, y, width, pageHeight, journal->descriptionIsRich());
y += 7;
}
y += 10;
}
void CalPrintJournal::print(QPainter &p, int width, int height)
{
int x = 0, y = 0;
......
......@@ -59,6 +59,20 @@ public:
void setDateRange(const QDate &from, const QDate &to) override;
protected:
/**
Draws single journal item.
Obeys configuration options #mExcludeConfidential, #excludePrivate.
@param journal The item to be printed.
@param p QPainter of the printout
@param x x-coordinate of the upper left coordinate of the first item
@param y y-coordinate of the upper left coordinate of the first item
@param width width of the whole list
@param pageHeight Total height allowed for the list on a page. If an item
would be below that line, a new page is started.
*/
void drawJournal(const KCalendarCore::Journal::Ptr &journal, QPainter &p, int x, int &y, int width, int pageHeight);
bool mUseDateRange;
};
......
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