Changeset 4905

Show
Ignore:
Timestamp:
05/13/07 03:23:46 (19 months ago)
Author:
flynd
Message:

Implemented a qt4 model representing the contact list in the licq daemon.

The model is a tree structure with all groups (including system groups) as root elements and users sub elements.
Each group also contains the bars used to separate online and offline contacts.
The list is unsorted and no users or groups can be hidden. Proxy models are needed to present a sorted and filtered contact list to a view.

The file contactlist.h contains the public interface to access the model and contactlistdata.h contains the internal classes used by the model.
Everything in contactlistdata is internal to the model and is not meant to be included anywhere else as all access should be made through the CContactList interface.

The classes in contactlistdata represents the users, groups and bars that previously was handled by CUserViewItem.
The item types are now implemented as separate classes (CContactUser, CContactGroup, CContactBar) with the little they have in common inherited from the base class CContactItem.
As a user can be a member of multiple groups the CContactUser class does not contain any data. Instead there is a CContactUserData object for each actual contact that the CContactUser objects share.

Much of the code in CContactUserData is just copied from CUserViewItem.
Currently animations are triggered from the model, they should perhaps be handled entirly by the view and delegate. Since the delegate is stateless and the view doesn't really know what data it is presenting it was easier to implement this way.

Known problems:
- The model is not updated when contacts are added to or removed from groups. This is because the daemon does not notify plugins of contact group changes.

Location:
branches/qt-gui_qt4/src
Files:
4 added
4 modified

Legend:

Unmodified
Added
Removed
  • branches/qt-gui_qt4/src/CMakeLists.txt

    r4820 r4905  
    77  chatdlg.cpp 
    88  chatjoin.cpp 
     9  contactlist.cpp 
     10  contactlistdata.cpp 
    911  editfile.cpp 
    1012  editfilelistdlg.cpp 
  • branches/qt-gui_qt4/src/mainwin.cpp

    r4894 r4905  
    9797#include "emoticon.h" 
    9898#include "ownermanagerdlg.h" 
     99#include "contactlist.h" 
    99100 
    100101#ifdef USE_KDE 
     
    677678     colInfo.push_back(new CColumnInfo(QString::fromLocal8Bit(colTitle), colFormat, colWidth, colAlign)); 
    678679  } 
     680  contactList = new CContactList(theSigMan, this); 
    679681  CreateUserView(); 
    680682 
     
    11261128CMainWindow::~CMainWindow() 
    11271129{ 
     1130  delete contactList; 
    11281131  delete licqIcon; 
    11291132  if (skin) delete skin; 
     
    18631866void CMainWindow::updateUserWin() 
    18641867{ 
     1868  // Reload contact list from the daemon 
     1869  contactList->reloadAll(); 
    18651870  // set the pixmap and color for each user and add them to the view 
    18661871  userView->setUpdatesEnabled(false); 
     
    34703475    } 
    34713476  } 
     3477 
     3478  // The daemon does not send an update when group membership changes so tell the contactList it needs to update 
     3479  contactList->updateUser(m_szUserMenuId, m_nUserMenuPPID); 
    34723480} 
    34733481 
     
    34933501         gUserManager.RemoveUserFromGroup(szId, nPPID, group); 
    34943502         updateUserWin(); 
     3503 
     3504        // The daemon does not send an update when group membership changes so tell the contactList it needs to update 
     3505        contactList->updateUser(m_szUserMenuId, m_nUserMenuPPID); 
    34953506         return true; 
    34963507      } 
     
    35053516    gUserManager.DropUser(u); 
    35063517    updateUserWin(); 
     3518 
     3519    // The daemon does not send an update when group membership changes so tell the contactList it needs to update 
     3520    contactList->updateUser(m_szUserMenuId, m_nUserMenuPPID); 
    35073521    return true; 
    35083522  } 
     
    35103524  return false; 
    35113525} 
    3512  
    35133526 
    35143527bool CMainWindow::RemoveUserFromGroup(GroupType gtype, unsigned long group, unsigned long nUin, QWidget *p) 
     
    35333546         gUserManager.RemoveUserFromGroup(nUin, group); 
    35343547         updateUserWin(); 
     3548 
     3549        // The daemon does not send an update when group membership changes so tell the contactList it needs to update 
     3550        contactList->updateUser(m_szUserMenuId, m_nUserMenuPPID); 
    35353551         return true; 
    35363552      } 
     
    35453561    gUserManager.DropUser(u); 
    35463562    updateUserWin(); 
     3563 
     3564    // The daemon does not send an update when group membership changes so tell the contactList it needs to update 
     3565    contactList->updateUser(m_szUserMenuId, m_nUserMenuPPID); 
    35473566    return true; 
    35483567  } 
     
    35923611 
    35933612  gUserManager.AddUserToGroup(m_szUserMenuId, m_nUserMenuPPID, a->data().toInt()); 
     3613 
     3614  // The daemon does not send an update when group membership changes so tell the contactList it needs to update 
     3615  contactList->updateUser(m_szUserMenuId, m_nUserMenuPPID); 
    35943616  updateUserWin(); 
    35953617} 
     
    42734295     // TODO Qt4 mnuUser->changeItem(QIcon(pmCustomAR), tr("Custom Auto Response..."), mnuUserCustomAutoResponse); 
    42744296     updateUserWin(); 
     4297    contactList->configUpdated(); 
    42754298   } 
    42764299} 
     
    44914514     CUserView::UpdateFloaties(); 
    44924515     updateUserWin(); 
     4516    contactList->configUpdated(); 
    44934517     updateEvents(); 
    44944518     updateStatus(0); //This shows ICQ status for the status label and dock icon 
  • branches/qt-gui_qt4/src/mainwin.h

    r4894 r4905  
    7575class UserSendCommon; 
    7676class IconManager; 
     77class CContactList; 
    7778class CUserView; 
    7879 
     
    215216  FlashType m_nFlash; 
    216217  CSkin *skin; 
     218  CContactList* contactList; 
    217219 
    218220  unsigned long m_nCurrentGroup, m_nGroupStates; 
  • branches/qt-gui_qt4/src/optionsdlg.cpp

    r4845 r4905  
    4848#endif 
    4949 
     50#include "contactlist.h" 
    5051#include "ewidgets.h" 
    5152#include "optionsdlg.h" 
     
    678679  mainwin->CreateUserView(); 
    679680  mainwin->updateUserWin(); 
     681  mainwin->contactList->configUpdated(); 
    680682  mainwin->resizeEvent(NULL); 
    681683  mainwin->userView->show();