本文整理汇总了C++中QTextTableFormat::setWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextTableFormat::setWidth方法的具体用法?C++ QTextTableFormat::setWidth怎么用?C++ QTextTableFormat::setWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextTableFormat
的用法示例。
在下文中一共展示了QTextTableFormat::setWidth方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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 );
}
}
示例3: sl_CreateTableAction_Triggered
void TextEditWidget::sl_CreateTableAction_Triggered() {
QTextTable* table = textField->textCursor().currentTable();
if (table) {
return;
}
textField->textCursor().beginEditBlock();
table = textField->textCursor().insertTable(2, 2);
QTextTableFormat format = table->format();
format.setCellSpacing(0);
format.setCellPadding(3);
format.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
QTextLength tableWidth(QTextLength::PercentageLength, 50);
format.setWidth(tableWidth);
table->setFormat(format);
textField->textCursor().endEditBlock();
QTextTableCell cell = table->cellAt(0, 0);
textField->setTextCursor(cell.firstCursorPosition());
}
示例4: 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);
//.........这里部分代码省略.........
示例5: printODT
bool PriceListPrinter::printODT( PriceListPrinter::PrintPriceItemsOption printOption,
const QList<int> &fieldsToPrint,
int priceDataSetToPrintInput,
bool printPriceList,
bool printPriceAP,
bool APgroupPrAm,
const QString &fileName,
double pageWidth,
double pageHeight,
Qt::Orientation paperOrientation) {
double borderWidth = 1.0f;
if( m_d->priceList ){
int priceDataSetToPrint = 0;
// controlliamo se il valore di input è corretto
if( priceDataSetToPrintInput >= 0 && priceDataSetToPrintInput < m_d->priceList->priceDataSetCount() ){
priceDataSetToPrint = priceDataSetToPrintInput;
}
QTextDocument doc;
QTextCursor cursor(&doc);
if( paperOrientation == Qt::Horizontal ){
if( pageHeight > pageWidth ){
double com = pageHeight;
pageHeight = pageWidth;
pageWidth = com;
}
} else {
if( pageHeight < pageWidth ){
double com = pageHeight;
pageHeight = pageWidth;
pageWidth = com;
}
}
double margin = 10.0;
double tableWidth = pageWidth - 2.0 * margin;
QTextCharFormat headerBlockCharFormat;
headerBlockCharFormat.setFontCapitalization( QFont::AllUppercase );
headerBlockCharFormat.setFontWeight( QFont::Bold );
QTextBlockFormat headerBlockFormat;
headerBlockFormat.setAlignment( Qt::AlignHCenter );
QTextBlockFormat headerWithPBBlockFormat = headerBlockFormat;
headerWithPBBlockFormat.setPageBreakPolicy( QTextFormat::PageBreak_AlwaysBefore );
QTextBlockFormat parBlockFormat;
if( printPriceList ){
cursor.setBlockFormat( headerWithPBBlockFormat );
cursor.setBlockCharFormat( headerBlockCharFormat );
cursor.insertText( m_d->priceList->name() );
cursor.insertBlock( headerBlockFormat );
cursor.setBlockCharFormat( headerBlockCharFormat );
cursor.insertText(QObject::trUtf8("Elenco Prezzi") );
cursor.insertBlock( parBlockFormat );
QTextTableFormat tableFormat;
tableFormat.setCellPadding(5);
tableFormat.setHeaderRowCount(2);
tableFormat.setBorderStyle( QTextFrameFormat::BorderStyle_Solid);
tableFormat.setWidth( QTextLength( QTextLength::FixedLength, tableWidth ) );
QVector<QTextLength> colWidths;
if( paperOrientation == Qt::Horizontal ){
double descColWidth = tableWidth - ( 30.0 + 20.0 + 35.0 * fieldsToPrint.size() );
colWidths << QTextLength( QTextLength::FixedLength, 30.0 )
<< QTextLength( QTextLength::FixedLength, descColWidth )
<< QTextLength( QTextLength::FixedLength, 20.0 );
for( int i=0; i < fieldsToPrint.size(); ++i ){
colWidths << QTextLength( QTextLength::FixedLength, 35.0 );
}
} else {
double descColWidth = tableWidth - ( 25.0 + 15.0 + 30.0 * fieldsToPrint.size() );
colWidths << QTextLength( QTextLength::FixedLength, 25.0 )
<< QTextLength( QTextLength::FixedLength, descColWidth )
<< QTextLength( QTextLength::FixedLength, 15.0 );
for( int i=0; i < fieldsToPrint.size(); ++i ){
colWidths << QTextLength( QTextLength::FixedLength, 30.0 );
}
}
tableFormat.setColumnWidthConstraints( colWidths );
tableFormat.setHeaderRowCount( 2 );
cursor.insertTable(1, colWidths.size(), tableFormat);
m_d->priceList->writeODTOnTable( &cursor, printOption, fieldsToPrint, priceDataSetToPrint );
cursor.movePosition( QTextCursor::End );
}
if( printPriceAP ){
bool firstAP=true;
QList<PriceItem *> priceItemList = m_d->priceList->priceItemList();
for( int i=0; i < priceItemList.size(); ++i ){
if( (!priceItemList.at(i)->hasChildren()) && (priceItemList.at(i)->associateAP(priceDataSetToPrint)) ){
if( firstAP ){
if( printPriceList ){
//.........这里部分代码省略.........
示例6: render
bool KoReportODTRenderer::render(const KoReportRendererContext& context, ORODocument* document, int /*page*/)
{
QTextTableFormat tableFormat;
tableFormat.setCellPadding(5);
tableFormat.setHeaderRowCount(1);
tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
tableFormat.setWidth(QTextLength(QTextLength::PercentageLength, 100));
QTextTable *table = m_cursor.insertTable(1, 1, tableFormat);
long renderedSections = 0;
for (long s = 0; s < document->sections(); s++) {
OROSection *section = document->section(s);
section->sortPrimatives(OROSection::SortX);
if (section->type() == KRSectionData::GroupHeader || section->type() == KRSectionData::GroupFooter ||
section->type() == KRSectionData::ReportHeader || section->type() == KRSectionData::ReportFooter ||
section->type() == KRSectionData::Detail){
//Add this section to the document
//Resize the table to accommodate all the primitives in the section
if (table->columns() < section->primitives()) {
table->appendColumns(section->primitives() - table->columns());
}
if (renderedSections > 0) {
//We need to back a row, then forward a row to get at the start cell
m_cursor.movePosition(QTextCursor::PreviousRow);
m_cursor.movePosition(QTextCursor::NextRow);
} else {
//On the first row, ensure we are in the first cell after expanding the table
while (m_cursor.movePosition(QTextCursor::PreviousCell)){}
}
//Render the objects in each section
for (int i = 0; i < section->primitives(); i++) {
//Colour the cell using hte section background colour
OROPrimitive * prim = section->primitive(i);
QTextTableCell cell = table->cellAt(m_cursor);
QTextCharFormat format = cell.format();
format.setBackground(section->backgroundColor());
cell.setFormat(format);
if (prim->type() == OROTextBox::TextBox) {
OROTextBox * tb = (OROTextBox*) prim;
m_cursor.insertText(tb->text());
} else if (prim->type() == OROImage::Image) {
OROImage * im = (OROImage*) prim;
m_cursor.insertImage(im->image().scaled(im->size().width(), im->size().height(), Qt::KeepAspectRatio));
} else if (prim->type() == OROPicture::Picture) {
OROPicture * im = (OROPicture*) prim;
QImage image(im->size().toSize(), QImage::Format_RGB32);
QPainter painter(&image);
im->picture()->play(&painter);
m_cursor.insertImage(image);
} else {
kWarning() << "unhandled primitive type";
}
m_cursor.movePosition(QTextCursor::NextCell);
}
if (s < document->sections() - 1) {
table->appendRows(1);
}
renderedSections++;
}
}
QTextDocumentWriter writer(context.destinationUrl.toLocalFile());
return writer.write(m_document);
}
示例7: 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;
}
示例8: hacerResumen
void InformeCierreCaja::hacerResumen( int id_caja, bool ultimo, int id_cierre )
{
if( id_caja == -1 ) {
qWarning( "Numero de caja incorrecto" );
//abort();
return;
} else if( ultimo == false && id_cierre == -1 ) {
qWarning( "El cierre pedido es incorrecto" );
//abort();
return;
}
// Busco los datos
MMovimientosCaja *m = new MMovimientosCaja( this );
if( ultimo ) {
id_cierre = m->buscarUltimoCierre( id_caja );
if( id_cierre == -1 ) {
return;
}
}
QSqlQuery resultados = m->buscarMovimientos( id_caja, id_cierre );
///////////////////////////////////////////////////////////////////////////////////////////////////
// Inicio el renderizado
QTextCursor cursor( documento );
int cantidadCol = 6;
if( preferencias::getInstancia()->value( "Preferencias/Caja/responsable", true ).toBool() ) { cantidadCol++; }
/////////////////////////////////////
/// Hago la cabecera de la tabla
QTextTable *tabla = cursor.insertTable( 1, cantidadCol );
QTextTableFormat formatoTabla = tabla->format();
formatoTabla.setHeaderRowCount( 1 );
formatoTabla.setWidth( QTextLength( QTextLength::PercentageLength, 100 ) );
tabla->setFormat( formatoTabla );
tabla->cellAt( 0,0 ).firstCursorPosition().insertHtml( " # Op " );
tabla->cellAt( 0,1 ).firstCursorPosition().insertHtml( " Fecha/Hora " );
tabla->cellAt( 0,2 ).firstCursorPosition().insertHtml( " Razon " );
tabla->cellAt( 0,3 ).firstCursorPosition().insertHtml( " Ingreso " );
tabla->cellAt( 0,4 ).firstCursorPosition().insertHtml( " Egreso " );
tabla->cellAt( 0,5 ).firstCursorPosition().insertHtml( " Saldo " );
if( preferencias::getInstancia()->value( "Preferencias/Caja/responsable", true ).toBool() ) {
tabla->cellAt( 0, 6 ).firstCursorPosition().insertHtml( " Responsable " );
}
// Averiguo el saldo hasta el momento del cierre anterior
double saldo_anterior = m->saldoEnMovimientoAnteriorA( id_caja, id_cierre );
while( resultados.next() ) {
int pos = tabla->rows();
tabla->insertRows( pos, 1 );
tabla->cellAt( pos, 0 ).firstCursorPosition().insertHtml( QString( " # %1 " ).arg( resultados.record().value("id_movimiento" ).toInt() ) );
tabla->cellAt( pos, 1 ).firstCursorPosition().insertHtml( resultados.record().value("fecha_hora" ).toDateTime().toString( Qt::SystemLocaleDate ) );
tabla->cellAt( pos, 2 ).firstCursorPosition().insertHtml( resultados.record().value("razon" ).toString() );
if( resultados.record().value( "cierre" ).toBool() == false ) {
// Ingreso
double haber = resultados.record().value( "ingreso" ).toDouble();
saldo_anterior += haber;
tabla->cellAt( pos, 3 ).firstCursorPosition().insertHtml( QString( " $ %L1" ).arg( haber ) );
// Egreso
double debe = resultados.record().value( "egreso" ).toDouble();
saldo_anterior -= debe;
tabla->cellAt( pos, 4 ).firstCursorPosition().insertHtml( QString( " $ %L1" ).arg( debe ) );
// Subtotal hasta el momento
tabla->cellAt( pos, 5 ).firstCursorPosition().insertHtml( QString( " $ %L1" ).arg( saldo_anterior ) );
} else {
saldo_anterior += resultados.record().value( "ingreso" ).toDouble();
tabla->cellAt( pos, 5 ).firstCursorPosition().insertHtml( QString( " $ %L1" ).arg( saldo_anterior ) );
}
if( preferencias::getInstancia()->value( "Preferencias/Caja/responsable", true ).toBool() ) {
tabla->cellAt( pos, 6 ).firstCursorPosition().insertHtml( resultados.record().value( "responsable" ).toString() );
}
}
// Saldos finales
cursor.movePosition( QTextCursor::End );
cursor.insertBlock();
cursor.insertHtml( QString( "<b>Saldo Final:</b> $ %L1" ).arg( saldo_anterior ) );
cursor.insertBlock();
if( preferencias::getInstancia()->value( "Preferencias/Caja/firma", true ).toBool() ) {
cursor.insertBlock();
cursor.insertText( "Controlado por: ________________________" );
cursor.insertBlock();
cursor.insertBlock();
cursor.insertText( "Firma: ____________" );
}
// Termino el resumen
cursor.movePosition( QTextCursor::Start );
cursor.insertBlock();
if( preferencias::getInstancia()->value( "Preferencias/Caja/logo" ).toBool() ) {
//cursor.insertImage( ERegistroPlugins::pluginInfo()->imagenPrograma() );
cursor.insertImage( ":/imagenes/gestotux32.png" );
}
cursor.insertHtml( "<h1>Cierre de Caja</h1>" );
cursor.insertBlock();
cursor.insertHtml( QString( "<b>Fecha de Cierre:</b> %1 <br />" ).arg( QDateTime::currentDateTime().toString( Qt::SystemLocaleLongDate ) ) );
cursor.insertHtml( QString( "<b>Caja:</b> %1<br />").arg( MCajas::nombreCaja( id_caja ) ) );
return;
}
示例9: writeTable
bool OutputQtDocument::writeTable()
{
/*
start of table
*/
m_cursor.beginEditBlock();
m_cursor.insertBlock();
m_cursor.insertBlock();
QTextFrame *topFrame = m_cursor.currentFrame();
QTextTableFormat tableFormat;
tableFormat.setCellPadding(4);
tableFormat.setHeaderRowCount(1);
/* tableFormat.setBorderStyle(
QTextFrameFormat::BorderStyle_Double); */
tableFormat.setMargin(2);
tableFormat.setWidth(QTextLength(
QTextLength::PercentageLength, 100));
QTextTable *table = m_cursor.insertTable(
m_params->height()+2, m_params->width()+5, tableFormat);
/*
headers
*/
m_cursor = table->cellAt(0, 0).firstCursorPosition();
m_cursor.insertText("i");
m_cursor = table->cellAt(0, 1).firstCursorPosition();
m_cursor.insertText(tr("basis"));
m_cursor = table->cellAt(0, 2).firstCursorPosition();
m_cursor.insertHtml("C<sub>i</sub> ");
m_cursor = table->cellAt(0, 3).firstCursorPosition();
m_cursor.insertText("B");
for(size_t j=0; j < m_params->width(); j++)
{
m_cursor = table->cellAt(0, j+4).firstCursorPosition();
m_cursor.insertHtml(QString("P<sub>%1</sub> ").arg(j+1));
/* m_cursor.insertHtml(QString("C<sub>%1</sub> =").arg(j+1));
if(m_params->variableType(j) == SimplexMethod::VariableArtificial)
m_cursor.insertText("W");
else
m_cursor.insertText(formatDouble(m_params->rowC(j))); */
}
m_cursor = table->cellAt(0, m_params->width()+4).firstCursorPosition();
m_cursor.insertText(QChar(0x0398)); // theta
/*
matrix, columnCompareOp, columnB, columnTheta
*/
for(size_t i=0; i < m_params->height(); i++)
{
m_cursor = table->cellAt(i+1, 0).firstCursorPosition();
m_cursor.insertText(QString("%1").arg(i+1));
// basis
m_cursor = table->cellAt(i+1, 1).firstCursorPosition();
size_t basisColumn = m_params->columnBasis(i);
m_cursor.insertHtml(QString("P<sub>%1</sub> ").arg(basisColumn+1));
// basis C
m_cursor = table->cellAt(i+1, 2).firstCursorPosition();
if(m_params->variableType(basisColumn) == SimplexMethod::VariableArtificial)
m_cursor.insertText("W");
else
m_cursor.insertText(formatDouble(m_params->rowC(basisColumn)));
// B
m_cursor = table->cellAt(i+1, 3).firstCursorPosition();
m_cursor.insertText(formatDouble(m_params->columnB(i)));
// matrix
for(size_t j=0; j < m_params->width(); j++)
{
m_cursor = table->cellAt(i+1, j+4).firstCursorPosition();
m_cursor.insertText(formatDouble(m_params->matrixA(i, j)));
}
// theta
m_cursor = table->cellAt(i+1, m_params->width()+4).firstCursorPosition();
if(m_params->columnTheta(i) > 0)
m_cursor.insertText(formatDouble(m_params->columnTheta(i)));
else
m_cursor.insertText("-");
}
/*
m+1 row
*/
m_cursor = table->cellAt(m_params->height()+1, 0).firstCursorPosition();
m_cursor.insertText("m+1");
m_cursor = table->cellAt(m_params->height()+1, 3).firstCursorPosition();
m_cursor.insertText(formatDouble(m_params->F()));
for(size_t j=0; j < m_params->width(); j++)
{
m_cursor = table->cellAt(m_params->height()+1, j+4).firstCursorPosition();
//.........这里部分代码省略.........
示例10: 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));
//.........这里部分代码省略.........