📄 lxaccountstmtprint.cc
字号:
// ****************************************************************************// // LxBank - home-banking for Linux using the HBCI standard// // Author: Franz Zimmermann 83043 Bad Aibling// // Copyright (C) 2002-2003 Franz Zimmermann - arafang@users.sourceforge.net// // This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.// // This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.// // You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.// // ***************************************************************************//// ***************************************************************************// /*! \file \brief LxAccountStmtPrint: Prints the account statement list*/ // ***************************************************************************//// $Name: $//// $State: Exp $//// $Log: LxAccountStmtPrint.cc,v $// Revision 1.8 2003/04/05 02:01:00 arafang// Turnover printing updated.//// Revision 1.7 2003/04/01 00:32:32 arafang// Misaligned column width in account statement print fixed.//// Revision 1.6 2003/02/08 15:25:21 franz// Mail address changed.//// Revision 1.5 2003/01/26 23:09:41 franz// LxAccountSelectDialog: New method to delete accounts (remove).// Class LxAccountStmtPrint adapted to new account statement view layout.// Account update implemented.//// Revision 1.4 2003/01/02 15:04:45 franz// Started to use the openHBCI lib.//// Revision 1.3 2002/06/02 22:03:19 franz// Remittance view lists improved.// Remittance work dialogs implemented.//// Revision 1.2 2002/04/23 22:13:15 franz// File LxAccountStmtList.h renamed to LxAccount.h// File LxAccountStmtList.cc renamed to LxAccount.cc//// Revision 1.1 2002/04/19 23:51:20 franz// Account statement printing implemented////#ifdef HAVE_CONFIG_H#include <config.h>#endif#include "LxAccountStmtPrint.h"#include <qapplication.h>#include <qpaintdevicemetrics.h>#include <math.h>LxAccountStmtPrint::LxAccountStmtPrint ( QListView *lv, const QString &bnk, const QString &inh, const QString &bl, const QString &knum, const QString &knam ) : lView(lv), normalFont( (*lView).font() ), largeFont( (*lView).font() ), hugeFont( (*lView).font() ), topMargin( 18 ), ruleHeight( 3 ), leftMargin( 30 ), rightMargin( 0 ), bottomMargin( 23 ), textSpace( 5 ), edgeMargin( 5 ), labelBank( lView->tr("Institute:") ), labelInhaber( lView->tr("Customer:") ), labelBlz( lView->tr("Bank Code:") ), labelKtonumber( lView->tr("Account-Id:") ), bank(bnk), inhaber(inh), blz(bl), ktonumber(knum), ktoname(knam), labelDatum(lView->tr("Date")), labelValuta(lView->tr("Valuta")), labelInstitute(lView->tr("Institute")), labelAccount(lView->tr("Account-Id")), labelCode(lView->tr("Code")), labelBuchungstext(lView->tr("Description")), labelUmsatz(lView->tr("S-soll/H-haben")), labelSaldo(lView->tr("Balance")), brush( QBrush::Dense7Pattern ){ printer = new QPrinter; CHECK_PTR( printer ); painter = new QPainter (printer); printer->setCreator ( "LxBank" ); // setup printing fonts int normalPointSize = normalFont.pointSize () - 1; normalFont.setPointSize ( normalPointSize); largeFont.setPointSize ( normalPointSize + 2 - 1); hugeFont.setPointSize ( normalPointSize + 4 - 1); hugeFont.setBold ( TRUE ); // setup item printing painter->setFont( normalFont ); penColor = painter->pen().color(); // setup text height and line spacing QFontMetrics pfm( normalFont ); textSpacing = pfm.height() + pfm.leading(); // setup head limits headTextFieldHeight = (int)ceil((double)(normalPointSize+2) * 2.5); headHeight = headTextFieldHeight + 2*ruleHeight + textSpacing + 2; QListViewItemIterator lvit( lView ); LxAccountListViewItem *item; item = (LxAccountListViewItem *)(lvit.current()); if ( item ){ dateWidth = item->width ( pfm, lView, 0 ) + 5; valutaWidth = item->width ( pfm, lView, 1 ) + 5; instituteWidth = item->width ( pfm, lView, 2 ) + 10; accountWidth = item->width ( pfm, lView, 3 ) + 10; codeWidth = item->width ( pfm, lView, 4 ) + 10; textWidth = item->width ( pfm, lView, 5 ); turnoverWidth = item->width ( pfm, lView, 6 ); balanceWidth = item->width ( pfm, lView, 7 ) + 10; }else{ dateWidth = valutaWidth = instituteWidth = accountWidth = codeWidth = textWidth = turnoverWidth = balanceWidth = 0; } painter->end( );}LxAccountStmtPrint::~LxAccountStmtPrint (){ delete printer; delete painter;}void LxAccountStmtPrint::setup ( ){ // setup paint area limits QPaintDeviceMetrics printerMetrics( printer ); pageWidth = printerMetrics.width() - (leftMargin + rightMargin); bottomEdge = printerMetrics.height () - bottomMargin; // setup head text printing QRect bbox; int lw1, lw2, leftX, txtWidth, leftSpaceUsed, rightSpaceUsed; int topEdge = topMargin + ruleHeight; painter->setFont( largeFont ); // text labels on left side bbox = painter->boundingRect ( leftMargin, topEdge, pageWidth, headTextFieldHeight, Qt::AlignLeft | Qt::AlignTop, labelBank); lw1 = bbox.width(); bbox = painter->boundingRect ( leftMargin, topEdge, pageWidth, headTextFieldHeight, Qt::AlignLeft | Qt::AlignBottom, labelInhaber); lw2 = bbox.width(); txtWidth = lw1 > lw2 ? lw1 : lw2; headTxtRecLeftOts.setRect ( leftMargin, topEdge, txtWidth, headTextFieldHeight ); txtWidth += textSpace; leftSpaceUsed = txtWidth; // text on left side bbox = painter->boundingRect ( leftMargin + leftSpaceUsed, topEdge, pageWidth - leftSpaceUsed, headTextFieldHeight, Qt::AlignLeft | Qt::AlignTop, bank ); lw1 = bbox.width(); bbox = painter->boundingRect ( leftMargin + leftSpaceUsed, topEdge, pageWidth - leftSpaceUsed, headTextFieldHeight, Qt::AlignLeft | Qt::AlignBottom, inhaber ); lw2 = bbox.width(); txtWidth = lw1 > lw2 ? lw1 : lw2; headTxtRecLeftIns.setRect ( leftMargin + leftSpaceUsed, topEdge, txtWidth, headTextFieldHeight ); leftSpaceUsed += txtWidth; // text on right side bbox = painter->boundingRect ( leftMargin, topEdge, pageWidth, headTextFieldHeight, Qt::AlignRight | Qt::AlignTop, blz ); lw1 = bbox.width(); bbox = painter->boundingRect ( leftMargin, topEdge, pageWidth, headTextFieldHeight, Qt::AlignRight | Qt::AlignBottom, ktonumber ); lw2 = bbox.width(); txtWidth = lw1 > lw2 ? lw1 : lw2; rightSpaceUsed = txtWidth; leftX = leftMargin + pageWidth - rightSpaceUsed; headTxtRecRightOts.setRect ( leftX, topEdge, txtWidth, headTextFieldHeight ); // text labels on right side leftX -= textSpace; rightSpaceUsed += textSpace; bbox = painter->boundingRect ( leftMargin, topEdge, pageWidth - rightSpaceUsed, headTextFieldHeight, Qt::AlignRight | Qt::AlignTop, labelBlz ); lw1 = bbox.width(); bbox = painter->boundingRect ( leftMargin, topEdge, pageWidth - rightSpaceUsed, headTextFieldHeight, Qt::AlignRight | Qt::AlignBottom, labelKtonumber ); lw2 = bbox.width(); txtWidth = lw1 > lw2 ? lw1 : lw2; leftX -= txtWidth; headTxtRecRightIns.setRect ( leftX, topEdge, txtWidth, headTextFieldHeight ); rightSpaceUsed += txtWidth; // konto name centered headTxtRecCenter.setRect (leftMargin + leftSpaceUsed, topEdge, pageWidth - (leftSpaceUsed + rightSpaceUsed), headTextFieldHeight ); // setup item printing painter->setFont( normalFont ); bgRec.setRect( leftMargin, 0, pageWidth, 1 ); bbox = painter->boundingRect ( leftMargin, topEdge, pageWidth, headTextFieldHeight, Qt::AlignLeft | Qt::AlignTop, labelDatum); lw1 = bbox.width(); dateWidth = dateWidth < lw1 ? lw1 : dateWidth; bbox = painter->boundingRect ( leftMargin, topEdge, pageWidth, headTextFieldHeight, Qt::AlignLeft | Qt::AlignTop, labelValuta); lw1 = bbox.width(); valutaWidth = valutaWidth < lw1 ? lw1 : valutaWidth;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -