00001 #include "accountingrecord.h"
00002 #include <QTime>
00003 #include <QPushButton>
00004 #include <QLineEdit>
00005
00006 AccountingRecord::AccountingRecord(QWidget *parent, DateCalendar *dc) : QWidget(parent)
00007 {
00008 dateCalendar = dc;
00009 isSolution = false;
00010 }
00011
00012 AccountingRecord::~AccountingRecord()
00013 {
00014 qDebug()<<"AccountingRecord: destructor disabled -- triggers crash when deleting accountingrows - no time to investigate";
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 }
00030
00031 void AccountingRecord::createAccountingInformation(bool editable, QString date, QString accountingNumber, bool onlyLabel)
00032 {
00033 if(date != "" && accountingNumber != "")
00034 {
00035 if(onlyLabel)
00036 {
00037 p_accountingNumber = new QLabel(accountingNumber, this);
00038 p_date = new QLabel(date, this);
00039 }
00040 else
00041 {
00042 p_accountingNumber = new ALineEdit("S00", accountingNumber, this);
00043 p_date = new ALineEdit("Datum", date, this);
00044 dateCalendar->enableOn(qobject_cast<ALineEdit *>(p_date));
00045 }
00046 }
00047 else
00048 {
00049 p_accountingNumber = new ALineEdit("S00", this);
00050 p_date = new ALineEdit("Datum", this);
00051 dateCalendar->enableOn(qobject_cast<ALineEdit *>(p_date));
00052 }
00053 p_date->setEnabled(editable);
00054 p_accountingNumber->setEnabled(editable);
00055 if(onlyLabel)
00056 {
00057 p_date->setFixedWidth(50);
00058 p_accountingNumber->setFixedWidth(30);
00059 }
00060 else
00061 {
00062 p_date->setFixedWidth(90);
00063 p_accountingNumber->setFixedWidth(50);
00064 }
00065 }
00066
00067 void AccountingRecord::createAccounts(bool editable, bool debit, AccountModel *model, DataAccountingRecord *record, bool onlyLabel)
00068 {
00069 QList<QPair<int, double> *> *list;
00070 if(debit)
00071 {
00072 list = record->debits();
00073 }
00074 else
00075 {
00076 list = record->credits();
00077 }
00078
00079 for(int i = 0; i < list->size(); i++)
00080 {
00081 AccountingInformation info;
00082 QHBoxLayout *temp = new QHBoxLayout();
00083 if(editable)
00084 {
00085 QWidget *account;
00086 if(onlyLabel)
00087 {
00088 account = new QLabel(model->getFullNameByNumber(list->at(i)->first));
00089 }
00090 else
00091 {
00092 if(debit)
00093 {
00094 account = new AComboBox("Konto Soll", model, model->getFullNameByNumber(list->at(i)->first), this);
00095 }
00096 else
00097 {
00098 account = new AComboBox("Konto Haben", model, model->getFullNameByNumber(list->at(i)->first), this);
00099 }
00100 }
00101 info.insert("account", account);
00102 if(onlyLabel)
00103 {
00104 account->setFixedWidth(220);
00105 }
00106 else
00107 {
00108 account->setFixedWidth(200);
00109 }
00110 if(!onlyLabel)
00111 {
00112 static_cast<AComboBox*>(account)->setEditable(editable);
00113 }
00114 temp->addWidget(account);
00115 if(!onlyLabel)
00116 {
00117 if(debit)
00118 {
00119 disconnect(account, SIGNAL(currentIndexChanged(int)), 0, 0);
00120 connect(account, SIGNAL(currentIndexChanged(int)), this, SLOT(addMoreDebit(int)));
00121 }
00122 else
00123 {
00124 disconnect(account, SIGNAL(currentIndexChanged(int)), 0, 0);
00125 connect(account, SIGNAL(currentIndexChanged(int)), this, SLOT(addMoreCredit(int)));
00126 }
00127 connect(qobject_cast<AComboBox*>(account)->lineEdit(), SIGNAL(editingFinished()), this, SLOT(checkDeletionNeeded()));
00128 }
00129 }
00130 else
00131 {
00132 QWidget *account;
00133 if(onlyLabel)
00134 {
00135 account = new QLabel(model->getFullNameByNumber(list->at(i)->first));
00136 }
00137 else
00138 {
00139 if(debit)
00140 {
00141 account = new ALineEdit("Konto Soll", model->getFullNameByNumber(list->at(i)->first), this);
00142 }
00143 else
00144 {
00145 account = new ALineEdit("Konto Haben", model->getFullNameByNumber(list->at(i)->first), this);
00146 }
00147 }
00148 info.insert("account", account);
00149 if(onlyLabel)
00150 {
00151 account->setFixedWidth(220);
00152 }
00153 else
00154 {
00155 account->setFixedWidth(200);
00156 }
00157 account->setEnabled(editable);
00158 temp->addWidget(account);
00159 }
00160 QWidget *amount;
00161 if(onlyLabel)
00162 {
00163 amount = new QLabel(QString::number(list->at(i)->second));
00164 }
00165 else
00166 {
00167 if(debit)
00168 {
00169 amount = new ALineEdit("Soll", QString::number(list->at(i)->second), this);
00170 }
00171 else
00172 {
00173 amount = new ALineEdit("Haben", QString::number(list->at(i)->second), this);
00174 }
00175 }
00176 if(onlyLabel)
00177 {
00178 amount->setFixedWidth(30);
00179 }
00180 else
00181 {
00182 amount->setFixedWidth(80);
00183 }
00184 amount->setEnabled(editable);
00185
00186 info.insert("amount", amount);
00187 ABool *correct = new ABool();
00188 correct->setValue(true);
00189 info.insert("correct", correct);
00190
00191 temp->addWidget(amount);
00192 if(debit)
00193 {
00194 p_debitList->append(info);
00195 p_debitLayout->addLayout(temp);
00196 }
00197 else
00198 {
00199 p_creditList->append(info);
00200 p_creditLayout->addLayout(temp);
00201 }
00202 }
00203 }
00204
00205 void AccountingRecord::createEmptyAccounts(bool debit, AccountModel *model)
00206 {
00207 AComboBox *account = NULL;
00208 ALineEdit *amount = NULL;
00209 if(debit)
00210 {
00211 account = new AComboBox("Konto Soll", model, this);
00212 amount = new ALineEdit("Soll", this);
00213 }
00214 else
00215 {
00216 account = new AComboBox("Konto Haben", model, this);
00217 amount = new ALineEdit("Haben", this);
00218 }
00219 account->setEditable(true);
00220 account->setFixedWidth(200);
00221 amount->setEnabled(false);
00222 amount->setFixedWidth(80);
00223
00224 if(debit)
00225 {
00226 disconnect(account, SIGNAL(currentIndexChanged(int)), 0, 0);
00227 connect(account, SIGNAL(currentIndexChanged(int)), this, SLOT(addMoreDebit(int)));
00228 }
00229 else
00230 {
00231 disconnect(account, SIGNAL(currentIndexChanged(int)), 0, 0);
00232 connect(account, SIGNAL(currentIndexChanged(int)), this, SLOT(addMoreCredit(int)));
00233 }
00234 connect(account->lineEdit(), SIGNAL(editingFinished()), this, SLOT(checkDeletionNeeded()));
00235
00236 AccountingInformation info;
00237 info.insert("account", account);
00238 info.insert("amount", amount);
00239 ABool *correct = new ABool();
00240 correct->setValue(true);
00241 info.insert("correct", correct);
00242
00243 QHBoxLayout *temp = new QHBoxLayout();
00244 temp->addWidget(account);
00245 temp->addWidget(amount);
00246 if(debit)
00247 {
00248 p_debitList->append(info);
00249 p_debitLayout->addLayout(temp);
00250 }
00251 else
00252 {
00253 p_creditList->append(info);
00254 p_creditLayout->addLayout(temp);
00255 }
00256 }
00257
00258 void AccountingRecord::createLayout(bool printer)
00259 {
00260 p_all = new QHBoxLayout();
00261 if(!printer)
00262 {
00263 p_all->addSpacerItem(new QSpacerItem(30, 0, QSizePolicy::Fixed, QSizePolicy::Fixed));
00264 }
00265 p_all->addWidget(p_accountingNumber);
00266 p_all->addWidget(p_date);
00267 if(!printer)
00268 {
00269 p_all->addSpacerItem(new QSpacerItem(30, 0, QSizePolicy::Fixed, QSizePolicy::Fixed));
00270 }
00271 p_all->addLayout(p_debitLayout);
00272 QSvgWidget *svg = new QSvgWidget(":/account/Bar");
00273 svg->setFixedWidth(5);
00274 p_all->addWidget(svg);
00275 p_all->addLayout(p_creditLayout);
00276 if(!printer)
00277 {
00278 p_all->addSpacerItem(new QSpacerItem(50, 0, QSizePolicy::Expanding, QSizePolicy::Expanding));
00279 }
00280 setLayout(p_all);
00281
00282 this->resize(layout()->sizeHint());
00283 }
00284
00285 void AccountingRecord::createWidgetForExercise(bool editable, AccountModel *model, bool solution, DataAccountingRecord *record)
00286 {
00287 p_debitList = new QList<AccountingInformation>();
00288 p_creditList = new QList<AccountingInformation>();
00289 p_debitLayout = new QVBoxLayout();
00290 p_creditLayout = new QVBoxLayout();
00291 p_currentAccountModel = model;
00292
00293 isSolution = solution;
00294
00295 if(!record)
00296 {
00297 createAccountingInformation(editable);
00298 }
00299 if(record)
00300 {
00301 createAccountingInformation(editable, record->date().toString("dd.MM.yyyy"), record->documentNumber());
00302 createAccounts(editable, true, model, record);
00303 createAccounts(editable, false, model, record);
00304 }
00305 if(editable)
00306 {
00307 createEmptyAccounts(true, model);
00308 createEmptyAccounts(false, model);
00309 }
00310
00311 createLayout(false);
00312 if(editable)
00313 {
00314 makeConnects();
00315 }
00316 }
00317
00318 void AccountingRecord::createWidgetForPrinter(AccountModel *model, DataAccountingRecord *record)
00319 {
00320 p_debitList = new QList<AccountingInformation>();
00321 p_creditList = new QList<AccountingInformation>();
00322 p_debitLayout = new QVBoxLayout();
00323 p_creditLayout = new QVBoxLayout();
00324 p_currentAccountModel = model;
00325
00326 if(record)
00327 {
00328 createAccountingInformation(true, record->date().toString("dd.MM.yyyy"), record->documentNumber(), true);
00329 createAccounts(true, true, model, record, true);
00330 createAccounts(true, false, model, record, true);
00331 }
00332 createLayout(true);
00333 }
00334
00335 void AccountingRecord::checkDeletionNeeded()
00336 {
00337 if(qobject_cast<AComboBox*>(sender()->parent())->currentText() == "" || qobject_cast<AComboBox*>(sender()->parent())->currentText() == "Konto Soll" || qobject_cast<AComboBox*>(sender()->parent())->currentText() == "Konto Haben")
00338 {
00339 qobject_cast<AComboBox*>(sender()->parent())->setCurrentIndex(0);
00340 }
00341 }
00342
00343 void AccountingRecord::addMoreDebit(int index)
00344 {
00345
00346
00347
00348
00349 if(index == 0)
00350 {
00351 for(int i = 0; i < p_debitList->size()-1; i++)
00352 {
00353 if(qobject_cast<AComboBox*>(p_debitList->value(i).value("account"))->currentIndex() == index)
00354 {
00355 QLayoutItem *item;
00356 item = p_debitLayout->takeAt(i);
00357
00358 delete (qobject_cast<ALineEdit*>)(p_debitList->value(i).value("amount"));
00359
00360 qobject_cast<AComboBox*>(p_debitList->value(i).value("account"))->clearFocus();
00361 qDebug()<<"AComboBox: "<< qobject_cast<AComboBox*>(p_debitList->value(i).value("account"));
00362
00363 qobject_cast<AComboBox*>(p_debitList->value(i).value("account"))->deleteLater();
00364
00365 p_debitLayout->removeItem(item);
00366 delete item;
00367
00368 p_debitList->removeAt(i);
00369 i = p_debitList->size()-1;
00370 }
00371 }
00372 }
00373 else
00374 {
00375 int comboBoxWithIndex = 0;
00376 int lastCombBox = 0;
00377 for(int i = 0; i < p_debitList->size(); i++)
00378 {
00379 if(qobject_cast<AComboBox*>(p_debitList->value(i).value("account"))->currentIndex() == index)
00380 {
00381 comboBoxWithIndex++;
00382 lastCombBox = i;
00383 }
00384 }
00385 if(comboBoxWithIndex > 1)
00386 {
00387 emit sendErrorMessage("Dieses Konto exisitiert bereits auf der Soll-Seite");
00388 qobject_cast<AComboBox*>(p_debitList->value(lastCombBox).value("account"))->setCurrentIndex(0);
00389 return;
00390 }
00391 if(p_debitList->size() - 1 == lastCombBox)
00392 {
00393 (qobject_cast<ALineEdit*>(p_debitList->value(lastCombBox).value("amount")))->setEnabled(true);
00394
00395 AComboBox *account = new AComboBox("Konto Soll", p_currentAccountModel, this);
00396 account->setEditable(true);
00397 account->setFixedWidth(200);
00398 disconnect(account, SIGNAL(currentIndexChanged(int)), 0, 0);
00399 connect(account, SIGNAL(currentIndexChanged(int)), this, SLOT(addMoreDebit(int)));
00400 connect(account->lineEdit(), SIGNAL(editingFinished()), this, SLOT(checkDeletionNeeded()));
00401 ALineEdit *amount = new ALineEdit("Soll", this);
00402 amount->setFixedWidth(80);
00403 amount->setEnabled(false);
00404 connect(amount, SIGNAL(editingFinished()), this, SLOT(checkAmount()));
00405 connect(amount, SIGNAL(editingFinished()), this, SIGNAL(actualizeAccounts()));
00406
00407 QHBoxLayout *temp = new QHBoxLayout();
00408 temp->addWidget(account);
00409 temp->addWidget(amount);
00410 p_debitLayout->addLayout(temp);
00411
00412 AccountingInformation row1;
00413 row1.insert("account", account);
00414 row1.insert("amount", amount);
00415 ABool *correct = new ABool();
00416 correct->setValue(true);
00417 row1.insert("correct", correct);
00418 p_debitList->append(row1);
00419 }
00420 else
00421 {
00422 (qobject_cast<ALineEdit*>(p_debitList->value(lastCombBox).value("amount")))->setEnabled(true);
00423 }
00424 }
00425
00426 emit actualizeAccounts();
00427 }
00428
00429 void AccountingRecord::addMoreCredit(int index)
00430 {
00431
00432
00433
00434
00435 if(index == 0)
00436 {
00437 for(int i = 0; i < p_creditList->size()-1; i++)
00438 {
00439 if(qobject_cast<AComboBox*>(p_creditList->value(i).value("account"))->currentIndex() == index)
00440 {
00441 QLayoutItem *item;
00442 item = p_creditLayout->takeAt(i);
00443
00444
00445 delete (qobject_cast<ALineEdit*>)(p_creditList->value(i).value("amount"));
00446
00447 qobject_cast<AComboBox*>(p_creditList->value(i).value("account"))->clearFocus();
00448 qDebug()<<"AComboBox: "<< qobject_cast<AComboBox*>(p_creditList->value(i).value("account"));
00449
00450 qobject_cast<AComboBox*>(p_creditList->value(i).value("account"))->deleteLater();
00451
00452 p_creditLayout->removeItem(item);
00453 delete item;
00454
00455 p_creditList->removeAt(i);
00456 i = p_creditList->size()-1;
00457 }
00458 }
00459 }
00460 else
00461 {
00462 int comboBoxWithIndex = 0;
00463 int lastCombBox = 0;
00464 for(int i = 0; i != p_creditList->size(); i++)
00465 {
00466 if(qobject_cast<AComboBox*>(p_creditList->value(i).value("account"))->currentIndex() == index)
00467 {
00468 comboBoxWithIndex++;
00469 lastCombBox = i;
00470 }
00471 }
00472 if(comboBoxWithIndex > 1)
00473 {
00474 emit sendErrorMessage("Dieses Konto exisitiert bereits auf der Haben-Seite");
00475 qobject_cast<AComboBox*>(p_creditList->value(lastCombBox).value("account"))->setCurrentIndex(0);
00476 return;
00477 }
00478 if(p_creditList->size()-1 == lastCombBox)
00479 {
00480 (qobject_cast<ALineEdit*>(p_creditList->value(lastCombBox).value("amount")))->setEnabled(true);
00481
00482
00483 AComboBox *account = new AComboBox("Konto Haben", p_currentAccountModel, this);
00484 account->setEditable(true);
00485 account->setFixedWidth(200);
00486 disconnect(account, SIGNAL(currentIndexChanged(int)), 0, 0);
00487 connect(account, SIGNAL(currentIndexChanged(int)), this, SLOT(addMoreCredit(int)));
00488 connect(account->lineEdit(), SIGNAL(editingFinished()), this, SLOT(checkDeletionNeeded()));
00489
00490 ALineEdit *amount = new ALineEdit("Haben", this);
00491 amount->setFixedWidth(80);
00492 amount->setEnabled(false);
00493 connect(amount, SIGNAL(editingFinished()), this, SLOT(checkAmount()));
00494 connect(amount, SIGNAL(editingFinished()), this, SIGNAL(actualizeAccounts()));
00495
00496 QHBoxLayout *temp = new QHBoxLayout();
00497 temp->addWidget(account);
00498 temp->addWidget(amount);
00499 p_creditLayout->addLayout(temp);
00500
00501 AccountingInformation row1;
00502 row1.insert("account", account);
00503 row1.insert("amount", amount);
00504 ABool *correct = new ABool();
00505 correct->setValue(true);
00506 row1.insert("correct", correct);
00507 p_creditList->append(row1);
00508 }
00509 else
00510 {
00511 (qobject_cast<ALineEdit*>(p_creditList->value(lastCombBox).value("amount")))->setEnabled(true);
00512 }
00513 }
00514
00515 emit actualizeAccounts();
00516 }
00517
00518 void AccountingRecord::save()
00519 {
00520 emit actualizeAccounts();
00521 }
00522
00523 void AccountingRecord::makeConnects()
00524 {
00525
00526 disconnect(p_accountingNumber, SIGNAL(editingFinished()), 0, 0);
00527 connect(p_accountingNumber, SIGNAL(editingFinished()), this, SIGNAL(actualizeAccounts()));
00528
00529 disconnect(p_date, SIGNAL(editingFinished()), 0, 0);
00530 connect(p_date, SIGNAL(editingFinished()), this, SIGNAL(actualizeAccounts()));
00531
00532
00533 for(int i = 0; i < p_debitList->size(); i++)
00534 {
00535 ALineEdit *line = qobject_cast<ALineEdit*>(p_debitList->value(i).value("amount"));
00536
00537 disconnect(line, SIGNAL(editingFinished()), 0, 0);
00538 connect(line, SIGNAL(editingFinished()), this, SIGNAL(actualizeAccounts()));
00539 connect(line, SIGNAL(editingFinished()), this, SLOT(checkAmount()));
00540 }
00541
00542
00543 for(int i = 0; i < p_creditList->size(); i++)
00544 {
00545 ALineEdit *line = qobject_cast<ALineEdit*>(p_creditList->value(i).value("amount"));
00546
00547 disconnect(line, SIGNAL(editingFinished()), 0, 0);
00548 connect(line, SIGNAL(editingFinished()), this, SIGNAL(actualizeAccounts()));
00549 connect(line, SIGNAL(editingFinished()), this, SLOT(checkAmount()));
00550 }
00551 }
00552
00553 void AccountingRecord::checkAmount()
00554 {
00555 QRegExp check;
00556 QRegExp check2;
00557 check.setPattern("^[0-9]*,[0-9]{1,2}$");
00558 check2.setPattern("^[0-9]*$");
00559
00560
00561 for(int i = 0; i < p_debitList->size()-1; i++)
00562 {
00563
00564 if(check.exactMatch(qobject_cast<ALineEdit*>(p_debitList->value(i).value("amount"))->text()) || check2.exactMatch(qobject_cast<ALineEdit*>(p_debitList->value(i).value("amount"))->text()) || qobject_cast<ALineEdit*>(p_debitList->value(i).value("amount"))->text() == "Soll")
00565 {
00566
00567 }
00568 else
00569 {
00570
00571 QString message = "Der Betrag des Soll-Kontos """;
00572 message += qobject_cast<AComboBox*>(p_debitList->value(i).value("account"))->currentText();
00573 message += """ ist nicht gültig";
00574
00575 qobject_cast<ALineEdit*>(p_debitList->value(i).value("amount"))->setText("Soll");
00576
00577 emit sendErrorMessage(message);
00578
00579 return ;
00580 }
00581 }
00582
00583 for(int i = 0; i < p_creditList->size()-1; i++)
00584 {
00585 if(check.exactMatch(qobject_cast<ALineEdit*>(p_creditList->value(i).value("amount"))->text()) || check2.exactMatch(qobject_cast<ALineEdit*>(p_creditList->value(i).value("amount"))->text()) || qobject_cast<ALineEdit*>(p_creditList->value(i).value("amount"))->text() == "Haben")
00586 {
00587
00588 }
00589 else
00590 {
00591 QString message = "Der Betrag des Haben-Kontos """;
00592 message += qobject_cast<AComboBox*>(p_creditList->value(i).value("account"))->currentText();
00593 message += """ ist nicht gültig";
00594
00595 qobject_cast<ALineEdit*>(p_creditList->value(i).value("amount"))->setText("Haben");
00596
00597 emit sendErrorMessage(message);
00598
00599 return ;
00600 }
00601 }
00602 }
00603
00604 void AccountingRecord::saveIntoData(DataExercise *data)
00605 {
00606
00607
00608 DataAccountingRecord *record = new DataAccountingRecord();
00609 if(static_cast<ALineEdit*>(p_date)->text() != "Datum")
00610 {
00611 record->setDate(static_cast<ALineEdit*>(p_date)->text());
00612 }
00613 else
00614 {
00615 record->setDate("");
00616 }
00617 if(static_cast<ALineEdit*>(p_accountingNumber)->text() != "S00")
00618 {
00619 record->setDocumentNumberValue(static_cast<ALineEdit*>(p_accountingNumber)->text());
00620 }
00621 else
00622 {
00623 record->setDocumentNumberValue("");
00624 }
00625
00626
00627
00628 for(int i = 0; i < (p_debitList->size() - 1); i++)
00629 {
00630 AComboBox *comboBox = qobject_cast<AComboBox*>(p_debitList->value(i).value("account"));
00631 ALineEdit *lineEdit = qobject_cast<ALineEdit*>(p_debitList->value(i).value("amount"));
00632 QPair<int, double> *debit = new QPair<int, double>();
00633 if(comboBox)
00634 {
00635 if(comboBox->currentText() != "Konto Soll" && comboBox->currentText() != "")
00636 {
00637 QStringList list = comboBox->currentText().split(" ");
00638 debit->first = QVariant(list.value(0)).toInt();
00639 if(lineEdit->text() != "Soll")
00640 {
00641 debit->second = QVariant(lineEdit->text()).toDouble();
00642 }
00643 else
00644 {
00645 debit->second = 0.0;
00646 }
00647 record->debits()->append(debit);
00648 }
00649 }
00650 else
00651 {
00652 qDebug()<<"debits combobox doesn't exist -- not everything will be saved!";
00653 }
00654 }
00655
00656
00657 for(int i = 0; i < (p_creditList->size() - 1); i++)
00658 {
00659 AComboBox *comboBox = qobject_cast<AComboBox*>(p_creditList->value(i).value("account"));
00660 ALineEdit *lineEdit = qobject_cast<ALineEdit*>(p_creditList->value(i).value("amount"));
00661 QPair<int, double> *credit = new QPair<int, double>();
00662 if(comboBox)
00663 {
00664 if(comboBox->currentText() != "Konto Haben" && comboBox->currentText() != "")
00665 {
00666 QStringList list = comboBox->currentText().split(" ");
00667 credit->first = QVariant(list.value(0)).toInt();
00668 if(lineEdit->text() != "Haben")
00669 {
00670 credit->second = QVariant(lineEdit->text()).toDouble();
00671 }
00672 else
00673 {
00674 credit->second = 0.0;
00675 }
00676 record->credits()->append(credit);
00677 }
00678 }
00679 else
00680 {
00681 qDebug()<<"credits combobox doesn't exist -- not everything will be saved!";
00682 }
00683 }
00684 if(isSolution)
00685 {
00686 data->solutionRecords()->append(record);
00687 }
00688 else
00689 {
00690 data->accountingRecords()->append(record);
00691 }
00692 }
00693
00694 AccountingInformation *AccountingRecord::accountingRowInfos()
00695 {
00696 AccountingInformation *returnValue = new AccountingInformation();
00697
00698 returnValue->insert(QString("accountingNumber"), QPointer<QObject>(this->p_accountingNumber));
00699 returnValue->insert(QString("date"), QPointer<QObject>(this->p_date));
00700 return returnValue;
00701 }
00702
00703 void AccountingRecord::printAccountingRecord()
00704 {
00705 qDebug()<<"*********PRINTING**********";
00706 qDebug()<<"DEBITS:";
00707 qDebug()<<"size: "<<p_debitList->size();
00708 for(int i = 0; i < p_debitList->size(); i++)
00709 {
00710 qDebug()<<qobject_cast<AComboBox*>(p_debitList->value(i).value("account"))->currentText()<<" "<<qobject_cast<ALineEdit*>(p_debitList->value(i).value("amount"))->text();
00711 }
00712 qDebug()<<"CREDITS:";
00713 qDebug()<<"size: "<<p_creditList->size();
00714 for(int i = 0; i < p_creditList->size(); i++)
00715 {
00716 qDebug()<<qobject_cast<AComboBox*>(p_creditList->value(i).value("account"))->currentText()<<" "<<qobject_cast<ALineEdit*>(p_creditList->value(i).value("amount"))->text();
00717 }
00718 qDebug()<<"******END*PRINTING*******";
00719 }
00720
00721 void AccountingRecord::deleteWidget()
00722 {
00723 QLayoutItem *item;
00724
00725 dateCalendar->disableOn(qobject_cast<ALineEdit *>(p_date));
00726
00727 while(item = layout()->takeAt(0))
00728 {
00729 if((item->widget()) != 0)
00730 {
00731 layout()->removeWidget(item->widget());
00732 delete item->widget();
00733 }
00734 else if((item->layout()) != 0)
00735 {
00736 QLayout *layout = item->layout();
00737 while(item = layout->takeAt(0))
00738 {
00739 if((item->widget()) != 0)
00740 {
00741 layout->removeWidget(item->widget());
00742 delete item->widget();
00743 }
00744 else if((item->layout()) != 0)
00745 {
00746 QLayout *layout = item->layout();
00747 while(item = layout->takeAt(0))
00748 {
00749 if((item->widget()) != 0)
00750 {
00751 layout->removeWidget(item->widget());
00752 delete item->widget();
00753 }
00754 else if((item->spacerItem()) != 0)
00755 {
00756 layout->removeItem(item);
00757 delete item->spacerItem();
00758 }
00759 }
00760 delete layout;
00761 }
00762 else if((item->spacerItem()) != 0)
00763 {
00764 layout->removeItem(item);
00765 delete item->spacerItem();
00766 }
00767 }
00768 delete layout;
00769 }
00770 else if((item->spacerItem()) != 0)
00771 {
00772 layout()->removeItem(item);
00773 delete item->spacerItem();
00774 }
00775 }
00776 delete layout();
00777 }
00778
00779 void AccountingRecord::resetStyle()
00780 {
00781 setOriginalStyle(p_date);
00782 setOriginalStyle(p_accountingNumber);
00783
00784
00785 for(int i = 0; i < p_debitList->count(); i++)
00786 {
00787 AccountingInformation info = p_debitList->value(i);
00788
00789 AComboBox *combo = qobject_cast<AComboBox*>(info.value("account"));
00790 setOriginalStyle(combo);
00791
00792 ALineEdit *line = qobject_cast<ALineEdit*>(info.value("amount"));
00793 setOriginalStyle(line);
00794
00795 p_debitList->replace(i, info);
00796 }
00797
00798
00799 for(int i = 0; i < p_creditList->count(); i++)
00800 {
00801 AccountingInformation info = p_creditList->value(i);
00802
00803 AComboBox *combo = qobject_cast<AComboBox*>(info.value("account"));
00804 setOriginalStyle(combo);
00805
00806 ALineEdit *line = qobject_cast<ALineEdit*>(info.value("amount"));
00807 setOriginalStyle(line);
00808
00809 p_creditList->replace(i, info);
00810 }
00811 }
00812
00813 void AccountingRecord::setOriginalStyle(QWidget *widget)
00814 {
00815
00816 ALineEdit *lineEdit = qobject_cast<ALineEdit *>(widget);
00817 if(lineEdit)
00818 {
00819 lineEdit->resetStyle();
00820 }
00821
00822 AComboBox *comboBox = qobject_cast<AComboBox *>(widget);
00823 if(comboBox)
00824 {
00825 comboBox->resetStyle();
00826 }
00827 }