>From: Jon Keating <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: [Licq-devel] [PATCH2] clearing events in chatmode messageview
>Date: Fri, 6 Sep 2002 19:49:50 -0500
>
>I see a few problems with this patch.
>
>       * The activated parameter in windowActivationChange() is it's previous 
>state.
>Therefore the function is checking to see if the window is being 
>deactivated.
>The icon should be reset when the window is activated and the message is
>seen.  Using isActiveWindow() is advised.
>
>       * You need to make a call to QWidget::windowActivationChange() at the end 
>of
>the UserSendCommon version of it, so Qt can handle the window updating.
>
>Please fix these and send it again.

Thanks for notifying these bugs!
I fixed the patch and it comes here as an attachment.
I hope it was ok this time.


_________________________________________________________________
Join the world�s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com
diff -ur licq.orig/plugins/qt-gui/src/ewidgets.cpp 
licq/plugins/qt-gui/src/ewidgets.cpp
--- licq.orig/plugins/qt-gui/src/ewidgets.cpp   2002-09-07 16:01:32.000000000 
+0300
+++ licq/plugins/qt-gui/src/ewidgets.cpp        2002-09-07 14:47:26.000000000 +0300
@@ -506,6 +506,7 @@
:CHistoryWidget(parent,name)
{
   m_nUin= _nUin;
+  parentWidget = parent;
   // add all unread messages.
//   ICQUser *u = gUserManager.FetchUser(_nUin, LOCK_W);
//   if (u != NULL && u->NewMessages() > 0)
@@ -608,7 +609,11 @@
#endif
   GotoEnd();

-  if (e->Direction() == D_RECEIVER && e->SubCommand() == ICQ_CMDxSUB_MSG) {
+  if (
+#if QT_VERSION >= 300
+      parentWidget && parentWidget->isActiveWindow() &&
+#endif
+      e->Direction() == D_RECEIVER && e->SubCommand() == ICQ_CMDxSUB_MSG) {
     ICQUser *u = gUserManager.FetchUser(m_nUin, LOCK_R );
     if (u != NULL) {
        u->EventClearId(e->Id());
diff -ur licq.orig/plugins/qt-gui/src/ewidgets.h 
licq/plugins/qt-gui/src/ewidgets.h
--- licq.orig/plugins/qt-gui/src/ewidgets.h     2002-09-07 16:01:32.000000000 
+0300
+++ licq/plugins/qt-gui/src/ewidgets.h  2002-09-07 14:24:26.000000000 +0300
@@ -129,6 +129,7 @@
   Q_OBJECT
private:
   unsigned long m_nUin;
+  QWidget *parentWidget;
public:
   CMessageViewWidget(unsigned long _nUin, QWidget* parent=0, const char * 
name =0);
   virtual ~CMessageViewWidget(){};
diff -ur licq.orig/plugins/qt-gui/src/usereventdlg.cpp 
licq/plugins/qt-gui/src/usereventdlg.cpp
--- licq.orig/plugins/qt-gui/src/usereventdlg.cpp       2002-09-07 
16:01:33.000000000 +0300
+++ licq/plugins/qt-gui/src/usereventdlg.cpp    2002-09-07 16:32:15.000000000 
+0300
@@ -1029,6 +1029,32 @@
{
}

+#if QT_VERSION >= 300
+//-----UserSendCommon::windowActivationChange--------------------------------
+void UserSendCommon::windowActivationChange(bool oldActive)
+{
+  if (isActiveWindow() && mainwin->m_bMsgChatView)
+  {
+    ICQUser *u = gUserManager.FetchUser(m_nUin, LOCK_R);
+    if (u != NULL && u->NewMessages() > 0)
+    {
+      vector<int> idList;
+      for (unsigned short i = 0; i < u->NewMessages(); i++)
+      {
+       CUserEvent *e = u->EventPeek(i);
+       if (e->Direction() == D_RECEIVER && e->SubCommand() == ICQ_CMDxSUB_MSG)
+         idList.push_back(e->Id());
+      }
+
+      for (unsigned short i = 0; i < idList.size(); i++)
+       u->EventClearId(idList[i]);
+    }
+    gUserManager.DropUser(u);
+  }
+  QWidget::windowActivationChange(oldActive);
+}
+#endif
+
//-----UserSendCommon::slot_SetForegroundColor-------------------------------
void UserSendCommon::slot_SetForegroundICQColor()
{
diff -ur licq.orig/plugins/qt-gui/src/usereventdlg.h 
licq/plugins/qt-gui/src/usereventdlg.h
--- licq.orig/plugins/qt-gui/src/usereventdlg.h 2002-09-07 
16:01:33.000000000 +0300
+++ licq/plugins/qt-gui/src/usereventdlg.h      2002-09-07 14:57:30.000000000 
+0300
@@ -160,6 +160,9 @@
   virtual ~UserSendCommon();

   void setText(const QString& txt);
+#if QT_VERSION >= 300
+  virtual void windowActivationChange(bool oldActive);
+#endif

signals:
   void autoCloseNotify();

Reply via email to