//Actions for the buttons void DocumentWidget::createActions() { connect(m_closeButton, SIGNAL(clicked()), this, SLOT(closeFile())); connect(m_reviewButton, SIGNAL(clicked()), this, SLOT(showReview())); connect(m_hideReview, SIGNAL(clicked()), this, SLOT(hideReview())); connect(m_submitReview, SIGNAL(clicked()), this, SLOT(submitReview())); connect(m_slider, SIGNAL(valueChanged(int)), m_box, SLOT(setValue(int))); connect(m_box, SIGNAL(valueChanged(int)), m_slider, SLOT(setValue(int))); connect(m_reportButton, SIGNAL(clicked()), this, SLOT(showReport())); connect(m_clearReport, SIGNAL(clicked()), this, SLOT(clearReport())); connect(m_hideReport, SIGNAL(clicked()), this, SLOT(hideReport())); connect(m_submitReport, SIGNAL(clicked()), this, SLOT(submitReport())); connect(m_timer, SIGNAL(timeout()), this, SLOT(s_counter())); connect(m_timer, SIGNAL(timeout()), m_parent, SLOT(s_updateCredit())); connect(m_clearReview, SIGNAL(clicked()), this, SLOT(clearReview())); connect(m_searchButton, SIGNAL(clicked()), this, SLOT(s_search())); }
void deliverEmail::sSubmit() { if (_to->text().isEmpty()) { QMessageBox::critical( this, tr("Cannot Email for Delivery"), tr("You must enter a email address to which this message is to be delivered.") ); _to->setFocus(); return; } if (_reportName.isEmpty()) submitEmail(this, _from->text(), _to->text(), _cc->text(), _subject->text(), _body->toPlainText(), _emailHTML->isChecked()); else submitReport(this, _reportName, _filename->text(), _from->text(), _to->text(), _cc->text(), _subject->text(), _body->toPlainText(), _emailHTML->isChecked(), _reportParams); if (_captive) accept(); else { _submit->setEnabled(FALSE); _close->setText(tr("&Close")); _to->clear(); _cc->clear(); _body->clear(); _subject->clear(); _filename->clear(); } }
bool deliverEmail::profileEmail(QWidget *parent, int profileid, ParameterList &pParams, ParameterList &rptParams) { if (!profileid) return false; QVariant param; bool valid; bool preview = false; QString reportName; QString fileName; //Token variables int docid = 0; QString comments; QString descrip; QString docnumber; QString doctype; QString docbody; QString email1; QString email2; QString email3; //Email variables QString from; QString to; QString cc; QString subject; QString body; //Process parameters param = pParams.value("preview", &valid); if (valid) preview = param.toBool(); param = pParams.value("reportName", &valid); if (valid) reportName = param.toString(); param = pParams.value("fileName", &valid); if (valid) fileName = param.toString(); param = pParams.value("description", &valid); if (valid) descrip = param.toString(); param = pParams.value("docid", &valid); if (valid) docid = param.toInt(); param = pParams.value("docbody", &valid); if (valid) docbody = param.toString(); param = pParams.value("docnumber", &valid); if (valid) docnumber = param.toString(); param = pParams.value("doctype", &valid); if (valid) doctype = param.toString(); param = pParams.value("email1", &valid); if (valid) email1 = param.toString(); param = pParams.value("email2", &valid); if (valid) email2 = param.toString(); param = pParams.value("email3", &valid); if (valid) email3 = param.toString(); //Get user email q.exec( "SELECT usr_email " "FROM usr " "WHERE (usr_username=CURRENT_USER);" ); if (q.first()) from=q.value("usr_email").toString(); //Process profile q.prepare( "SELECT ediprofile_option1 AS emailto, " " ediprofile_option4 AS emailcc, " " ediprofile_option2 AS subject, " " ediprofile_option3 AS body, " " ediprofile_emailhtml " "FROM ediprofile " "WHERE ( (ediprofile_id=:ediprofile_id) " " AND (ediprofile_type='email') );" ); q.bindValue(":ediprofile_id", profileid); q.exec(); if (q.first()) { to=q.value("emailto").toString(); cc=q.value("emailcc").toString(); body=QString(q.value("body").toString() .replace("</description>" , descrip) .replace("</docnumber>" , docnumber) .replace("</doctype>" , doctype) .replace("</docbody>" , docbody)); subject=QString(q.value("subject").toString() .replace("</description>" , descrip) .replace("</docnumber>" , docnumber) .replace("</doctype>" , doctype) .replace("</docbody>" , docbody)); //Handle E-mail //Don't send messages to myself if (email1 == to) email1 = QString::null; if (email2 == from) email2 = QString::null; if (email3 == from) email3 = QString::null; //Add token addresses to "To" list if applicable if ((email1.isEmpty()) || (to.count(email1,Qt::CaseInsensitive))) to=to.remove("</email1>"); else { if (to.stripWhiteSpace() .remove("</email1>") .remove("</email2>") .remove("</email3>") .length()) to=to.replace("</email1>", ", " + email1); else to=to.replace("</email1>", email1); } if ((email2.isEmpty()) || (to.count(email2,Qt::CaseInsensitive))) to=to.remove("</email2>"); else { if (to.stripWhiteSpace() .remove("</email1>") .remove("</email2>") .remove("</email3>") .length()) to=to.replace("</email2>", ", " + email2); else to=to.replace("</email2>", email2); } if ((email3.isEmpty()) || (to.count(email3,Qt::CaseInsensitive))) to=to.remove("</email3>"); else { if (to.stripWhiteSpace() .remove("</email1>") .remove("</email2>") .remove("</email3>") .length()) to=to.replace("</email3>", ", " + email3); else to=to.replace("</email3>", email3); } //Add token addresses to "CC" list if applicable if ((email1.isEmpty()) || (cc.count(email1,Qt::CaseInsensitive))) cc=cc.remove("</email1>"); else { if (cc.stripWhiteSpace() .remove("</email1>") .remove("</email2>") .remove("</email3>") .length()) cc=cc.replace("</email1>", ", " + email1); else cc=cc.replace("</email1>", email1); } if ((email2.isEmpty()) || (cc.count(email2,Qt::CaseInsensitive))) cc=cc.remove("</email2>"); else { if (cc.stripWhiteSpace() .remove("</email1>") .remove("</email2>") .remove("</email3>") .length()) cc=cc.replace("</email2>", ", " + email2); else cc=cc.replace("</email2>", email2); } if ((email3.isEmpty()) || (cc.count(email3,Qt::CaseInsensitive))) cc=cc.remove("</email3>"); else { if (cc.stripWhiteSpace() .remove("</email1>") .remove("</email2>") .remove("</email3>") .length()) cc=cc.replace("</email3>", ", " + email3); else cc=cc.replace("</email3>", email3); } //Build comment detail if applicable if (body.count("</comments>") && !doctype.isEmpty() && docid) { q.prepare("SELECT comment_user, comment_date, comment_text " "FROM comment " "WHERE ( (comment_source=:doctype) " " AND (comment_source_id=:docid) ) " "ORDER BY comment_date;"); q.bindValue(":doctype", doctype); q.bindValue(":docid", docid); q.exec(); while (q.next()) { comments += "-----------------------------------------------------\n"; comments += q.value("comment_user").toString(); comments += " - "; comments += q.value("comment_date").toString(); comments += "\n-----------------------------------------------------\n"; comments += q.value("comment_text").toString(); comments += "\n\n"; } body=body.replace("</comments>", comments); } if (preview) { ParameterList params; params.append("from", from); params.append("to", to); params.append("cc", cc); params.append("subject", subject); params.append("body", body); params.append("emailhtml", q.value("ediprofile_emailhtml").toBool()); params.append("fileName", fileName); deliverEmail newdlg(parent, "", TRUE); newdlg.set(params); newdlg.setReportName(reportName); newdlg.setReportParameters(rptParams); if (newdlg.exec() == XDialog::Rejected) return false; else return true; } else if (reportName.isEmpty()) submitEmail(parent,from,to,cc,subject,body,q.value("ediprofile_emailhtml").toBool()); else submitReport(parent,reportName,fileName,from,to,cc,subject,body,q.value("ediprofile_emailhtml").toBool(),rptParams); } else return false; return true; }