95 } |
95 } |
96 |
96 |
97 |
97 |
98 void PlayersListModel::removePlayer(const QString & nickname) |
98 void PlayersListModel::removePlayer(const QString & nickname) |
99 { |
99 { |
100 QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname); |
100 QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly); |
101 |
101 |
102 if(mil.size()) |
102 if(mil.size()) |
103 removeRow(mil[0].row()); |
103 removeRow(mil[0].row()); |
104 } |
104 } |
105 |
105 |
106 |
106 |
107 void PlayersListModel::playerJoinedRoom(const QString & nickname) |
107 void PlayersListModel::playerJoinedRoom(const QString & nickname) |
108 { |
108 { |
109 QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname); |
109 QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly); |
110 |
110 |
111 if(mil.size()) |
111 if(mil.size()) |
|
112 { |
112 setData(mil[0], "1", RoomFilterRole); |
113 setData(mil[0], "1", RoomFilterRole); |
|
114 updateIcon(mil[0]); |
|
115 } |
113 } |
116 } |
114 |
117 |
115 |
118 |
116 void PlayersListModel::playerLeftRoom(const QString & nickname) |
119 void PlayersListModel::playerLeftRoom(const QString & nickname) |
117 { |
120 { |
118 QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname); |
121 QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly); |
119 |
122 |
120 if(mil.size()) |
123 if(mil.size()) |
|
124 { |
121 setData(mil[0], "0", RoomFilterRole); |
125 setData(mil[0], "0", RoomFilterRole); |
|
126 updateIcon(mil[0]); |
|
127 } |
122 } |
128 } |
123 |
129 |
124 |
130 |
125 void PlayersListModel::setFlag(const QString &nickname, StateFlag flagType, bool isSet) |
131 void PlayersListModel::setFlag(const QString &nickname, StateFlag flagType, bool isSet) |
126 { |
132 { |
127 QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname); |
133 QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly); |
128 |
134 |
129 if(mil.size()) |
135 if(mil.size()) |
130 { |
136 { |
131 setData(mil[0], isSet, flagType); |
137 setData(mil[0], isSet, flagType); |
132 |
138 |
159 } |
165 } |
160 |
166 |
161 |
167 |
162 bool PlayersListModel::isFlagSet(const QString & nickname, StateFlag flagType) |
168 bool PlayersListModel::isFlagSet(const QString & nickname, StateFlag flagType) |
163 { |
169 { |
164 QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname); |
170 QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly); |
165 |
171 |
166 if(mil.size()) |
172 if(mil.size()) |
167 return mil[0].data(flagType).toBool(); |
173 return mil[0].data(flagType).toBool(); |
168 else |
174 else |
169 return false; |
175 return false; |
197 << index.data(ServerAdmin).toBool() |
203 << index.data(ServerAdmin).toBool() |
198 << index.data(RoomAdmin).toBool() |
204 << index.data(RoomAdmin).toBool() |
199 << index.data(Registered).toBool() |
205 << index.data(Registered).toBool() |
200 << index.data(Friend).toBool() |
206 << index.data(Friend).toBool() |
201 << index.data(Ignore).toBool() |
207 << index.data(Ignore).toBool() |
|
208 << (index.data(RoomFilterRole).toString() == "1") |
202 ; |
209 ; |
203 |
210 |
204 for(int i = flags.size() - 1; i >= 0; --i) |
211 for(int i = flags.size() - 1; i >= 0; --i) |
205 if(flags[i]) |
212 if(flags[i]) |
206 iconNum |= 1 << i; |
213 iconNum |= 1 << i; |
214 QPixmap result(24, 16); |
221 QPixmap result(24, 16); |
215 result.fill(Qt::transparent); |
222 result.fill(Qt::transparent); |
216 |
223 |
217 QPainter painter(&result); |
224 QPainter painter(&result); |
218 |
225 |
219 if(index.data(Ready).toBool()) |
226 if(index.data(RoomFilterRole).toString() == "1") |
220 painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp.png")); |
227 if(index.data(Ready).toBool()) |
|
228 painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp.png")); |
|
229 else |
|
230 painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp_off.png")); |
221 |
231 |
222 QString mainIconName(":/res/chat/"); |
232 QString mainIconName(":/res/chat/"); |
223 |
233 |
224 if(index.data(RoomAdmin).toBool()) |
234 if(index.data(RoomAdmin).toBool()) |
225 mainIconName += "roomadmin"; |
235 mainIconName += "roomadmin"; |