本文整理汇总了C++中QTextTableFormat::setBorder方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextTableFormat::setBorder方法的具体用法?C++ QTextTableFormat::setBorder怎么用?C++ QTextTableFormat::setBorder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextTableFormat
的用法示例。
在下文中一共展示了QTextTableFormat::setBorder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printDeckListNode
void DeckListModel::printDeckListNode(QTextCursor *cursor, InnerDecklistNode *node)
{
static const int totalColumns = 3;
if (node->height() == 1) {
QTextBlockFormat blockFormat;
QTextCharFormat charFormat;
charFormat.setFontPointSize(11);
charFormat.setFontWeight(QFont::Bold);
cursor->insertBlock(blockFormat, charFormat);
cursor->insertText(QString("%1: %2").arg(node->getVisibleName()).arg(node->recursiveCount(true)));
QTextTableFormat tableFormat;
tableFormat.setCellPadding(0);
tableFormat.setCellSpacing(0);
tableFormat.setBorder(0);
QTextTable *table = cursor->insertTable(node->size() + 1, 2, tableFormat);
for (int i = 0; i < node->size(); i++) {
AbstractDecklistCardNode *card = dynamic_cast<AbstractDecklistCardNode *>(node->at(i));
QTextCharFormat cellCharFormat;
cellCharFormat.setFontPointSize(9);
QTextTableCell cell = table->cellAt(i, 0);
cell.setFormat(cellCharFormat);
QTextCursor cellCursor = cell.firstCursorPosition();
cellCursor.insertText(QString("%1 ").arg(card->getNumber()));
cell = table->cellAt(i, 1);
cell.setFormat(cellCharFormat);
cellCursor = cell.firstCursorPosition();
cellCursor.insertText(card->getName());
}
} else if (node->height() == 2) {
QTextBlockFormat blockFormat;
QTextCharFormat charFormat;
charFormat.setFontPointSize(14);
charFormat.setFontWeight(QFont::Bold);
cursor->insertBlock(blockFormat, charFormat);
cursor->insertText(QString("%1: %2").arg(node->getVisibleName()).arg(node->recursiveCount(true)));
QTextTableFormat tableFormat;
tableFormat.setCellPadding(10);
tableFormat.setCellSpacing(0);
tableFormat.setBorder(0);
QVector<QTextLength> constraints;
for (int i = 0; i < totalColumns; i++)
constraints << QTextLength(QTextLength::PercentageLength, 100.0 / totalColumns);
tableFormat.setColumnWidthConstraints(constraints);
QTextTable *table = cursor->insertTable(1, totalColumns, tableFormat);
for (int i = 0; i < node->size(); i++) {
QTextCursor cellCursor = table->cellAt(0, (i * totalColumns) / node->size()).lastCursorPosition();
printDeckListNode(&cellCursor, dynamic_cast<InnerDecklistNode *>(node->at(i)));
}
}
cursor->movePosition(QTextCursor::End);
}
示例2: onCreatetableClicked
// Действия при нажатии кнопки создания новой таблицы
void TableFormatter::onCreatetableClicked(void)
{
// Создается и запускается диалог создания новой таблицы
EditorAddTableForm dialog;
if(dialog.exec()!=QDialog::Accepted) return;
// Выясняются введенные в диалоге данные
int tableColumns=dialog.get_columns();
int tableRows=dialog.get_rows();
int tableWidth=dialog.get_width();
// Целочислительный формат ширины таблицы преобразуется в проценты
QTextLength tableWidthInPercent(QTextLength::PercentageLength, tableWidth);
// Создается форматирование таблицы
QTextTableFormat tableFormat;
tableFormat.setWidth(tableWidthInPercent);
tableFormat.setAlignment(Qt::AlignHCenter);
tableFormat.setBorder(1);
tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
tableFormat.setPadding(0);
tableFormat.setCellPadding(0);
tableFormat.setCellSpacing(-1);
// Добавляется таблица с нужными размерами и форматированием
// QTextTable *table=textarea->textCursor().insertTable(table_rows, table_columns, table_format);
textArea->textCursor().insertTable(tableRows, tableColumns, tableFormat);
return;
}
示例3: cursor
void
ChatDialog::appendChatMessage(const QString& nick, const QString& text, time_t timestamp)
{
QTextCharFormat nickFormat;
nickFormat.setForeground(Qt::darkGreen);
nickFormat.setFontWeight(QFont::Bold);
nickFormat.setFontUnderline(true);
nickFormat.setUnderlineColor(Qt::gray);
// Print who & when
QTextCursor cursor(ui->textEdit->textCursor());
cursor.movePosition(QTextCursor::End);
QTextTableFormat tableFormat;
tableFormat.setBorder(0);
QTextTable *table = cursor.insertTable(1, 2, tableFormat);
QString from = QString("%1 ").arg(nick);
QTextTableCell fromCell = table->cellAt(0, 0);
fromCell.setFormat(nickFormat);
fromCell.firstCursorPosition().insertText(from);
printTimeInCell(table, timestamp);
// Print what
QTextCursor nextCursor(ui->textEdit->textCursor());
nextCursor.movePosition(QTextCursor::End);
table = nextCursor.insertTable(1, 1, tableFormat);
table->cellAt(0, 0).firstCursorPosition().insertText(text);
// Popup notification
showMessage(from, text);
QScrollBar *bar = ui->textEdit->verticalScrollBar();
bar->setValue(bar->maximum());
}
示例4: QTextEdit
/*!
* \author Anders Fernström
* \date 2005-12-19
*
* \brief The class constructor
*
* 2006-03-03 AF, Updated function so cells are printed in tables,
* so chapter numbers can be added to the left of the text. This
* change remade large part of this function (and the rest of the
* class).
*/
PrinterVisitor::PrinterVisitor( QTextDocument* doc, QPrinter* printer )
: ignore_(false), firstChild_(true), closedCell_(0), currentTableRow_(0), printer_(printer)
{
printEditor_ = new QTextEdit();
printEditor_->setDocument( doc );
// set table format
QTextTableFormat tableFormat;
tableFormat.setBorder( 0 );
tableFormat.setColumns( 2 );
tableFormat.setCellPadding( 2 );
// do not put the constraints on the columns. If we don't have chapter numbers we want to use the full space.
// QVector<QTextLength> constraints;
// constraints << QTextLength(QTextLength::PercentageLength, 20)
// << QTextLength(QTextLength::PercentageLength, 80);
// tableFormat.setColumnWidthConstraints(constraints);
// insert the table
QTextCursor cursor = printEditor_->textCursor();
table_ = cursor.insertTable(1, 2, tableFormat);
}
示例5: visitTextCellNodeBefore
// TEXTCELL
void PrinterVisitor::visitTextCellNodeBefore(TextCell *node)
{
if( !ignore_ || firstChild_ )
{
++currentTableRow_;
table_->insertRows( currentTableRow_, 1 );
// first column
QTextTableCell tableCell( table_->cellAt( currentTableRow_, 0 ) );
if( tableCell.isValid() )
{
if( !node->ChapterCounterHtml().isNull() )
{
QTextCursor cursor( tableCell.firstCursorPosition() );
cursor.insertFragment( QTextDocumentFragment::fromHtml(
node->ChapterCounterHtml() ));
}
}
// second column
tableCell = table_->cellAt( currentTableRow_, 1 );
if( tableCell.isValid() )
{
QTextCursor cursor( tableCell.firstCursorPosition() );
if( node->isViewExpression() )
{
//view expression table
QTextTableFormat tableFormatExpression;
tableFormatExpression.setBorder( 0 );
tableFormatExpression.setColumns( 1 );
tableFormatExpression.setCellPadding( 2 );
// tableFormatExpression.setBackground( QColor(235, 235, 220) ); // 180, 180, 180
tableFormatExpression.setBackground( QColor(235, 0, 0) ); // 180, 180, 180
QVector<QTextLength> constraints;
constraints << QTextLength(QTextLength::PercentageLength, 100);
tableFormatExpression.setColumnWidthConstraints(constraints);
cursor.insertTable( 1, 1, tableFormatExpression );
// QMessageBox::information(0,"uu2", node->text());
QString html = node->textHtml();
cursor.insertFragment( QTextDocumentFragment::fromHtml( html ));
}
else
{
QString html = node->textHtml();
html.remove( "file:///" );
printEditor_->document()->setTextWidth(700);
cursor.insertFragment(QTextDocumentFragment::fromHtml( html ));
// QMessageBox::information(0, "uu3", node->text());
}
}
if( firstChild_ )
firstChild_ = false;
}
}
示例6: addTable
void CPrint::addTable(QTextCursor &cursor,int rows,int cols,QStringList headers)
{
QTextTableFormat tableFormat;
tableFormat.setBorder(1);
tableFormat.setBorderStyle(QTextTableFormat::BorderStyle_Solid);
tableFormat.setHeaderRowCount(1);
QTextTable *table=cursor.insertTable(rows+1,cols,tableFormat);
cursor.movePosition(QTextCursor::End);
}
示例7: newLetter
//! [2]
void MainWindow::newLetter()
{
textEdit->clear();
QTextCursor cursor(textEdit->textCursor());
cursor.movePosition(QTextCursor::Start);
QTextFrame *topFrame = cursor.currentFrame();
QTextFrameFormat topFrameFormat = topFrame->frameFormat();
topFrameFormat.setPadding(16);
topFrame->setFrameFormat(topFrameFormat);
QTextCharFormat textFormat;
QTextCharFormat boldFormat;
boldFormat.setFontWeight(QFont::Bold);
QTextCharFormat italicFormat;
italicFormat.setFontItalic(true);
QTextTableFormat tableFormat;
tableFormat.setBorder(1);
tableFormat.setCellPadding(16);
tableFormat.setAlignment(Qt::AlignRight);
cursor.insertTable(1, 1, tableFormat);
cursor.insertText("The Firm", boldFormat);
cursor.insertBlock();
cursor.insertText("321 City Street", textFormat);
cursor.insertBlock();
cursor.insertText("Industry Park");
cursor.insertBlock();
cursor.insertText("Some Country");
cursor.setPosition(topFrame->lastPosition());
cursor.insertText(QDate::currentDate().toString("d MMMM yyyy"), textFormat);
cursor.insertBlock();
cursor.insertBlock();
cursor.insertText("Dear ", textFormat);
cursor.insertText("NAME", italicFormat);
cursor.insertText(",", textFormat);
for (int i = 0; i < 3; ++i)
cursor.insertBlock();
cursor.insertText(tr("Yours sincerely,"), textFormat);
for (int i = 0; i < 3; ++i)
cursor.insertBlock();
cursor.insertText("The Boss", textFormat);
cursor.insertBlock();
cursor.insertText("ADDRESS", italicFormat);
}
示例8: QTextLength
void KDReports::AbstractTableElement::fillTableFormat( QTextTableFormat& tableFormat, QTextCursor& textDocCursor ) const
{
if ( d->m_width ) {
if ( d->m_unit == Millimeters ) {
tableFormat.setWidth( QTextLength( QTextLength::FixedLength, mmToPixels( d->m_width ) ) );
} else {
tableFormat.setWidth( QTextLength( QTextLength::PercentageLength, d->m_width ) );
}
}
tableFormat.setBorder( border() );
#if QT_VERSION >= 0x040300
tableFormat.setBorderBrush( borderBrush() );
tableFormat.setBorderStyle( QTextFrameFormat::BorderStyle_Solid );
#endif
tableFormat.setCellPadding( mmToPixels( padding() ) );
tableFormat.setCellSpacing( -1 ); // HTML-like table borders look so old century
if ( d->m_fontSpecified ) {
QTextCharFormat charFormat = textDocCursor.charFormat();
charFormat.setFont( d->m_defaultFont );
textDocCursor.setCharFormat( charFormat );
}
}
示例9: QTextEdit
/*!
* \author Anders Fernström
* \date 2005-12-19
*
* \brief The class constructor
*
* 2006-03-03 AF, Updated function so cells are printed in tables,
* so chapter numbers can be added to the left of the text. This
* change remade large part of this function (and the rest of the
* class).
*/
PrinterVisitor::PrinterVisitor( QTextDocument* doc, QPrinter* printer )
: ignore_(false), firstChild_(true), closedCell_(0), currentTableRow_(0), printer_(printer)
{
printEditor_ = new QTextEdit();
printEditor_->setDocument( doc );
// set table format
QTextTableFormat tableFormat;
tableFormat.setBorder( 0 );
tableFormat.setColumns( 2 );
tableFormat.setCellPadding( 5 );
QVector<QTextLength> constraints;
constraints << QTextLength(QTextLength::FixedLength, 50)
<< QTextLength(QTextLength::VariableLength, 620);
tableFormat.setColumnWidthConstraints(constraints);
// insert the table
QTextCursor cursor = printEditor_->textCursor();
table_ = cursor.insertTable(1, 2, tableFormat);
}
示例10:
QTextTable * PrintDialog::insertCategoryTable(QTextCursor & cursor, const QString & categoryName)
{
QTextBlockFormat blockCategoryTitleFormat;
blockCategoryTitleFormat.setAlignment(Qt::AlignCenter);
blockCategoryTitleFormat.setTopMargin(40.0);
blockCategoryTitleFormat.setBottomMargin(30.0);
QTextCharFormat categoryTitleFormat;
categoryTitleFormat.setFontCapitalization(QFont::AllUppercase);
categoryTitleFormat.setFontWeight(25);
categoryTitleFormat.setFontPointSize(14.0);
QString category = "Category \"";
category += categoryName;
category += "\"";
cursor.insertBlock(blockCategoryTitleFormat);
cursor.insertText(category,categoryTitleFormat);
cursor.insertBlock(QTextBlockFormat()); // to break the previous block format
QTextTable * table = cursor.insertTable(1, 4);
if(!table)
return NULL;
QTextTableFormat categoryTableFormat;
categoryTableFormat.setAlignment(Qt::AlignHCenter);
categoryTableFormat.setHeaderRowCount(1); // header line
categoryTableFormat.setBorderStyle(QTextTableFormat::BorderStyle_Solid);
categoryTableFormat.setBorder(1.0);
categoryTableFormat.setCellPadding(10);
categoryTableFormat.setCellSpacing(0);
table->setFormat(categoryTableFormat);
// header :
// header cell format :
QTextCharFormat headerCellFormat;
headerCellFormat.setFontWeight(50);
headerCellFormat.setFontPointSize(12.0);
headerCellFormat.setBackground(QBrush(QColor(60,60,60)));
headerCellFormat.setForeground(QBrush(QColor(255,255,255)));
QTextTableCell cell = table->cellAt(0,0);
cell.setFormat(headerCellFormat);
cursor = cell.firstCursorPosition();
cursor.insertText(tr("Position"));
cell = table->cellAt(0,1);
cell.setFormat(headerCellFormat);
cursor = cell.firstCursorPosition();
cursor.insertText(tr("LastName"));
cell = table->cellAt(0,2);
cell.setFormat(headerCellFormat);
cursor = cell.firstCursorPosition();
cursor.insertText(tr("Firstname"));
cell = table->cellAt(0,3);
cell.setFormat(headerCellFormat);
cursor = cell.firstCursorPosition();
cursor.insertText(tr("Time"));
return table;
}
示例11: draw
void CDiaryEdit::draw(QTextDocument& doc)
{
CDiaryEditLock lock(this);
QFontMetrics fm(QFont(font().family(),10));
bool hasGeoCaches = false;
int cnt;
int w = doc.textWidth();
int pointSize = ((10 * (w - 2 * ROOT_FRAME_MARGIN)) / (CHAR_PER_LINE * fm.width("X")));
if(pointSize == 0) return;
doc.setUndoRedoEnabled(false);
QFont f = textEdit->font();
f.setPointSize(pointSize);
textEdit->setFont(f);
QTextCharFormat fmtCharHeading1;
fmtCharHeading1.setFont(f);
fmtCharHeading1.setFontWeight(QFont::Black);
fmtCharHeading1.setFontPointSize(f.pointSize() + 8);
QTextCharFormat fmtCharHeading2;
fmtCharHeading2.setFont(f);
fmtCharHeading2.setFontWeight(QFont::Black);
fmtCharHeading2.setFontPointSize(f.pointSize() + 4);
QTextCharFormat fmtCharStandard;
fmtCharStandard.setFont(f);
QTextCharFormat fmtCharHeader;
fmtCharHeader.setFont(f);
fmtCharHeader.setBackground(Qt::darkBlue);
fmtCharHeader.setFontWeight(QFont::Bold);
fmtCharHeader.setForeground(Qt::white);
QTextBlockFormat fmtBlockStandard;
fmtBlockStandard.setTopMargin(10);
fmtBlockStandard.setBottomMargin(10);
fmtBlockStandard.setAlignment(Qt::AlignJustify);
QTextFrameFormat fmtFrameStandard;
fmtFrameStandard.setTopMargin(5);
fmtFrameStandard.setBottomMargin(5);
fmtFrameStandard.setWidth(w - 2 * ROOT_FRAME_MARGIN);
QTextFrameFormat fmtFrameRoot;
fmtFrameRoot.setTopMargin(ROOT_FRAME_MARGIN);
fmtFrameRoot.setBottomMargin(ROOT_FRAME_MARGIN);
fmtFrameRoot.setLeftMargin(ROOT_FRAME_MARGIN);
fmtFrameRoot.setRightMargin(ROOT_FRAME_MARGIN);
QTextTableFormat fmtTableStandard;
fmtTableStandard.setBorder(1);
fmtTableStandard.setBorderBrush(Qt::black);
fmtTableStandard.setCellPadding(4);
fmtTableStandard.setCellSpacing(0);
fmtTableStandard.setHeaderRowCount(1);
fmtTableStandard.setTopMargin(10);
fmtTableStandard.setBottomMargin(20);
fmtTableStandard.setWidth(w - 2 * ROOT_FRAME_MARGIN);
QVector<QTextLength> constraints;
constraints << QTextLength(QTextLength::FixedLength, 32);
constraints << QTextLength(QTextLength::VariableLength, 50);
constraints << QTextLength(QTextLength::VariableLength, 100);
fmtTableStandard.setColumnWidthConstraints(constraints);
doc.rootFrame()->setFrameFormat(fmtFrameRoot);
QTextCursor cursor = doc.rootFrame()->firstCursorPosition();
cursor.insertText(diary.getName(), fmtCharHeading1);
cursor.setCharFormat(fmtCharStandard);
cursor.setBlockFormat(fmtBlockStandard);
diary.diaryFrame = cursor.insertFrame(fmtFrameStandard);
{
QTextCursor cursor1(diary.diaryFrame);
cursor1.setCharFormat(fmtCharStandard);
cursor1.setBlockFormat(fmtBlockStandard);
if(diary.getComment().isEmpty())
{
cursor1.insertText(tr("Add your own text here..."));
}
else
{
cursor1.insertHtml(diary.getComment());
}
cursor.setPosition(cursor1.position()+1);
}
if(!diary.getWpts().isEmpty())
{
QList<CWpt*>& wpts = diary.getWpts();
cursor.insertText(tr("Waypoints"),fmtCharHeading2);
QTextTable * table = cursor.insertTable(wpts.count()+1, eMax, fmtTableStandard);
//.........这里部分代码省略.........
示例12: printCalc
void CalcFrame::printCalc()
{
const auto milkReception = m_mainWindow->database()->milkReception();
if (!milkReception) {
Utils::Main::showMsgIfDbNotChoosed(this);
return;
}
DataWorker dw(m_mainWindow->database());
try {
dw.loadMilkReceptions(getWhereQuery());
} catch (const QString &err) {
QMessageBox::critical(this, tr("Расчеты"), tr("Произошла ошибка во время подгрузки данных: ") + err);
}
const auto deliverers = dw.getDeliverers().values();
if (deliverers.isEmpty())
{
QMessageBox::information(this, tr("Печать"), tr("Отсутствуют данные для печати"));
return;
}
const char f = 'f';
int row = 0;
const auto settings = m_mainWindow->getSettings();
const auto printColumns = m_mainWindow->getSettings()->getPrint().columns;
QStringList columns;
for (int i = 0; i < printColumns.size(); ++i) {
const auto &col = printColumns[i];
if (col.isShow)
columns.append(printColumns[i].display);
}
const int columnsCount = columns.size();
if (columnsCount <= 0) {
QMessageBox::information(this, tr("Печать сдачи молока"), tr("Не выбрана ни одна колонка для печати"));
return;
}
const Settings::Column snCol = printColumns[Constants::PrintColumns::SerialNumber],
delivNameCol = printColumns[Constants::PrintColumns::DeliverersName],
litersCol = printColumns[Constants::PrintColumns::Liters],
fatCol = printColumns[Constants::PrintColumns::Fat],
proteinCol = printColumns[Constants::PrintColumns::Protein],
fatUnitsCol = printColumns[Constants::PrintColumns::FatUnits],
rankWeightCol = printColumns[Constants::PrintColumns::RankWeight],
payCol = printColumns[Constants::PrintColumns::PayWithOutPrem],
permiumCol = printColumns[Constants::PrintColumns::Premium],
sumCol = printColumns[Constants::PrintColumns::Sum],
signCol = printColumns[Constants::PrintColumns::Sign];
auto itemToPrintRow = [&](const QString &delivName, const CalculatedItem::Data &item,
const int rowPos = -1) -> QStringList
{
QStringList row;
if (snCol.isShow)
row.append(rowPos >= 0 ? QString::number(rowPos) : QString());
if (delivNameCol.isShow)
row.append(delivName);
if (litersCol.isShow)
row.append(QString::number(item.liters, f, litersCol.prec));
if (fatCol.isShow)
row.append(QString::number(item.fat, f, fatCol.prec));
if (proteinCol.isShow)
row.append(QString::number(item.protein, f, proteinCol.prec));
if (fatUnitsCol.isShow)
row.append(QString::number(item.fatUnits, f, fatCol.prec));
if (rankWeightCol.isShow)
row.append(QString::number(item.rankWeight, f, rankWeightCol.prec));
if (payCol.isShow)
row.append(QString::number(item.paymentWithOutPremium, f, payCol.prec));
if (permiumCol.isShow)
row.append(QString::number(item.premiumForFat, f, permiumCol.prec));
if (sumCol.isShow)
row.append(QString::number(floor(item.sum), f, sumCol.prec));
if (signCol.isShow)
row.append(QString());
return row;
};
const auto &printSettings = settings->getPrint();
QTextTableFormat tableFormat;
tableFormat.setBorder(printSettings.tableBorderWidth);
tableFormat.setBorderStyle(static_cast<QTextFrameFormat::BorderStyle>(printSettings.tableBorderStyle));
tableFormat.setColumns(columnsCount);
tableFormat.setAlignment(Qt::AlignHCenter);
tableFormat.setWidth(QTextLength(QTextLength::VariableLength, 100));
tableFormat.setBorderBrush(QBrush(printSettings.tableBorderColor));
tableFormat.setCellSpacing(printSettings.cellSpacing);
tableFormat.setCellPadding(printSettings.cellPadding);
PrintTable print(columnsCount, tableFormat);
{
auto &textFormat = print.getTableBodyTextFormat();
textFormat.setFont(printSettings.tableTextFont);
textFormat.setForeground(QBrush(printSettings.tableTextColor));
//.........这里部分代码省略.........
示例13: visitLatexCellNodeBefore
void PrinterVisitor::visitLatexCellNodeBefore(LatexCell *node)
{
if( !ignore_ || firstChild_ )
{
++currentTableRow_;
table_->insertRows( currentTableRow_, 1 );
// first column
QTextTableCell tableCell( table_->cellAt( currentTableRow_, 0 ) );
if( tableCell.isValid() )
{
if( !node->ChapterCounterHtml().isNull() )
{
QTextCursor cursor( tableCell.firstCursorPosition() );
cursor.insertFragment( QTextDocumentFragment::fromHtml(
node->ChapterCounterHtml() ));
}
}
// second column
tableCell = table_->cellAt( currentTableRow_, 1 );
if( tableCell.isValid() )
{
QTextCursor cursor( tableCell.firstCursorPosition() );
// input table
QTextTableFormat tableFormatInput;
tableFormatInput.setBorder( 0 );
tableFormatInput.setMargin( 6 );
tableFormatInput.setColumns( 1 );
tableFormatInput.setCellPadding( 8 );
tableFormatInput.setBackground( QColor(245, 245, 255) ); // 200, 200, 255
QVector<QTextLength> constraints;
constraints << QTextLength(QTextLength::PercentageLength, 100);
tableFormatInput.setColumnWidthConstraints(constraints);
cursor.insertTable( 1, 1, tableFormatInput );
QString html = node->textHtml();
html += "<br>";
if( !node->isEvaluated() || node->isClosed() )
html += "<br>";
cursor.insertFragment( QTextDocumentFragment::fromHtml( html ));
if( node->isEvaluated() && !node->isClosed() )
{
QTextTableFormat tableFormatOutput;
tableFormatOutput.setBorder( 0 );
tableFormatOutput.setMargin( 6 );
tableFormatOutput.setColumns( 1 );
tableFormatOutput.setCellPadding( 8 );
QVector<QTextLength> constraints;
constraints << QTextLength(QTextLength::PercentageLength, 100);
tableFormatOutput.setColumnWidthConstraints(constraints);
cursor = tableCell.lastCursorPosition();
cursor.insertTable( 1, 1, tableFormatOutput );
QString outputHtml( node->textOutputHtml() );
outputHtml += "<br><br>";
outputHtml.remove( "file:///" );
cursor.insertFragment( QTextDocumentFragment::fromHtml( outputHtml ));
}
}
if( firstChild_ )
firstChild_ = false;
}
}
示例14: generaReporte
void FormSimularCuotas::generaReporte()
{
documento = new QTextDocument();
QTextCursor cursor( documento );
int cant_filas = 3 + SBCantidad->value();
QTextTable *tabla = cursor.insertTable( cant_filas, 5 );
QTextTableFormat formatoTabla = tabla->format();
formatoTabla.setHeaderRowCount( 1 );
formatoTabla.setWidth( QTextLength( QTextLength::PercentageLength, 100 ) );
formatoTabla.setBorderStyle( QTextFrameFormat::BorderStyle_Solid );
formatoTabla.setBorder( 1 );
formatoTabla.setCellPadding( 3 );
formatoTabla.setCellSpacing( 0 );
tabla->setFormat( formatoTabla );
tabla->cellAt( 0,0 ).firstCursorPosition().insertHtml( "<b> # Cuota</b>" );
tabla->cellAt( 0,1 ).firstCursorPosition().insertHtml( "<b> Fecha de pago </b>" );
tabla->cellAt( 0,2 ).firstCursorPosition().insertHtml( "<b> Cuota </b>" );
tabla->cellAt( 0,3 ).firstCursorPosition().insertHtml( "<b> Pagado </b> " );
tabla->cellAt( 0,4 ).firstCursorPosition().insertHtml( "<b> Subtotal </b>" );
QTextBlockFormat bfizq = tabla->cellAt( 0, 3 ).firstCursorPosition().blockFormat();
bfizq.setAlignment( Qt::AlignRight );
// Ingreso los datos
double subtotal = DSBImporte->value();
double pagado = DSBEntrega->value();
// Importe
tabla->cellAt( 1, 0 ).firstCursorPosition().insertHtml( " " );
tabla->cellAt( 1, 1 ).firstCursorPosition().insertHtml( "Importe a pagar en cuotas" );
tabla->cellAt( 1, 2 ).firstCursorPosition().setBlockFormat( bfizq );
tabla->cellAt( 1, 2 ).firstCursorPosition().insertHtml( QString( "$ %L1" ).arg( subtotal, 10, 'f', 2 ) );
tabla->cellAt( 1, 3 ).firstCursorPosition().setBlockFormat( bfizq );
tabla->cellAt( 1, 3 ).firstCursorPosition().insertHtml( QString( "$ %L1" ).arg( 0.0, 10, 'f', 2 ) );
tabla->cellAt( 1, 4 ).firstCursorPosition().setBlockFormat( bfizq );
tabla->cellAt( 1, 4 ).firstCursorPosition().insertHtml( QString( "$ %L1" ).arg( subtotal, 10, 'f', 2 ) );
subtotal -= DSBEntrega->value();
tabla->cellAt( 2, 0 ).firstCursorPosition().insertHtml( "" );
tabla->cellAt( 2, 1 ).firstCursorPosition().insertHtml( "Entrega inicial" );
tabla->cellAt( 2, 2 ).firstCursorPosition().setBlockFormat( bfizq );
tabla->cellAt( 2, 2 ).firstCursorPosition().insertHtml( QString( "$ %L1" ).arg( DSBEntrega->value(), 10, 'f', 2 ) );
tabla->cellAt( 2, 3 ).firstCursorPosition().setBlockFormat( bfizq );
tabla->cellAt( 2, 3 ).firstCursorPosition().insertHtml( QString( "$ %L1" ).arg( pagado, 10, 'f', 2 ) );
tabla->cellAt( 2, 4 ).firstCursorPosition().setBlockFormat( bfizq );
tabla->cellAt( 2, 4 ).firstCursorPosition().insertHtml( QString( "$ %L1" ).arg( subtotal, 10, 'f', 2 ) );
subtotal *= ( 1 + DSBInteres->value() / 100 );
double valor_cuota = ( ( DSBTotal->value() ) * ( 1 + DSBInteres->value() / 100 ) ) / SBCantidad->value();
QDate fch = DEInicio->date();
for( int i = 1; i<=SBCantidad->value(); i++ ) {
tabla->cellAt( i+2, 0 ).firstCursorPosition().insertHtml( QString( "#%1" ).arg( i ) );
tabla->cellAt( i+2, 1 ).firstCursorPosition().insertHtml( QString( "%1" ).arg( fch.toString( Qt::SystemLocaleShortDate ) ) );
fch.addDays( (i-1)*MPlanCuota::diasEnPeriodo( (MPlanCuota::Periodo) CBPeriodo->currentIndex(), fch ) );
tabla->cellAt( i+2, 2 ).firstCursorPosition().setBlockFormat( bfizq );
tabla->cellAt( i+2, 2 ).firstCursorPosition().insertHtml( QString( "$ %L1" ).arg( valor_cuota, 10, 'f', 2 ) );
pagado += valor_cuota;
tabla->cellAt( i+2, 3 ).firstCursorPosition().setBlockFormat( bfizq );
tabla->cellAt( i+2, 3 ).firstCursorPosition().insertHtml( QString( "$ %L1" ).arg( pagado, 10, 'f', 2 ) );
subtotal -= valor_cuota;
tabla->cellAt( i+2, 4 ).firstCursorPosition().setBlockFormat( bfizq );
tabla->cellAt( i+2, 4 ).firstCursorPosition().insertHtml( QString( "$ %L1" ).arg( subtotal, 10, 'f', 2 ) );
}
// Firma y aclaracion
cursor.movePosition( QTextCursor::End );
cursor.insertBlock();
cursor.insertBlock();
cursor.insertBlock();
cursor.insertBlock();
cursor.insertBlock();
cursor.insertText( "Firma del contrayente: ___________________________" );
cursor.insertBlock();
cursor.insertBlock();
cursor.insertBlock();
cursor.insertBlock();
cursor.insertText( QString::fromUtf8( "Aclaracion: ________________________________________________ DNI:___-__________-___" ) );
cursor.insertBlock();
cursor.insertBlock();
cursor.insertHtml( QString::fromUtf8( "<small>En caso de provocarse un atraso en la fecha de pago de cualquiera de las cuotas, se aplicara el recargo correspondiente tal cual se hace actualmenete con cualquier recibo emitido por nuestra entidad.</small>" ) );
// Cabecera
cursor.movePosition( QTextCursor::Start );
cursor.insertBlock();
#ifdef Q_OS_WIN
cursor.insertHtml( "<h1>HiComp Computación</h1><br />" );
#else
cursor.insertHtml( "<h1>" + ERegistroPlugins::getInstancia()->pluginInfo()->empresa() + "</h1><br />" );
#endif
cursor.insertHtml( "<h2>Plan de cuotas</h2><br /><br />" );
cursor.insertBlock();
cursor.insertHtml( QString( "<b>Fecha de Inicio:</b> %1 <br />" ).arg( DEInicio->date().toString( Qt::SystemLocaleLongDate ) ) );
cursor.insertHtml( QString( "<b>Nombre del cliente:</b> %1 <br />").arg( MClientes::getRazonSocial( _id_cliente ) ) );
return;
}
示例15: visitGraphCellNodeBefore
void PrinterVisitor::visitGraphCellNodeBefore(GraphCell *node)
{
if( !ignore_ || firstChild_ )
{
++currentTableRow_;
table_->insertRows( currentTableRow_, 1 );
// first column
QTextTableCell tableCell( table_->cellAt( currentTableRow_, 0 ) );
if( tableCell.isValid() )
{
if( !node->ChapterCounterHtml().isNull() )
{
QTextCursor cursor( tableCell.firstCursorPosition() );
cursor.insertFragment( QTextDocumentFragment::fromHtml(
node->ChapterCounterHtml() ));
}
}
// second column
tableCell = table_->cellAt( currentTableRow_, 1 );
if( tableCell.isValid() )
{
QTextCursor cursor( tableCell.firstCursorPosition() );
// input table
QTextTableFormat tableFormatInput;
tableFormatInput.setBorder( 0 );
tableFormatInput.setColumns( 1 );
tableFormatInput.setCellPadding( 2 );
tableFormatInput.setBackground( QColor(245, 245, 255) ); // 200, 200, 255
QVector<QTextLength> constraints;
constraints << QTextLength(QTextLength::PercentageLength, 100);
tableFormatInput.setColumnWidthConstraints(constraints);
cursor.insertTable( 1, 1, tableFormatInput );
QString html = node->textHtml();
if( !node->isEvaluated() || node->isClosed() )
html += "<br />";
cursor.insertFragment( QTextDocumentFragment::fromHtml( html ));
if( node->isEvaluated() && !node->isClosed() )
{
QTextTableFormat tableFormatOutput;
tableFormatOutput.setBorder( 0 );
tableFormatOutput.setColumns( 1 );
tableFormatOutput.setCellPadding( 2 );
QVector<QTextLength> constraints;
constraints << QTextLength(QTextLength::PercentageLength, 100);
tableFormatOutput.setColumnWidthConstraints(constraints);
cursor = tableCell.lastCursorPosition();
cursor.insertTable( 1, 1, tableFormatOutput );
QString outputHtml( node->textOutputHtml() );
outputHtml.remove( "file:///" );
cursor.insertFragment( QTextDocumentFragment::fromHtml( outputHtml ));
}
}
// print the plot
if (node->mpPlotWindow && node->mpPlotWindow->isVisible()) {
++currentTableRow_;
table_->insertRows( currentTableRow_, 1 );
// first column
tableCell = table_->cellAt( currentTableRow_, 1 );
if( tableCell.isValid() )
{
QTextCursor cursor( tableCell.firstCursorPosition() );
// input table
QTextTableFormat tableFormatInput;
tableFormatInput.setBorder( 0 );
tableFormatInput.setColumns( 1 );
tableFormatInput.setCellPadding( 2 );
QVector<QTextLength> constraints;
constraints << QTextLength(QTextLength::PercentageLength, 100);
tableFormatInput.setColumnWidthConstraints(constraints);
cursor.insertTable( 1, 1, tableFormatInput );
OMPlot::Plot *pPlot = node->mpPlotWindow->getPlot();
// calculate height for widht while preserving aspect ratio.
int width, height;
if (pPlot->size().width() > 600) {
width = 600;
qreal ratio = (double)pPlot->size().height() / pPlot->size().width();
height = width * qCeil(ratio);
} else {
width = pPlot->size().width();
height = pPlot->size().height();
}
// create a pixmap and render the plot on it
QPixmap plotPixmap(width, height);
QwtPlotRenderer plotRenderer;
plotRenderer.renderTo(pPlot, plotPixmap);
// insert the pixmap to table
cursor.insertImage(plotPixmap.toImage());
//.........这里部分代码省略.........