108 { |
108 { |
109 QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly); |
109 QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly); |
110 |
110 |
111 if(mil.size()) |
111 if(mil.size()) |
112 { |
112 { |
113 setData(mil[0], "1", RoomFilterRole); |
113 setData(mil[0], true, RoomFilterRole); |
114 updateIcon(mil[0]); |
114 updateIcon(mil[0]); |
|
115 updateSortData(mil[0]); |
115 } |
116 } |
116 } |
117 } |
117 |
118 |
118 |
119 |
119 void PlayersListModel::playerLeftRoom(const QString & nickname) |
120 void PlayersListModel::playerLeftRoom(const QString & nickname) |
120 { |
121 { |
121 QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly); |
122 QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly); |
122 |
123 |
123 if(mil.size()) |
124 if(mil.size()) |
124 { |
125 { |
125 setData(mil[0], "0", RoomFilterRole); |
126 setData(mil[0], false, RoomFilterRole); |
|
127 setData(mil[0], false, RoomAdmin); |
|
128 setData(mil[0], false, Ready); |
|
129 setData(mil[0], false, InGame); |
126 updateIcon(mil[0]); |
130 updateIcon(mil[0]); |
127 } |
131 } |
128 } |
132 } |
129 |
133 |
130 |
134 |
179 { |
183 { |
180 for(int i = rowCount() - 1; i >= 0; --i) |
184 for(int i = rowCount() - 1; i >= 0; --i) |
181 { |
185 { |
182 QModelIndex mi = index(i); |
186 QModelIndex mi = index(i); |
183 |
187 |
184 if(mi.data(RoomFilterRole).toString() == "1") |
188 if(mi.data(RoomFilterRole).toBool()) |
185 { |
189 { |
186 setData(mi, "0", RoomFilterRole); |
190 setData(mi, false, RoomFilterRole); |
187 setData(mi, false, RoomAdmin); |
191 setData(mi, false, RoomAdmin); |
188 setData(mi, false, Ready); |
192 setData(mi, false, Ready); |
189 setData(mi, false, InGame); |
193 setData(mi, false, InGame); |
190 |
194 |
191 updateSortData(mi); |
195 updateSortData(mi); |
205 << index.data(RoomAdmin).toBool() |
209 << index.data(RoomAdmin).toBool() |
206 << index.data(Registered).toBool() |
210 << index.data(Registered).toBool() |
207 << index.data(Friend).toBool() |
211 << index.data(Friend).toBool() |
208 << index.data(Ignore).toBool() |
212 << index.data(Ignore).toBool() |
209 << index.data(InGame).toBool() |
213 << index.data(InGame).toBool() |
210 << (index.data(RoomFilterRole).toString() == "1") |
214 << index.data(RoomFilterRole).toBool() |
211 ; |
215 ; |
212 |
216 |
213 for(int i = flags.size() - 1; i >= 0; --i) |
217 for(int i = flags.size() - 1; i >= 0; --i) |
214 if(flags[i]) |
218 if(flags[i]) |
215 iconNum |= 1 << i; |
219 iconNum |= 1 << i; |
223 QPixmap result(24, 16); |
227 QPixmap result(24, 16); |
224 result.fill(Qt::transparent); |
228 result.fill(Qt::transparent); |
225 |
229 |
226 QPainter painter(&result); |
230 QPainter painter(&result); |
227 |
231 |
228 if(index.data(RoomFilterRole).toString() == "1") |
232 if(index.data(RoomFilterRole).toBool()) |
|
233 { |
229 if(index.data(InGame).toBool()) |
234 if(index.data(InGame).toBool()) |
|
235 { |
230 painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/ingame.png")); |
236 painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/ingame.png")); |
|
237 } |
231 else |
238 else |
|
239 { |
232 if(index.data(Ready).toBool()) |
240 if(index.data(Ready).toBool()) |
233 painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp.png")); |
241 painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp.png")); |
234 else |
242 else |
235 painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp_off.png")); |
243 painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp_off.png")); |
|
244 } |
|
245 } |
236 |
246 |
237 QString mainIconName(":/res/chat/"); |
247 QString mainIconName(":/res/chat/"); |
238 |
248 |
239 if(index.data(RoomAdmin).toBool()) |
249 if(index.data(RoomAdmin).toBool()) |
240 mainIconName += "roomadmin"; |
250 mainIconName += "roomadmin"; |