PageRenderTime 26ms CodeModel.GetById 10ms app.highlight 11ms RepoModel.GetById 2ms app.codeStats 0ms

/inc/grid_view/viewcolumn.h

https://code.google.com/p/dwarftherapist/
C++ Header | 79 lines | 40 code | 9 blank | 30 comment | 0 complexity | 4baf832060f9e99228cfa0773e683bc7 MD5 | raw file
 1/*
 2Dwarf Therapist
 3Copyright (c) 2009 Trey Stout (chmod)
 4
 5Permission is hereby granted, free of charge, to any person obtaining a copy
 6of this software and associated documentation files (the "Software"), to deal
 7in the Software without restriction, including without limitation the rights
 8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21THE SOFTWARE.
22*/
23#ifndef VIEW_COLUMN_H
24#define VIEW_COLUMN_H
25
26#include <QtGui>
27#include "columntypes.h"
28
29class ViewColumnSet;
30class Dwarf;
31
32/*!
33ViewColumn
34I can think of a need for:
35* Labor cols
36* status cols (happiness, wounds, etc...)
37* radio cols (choose which weapon skill, or armor type)
38* simple counters (num kills, num kids, total gold, total items)
39*/
40class ViewColumn : public QObject {
41	Q_OBJECT
42public:
43	ViewColumn(QString title, COLUMN_TYPE type, ViewColumnSet *set = 0, QObject *parent = 0);
44	ViewColumn(QSettings &s, ViewColumnSet *set = 0, QObject *parent = 0);
45    ViewColumn(const ViewColumn &to_copy); // copy ctor
46    virtual ViewColumn* clone() = 0;
47
48	QString title() {return m_title;}
49	void set_title(QString title) {m_title = title;}
50	bool override_color() {return m_override_set_colors;}
51	void set_override_color(bool yesno) {m_override_set_colors = yesno;}
52	QColor bg_color() {return m_bg_color;}
53	void set_bg_color(QColor c) {m_bg_color = c;}
54	ViewColumnSet *set() {return m_set;}
55    void set_viewcolumnset(ViewColumnSet *set) {m_set = set;}
56	virtual COLUMN_TYPE type() {return m_type;}
57
58	QStandardItem *init_cell(Dwarf *d);
59	virtual QStandardItem *build_cell(Dwarf *d) = 0; // create a suitable item based on a dwarf
60	virtual QStandardItem *build_aggregate(const QString &group_name, 
61										   const QVector<Dwarf*> &dwarves) = 0; // create an aggregate cell based on several dwarves
62
63	virtual void write_to_ini(QSettings &s);
64
65	public slots:
66		virtual void read_settings() {}
67		void clear_cells() {m_cells.clear();}
68		virtual void redraw_cells() {}
69
70protected:
71	QString m_title;
72	QColor m_bg_color;
73	bool m_override_set_colors;
74	ViewColumnSet *m_set;
75	COLUMN_TYPE m_type;
76	QHash<Dwarf*, QStandardItem*> m_cells;
77};
78
79#endif