FreeDebks  1.0.3
 All Classes Files Functions Variables Friends Pages
FdViewResults.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 FDVIEWRESULTS_HPP
21 #define FDVIEWRESULTS_HPP
22 
23 #include <QTableView>
24 #include <QHeaderView>
25 #include <QMouseEvent>
26 #include <QStyledItemDelegate>
27 
28 #include "../guiDefinitions.hpp"
29 
30 class FdDelegateResults;
31 
32 class FdViewResults : public QTableView
33 {
34 Q_OBJECT
35 
36 private:
44  QTimer* mSearchTimer;
48  QString mSearchText;
49  QModelIndexList mSearchResults;
50  int mCurrentResult;
51 
52 public:
53  explicit FdViewResults(FdSubWindow* parent);
54  void mouseReleaseEvent(QMouseEvent *event);
55  QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
56  void keyboardSearch(const QString &search);
57  void print(QPrinter& printer, QPainter& painter, const QRect& area, QRect& remainingArea, FdSubWindow* subwindow, int startPage);
58  QList<int> selectedRows() const;
59  void writeSettings();
60 public slots:
61  void edit(const QModelIndex &index);
62  void setCurrentIndex(const QModelIndex& index);
63  void currentChanged(const QModelIndex &current, const QModelIndex &previous);
64  void nextSearchResult();
65 private slots:
66  void contextMenu(const QPoint& position);
67  void searchTimeout();
68 };
69 
70 class FdDelegateResults : public QStyledItemDelegate
71 {
72 private:
73  const FdModelResults* mModel;
74 public:
75  explicit FdDelegateResults(FdModelResults* model);
76  QString displayText(const QVariant &value) const;
77  QString displayText(const QVariant &value, const QLocale &locale) const;
78  void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
79 };
80 
81 #endif // FDVIEWRESULTS_HPP