1 /*
2 * OpenClonk, http://www.openclonk.org
3 *
4 * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5 * Copyright (c) 2013, The OpenClonk Team and contributors
6 *
7 * Distributed under the terms of the ISC license; see accompanying file
8 * "COPYING" for details.
9 *
10 * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11 * See accompanying file "TRADEMARK" for details.
12 *
13 * To redistribute this file separately, substitute the full license texts
14 * for the above references.
15 */
16 
17 /* Proplist table view */
18 
19 #ifndef INC_C4ConsoleQtObjectListViewer
20 #define INC_C4ConsoleQtObjectListViewer
21 #ifdef WITH_QT_EDITOR
22 
23 #include "C4Include.h" // needed for automoc
24 #include "editor/C4ConsoleGUI.h" // for glew.h
25 #include "script/C4Value.h"
26 #include "editor/C4ConsoleQt.h"
27 
28 // Prop list view implemented as a model view
29 class C4ConsoleQtObjectListModel : public QAbstractItemModel
30 {
31 	Q_OBJECT
32 
33 	mutable int32_t last_row_count{0};
34 	QBrush clr_deleted, clr_effect;
35 
36 	// model indices for static proplists
37 	enum
38 	{
39 		IDX_Global = 0,
40 		IDX_Scenario = 1,
41 		IDX_Objects = 2
42 	};
43 
44 public:
45 	C4ConsoleQtObjectListModel();
46 	~C4ConsoleQtObjectListModel() override;
47 
48 	// Refresh object list on next redraw
49 	void Invalidate();
50 
51 	QModelIndex GetModelIndexByItem(class C4PropList *item) const;
52 	C4PropList *GetItemByModelIndex(const QModelIndex &index) const;
53 
54 protected:
55 	int rowCount(const QModelIndex & parent = QModelIndex()) const override;
56 	int columnCount(const QModelIndex & parent = QModelIndex()) const override;
57 	QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
58 	QModelIndex index(int row, int column, const QModelIndex &parent) const override;
59 	QModelIndex parent(const QModelIndex &index) const override;
60 };
61 
62 #endif // WITH_QT_EDITOR
63 #endif // INC_C4ConsoleQtObjectListViewer
64