PageRenderTime 35ms CodeModel.GetById 25ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/inc/grid_view/viewcolumnset.h

https://code.google.com/p/dwarftherapist/
C++ Header | 78 lines | 40 code | 10 blank | 28 comment | 0 complexity | b1bb10e0c07135a37429d6db5eec86d4 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_SET_H
24#define VIEW_COLUMN_SET_H
25
26#include <QtGui>
27
28class ViewManager;
29class ViewColumn;
30class ViewColumnSetDialog;
31class GridView;
32class Dwarf;
33
34/*!
35ViewColumnSet
36*/
37class ViewColumnSet : public QObject {
38	Q_OBJECT
39public:
40	ViewColumnSet(QString name, QObject *parent = 0);
41	ViewColumnSet(const ViewColumnSet &copy); //copy ctor
42
43    void re_parent(QObject *parent);
44
45	QString name() {return m_name;}
46	void add_column(ViewColumn *col);
47	void clear_columns();
48	void set_bg_color(const QColor &color) {m_bg_color = color;}
49	QColor bg_color() {return m_bg_color;}
50	QList<ViewColumn*> columns() {return m_columns;}
51	GridView *view() {return m_view;}
52	void remove_column(int offset) {m_columns.removeAt(offset);}
53	void remove_column(ViewColumn *vc) {m_columns.removeAll(vc);}
54	ViewColumn *column_at(int offset) {return m_columns.at(offset);}
55
56	//! order of columns was changed by a view, so reflect those changes internally
57	void reorder_columns(const QStandardItemModel &model);
58
59	//! persist this structure to disk
60	void write_to_ini(QSettings &s);
61	//! factory method for creating a set based on a QSettings that has been pointed at a set entry
62	static ViewColumnSet *read_from_ini(QSettings &s, QObject *parent = 0);
63
64	public slots:
65		void set_name(const QString &name);
66		void toggle_for_dwarf(Dwarf *d);
67		void toggle_for_dwarf(); // from context menu of single labor
68		void toggle_for_dwarf_group(); // from context menu of aggregate
69
70private:
71	QString m_name;
72	GridView *m_view;
73	QList<ViewColumn*> m_columns;
74	QBrush m_bg_brush; // possibly allow textured backgrounds in the long long ago, err future.
75	QColor m_bg_color;
76};
77
78#endif