1 | // |
2 | // KBlackBox |
3 | // |
4 | // A simple game inspired by an emacs module |
5 | // |
6 | /*************************************************************************** |
7 | * Copyright (c) 1999-2000, Robert Cimrman * |
8 | * cimrman3@students.zcu.cz * |
9 | * * |
10 | * Copyright (c) 2007, Nicolas Roffet * |
11 | * nicolas-kde@roffet.com * |
12 | * * |
13 | * * |
14 | * This program is free software; you can redistribute it and/or modify * |
15 | * it under the terms of the GNU General Public License as published by * |
16 | * the Free Software Foundation; either version 2 of the License, or * |
17 | * (at your option) any later version. * |
18 | * * |
19 | * This program is distributed in the hope that it will be useful, * |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
22 | * GNU General Public License for more details. * |
23 | * * |
24 | * You should have received a copy of the GNU General Public License * |
25 | * along with this program; if not, write to the * |
26 | * Free Software Foundation, Inc., * |
27 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * |
28 | ***************************************************************************/ |
29 | |
30 | #ifndef KBBGRAPHICSITEMSET_H |
31 | #define KBBGRAPHICSITEMSET_H |
32 | |
33 | |
34 | |
35 | class QGraphicsScene; |
36 | #include <QList> |
37 | |
38 | |
39 | class KBBItemWithPosition; |
40 | |
41 | |
42 | |
43 | /** |
44 | * @brief Set of graphic items with positions |
45 | */ |
46 | class KBBGraphicsItemSet |
47 | { |
48 | public: |
49 | KBBGraphicsItemSet(QGraphicsScene* scene); |
50 | ~KBBGraphicsItemSet(); |
51 | |
52 | |
53 | static const int NO_INDEX = -1; |
54 | |
55 | /** |
56 | * @brief A position of an item (anyone of them) |
57 | */ |
58 | int anyItemPosition(); |
59 | |
60 | /** |
61 | * @brief Number of items |
62 | */ |
63 | int count() const; |
64 | |
65 | /** |
66 | * @brief Remove all items |
67 | */ |
68 | void clear(); |
69 | |
70 | /** |
71 | * If an element is not visible, it is not contained. |
72 | * @return false if the element is not contained or contained but not visible. |
73 | */ |
74 | bool containsVisible(int position); |
75 | |
76 | /** |
77 | * @brief Insert an item in the list |
78 | * |
79 | * @param item Item to insert. It must have a position: a box position or a border position. |
80 | */ |
81 | void insert(KBBItemWithPosition* item); |
82 | |
83 | /** |
84 | * @brief Return the item at the given position |
85 | * |
86 | * @param position Position of the item. |
87 | */ |
88 | KBBItemWithPosition* item(int position); |
89 | |
90 | /** |
91 | * @brief Remove item at given position |
92 | * |
93 | * @param position Position of the item to be removed. |
94 | */ |
95 | void remove(int position); |
96 | |
97 | /** |
98 | * @brief Change the visibility of an element |
99 | */ |
100 | void setVisible(const int position, const bool visible); |
101 | |
102 | |
103 | private: |
104 | bool contains(int position); |
105 | int indexOf(int position); |
106 | |
107 | QGraphicsScene* m_scene; |
108 | QList<KBBItemWithPosition*> m_items; |
109 | }; |
110 | |
111 | #endif // KBBGRAPHICSITEMSET_H |
112 | |