📄 lxmainwin.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 LxMainWin: Main Window for LxBank*/ // ***************************************************************************//// $Name: $//// $State: Exp $//// $Log: LxMainWin.cc,v $// Revision 1.20 2003/05/01 14:06:20 arafang// Format of bank code data file changed: was blz.txt - ascii, new blz.bin - binary//// Revision 1.19 2003/02/08 15:41:16 franz// Pixmap printmgr_xpm renamed to print_xpm.//// Revision 1.18 2003/02/08 15:25:21 franz// Mail address changed.//// Revision 1.17 2003/02/08 11:45:19 franz// Money transfer (single mode) works.//// Revision 1.16 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.15 2003/01/18 15:36:09 franz// New class LxAccountStmtView implemented.//// Revision 1.14 2003/01/17 00:56:42 franz// Getting account statements work.//// Revision 1.13 2003/01/07 22:09:31 franz// Added user list dialog.//// Revision 1.12 2003/01/03 17:15:32 franz// LxUserAddWizard able to create a DDV-Card user.//// Revision 1.11 2003/01/02 15:04:45 franz// Started to use the openHBCI lib.//// Revision 1.10 2002/07/04 23:18:31 franz// Optimize performance of class LxAccount.// Add account close function.//// Revision 1.9 2002/07/02 23:09:45 franz// Now the accounts from the global accounts list are used within the program//// Revision 1.8 2002/06/02 22:03:19 franz// Remittance view lists improved.// Remittance work dialogs implemented.//// Revision 1.7 2002/05/15 00:38:18 franz// Started to switch to Qt3.// Class LxRemittanceViewButton renamed to LxPushButton.// Layout of LxAccountSelectDialog improved.//// Revision 1.6 2002/05/05 18:31:35 franz// Started with the implementatation of remittance views.//// Revision 1.5 2002/04/23 22:13:15 franz// File LxAccountStmtList.h renamed to LxAccount.h// File LxAccountStmtList.cc renamed to LxAccount.cc//// Revision 1.4 2002/04/22 23:53:16 franz// Account open dialog implemented. This dialog presents a list of all// existing accounts. The information where the account data files are// located is stored in the LxBank resource directory '~/.LxBank' in the// file 'accounts.dat'.//// 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 <qapplication.h>#include <qfile.h> #include <qlayout.h>#include <qhbox.h>#include <qvbox.h> #include <qgrid.h> #include <qstringlist.h> #include <qregexp.h> #include <qtextstream.h> #include <qstatusbar.h> #include <qtoolbar.h> #include <qiconset.h> #include <qtoolbutton.h>#include <qpushbutton.h> #include <qpixmap.h>#include <qpaintdevicemetrics.h>#include <qtabwidget.h>#include <qlabel.h> #include <qprinter.h>#include <qpainter.h>#include <qptrlist.h>#include <stream.h>#include <math.h>#include "LxMainWin.h"#include "LxPushButtonActions.h"#include "exit.xpm"#include "open.xpm"#include "close.xpm"#include "print.xpm"#include "users.xpm"#include "newuser.xpm"LxMainWin::LxMainWin( LxHbci *hbciapi, QApplication *qa, QWidget *parent, const char *name ) : QMainWindow( parent, name ), hbciApi(hbciapi), app(qa), account(0), prtStm(0){ QFontMetrics fm(font()); int labelWidth; // Menu bar menu = new LxMainMenu(hbciApi, this, "mainMenu"); // Account data window QVBox *mBox = new QVBox( this, "mbox" ); QHBox *topBox = new QHBox ( mBox, "topbox" ); topBox->setFrameStyle ( QFrame::Box | QFrame::Sunken ); topBox->setLineWidth( 2 ); QGrid *leftBox = new QGrid (2, topBox, "leftbox" ); QHBox *centerBox = new QHBox ( topBox, "centerbox" ); QGrid *rightBox = new QGrid (2, topBox, "rightbox" ); topBox->setStretchFactor ( centerBox, 1 ); leftBox->setSpacing (5); leftBox->setMargin (5); rightBox->setSpacing (5); rightBox->setMargin (5); QLabel *lBank = new QLabel(tr("Institute:"), leftBox, "instituteLab"); Bank = new QLabel("...............", leftBox, "institute"); QLabel *lInhaber = new QLabel(tr("Customer:"), leftBox, "customerLab"); Inhaber = new QLabel("...............", leftBox, "customer"); labelWidth = fm.boundingRect( lInhaber->text() ).width() + 5; lBank->setFixedWidth ( labelWidth ); lInhaber->setFixedWidth ( labelWidth ); Konto = new QLabel(tr("Account"), centerBox, "account"); KontoFont = font(); KontoFont.setPointSize( 12 ); KontoFont.setBold ( TRUE ); Konto->setFont( KontoFont ); QFontMetrics fmK(Konto->font()); labelWidth = fmK.boundingRect( Konto->text() ).width() * 120 / 100; Konto->setFixedWidth ( labelWidth ); QLabel *lBLZ = new QLabel(tr("BLZ:"), rightBox, "blz"); BLZ = new QLabel("........", rightBox, "BLZ"); QLabel *lKtonumber = new QLabel(tr("Account-Id:"), rightBox, "ktonumber"); KtoNumber = new QLabel("..........", rightBox, "KtoNumber"); labelWidth = fm.boundingRect( lKtonumber->text() ).width() + 5; lKtonumber->setFixedWidth ( labelWidth ); lBLZ->setFixedWidth ( labelWidth ); // tab widget QTabWidget *views = new QTabWidget ( mBox, "viewBox" ); views->setTabShape ( QTabWidget::Triangular ); // Account status line QHBox *bottomBox = new QHBox ( mBox, "bottombox" ); bottomBox->setFrameStyle ( QFrame::Box | QFrame::Sunken ); bottomBox->setLineWidth( 2 ); QWidget *bBox = new QWidget ( bottomBox, "bbox" ); QHBoxLayout *bottomBoxLayout = new QHBoxLayout ( bBox ); bottomBoxLayout->setSpacing (5); bottomBoxLayout->setMargin (5); QLabel *lLastAuszug = new QLabel(tr("Last account statement date:"), bBox, "lastAccStm"); bottomBoxLayout->addWidget( lLastAuszug ); LastAuszug = new QLabel(".........", bBox, "lLastAuszug"); bottomBoxLayout->addWidget( LastAuszug ); bottomBoxLayout->addStretch ( 1 ); QLabel *lKtoStand = new QLabel(tr("Balance:"), bBox, "balance"); bottomBoxLayout->addWidget( lKtoStand ); KontoStand = new QLabel(".......", bBox, "Balance"); bottomBoxLayout->addWidget( KontoStand ); // View of account statements accStmtBox = new LxAccountStmtView (views, "AccStmtListPage"); views->addTab ( accStmtBox, tr("Account Statements") ); // View of current remittances curRemBox = new LxRemittanceView( hbciApi, LxRemittance::current, Lx::New | Lx::View | Lx::Modify | Lx::Copy | Lx::Submit | Lx::Delete, views, "curRemBox" ); views->addTab ( curRemBox, tr("Current Transactions") ); // View of processed remittances procRemBox = new LxRemittanceView( hbciApi, LxRemittance::processed, Lx::View | Lx::Copy | Lx::Delete, views, "procRemBox" ); views->addTab ( procRemBox, tr("Processed Transactions") ); // Tool bar QPixmap exitpix( exit_xpm ); QPixmap openpix( open_xpm ); QPixmap closepix( close_xpm ); QPixmap printpix( print_xpm ); QPixmap newuserpix( newuser_xpm ); QPixmap userspix( users_xpm ); QIconSet exitIcon( exitpix ); QIconSet openIcon( openpix ); QIconSet closeIcon( closepix ); QIconSet printIcon( printpix ); QIconSet newuserIcon( newuserpix ); QIconSet usersIcon( userspix ); tools = new QToolBar ( this, "toolbar" );// tools->setHorizontalStretchable ( TRUE ); exit = new QToolButton ( exitIcon, tr("Exit"), tr("Terminates the application."), qApp, SLOT(quit()), tools, "exit" ); open = new QToolButton ( openIcon, tr("Open Account"), tr("Loads all account data."), menu, SLOT(open()), tools, "open" ); close = new QToolButton ( closeIcon, tr("Close Account"), tr("Closes the currently open account."), menu, SLOT(close()), tools, "close" ); print = new QToolButton ( printIcon, tr("Print Transaction"), tr("Prints all selected transactions."), menu, SLOT(print()), tools, "print" ); newuser = new QToolButton ( newuserIcon, tr("Create New User"), tr("Create a new user with the User-Add Wizzard."), menu, SLOT(createUser()), tools, "newuser" ); users = new QToolButton ( usersIcon, tr("User List"), tr("Brings up a dialog to manipulate user data."), menu, SLOT(users()), tools, "users" ); stat = new QStatusBar ( this, "aStatus" ); setCentralWidget ( mBox ); // setup signals connect( menu, SIGNAL(openAccount( LxAccount* )), this, SLOT(openAccount( LxAccount* )) ); connect( menu, SIGNAL(closeAccount( )), this, SLOT(closeAccount( )) ); connect( menu, SIGNAL(printAccStmt( )), this, SLOT(printAccountStmt( )) ); connect ( accStmtBox, SIGNAL( accountStmtViewChanged ( QListView* ) ), this, SLOT( updateAccountDataPrint( QListView* ) ) );}void LxMainWin::disconnectRecentAccount( ){ if ( account ){ // disconnect signals of recent account disconnect( account, SIGNAL(updateAccountDataView( const LxAccount& )), this, SLOT(updateAccountDataView( const LxAccount& )) ); disconnect( account, SIGNAL( updateAccountStmtView( AccountStmtList& )), accStmtBox, SLOT(updateAccountStmtView( AccountStmtList& )) ); disconnect( account, SIGNAL( updateCurrentRemittanceView( RemittanceList& )), curRemBox, SLOT(updateListView( RemittanceList& )) ); disconnect( account, SIGNAL( updateProcessedRemittanceView( RemittanceList& )), procRemBox, SLOT(updateListView( RemittanceList& )) ); } account = 0; accStmtBox->setAccount ( 0 ); curRemBox->setAccount ( 0 ); procRemBox->setAccount ( 0 );}void LxMainWin::connectActualAccount( ){ // setup signals of actual account connect( account, SIGNAL(updateAccountDataView( const LxAccount& )), this, SLOT(updateAccountDataView( const LxAccount& )) ); connect( account, SIGNAL( updateAccountStmtView( AccountStmtList& )), accStmtBox, SLOT(updateAccountStmtView( AccountStmtList& )) ); connect( account, SIGNAL( updateCurrentRemittanceView( RemittanceList& )), curRemBox, SLOT(updateListView( RemittanceList& )) ); connect( account, SIGNAL( updateProcessedRemittanceView( RemittanceList& )), procRemBox, SLOT(updateListView( RemittanceList& )) );}void LxMainWin::openAccount( LxAccount *acc ){ if ( account ){ // disconnect signals of recent account account->close( ); disconnectRecentAccount (); } account = acc; accStmtBox->setAccount ( account ); curRemBox->setAccount ( account ); procRemBox->setAccount ( account ); connectActualAccount( ); account->open( );}void LxMainWin::closeAccount( ){ if ( account ){ account->close( ); disconnectRecentAccount( ); }} void LxMainWin::resetAccountDataView( ){ Bank->setText("..............."); KtoNumber->setText(".........."); BLZ->setText("........"); Konto->setText(tr("Account")); Inhaber->setText("..............."); LastAuszug->setText(""); KontoStand->setText("");}void LxMainWin::updateAccountDataView( const LxAccount &account ){// cerr << "LxMainWin::updateAccountDataView: Update of account data view requested!" << endl; if ( account.isOpened() ){ int labelWidth; Bank->setText(account.getInstitut()); KtoNumber->setText(account.getAccountNo()); BLZ->setText(account.getBLZ()); Konto->setText(account.getName()); QFontMetrics fmK(Konto->font()); labelWidth = fmK.boundingRect( Konto->text() ).width() * 120 / 100; Konto->setFixedWidth ( labelWidth ); Inhaber->setText(account.getInhaber()); LastAuszug->setText( account.getLastAccountStmtDate () ); KontoStand->setText(account.getKontoStand()); }else{ resetAccountDataView( ); disconnectRecentAccount (); }}void LxMainWin::updateAccountDataPrint( QListView* accStmtList ){// cerr << "LxMainWin::updateAccountDataPrint: Update of account printing requested!" << endl; if ( prtStm ){ delete prtStm; prtStm = 0; } if ( accStmtList->childCount () ){ prtStm = new LxAccountStmtPrint( accStmtList, Bank->text(), Inhaber->text(), BLZ->text(), KtoNumber->text(), Konto->text() ); }}void LxMainWin::printAccountStmt(){ if ( prtStm ){ AccListVItemList *selected = accStmtBox->getSelectedItems( ); if ( !selected->isEmpty() ) prtStm->print ( selected ); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -