FreeDebks  1.0.3
 All Classes Files Functions Variables Friends Pages
FdDialogPrintOptions.cpp
Go to the documentation of this file.
1 // --------------------------------------------------------------------
2 // Copyright © 2011-2013 Mathieu Schopfer
3 //
4 // This file is part of FreeDebks.
5 //
6 // FreeDebks is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // FreeDebks is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with FreeDebks. If not, see <http://www.gnu.org/licenses/>.
18 // --------------------------------------------------------------------
19 
20 #include "FdDialogPrintOptions.hpp"
21 #include "../data/FdModelCoa.hpp"
22 #include "../data/FdItemCoa.hpp"
23 
25  QDialog(parent)
26 {
27  setupUi(this);
28 
29  QList<FdItemCoa_p> accounts = coa->accounts();
30  accountsWidget->setRowCount(accounts.size());
31  accountsWidget->setColumnCount(2);
32  accountsWidget->setColumnWidth(0, 50);
33  accountsWidget->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch);
34 
35  for(int i = 0; i < accounts.size(); ++i)
36  {
37  accountsWidget->setItem(i, 0, new QTableWidgetItem(accounts[i]->id()));
38  accountsWidget->setItem(i, 1, new QTableWidgetItem(accounts[i]->label()));
39  }
40  accountsWidget->selectAll();
41 }
42 
53 {
54  QStringList elements;
55  elements.insert(PrintCoa, QString::number(inPrintCoa->checkState()));
56  elements.insert(PrintJournal, QString::number(inPrintJournal->checkState()));
57  elements.insert(PrintResults, QString::number(inPrintResults->checkState()));
58  elements.insert(PrintAccounts, QString::number(inPrintAccounts->checkState()));
59 
60  if(inPrintAccounts->checkState())
61  {
62  QList<QTableWidgetItem*> items = accountsWidget->selectedItems();
63  for(int i = 0; i < items.size()/2; ++i)
64  elements << items[i]->text();
65  }
66 
67  return elements;
68 }