Ticket #1389: licq_1.3.4-rc1_format_date_loki.patch

File licq_1.3.4-rc1_format_date_loki.patch, 10.3 kB (added by Loki (loki@…, 2 years ago)

new "Date Format" option

  • licq-1.3.4-RC1/plugins/qt-gui/src/ewidgets.cpp

     
    752752  m_szId = szId ? strdup(szId) : 0; 
    753753  m_nPPID = nPPID; 
    754754  m_nMsgStyle = m->m_nMsgStyle; 
     755  m_nDateFormat = m->m_nDateFormat; 
    755756  m_bAppendLineBreak = m->m_bAppendLineBreak; 
    756757  m_colorRcv = m->m_colorRcv; 
    757758  m_colorSnt = m->m_colorSnt; 
     
    785786  m_nUin= _nUin; 
    786787  m_szId = NULL; // avoid desalocation error at destructor 
    787788  m_nMsgStyle = m->m_nMsgStyle; 
     789  m_nDateFormat = m->m_nDateFormat; 
    788790  m_bAppendLineBreak = m->m_bAppendLineBreak; 
    789791  m_colorRcv = m->m_colorRcv; 
    790792  m_colorSnt = m->m_colorSnt; 
     
    860862    } 
    861863  } 
    862864      
     865  QString my_date = date.toString( m_nDateFormat ); 
    863866   
    864867  switch (m_nMsgStyle) { 
    865868    case 0: 
    866869      s = QString("<html><body><font color=\"%1\"><b>%2%3 [%4%5%6%7] %8:</b></font><br>") 
    867870                  .arg(color) 
    868871                  .arg(eventDescription) 
    869                   .arg(date.time().toString()) 
     872                  .arg(my_date) 
    870873                  .arg(isDirect ? 'D' : '-') 
    871874                  .arg(isMultiRec ? 'M' : '-') 
    872875                  .arg(isUrgent ? 'U' : '-') 
     
    880883      s = QString("<font color=\"%1\"><b>(%2%3) [%4%5%6%7] %8: </b></font>") 
    881884                  .arg(color) 
    882885                  .arg(eventDescription) 
    883                   .arg(date.time().toString()) 
     886                  .arg(my_date) 
    884887                  .arg(isDirect ? 'D' : '-') 
    885888                  .arg(isMultiRec ? 'M' : '-') 
    886889                  .arg(isUrgent ? 'U' : '-') 
     
    900903      s = QString("<font color=\"%1\"><b>%2%3 - %4: </b></font>") 
    901904                  .arg(color) 
    902905                  .arg(eventDescription) 
    903                   .arg(date.time().toString()) 
     906                  .arg(my_date) 
    904907                  .arg(contactName); 
    905908      s.append(QString("<font color=\"%1\">%2</font>") 
    906909                      .arg(color) 
     
    917920      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>") 
    918921                  .arg(color) 
    919922                  .arg(eventDescription) 
    920                   .arg(date.time().toString()) 
     923                  .arg(my_date) 
    921924                  .arg(color) 
    922925                  .arg(contactName); 
    923926      s.append(QString("<td><font color=\"%1\">%2</font></td></tr></table>") 
     
    930933                  .arg((dir == D_RECEIVER ? tr("%1 from %2") : tr("%1 to %2"))) 
    931934                  .arg(eventDescription) 
    932935                  .arg(contactName) 
    933                   .arg(date.toString()) 
     936                  .arg(my_date) 
    934937                  .arg(isDirect ? 'D' : '-') 
    935938                  .arg(isMultiRec ? 'M' : '-') 
    936939                  .arg(isUrgent ? 'U' : '-') 
     
    955958{ 
    956959  QDateTime date; 
    957960  date.setTime_t(e->Time()); 
    958   QString sd = date.time().toString(); 
     961  QString sd = date.time().toString( m_nDateFormat ); 
    959962  bool bUseHTML = false; 
    960963 
    961964  QString contactName; 
  • ewidgets.h

    old new  
    197197  void addNotice(QString dateTime, QString messageText); 
    198198 
    199199  unsigned short m_nMsgStyle; 
     200  QString m_nDateFormat; 
    200201  bool m_bAppendLineBreak; 
    201202  QColor m_colorRcvHistory; 
    202203  QColor m_colorSntHistory; 
  • mainwin.cpp

    old new  
    452452  licqConf.ReadBool("MsgWinSticky", m_bMsgWinSticky, false); 
    453453  licqConf.ReadBool("SingleLineChatMode", m_bSingleLineChatMode, false); 
    454454  licqConf.ReadBool("CheckSpellingEnabled", m_bCheckSpellingEnabled, false); 
     455  licqConf.ReadStr("DateFormat", szTemp, "yyyy-MM-dd hh:mm:ss"); 
     456  m_nDateFormat = QString::fromLatin1(szTemp); 
     457   
    455458 
    456459  licqConf.ReadStr("ReceiveMessageColor", szTemp, "red"); 
    457460  m_colorRcv = QColor(szTemp); 
     
    36763679  licqConf.WriteStr("TabFontColor", m_colorTab.name()); 
    36773680  licqConf.WriteStr("TabOnTypingColor", m_colorTabTyping.name()); 
    36783681  licqConf.WriteStr("ChatBackground", m_colorChatBkg.name()); 
     3682  licqConf.WriteStr("DateFormat", m_nDateFormat.latin1()); 
    36793683   
    36803684  licqConf.WriteBool("showPopAlias", m_bPopAlias); 
    36813685  licqConf.WriteBool("showPopName", m_bPopName); 
  • mainwin.h

    old new  
    172172  unsigned short m_nSortByStatus, 
    173173                 m_nSortColumn, 
    174174                 m_nMsgStyle; 
     175  QString m_nDateFormat; 
    175176                  
    176177  QColor m_colorRcvHistory, 
    177178         m_colorSntHistory, 
  • optionsdlg.cpp

    old new  
    209209  chkSysBack->setChecked(mainwin->m_bSystemBackground); 
    210210  chkSendFromClipboard->setChecked(mainwin->m_bSendFromClipboard); 
    211211  chkMsgChatView->setChecked(mainwin->m_bMsgChatView); 
     212 
     213  unsigned short int isCustomDate = 1; 
     214  for (int i = 1; i < cmbDateFormat->count(); i++) 
     215  { 
     216    if (cmbDateFormat->text(i) == mainwin->m_nDateFormat) 
     217    { 
     218      cmbDateFormat->setCurrentItem(i); 
     219      isCustomDate = 0; 
     220      break; 
     221    } 
     222  } 
     223 
     224  if (isCustomDate) { 
     225    cmbDateFormat->setEnabled(false); 
     226    chkCustomDateFormat->setChecked(true); 
     227  } 
     228 
     229  customDateFormat->setText(mainwin->m_nDateFormat); 
    212230   
    213231  chkLineBreak->setChecked(mainwin->m_bAppendLineBreak); 
    214232  cmbStyle->setCurrentItem(mainwin->m_nMsgStyle); 
     
    523541  mainwin->m_bMsgChatView = chkMsgChatView->isChecked(); 
    524542  mainwin->m_bAppendLineBreak = chkLineBreak->isChecked(); 
    525543  mainwin->m_nMsgStyle = cmbStyle->currentItem(); 
     544  mainwin->m_nDateFormat = customDateFormat->text(); 
    526545  mainwin->m_colorRcv = btnColorRcv->paletteBackgroundColor(); 
    527546  mainwin->m_colorSnt = btnColorSnt->paletteBackgroundColor(); 
    528547  mainwin->m_colorRcvHistory = btnColorRcvHistory->paletteBackgroundColor(); 
     
    15861605   
    15871606  chkLineBreak = new QCheckBox(tr("Insert Horizontal Line"), boxOptions); 
    15881607  connect(chkLineBreak, SIGNAL(toggled(bool)), this, SLOT(slot_refresh_msgViewer())); 
     1608 
     1609  new QLabel(tr("Date Format:"), boxOptions); 
     1610  cmbDateFormat = new QComboBox(false, boxOptions); 
     1611  cmbDateFormat->insertItem("yyyy-MM-dd hh:mm:ss"); 
     1612  cmbDateFormat->insertItem("yyyy-MM-dd"); 
     1613  cmbDateFormat->insertItem("yyyy/MM/dd hh:mm:ss"); 
     1614  cmbDateFormat->insertItem("yyyy/MM/dd"); 
     1615  connect(cmbDateFormat, SIGNAL(activated(int)), this, SLOT(slot_refresh_msgViewer())); 
     1616 
     1617  chkCustomDateFormat = new QCheckBox(tr("Custom Date Format:"), boxOptions); 
     1618 
     1619  connect(chkCustomDateFormat, SIGNAL(toggled(bool)), this, SLOT(chkCustomDateFormatEnable(bool))); 
     1620 
     1621  QGroupBox* boxCDateFormat = new QGroupBox(2, Horizontal, boxOptions); 
     1622  boxCDateFormat->setFlat(1); 
     1623   
     1624  customDateFormat = new QLineEdit(boxCDateFormat); 
     1625  QWhatsThis::add(customDateFormat, tr( 
     1626 
     1627"Available custom datetime format variables:\n" 
     1628"\n" 
     1629"d      the day as number without a leading zero (1-31)\n" 
     1630"dd     the day as number with a leading zero (01-31)\n" 
     1631"ddd    the abbreviated localized day name (e.g. 'Mon'..'Sun')\n" 
     1632"dddd   the long localized day name (e.g. 'Monday'..'Sunday')\n" 
     1633"M  the month as number without a leading zero (1-12)\n" 
     1634"MM     the month as number with a leading zero (01-12)\n" 
     1635"MMM    the abbreviated localized month name (e.g. 'Jan'..'Dec')\n" 
     1636"MMMM   the long localized month name (e.g. 'January'..'December')\n" 
     1637"yy     the year as two digit number (00-99)\n" 
     1638"yyyy   the year as four digit number (1752-8000)\n" 
     1639"\n" 
     1640"h  the hour without a leading zero (0..23 or 1..12 if AM/PM display)\n" 
     1641"hh     the hour with a leading zero (00..23 or 01..12 if AM/PM display\n"  
     1642"m  the minute without a leading zero (0..59\n"  
     1643"mm     the minute with a leading zero (00..59\n"  
     1644"s  the second whithout a leading zero (0..59)\n" 
     1645"ss     the second whith a leading zero (00..59\n"  
     1646"z  the milliseconds without leading zeroes (0..999)\n" 
     1647"zzz    the milliseconds with leading zeroes (000..999\n"  
     1648"AP     use AM/PM display. AP will be replaced by either 'AM' or 'PM'\n" 
     1649"ap     use am/pm display. ap will be replaced by either 'am' or 'pm'\n" )); 
     1650 
     1651  btnSetCustomDateFormat = new QPushButton(tr("Set"), boxCDateFormat); 
     1652  //btnSaveIt->setFixedWidth(40); 
     1653  connect(btnSetCustomDateFormat, SIGNAL(clicked()), this, SLOT(slot_refresh_msgViewer())); 
    15891654   
    15901655  QGroupBox *boxColors = new QGroupBox(2, Horizontal, tr("Colors"), boxRight); 
    15911656 
     
    16291694  return w; 
    16301695} 
    16311696 
     1697void OptionsDlg::chkCustomDateFormatEnable(bool isOn) 
     1698{ 
     1699  if (isOn) { 
     1700    cmbDateFormat->setEnabled(false); 
     1701    customDateFormat->setEnabled(true); 
     1702    btnSetCustomDateFormat->setEnabled(true); 
     1703  } else { 
     1704    cmbDateFormat->setEnabled(true); 
     1705    customDateFormat->setEnabled(false); 
     1706    btnSetCustomDateFormat->setEnabled(false); 
     1707  } 
     1708} 
     1709 
    16321710void OptionsDlg::slot_refresh_msgViewer() 
    16331711{ 
    16341712  QDateTime date; 
     1713  date.setTime_t(time(TIME_NOW)); 
    16351714  const char *names[2] = {"Marge", "Homer"}; 
    16361715  const char *msgs[7] = { 
    16371716      "This is received message", 
     
    16501729  msgViewer->m_colorRcvHistory = btnColorRcvHistory->paletteBackgroundColor(); 
    16511730  tabViewer->setPaletteForegroundColor(btnColorTypingLabel->paletteBackgroundColor()); 
    16521731  msgViewer->setPaletteBackgroundColor(btnColorChatBkg->paletteBackgroundColor()); 
     1732 
     1733  if (chkCustomDateFormat->isChecked()) { 
     1734    msgViewer->m_nDateFormat = customDateFormat->text(); 
     1735  } else { 
     1736    customDateFormat->setText(cmbDateFormat->currentText()); 
     1737    msgViewer->m_nDateFormat = cmbDateFormat->currentText(); 
     1738  } 
    16531739   
    16541740  msgViewer->clear(); 
    16551741  for (unsigned int i = 0; i<7; i++) 
  • optionsdlg.h

    old new  
    143143   CMessageViewWidget *msgViewer; 
    144144   QTabWidget *tabViewer; 
    145145   QComboBox *cmbStyle; 
     146   QComboBox *cmbDateFormat; 
     147   QCheckBox *chkCustomDateFormat; 
     148   QPushButton *btnSetCustomDateFormat; 
     149   QLineEdit *customDateFormat; 
    146150   QCheckBox *chkLineBreak; 
    147151   CColorOption *btnColorRcv; 
    148152   CColorOption *btnColorSnt; 
     
    167171  virtual void accept(); 
    168172  virtual void reject(); 
    169173  void colEnable(bool); 
     174  void chkCustomDateFormatEnable(bool); 
    170175  void ApplyOptions(); 
    171176  void slot_selectfont(); 
    172177  void slot_selecteditfont();