diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -110,7 +110,6 @@ QDir::homePath(), i18n("GCode (*.gco *.gcode)")); if (!fileNameFromDialog.isEmpty()) { fileName = fileNameFromDialog.toLocalFile(); - ui->gcodeEditorWidget->loadFile(fileName); } } diff --git a/src/widgets/gcodeeditorwidget.h b/src/widgets/gcodeeditorwidget.h --- a/src/widgets/gcodeeditorwidget.h +++ b/src/widgets/gcodeeditorwidget.h @@ -31,7 +31,6 @@ public: explicit GCodeEditorWidget(QWidget *parent = nullptr); ~GCodeEditorWidget(); - void loadFile(const QString &fileName); private: Ui::GCodeEditorWidget *ui; diff --git a/src/widgets/gcodeeditorwidget.cpp b/src/widgets/gcodeeditorwidget.cpp --- a/src/widgets/gcodeeditorwidget.cpp +++ b/src/widgets/gcodeeditorwidget.cpp @@ -18,6 +18,7 @@ #include "gcodeeditorwidget.h" #include "ui_gcodeeditorwidget.h" #include + GCodeEditorWidget::GCodeEditorWidget(QWidget *parent) : QWidget(parent), ui(new Ui::GCodeEditorWidget) @@ -29,35 +30,3 @@ { delete ui; } - -void GCodeEditorWidget::loadFile(const QString &fileName) -{ - QRegularExpression cacthMov("G(?.) .*\\bX(?[0-9.-]+) Y(?[0-9.-]+) Z(?[0-9].+)"); - QRegularExpression catchEnd(";(\\s?)(End)(\\s?\\w+\\s?(\\w+)?)"); - catchEnd.setPatternOptions(QRegularExpression::CaseInsensitiveOption); - QRegularExpressionMatch match; - QFile gcode(fileName); - if (!gcode.open(QFile::ReadOnly)) { - return; - } - QTextStream gcodeStream(&gcode); - QString content = gcodeStream.readAll(); - //TODO: Send this content to 3DView - QStringList list = content.split(QStringLiteral("\n"), QString::SkipEmptyParts); - QString header, footer; - foreach (const auto &line, list) { - match = cacthMov.match(line); - if (match.hasMatch()) { - break; - } - header += (line + QStringLiteral("\n")); - } - int last = list.lastIndexOf(catchEnd); - if (last != -1) { - for (int i = last; i <= list.size() - 1; ++i) { - footer += (list.at(i) + QStringLiteral("\n")); - } - } - ui->headerPT->setPlainText(header); - ui->footerPT->setPlainText(footer); -} diff --git a/src/widgets/gcodeeditorwidget.ui b/src/widgets/gcodeeditorwidget.ui --- a/src/widgets/gcodeeditorwidget.ui +++ b/src/widgets/gcodeeditorwidget.ui @@ -13,82 +13,7 @@ Form - - - - - Qt::LeftToRight - - - Header - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - Save - - - - - - - Cancel - - - - - - - Undo - - - - - - - Redo - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Footer - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - +