FreeDebks  1.0.3
 All Classes Files Functions Variables Friends Pages
FdViewAccountSummary.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 FDVIEWACCOUNTSUMMARY_HPP
21 #define FDVIEWACCOUNTSUMMARY_HPP
22 
23 #include <QTableView>
24 #include <QAbstractTableModel>
25 #include <QStyledItemDelegate>
26 #include <QHeaderView>
27 #include <QMouseEvent>
28 
29 #include "../guiDefinitions.hpp"
30 
32 
34 
39 class FdViewAccountSummary : public QTableView
40 {
41 Q_OBJECT
42 
43 private:
45  FdItemCoa_p mAccount;
52  QTimer* mSearchTimer;
56  QString mSearchText;
57  QModelIndexList mSearchResults;
58  int mCurrentResult;
59 
60 public:
61  explicit FdViewAccountSummary(FdSubWindow* parent, FdItemCoa_p account);
62  void mouseReleaseEvent(QMouseEvent *event);
63  void keyboardSearch(const QString &search);
64  int print(QPrinter& printer, QPainter& painter, QRect& area, QRect& remainingArea, FdSubWindow* subwindow, int pageNumber);
65  FdItemCoa_p currentCounterpart();
66  FdItemJournal_p currentEntry();
67  void setDockText();
68  void writeSettings();
69 public slots:
70  void currentChanged();
71  void refreshView();
72  void nextSearchResult();
73 protected slots:
74  void currentChanged(const QModelIndex &current, const QModelIndex &previous);
75  void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
76 private slots:
77  void contextMenu(const QPoint& position);
78  void searchTimeout();
79 signals:
80  void refresh();
81 
82 };
83 
84 class FdModelAccountSummary : public QAbstractTableModel
85 {
86 Q_OBJECT
87 
88 private:
90  FdItemCoa_p mAccount;
91  QList<FdItemJournal_p> mEntries;
92 public:
93  explicit FdModelAccountSummary(FdSubWindow* mSubwindow, FdItemCoa_p account);
94  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
95  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
96  int rowCount(const QModelIndex &parent = QModelIndex()) const;
97  int columnCount(const QModelIndex &parent = QModelIndex()) const;
98  QModelIndexList entryByPartialText(QString text) const;
99  FdItemCoa_p selectedCounterpart(const QModelIndex& index) const;
100  FdItemJournal_p selectedEntry(const QModelIndex &index) const;
101 public slots:
102  void refresh();
103 
104 };
105 
106 class FdDelegateAccountSummary : public QStyledItemDelegate
107 {
108 private:
111 public:
112  explicit FdDelegateAccountSummary(FdModelAccountSummary* model, FdSubWindow* subwindow);
113  QString displayText(const QVariant &value) const;
114  QString displayText(const QVariant& value, const QLocale& locale) const;
115  void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
116 };
117 
118 #endif // FDVIEWACCOUNTSUMMARY_HPP