Changeset 6182

Show
Ignore:
Timestamp:
2008-05-05 21:32:10 (3 months ago)
Author:
eugene
Message:

Made tab replacement avoid flickering by inserting a new tab after the replaced tab. This also fixes the glitch when focus is moved forward upon message type changing. Somewhat simplified tab label updating.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/qt4-gui/src/userevents/usereventtabdlg.cpp

    r6145 r6182  
    7373void UserEventTabDlg::addTab(UserEventCommon* tab, int index) 
    7474{ 
    75   QString label; 
    7675  ICQUser* u = gUserManager.FetchUser(tab->id().toLatin1(), tab->ppid(), LOCK_R); 
    7776  if (u == NULL) 
    7877    return; 
    7978 
    80   label = QString::fromUtf8(u->GetAlias()); 
    81   index = myTabs->insertTab(index, tab, label); 
    82   updateTabLabel(u); 
     79  index = myTabs->insertTab(index, tab, QString::fromUtf8(u->GetAlias())); 
     80  updateTabLabel(tab, u); 
    8381  gUserManager.DropUser(u); 
    8482} 
     
    9290void UserEventTabDlg::replaceTab(QWidget* oldTab, UserEventCommon* newTab) 
    9391{ 
    94   addTab(newTab, myTabs->indexOf(oldTab)); 
     92  addTab(newTab, myTabs->indexOf(oldTab) + 1); 
    9593  removeTab(oldTab); 
    9694} 
     
    134132void UserEventTabDlg::updateTabLabel(ICQUser* u) 
    135133{ 
    136   if (u == 0
     134  if (u == NULL
    137135    return; 
    138136 
     
    141139    UserEventCommon* tab = dynamic_cast<UserEventCommon*>(myTabs->widget(index)); 
    142140 
    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 
     147void 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()) 
    148168      { 
    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; 
    178187      } 
    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); 
    196212} 
    197213 
  • trunk/qt4-gui/src/userevents/usereventtabdlg.h

    r6108 r6182  
    4848  void updateConvoLabel(UserEventCommon* tab); 
    4949  void updateTabLabel(ICQUser* u); 
     50  void updateTabLabel(UserEventCommon* tab, ICQUser* u = NULL); 
    5051  void setTyping(ICQUser* u, int convoId); 
    5152 
  • trunk/qt4-gui/src/userevents/usersendcommon.cpp

    r6180 r6182  
    748748    } 
    749749    else 
    750       LicqGui::instance()->userEventTabDlg()->replaceTab(this, e); 
     750      tabDlg->replaceTab(this, e); 
    751751  } 
    752752}