diff --git a/gui/Dialog.ui b/gui/Dialog.ui
index 6ef949a..257b218 100644
--- a/gui/Dialog.ui
+++ b/gui/Dialog.ui
@@ -241,6 +241,7 @@
+
@@ -382,6 +383,14 @@
Enable Line Wrapping
+
+
+ true
+
+
+ Enable XML-style Output
+
+
analyzeButton
diff --git a/src/Config.h b/src/Config.h
index e5019bd..9ab16d1 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -27,7 +27,7 @@
//Version
MIXP_DEFINE_CONF(unsigned int, mixp_versionMajor, 2)
-MIXP_DEFINE_CONF(unsigned int, mixp_versionMinor, 27)
+MIXP_DEFINE_CONF(unsigned int, mixp_versionMinor, 28)
//MediaInfo Version
MIXP_DEFINE_CONF(unsigned int, mixp_miVersionMajor, 0)
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index cc63c62..c11aa9c 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -45,6 +45,8 @@
#include
#include
#include
+#include
+#include
//CRT
#include
@@ -64,19 +66,9 @@ const char *STATUS_BLNK = ">> You can drop any type of media files here <<";
const char *STATUS_WORK = "Analyzing file(s), this may take a moment or two...
";
//Links
-const char *LINK_MULDER = "http://muldersoft.com/";
+const char *LINK_MULDER = "http://muldersoft.com/";
const char *LINK_MEDIAINFO = "http://mediaarea.net/en/MediaInfo"; /*"http://mediainfo.sourceforge.net/en"*/
-const char *LINK_DISCUSS = "http://forum.doom9.org/showthread.php?t=96516";
-
-//HTML characters
-static QList> HTML_ESCAPE(void)
-{
- QList> htmlEscape;
- htmlEscape << QPair("<", "<");
- htmlEscape << QPair(">", ">");
- htmlEscape << QPair("&", "&");
- return htmlEscape;
-}
+const char *LINK_DISCUSS = "http://forum.doom9.org/showthread.php?t=96516";
//MediaInfo
static const struct
@@ -106,7 +98,6 @@ CMainWindow::CMainWindow(const QString &tempFolder, MUtils::IPCChannel *const ip
QMainWindow(parent),
m_tempFolder(tempFolder),
m_ipcThread(new IPCReceiveThread(ipc)),
- m_htmlEscape(HTML_ESCAPE()),
m_status(APP_STATUS_STARTING),
ui(new Ui::MainWindow)
{
@@ -138,6 +129,8 @@ CMainWindow::CMainWindow(const QString &tempFolder, MUtils::IPCChannel *const ip
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAboutScreen()));
connect(ui->actionShellExtension, SIGNAL(toggled(bool)), this, SLOT(updateShellExtension(bool)));
connect(ui->actionLineWrapping, SIGNAL(toggled(bool)), this, SLOT(updateLineWrapping(bool)));
+ connect(ui->actionVerboseOutput, SIGNAL(toggled(bool)), this, SLOT(toggleOutputOption(bool)));
+ connect(ui->actionXmlOutput, SIGNAL(toggled(bool)), this, SLOT(toggleOutputOption(bool)));
connect(m_ipcThread.data(), SIGNAL(received(quint32, QString)), this, SLOT(received(quint32, QString)));
ui->versionLabel->installEventFilter(this);
@@ -416,6 +409,7 @@ void CMainWindow::analyzeNextFile(void)
//Generate the command line
QStringList commandLine;
if(ui->actionVerboseOutput->isChecked()) commandLine << "--Full";
+ if(ui->actionXmlOutput->isChecked()) commandLine << "--Output=XML";
commandLine << QDir::toNativeSeparators(filePath);
//Start analyziation
@@ -552,11 +546,11 @@ void CMainWindow::processFinished(void)
}
//Remove leading "E:" lines
- while ((!m_outputLines.isEmpty()) && m_outputLines.first().trimmed().startsWith(QLatin1String("E: ")))
- {
- qWarning("E: line has been removed!");
- m_outputLines.takeFirst();
- }
+ /*while ((!m_outputLines.isEmpty()) && m_outputLines.first().trimmed().startsWith(QLatin1String("E: ")))
+ //{
+ // qWarning("E: line has been removed!");
+ // m_outputLines.takeFirst();
+ }*/
//Failed?
if(m_outputLines.empty())
@@ -589,17 +583,20 @@ void CMainWindow::processFinished(void)
//Hide banner
if(m_floatingLabel->isVisible()) m_floatingLabel->hide();
- //Convert to HTML
- QStringList htmlData(m_outputLines);
- escapeHtmlChars(htmlData);
-
- //Highlight headers
- htmlData.replaceInStrings(QRegExp("^(-+)$"), "\\1"); //Separator lines
- htmlData.replaceInStrings(QRegExp("^([^:<>]+):(.+)$"), "\\1:\\2"); //Info lines
- htmlData.replaceInStrings(QRegExp("^([^:<>]+)$"), "\\1"); //Heading lines
-
//Update document
- ui->textBrowser->setHtml(QString("%1
").arg(htmlData.join("
")));
+ if (!ui->actionXmlOutput->isChecked())
+ {
+ QStringList htmlData = escapeHtmlLines(m_outputLines);
+ htmlData.replaceInStrings(QRegExp("^(-+)$"), "\\1");
+ htmlData.replaceInStrings(QRegExp("^([^:<>]+):(.+)$"), "\\1:\\2");
+ htmlData.replaceInStrings(QRegExp("^([^:<>]+)$"), "\\1");
+ ui->textBrowser->setHtml(QString("%1
").arg(htmlData.join("
")));
+ }
+ else
+ {
+ const QString xmlData = Qt::escape(reformatXml(m_outputLines.join(QLatin1String("\n"))));
+ ui->textBrowser->setHtml(QString("%1
").arg(xmlData));
+ }
//Enable actions
if(!m_outputLines.empty())
@@ -641,6 +638,11 @@ void CMainWindow::updateLineWrapping(bool checked)
ui->textBrowser->setLineWrapMode(checked ? QTextEdit::WidgetWidth : QTextEdit::NoWrap);
}
+void CMainWindow::toggleOutputOption(bool checked)
+{
+ QMessageBox::information(this, this->windowTitle(), tr("Changes will take effect the next time that you open a file!"));
+}
+
void CMainWindow::linkTriggered(void)
{
QObject *obj = QObject::sender();
@@ -892,11 +894,29 @@ QString CMainWindow::getMediaInfoPath(void)
return QString();
}
-void CMainWindow::escapeHtmlChars(QStringList &strings)
+QStringList CMainWindow::escapeHtmlLines(const QStringList &strings)
{
- QList>::ConstIterator iter;
- for(iter = m_htmlEscape.constBegin(); iter != m_htmlEscape.constEnd(); iter++)
+ QStringList output;
+ for (QStringList::const_iterator iter = strings.constBegin(); iter != strings.constEnd(); ++iter)
{
- strings.replaceInStrings((*iter).first, (*iter).second);
+ output << Qt::escape(*iter);
}
+ return output;
+}
+
+QString CMainWindow::reformatXml(const QString &input)
+{
+ QString output;
+ QXmlStreamReader reader(input);
+ QXmlStreamWriter writer(&output);
+ writer.setAutoFormatting(true);
+ while (!reader.atEnd())
+ {
+ reader.readNext();
+ if (!reader.isWhitespace())
+ {
+ writer.writeCurrentToken(reader);
+ }
+ }
+ return output;
}
diff --git a/src/MainWindow.h b/src/MainWindow.h
index 95e5936..ddf294f 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -62,6 +62,7 @@ private slots:
void initShellExtension(void);
void updateShellExtension(bool checked);
void updateLineWrapping(bool checked);
+ void toggleOutputOption(bool checked);
void received(const quint32 &command, const QString &message);
protected:
@@ -96,10 +97,10 @@ private:
QStringList m_pendingFiles;
QStringList m_outputLines;
- const QList> m_htmlEscape;
-
QPair getMediaInfoArch(void);
void selfTest(void);
QString getMediaInfoPath(void);
- void escapeHtmlChars(QStringList &strings);
+
+ static QStringList escapeHtmlLines(const QStringList &strings);
+ static QString reformatXml(const QString &input);
};