1 // AircraftItemDelegate.hxx - part of GUI launcher using Qt5
3 // Written by James Turner, started March 2015.
5 // Copyright (C) 2014 James Turner <zakalawe@mac.com>
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.
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.
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.
21 #ifndef FG_GUI_AIRCRAFT_ITEM_DELEGATE
22 #define FG_GUI_AIRCRAFT_ITEM_DELEGATE
24 #include <QStyledItemDelegate>
28 class AircraftItemDelegate : public QStyledItemDelegate
32 static const int MARGIN = 4;
33 static const int ARROW_SIZE = 20;
34 static const int BUTTON_HEIGHT = 24;
36 AircraftItemDelegate(QListView* view);
38 virtual void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
40 virtual QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
42 virtual bool eventFilter( QObject*, QEvent* event );
45 void variantChanged(const QModelIndex& index);
48 QRect leftCycleArrowRect(const QRect& visualRect, const QModelIndex& index) const;
49 QRect rightCycleArrowRect(const QRect& visualRect, const QModelIndex& index) const;
51 QRect packageButtonRect(const QRect& visualRect, const QModelIndex& index) const;
53 void drawRating(QPainter* painter, QString label, const QRect& box, int value) const;
56 QPixmap m_leftArrowIcon,