Changeset 6186

Show
Ignore:
Timestamp:
05/06/08 04:56:15 (7 months ago)
Author:
flynd
Message:

Add sent and recieved messages to history dialog. Currently the message view is not updated automatically, only the calendar view.

Location:
trunk/qt4-gui/src/dialogs
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt4-gui/src/dialogs/historydlg.cpp

    r6178 r6186  
    3535#include <QVBoxLayout> 
    3636 
     37#include <licq_events.h> 
     38#include <licq_message.h> 
    3739#include <licq_user.h> 
    3840 
    3941#include "config/chat.h" 
    4042#include "core/licqgui.h" 
     43#include "core/signalmanager.h" 
    4144#include "core/usermenu.h" 
    4245#include "helpers/eventdesc.h" 
     
    252255  myCalendar->setSelectedDate(lastDate); 
    253256  calenderClicked(); 
     257 
     258  // Catch sent messages and add them to history 
     259  connect(LicqGui::instance(), SIGNAL(eventSent(const ICQEvent*)), 
     260      SLOT(eventSent(const ICQEvent*))); 
     261 
     262  // Catch received messages so we can add them to history 
     263  connect(LicqGui::instance()->signalManager(), SIGNAL(updatedUser(CICQSignal*)), SLOT(updatedUser(CICQSignal*))); 
    254264} 
    255265 
     
    257267{ 
    258268  ICQUser::ClearHistory(myHistoryList); 
     269} 
     270 
     271void HistoryDlg::updatedUser(CICQSignal* signal) 
     272{ 
     273  if (signal->Id() != myId || signal->PPID() != myPpid) 
     274    return; 
     275 
     276  if (signal->SubSignal() == USER_EVENTS) 
     277  { 
     278    ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
     279    if (u == NULL) 
     280      return; 
     281 
     282    const CUserEvent* event = u->EventPeekId(signal->Argument()); 
     283    gUserManager.DropUser(u); 
     284 
     285    if (event != NULL && signal->Argument() > 0 && signal->Argument() > (*(--myHistoryList.end()))->Id()) 
     286      addMsg(event); 
     287  } 
     288} 
     289 
     290void HistoryDlg::eventSent(const ICQEvent* event) 
     291{ 
     292  if (event->Id() == myId && event->PPID() == myPpid && event->UserEvent() != NULL) 
     293    addMsg(event->UserEvent()); 
     294} 
     295 
     296void HistoryDlg::addMsg(const CUserEvent* event) 
     297{ 
     298  CUserEvent* eventCopy = event->Copy(); 
     299  myHistoryList.push_back(eventCopy); 
     300  QDate date = QDateTime::fromTime_t(event->Time()).date(); 
     301  myCalendar->markDate(date); 
     302  myCalendar->setMaximumDate(date); 
    259303} 
    260304 
  • trunk/qt4-gui/src/dialogs/historydlg.h

    r5999 r6186  
    3535class QRegExp; 
    3636class QTextCodec; 
     37 
     38class CICQSignal; 
     39class ICQEvent; 
    3740 
    3841namespace LicqQtGui 
     
    108111  void previousDate(); 
    109112 
     113private slots: 
     114  /** 
     115   * A user was updated. Add to history if it was a message recieved for this user 
     116   * 
     117   * @param signal Signal from daemon 
     118   */ 
     119  void updatedUser(CICQSignal* signal); 
     120 
     121  /** 
     122   * A message was sent. Add to history if it was for the current user 
     123   * 
     124   * @param event Event object for message 
     125   */ 
     126  void eventSent(const ICQEvent* event); 
     127 
    110128private: 
     129  /** 
     130   * Add an event to the current history 
     131   * 
     132   * @param event Event to add 
     133   */ 
     134  void addMsg(const CUserEvent* event); 
     135 
    111136  /** 
    112137   * Build a regular expression from the input fields