From b2c130ca56d02ca722fa24693cfed8ae7c9a6294 Mon Sep 17 00:00:00 2001 From: AntonMrt Date: Sat, 16 Nov 2024 22:36:09 +0300 Subject: [PATCH] Revert "Merge branch 'main' into messages" This reverts commit 8898ba17489dd00c962b9d6de71cce4784bd91a9, reversing changes made to f5eba6302ced86ccca989487e0e8c45be9bdbb20. --- common_utils/common_utils.cpp | 2 +- davis_one/davis.cpp | 76 +++--------------------------- davis_one/davis.h | 14 ------ gui/CMakeLists.txt | 2 - gui/date_time_formats.json | 6 --- gui/davis_gui.cpp | 88 +++-------------------------------- gui/davis_gui.h | 1 - gui/json_utils.cpp | 82 -------------------------------- gui/json_utils.h | 32 ------------- gui/res.qrc | 1 - plotly_maker/html_parts.cpp | 35 -------------- plotly_maker/html_parts.h | 11 ----- plotly_maker/plotly_maker.cpp | 39 ++-------------- plotly_maker/plotly_maker.h | 3 -- 14 files changed, 18 insertions(+), 374 deletions(-) delete mode 100644 gui/date_time_formats.json delete mode 100644 gui/json_utils.cpp delete mode 100644 gui/json_utils.h diff --git a/common_utils/common_utils.cpp b/common_utils/common_utils.cpp index 3afbf32..502a970 100644 --- a/common_utils/common_utils.cpp +++ b/common_utils/common_utils.cpp @@ -236,7 +236,7 @@ bool make_string(const string& src, int find_separator(const std::string& src, char& separator) { - std::vector ignored_chars = {'+', '-', 'e', '.', '\r', ',', 'E'}; + std::vector ignored_chars = {'+', '-', 'e', '.', '\r', ','}; std::set unique_chars; bool is_service_char = false; bool is_dot_present = false; diff --git a/davis_one/davis.cpp b/davis_one/davis.cpp index c5cad9e..1a9c56a 100644 --- a/davis_one/davis.cpp +++ b/davis_one/davis.cpp @@ -355,41 +355,6 @@ const char kNoFileFoundedPage[] = R"( extern const char kWarningIcon[] = R"davis_delimeter()davis_delimeter"; - - -extern const char kHtmlDateTimeModel[] = R"davis_delimeter( - - - -
- - - -)davis_delimeter"; - - - // *INDENT-ON* } // namespace dvs end @@ -619,7 +584,7 @@ bool make_string(const string& src, int find_separator(const std::string& src, char& separator) { - std::vector ignored_chars = {'+', '-', 'e', '.', '\r', ',', 'E'}; + std::vector ignored_chars = {'+', '-', 'e', '.', '\r', ','}; std::set unique_chars; bool is_service_char = false; bool is_dot_present = false; @@ -713,7 +678,7 @@ bool checkThatSizesAreTheSame(const vector>& values) { for (size_t i = 0; i < values.size(); ++i) { if (values[i].size() != size) { - showMatrixSizesAreNotTheSame(); + showMatrixSizesAreNotTheSame(i); return false; } } @@ -1016,42 +981,13 @@ void showReportFileEmpty() { } -void showMatrixSizesAreNotTheSame() { +void showMatrixSizesAreNotTheSame(int badRow) { + string text; + text.append("Rows have different sizes in matrix. Check the row № ").append(std::to_string(badRow + 1)); showReportPage("Rows sizes are not the same", kWarningIcon, - "Rows have different sizes in matrix"); -} - -void showDateTimeChart(const string& date_time_values, - const vector& yValues) { - - string out; - string davis_dir; -#ifdef _WIN32 - davis_dir = "\\davis_htmls"; -#elif __linux__ - davis_dir = "/davis_htmls"; -#endif - vectorargs {ARGS_DATE_TIME_PAGE_SIZE, ""}; - args[ARG_JS_NAME] = kPlotlyJsName; - args[ARG_DATE_TIME_VALUES] = date_time_values; - - std::string values; - for (size_t i = 0; i < yValues.size(); ++i) { - std::string value = std::to_string(yValues[i]); - values.append(value); - if (i != yValues.size() - 1) { - values.append(","); - } - } - - args[ARG_Y_DATE_TIME_VALUES] = values; - make_string(kHtmlDateTimeModel, args, out); - saveStringToFile(kReportPagePath, out); - openFileBySystem(kReportPagePath); - - + text); } diff --git a/davis_one/davis.h b/davis_one/davis.h index 56e1fd2..c41f17b 100644 --- a/davis_one/davis.h +++ b/davis_one/davis.h @@ -139,14 +139,6 @@ enum ARGS_REPORT_PAGE_INDEX { ARGS_REPORT_PAGE_SIZE }; -enum ARGS_DATE_TIME_PAGE_INDEX { - ARG_JS_NAME, //%1 - ARG_DATE_TIME_VALUES, //%2 - ARG_Y_DATE_TIME_VALUES, //%3 - // ADD NEW ENUM BEFORE THIS COMMENT - ARGS_DATE_TIME_PAGE_SIZE -}; - extern const char kHtmlModel[]; extern const char kColorMapDefaultPart[]; @@ -168,9 +160,6 @@ extern const char kNoFileFoundedPage[]; extern const char kWarningIcon[]; -extern const char kHtmlDateTimeModel[]; - - } // namespace dvs end namespace dvs { @@ -343,9 +332,6 @@ void showReportFileEmpty(); void showMatrixSizesAreNotTheSame(int badRow); -void showDateTimeChart(const string& date_time_values, - const vector& yValues); - } // namespace dvs end diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index b488f8b..8e3172a 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -45,8 +45,6 @@ set(PROJECT_SOURCES about_window.cpp davis_gui.ui about_window.ui - json_utils.h - json_utils.cpp ) qt5_add_resources(PROJECT_SOURCES res.qrc) diff --git a/gui/date_time_formats.json b/gui/date_time_formats.json deleted file mode 100644 index 1a749c2..0000000 --- a/gui/date_time_formats.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - "dd/MM/yyyy hh:mm", - "yyyy/MM/dd hh:mm:ss", - "yyyy.MM.dd_hh:mm:ss", - "yyyy/MM/dd hh_mm_ss" -] diff --git a/gui/davis_gui.cpp b/gui/davis_gui.cpp index 3e00999..b4eb9bd 100644 --- a/gui/davis_gui.cpp +++ b/gui/davis_gui.cpp @@ -16,10 +16,6 @@ #include "QFileDialog" #include "QTextStream" #include -#include -#include "json_utils.h" -#include "QDateTime" -#include DavisGUI::DavisGUI(QWidget* parent) : QMainWindow(parent) @@ -88,9 +84,7 @@ void DavisGUI::pasteTextAdded() { QString clipboardText = clipboard->text(); qDebug() << clipboardText; QStringList lines = clipboardText.split(QRegExp("[\r\n]+")); - if (checkDateTimeVariant(lines) == false) { - readPlotText(lines); - }; + readPlotText(lines); } void DavisGUI::readPlotText(QStringList& str_lines) { @@ -125,7 +119,7 @@ void DavisGUI::readPlotText(QStringList& str_lines) { } if (data.empty()) { - dvs::showReportFileEmpty(); + qDebug() << "Empty file"; return; } @@ -156,60 +150,6 @@ void DavisGUI::readPlotText(QStringList& str_lines) { } } -bool DavisGUI::checkDateTimeVariant(const QStringList& lines) { - - QJsonArray jarr; - if(jsn::getJsonArrayFromFile("date_time_formats.json", jarr)==false){ - jsn::getJsonArrayFromFile(":/date_time_formats.json", jarr); - } - qDebug() << jarr; - QString dates; - std::vector values; - - for (int i = 0; i < lines.size(); ++i) { - QString test = lines[i]; - for (int j = 0; j < jarr.size(); ++j) { - int template_time_stamp_size = jarr[j].toString().size(); - QString template_time_stamp = jarr[j].toString(); - if (test.size() < template_time_stamp_size + 1) { - continue; - } - QString separator = QString(test[template_time_stamp_size]); - QString substr = test.mid(0, template_time_stamp_size); - QDateTime dt = QDateTime::fromString(substr, template_time_stamp); - if (dt.isValid()) { - //2013-10-04 22:23:00 - qDebug() << dt.toString("yyyy-MM-dd hh:mm:ss"); - dates.append("'"); - dates.append(dt.toString("yyyy-MM-dd hh:mm:ss")); - dates.append("'"); - if (i < lines.size() - 1) { - dates.append(","); - } - - auto values_list = test.split(separator); - if (values_list.size() != 2) { - continue; - } - double value = values_list[1].toDouble(); - qDebug()<mimeData()->hasUrls()) { event->acceptProposedAction(); @@ -219,14 +159,11 @@ void DavisGUI::dragEnterEvent(QDragEnterEvent* event) { } void DavisGUI::dropEvent(QDropEvent* event) { - QList file_list = event->mimeData()->urls(); - if(file_list.size()>1){ - qDebug()<<"file list size: "<mimeData()->urls().first().toLocalFile(); QFileInfo info(filePath); + qDebug() << "---file path--->" << filePath; if (info.exists()) { + qDebug() << "exist"; QFile file(filePath); QTextStream ts(&file); ts.setCodec("UTF-8"); @@ -234,17 +171,6 @@ void DavisGUI::dropEvent(QDropEvent* event) { dvs::showReportFileNotFounded(); return; }; - - QString suffix = info.suffix(); - QStringList suffixes = {"jpg","bmp","png","svg","mp4","json"}; - for(int i=0;i -#include -#include -#include -#include -#include -#include -#include - - -namespace jsn { - -bool getJsonObjectFromFile(const QString& path, - QJsonObject& object) { - QFile file(path); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - qDebug() << "File can't be opened!" << path; - return false; - }; - QByteArray data = file.readAll(); - QJsonParseError errorPtr; - object = QJsonDocument::fromJson(data, &errorPtr).object(); - if (object.isEmpty()) { - qDebug() << "JSON IS EMPTY: " << errorPtr.errorString(); - return false; - } - file.close(); - - return true; -} - -bool getJsonArrayFromFile(const QString& path, - QJsonArray& object) { - QFile file(path); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - qDebug() << "File can't be opened!" << path; - return false; - }; - QByteArray data = file.readAll(); - QJsonParseError errorPtr; - object = QJsonDocument::fromJson(data, &errorPtr).array(); - if (object.isEmpty()) { - qDebug() << "JSON IS EMPTY: " << errorPtr.errorString(); - return false; - } - file.close(); - return true; -} - -bool saveJsonObjectToFile(const QString& path, - const QJsonObject& json_object, - QJsonDocument::JsonFormat format) { - QFile file(path); - if (!file.open(QIODevice::WriteOnly)) - return false; - auto json_doc = QJsonDocument(json_object).toJson(format); - auto result = file.write(json_doc); - file.close(); - if (result == -1) - return false; - else - return true; -} - -bool saveJsonArrayToFile(const QString& path, - const QJsonArray& json_object, - QJsonDocument::JsonFormat format) { - QFile file(path); - if (!file.open(QIODevice::WriteOnly)) - return false; - auto json_doc = QJsonDocument(json_object).toJson(format); - auto result = file.write(json_doc); - file.close(); - if (result == -1) - return false; - else - return true; -} - -} // end jsn namespace diff --git a/gui/json_utils.h b/gui/json_utils.h deleted file mode 100644 index 64a074c..0000000 --- a/gui/json_utils.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef JSON_UTILS_H -#define JSON_UTILS_H - -#include "QVector" -#include "QJsonDocument" - -class QString; -class QJsonArray; -class QJsonObject; - - -namespace jsn { - - -bool getJsonObjectFromFile(const QString& path, - QJsonObject& object); - -bool getJsonArrayFromFile(const QString& path, - QJsonArray& object); - - -bool saveJsonObjectToFile(const QString& path, - const QJsonObject& json_object, - QJsonDocument::JsonFormat format); - -bool saveJsonArrayToFile(const QString& path, - const QJsonArray& json_object, - QJsonDocument::JsonFormat format); - -} // end namespace jsn - -#endif // JSON_UTILS_H diff --git a/gui/res.qrc b/gui/res.qrc index e618b9a..3a7169f 100644 --- a/gui/res.qrc +++ b/gui/res.qrc @@ -9,6 +9,5 @@ res/davis.mp3 res/content_copy_200dp_969696_FILL0_wght300_GRAD0_opsz48.png res/check_200dp_969696_FILL0_wght300_GRAD0_opsz48.png - date_time_formats.json diff --git a/plotly_maker/html_parts.cpp b/plotly_maker/html_parts.cpp index e77b418..ed6e2cf 100644 --- a/plotly_maker/html_parts.cpp +++ b/plotly_maker/html_parts.cpp @@ -328,41 +328,6 @@ const char kNoFileFoundedPage[] = R"( extern const char kWarningIcon[] = R"davis_delimeter()davis_delimeter"; - - -extern const char kHtmlDateTimeModel[] = R"davis_delimeter( - - - -
- - - -)davis_delimeter"; - - - // *INDENT-ON* //#STOP_GRAB_TO_DVS_NAMESPACE } // namespace dvs diff --git a/plotly_maker/html_parts.h b/plotly_maker/html_parts.h index dba6061..5b44c41 100644 --- a/plotly_maker/html_parts.h +++ b/plotly_maker/html_parts.h @@ -32,14 +32,6 @@ enum ARGS_REPORT_PAGE_INDEX { ARGS_REPORT_PAGE_SIZE }; -enum ARGS_DATE_TIME_PAGE_INDEX { - ARG_JS_NAME, //%1 - ARG_DATE_TIME_VALUES, //%2 - ARG_Y_DATE_TIME_VALUES, //%3 - // ADD NEW ENUM BEFORE THIS COMMENT - ARGS_DATE_TIME_PAGE_SIZE -}; - extern const char kHtmlModel[]; extern const char kColorMapDefaultPart[]; @@ -60,9 +52,6 @@ extern const char kWarningJSLibAbsentPage[]; extern const char kNoFileFoundedPage[]; extern const char kWarningIcon[]; - -extern const char kHtmlDateTimeModel[]; - //#STOP_GRAB_TO_DVS_NAMESPACE } diff --git a/plotly_maker/plotly_maker.cpp b/plotly_maker/plotly_maker.cpp index 24340b2..4857e55 100644 --- a/plotly_maker/plotly_maker.cpp +++ b/plotly_maker/plotly_maker.cpp @@ -28,7 +28,7 @@ bool checkThatSizesAreTheSame(const vector>& values) { for (size_t i = 0; i < values.size(); ++i) { if (values[i].size() != size) { - showMatrixSizesAreNotTheSame(); + showMatrixSizesAreNotTheSame(i); return false; } } @@ -331,42 +331,13 @@ void showReportFileEmpty() { } -void showMatrixSizesAreNotTheSame() { +void showMatrixSizesAreNotTheSame(int badRow) { + string text; + text.append("Rows have different sizes in matrix. Check the row № ").append(std::to_string(badRow + 1)); showReportPage("Rows sizes are not the same", kWarningIcon, - "Rows have different sizes in matrix"); -} - -void showDateTimeChart(const string& date_time_values, - const vector& yValues) { - - string out; - string davis_dir; -#ifdef _WIN32 - davis_dir = "\\davis_htmls"; -#elif __linux__ - davis_dir = "/davis_htmls"; -#endif - vectorargs {ARGS_DATE_TIME_PAGE_SIZE, ""}; - args[ARG_JS_NAME] = kPlotlyJsName; - args[ARG_DATE_TIME_VALUES] = date_time_values; - - std::string values; - for (size_t i = 0; i < yValues.size(); ++i) { - std::string value = std::to_string(yValues[i]); - values.append(value); - if (i != yValues.size() - 1) { - values.append(","); - } - } - - args[ARG_Y_DATE_TIME_VALUES] = values; - make_string(kHtmlDateTimeModel, args, out); - saveStringToFile(kReportPagePath, out); - openFileBySystem(kReportPagePath); - - + text); } //#STOP_GRAB_TO_DVS_NAMESPACE diff --git a/plotly_maker/plotly_maker.h b/plotly_maker/plotly_maker.h index 7b440a6..d8d2ad2 100644 --- a/plotly_maker/plotly_maker.h +++ b/plotly_maker/plotly_maker.h @@ -47,9 +47,6 @@ void showReportFileEmpty(); void showMatrixSizesAreNotTheSame(int badRow); -void showDateTimeChart(const string& date_time_values, - const vector& yValues); - //#STOP_GRAB_TO_DVS_NAMESPACE }; // namespace dvs