📄 lxaccountselectdialog.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 LxAccountSelectDialog: Account selection dialog for LxBank*/ // ***************************************************************************//// $Name: $//// $State: Exp $//// $Log: LxAccountSelectDialog.cc,v $// Revision 1.10 2003/05/01 14:06:19 arafang// Format of bank code data file changed: was blz.txt - ascii, new blz.bin - binary//// Revision 1.9 2003/02/20 02:38:03 arafang// Default args in some constructor implementions removed.//// Revision 1.8 2003/02/08 15:25:20 franz// Mail address changed.//// Revision 1.7 2003/02/03 23:06:10 franz// Class LxRemittance adapted to needs of HBCI. Remittances saved on Account// config. LxRemittanceWorkDialog and constructor of class LxRemittance improved// to avoid possible core dumps with QString method latin1 and class QStringList.// Make checks in LxAccount::updateBalanceAndAccStmt weather a job has been// performed successfully or not.//// Revision 1.6 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.5 2003/01/07 22:09:31 franz// Added user list dialog.//// 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/05/15 00:38:18 franz// Started to switch to Qt3.// Class LxRemittanceViewButton renamed to LxPushButton.// Layout of LxAccountSelectDialog improved.//// Revision 1.1 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'.////#ifdef HAVE_CONFIG_H#include <config.h>#endif#include "LxAccountSelectDialog.h"#include "LxPushButtonActions.h"#include <qpushbutton.h>#include <qlistview.h> #include <qlayout.h>#include <qsignalmapper.h>#include <qmessagebox.h>// LxAccountSelectDialog::LxAccountSelectDialog(AccountList *acclist,// int buttonFlags, QString cap,// QWidget *parent=0, const char *name, // bool modal, WFlags f)// : QDialog( parent, name, modal, f ), hbciApi(0), accList(acclist), openButton(0),// saveButton(0), editButton(0), deleteButton(0), closeButton(0)// {// setCaption(tr(cap));// sm = new QSignalMapper( this );// vBox = new QVBoxLayout( this, 3, 5, "ASD-VBox" );// lView = new QListView( this, "AccountsList" );// vBox->addWidget( lView, 10 );// lView->setAllColumnsShowFocus ( TRUE ); // lView->setSelectionMode ( QListView::Single );// int c1, c2, c3, c4, c5;// c1 = lView->addColumn ( tr("No.") );// c2 = lView->addColumn ( tr("Account Name") ); // c3 = lView->addColumn ( tr("Institute") ); // c4 = lView->addColumn ( tr("Account Owner") ); // c5 = lView->addColumn ( tr("Account Number") );// // setColumnAlignment ( c4, AlignRight );// lView->setItemMargin ( 2 );// hBox = new QHBoxLayout(vBox, 3, "ASD-HBox");// hBox->addStretch ( 10 );// createButtons1 ( buttonFlags );// setupAccountList ();// connect( lView, SIGNAL( selectionChanged(QListViewItem *) ),// this, SLOT( selectionChanged(QListViewItem *) ) );// connect( lView, SIGNAL( pressed(QListViewItem *) ),// this, SLOT( pressedInList(QListViewItem *) ) );// connect(lView, SIGNAL( doubleClicked ( QListViewItem * ) ), // this, SLOT(selectionDone(QListViewItem *)) );// connect(lView, SIGNAL( returnPressed ( QListViewItem * ) ), // this, SLOT(selectionDone(QListViewItem *)) );// connect( sm, SIGNAL( mapped( int )), this, SLOT( done( int ) ));// }LxAccountSelectDialog::LxAccountSelectDialog(LxHbci *hbciapi, AccountList *acclist, int buttonFlags, QString cap, QWidget *parent, const char *name, bool modal, WFlags f) : QDialog( parent, name, modal, f ), hbciApi(hbciapi), accList(acclist), openButton(0), saveButton(0), editButton(0), deleteButton(0), closeButton(0){ setCaption(tr(cap)); sm = new QSignalMapper( this ); vBox = new QVBoxLayout( this, 3, 5, "ASD-VBox" ); lView = new QListView( this, "AccountsList" ); vBox->addWidget( lView, 10 ); lView->setAllColumnsShowFocus ( TRUE ); lView->setSelectionMode ( QListView::Single ); int c1, c2, c3, c4, c5; c1 = lView->addColumn ( tr("No.") ); c2 = lView->addColumn ( tr("Account Name") ); c3 = lView->addColumn ( tr("Institute") ); c4 = lView->addColumn ( tr("Account Owner") ); c5 = lView->addColumn ( tr("Account Number") ); // setColumnAlignment ( c4, AlignRight ); lView->setItemMargin ( 2 ); hBox = new QHBoxLayout(vBox, 3, "ASD-HBox"); hBox->addStretch ( 10 ); createButtons ( buttonFlags ); setupAccountList (); connect( lView, SIGNAL( selectionChanged(QListViewItem *) ), this, SLOT( selectionChanged(QListViewItem *) ) ); connect( lView, SIGNAL( pressed(QListViewItem *) ), this, SLOT( pressedInList(QListViewItem *) ) ); connect(lView, SIGNAL( doubleClicked ( QListViewItem * ) ), this, SLOT(selectionDone(QListViewItem *)) ); connect(lView, SIGNAL( returnPressed ( QListViewItem * ) ), this, SLOT(selectionDone(QListViewItem *)) ); connect( sm, SIGNAL( mapped( int )), this, SLOT( done( int ) ));}// void LxAccountSelectDialog::createButtons1( int buttonFlags )// {// if ( buttonFlags & Lx::Open ){// openButton = new QPushButton(tr("Open"), this);// addButton( openButton, Lx::Open );// }// if ( buttonFlags & Lx::Save ){// saveButton = new QPushButton(tr("Save"), this);// addButton( saveButton, Lx::Save );// }// if ( buttonFlags & Lx::Dismiss ){// closeButton = new QPushButton(tr("Dismiss"), this);// addButton( closeButton, Lx::Dismiss );// }// if ( buttonFlags & Lx::Cancel ){// closeButton = new QPushButton(tr("Cancel"), this);// addButton( closeButton, Lx::Cancel );// }// }void LxAccountSelectDialog::createButtons( int buttonFlags ){ if ( buttonFlags & Lx::Open ){ openButton = new QPushButton(tr("Open"), this); addButton( openButton, Lx::Open ); } if ( buttonFlags & Lx::Save ){ saveButton = new QPushButton(tr("Save"), this); addButton( saveButton, Lx::Save ); } if ( buttonFlags & Lx::Edit ){ editButton = new QPushButton(tr("Edit"), this); addButton( editButton, 0 ); connect( editButton, SIGNAL( clicked() ), this, SLOT( edit() ) ); } if ( buttonFlags & Lx::Delete ){ deleteButton = new QPushButton(tr("Delete"), this); addButton( deleteButton, 0 ); connect( deleteButton, SIGNAL( clicked() ), this, SLOT( remove() ) ); } if ( buttonFlags & Lx::Dismiss ){ closeButton = new QPushButton(tr("Dismiss"), this); addButton( closeButton, Lx::Dismiss ); } if ( buttonFlags & Lx::Cancel ){ closeButton = new QPushButton(tr("Cancel"), this); addButton( closeButton, Lx::Cancel ); }}void LxAccountSelectDialog::addButton( QPushButton *button, int result ){ hBox->addWidget ( button, 0 ); hBox->addStretch ( 10 ); if ( result ){ sm->setMapping( button, result ); connect( button, SIGNAL( clicked() ), sm, SLOT( map() ) ); }}void LxAccountSelectDialog::setupAccountList (){ LxAccount *account; lView->clear(); for ( account = accList->first(); account != 0; account = accList->next() ) { addAccountToList ( account ); } QListViewItem *item; item = lView->firstChild (); if (item){ lView->setSelected ( item, TRUE ); } setButtonState ( item );}void LxAccountSelectDialog::addAccountToList (LxAccount* acc){ QListViewItem *item; item = new QListViewItem( lView, QString::number(acc->getId ()), acc->getName(), acc->getInstitut(), acc->getInhaber(), acc->getAccountNo() );}LxAccount* LxAccountSelectDialog::getSelectedAccount (){ int accountNo; LxAccount *account; QListViewItem *item; item = lView->selectedItem(); if ( item ){ accountNo = item->text(0).toInt(); for ( account = accList->first(); account != 0; account = accList->next() ){ if ( account->getId() == accountNo ){ break; } } }else{ account = 0; } return account; }void LxAccountSelectDialog::selectionDone ( QListViewItem *lvItem ){ done ( 1 ); }void LxAccountSelectDialog::selectionChanged ( QListViewItem *lvItem ){ setButtonState ( lvItem ); }void LxAccountSelectDialog::pressedInList ( QListViewItem *lvItem ){ setButtonState ( lvItem ); }void LxAccountSelectDialog::setButtonState ( QListViewItem *lvItem ){ if ( lvItem && lView->selectedItem() ){ if (saveButton) saveButton->setEnabled(TRUE); if (openButton) openButton->setEnabled(TRUE); if (deleteButton) deleteButton->setEnabled(TRUE); if (editButton) editButton->setEnabled(TRUE); }else{ if (saveButton) saveButton->setEnabled(FALSE); if (openButton) openButton->setEnabled(FALSE); if (deleteButton) deleteButton->setEnabled(FALSE); if (editButton) editButton->setEnabled(FALSE); }}void LxAccountSelectDialog::edit(){ QMessageBox::information ( this, tr("Edit Account"), tr("Not yet implemented!\n"), QMessageBox::Ok, 0);}void LxAccountSelectDialog::remove(){ LxAccount *account = getSelectedAccount (); if ( account ){ switch( QMessageBox::warning ( this, tr("Confirm Delete"), tr("Do you really want to delete this account?"), tr("Ok"), tr("Cancel"), QString::null, 1, 1 ) ){ case 0: // The user clicked the Ok button removeAccount ( account ); break; case 1: // The user clicked the Cancel button, or pressed Enter or Escape return; break; } }}void LxAccountSelectDialog::removeAccount( LxAccount *acc ){ const HBCI::Pointer<HBCI::Account> &hbciAcc = acc->HBCIaccount(); HBCI::Pointer<HBCI::Bank> bank = (*hbciAcc).bank (); // delete hbci account (*bank).removeAccount ( hbciAcc ); // remove lx-staff acc->close (); acc->clearConfig (); accList->remove ( acc ); delete acc; // setup list setupAccountList (); hbciApi->save ();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -