QTfrontend/ui/widget/chatwidget.cpp
changeset 6229 4c834af76c3b
parent 6227 ce60b734fff1
child 6231 810b9ced2b67
equal deleted inserted replaced
6227:ce60b734fff1 6229:4c834af76c3b
    32 #include <QItemSelectionModel>
    32 #include <QItemSelectionModel>
    33 #include <QStringList>
    33 #include <QStringList>
    34 #include <QDateTime>
    34 #include <QDateTime>
    35 #include <QTime>
    35 #include <QTime>
    36 
    36 
       
    37 #include <QMessageBox>
       
    38 
    37 
    39 
    38 #include "HWDataManager.h"
    40 #include "HWDataManager.h"
    39 #include "hwconsts.h"
    41 #include "hwconsts.h"
    40 #include "gameuiconfig.h"
    42 #include "gameuiconfig.h"
    41 
    43 
   101 }
   103 }
   102 
   104 
   103 QString * HWChatWidget::s_styleSheet = NULL;
   105 QString * HWChatWidget::s_styleSheet = NULL;
   104 QStringList * HWChatWidget::s_displayNone = NULL;
   106 QStringList * HWChatWidget::s_displayNone = NULL;
   105 bool HWChatWidget::s_isTimeStamped = true;
   107 bool HWChatWidget::s_isTimeStamped = true;
       
   108 QString HWChatWidget::s_tsFormat = ":mm:ss";
   106 
   109 
   107 const QString & HWChatWidget::styleSheet()
   110 const QString & HWChatWidget::styleSheet()
   108 {
   111 {
   109     if (s_styleSheet != NULL)
   112     if (s_styleSheet != NULL)
   110         return *s_styleSheet;
   113         return *s_styleSheet;
   171     // matches class names that are referenced without hierachy
   174     // matches class names that are referenced without hierachy
   172     QRegExp nohierarchy("^.[^ .]+$");
   175     QRegExp nohierarchy("^.[^ .]+$");
   173 
   176 
   174     QStringList victims = QString(style).
   177     QStringList victims = QString(style).
   175                                 remove(displayed). // remove visible stuff
   178                                 remove(displayed). // remove visible stuff
       
   179                                 trimmed().
   176                                 split(split). // get a list of the names
   180                                 split(split). // get a list of the names
   177                                 filter(nohierarchy). // only direct class names
   181                                 filter(nohierarchy). // only direct class names
   178                                 replaceInStrings(QRegExp("^."),""); // crop .
   182                                 replaceInStrings(QRegExp("^."),""); // crop .
   179 
   183 
   180 
   184 
   181     if (victims.contains("timestamp"))
   185     if (victims.contains("timestamp"))
   182     {
   186     {
   183         s_isTimeStamped = false;
   187         s_isTimeStamped = false;
   184         victims.removeAll("timestamp");
   188         victims.removeAll("timestamp");
   185     }
   189     }
       
   190     else
       
   191     {
       
   192         s_isTimeStamped = true;
       
   193         s_tsFormat =
       
   194             ((victims.contains("timestamp:hours"))?"":"hh") +
       
   195             QString(":mm:") +
       
   196             ((victims.contains("timestamp:seconds"))?"":"ss");
       
   197     }
       
   198 
       
   199     victims.removeAll("timestamp:hours");
       
   200     victims.removeAll("timestamp:seconds");
   186 
   201 
   187     victims.removeDuplicates();
   202     victims.removeDuplicates();
   188 
   203 
   189     QStringList * oldDisplayNone = s_displayNone;
   204     QStringList * oldDisplayNone = s_displayNone;
   190     QString * oldStyleSheet = s_styleSheet;
   205     QString * oldStyleSheet = s_styleSheet;
   538     }
   553     }
   539 
   554 
   540     bool isHL = false;
   555     bool isHL = false;
   541 
   556 
   542     if ((c != 3) && (!nick.isEmpty()) &&
   557     if ((c != 3) && (!nick.isEmpty()) &&
   543         (nick != m_userNick) && (m_userNick.isEmpty()))
   558         (nick != m_userNick) && (!m_userNick.isEmpty()))
   544     {
   559     {
   545         QString lcStr = str.toLower();
   560         QString lcStr = str.toLower();
   546 
   561 
   547         foreach (const QRegExp & hl, m_highlights)
   562         foreach (const QRegExp & hl, m_highlights)
   548         {
   563         {
   567 
   582 
   568     if (s_isTimeStamped)
   583     if (s_isTimeStamped)
   569     {
   584     {
   570         QString tsMarkUp = "<span class=\"timestamp\">[%1]</span> ";
   585         QString tsMarkUp = "<span class=\"timestamp\">[%1]</span> ";
   571         QTime now = QDateTime::currentDateTime().time();
   586         QTime now = QDateTime::currentDateTime().time();
   572         line = tsMarkUp.arg(now.toString(":mm:ss")) + line;
   587         line = tsMarkUp.arg(now.toString(s_tsFormat)) + line;
   573     }
   588     }
   574 
   589 
   575     line = QString("<span class=\"%1\">%2</span>").arg(cssClass).arg(line);
   590     line = QString("<span class=\"%1\">%2</span>").arg(cssClass).arg(line);
   576 
   591 
   577     if (isHighlight)
   592     if (isHighlight)