Changeset 6118

Show
Ignore:
Timestamp:
03/29/08 04:35:22 (8 months ago)
Author:
flynd
Message:

Updated variable and function names to conform better with coding style. Replaced MessageManager? with static function in MessageBox?. Rewrote dialog extension to not use obsolete functions.

Location:
trunk/qt4-gui/src/core
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt4-gui/src/core/messagebox.cpp

    r6048 r6118  
    2222 
    2323#include "config.h" 
    24  
    25 #include <algorithm> 
    26 #include <ctype.h> 
    27 #include <stdio.h> 
    2824 
    2925#include <QHBoxLayout> 
     
    4844/*! \brief Dialog with configurable yes/no buttons 
    4945 * 
    50  * In it's easiest form, this dialog displays szQuery and the buttons szBtn1 and szBtn2. 
    51  * szBtn1 means true/yes, 
    52  * szBtn2 means false/no. 
     46 * In it's easiest form, this dialog displays query and the buttons button1 and button2. 
     47 * button1 means true/yes, 
     48 * button2 means false/no. 
    5349 * 
    5450 * When bConfirmYes is true, then a second dialog asks the user to confirm his positive 
     
    5854 * decision, the displayed confirmation message is passed using the QString szConfirmNo. 
    5955 */ 
    60 bool LicqQtGui::QueryUser(QWidget* q, QString szQuery, QString szBtn1, QString szBtn2, 
    61     bool bConfirmYes, QString szConfirmYes, bool bConfirmNo, QString szConfirmNo) 
     56bool LicqQtGui::QueryUser(QWidget* parent, QString query, QString button1, QString button2, 
     57    bool confirmYes, QString confirmYesText, bool confirmNo, QString confirmNoText) 
    6258{ 
    6359  bool result; 
    6460 
    6561#ifdef USE_KDE 
    66   result = (KMessageBox::questionYesNo(q, szQuery, QMessageBox::tr("Licq Question"), 
    67         KGuiItem(szBtn1), KGuiItem(szBtn2)) == KMessageBox::Yes); 
     62  result = (KMessageBox::questionYesNo(parent, query, QMessageBox::tr("Licq Question"), 
     63        KGuiItem(button1), KGuiItem(button2)) == KMessageBox::Yes); 
    6864  // The user must confirm his decision! 
    69   if (result == true && bConfirmYes && !szConfirmYes.isEmpty()) 
    70     result = (KMessageBox::questionYesNo(q, szConfirmYes, 
     65  if (result == true && confirmYes && !confirmYesText.isEmpty()) 
     66    result = (KMessageBox::questionYesNo(parent, confirmYesText, 
    7167          QMessageBox::tr("Licq Question")) == KMessageBox::Yes); 
    72   else if (result == false && bConfirmNo && !szConfirmNo.isEmpty()) 
    73     result = (KMessageBox::questionYesNo(q, szConfirmNo, 
     68  else if (result == false && confirmNo && !confirmNoText.isEmpty()) 
     69    result = (KMessageBox::questionYesNo(parent, confirmNoText, 
    7470          QMessageBox::tr("Licq Question")) == KMessageBox::Yes); 
    7571#else 
    76   result = (QMessageBox::question(q, QMessageBox::tr("Licq Question"), szQuery, 
    77         szBtn1, szBtn2) == 0); 
     72  result = (QMessageBox::question(parent, QMessageBox::tr("Licq Question"), query, 
     73        button1, button2) == 0); 
    7874  // The user must confirm his decision! 
    79   if (result == true && bConfirmYes && !szConfirmYes.isEmpty()) 
    80     result = (QMessageBox::question(q, QMessageBox::tr("Licq Question"), szConfirmYes, 
     75  if (result == true && confirmYes && !confirmYesText.isEmpty()) 
     76    result = (QMessageBox::question(parent, QMessageBox::tr("Licq Question"), confirmYesText, 
    8177          QMessageBox::tr("Yes"), QMessageBox::tr("No")) == 0); 
    82   else if (result == false && bConfirmNo && !szConfirmNo.isEmpty()) 
    83     result = (QMessageBox::question(q, QMessageBox::tr("Licq Question"), szConfirmNo, 
     78  else if (result == false && confirmNo && !confirmNoText.isEmpty()) 
     79    result = (QMessageBox::question(parent, QMessageBox::tr("Licq Question"), confirmNoText, 
    8480          QMessageBox::tr("Yes"), QMessageBox::tr("No")) == 0); 
    8581#endif 
     
    8884} 
    8985 
    90 int LicqQtGui::QueryUser(QWidget* q, QString szQuery, QString szBtn1, QString szBtn2, QString szBtn3) 
    91 { 
    92   return ( QMessageBox::question(q, QMessageBox::tr("Licq Question"), szQuery, szBtn1, szBtn2, szBtn3)); 
     86int LicqQtGui::QueryUser(QWidget* parent, QString query, QString button1, QString button2, QString button3) 
     87{ 
     88  return ( QMessageBox::question(parent, QMessageBox::tr("Licq Question"), query, button1, button2, button3)); 
    9389} 
    9490 
     
    9894} 
    9995 
    100  
    101 void LicqQtGui::InformUser(QWidget* q, QString sz) 
    102 { 
    103   MessageManager::Instance()->addMessage(QMessageBox::Information, sz, q); 
    104 } 
    105  
    106 void LicqQtGui::WarnUser(QWidget* q, QString sz) 
    107 { 
    108   MessageManager::Instance()->addMessage(QMessageBox::Warning, sz, q); 
    109 } 
    110  
    111 void LicqQtGui::CriticalUser(QWidget* q, QString sz) 
    112 { 
    113   MessageManager::Instance()->addMessage(QMessageBox::Critical, sz, q); 
     96void LicqQtGui::InformUser(QWidget* parent, QString text) 
     97{ 
     98  MessageBox::addMessage(QMessageBox::Information, text, parent); 
     99} 
     100 
     101void LicqQtGui::WarnUser(QWidget* parent, QString text) 
     102{ 
     103  MessageBox::addMessage(QMessageBox::Warning, text, parent); 
     104} 
     105 
     106void LicqQtGui::CriticalUser(QWidget* parent, QString text) 
     107{ 
     108  MessageBox::addMessage(QMessageBox::Critical, text, parent); 
    114109} 
    115110 
     
    117112 
    118113MessageBox::MessageBox(QWidget* parent) 
    119   : QDialog(parent, Qt::Dialog), m_nUnreadNum(0) 
     114  : QDialog(parent, Qt::Dialog), myUnreadCount(0) 
    120115{ 
    121116  setModal(true); 
     
    127122  QMessageBox::Icon type = QMessageBox::Information; 
    128123 
    129   QVBoxLayout* topLay = new QVBoxLayout(this); 
     124  QVBoxLayout* topLayout = new QVBoxLayout(this); 
    130125 
    131126  // Make the first horizontal layout for the icon and message 
    132   QFrame* frmMessage = new QFrame(); 
    133   QHBoxLayout* lay = new QHBoxLayout(frmMessage); 
    134   m_lblIcon = new QLabel(); 
     127  QHBoxLayout* messageLayout = new QHBoxLayout(); 
     128  myIconLabel = new QLabel(); 
    135129  QPixmap icon = getMessageIcon(type); 
    136   m_lblIcon->setPixmap(icon); 
    137   m_lblMessage = new QLabel(msg); 
    138  
    139   lay->addWidget(m_lblIcon, 0, Qt::AlignCenter); 
    140   lay->addWidget(m_lblMessage); 
     130  myIconLabel->setPixmap(icon); 
     131  myMessageLabel = new QLabel(msg); 
     132 
     133  messageLayout->addStretch(1); 
     134  messageLayout->addWidget(myIconLabel); 
     135  messageLayout->addWidget(myMessageLabel); 
     136  messageLayout->addStretch(1); 
    141137 
    142138  // Make the list box of all the pending messages, starts out hidden 
    143   m_frmList = new QFrame(); 
    144   QHBoxLayout* layList = new QHBoxLayout(m_frmList); 
    145   m_lstMsg = new QListWidget(); 
    146   m_lstMsg->setFixedHeight(100); // This seems to be a good height 
    147   layList->addWidget(m_lstMsg); 
    148   // Add this listbox as an extension to the dialog, and make it shown at the 
    149   // bottom part of the dialog. 
    150   setOrientation(Qt::Vertical); 
    151   setExtension(m_frmList); 
     139  myExtension = new QWidget(); 
     140  myExtension->hide(); 
     141  QHBoxLayout* listLayout = new QHBoxLayout(myExtension); 
     142  listLayout->setMargin(0); 
     143  myMessageList = new QListWidget(); 
     144  myMessageList->setFixedHeight(100); // This seems to be a good height 
     145  listLayout->addWidget(myMessageList); 
    152146 
    153147  // Make the second horizontal layout for the buttons 
    154   QFrame* frmButtons = new QFrame(); 
    155   QHBoxLayout* lay2 = new QHBoxLayout(frmButtons); 
    156   m_btnMore = new QPushButton(tr("&List")); 
    157   //m_btnMore->setDisabled(true); 
    158   m_btnNext = new QPushButton(tr("&Next")); 
    159   m_btnNext->setDisabled(true); 
    160   m_btnClear = new QPushButton(tr("&Ok")); 
    161   m_btnClear->setDefault(true); 
    162  
    163   lay2->addWidget(m_btnMore); 
    164   lay2->addWidget(m_btnNext); 
    165   lay2->addWidget(m_btnClear); 
    166  
    167   topLay->addWidget(frmMessage, 0, Qt::AlignCenter); 
    168   topLay->addWidget(frmButtons, 0, Qt::AlignCenter); 
     148  QHBoxLayout* buttonsLayout = new QHBoxLayout(); 
     149  myMoreButton = new QPushButton(tr("&List")); 
     150  myMoreButton->setCheckable(true); 
     151  //myMoreButton->setDisabled(true); 
     152  myNextButton = new QPushButton(tr("&Next")); 
     153  myNextButton->setDisabled(true); 
     154  myCloseButton = new QPushButton(tr("&Ok")); 
     155  myCloseButton->setDefault(true); 
     156 
     157  buttonsLayout->addStretch(1); 
     158  buttonsLayout->addWidget(myMoreButton); 
     159  buttonsLayout->addWidget(myNextButton); 
     160  buttonsLayout->addWidget(myCloseButton); 
     161  buttonsLayout->addStretch(1); 
     162 
     163  topLayout->addLayout(messageLayout); 
     164  topLayout->addLayout(buttonsLayout); 
     165  topLayout->addWidget(myExtension); 
    169166 
    170167  // Connect all the signals here 
    171   connect(m_btnMore, SIGNAL(clicked()), SLOT(slot_toggleMore())); 
    172   connect(m_btnNext, SIGNAL(clicked()), SLOT(slot_clickNext())); 
    173   connect(m_btnClear, SIGNAL(clicked()), SLOT(slot_clickClear())); 
    174   connect(m_lstMsg, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), 
    175       SLOT(slot_listChanged(QListWidgetItem*, QListWidgetItem*))); 
     168  connect(myMoreButton, SIGNAL(toggled(bool)), myExtension, SLOT(setVisible(bool))); 
     169  connect(myNextButton, SIGNAL(clicked()), SLOT(showNext())); 
     170  connect(myCloseButton, SIGNAL(clicked()), SLOT(closeDialog())); 
     171  connect(myMessageList, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), 
     172      SLOT(updateCurrentMessage(QListWidgetItem*, QListWidgetItem*))); 
    176173 
    177174  show(); 
     175} 
     176 
     177MessageBox::~MessageBox() 
     178{ 
     179  myMessageDialog = NULL; 
    178180} 
    179181 
     
    188190  // If we have only one message in queue, show that one, otherwise update 
    189191  // the number of pending messages. 
    190   if (m_lstMsg->count() == 0) 
    191   { 
    192     m_lblIcon->setPixmap(pix); 
    193     m_lblMessage->setText(msg); 
    194     m_btnNext->setText(tr("&Next")); 
    195     m_btnNext->setEnabled(false); 
    196     m_btnMore->setEnabled(false); 
    197     m_btnNext->hide(); 
    198     m_btnMore->hide(); 
    199     m_btnClear->setText(tr("&Ok")); 
    200     showExtension(false); // We are opening the window, so default to not showing this 
     192  if (myMessageList->count() == 0) 
     193  { 
     194    myIconLabel->setPixmap(pix); 
     195    myMessageLabel->setText(msg); 
     196    myNextButton->setText(tr("&Next")); 
     197    myNextButton->setEnabled(false); 
     198    myMoreButton->setEnabled(false); 
     199    myNextButton->hide(); 
     200    myMoreButton->hide(); 
     201    myCloseButton->setText(tr("&Ok")); 
    201202  } 
    202203  else 
    203204  { 
    204     m_nUnreadNum++; 
     205    myUnreadCount++; 
    205206    unread = true; // It is unread 
    206     m_btnClear->setText(tr("&Clear All")); 
    207     QString nextStr = QString(tr("&Next (%1)")).arg(m_nUnreadNum); 
    208     m_btnNext->setText(nextStr); 
    209     if (!m_btnNext->isEnabled()) 
     207    myCloseButton->setText(tr("&Clear All")); 
     208    QString nextStr = QString(tr("&Next (%1)")).arg(myUnreadCount); 
     209    myNextButton->setText(nextStr); 
     210    if (!myNextButton->isEnabled()) 
    210211    { 
    211       m_btnNext->setEnabled(true); 
    212       m_btnNext->show(); 
     212      myNextButton->setEnabled(true); 
     213      myNextButton->show(); 
    213214    } 
    214     if (!m_btnMore->isEnabled()) 
     215    if (!myMoreButton->isEnabled()) 
    215216    { 
    216       m_btnMore->setEnabled(true); 
    217       m_btnMore->show(); 
     217      myMoreButton->setEnabled(true); 
     218      myMoreButton->show(); 
    218219    } 
    219220  } 
    220221 
    221   MessageBoxItem* pEntry = new MessageBoxItem(); 
     222  MessageBoxItem* entry = new MessageBoxItem(); 
    222223  // Resize the icon 
    223224  img = pix.toImage(); 
     
    228229  QPixmap scaledPix(QPixmap::fromImage(img)); 
    229230  // Add the columns now 
    230   pEntry->setIcon(scaledPix); 
    231   pEntry->setText(msg.left(qMin(50, msg.indexOf('\n')))); // Put this in setMessage() 
     231  entry->setIcon(scaledPix); 
     232  entry->setText(msg.left(qMin(50, msg.indexOf('\n')))); // Put this in setMessage() 
    232233  // Set the special data 
    233   pEntry->setMessage(msg); 
    234   pEntry->setFullIcon(pix); 
    235   pEntry->setUnread(unread); 
    236   pEntry->setType(type); 
    237  
    238   m_lstMsg->insertItem(0, pEntry); 
     234  entry->setMessage(msg); 
     235  entry->setFullIcon(pix); 
     236  entry->setUnread(unread); 
     237  entry->setType(type); 
     238 
     239  myMessageList->insertItem(0, entry); 
    239240 
    240241  // Set the caption if we set the text and icon here 
    241   if (m_nUnreadNum == 0) 
    242     updateCaption(pEntry); 
    243 } 
    244  
    245 /// //////////////////////////////////////////////////////// 
    246 /// @brief Toggline the detailed list view 
    247 /// 
    248 /// When the more button is clicked, toggle showing the list view of 
    249 /// pending messages. When we hide the list view, we need to show the 
    250 /// oldest unread message. 
    251 /// //////////////////////////////////////////////////////// 
    252 void MessageBox::slot_toggleMore() 
    253 { 
    254   showExtension(m_frmList->isHidden()); 
     242  if (myUnreadCount == 0) 
     243    updateCaption(entry); 
    255244} 
    256245 
     
    261250/// unread message. The text and icon will both be updated. 
    262251/// //////////////////////////////////////////////////////// 
    263 void MessageBox::slot_clickNext() 
     252void MessageBox::showNext() 
    264253{ 
    265254  // Find the next unread message 
    266   bool bFound = false; 
     255  bool found = false; 
    267256  MessageBoxItem* item = 0; 
    268   for (int i = m_lstMsg->currentRow(); i >= 0; --i) 
    269   { 
    270     item = dynamic_cast<MessageBoxItem*>(m_lstMsg->item(i)); 
     257  for (int i = myMessageList->currentRow(); i >= 0; --i) 
     258  { 
     259    item = dynamic_cast<MessageBoxItem*>(myMessageList->item(i)); 
    271260    if (item->isUnread()) 
    272261    { 
    273       bFound = true; 
     262      found = true; 
    274263      break; 
    275264    } 
     
    277266 
    278267  // If no unread item was found, search from the bottom 
    279   if (!bFound) 
    280   { 
    281     for (int i = m_lstMsg->count() - 1; i >= 0; --i) 
     268  if (!found) 
     269  { 
     270    for (int i = myMessageList->count() - 1; i >= 0; --i) 
    282271    { 
    283       item = dynamic_cast<MessageBoxItem*>(m_lstMsg->item(i)); 
     272      item = dynamic_cast<MessageBoxItem*>(myMessageList->item(i)); 
    284273      if (item->isUnread()) 
    285274      { 
    286         bFound = true; 
     275        found = true; 
    287276        break; 
    288277      } 
     
    291280 
    292281  // Only change the item if there something to change it to 
    293   if (bFound) 
    294     m_lstMsg->setCurrentItem(item); 
     282  if (found) 
     283    myMessageList->setCurrentItem(item); 
    295284} 
    296285 
     
    301290/// remove all messages from the queue. 
    302291/// //////////////////////////////////////////////////////// 
    303 void MessageBox::slot_clickClear() 
     292void MessageBox::closeDialog() 
    304293{ 
    305294  // Hide the window first 
     
    307296 
    308297  // Remove all items that have been read 
    309   m_lstMsg->clear(); 
    310   m_nUnreadNum = 0; 
     298  myMessageList->clear(); 
     299  myUnreadCount = 0; 
    311300} 
    312301 
     
    320309/// @param previous The QListWidgetItem* that has been selected prior 
    321310/// //////////////////////////////////////////////////////// 
    322 void MessageBox::slot_listChanged(QListWidgetItem* i, QListWidgetItem* /* previous */) 
     311void MessageBox::updateCurrentMessage(QListWidgetItem* i, QListWidgetItem* /* previous */) 
    323312{ 
    324313  // Change the icon, message and caption 
     
    326315  if (item != NULL) 
    327316  { 
    328     m_lblIcon->setPixmap(item->getFullIcon()); 
    329     m_lblMessage->setText(item->getMessage()); 
     317    myIconLabel->setPixmap(item->getFullIcon()); 
     318    myMessageLabel->setText(item->getMessage()); 
    330319    updateCaption(item); 
    331320 
     
    333322    if (item->isUnread()) 
    334323    { 
    335       m_nUnreadNum--; 
     324      myUnreadCount--; 
    336325      item->setUnread(false); 
    337326    } 
     
    340329  // Update the next button 
    341330  QString nextStr; 
    342   if (m_nUnreadNum > 0) 
    343     nextStr = QString(tr("&Next (%1)")).arg(m_nUnreadNum); 
     331  if (myUnreadCount > 0) 
     332    nextStr = QString(tr("&Next (%1)")).arg(myUnreadCount); 
    344333  else 
    345334  { 
    346335    // No more unread messages 
    347336    nextStr = QString(tr("&Next")); 
    348     m_btnNext->setEnabled(false); 
    349     m_nUnreadNum = 0; 
    350   } 
    351   m_btnNext->setText(nextStr); 
     337    myNextButton->setEnabled(false); 
     338    myUnreadCount = 0; 
     339  } 
     340  myNextButton->setText(nextStr); 
    352341} 
    353342 
     
    362351    return; 
    363352 
    364   QString strCaption; 
     353  QString caption; 
    365354  switch (item->getType()) 
    366355  { 
    367356    case QMessageBox::Information: 
    368       strCaption = tr("Licq Information"); 
     357      caption = tr("Licq Information"); 
    369358      break; 
    370359 
    371360    case QMessageBox::Warning: 
    372       strCaption = tr("Licq Warning"); 
     361      caption = tr("Licq Warning"); 
    373362      break; 
    374363 
    375364    case QMessageBox::Critical: 
    376       strCaption = tr("Licq Critical"); 
     365      caption = tr("Licq Critical"); 
    377366      break; 
    378367 
     
    380369    case QMessageBox::Question: 
    381370    default: 
    382       strCaption = tr("Licq"); 
    383       break; 
    384   } 
    385   setWindowTitle(strCaption); 
     371      caption = tr("Licq"); 
     372      break; 
     373  } 
     374  setWindowTitle(caption); 
    386375} 
    387376 
     
    419408} 
    420409 
    421 MessageManager* MessageManager::m_pInstance = 0; 
    422  
    423 MessageManager::MessageManager() 
    424   : m_pMsgDlg(0) 
    425 { 
    426 } 
    427  
    428 MessageManager::~MessageManager() 
    429 { 
    430   if (m_pMsgDlg) 
    431     delete m_pMsgDlg; 
    432 } 
    433  
    434 MessageManager* MessageManager::Instance() 
    435 { 
    436   if (m_pInstance == 0) 
    437     m_pInstance = new MessageManager; 
    438  
    439   return m_pInstance; 
    440 } 
    441  
    442 void MessageManager::addMessage(QMessageBox::Icon type, const QString& msg, 
     410MessageBox* MessageBox::myMessageDialog = 0; 
     411 
     412void MessageBox::addMessage(QMessageBox::Icon type, const QString& msg, 
    443413  QWidget* parent) 
    444414{ 
    445415  // We should pass parent to it, but it causes a crash after the parent closes 
    446   // and we try to show another message box. I tried to reparent m_pMsgDlg, but 
     416  // and we try to show another message box. I tried to reparent myMessageDialog, but 
    447417  // that didnt help much. 
    448418  // So for now.. we do this: 
    449419  parent = 0; // XXX See comment above 
    450   if (m_pMsgDlg == 0) 
    451     m_pMsgDlg = new MessageBox(parent); 
    452  
    453   m_pMsgDlg->addMessage(type, msg); 
    454   m_pMsgDlg->show(); 
     420  if (myMessageDialog == 0) 
     421    myMessageDialog = new MessageBox(parent); 
     422 
     423  myMessageDialog->addMessage(type, msg); 
     424  myMessageDialog->show(); 
    455425} 
    456426 
     
    458428  : QListWidgetItem(parent) 
    459429{ 
    460   m_unread = false; 
    461 } 
    462  
    463 void MessageBoxItem::setUnread(bool b) 
    464 { 
    465   m_unread = b; 
    466   if (m_unread) 
     430  myUnread = false; 
     431} 
     432 
     433void MessageBoxItem::setUnread(bool unread) 
     434{ 
     435  myUnread = unread; 
     436  if (myUnread) 
    467437    setForeground(Qt::red); 
    468438  else 
  • trunk/qt4-gui/src/core/messagebox.h

    r5837 r6118  
    3434namespace LicqQtGui 
    3535{ 
    36 bool QueryUser(QWidget*, QString, QString, QString, bool bConfirmYes=false, 
    37     QString szConfirm=NULL, bool bConfirmNo=false, QString szConfirmNo=NULL); 
    38 int QueryUser(QWidget*, QString, QString, QString, QString); 
     36bool QueryUser(QWidget* q, QString query, QString button1, QString button2, 
     37    bool confirmYes = false, QString confirmYesText = NULL, 
     38    bool confirmNo = false, QString confirmNoText = NULL); 
     39int QueryUser(QWidget* parent, QString query, QString button1, QString button2, 
     40    QString button3); 
    3941bool QueryYesNo(QWidget* parent, QString query); 
    40 void InformUser(QWidget* q, QString); 
    41 void WarnUser(QWidget* q, QString szInfo); 
    42 void CriticalUser(QWidget* q, QString szInfo); 
     42void InformUser(QWidget* parent, QString text); 
     43void WarnUser(QWidget* parent, QString text); 
     44void CriticalUser(QWidget* parent, QString text); 
     45 
    4346 
    4447class MessageBoxItem : public QListWidgetItem 
     
    4750  MessageBoxItem(QListWidget* parent = 0); 
    4851 
    49   void setMessage(const QString& s) { m_msg = s; } 
    50   void setFullIcon(const QPixmap& p) { m_fullIcon = p; } 
    51   void setUnread(bool b); 
    52   void setType(QMessageBox::Icon t) { m_type = t; } 
     52  void setMessage(const QString& s) { myMessage = s; } 
     53  void setFullIcon(const QPixmap& p) { myFullIcon = p; } 
     54  void setUnread(bool unread); 
     55  void setType(QMessageBox::Icon t) { myType = t; } 
    5356 
    54   QString getMessage() const { return m_msg; } 
    55   QPixmap getFullIcon() const { return m_fullIcon; } 
    56   bool isUnread() const { return m_unread; } 
    57   QMessageBox::Icon getType() const { return m_type; } 
     57  QString getMessage() const { return myMessage; } 
     58  QPixmap getFullIcon() const { return myFullIcon; } 
     59  bool isUnread() const { return myUnread; } 
     60  QMessageBox::Icon getType() const { return myType; } 
    5861 
    5962private: 
    60   QString m_msg; 
    61   QPixmap m_fullIcon; 
    62   bool m_unread; 
    63   QMessageBox::Icon m_type; 
     63  QString myMessage; 
     64  QPixmap myFullIcon; 
     65  bool myUnread; 
     66  QMessageBox::Icon myType; 
    6467}; 
    6568 
     
    6871  Q_OBJECT 
    6972public: 
     73  static void addMessage(QMessageBox::Icon type, const QString& msg, QWidget* p); 
     74 
     75public slots: 
     76  void showNext(); 
     77  void closeDialog(); 
     78  void updateCurrentMessage(QListWidgetItem* current, QListWidgetItem* previous); 
     79 
     80private: 
    7081  MessageBox(QWidget* parent = 0); 
     82  ~MessageBox(); 
    7183  void addMessage(QMessageBox::Icon type, const QString& msg); 
    7284 
    73 public slots: 
    74   void slot_toggleMore(); 
    75   void slot_clickNext(); 
    76   void slot_clickClear(); 
    77   void slot_listChanged(QListWidgetItem* current, QListWidgetItem* previous); 
    78  
    79 private: 
    8085  QPixmap getMessageIcon(QMessageBox::Icon); 
    8186  void updateCaption(MessageBoxItem*); 
    8287 
    83   int m_nUnreadNum; 
    84   QLabel* m_lblIcon; 
    85   QLabel* m_lblMessage; 
    86   QPushButton* m_btnNext; 
    87   QPushButton* m_btnMore; 
    88   QPushButton* m_btnClear; 
    89   QListWidget* m_lstMsg; 
    90   QFrame* m_frmList; 
    91 }; 
     88  static MessageBox* myMessageDialog; 
    9289 
    93 class MessageManager 
    94 { 
    95 public: 
    96   ~MessageManager(); 
    97  
    98   static MessageManager* Instance(); 
    99  
    100   void addMessage(QMessageBox::Icon type, const QString& msg, QWidget* p); 
    101  
    102 private: 
    103   MessageManager(); 
    104   MessageManager(const MessageManager&); 
    105   MessageManager& operator=(const MessageManager&); 
    106  
    107   static MessageManager* m_pInstance; 
    108   MessageBox* m_pMsgDlg; 
     90  int myUnreadCount; 
     91  QLabel* myIconLabel; 
     92  QLabel* myMessageLabel; 
     93  QPushButton* myNextButton; 
     94  QPushButton* myMoreButton; 
     95  QPushButton* myCloseButton; 
     96  QListWidget* myMessageList; 
     97  QWidget* myExtension; 
    10998}; 
    11099