00001 #include "selecttableofaccountdialog.h"
00002 #include "accountstabledialog.h"
00003 #include "../Data/settings.h"
00004 #include <QCloseEvent>
00005 #include <QDebug>
00006
00007 SelectTableOfAccountDialog::SelectTableOfAccountDialog(Settings &s, QWidget *parent) : QDialog(parent)
00008 {
00009 setupUi(this);
00010
00011
00012
00013 connect(buttonOpenTableOfAccount, SIGNAL(clicked()), this, SLOT(chooseTableOfAccounts()));
00014 connect(buttonNewTableOfAccount, SIGNAL(clicked()), this, SLOT(createTableOfAccount()));
00015
00016 settings = &s;
00017 }
00018
00019 void SelectTableOfAccountDialog::chooseTableOfAccounts()
00020 {
00021 QFileDialog dialog(this);
00022 QString path = "";
00023 while(path == "")
00024 {
00025 path = dialog.getOpenFileName(this, tr("Kontenplan öffnen"), settings->workspace().absolutePath(), tr("Allevo II Kontenplan (*.dbkk)"));
00026 }
00027
00028 sendPath(path);
00029 }
00030
00031 void SelectTableOfAccountDialog::createTableOfAccount()
00032 {
00033 QFileDialog dialog(this);
00034 QString path = "";
00035 while(path == "")
00036 {
00037 path = dialog.getSaveFileName(this, tr("Kontenplan erstellen"), settings->workspace().absolutePath(), tr("Allevo II Kontenplan (*.dbkk)"));
00038 }
00039
00040 AccountsTableDialog *accountsTable = new AccountsTableDialog(path, *settings, this);
00041 accountsTable->show();
00042
00043 connect(accountsTable, SIGNAL(tableOfAccountsCreated(QString)), this, SLOT(sendPath(QString)));
00044 }
00045
00046 void SelectTableOfAccountDialog::sendPath(QString path)
00047 {
00048 if(path != "")
00049 {
00050 emit tableOfAccountsChoosen(path);
00051
00052 done(QDialog::Accepted);
00053 }
00054 }
00055
00056 void SelectTableOfAccountDialog::closeEvent(QCloseEvent *event)
00057 {
00058 event->ignore();
00059 }