void MessageBox::show(Exception e, const QString &msg, unsigned icon_type) { deque<Exception> list; deque<Exception>::reverse_iterator itr,itr_end; QTreeWidgetItem *item=NULL,*item1=NULL,*item2=NULL; QLabel *label=NULL; int idx=0; Exception *ex=NULL; QString str_aux, title; QFont font=this->font(); show_errors_txt_tb->blockSignals(true); show_errors_txt_tb->setChecked(false); show_errors_txt_tb->blockSignals(false); exceptions_txt->setPlainText(e.getExceptionsText()); e.getExceptionsList(list); itr=list.rbegin(); itr_end=list.rend(); while(itr!=itr_end) { ex=&(*itr); item=new QTreeWidgetItem; str_aux=QString("[%1] - %2") .arg(idx) .arg(ex->getMethod()); item->setIcon(0,QPixmap(QString(":/icones/icones/funcao.png"))); exceptions_trw->insertTopLevelItem(0,item); label=new QLabel; label->setFont(font); label->setWordWrap(true); label->setText(str_aux); exceptions_trw->setItemWidget(item, 0, label); item1=new QTreeWidgetItem(item); item1->setIcon(0,QPixmap(QString(":/icones/icones/codigofonte.png"))); item1->setText(0,ex->getFile() + " (" + ex->getLine() + ")"); item2=new QTreeWidgetItem(item); item2->setIcon(0,QPixmap(QString(":/icones/icones/msgbox_alerta.png"))); item2->setText(0,Exception::getErrorCode(ex->getErrorType()) + " (" + QString("%1").arg(ex->getErrorType()) + ")"); item1=new QTreeWidgetItem(item); item1->setIcon(0,QPixmap(":/icones/icones/msgbox_erro.png")); label=new QLabel; label->setWordWrap(true); label->setFont(font); label->setStyleSheet("color: #ff0000;"); exceptions_trw->setItemWidget(item1, 0, label); label->setText(ex->getErrorMessage()); if(!ex->getExtraInfo().isEmpty()) { item1=new QTreeWidgetItem(item); item1->setIcon(0,QPixmap(QString(":/icones/icones/msgbox_info.png"))); label=new QLabel; label->setWordWrap(true); label->setFont(font); label->setStyleSheet("color: #000080;"); exceptions_trw->setItemWidget(item1, 0, label); label->setText(ex->getExtraInfo()); } itr++; idx++; } switch(icon_type) { case ERROR_ICON: title=trUtf8("Error"); break; case ALERT_ICON: title=trUtf8("Alert"); break; case INFO_ICON: title=trUtf8("Information"); break; default: title=""; break; } if(msg.isEmpty()) str_aux=e.getErrorMessage(); else str_aux=msg; this->show(title,str_aux,icon_type,OK_BUTTON); }
void Messagebox::show(Exception e, const QString &msg, unsigned icon_type, unsigned buttons, const QString &yes_lbl, const QString &no_lbl, const QString &cancel_lbl, const QString &yes_ico, const QString &no_ico, const QString &cancel_ico) { vector<Exception> list; vector<Exception>::reverse_iterator itr,itr_end; QTreeWidgetItem *item=nullptr,*item1=nullptr,*item2=nullptr; QLabel *label=nullptr; int idx=0; Exception *ex=nullptr; QString str_aux, title; QFont font=this->font(); show_raw_info_tb->blockSignals(true); show_raw_info_tb->setChecked(false); show_raw_info_tb->blockSignals(false); raw_info_txt->setPlainText(e.getExceptionsText()); e.getExceptionsList(list); itr=list.rbegin(); itr_end=list.rend(); while(itr!=itr_end) { ex=&(*itr); item=new QTreeWidgetItem; str_aux=QString("[%1] - %2") .arg(idx) .arg(ex->getMethod()); item->setIcon(0,QPixmap(QString(":/icones/icones/funcao.png"))); exceptions_trw->insertTopLevelItem(0,item); label=new QLabel; label->setFont(font); label->setWordWrap(true); label->setText(str_aux); exceptions_trw->setItemWidget(item, 0, label); item1=new QTreeWidgetItem(item); item1->setIcon(0,QPixmap(QString(":/icones/icones/codigofonte.png"))); item1->setText(0,ex->getFile() + " (" + ex->getLine() + ")"); item2=new QTreeWidgetItem(item); item2->setIcon(0,QPixmap(QString(":/icones/icones/msgbox_alerta.png"))); item2->setText(0,Exception::getErrorCode(ex->getErrorType()) + " (" + QString("%1").arg(ex->getErrorType()) + ")"); item1=new QTreeWidgetItem(item); item1->setIcon(0,QPixmap(":/icones/icones/msgbox_erro.png")); label=new QLabel; label->setWordWrap(true); label->setFont(font); label->setStyleSheet("color: #ff0000;"); exceptions_trw->setItemWidget(item1, 0, label); label->setText(ex->getErrorMessage()); if(!ex->getExtraInfo().isEmpty()) { item1=new QTreeWidgetItem(item); item1->setIcon(0,QPixmap(QString(":/icones/icones/msgbox_info.png"))); label=new QLabel; label->setWordWrap(true); label->setFont(font); label->setStyleSheet("color: #000080;"); label->setTextInteractionFlags(Qt::TextSelectableByMouse); exceptions_trw->setItemWidget(item1, 0, label); label->setText(ex->getExtraInfo()); } itr++; idx++; } switch(icon_type) { case ERROR_ICON: title=trUtf8("Error"); break; case ALERT_ICON: title=trUtf8("Alert"); break; case INFO_ICON: title=trUtf8("Information"); break; default: title=""; break; } if(msg.isEmpty()) str_aux=e.getErrorMessage(); else str_aux=msg; if(str_aux.contains("`") && str_aux.contains("'")) { str_aux.replace("`", "<strong>"); str_aux.replace("\'","</strong>"); str_aux.replace("(", "<em>("); str_aux.replace(")", ")</em>"); } this->show(title, str_aux, icon_type, buttons, yes_lbl, no_lbl, cancel_lbl, yes_ico, no_ico, cancel_ico); }