Mercurial > hg > easaier-soundaccess
comparison widgets/ItemContainer.cpp @ 79:afcf540ae3a2
add the real time filter stack to manage real time filters and their attributes
author | lbajardsilogic |
---|---|
date | Tue, 19 Jun 2007 15:15:12 +0000 |
parents | 57c85a9d9b4a |
children | 5060939ca69d |
comparison
equal
deleted
inserted
replaced
78:d99441818cd9 | 79:afcf540ae3a2 |
---|---|
31 mainlayout->addLayout(m_itemLayout); | 31 mainlayout->addLayout(m_itemLayout); |
32 mainlayout->addStretch(); | 32 mainlayout->addStretch(); |
33 | 33 |
34 this->setLayout(mainlayout); | 34 this->setLayout(mainlayout); |
35 | 35 |
36 m_currentItem = -1; | |
37 | |
36 } | 38 } |
37 | 39 |
38 void ItemContainer::addItem(GenericItemList *item){ | 40 void ItemContainer::addItem(GenericItemList *item){ |
39 m_map->insert(m_cpt,item); | 41 m_map->insert(m_cpt,item); |
40 m_linkedList->prepend(m_cpt); | 42 m_linkedList->prepend(m_cpt); |
56 void ItemContainer::setSelectedItem(QVariant &data){ | 58 void ItemContainer::setSelectedItem(QVariant &data){ |
57 | 59 |
58 } | 60 } |
59 | 61 |
60 void ItemContainer::removeSelectedItem(){ | 62 void ItemContainer::removeSelectedItem(){ |
61 //QLindList<int>::iterator iter = m_linkedList->find(x); | 63 if (m_currentItem < 0) |
62 | 64 return; |
63 } | 65 |
64 | 66 QLinkedList<int>::iterator iter = find(m_currentItem); |
67 QMap<int,GenericItemList*>::iterator iterItem = m_map->find(*iter); | |
68 | |
69 QLinkedList<int>::iterator newCurItem = iter + 1; | |
70 | |
71 if (iter != m_linkedList->end()) | |
72 { | |
73 m_linkedList->erase(iter); | |
74 } | |
75 if (iterItem != m_map->end()) | |
76 { | |
77 delete iterItem.value(); | |
78 m_map->erase(iterItem); | |
79 } | |
80 | |
81 reorganize(); | |
82 | |
83 | |
84 if (newCurItem != m_linkedList->end()) | |
85 { | |
86 m_currentItem = *newCurItem; | |
87 newItemSelected(m_currentItem); | |
88 return; | |
89 } else if (!m_linkedList->isEmpty()) { | |
90 m_currentItem = *(m_linkedList->end() - 1); | |
91 newItemSelected(m_currentItem); | |
92 return; | |
93 } | |
94 } | |
95 | |
96 void ItemContainer::removeItem(QString &name){ | |
97 | |
98 QMap<int,GenericItemList*>::iterator iterItem; | |
99 | |
100 int index = -1; | |
101 | |
102 //erase the element from the widget map | |
103 for (iterItem = m_map->begin(); iterItem != m_map->end(); iterItem++) | |
104 { | |
105 QString iterName = iterItem.value()->getName(); | |
106 if (iterName == name) | |
107 { | |
108 index = iterItem.key(); | |
109 delete iterItem.value(); | |
110 m_map->erase(iterItem); | |
111 break; | |
112 } | |
113 } | |
114 | |
115 if (index != -1) | |
116 { | |
117 QLinkedList<int>::iterator iter = find(index); | |
118 | |
119 QLinkedList<int>::iterator newCurItem = iter + 1; | |
120 | |
121 //erase the element from the linked list | |
122 if (iter != m_linkedList->end()) | |
123 { | |
124 m_linkedList->erase(iter); | |
125 } | |
126 | |
127 //if it was the current item, select the following item if it exists | |
128 if (index == m_currentItem) | |
129 { | |
130 if (newCurItem != m_linkedList->end()) | |
131 { | |
132 m_currentItem = *newCurItem; | |
133 newItemSelected(m_currentItem); | |
134 return; | |
135 } else if (!m_linkedList->isEmpty()) { | |
136 m_currentItem = *(m_linkedList->end() - 1); | |
137 newItemSelected(m_currentItem); | |
138 return; | |
139 } | |
140 } | |
141 } | |
142 | |
143 reorganize(); | |
144 } | |
65 void ItemContainer::reset() | 145 void ItemContainer::reset() |
66 { | 146 { |
67 QLayoutItem *child; | 147 QLayoutItem *child; |
68 while ((child = m_itemLayout->takeAt(0)) != 0) { | 148 while ((child = m_itemLayout->takeAt(0)) != 0) { |
69 delete child->widget(); | 149 delete child->widget(); |
71 } | 151 } |
72 | 152 |
73 void ItemContainer::removeAllItems(){ | 153 void ItemContainer::removeAllItems(){ |
74 m_linkedList->clear(); | 154 m_linkedList->clear(); |
75 reset(); | 155 reset(); |
156 m_cpt=0; | |
76 m_map->clear(); | 157 m_map->clear(); |
77 m_cpt=0; | |
78 | |
79 } | 158 } |
80 | 159 |
81 void ItemContainer::setCurrentIndex(int i){ | 160 void ItemContainer::setCurrentIndex(int i){ |
82 | 161 |
83 | 162 |
91 } | 170 } |
92 return i; | 171 return i; |
93 } | 172 } |
94 | 173 |
95 void ItemContainer::reorganize(){ | 174 void ItemContainer::reorganize(){ |
96 for (int i = 0; i < m_itemLayout->count(); i++){ | 175 int count = m_itemLayout->count(); |
176 for (int i = count-1; i >= 0; i--){ | |
97 m_itemLayout->removeItem(m_itemLayout->itemAt(i)); | 177 m_itemLayout->removeItem(m_itemLayout->itemAt(i)); |
98 } | 178 } |
99 QLinkedList<int>::iterator iter; | 179 QLinkedList<int>::iterator iter; |
100 for(iter = m_linkedList->begin(); iter != m_linkedList->end(); iter++){ | 180 for(iter = m_linkedList->begin(); iter != m_linkedList->end(); iter++){ |
101 m_itemLayout->addWidget(m_map->value(*iter)); | 181 int j = *iter; |
102 } | 182 QMap<int,GenericItemList*>::iterator iterItem = m_map->find(j); |
183 if (iterItem != m_map->end()) | |
184 { | |
185 int toto = iterItem.key(); | |
186 m_itemLayout->addWidget(iterItem.value()); | |
187 } | |
188 | |
189 | |
190 //m_itemLayout->addWidget(m_map->value(*iter)); | |
191 } | |
192 m_itemLayout->update(); | |
103 } | 193 } |
104 | 194 |
105 /********* SLOTS **************/ | 195 /********* SLOTS **************/ |
106 void ItemContainer::moveItem(int idItem1, int idItem2){ | 196 void ItemContainer::moveItem(int idItem1, int idItem2){ |
107 m_linkedList->removeAll(idItem1); | 197 m_linkedList->removeAll(idItem1); |
190 GenericItemList* item = m_map->value(m_currentItem); | 280 GenericItemList* item = m_map->value(m_currentItem); |
191 if(item!=0){ | 281 if(item!=0){ |
192 item->configAction(); | 282 item->configAction(); |
193 } | 283 } |
194 } | 284 } |
285 | |
286 QString ItemContainer::getCurrentFilterName() | |
287 { | |
288 QString name = ""; | |
289 | |
290 if (m_currentItem < 0) | |
291 return name; | |
292 | |
293 QLinkedList<int>::iterator iter = find(m_currentItem); | |
294 | |
295 if (iter != m_linkedList->end()) | |
296 { | |
297 QMap<int,GenericItemList*>::iterator iterItem = m_map->find(*iter); | |
298 if (iterItem != m_map->end()) | |
299 { | |
300 GenericItemList* item = iterItem.value(); | |
301 name = item->getName(); | |
302 } | |
303 } | |
304 return name; | |
305 } |