Commit 823b53dc authored by Glen Ditchfield's avatar Glen Ditchfield 🐛
Browse files

Merge branch 'release/21.04'

parents 6a9459cc 24c4ece0
Pipeline #63522 passed with stage
in 6 minutes and 31 seconds
......@@ -1497,11 +1497,8 @@ void CalPrintTodos::saveConfig()
void CalPrintTodos::print(QPainter &p, int width, int height)
{
// TODO: Find a good way to guarantee a nicely designed output
int pospriority = 0;
int possummary = 100;
int posdue = width - 65;
int poscomplete = posdue - 70; // Complete column is to right of the Due column
QRect headerBox(0, 0, width, headerHeight());
QRect footerBox(0, height - footerHeight(), width, footerHeight());
......@@ -1510,10 +1507,15 @@ void CalPrintTodos::print(QPainter &p, int width, int height)
// Draw the First Page Header
drawHeader(p, mPageTitle, mFromDate, QDate(), headerBox);
// Estimate widths of some data columns.
QFont oldFont(p.font());
p.setFont(QFont(QStringLiteral("sans-serif"), 10));
const int widDate = p.fontMetrics().boundingRect(QLocale::system().toString(QDate(2222, 12, 22), QLocale::ShortFormat)).width();
const int widPct = p.fontMetrics().boundingRect(i18n("%1%", 100)).width() + 27;
// Draw the Column Headers
int mCurrentLinePos = headerHeight() + 5;
QString outStr;
QFont oldFont(p.font());
p.setFont(QFont(QStringLiteral("sans-serif"), 9, QFont::Bold));
int lineSpacing = p.fontMetrics().lineSpacing();
......@@ -1525,29 +1527,32 @@ void CalPrintTodos::print(QPainter &p, int width, int height)
pospriority = -1;
}
outStr.truncate(0);
outStr += i18nc("@label to-do summary", "Title");
p.drawText(possummary, mCurrentLinePos - 2, outStr);
int posdue;
if (mIncludeDueDate) {
outStr.truncate(0);
outStr += i18nc("@label to-do due date", "Due");
const int widDue = std::max(p.fontMetrics().boundingRect(outStr).width(), widDate);
posdue = width - widDue;
p.drawText(posdue, mCurrentLinePos - 2, outStr);
} else {
posdue = -1;
}
int poscomplete;
if (mIncludePercentComplete) {
if (!mIncludeDueDate) { // move Complete column to the right
poscomplete = posdue; // if not print the Due Date column
}
outStr.truncate(0);
outStr += i18nc("@label to-do percentage complete", "Complete");
const int widComplete = std::max(p.fontMetrics().boundingRect(outStr).width(), widPct);
if (!mIncludeDueDate) {
poscomplete = width - widComplete;
} else {
poscomplete = posdue - widComplete - 5;
}
p.drawText(poscomplete, mCurrentLinePos - 2, outStr);
} else {
poscomplete = -1;
}
if (mIncludeDueDate) {
outStr.truncate(0);
outStr += i18nc("@label to-do due date", "Due");
p.drawText(posdue, mCurrentLinePos - 2, outStr);
} else {
posdue = -1;
}
p.setFont(QFont(QStringLiteral("sans-serif"), 10));
// fontHeight = p.fontMetrics().height();
......
......@@ -1945,7 +1945,7 @@ void CalPrintPluginBase::drawTodo(int &count,
p.drawLine(rect.topLeft(), rect.bottomRight());
p.drawLine(rect.topRight(), rect.bottomLeft());
}
lhs = rect.right() + 3;
lhs = rect.right() + 5;
// Priority
if (todo->priority() > 0 && showPriority) {
......@@ -1992,7 +1992,7 @@ void CalPrintPluginBase::drawTodo(int &count,
bool showPercentComplete = posPercentComplete >= 0;
if (showPercentComplete) {
int lwidth = 24;
int lheight = 12;
int lheight = p.fontMetrics().ascent();
// first, draw the progress bar
int progress = static_cast<int>(((lwidth * todo->percentComplete()) / 100.0 + 0.5));
......@@ -2009,7 +2009,7 @@ void CalPrintPluginBase::drawTodo(int &count,
p.drawText(rect, Qt::AlignTop | Qt::AlignLeft, outStr);
}
y += 10;
y = newrect.bottom();
// Make a list of all the sub-to-dos related to this to-do.
KCalendarCore::Todo::List t;
......@@ -2052,10 +2052,7 @@ void CalPrintPluginBase::drawTodo(int &count,
// description
if (!todo->description().isEmpty() && desc) {
y = newrect.bottom() + 5;
drawTodoLines(p, todo->description(), left, y, width - (left + 10 - x), pageHeight, todo->descriptionIsRich(), startPoints, connectSubTodos);
} else {
y += 10;
}
// Sort the sub-to-dos and print them
......
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