-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework interaction energy infodocuments (WIP), remove build cache for…
… gh actions
- Loading branch information
1 parent
674795d
commit df52e60
Showing
15 changed files
with
363 additions
and
970 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include "infotable.h" | ||
#include <QTextTableFormat> | ||
#include <QTextCharFormat> | ||
#include <QTextBlockFormat> | ||
|
||
InfoTable::InfoTable(QTextCursor& cursor, int rows, int cols) | ||
{ | ||
QTextTableFormat format; | ||
format.setCellPadding(5.0); | ||
format.setBorderStyle(QTextFrameFormat::BorderStyle_None); | ||
format.setCellSpacing(-1.0); | ||
format.setBorder(1.0); | ||
|
||
m_table = cursor.insertTable(rows, cols, format); | ||
} | ||
|
||
InfoTable::~InfoTable() | ||
{ | ||
// The QTextTable object is owned by the QTextDocument, | ||
// so we don't need to delete it here. | ||
} | ||
|
||
void InfoTable::insertTableHeader(const QStringList& tableHeader) | ||
{ | ||
const int row = 0; | ||
QTextCharFormat format; | ||
format.setFontWeight(QFont::Bold); | ||
|
||
for (int column = 0; column < tableHeader.size() && column < m_table->columns(); ++column) { | ||
QTextCursor cursor = getCellCursor(row, column); | ||
cursor.setCharFormat(format); | ||
cursor.insertText(tableHeader[column]); | ||
} | ||
} | ||
|
||
void InfoTable::insertColorBlock(int row, int column, const QColor& color) | ||
{ | ||
if (!color.isValid()) { | ||
return; | ||
} | ||
|
||
QTextTableCell cell = m_table->cellAt(row, column); | ||
QTextCharFormat format = cell.format(); | ||
format.setBackground(color); | ||
cell.setFormat(format); | ||
|
||
QTextCursor cursor = getCellCursor(row, column); | ||
cursor.insertText(" "); | ||
} | ||
|
||
void InfoTable::insertCellValue(int row, int column, const QString& valueString, Qt::Alignment alignment) | ||
{ | ||
QTextCursor cursor = getCellCursor(row, column); | ||
QTextBlockFormat blockFormat = cursor.blockFormat(); | ||
|
||
// Preserve vertical alignment | ||
Qt::Alignment vertAlign = blockFormat.alignment() & Qt::AlignVertical_Mask; | ||
Qt::Alignment combAlign = alignment | vertAlign; | ||
|
||
blockFormat.setAlignment(combAlign); | ||
cursor.setBlockFormat(blockFormat); | ||
cursor.insertText(valueString); | ||
} | ||
|
||
QTextCursor InfoTable::getCellCursor(int row, int column) const | ||
{ | ||
return m_table->cellAt(row, column).firstCursorPosition(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
#include <QTextTable> | ||
#include <QTextCursor> | ||
#include <QStringList> | ||
#include <QColor> | ||
|
||
class InfoTable { | ||
public: | ||
InfoTable(QTextCursor& cursor, int rows, int cols); | ||
~InfoTable(); | ||
|
||
void insertTableHeader(const QStringList& tableHeader); | ||
void insertColorBlock(int row, int column, const QColor& color); | ||
void insertCellValue(int row, int column, const QString& valueString, Qt::Alignment alignment = Qt::AlignLeft); | ||
|
||
QTextTable* table() const { return m_table; } | ||
|
||
private: | ||
QTextCursor getCellCursor(int row, int column) const; | ||
QTextTable* m_table; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.