FreeDebks  1.0.3
 All Classes Files Functions Variables Friends Pages
FdViewCoa.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 FDVIEWCOA_HPP
21 #define FDVIEWCOA_HPP
22 
23 #include <QTreeView>
24 #include <QStyledItemDelegate>
25 #include <QMouseEvent>
26 #include <QComboBox>
27 #include <QMenu>
28 
29 #include "../guiDefinitions.hpp"
30 
31 class FdDelegateCoa;
32 
34 
39 class FdViewCoa : public QTreeView
40 {
41 Q_OBJECT
42 
43 private:
51  QTimer* mSearchTimer;
55  QString mSearchText;
56  QModelIndexList mSearchResults;
57  int mCurrentResult;
58 
59 public:
60  explicit FdViewCoa(FdSubWindow* parent);
61  void mouseReleaseEvent(QMouseEvent *event);
62  QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
63  void keyboardSearch(const QString &search);
64  int print(QPrinter& printer, QPainter& painter, const QRect &area, QRect& remainingArea);
65  int print(QPrinter &printer,
66  QPainter &painter,
67  const QRect &area,
68  QRect& remainingArea,
69  QFont font,
70  int rowHeight,
71  int tabulation,
72  int widthLabel,
73  int widthAmount,
74  FdItemCoa_p parent,
75  int pageNumber = 0,
76  int level = 0);
77  QModelIndexList selectedItems() const;
78  void writeSettings();
79 public slots:
80  void edit(const QModelIndex &index);
81  void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
82  void setCurrentIndex(const QModelIndex& index);
83  void currentChanged(const QModelIndex &current, const QModelIndex &previous);
84  void nextSearchResult();
85 private slots:
86  void contextMenu(const QPoint& position);
87  void searchTimeout();
88 
89 };
90 
91 class FdDelegateCoa : public QStyledItemDelegate
92 {
93 Q_OBJECT
94 private:
96 public:
97  explicit FdDelegateCoa(FdModelCoa* model);
98  QString displayText(const QVariant &value) const;
99  QString displayText(const QVariant &value, const QLocale &locale) const;
100  void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
101  QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
102  void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
103 };
104 
105 
106 #endif // FDVIEWCOA_HPP