| 143 | | if (tab->ppid() == u->PPID() && tab->isUserInConvo(u->IdString())) |
| 144 | | { |
| 145 | | QIcon icon; |
| 146 | | |
| 147 | | if (u->NewMessages() > 0) // use an event icon |
| | 141 | if (tab->ppid() == u->PPID() && |
| | 142 | tab->isUserInConvo(u->IdString())) |
| | 143 | updateTabLabel(tab, u); |
| | 144 | } |
| | 145 | } |
| | 146 | |
| | 147 | void UserEventTabDlg::updateTabLabel(UserEventCommon* tab, ICQUser* u) |
| | 148 | { |
| | 149 | if (tab == NULL) |
| | 150 | return; |
| | 151 | |
| | 152 | bool fetched = false; |
| | 153 | if (u == NULL) |
| | 154 | { |
| | 155 | u = gUserManager.FetchUser(tab->id().toLatin1(), tab->ppid(), LOCK_R); |
| | 156 | if (u == NULL) |
| | 157 | return; |
| | 158 | fetched = true; |
| | 159 | } |
| | 160 | |
| | 161 | QIcon icon; |
| | 162 | |
| | 163 | if (u->NewMessages() > 0) // use an event icon |
| | 164 | { |
| | 165 | unsigned short SubCommand = ICQ_CMDxSUB_MSG; |
| | 166 | for (unsigned short i = 0; i < u->NewMessages(); i++) |
| | 167 | switch (u->EventPeek(i)->SubCommand()) |
| 149 | | unsigned short SubCommand = ICQ_CMDxSUB_MSG; |
| 150 | | for (unsigned short i = 0; i < u->NewMessages(); i++) |
| 151 | | switch (u->EventPeek(i)->SubCommand()) |
| 152 | | { |
| 153 | | case ICQ_CMDxSUB_FILE: |
| 154 | | SubCommand = ICQ_CMDxSUB_FILE; |
| 155 | | break; |
| 156 | | case ICQ_CMDxSUB_CHAT: |
| 157 | | if (SubCommand != ICQ_CMDxSUB_FILE) |
| 158 | | SubCommand = ICQ_CMDxSUB_CHAT; |
| 159 | | break; |
| 160 | | case ICQ_CMDxSUB_URL: |
| 161 | | if (SubCommand != ICQ_CMDxSUB_FILE && |
| 162 | | SubCommand != ICQ_CMDxSUB_CHAT) |
| 163 | | SubCommand = ICQ_CMDxSUB_URL; |
| 164 | | break; |
| 165 | | case ICQ_CMDxSUB_CONTACTxLIST: |
| 166 | | if (SubCommand != ICQ_CMDxSUB_FILE && |
| 167 | | SubCommand != ICQ_CMDxSUB_CHAT && |
| 168 | | SubCommand != ICQ_CMDxSUB_URL) |
| 169 | | SubCommand = ICQ_CMDxSUB_CONTACTxLIST; |
| 170 | | break; |
| 171 | | } |
| 172 | | |
| 173 | | icon = IconManager::instance()->iconForEvent(SubCommand); |
| 174 | | myTabs->setTabColor(tab, QColor("blue")); |
| 175 | | |
| 176 | | // to clear it.. |
| 177 | | tab->setTyping(u->GetTyping()); |
| | 169 | case ICQ_CMDxSUB_FILE: |
| | 170 | SubCommand = ICQ_CMDxSUB_FILE; |
| | 171 | break; |
| | 172 | case ICQ_CMDxSUB_CHAT: |
| | 173 | if (SubCommand != ICQ_CMDxSUB_FILE) |
| | 174 | SubCommand = ICQ_CMDxSUB_CHAT; |
| | 175 | break; |
| | 176 | case ICQ_CMDxSUB_URL: |
| | 177 | if (SubCommand != ICQ_CMDxSUB_FILE && |
| | 178 | SubCommand != ICQ_CMDxSUB_CHAT) |
| | 179 | SubCommand = ICQ_CMDxSUB_URL; |
| | 180 | break; |
| | 181 | case ICQ_CMDxSUB_CONTACTxLIST: |
| | 182 | if (SubCommand != ICQ_CMDxSUB_FILE && |
| | 183 | SubCommand != ICQ_CMDxSUB_CHAT && |
| | 184 | SubCommand != ICQ_CMDxSUB_URL) |
| | 185 | SubCommand = ICQ_CMDxSUB_CONTACTxLIST; |
| | 186 | break; |
| 179 | | else // use status icon |
| 180 | | { |
| 181 | | icon = IconManager::instance()->iconForStatus(u->StatusFull(), u->IdString(), u->PPID()); |
| 182 | | |
| 183 | | if (u->GetTyping() == ICQ_TYPING_ACTIVE) |
| 184 | | myTabs->setTabColor(tab, Config::Chat::instance()->tabTypingColor()); |
| 185 | | else |
| 186 | | myTabs->setTabColor(tab, QColor("black")); |
| 187 | | } |
| 188 | | |
| 189 | | myTabs->setTabIcon(index, icon); |
| 190 | | if (myTabs->currentIndex() == index) |
| 191 | | setWindowIcon(icon); |
| 192 | | |
| 193 | | break; |
| 194 | | } |
| 195 | | } |
| | 188 | |
| | 189 | icon = IconManager::instance()->iconForEvent(SubCommand); |
| | 190 | myTabs->setTabColor(tab, QColor("blue")); |
| | 191 | |
| | 192 | // to clear it.. |
| | 193 | tab->setTyping(u->GetTyping()); |
| | 194 | } |
| | 195 | else // use status icon |
| | 196 | { |
| | 197 | icon = IconManager::instance()->iconForStatus(u->StatusFull(), u->IdString(), u->PPID()); |
| | 198 | |
| | 199 | if (u->GetTyping() == ICQ_TYPING_ACTIVE) |
| | 200 | myTabs->setTabColor(tab, Config::Chat::instance()->tabTypingColor()); |
| | 201 | else |
| | 202 | myTabs->setTabColor(tab, QColor("black")); |
| | 203 | } |
| | 204 | |
| | 205 | if (fetched) |
| | 206 | gUserManager.DropUser(u); |
| | 207 | |
| | 208 | int index = myTabs->indexOf(tab); |
| | 209 | myTabs->setTabIcon(index, icon); |
| | 210 | if (myTabs->currentIndex() == index) |
| | 211 | setWindowIcon(icon); |