Commit ca13be59 authored by Bryan Godbolt's avatar Bryan Godbolt

Merge remote-tracking branch 'upstream/dev-lin' into dev-lin

parents f31c086b 0f28dcbf
...@@ -18,13 +18,13 @@ XMLCommProtocolWidget::XMLCommProtocolWidget(QWidget *parent) : ...@@ -18,13 +18,13 @@ XMLCommProtocolWidget::XMLCommProtocolWidget(QWidget *parent) :
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
// Now set syntax highlighter
//highlighter = new MAVLinkSyntaxHighlighter(m_ui->xmlTextView->document());
connect(m_ui->selectFileButton, SIGNAL(clicked()), this, SLOT(selectXMLFile())); connect(m_ui->selectFileButton, SIGNAL(clicked()), this, SLOT(selectXMLFile()));
connect(m_ui->selectOutputButton, SIGNAL(clicked()), this, SLOT(selectOutputDirectory())); connect(m_ui->selectOutputButton, SIGNAL(clicked()), this, SLOT(selectOutputDirectory()));
connect(m_ui->generateButton, SIGNAL(clicked()), this, SLOT(generate())); connect(m_ui->generateButton, SIGNAL(clicked()), this, SLOT(generate()));
connect(m_ui->saveButton, SIGNAL(clicked()), this, SLOT(save())); connect(m_ui->saveButton, SIGNAL(clicked()), this, SLOT(save()));
// Make sure text background is white
m_ui->xmlTextView->setStyleSheet("QGCMAVLinkTextEdit { background-color: #FFFFFF; }");
} }
void XMLCommProtocolWidget::selectXMLFile() void XMLCommProtocolWidget::selectXMLFile()
...@@ -128,7 +128,11 @@ void XMLCommProtocolWidget::generate() ...@@ -128,7 +128,11 @@ void XMLCommProtocolWidget::generate()
m_ui->compileLog->clear(); m_ui->compileLog->clear();
// Check XML validity // Check XML validity
if (!m_ui->xmlTextView->syntaxcheck()) return; if (!m_ui->xmlTextView->syntaxcheck())
{
// Syntax check already gives output
return;
}
MAVLinkXMLParser* parser = new MAVLinkXMLParser(m_ui->fileNameLabel->text().trimmed(), m_ui->outputDirNameLabel->text().trimmed()); MAVLinkXMLParser* parser = new MAVLinkXMLParser(m_ui->fileNameLabel->text().trimmed(), m_ui->outputDirNameLabel->text().trimmed());
connect(parser, SIGNAL(parseState(QString)), m_ui->compileLog, SLOT(appendHtml(QString))); connect(parser, SIGNAL(parseState(QString)), m_ui->compileLog, SLOT(appendHtml(QString)));
......
...@@ -50,32 +50,32 @@ void QGCMAVLinkTextEdit::setPlainText( const QString txt ) ...@@ -50,32 +50,32 @@ void QGCMAVLinkTextEdit::setPlainText( const QString txt )
bool QGCMAVLinkTextEdit::syntaxcheck() bool QGCMAVLinkTextEdit::syntaxcheck()
{ {
bool error = false; bool noError = true;
if (text().size() > 0 ) { if (text().size() > 0 ) {
QString errorStr; QString errorStr;
int errorLine, errorColumn; int errorLine, errorColumn;
QDomDocument doc; QDomDocument doc;
if (!doc.setContent(text(),false, &errorStr, &errorLine, &errorColumn)) { if (!doc.setContent(text(),false, &errorStr, &errorLine, &errorColumn)) {
//////return doc.toString(5); //////return doc.toString(5);
QMessageBox::information(0, tr("Found xml error"),tr("Check line %1 column %2 on string \"%3\"!") QMessageBox::critical(0, tr("Found xml error"),tr("Check line %1 column %2 on string \"%3\"!")
.arg(errorLine - 1) .arg(errorLine - 1)
.arg(errorColumn - 1) .arg(errorColumn - 1)
.arg(errorStr)); .arg(errorStr));
error = true; noError = false;
// FIXME Mark line // FIXME Mark line
if (errorLine >= 0 ) { if (errorLine >= 0 ) {
} }
} else { } else {
QMessageBox::information(0, tr("XML valid."),tr("All tag are valid size %1.").arg(text().size())); QMessageBox::information(0, tr("XML valid."),tr("All tags are valid. Document size is %1 characters.").arg(text().size()));
setPlainText(doc.toString(5)); setPlainText(doc.toString(5));
} }
} else { } else {
QMessageBox::information(0, tr("XML not found!"),tr("Null size xml document!")); QMessageBox::information(0, tr("XML not found!"),tr("Null size xml document!"));
error = true; noError = false;
} }
return error; return noError;
} }
void QGCMAVLinkTextEdit::contextMenuEvent ( QContextMenuEvent * e ) void QGCMAVLinkTextEdit::contextMenuEvent ( QContextMenuEvent * e )
......
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