Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-qt/plrdlg.h Source File

Freeciv-3.2

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***************************************************************************/
52 class plr_item_delegate:public QItemDelegate {
53 Q_OBJECT
54
55public:
56 plr_item_delegate(QObject *parent) : QItemDelegate(parent) {}
57 ~plr_item_delegate() {}
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***************************************************************************/
67 class plr_item: public QObject {
68 Q_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:
76 struct player *ipplayer;
77};
78
79/***************************************************************************
80 Nation/Player model
81***************************************************************************/
82 class 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);
94 return num_player_dlg_columns;
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***************************************************************************/
112 class 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***************************************************************************/
128 class plr_widget: public QTreeView
129{
130 Q_OBJECT
131
132 plr_model *list_model;
133 plr_sorter *filter_model;
134 plr_item_delegate *pid;
135 plr_report *plr;
136 QString techs_known;
137 QString techs_unknown;
138 struct player *selected_player;
139public:
140 plr_widget(plr_report *pr);
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;
148 struct player *other_player;
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***************************************************************************/
160 class plr_report: public QWidget
161{
162 Q_OBJECT
163
164 plr_widget *plr_wdg;
165 QLabel *plr_label;
166 QLabel *ally_label;
167 QLabel *tech_label;
168 QLabel *wonder_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:
187 struct player *other_player;
188 int index;
189private slots:
190 void req_meeeting();
191 void req_caancel_threaty();
194 void req_wiithdrw_vision();
195 void toggle_ai_mode();
196 void show_relations_toggle();
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#endif // FC__PLRDLG_H
plr_item_delegate
Definition plrdlg.h:52
plr_item_delegate::plr_item_delegate
plr_item_delegate(QObject *parent)
Definition plrdlg.h:56
plr_item_delegate::sizeHint
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition plrdlg.cpp:55
plr_item_delegate::~plr_item_delegate
~plr_item_delegate()
Definition plrdlg.h:57
plr_item_delegate::paint
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition plrdlg.cpp:69
plr_item
Definition plrdlg.h:67
plr_item::setData
bool setData(int column, const QVariant &value, int role=Qt::DisplayRole)
Definition plrdlg.cpp:151
plr_item::data
QVariant data(int column, int role=Qt::DisplayRole) const
Definition plrdlg.cpp:159
plr_item::columnCount
int columnCount() const
Definition plrdlg.h:72
plr_item::ipplayer
struct player * ipplayer
Definition plrdlg.h:76
plr_model
Definition plrdlg.h:83
plr_model::rowCount
int rowCount(const QModelIndex &index=QModelIndex()) const
Definition plrdlg.h:88
plr_model::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Definition plrdlg.cpp:235
plr_model::setData
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::DisplayRole)
Definition plrdlg.cpp:254
plr_model::populate
void populate()
Definition plrdlg.cpp:286
plr_model::hide_data
QVariant hide_data(int section) const
Definition plrdlg.cpp:466
plr_model::~plr_model
~plr_model()
Definition plrdlg.cpp:209
plr_model::plr_list
QList< plr_item * > plr_list
Definition plrdlg.h:106
plr_model::notify_plr_changed
void notify_plr_changed(int row)
Definition plrdlg.cpp:278
plr_model::data
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Definition plrdlg.cpp:218
plr_model::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition plrdlg.h:92
plr_report
Definition plrdlg.h:161
plr_report::req_caancel_threaty
void req_caancel_threaty()
Definition plrdlg.cpp:924
plr_report::wonder_label
QLabel * wonder_label
Definition plrdlg.h:168
plr_report::call_meeting
void call_meeting()
Definition plrdlg.cpp:913
plr_report::update_report
void update_report(bool update_selection=true)
Definition plrdlg.cpp:1071
plr_report::layout
QVBoxLayout * layout
Definition plrdlg.h:178
plr_report::index
int index
Definition plrdlg.h:188
plr_report::other_player
struct player * other_player
Definition plrdlg.h:187
plr_report::toggle_ai_mode
void toggle_ai_mode()
Definition plrdlg.cpp:953
plr_report::toggle_ai_but
QPushButton * toggle_ai_but
Definition plrdlg.h:174
plr_report::cancel_but
QPushButton * cancel_but
Definition plrdlg.h:172
plr_report::show_wonders_toggle
void show_wonders_toggle()
Definition plrdlg.cpp:1040
plr_report::v_splitter
QSplitter * v_splitter
Definition plrdlg.h:169
plr_report::plr_wdg
plr_widget * plr_wdg
Definition plrdlg.h:164
plr_report::tech_label
QLabel * tech_label
Definition plrdlg.h:167
plr_report::req_meeeting
void req_meeeting()
Definition plrdlg.cpp:934
plr_report::plr_label
QLabel * plr_label
Definition plrdlg.h:165
plr_report::show_relations_toggle
void show_relations_toggle()
Definition plrdlg.cpp:1008
plr_report::withdraw_but
QPushButton * withdraw_but
Definition plrdlg.h:173
plr_report::plr_report
plr_report()
Definition plrdlg.cpp:793
plr_report::init
void init()
Definition plrdlg.cpp:903
plr_report::show_techs
QPushButton * show_techs
Definition plrdlg.h:176
plr_report::ally_label
QLabel * ally_label
Definition plrdlg.h:166
plr_report::show_relations
QPushButton * show_relations
Definition plrdlg.h:175
plr_report::h_splitter
QSplitter * h_splitter
Definition plrdlg.h:170
plr_report::req_wiithdrw_vision
void req_wiithdrw_vision()
Definition plrdlg.cpp:943
plr_report::~plr_report
~plr_report()
Definition plrdlg.cpp:895
plr_report::show_wonders
QPushButton * show_wonders
Definition plrdlg.h:177
plr_report::show_techs_toggle
void show_techs_toggle()
Definition plrdlg.cpp:1024
plr_report::hlayout
QHBoxLayout * hlayout
Definition plrdlg.h:179
plr_report::meet_but
QPushButton * meet_but
Definition plrdlg.h:171
plr_sorter
Definition plrdlg.h:113
plr_sorter::~plr_sorter
~plr_sorter()
Definition plrdlg.cpp:317
plr_sorter::lessThan
bool lessThan(const QModelIndex &left, const QModelIndex &right) const
Definition plrdlg.cpp:324
plr_widget
Definition plrdlg.h:129
plr_widget::nation_selected
void nation_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition plrdlg.cpp:492
plr_widget::techs_known
QString techs_known
Definition plrdlg.h:136
plr_widget::selected_player
struct player * selected_player
Definition plrdlg.h:138
plr_widget::~plr_widget
~plr_widget()
Definition plrdlg.cpp:781
plr_widget::plr
plr_report * plr
Definition plrdlg.h:135
plr_widget::list_model
plr_model * list_model
Definition plrdlg.h:132
plr_widget::pid
plr_item_delegate * pid
Definition plrdlg.h:134
plr_widget::tech_str
QString tech_str
Definition plrdlg.h:146
plr_widget::get_model
plr_model * get_model() const
Definition plrdlg.cpp:773
plr_widget::intel_str
QString intel_str
Definition plrdlg.h:144
plr_widget::wonder_str
QString wonder_str
Definition plrdlg.h:147
plr_widget::other_player
struct player * other_player
Definition plrdlg.h:148
plr_widget::display_header_menu
void display_header_menu(const QPoint &)
Definition plrdlg.cpp:425
plr_widget::filter_model
plr_sorter * filter_model
Definition plrdlg.h:133
plr_widget::ally_str
QString ally_str
Definition plrdlg.h:145
plr_widget::techs_unknown
QString techs_unknown
Definition plrdlg.h:137
plr_widget::hide_columns
void hide_columns()
Definition plrdlg.cpp:478
plr_widget::restore_selection
void restore_selection()
Definition plrdlg.cpp:396
plr_widget::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition plrdlg.cpp:1056
incite_cost
char * incite_cost
Definition comments.c:74
event
enum event_type event
Definition events.c:81
popup_players_dialog
void popup_players_dialog(bool raise)
Definition plrdlg.c:91
popdown_players_report
void popdown_players_report(void)
Definition plrdlg.cpp:1187
colors.h
sprite.h
slots
struct player_slot * slots
Definition player.c:51
player.h
num_player_dlg_columns
const int num_player_dlg_columns
Definition plrdlg_common.c:601
plrdlg_g.h
research.h
option
Definition options.c:478
player
Definition player.h:247
section
Definition section_file.h:28