Paint empty result cells gray
This commit is contained in:
parent
6eb585b08c
commit
c8bd1bbdb8
6 changed files with 53 additions and 36 deletions
|
@ -191,32 +191,6 @@ void CheckableTestModel::printSummaryTo(QTextCursor &cursor) const
|
|||
setCellNumber(*table, 0, 3, getPoints());
|
||||
}
|
||||
|
||||
void CheckableTestModel::setCellText(QTextTable &table, int row, int column, const QString &text)
|
||||
{
|
||||
auto cell = table.cellAt(row, column);
|
||||
auto textCursor = cell.firstCursorPosition();
|
||||
|
||||
auto blockFormat = textCursor.blockFormat();
|
||||
blockFormat.setAlignment(Qt::AlignCenter);
|
||||
textCursor.setBlockFormat(blockFormat);
|
||||
|
||||
auto cellFormat = cell.format();
|
||||
cellFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
|
||||
cell.setFormat(cellFormat);
|
||||
|
||||
auto charFormat = textCursor.charFormat();
|
||||
charFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
|
||||
charFormat.setFontPointSize(8);
|
||||
textCursor.setCharFormat(charFormat);
|
||||
|
||||
textCursor.insertText(text);
|
||||
}
|
||||
|
||||
void CheckableTestModel::setCellChecked(QTextTable &table, int row, int column, bool check)
|
||||
{
|
||||
setCellText(table, row, column, check ? "x" : "\u2610");
|
||||
}
|
||||
|
||||
CheckableItems &CheckableTestModel::getItems(const QModelIndex &index)
|
||||
{
|
||||
if (index.row() < m_tests.size())
|
||||
|
|
|
@ -40,15 +40,6 @@ protected:
|
|||
virtual void printTableTo(QTextCursor &cursor) const;
|
||||
virtual void printSummaryTo(QTextCursor &cursor) const;
|
||||
|
||||
static void setCellText(QTextTable &table, int row, int column, const QString &text);
|
||||
static void setCellChecked(QTextTable &table, int row, int column, bool check);
|
||||
|
||||
template <typename NumberType>
|
||||
static void setCellNumber(QTextTable &table, int row, int column, const NumberType &number)
|
||||
{
|
||||
setCellText(table, row, column, QString::number(number));
|
||||
}
|
||||
|
||||
private:
|
||||
CheckableItems &getItems(const QModelIndex &index);
|
||||
const CheckableItems &getItems(const QModelIndex &index) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue