Commit 5fc51092 authored by Andrei O.'s avatar Andrei O.
Browse files

alfa 0.1.1

parent 657e5fe8
......@@ -199,9 +199,11 @@ while (!file.atEnd()) {
if(var == (lineSplit.length()-1)) qSlist.append(lineSplit[var].left(lineSplit[var].length()-2));
else qSlist.append(lineSplit[var]);
po->smtpMvars.append(qSlist);
}
}
qDebug() << "sss " << qSlist;
po->smtpMvars.append(qSlist);
cLine++;
}else throw Qmescsvlinenotvalid{};
......@@ -248,8 +250,13 @@ foreach (QStringList headVar, po->smtpMvars) {
QString QmesCvsParsUtil::parseVarInText(QString ptext, int mailLine, QMESMainWindow *po){
if(po->smtpMvars.size() >= mailLine)
{
QRegularExpression rx("\\{var[0-9]{1,2}\\}");
QRegularExpressionMatchIterator i = rx.globalMatch(ptext);
int lastIns = 0;
while (i.hasNext()) {
QRegularExpressionMatch match = i.next();
......@@ -258,20 +265,29 @@ QString QmesCvsParsUtil::parseVarInText(QString ptext, int mailLine, QMESMainWi
QRegularExpressionMatch sbMatch = re.match(match.captured());
qDebug() << match.captured() << sbMatch.captured().toInt();
if(po->smtpMvars.size() >= mailLine)
{
if( po->smtpMvars.at(mailLine).size() >= sbMatch.captured().toInt()){
varNotInMem = false;
ptext.remove(match.capturedStart(), match.capturedEnd());
ptext.insert(match.capturedStart(),po->smtpMvars.at(mailLine).at(sbMatch.captured().toInt()));
varNotInMem = false;
qDebug() << match.capturedStart() << " " << match.capturedEnd();
qDebug() << ptext;
ptext.remove(match.capturedStart()+lastIns, match.capturedLength());
ptext.insert(match.capturedStart()+lastIns,po->smtpMvars.at(mailLine).at(sbMatch.captured().toInt()));
lastIns+= (match.capturedStart(),po->smtpMvars.at(mailLine).at(sbMatch.captured().toInt()).length()-6);
}
}
// I didn't want same code twice so i added a bool, if var from text was not parsed just remove the {var\\d+} and go on.
if(varNotInMem) ptext.remove(match.capturedStart(), match.capturedEnd());
if(varNotInMem) { ptext.remove(match.capturedStart()+lastIns,match.capturedLength());
lastIns+= -6;
QmesCvsParsUtil::cvsNbEmailToS = po->smtpMTo.length();
QString logM = QString("<br/><span style='color:#998100'> WARNING:</span>").append("Email processed on line ").append(mailLine).append(" didn't find var ").append(match.captured()).append(" variable replaced with empty string.");
po->addtoLog(logM);
po->printToLogTb(logM);
}
}
}}
return ptext;
......
......@@ -76,8 +76,8 @@ void QMESMainWindow::on_btLoadCsvMail_clicked()
QmesCvsParsUtil::parseCsvMail(fileName, ui->edMailVar, this);
ui->sBoxNmail->setValue(QmesCvsParsUtil::cvsNbEmailToS);
QString debTxt = QmesCvsParsUtil::parseVarInText(ui->tBMsg->toHtml(),0,this);
ui->tBMsg->setHtml(debTxt);
QString debTxt = QmesCvsParsUtil::parseVarInText(ui->tBMsg->toPlainText(),0,this);
ui->tBMsg->setPlainText(debTxt);
......
......@@ -197,7 +197,7 @@
<property name="title">
<string>Message Controls</string>
</property>
<widget class="QTextEdit" name="tBMsg">
<widget class="QPlainTextEdit" name="tBMsg">
<property name="geometry">
<rect>
<x>10</x>
......@@ -206,25 +206,14 @@
<height>271</height>
</rect>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&amp;lt;html&amp;gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&amp;lt;body&amp;gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Sample message:&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Hello {var1}, we would like to announce you about the campaing {var2} that you enlisted.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;{var3}&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&amp;lt;/body&amp;gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&amp;lt;/htmL&amp;gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<property name="plainText">
<string>&lt;html&gt;&lt;body&gt;
Hello {var1} we would like to inform you about the campaing {var2}, on wich you had suscribed.
{var3}
&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QProgressBar" name="progressBar">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment