Index: licq/plugins/qt-gui/src/mainwin.h
===================================================================
--- licq/plugins/qt-gui/src/mainwin.h	(revision 4786)
+++ licq/plugins/qt-gui/src/mainwin.h	(working copy)
@@ -161,7 +161,9 @@
        m_bShowHistory,
        m_bDisableDockIcon,
        m_bSortColumnAscending,
-       m_bAppendLineBreak,
+       m_chatVertSpacing,
+       m_chatAppendLineBreak,
+       m_histVertSpacing,
        m_bFlashTaskbar,
        m_bMainWinSticky,
        m_bMsgWinSticky,
@@ -179,9 +181,12 @@
   unsigned long m_nCurrentGroup, m_nGroupStates;
   unsigned short m_nSortByStatus,
                  m_nSortColumn,
-                 m_nMsgStyle;
-  QString m_nDateFormat;
-                 
+                 m_chatMsgStyle,
+                 m_histMsgStyle;
+
+  QString m_chatDateFormat,
+          m_histDateFormat;
+
   QColor m_colorRcvHistory,
          m_colorSntHistory,
          m_colorRcv,
Index: licq/plugins/qt-gui/src/userinfodlg.cpp
===================================================================
--- licq/plugins/qt-gui/src/userinfodlg.cpp	(revision 4786)
+++ licq/plugins/qt-gui/src/userinfodlg.cpp	(working copy)
@@ -1725,8 +1725,7 @@
   chkHistoryReverse->setFixedSize(chkHistoryReverse->sizeHint());
   l->addWidget(chkHistoryReverse);
 
-  mlvHistory = new CMessageViewWidget(m_szId, m_nPPID, mainwin, p, "history");
-  mlvHistory->m_nMsgStyle = 4; /* STYLE_HISTORY */
+  mlvHistory = new CMessageViewWidget(m_szId, m_nPPID, mainwin, p, "history", true);
 
   connect(mlvHistory, SIGNAL(viewurl(QWidget*, QString)), mainwin, SLOT(slot_viewurl(QWidget *, QString)));
 
@@ -2027,7 +2026,18 @@
   barFiltering->setTotalSteps(NUM_MSG_PER_HISTORY);
   char* ftxt = qstrdup(codec->fromUnicode(lneFilter->text()));
   int flen = strlen(ftxt);
-  
+
+  QString ownerName;
+  ICQOwner *o = gUserManager.FetchOwner(m_nPPID, LOCK_R);
+  if (o != NULL)
+  {
+    // Don't use this codec to decode our conversation with the contact
+    // since we're using the contact's encoding, not ours.
+    QTextCodec *ownerCodec = UserCodec::codecForICQUser(o);
+    ownerName = ownerCodec->toUnicode(o->GetAlias());
+    gUserManager.DropOwner(m_nPPID);
+  }
+
   mlvHistory->clear();
   while (m_nHistoryShowing < (NUM_MSG_PER_HISTORY))
   {
@@ -2041,13 +2051,13 @@
         messageText = codec->toUnicode((*tempIter)->Text());
 
       mlvHistory->addMsg((*tempIter)->Direction(), false,
-                  EventDescription(*tempIter),
+                  ((*tempIter)->SubCommand() == ICQ_CMDxSUB_MSG ? QString("") : (EventDescription(*tempIter) + " ")),
                   date,
                   (*tempIter)->IsDirect(),
                   (*tempIter)->IsMultiRec(),
                   (*tempIter)->IsUrgent(),
                   (*tempIter)->IsEncrypted(),
-                  contactName,
+                  ((*tempIter)->Direction() == D_RECEIVER ? contactName : ownerName),
                   MLView::toRichText(messageText, true, bUseHTML));
       m_nHistoryShowing++;
       barFiltering->setProgress(m_nHistoryShowing);
@@ -2067,6 +2077,10 @@
          break;
     }
   }
+
+  // History view is buffered so tell it write buffer to output now that all entries have been added
+  mlvHistory->updateContent();
+
   delete [] ftxt;
   if(lneFilter->text().isEmpty())
     lblHistory->setText(tr("[<font color=\"%1\">Received</font>] "
@@ -2089,7 +2103,7 @@
   if(!m_bHistoryReverse)
     mlvHistory->GotoEnd();
   else
-    mlvHistory->setCursorPosition(0, 0);
+    mlvHistory->GotoHome();
   barFiltering->reset();
 }
 
Index: licq/plugins/qt-gui/src/mlview.h
===================================================================
--- licq/plugins/qt-gui/src/mlview.h	(revision 4786)
+++ licq/plugins/qt-gui/src/mlview.h	(working copy)
@@ -31,6 +31,7 @@
 
   void appendNoNewLine(const QString& s);
   void append(const QString& s);
+  void GotoHome();
   void GotoEnd();
 
   bool hasMarkedText() const;
Index: licq/plugins/qt-gui/src/mlview.cpp
===================================================================
--- licq/plugins/qt-gui/src/mlview.cpp	(revision 4786)
+++ licq/plugins/qt-gui/src/mlview.cpp	(working copy)
@@ -156,6 +156,11 @@
   return text;
 }
 
+void MLView::GotoHome()
+{
+  setContentsPos(0, 0);
+}
+
 void MLView::GotoEnd()
 {
   moveCursor(QTextBrowser::MoveEnd, false);
Index: licq/plugins/qt-gui/src/ewidgets.h
===================================================================
--- licq/plugins/qt-gui/src/ewidgets.h	(revision 4786)
+++ licq/plugins/qt-gui/src/ewidgets.h	(working copy)
@@ -198,13 +198,17 @@
   unsigned long m_nUin;
   CMainWindow *mainwin;
 public:
+  static const char *const styleNames[];
+
   CMessageViewWidget(const char *szId, unsigned long nPPID,
-    CMainWindow *m, QWidget *parent = 0, const char *name = 0);
+    CMainWindow *m, QWidget *parent = 0, const char *name = 0, bool historyMode = false);
   CMessageViewWidget(unsigned long _nUin, CMainWindow *m,
-		     QWidget* parent=0, const char * name =0);
+    QWidget* parent = 0, const char *name = 0, bool historyMode = false);
   virtual ~CMessageViewWidget();
 
   void setOwner(const char *szId);
+  void updateContent();
+  void clear();
   void addMsg(direction dir, bool fromHistory, QString eventDescription, QDateTime date, 
     bool isDirect, bool isMultiRec, bool isUrgent, bool isEncrypted, 
     QString contactName, QString messageText);
@@ -212,7 +216,9 @@
 
   unsigned short m_nMsgStyle;
   QString m_nDateFormat;
-  bool m_bAppendLineBreak;
+  bool m_extraSpacing;
+  bool m_appendLineBreak;
+  bool m_useBuffer;
   QColor m_colorRcvHistory;
   QColor m_colorSntHistory;
   QColor m_colorRcv;
@@ -222,6 +228,10 @@
 public slots:
   virtual void addMsg(CUserEvent *, const char * = 0, unsigned long = 0);
   void addMsg(ICQEvent *);
+
+private:
+  void internalAddMsg(QString s);
+  QString m_buffer;
 };
 
 /* ----------------------------------------------------------------------------- */
Index: licq/plugins/qt-gui/src/optionsdlg.cpp
===================================================================
--- licq/plugins/qt-gui/src/optionsdlg.cpp	(revision 4786)
+++ licq/plugins/qt-gui/src/optionsdlg.cpp	(working copy)
@@ -212,26 +212,13 @@
   chkSysBack->setChecked(mainwin->m_bSystemBackground);
   chkSendFromClipboard->setChecked(mainwin->m_bSendFromClipboard);
   chkMsgChatView->setChecked(mainwin->m_bMsgChatView);
-
-  bool isCustomDate = true;
-  for (int i = 0; i < cmbDateFormat->count(); i++)
-  {
-    if (cmbDateFormat->text(i) == mainwin->m_nDateFormat)
-    {
-      cmbDateFormat->setCurrentItem(i);
-      isCustomDate = false;
-      break;
-    }
-  }
-
-  // Make sure the checkbox is actually toggled, so that widgets are enabled/disabled.
-  chkCustomDateFormat->setChecked(!isCustomDate);
-  chkCustomDateFormat->setChecked(isCustomDate);
-
-  customDateFormat->setText(mainwin->m_nDateFormat);
-
-  chkLineBreak->setChecked(mainwin->m_bAppendLineBreak);
-  cmbStyle->setCurrentItem(mainwin->m_nMsgStyle);
+  cmbChatDateFormat->lineEdit()->setText(mainwin->m_chatDateFormat);
+  chkChatVertSpacing->setChecked(mainwin->m_chatVertSpacing);
+  chkChatLineBreak->setChecked(mainwin->m_chatAppendLineBreak);
+  cmbChatStyle->setCurrentItem(mainwin->m_chatMsgStyle);
+  cmbHistStyle->setCurrentItem(mainwin->m_histMsgStyle);
+  chkHistVertSpacing->setChecked(mainwin->m_histVertSpacing);
+  cmbHistDateFormat->lineEdit()->setText(mainwin->m_histDateFormat);
   btnColorRcv->setPaletteBackgroundColor(mainwin->m_colorRcv);
   btnColorSnt->setPaletteBackgroundColor(mainwin->m_colorSnt);
   btnColorRcvHistory->setPaletteBackgroundColor(mainwin->m_colorRcvHistory);
@@ -527,9 +514,13 @@
   mainwin->m_bSystemBackground = chkSysBack->isChecked();
   mainwin->m_bSendFromClipboard = chkSendFromClipboard->isChecked();
   mainwin->m_bMsgChatView = chkMsgChatView->isChecked();
-  mainwin->m_bAppendLineBreak = chkLineBreak->isChecked();
-  mainwin->m_nMsgStyle = cmbStyle->currentItem();
-  mainwin->m_nDateFormat = getCurrentDateFormat();
+  mainwin->m_chatVertSpacing = chkChatVertSpacing->isChecked();
+  mainwin->m_chatAppendLineBreak = chkChatLineBreak->isChecked();
+  mainwin->m_chatMsgStyle = cmbChatStyle->currentItem();
+  mainwin->m_chatDateFormat = cmbChatDateFormat->currentText();
+  mainwin->m_histMsgStyle = cmbHistStyle->currentItem();
+  mainwin->m_histVertSpacing = chkHistVertSpacing->isChecked();
+  mainwin->m_histDateFormat = cmbHistDateFormat->currentText();
   mainwin->m_colorRcv = btnColorRcv->paletteBackgroundColor();
   mainwin->m_colorSnt = btnColorSnt->paletteBackgroundColor();
   mainwin->m_colorRcvHistory = btnColorRcvHistory->paletteBackgroundColor();
@@ -1566,39 +1557,37 @@
   QVBox* boxRight = new QVBox(w);
   lay->addWidget(boxRight);
 
-  QGroupBox* boxOptions = new QGroupBox(1, Horizontal, tr("Options"), boxRight);
+  QGroupBox* boxChatOptions = new QGroupBox(1, Horizontal, tr("Chat Options"), boxRight);
 
-  new QLabel(tr("Style:"), boxOptions);
-  cmbStyle = new QComboBox(false, boxOptions);
-  cmbStyle->insertItem("Default");
-  cmbStyle->insertItem("Compact");
-  cmbStyle->insertItem("Tiny");
-  cmbStyle->insertItem("Table");
-  cmbStyle->insertItem("History");
-  connect(cmbStyle, SIGNAL(activated(int)), this, SLOT(slot_refresh_msgViewer()));
+  const char *const dateFormats[7] = {
+      "hh:mm:ss",
+      "yyyy-MM-dd hh:mm:ss",
+      "yyyy-MM-dd",
+      "yyyy/MM/dd hh:mm:ss",
+      "yyyy/MM/dd",
+      "dd.MM.yyyy hh:mm:ss",
+      "dd.MM.yyyy"};
 
-  chkLineBreak = new QCheckBox(tr("Insert Horizontal Line"), boxOptions);
-  connect(chkLineBreak, SIGNAL(toggled(bool)), this, SLOT(slot_refresh_msgViewer()));
+  new QLabel(tr("Style:"), boxChatOptions);
+  cmbChatStyle = new QComboBox(false, boxChatOptions);
+  for(int i = 0; i < 5; ++i)
+    cmbChatStyle->insertItem(CMessageViewWidget::styleNames[i]);
+  connect(cmbChatStyle, SIGNAL(activated(int)), this, SLOT(slot_refresh_msgViewer()));
 
-  new QLabel(tr("Date Format:"), boxOptions);
-  cmbDateFormat = new QComboBox(false, boxOptions);
-  cmbDateFormat->insertItem("hh:mm:ss");
-  cmbDateFormat->insertItem("yyyy-MM-dd hh:mm:ss");
-  cmbDateFormat->insertItem("yyyy-MM-dd");
-  cmbDateFormat->insertItem("yyyy/MM/dd hh:mm:ss");
-  cmbDateFormat->insertItem("yyyy/MM/dd");
-  cmbDateFormat->insertItem("dd.MM.yyyy hh:mm:ss");
-  cmbDateFormat->insertItem("dd.MM.yyyy");
-  connect(cmbDateFormat, SIGNAL(activated(int)), this, SLOT(slot_refresh_msgViewer()));
+  chkChatVertSpacing = new QCheckBox(tr("Insert Vertical Spacing"), boxChatOptions);
+  connect(chkChatVertSpacing, SIGNAL(toggled(bool)), this, SLOT(slot_refresh_msgViewer()));
 
-  chkCustomDateFormat = new QCheckBox(tr("Custom Date Format:"), boxOptions);
-  connect(chkCustomDateFormat, SIGNAL(toggled(bool)), this, SLOT(slot_refresh_msgViewer()));
-  connect(chkCustomDateFormat, SIGNAL(toggled(bool)), cmbDateFormat, SLOT(setDisabled(bool)));
+  chkChatLineBreak = new QCheckBox(tr("Insert Horizontal Line"), boxChatOptions);
+  connect(chkChatLineBreak, SIGNAL(toggled(bool)), this, SLOT(slot_refresh_msgViewer()));
 
-  customDateFormat = new QLineEdit(boxOptions);
-  connect(chkCustomDateFormat, SIGNAL(toggled(bool)), customDateFormat, SLOT(setEnabled(bool)));
-  connect(customDateFormat, SIGNAL(textChanged(const QString&)), this, SLOT(slot_refresh_msgViewer()));
-  QWhatsThis::add(customDateFormat, tr(
+  new QLabel(tr("Date Format:"), boxChatOptions);
+  cmbChatDateFormat = new QComboBox(true, boxChatOptions);
+  for(int i = 0; i < 7; ++i)
+    cmbChatDateFormat->insertItem(dateFormats[i]);
+  connect(cmbChatDateFormat, SIGNAL(activated(int)), this, SLOT(slot_refresh_msgViewer()));
+  connect(cmbChatDateFormat, SIGNAL(textChanged(const QString&)), this, SLOT(slot_refresh_msgViewer()));
+
+  QString helpDateFormat = tr(
       "<p>Available custom date format variables.</p>\n"
       "<table>\n"
       "<tr><th>Expression</th><th>Output</th></tr>\n"
@@ -1623,8 +1612,29 @@
       "<tr><td>zzz</td><td>the millisecond with leading zero (000..999)</td></tr>\n"
       "<tr><td>AP</td><td>use AM/PM display. AP will be replaced by either 'AM' or 'PM'</td></tr>\n"
       "<tr><td>ap</td><td>use am/pm display. ap will be replaced by either 'am' or 'pm'</td></tr>\n"
-      "</table>"));
+      "</table>");
 
+  QWhatsThis::add(cmbChatDateFormat, helpDateFormat);
+
+  QGroupBox* boxHistOptions = new QGroupBox(1, Horizontal, tr("History Options"), boxRight);
+  new QLabel(tr("Style:"), boxHistOptions);
+  cmbHistStyle = new QComboBox(false, boxHistOptions);
+  for(int i = 0; i < 6; ++i)
+    cmbHistStyle->insertItem(CMessageViewWidget::styleNames[i]);
+  connect(cmbHistStyle, SIGNAL(activated(int)), this, SLOT(slot_refresh_msgViewer()));
+
+  chkHistVertSpacing = new QCheckBox(tr("Insert Vertical Spacing"), boxHistOptions);
+  connect(chkHistVertSpacing, SIGNAL(toggled(bool)), this, SLOT(slot_refresh_msgViewer()));
+
+  new QLabel(tr("Date Format:"), boxHistOptions);
+  cmbHistDateFormat = new QComboBox(true, boxHistOptions);
+  for(int i = 0; i < 7; ++i)
+    cmbHistDateFormat->insertItem(dateFormats[i]);
+  connect(cmbHistDateFormat, SIGNAL(activated(int)), this, SLOT(slot_refresh_msgViewer()));
+  connect(cmbHistDateFormat, SIGNAL(textChanged(const QString&)), this, SLOT(slot_refresh_msgViewer()));
+  QWhatsThis::add(cmbHistDateFormat, helpDateFormat);
+
+
   QGroupBox *boxColors = new QGroupBox(2, Horizontal, tr("Colors"), boxRight);
 
   new QLabel(tr("Message Received:"), boxColors);
@@ -1663,22 +1673,17 @@
   tabViewer = new QTabWidget(w);
   lay->addWidget(tabViewer);
 
-  msgViewer = new CMessageViewWidget(0, gMainWindow, tabViewer);
-  tabViewer->insertTab(msgViewer, "Marge");
+  msgChatViewer = new CMessageViewWidget(0, gMainWindow, tabViewer);
+  tabViewer->insertTab(msgChatViewer, "Marge");
 
+  msgHistViewer = new CMessageViewWidget(0, gMainWindow, tabViewer, 0, true);
+  tabViewer->insertTab(msgHistViewer, "History");
+
   lay->activate();
 
   return w;
 }
 
-QString OptionsDlg::getCurrentDateFormat() const
-{
-  if (chkCustomDateFormat->isChecked())
-    return customDateFormat->text();
-  else
-    return cmbDateFormat->currentText();
-}
-
 void OptionsDlg::slot_refresh_msgViewer()
 {
   // Don't update the time at every refresh
@@ -1696,29 +1701,47 @@
       QT_TR_NOOP("Marge has left the conversation.")
   };
 
-  msgViewer->m_nMsgStyle = cmbStyle->currentItem();
-  msgViewer->m_bAppendLineBreak = chkLineBreak->isChecked();
-  msgViewer->m_colorSnt = btnColorSnt->paletteBackgroundColor();
-  msgViewer->m_colorRcv = btnColorRcv->paletteBackgroundColor();
-  msgViewer->m_colorSntHistory = btnColorSntHistory->paletteBackgroundColor();
-  msgViewer->m_colorRcvHistory = btnColorRcvHistory->paletteBackgroundColor();
-  msgViewer->m_colorNotice = btnColorNotice->paletteBackgroundColor();
+  msgChatViewer->m_nMsgStyle = cmbChatStyle->currentItem();
+  msgChatViewer->m_extraSpacing = chkChatVertSpacing->isChecked();
+  msgChatViewer->m_appendLineBreak = chkChatLineBreak->isChecked();
+  msgChatViewer->m_colorSnt = btnColorSnt->paletteBackgroundColor();
+  msgChatViewer->m_colorRcv = btnColorRcv->paletteBackgroundColor();
+  msgChatViewer->m_colorSntHistory = btnColorSntHistory->paletteBackgroundColor();
+  msgChatViewer->m_colorRcvHistory = btnColorRcvHistory->paletteBackgroundColor();
+  msgChatViewer->m_colorNotice = btnColorNotice->paletteBackgroundColor();
   tabViewer->setPaletteForegroundColor(btnColorTypingLabel->paletteBackgroundColor());
-  msgViewer->setPaletteBackgroundColor(btnColorChatBkg->paletteBackgroundColor());
+  msgChatViewer->setPaletteBackgroundColor(btnColorChatBkg->paletteBackgroundColor());
 
-  msgViewer->m_nDateFormat = getCurrentDateFormat();
+  msgChatViewer->m_nDateFormat = cmbChatDateFormat->currentText();
 
-  msgViewer->clear();
+  msgHistViewer->m_nMsgStyle = cmbHistStyle->currentItem();
+  msgHistViewer->m_extraSpacing = chkHistVertSpacing->isChecked();
+  msgHistViewer->m_colorSnt = btnColorSnt->paletteBackgroundColor();
+  msgHistViewer->m_colorRcv = btnColorRcv->paletteBackgroundColor();
+  msgHistViewer->setPaletteBackgroundColor(btnColorChatBkg->paletteBackgroundColor());
+  msgHistViewer->m_nDateFormat = cmbHistDateFormat->currentText();
+
+  msgChatViewer->clear();
+  msgHistViewer->clear();
   for (unsigned int i = 0; i<7; i++)
   {
-    msgViewer->addMsg(i%2 == 0 ? D_RECEIVER : D_SENDER, (i<2),
+    msgChatViewer->addMsg(i%2 == 0 ? D_RECEIVER : D_SENDER, (i<2),
           QString(""),
           date,
           true, false, false, false, 
           names[i % 2],
           MLView::toRichText(tr(msgs[i]), true, true));
+
+    msgHistViewer->addMsg(i%2 == 0 ? D_RECEIVER : D_SENDER, false,
+          QString(""),
+          date,
+          true, false, false, false,
+          names[i % 2],
+          MLView::toRichText(tr(msgs[i]), true, true));
   }
-  msgViewer->addNotice(date, MLView::toRichText(tr(msgs[7]), true, true));
+  msgChatViewer->addNotice(date, MLView::toRichText(tr(msgs[7]), true, true));
+
+  msgHistViewer->updateContent();
 }
 
 CColorOption::CColorOption (QWidget* parent)
Index: licq/plugins/qt-gui/src/mainwin.cpp
===================================================================
--- licq/plugins/qt-gui/src/mainwin.cpp	(revision 4786)
+++ licq/plugins/qt-gui/src/mainwin.cpp	(working copy)
@@ -432,8 +432,9 @@
   licqConf.ReadBool("AutoPosReplyWin", m_bAutoPosReplyWin, true);
   licqConf.ReadBool("AutoSendThroughServer", m_bAutoSendThroughServer, false);
   licqConf.ReadBool("EnableMainwinMouseMovement", m_bEnableMainwinMouseMovement, true);
-  licqConf.ReadNum("ChatMessageStyle", m_nMsgStyle, 0);
-  licqConf.ReadBool("ChatAppendLinebreak", m_bAppendLineBreak, false);
+  licqConf.ReadNum("ChatMessageStyle", m_chatMsgStyle, 0);
+  licqConf.ReadBool("ChatVerticalSpacing", m_chatVertSpacing, true);
+  licqConf.ReadBool("ChatAppendLinebreak", m_chatAppendLineBreak, false);
   licqConf.ReadBool("FlashTaskbar", m_bFlashTaskbar, true);
   licqConf.ReadBool("ShowUserIcons", m_bShowUserIcons, true);
   licqConf.ReadBool("MainWinSticky", m_bMainWinSticky, false);
@@ -441,7 +442,11 @@
   licqConf.ReadBool("SingleLineChatMode", m_bSingleLineChatMode, false);
   licqConf.ReadBool("CheckSpellingEnabled", m_bCheckSpellingEnabled, false);
   licqConf.ReadStr("DateFormat", szTemp, "hh:mm:ss");
-  m_nDateFormat = QString::fromLatin1(szTemp);
+  m_chatDateFormat = QString::fromLatin1(szTemp);
+  licqConf.ReadNum("HistoryMessageStyle", m_histMsgStyle, 0);
+  licqConf.ReadBool("HistoryVerticalSpacing", m_histVertSpacing, true);
+  licqConf.ReadStr("HistoryDateFormat", szTemp, "yyyy-MM-dd hh:mm:ss");
+  m_histDateFormat = QString::fromLatin1(szTemp);
 
   licqConf.ReadStr("ReceiveMessageColor", szTemp, "red");
   m_colorRcv = QColor(szTemp);
@@ -3576,8 +3581,9 @@
   licqConf.WriteBool("SingleLineChatMode", m_bSingleLineChatMode);
   licqConf.WriteBool("CheckSpellingEnabled", m_bCheckSpellingEnabled);
 
-  licqConf.WriteNum("ChatMessageStyle", m_nMsgStyle);
-  licqConf.WriteBool("ChatAppendLinebreak", m_bAppendLineBreak);
+  licqConf.WriteNum("ChatMessageStyle", m_chatMsgStyle);
+  licqConf.WriteBool("ChatVerticalSpacing", m_chatVertSpacing);
+  licqConf.WriteBool("ChatAppendLinebreak", m_chatAppendLineBreak);
   licqConf.WriteStr("ReceiveMessageColor", m_colorRcv.name());
   licqConf.WriteStr("ReceiveHistoryColor", m_colorRcvHistory.name());
   licqConf.WriteStr("SentMessageColor", m_colorSnt.name());
@@ -3586,7 +3592,10 @@
   licqConf.WriteStr("TabFontColor", m_colorTab.name());
   licqConf.WriteStr("TabOnTypingColor", m_colorTabTyping.name());
   licqConf.WriteStr("ChatBackground", m_colorChatBkg.name());
-  licqConf.WriteStr("DateFormat", m_nDateFormat.latin1());
+  licqConf.WriteStr("DateFormat", m_chatDateFormat.latin1());
+  licqConf.WriteNum("HistoryMessageStyle", m_histMsgStyle);
+  licqConf.WriteBool("HistoryVerticalSpacing", m_histVertSpacing);
+  licqConf.WriteStr("HistoryDateFormat", m_histDateFormat.latin1());
 
   licqConf.WriteBool("showPopPicture", m_bPopPicture);
   licqConf.WriteBool("showPopAlias", m_bPopAlias);
Index: licq/plugins/qt-gui/src/ewidgets.cpp
===================================================================
--- licq/plugins/qt-gui/src/ewidgets.cpp	(revision 4786)
+++ licq/plugins/qt-gui/src/ewidgets.cpp	(working copy)
@@ -661,15 +661,39 @@
 // -----------------------------------------------------------------------------
 
 //- Message View Widget ---------------------------------------------------------
+
+// Names of the message styles
+const char *const CMessageViewWidget::styleNames[] = {
+    "Default",
+    "Compact",
+    "Tiny",
+    "Table",
+    "Long",
+    "Wide"};
+
+
 CMessageViewWidget::CMessageViewWidget(const char *szId, unsigned long nPPID,
-  CMainWindow *m, QWidget* parent, const char * name)
+  CMainWindow *m, QWidget* parent, const char *name, bool historyMode)
   : CHistoryWidget(parent, name)
 {
   m_szId = szId ? strdup(szId) : 0;
   m_nPPID = nPPID;
-  m_nMsgStyle = m->m_nMsgStyle;
-  m_nDateFormat = m->m_nDateFormat;
-  m_bAppendLineBreak = m->m_bAppendLineBreak;
+  if (historyMode)
+  {
+    m_useBuffer = true;
+    m_nMsgStyle = m->m_histMsgStyle;
+    m_nDateFormat = m->m_histDateFormat;
+    m_extraSpacing = m->m_histVertSpacing;
+    m_appendLineBreak = false;
+  }
+  else
+  {
+    m_useBuffer = false;
+    m_nMsgStyle = m->m_chatMsgStyle;
+    m_nDateFormat = m->m_chatDateFormat;
+    m_extraSpacing = m->m_chatVertSpacing;
+    m_appendLineBreak = m->m_chatAppendLineBreak;
+  }
   m_colorRcv = m->m_colorRcv;
   m_colorSnt = m->m_colorSnt;
   m_colorRcvHistory = m->m_colorRcvHistory;
@@ -697,14 +721,27 @@
 */
 }
 
-CMessageViewWidget::CMessageViewWidget(unsigned long _nUin, CMainWindow *m, QWidget* parent, const char * name)
+CMessageViewWidget::CMessageViewWidget(unsigned long _nUin, CMainWindow *m, QWidget *parent, const char *name, bool historyMode)
 :CHistoryWidget(parent,name)
 {
   m_nUin= _nUin;
   m_szId = NULL; // avoid desalocation error at destructor
-  m_nMsgStyle = m->m_nMsgStyle;
-  m_nDateFormat = m->m_nDateFormat;
-  m_bAppendLineBreak = m->m_bAppendLineBreak;
+  if (historyMode)
+  {
+    m_useBuffer = true;
+    m_nMsgStyle = m->m_histMsgStyle;
+    m_nDateFormat = m->m_histDateFormat;
+    m_extraSpacing = m->m_histVertSpacing;
+    m_appendLineBreak = false;
+  }
+  else
+  {
+    m_useBuffer = false;
+    m_nMsgStyle = m->m_chatMsgStyle;
+    m_nDateFormat = m->m_chatDateFormat;
+    m_extraSpacing = m->m_chatVertSpacing;
+    m_appendLineBreak = m->m_chatAppendLineBreak;
+  }
   m_colorRcv = m->m_colorRcv;
   m_colorSnt = m->m_colorSnt;
   m_colorRcvHistory = m->m_colorRcvHistory;
@@ -745,6 +782,70 @@
   m_szId = strdup(_szId);
 }
 
+void CMessageViewWidget::clear()
+{
+  CHistoryWidget::clear();
+
+  m_buffer = "";
+
+  switch (m_nMsgStyle)
+  {
+    case 5:
+      // table doesn't work when appending so must buffer when using this style
+      m_buffer.append("<table border=\"0\">");
+      m_useBuffer = true;
+      break;
+  }
+  if (m_useBuffer)
+    m_buffer.prepend("<html><body>");
+}
+
+void CMessageViewWidget::updateContent()
+{
+  if (m_useBuffer == false)
+    return;
+  setText(m_buffer);
+}
+
+void CMessageViewWidget::internalAddMsg(QString s)
+{
+  if (m_extraSpacing)
+  {
+    if (m_nMsgStyle != 5)
+    {
+      if (m_useBuffer)
+      {
+        s.prepend("<p>");
+        s.append("</p>");
+      }
+      else
+      {
+        s.append("<br>");
+      }
+    }
+    else
+    {
+      s.append("<tr><td colspan=\"3\"></td></tr>");
+    }
+  }
+
+  if (m_useBuffer)
+  {
+    if (m_extraSpacing == false && m_nMsgStyle != 5)
+      s.append("<br>");
+
+    m_buffer.append(s);
+    if (m_appendLineBreak)
+      m_buffer.append("<hr>");
+  }
+  else
+  {
+    append(s);
+    if (m_appendLineBreak)
+      append("<hr>");
+  }
+}
+
 void CMessageViewWidget::addMsg(ICQEvent * _e)
 {
   if (strcmp(_e->Id(), m_szId) == 0 && _e->PPID() == m_nPPID &&
@@ -758,7 +859,6 @@
 {
   QString s;
   QString color;
-  bool bAIM = (m_nPPID == LICQ_PPID) && !isdigit(m_szId[0]);
 
   if (fromHistory) 
     if (dir == D_RECEIVER) 
@@ -784,7 +884,7 @@
   
   switch (m_nMsgStyle) {
     case 0:
-      s = QString("<html><body><font color=\"%1\"><b>%2%3 [%4%5%6%7] %8:</b></font><br>")
+      s = QString("<font color=\"%1\"><b>%2%3 [%4%5%6%7] %8:</b></font><br>")
                   .arg(color)
                   .arg(eventDescription)
                   .arg(my_date)
@@ -793,7 +893,7 @@
                   .arg(isUrgent ? 'U' : '-')
                   .arg(isEncrypted ? 'E' : '-')
                   .arg(contactName);
-      s.append(QString("<font color=\"%1\">%2</font></body></html>")
+      s.append(QString("<font color=\"%1\">%2</font>")
                       .arg(color)
                       .arg(messageText));
       break;
@@ -810,12 +910,6 @@
       s.append(QString("<font color=\"%1\">%2</font>")
                       .arg(color)
                       .arg(messageText));
-      if (bAIM)
-      {
-        s.prepend("<html><body>");
-        s.append("</body></html>");
-      }
-
       break;
     case 2:
       s = QString("<font color=\"%1\"><b>%2%3 - %4: </b></font>")
@@ -826,13 +920,6 @@
       s.append(QString("<font color=\"%1\">%2</font>")
                       .arg(color)
                       .arg(messageText));
-
-      if (bAIM)
-      {
-        s.prepend("<html><body>");
-        s.append("</body></html>");
-      }
-
       break;  
     case 3:
       s = QString("<table border=\"1\"><tr><td><b><font color=\"%1\">%2%3</font><b><td><b><font color=\"%4\">%5</font></b></font></td>")
@@ -864,12 +951,22 @@
                   .arg(color)
                   .arg(messageText));
     break;     
+
+    case 5:
+      // Mode 5 is a table so it cannot be displayed in paragraphs
+      s = QString("<tr><td><nobr><b><font color=\"%1\">%2</font><b></nobr></td>")
+                  .arg(color)
+                  .arg(my_date);
+      s.append(QString("<td><b><font color=\"%3\">%4</font></b></font></td>")
+                       .arg(color)
+                       .arg(contactName));
+      s.append(QString("<td><font color=\"%1\">%2</font></td></tr>")
+                      .arg(color)
+                      .arg(messageText));
+      break;
   }
-  
-  append(s);
-  if (m_bAppendLineBreak) {
-    append("<hr>");
-  }
+
+  internalAddMsg(s);
 }
 
 void CMessageViewWidget::addMsg(CUserEvent* e, const char *_szId, unsigned long _nPPID)
@@ -988,18 +1085,24 @@
                   .arg(messageText);
       break; 
 
+    case 5:
+      s = QString("<tr><td><b><font color=\"%1\">%2</font><b></td><td colspan=\"2\"><b><font color=\"%3\">%4</font></b></font></td></tr>")
+                  .arg(color)
+                  .arg(dateTime)
+                  .arg(color)
+                  .arg(messageText);
+      break;
+
     case 0:
     default:
-      s = QString("<html><body><font color=\"%1\"><b>[%2] %3</b></font><br></body></html>")
+      s = QString("<font color=\"%1\"><b>[%2] %3</b></font><br>")
                   .arg(color)
                   .arg(dateTime)
                   .arg(messageText);
       break;    
   }
 
-  append(s);
-  if (m_bAppendLineBreak)
-    append("<hr>");
+  internalAddMsg(s);
 }
 
 CLicqMessageBox::CLicqMessageBox(QWidget *parent)
Index: licq/plugins/qt-gui/src/optionsdlg.h
===================================================================
--- licq/plugins/qt-gui/src/optionsdlg.h	(revision 4786)
+++ licq/plugins/qt-gui/src/optionsdlg.h	(working copy)
@@ -151,21 +151,24 @@
    QComboBox* cmbSARgroup, *cmbSARmsg;
    MLEditWrap* edtSARtext;
 
-   // display tab
-   QWidget* new_popup_options();
+  // popup info group (contact list tab)
    QGroupBox *boxPopWin;
    QCheckBox *popPicture, *popAlias, *popName, *popEmail, *popPhone,
              *popFax, *popCellular, *popIP,
              *popLastOnline, *popOnlineSince, *popIdleTime, *popID;
 
+  // Message display tab
    QWidget* new_chat_options();
-   CMessageViewWidget *msgViewer;
+  CMessageViewWidget *msgChatViewer;
+  CMessageViewWidget *msgHistViewer;
    QTabWidget *tabViewer;
-   QComboBox *cmbStyle;
-   QComboBox *cmbDateFormat;
-   QCheckBox *chkCustomDateFormat;
-   QLineEdit *customDateFormat;
-   QCheckBox *chkLineBreak;
+  QComboBox *cmbChatStyle;
+  QComboBox *cmbChatDateFormat;
+  QCheckBox *chkChatVertSpacing;
+  QCheckBox *chkChatLineBreak;
+  QComboBox *cmbHistStyle;
+  QCheckBox *chkHistVertSpacing;
+  QComboBox *cmbHistDateFormat;
    CColorOption *btnColorRcv;
    CColorOption *btnColorSnt;
    CColorOption *btnColorRcvHistory;
@@ -206,7 +209,6 @@
   void slot_refresh_msgViewer();
 
 private:
-  QString getCurrentDateFormat() const;
 };
 
 
