Hi!

Fredrik Hultkrantz <[EMAIL PROTECTED]> wrote:
> When I have chatmode enabled and double click on a user to send
> him/her a message the top text box is empty. Same thing when I double
> click on a user to read an incoming message. The top text box only
> contains his/her answer(s). It is this that I would like to change so
> that that top box always contained the last 10 (or a number I specify)
> messages (the last part of the history really).

That sounds quite useful. I've hacked together a patch which I think
implements what you describe. Please give it a try.

Two things about it:
1. Somehow it must be shown which messages are from history and which
   have just arrived. My patch inserts a <hr>, but that doesn't really
   look good. How is this handled in ickle?
2. The code relies on the fact that each entry in the list uses exactly
   two paragraphs (although it can contain multiple lines).
Index: plugins/qt-gui/src/usereventdlg.cpp
===================================================================
RCS file: /cvsroot/licq/qt-gui/src/usereventdlg.cpp,v
retrieving revision 1.102
diff -u -3 -p -r1.102 usereventdlg.cpp
--- plugins/qt-gui/src/usereventdlg.cpp	15 Feb 2003 12:31:19 -0000	1.102
+++ plugins/qt-gui/src/usereventdlg.cpp	19 Feb 2003 17:23:48 -0000
@@ -1010,6 +1010,55 @@ UserSendCommon::UserSendCommon(CICQDaemo
 #if QT_VERSION >= 300
     mleHistory->setICQDaemon(server);
 #endif
+
+    // Fill history for ChatView, just a quick'n'dirty hack - jm
+#define HISTORY_COUNT 10
+
+    ICQUser *u = gUserManager.FetchUser(m_nUin, LOCK_R);
+    if (u != NULL) 
+    {
+      HistoryList lHistoryList;
+      if (u->GetHistory(lHistoryList) && (lHistoryList.size() > 0))
+      {
+	// Save new messages which are already in the list
+	// This relies on the fact that each message uses two paragraphs
+	int paras = mleHistory->paragraphs();
+	int entries = (paras <= 1 ? 0 : paras / 2);
+	QStringList str;
+	for (int i = 0; i < entries*2; i++)
+	  str.append(mleHistory->text(i));
+
+	mleHistory->clear();
+
+	// Add history
+	HistoryListIter tempIter = lHistoryList.end();
+	for (int i = 0; i < HISTORY_COUNT + entries; i++)
+	{
+	  if (tempIter == lHistoryList.begin()) break;
+	  tempIter--;  
+	}
+	for (int i = 0; i < HISTORY_COUNT; i++)
+	{
+	  if (tempIter == lHistoryList.end()) break;
+	  mleHistory->addMsg((*tempIter));
+	  tempIter++;
+	}
+
+	// Show where new messages start
+#if QT_VERSION >= 300
+	mleHistory->append("<hr>");
+#else
+	// what to do for qt2?
+#endif
+
+	// Re-add new messages
+	for (QStringList::Iterator it = str.begin(); it != str.end(); ++it)
+	  mleHistory->append(*it);
+	mleHistory->GotoEnd();
+      }
+      gUserManager.DropUser(u);
+    }
+
     connect (mainwin, SIGNAL(signal_sentevent(ICQEvent *)), mleHistory, SLOT(addMsg(ICQEvent *)));
     //splView->setResizeMode(mleHistory, QSplitter::FollowSizeHint);
   }
ciao
  J�rg

Reply via email to