Freeciv-3.1
Loading...
Searching...
No Matches
plrdlg.h
Go to the documentation of this file.
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.
7
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***********************************************************************/
13
14#ifndef FC__PLRDLG_H
15#define FC__PLRDLG_H
16
17#ifdef HAVE_CONFIG_H
18#include <fc_config.h>
19#endif
20
21extern "C" {
22#include "plrdlg_g.h"
23}
24
25// Qt
26#include <QAbstractListModel>
27#include <QItemDelegate>
28#include <QSortFilterProxyModel>
29#include <QTreeView>
30#include <QWidget>
31
32// common
33#include "colors.h"
34#include "player.h"
35#include "research.h"
36
37// gui-qt
38#include "sprite.h"
39
40
41class QHBoxLayout;
42class QLabel;
43class QPushButton;
44class QSplitter;
45class QTableWidget;
46class QVBoxLayout;
47class plr_report;
48
49/***************************************************************************
50 Item delegate for painting in model of nations view table
51***************************************************************************/
52class plr_item_delegate:public QItemDelegate {
53 Q_OBJECT
54
55public:
56 plr_item_delegate(QObject *parent) : QItemDelegate(parent) {}
58 void paint(QPainter *painter, const QStyleOptionViewItem &option,
59 const QModelIndex &index) const;
60 virtual QSize sizeHint (const QStyleOptionViewItem & option,
61 const QModelIndex & index ) const;
62};
63
64/***************************************************************************
65 Single item in model of nations view table
66***************************************************************************/
67class plr_item: public QObject {
68Q_OBJECT
69
70public:
71 plr_item(struct player *pplayer);
72 inline int columnCount() const { return num_player_dlg_columns; }
73 QVariant data(int column, int role = Qt::DisplayRole) const;
74 bool setData(int column, const QVariant &value, int role = Qt::DisplayRole);
75private:
77};
78
79/***************************************************************************
80 Nation/Player model
81***************************************************************************/
82class plr_model : public QAbstractListModel
83{
84 Q_OBJECT
85public:
86 plr_model(QObject *parent = 0);
87 ~plr_model();
88 inline int rowCount(const QModelIndex &index = QModelIndex()) const {
89 Q_UNUSED(index);
90 return plr_list.size();
91 }
92 int columnCount(const QModelIndex &parent = QModelIndex()) const {
93 Q_UNUSED(parent);
95 }
96 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
97 bool setData(const QModelIndex &index, const QVariant &value,
98 int role = Qt::DisplayRole);
99 QVariant headerData(int section, Qt::Orientation orientation,
100 int role) const;
101 QVariant hide_data(int section) const;
102 void populate();
103private slots:
104 void notify_plr_changed(int row);
105private:
106 QList<plr_item *> plr_list;
107};
108
109/***************************************************************************
110 Sorter for player/nation dialog
111***************************************************************************/
112class plr_sorter: public QSortFilterProxyModel
113{
114 Q_OBJECT
115
116public:
117 plr_sorter(QObject *parent);
118 ~plr_sorter();
119
120private:
121 bool lessThan(const QModelIndex &left,
122 const QModelIndex &right) const;
123};
124
125/***************************************************************************
126 Player widget to show player/nation model
127***************************************************************************/
128class plr_widget: public QTreeView
129{
130 Q_OBJECT
131
136 QString techs_known;
139public:
141 ~plr_widget();
142 void restore_selection();
143 plr_model *get_model() const;
144 QString intel_str;
145 QString ally_str;
146 QString tech_str;
147 QString wonder_str;
149public slots:
150 void display_header_menu(const QPoint &);
151 void nation_selected(const QItemSelection &sl, const QItemSelection &ds);
152private:
153 void mousePressEvent(QMouseEvent *event);
154 void hide_columns();
155};
156
157/***************************************************************************
158 Widget to show as tab widget in players view.
159***************************************************************************/
160class plr_report: public QWidget
161{
162 Q_OBJECT
163
165 QLabel *plr_label;
166 QLabel *ally_label;
167 QLabel *tech_label;
169 QSplitter *v_splitter;
170 QSplitter *h_splitter;
171 QPushButton *meet_but;
172 QPushButton *cancel_but;
173 QPushButton *withdraw_but;
174 QPushButton *toggle_ai_but;
175 QPushButton *show_relations;
176 QPushButton *show_techs;
177 QPushButton *show_wonders;
178 QVBoxLayout *layout;
179 QHBoxLayout *hlayout;
180public:
181 plr_report();
182 ~plr_report();
183 void update_report(bool update_selection = true);
184 void init();
185 void call_meeting();
186private:
188 int index;
189private slots:
190 void req_meeeting();
191 void req_caancel_threaty();
194 void req_wiithdrw_vision();
195 void toggle_ai_mode();
197 void show_techs_toggle();
198 void show_wonders_toggle();
199};
200
201void popup_players_dialog(bool raise);
202void popdown_players_report(void);
203
204
205#endif /* FC__PLRDLG_H */
plr_item_delegate(QObject *parent)
Definition plrdlg.h:56
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition plrdlg.cpp:55
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition plrdlg.cpp:69
bool setData(int column, const QVariant &value, int role=Qt::DisplayRole)
Definition plrdlg.cpp:151
QVariant data(int column, int role=Qt::DisplayRole) const
Definition plrdlg.cpp:159
int columnCount() const
Definition plrdlg.h:72
struct player * ipplayer
Definition plrdlg.h:76
int rowCount(const QModelIndex &index=QModelIndex()) const
Definition plrdlg.h:88
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Definition plrdlg.cpp:235
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::DisplayRole)
Definition plrdlg.cpp:254
void populate()
Definition plrdlg.cpp:286
QVariant hide_data(int section) const
Definition plrdlg.cpp:466
QList< plr_item * > plr_list
Definition plrdlg.h:106
void notify_plr_changed(int row)
Definition plrdlg.cpp:278
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Definition plrdlg.cpp:218
int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition plrdlg.h:92
void req_caancel_threaty()
Definition plrdlg.cpp:902
QLabel * wonder_label
Definition plrdlg.h:168
void call_meeting()
Definition plrdlg.cpp:891
void update_report(bool update_selection=true)
Definition plrdlg.cpp:1043
QVBoxLayout * layout
Definition plrdlg.h:178
int index
Definition plrdlg.h:188
struct player * other_player
Definition plrdlg.h:187
void toggle_ai_mode()
Definition plrdlg.cpp:931
QPushButton * toggle_ai_but
Definition plrdlg.h:174
QPushButton * cancel_but
Definition plrdlg.h:172
void show_wonders_toggle()
Definition plrdlg.cpp:1014
QSplitter * v_splitter
Definition plrdlg.h:169
plr_widget * plr_wdg
Definition plrdlg.h:164
QLabel * tech_label
Definition plrdlg.h:167
void req_meeeting()
Definition plrdlg.cpp:912
QLabel * plr_label
Definition plrdlg.h:165
void show_relations_toggle()
Definition plrdlg.cpp:986
QPushButton * withdraw_but
Definition plrdlg.h:173
void init()
Definition plrdlg.cpp:881
QPushButton * show_techs
Definition plrdlg.h:176
QLabel * ally_label
Definition plrdlg.h:166
QPushButton * show_relations
Definition plrdlg.h:175
QSplitter * h_splitter
Definition plrdlg.h:170
void req_wiithdrw_vision()
Definition plrdlg.cpp:921
QPushButton * show_wonders
Definition plrdlg.h:177
void show_techs_toggle()
Definition plrdlg.cpp:1000
QHBoxLayout * hlayout
Definition plrdlg.h:179
QPushButton * meet_but
Definition plrdlg.h:171
bool lessThan(const QModelIndex &left, const QModelIndex &right) const
Definition plrdlg.cpp:324
void nation_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition plrdlg.cpp:492
QString techs_known
Definition plrdlg.h:136
struct player * selected_player
Definition plrdlg.h:138
plr_report * plr
Definition plrdlg.h:135
plr_model * list_model
Definition plrdlg.h:132
plr_item_delegate * pid
Definition plrdlg.h:134
QString tech_str
Definition plrdlg.h:146
plr_model * get_model() const
Definition plrdlg.cpp:770
QString intel_str
Definition plrdlg.h:144
QString wonder_str
Definition plrdlg.h:147
struct player * other_player
Definition plrdlg.h:148
void display_header_menu(const QPoint &)
Definition plrdlg.cpp:425
plr_sorter * filter_model
Definition plrdlg.h:133
QString ally_str
Definition plrdlg.h:145
QString techs_unknown
Definition plrdlg.h:137
void hide_columns()
Definition plrdlg.cpp:478
void restore_selection()
Definition plrdlg.cpp:396
void mousePressEvent(QMouseEvent *event)
Definition plrdlg.cpp:1028
enum event_type event
Definition events.c:81
void popup_players_dialog(bool raise)
Definition plrdlg.c:91
void popdown_players_report(void)
Definition plrdlg.cpp:1159
struct player_slot * slots
Definition player.c:50
const int num_player_dlg_columns