FreeDebks  1.0.3
 All Classes Files Functions Variables Friends Pages
FdSubWindow.hpp
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 #ifndef FDSUBWINDOW_HPP
21 #define FDSUBWINDOW_HPP
22 
23 #include <QMdiSubWindow>
24 #include <QTabWidget>
25 #include <QTreeView>
26 #include <QTableView>
27 #include <QCloseEvent>
28 #include <QAction>
29 #include <QFile>
30 #include <QFileDialog>
31 #include <QtXml>
32 #include <QTextStream>
33 #include <QPrintDialog>
34 #include <QPrinter>
35 #include <QPainter>
36 #include <QClipboard>
37 
38 #include "guiDefinitions.hpp"
39 
41 
49 class FdSubWindow : public QMdiSubWindow
50 {
51 Q_OBJECT
52 
53 private:
54 
55  void init();
56 
64  QString mLabel;
74  QString mCurrency;
82  QDate mInitialDate;
90  QDate mFinalDate;
98  QString mCorporation;
106  QString mLogo;
114  QString mAccountant;
115 
116  QFile* mFile;
117  QTabWidget* mTab;
127  FdModelCoa* mCoa;
130 
131 public:
132  explicit FdSubWindow(QString label,
133  QString currency,
134  QDate initialDate = QDate(),
135  QDate finalDate = QDate(),
136  QString corporation = "",
137  QString logo = "",
138  QString accountant = "");
139  FdSubWindow(QFile* file);
140  FdSubWindow(const FdSubWindow* previousYear);
141  FdModelCoa* coa() const;
142  FdModelJournal* journal() const;
143  FdModelResults* results() const;
144  void setLabel(QString label);
145  void setCurrency(QString currency);
146  void setInitialDate(QDate date);
147  void setFinalDate(QDate date);
148  void setCorporation(QString corporation);
149  void setLogo(QString logo);
150  void setAccountant(QString accountant);
151  QString label() const;
152  QString currency() const;
153  QDate initialDate() const;
154  QDate finalDate() const;
155  QString corporation() const;
156  QString logo() const;
157  QString accountant() const;
158  TabRole getCurrentTabRole() const;
159  void save();
160  void saveAs(QString file);
161  void print();
162  QRect static setPrintArea(QPrinter& printer);
163  void printHeaderFooter(QPrinter& printer, QPainter& painter, QString document, int page) const;
164  void static printTitle(QPainter& painter, QRect& area, QString title);
165  void static printSubtitle(QPainter& painter, QRect& area, QString subtitle);
166  void static printColumnsHeader(QPainter& painter, QRect& area, QList<tableElement*> elements);
167  void static printTableRow(QPainter& painter, QRect& area, QList<tableElement*> elements);
168  void addLine();
169  void removeSelected();
170  void copy();
171  void findNext();
172  void recomputeAll();
173  void journalOrderByDate();
175  void showAccount();
176  void showEntry();
177  void setDefaultDockText() const;
178 
179 protected:
180  void closeEvent(QCloseEvent* event);
181 
182 private slots:
183  void newActiveTab();
184  void closeTab(int index);
185  void cleanStateChanged(bool clean);
186 };
187 
188 struct tableElement {
189  int width;
190  QString text;
191  Qt::Alignment alignement;
192  Qt::GlobalColor color;
193 };
194 
195 #endif // FDSUBWINDOW_HPP