📄 lxaccountlistviewitem.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 LxAccountListViewItem: Main Window for LxBank*/ // ***************************************************************************//// $Name: $//// $State: Exp $//// $Log: LxAccountListViewItem.cc,v $// Revision 1.11 2003/04/12 00:38:56 arafang// Fix problems with assignment QString to string//// Revision 1.10 2003/02/08 15:25:20 franz// Mail address changed.//// Revision 1.9 2003/01/17 00:56:42 franz// Getting account statements work.//// Revision 1.8 2003/01/03 17:15:32 franz// LxUserAddWizard able to create a DDV-Card user.//// Revision 1.7 2003/01/02 15:04:45 franz// Started to use the openHBCI lib.//// Revision 1.6 2002/07/04 23:18:31 franz// Optimize performance of class LxAccount.// Add account close function.//// Revision 1.5 2002/06/02 22:03:19 franz// Remittance view lists improved.// Remittance work dialogs implemented.//// Revision 1.4 2002/05/15 00:38:18 franz// Started to switch to Qt3.// Class LxRemittanceViewButton renamed to LxPushButton.// Layout of LxAccountSelectDialog improved.//// Revision 1.3 2002/04/19 23:51:20 franz// Account statement printing implemented//// Revision 1.2 2002/04/07 23:20:47 franz// Worked on account view window.//// Revision 1.1.1.1 2002/04/05 08:33:43 franz// Gets LxBank under revision control//////#ifdef HAVE_CONFIG_H#include <config.h>#endif#include <stream.h>#include <math.h>#include "LxAccountListViewItem.h"#include <qpainter.h> LxAccountListViewItem::LxAccountListViewItem (QListView * parent, QString label1, QString srtkey1, QString label2, QString srtkey2, QString label3, QString srtkey3, QString label4, QString srtkey4, QString label5, QString srtkey5, QStringList label6, QString label7, QString srtkey7, double u, QString label8, QString srtkey8, double s ) : QListViewItem (parent, label1, label2, label3, label4, label5, label6[0], label7, label8 ), lv(parent), BText(label6), sortKey1(srtkey1), sortKey2(srtkey2), sortKey3(srtkey3), sortKey4(srtkey4), sortKey5(srtkey5), sortKey6(label6[0]), sortKey7(srtkey7), sortKey8(srtkey8), umsatz(u), saldo(s){ textLines = label6.count (); QFontMetrics fm(parent->font()); textHeight = fm.height(); textLeading = fm.leading(); textSpacing = textHeight + textLeading; totalItemHeight = textLines * textSpacing + textHeight/2;// cerr << "LxAccountListViewItem: textHeight = " << textHeight << ", textLeading = " << textLeading << endl; width1 = fm.boundingRect( label1 ).width(); width2 = fm.boundingRect( label2 ).width(); width3 = fm.boundingRect( label3 ).width(); width4 = fm.boundingRect( label4 ).width(); width5 = fm.boundingRect( label5 ).width(); QStringList::Iterator it; int w; for( it = BText.begin(), width6 = w = 0; it != BText.end(); ++it ){ if ( (w = fm.boundingRect( *it ).width()) > width6 ){ width6 = w; } } width7 = fm.boundingRect( label7 ).width(); width8 = fm.boundingRect( label8 ).width(); sollColor.setRgb( 150, 0, 0 ); negSaldoColor.setRgb( 255, 0, 0 );}QStringList &LxAccountListViewItem::getBText (){ return BText;}QString LxAccountListViewItem::key ( int column, bool ascending ) const{ switch (column){ case 0: return sortKey1; case 1: return sortKey2; case 2: return sortKey3; case 3: return sortKey4; case 4: return sortKey5; case 5: return sortKey6; case 6: return sortKey7; case 7: return sortKey8; } return QString::null;}void LxAccountListViewItem::setHeight ( int h ){ QListViewItem::setHeight ( h );}void LxAccountListViewItem::setup (){ // QListViewItem::setup (); widthChanged ( 0 ); widthChanged ( 1 ); widthChanged ( 2 ); widthChanged ( 3 ); widthChanged ( 4 ); widthChanged ( 6 ); widthChanged ( 7 ); setHeight ( totalItemHeight );}int LxAccountListViewItem::width ( const QFontMetrics & fm, const QListView * lv, int c ) const{ switch (c){ case 0: return width1; case 1: return width2; case 2: return width3; case 3: return width4; case 4: return width5; case 5: return width6; case 6: return width7; case 7: return width8; } return 0;}void LxAccountListViewItem::paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align ){ // cerr << "\nLxAccountListViewItem::paintCell has been called: column = " // << column << ", width = " << width << ", align = " << align; QPen pn = p->pen(); QRect rec( 0, 0, width, totalItemHeight ); QRect backRec( 0, 0, width, textSpacing ); // cerr << "\nRectangle: left = " << rec.left() << ", top = " << rec.top() // << ", right = " << rec.right() << ", bottom = " << rec.bottom(); if ( isSelected() ){ p->fillRect( rec, cg.highlight() );// p->fillRect( rec, cg.foreground() ); pn.setColor( cg.highlightedText() ); p->fillRect( backRec, cg.dark() ); }else{ p->eraseRect( rec ); pn.setColor(cg.text());// p->fillRect( backRec, cg.light() ); p->fillRect( backRec, cg.button() ); } p->setPen(pn); int y = textHeight; QRect txtRec( lv->itemMargin(), 0, width - 2 * lv->itemMargin(), textSpacing ); QStringList::Iterator it; switch ( column ){ case 5: for( it = BText.begin(), y = 0; it != BText.end(); ++it, y += textSpacing ){ txtRec.setTop( y ); txtRec.setBottom( y + textSpacing ); p->drawText ( txtRec, align, *it ); } break; case 6: if ( umsatz < 0.0 ){ pn.setColor(sollColor); p->setPen(pn); } p->drawText ( txtRec, align, text(column) ); break; case 7: if ( saldo < 0.0 ){ pn.setColor(negSaldoColor); p->setPen(pn); } p->drawText ( txtRec, align, text(column) ); break; case 0: case 1: case 2: case 3: case 4: p->drawText ( txtRec, align, text(column) ); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -