FreeDebks  1.0.3
 All Classes Files Functions Variables Friends Pages
FdViewJournal.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 FDVIEWJOURNAL_HPP
21 #define FDVIEWJOURNAL_HPP
22 
23 #include <QTableView>
24 #include <QItemEditorFactory>
25 #include <QStyledItemDelegate>
26 #include <QHeaderView>
27 #include <QCompleter>
28 #include <QLineEdit>
29 #include <QCompleter>
30 #include <QMouseEvent>
31 #include <QPrinter>
32 #include <QPainter>
33 #include <QImage>
34 
35 #include "../guiDefinitions.hpp"
36 
37 class FdDelegateJournal;
38 
40 
45 class FdViewJournal : public QTableView
46 {
47 Q_OBJECT
48 
49 private:
57  QTimer* mSearchTimer;
61  QString mSearchText;
62  QModelIndexList mSearchResults;
63  int mCurrentResult;
64  bool openEditor;
65 
66 public:
67  explicit FdViewJournal(FdSubWindow* parent);
68  void mouseReleaseEvent(QMouseEvent *event);
69  QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
70  void keyboardSearch(const QString &search);
71  void editCurrentItem();
72  void print(QPrinter& printer, QPainter& painter, const QRect& area);
73  QList<int> selectedRows() const;
74  void setDockText() const;
75  void writeSettings();
76 public slots:
77  void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
78  void setCurrentIndex(const QModelIndex& index);
79  void currentChanged(const QModelIndex &current, const QModelIndex &previous);
80  void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
81  void lineEditDestroyed();
82  void nextSearchResult();
83 private slots:
84  void contextMenu(const QPoint& position);
85  void searchTimeout();
86 };
87 
88 class FdDelegateJournal : public QStyledItemDelegate
89 {
90 private:
93  const FdModelJournal* mModel;
94 public:
95  explicit FdDelegateJournal(FdModelJournal* model, FdSubWindow* subwindow, FdViewJournal* view);
96  QString displayText(const QVariant &value) const;
97  QString displayText(const QVariant &value, const QLocale &locale) const;
98  void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
99  QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
100 };
101 
102 #endif // FDVIEWJOURNAL_HPP