Multiply AI want for Great Wonders by 1.5
[freeciv.git] / client / gui-qt / plrdlg.h
blob4870625caa294adb09afa28976075188726c38a8
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)
6 any later version.
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 ***********************************************************************/
14 #ifndef FC__PLRDLG_H
15 #define FC__PLRDLG_H
17 #ifdef HAVE_CONFIG_H
18 #include <fc_config.h>
19 #endif
21 extern "C" {
22 #include "plrdlg_g.h"
25 //common
26 #include "colors.h"
27 #include "research.h"
29 // gui-qt
30 #include "sprite.h"
32 // Qt
33 #include <QAbstractListModel>
34 #include <QItemDelegate>
35 #include <QTreeView>
36 #include <QWidget>
38 class QHBoxLayout;
39 class QLabel;
40 class QPushButton;
41 class QSortFilterProxyModel;
42 class QSplitter;
43 class QTableWidget;
44 class QVBoxLayout;
45 class plr_report;
47 /***************************************************************************
48 Item delegate for painting in model of nations view table
49 ***************************************************************************/
50 class plr_item_delegate:public QItemDelegate {
51 Q_OBJECT
53 public:
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 {
66 Q_OBJECT
68 public:
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);
73 private:
74 struct player *ipplayer;
77 /***************************************************************************
78 Nation/Player model
79 ***************************************************************************/
80 class plr_model : public QAbstractListModel
82 Q_OBJECT
83 public:
84 plr_model(QObject *parent = 0);
85 ~plr_model();
86 inline int rowCount(const QModelIndex &index = QModelIndex()) const {
87 Q_UNUSED(index);
88 return plr_list.size();
90 int columnCount(const QModelIndex &parent = QModelIndex()) const {
91 Q_UNUSED(parent);
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,
98 int role) const;
99 QVariant hide_data(int section) const;
100 void populate();
101 private slots:
102 void notify_plr_changed(int row);
103 private:
104 QList<plr_item *> plr_list;
107 /***************************************************************************
108 Player widget to show player/nation model
109 ***************************************************************************/
110 class plr_widget: public QTreeView
112 Q_OBJECT
113 plr_model *list_model;
114 QSortFilterProxyModel *filter_model;
115 plr_item_delegate *pid;
116 plr_report *plr;
117 QString techs_known;
118 QString techs_unknown;
119 struct player *selected_player;
120 public:
121 plr_widget(plr_report *pr);
122 ~plr_widget();
123 void restore_selection();
124 plr_model *get_model() const;
125 QString intel_str;
126 QString ally_str;
127 QString tech_str;
128 struct player *other_player;
129 public slots:
130 void display_header_menu(const QPoint &);
131 void nation_selected(const QItemSelection &sl, const QItemSelection &ds);
132 private:
133 void mousePressEvent(QMouseEvent *event);
134 void hide_columns();
137 /***************************************************************************
138 Widget to show as tab widget in players view.
139 ***************************************************************************/
140 class plr_report: public QWidget
142 Q_OBJECT
143 plr_widget *plr_wdg;
144 QLabel *plr_label;
145 QLabel *ally_label;
146 QLabel *tech_label;
147 QSplitter *v_splitter;
148 QSplitter *h_splitter;
149 QPushButton *meet_but;
150 QPushButton *cancel_but;
151 QPushButton *withdraw_but;
152 QVBoxLayout *layout;
153 QHBoxLayout *hlayout;
154 public:
155 plr_report();
156 ~plr_report();
157 void update_report(bool update_selection = true);
158 void init();
159 void call_meeting();
160 private:
161 struct player *other_player;
162 int index;
163 private slots:
164 void req_meeeting();
165 void req_caancel_threaty(); /** somehow autoconnect feature messes
166 * here and names are bit odd to cheat
167 * autoconnect */
168 void req_wiithdrw_vision();
171 void popup_players_dialog(bool raise);
172 void popdown_players_report(void);
175 #endif /* FC__PLRDLG_H */