]> git.mxchange.org Git - flightgear.git/blob - src/GUI/AircraftItemDelegate.hxx
VS2015 compatability fixes.
[flightgear.git] / src / GUI / AircraftItemDelegate.hxx
1 // AircraftItemDelegate.hxx - part of GUI launcher using Qt5
2 //
3 // Written by James Turner, started March 2015.
4 //
5 // Copyright (C) 2014 James Turner <zakalawe@mac.com>
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
21 #ifndef FG_GUI_AIRCRAFT_ITEM_DELEGATE
22 #define FG_GUI_AIRCRAFT_ITEM_DELEGATE
23
24 #include <QStyledItemDelegate>
25
26 class QListView;
27
28 class AircraftItemDelegate : public QStyledItemDelegate
29 {
30     Q_OBJECT
31 public:
32     static const int MARGIN = 4;
33     static const int ARROW_SIZE = 20;
34     static const int BUTTON_HEIGHT = 24;
35     static const int BUTTON_WIDTH = 80;
36     
37     AircraftItemDelegate(QListView* view);
38     
39     virtual void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
40
41     virtual QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
42
43     virtual bool eventFilter( QObject*, QEvent* event );
44
45 Q_SIGNALS:
46     void variantChanged(const QModelIndex& index);
47
48     void requestInstall(const QModelIndex& index);
49     
50     void cancelDownload(const QModelIndex& index);
51 private:
52     QRect leftCycleArrowRect(const QRect& visualRect, const QModelIndex& index) const;
53     QRect rightCycleArrowRect(const QRect& visualRect, const QModelIndex& index) const;
54
55     QRect packageButtonRect(const QRect& visualRect, const QModelIndex& index) const;
56
57     void drawRating(QPainter* painter, QString label, const QRect& box, int value) const;
58
59     QListView* m_view;
60     QPixmap m_leftArrowIcon,
61         m_rightArrowIcon;
62 };
63
64 #endif