1 /**********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
18 #include <fc_config.h>
33 #include <QAbstractListModel>
34 #include <QItemDelegate>
41 class QSortFilterProxyModel
;
47 /***************************************************************************
48 Item delegate for painting in model of nations view table
49 ***************************************************************************/
50 class plr_item_delegate
:public QItemDelegate
{
54 plr_item_delegate(QObject
*parent
) : QItemDelegate(parent
) {}
55 ~plr_item_delegate() {}
56 void paint(QPainter
*painter
, const QStyleOptionViewItem
&option
,
57 const QModelIndex
&index
) const;
58 virtual QSize
sizeHint (const QStyleOptionViewItem
& option
,
59 const QModelIndex
& index
) const;
62 /***************************************************************************
63 Single item in model of nations view table
64 ***************************************************************************/
65 class plr_item
: public QObject
{
69 plr_item(struct player
*pplayer
);
70 inline int columnCount() const { return num_player_dlg_columns
; }
71 QVariant
data(int column
, int role
= Qt::DisplayRole
) const;
72 bool setData(int column
, const QVariant
&value
, int role
= Qt::DisplayRole
);
74 struct player
*ipplayer
;
77 /***************************************************************************
79 ***************************************************************************/
80 class plr_model
: public QAbstractListModel
84 plr_model(QObject
*parent
= 0);
86 inline int rowCount(const QModelIndex
&index
= QModelIndex()) const {
88 return plr_list
.size();
90 int columnCount(const QModelIndex
&parent
= QModelIndex()) const {
92 return num_player_dlg_columns
;
94 QVariant
data(const QModelIndex
&index
, int role
= Qt::DisplayRole
) const;
95 bool setData(const QModelIndex
&index
, const QVariant
&value
,
96 int role
= Qt::DisplayRole
);
97 QVariant
headerData(int section
, Qt::Orientation orientation
,
99 QVariant
hide_data(int section
) const;
102 void notify_plr_changed(int row
);
104 QList
<plr_item
*> plr_list
;
107 /***************************************************************************
108 Player widget to show player/nation model
109 ***************************************************************************/
110 class plr_widget
: public QTreeView
113 plr_model
*list_model
;
114 QSortFilterProxyModel
*filter_model
;
115 plr_item_delegate
*pid
;
118 QString techs_unknown
;
119 struct player
*selected_player
;
121 plr_widget(plr_report
*pr
);
123 void restore_selection();
124 plr_model
*get_model() const;
128 struct player
*other_player
;
130 void display_header_menu(const QPoint
&);
131 void nation_selected(const QItemSelection
&sl
, const QItemSelection
&ds
);
133 void mousePressEvent(QMouseEvent
*event
);
137 /***************************************************************************
138 Widget to show as tab widget in players view.
139 ***************************************************************************/
140 class plr_report
: public QWidget
147 QSplitter
*v_splitter
;
148 QSplitter
*h_splitter
;
149 QPushButton
*meet_but
;
150 QPushButton
*cancel_but
;
151 QPushButton
*withdraw_but
;
153 QHBoxLayout
*hlayout
;
157 void update_report(bool update_selection
= true);
161 struct player
*other_player
;
165 void req_caancel_threaty(); /** somehow autoconnect feature messes
166 * here and names are bit odd to cheat
168 void req_wiithdrw_vision();
171 void popup_players_dialog(bool raise
);
172 void popdown_players_report(void);
175 #endif /* FC__PLRDLG_H */