Ticket #1449: licq-4782-history_newstyle.patch

File licq-4782-history_newstyle.patch, 6.5 kB (added by flynd, 22 months ago)

Half fix for #1: This is a total change of the history style. No option to select style (yet).

  • licq/plugins/qt-gui/src/userinfodlg.cpp

     
    17261726  l->addWidget(chkHistoryReverse); 
    17271727 
    17281728  mlvHistory = new CMessageViewWidget(m_szId, m_nPPID, mainwin, p, "history"); 
    1729   mlvHistory->m_nMsgStyle = 4; /* STYLE_HISTORY */ 
     1729  mlvHistory->m_nMsgStyle = 5; /* STYLE_HISTORY */ 
    17301730 
    17311731  connect(mlvHistory, SIGNAL(viewurl(QWidget*, QString)), mainwin, SLOT(slot_viewurl(QWidget *, QString))); 
    17321732 
     
    20272027  barFiltering->setTotalSteps(NUM_MSG_PER_HISTORY); 
    20282028  char* ftxt = qstrdup(codec->fromUnicode(lneFilter->text())); 
    20292029  int flen = strlen(ftxt); 
    2030    
     2030 
     2031  QString ownerName; 
     2032  ICQOwner *o = gUserManager.FetchOwner(m_nPPID, LOCK_R); 
     2033  if (o != NULL) 
     2034  { 
     2035    // Don't use this codec to decode our conversation with the contact 
     2036    // since we're using the contact's encoding, not ours. 
     2037    QTextCodec *ownerCodec = UserCodec::codecForICQUser(o); 
     2038    ownerName = ownerCodec->toUnicode(o->GetAlias()); 
     2039    gUserManager.DropOwner(m_nPPID); 
     2040  } 
     2041 
    20312042  mlvHistory->clear(); 
    20322043  while (m_nHistoryShowing < (NUM_MSG_PER_HISTORY)) 
    20332044  { 
     
    20472058                  (*tempIter)->IsMultiRec(), 
    20482059                  (*tempIter)->IsUrgent(), 
    20492060                  (*tempIter)->IsEncrypted(), 
    2050                   contactName, 
     2061                  ((*tempIter)->Direction() == D_RECEIVER ? contactName : ownerName), 
    20512062                  MLView::toRichText(messageText, true, bUseHTML)); 
    20522063      m_nHistoryShowing++; 
    20532064      barFiltering->setProgress(m_nHistoryShowing); 
     
    20672078         break; 
    20682079    } 
    20692080  } 
     2081 
     2082  // History view may be buffered so write buffer to output now that all entries has been added 
     2083  mlvHistory->updateContent(); 
     2084 
    20702085  delete [] ftxt; 
    20712086  if(lneFilter->text().isEmpty()) 
    20722087    lblHistory->setText(tr("[<font color=\"%1\">Received</font>] " 
     
    20892104  if(!m_bHistoryReverse) 
    20902105    mlvHistory->GotoEnd(); 
    20912106  else 
    2092     mlvHistory->setCursorPosition(0, 0); 
     2107    mlvHistory->GotoHome(); 
    20932108  barFiltering->reset(); 
    20942109} 
    20952110 
  • licq/plugins/qt-gui/src/mlview.h

     
    3131 
    3232  void appendNoNewLine(const QString& s); 
    3333  void append(const QString& s); 
     34  void GotoHome(); 
    3435  void GotoEnd(); 
    3536 
    3637  bool hasMarkedText() const; 
  • licq/plugins/qt-gui/src/mlview.cpp

     
    156156  return text; 
    157157} 
    158158 
     159void MLView::GotoHome() 
     160{ 
     161  setContentsPos(0, 0); 
     162} 
     163 
    159164void MLView::GotoEnd() 
    160165{ 
    161166  moveCursor(QTextBrowser::MoveEnd, false); 
  • licq/plugins/qt-gui/src/ewidgets.h

     
    197197  unsigned long m_nPPID; 
    198198  unsigned long m_nUin; 
    199199  CMainWindow *mainwin; 
     200  QString m_buffer; 
    200201public: 
    201202  CMessageViewWidget(const char *szId, unsigned long nPPID, 
    202203    CMainWindow *m, QWidget *parent = 0, const char *name = 0); 
     
    205206  virtual ~CMessageViewWidget(); 
    206207 
    207208  void setOwner(const char *szId); 
     209  void updateContent(); 
     210  void clear(); 
    208211  void addMsg(direction dir, bool fromHistory, QString eventDescription, QDateTime date,  
    209212    bool isDirect, bool isMultiRec, bool isUrgent, bool isEncrypted,  
    210213    QString contactName, QString messageText); 
     
    213216  unsigned short m_nMsgStyle; 
    214217  QString m_nDateFormat; 
    215218  bool m_bAppendLineBreak; 
     219  bool m_useBuffer; 
    216220  QColor m_colorRcvHistory; 
    217221  QColor m_colorSntHistory; 
    218222  QColor m_colorRcv; 
  • licq/plugins/qt-gui/src/ewidgets.cpp

     
    745745  m_szId = strdup(_szId); 
    746746} 
    747747 
     748void CMessageViewWidget::clear() 
     749{ 
     750  CHistoryWidget::clear(); 
     751 
     752  m_buffer = "<html><body>"; 
     753  switch(m_nMsgStyle) 
     754  { 
     755    case 5: 
     756      m_buffer.append("<table border=\"0\">"); 
     757      m_useBuffer = true; 
     758      break; 
     759    default: 
     760      m_useBuffer = false; 
     761  } 
     762} 
     763 
     764void CMessageViewWidget::updateContent() 
     765{ 
     766  if (m_useBuffer == false) 
     767    return; 
     768  setText(m_buffer); 
     769} 
     770 
    748771void CMessageViewWidget::addMsg(ICQEvent * _e) 
    749772{ 
    750773  if (strcmp(_e->Id(), m_szId) == 0 && _e->PPID() == m_nPPID && 
     
    864887                  .arg(color) 
    865888                  .arg(messageText)); 
    866889    break;      
     890 
     891    case 5: 
     892      // Mode 5 is a table so it cannot be displayed in paragraphs 
     893      s = QString("<tr><td><nobr><b><font color=\"%1\">%2</font><b></nobr></td>") 
     894                  .arg(color) 
     895                  .arg(my_date); 
     896      s.append(QString("<td><b><font color=\"%3\">%4</font></b></font></td>") 
     897                       .arg(color) 
     898                       .arg(contactName)); 
     899      s.append(QString("<td><font color=\"%1\">%2</font></td></tr>") 
     900                      .arg(color) 
     901                      .arg(messageText)); 
     902      break; 
    867903  } 
    868    
    869   append(s); 
    870   if (m_bAppendLineBreak) { 
    871     append("<hr>"); 
     904 
     905  if (m_useBuffer) 
     906  { 
     907    m_buffer.append(s); 
     908    if (m_bAppendLineBreak) 
     909      m_buffer.append("<hr>"); 
    872910  } 
     911  else 
     912  { 
     913    append(s); 
     914    if (m_bAppendLineBreak) 
     915      append("<hr>"); 
     916  } 
    873917} 
    874918 
    875919void CMessageViewWidget::addMsg(CUserEvent* e, const char *_szId, unsigned long _nPPID) 
     
    9881032                  .arg(messageText); 
    9891033      break;  
    9901034 
     1035    case 5: 
     1036      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>") 
     1037                  .arg(color) 
     1038                  .arg(dateTime) 
     1039                  .arg(color) 
     1040                  .arg(messageText); 
     1041      break; 
     1042 
    9911043    case 0: 
    9921044    default: 
    9931045      s = QString("<html><body><font color=\"%1\"><b>[%2] %3</b></font><br></body></html>") 
     
    9971049      break;     
    9981050  } 
    9991051 
    1000   append(s); 
    1001   if (m_bAppendLineBreak) 
    1002     append("<hr>"); 
     1052  if (m_useBuffer) 
     1053  { 
     1054    m_buffer.append(s); 
     1055    if (m_bAppendLineBreak) 
     1056      m_buffer.append("<hr>"); 
     1057  } 
     1058  else 
     1059  { 
     1060    append(s); 
     1061    if (m_bAppendLineBreak) 
     1062      append("<hr>"); 
     1063  } 
    10031064} 
    10041065 
    10051066CLicqMessageBox::CLicqMessageBox(QWidget *parent)