diff --git a/src/App/StringHasher.cpp b/src/App/StringHasher.cpp index 37c1cb1626c2..ff3218d05443 100644 --- a/src/App/StringHasher.cpp +++ b/src/App/StringHasher.cpp @@ -621,7 +621,7 @@ void StringHasher::RestoreDocFile(Base::Reader& reader) void StringHasher::restoreStreamNew(std::istream& stream, std::size_t count) { - Base::ASCIIInputStream asciiStream (stream); + Base::TextInputStream asciiStream (stream); _hashes->clear(); std::string content; boost::io::ios_flags_saver ifs(stream); diff --git a/src/Base/Stream.cpp b/src/Base/Stream.cpp index a62de1a245e8..eb9a8743fb04 100644 --- a/src/Base/Stream.cpp +++ b/src/Base/Stream.cpp @@ -836,7 +836,7 @@ std::streambuf::pos_type Streambuf::seekpos(std::streambuf::pos_type pos, // The custom string handler written by realthunder for the LinkStage3 toponaming code, to handle // reading multi-line strings directly into a std::string. Imported from LinkStage3 and refactored // during the TNP mitigation project in February 2024. -ASCIIInputStream& ASCIIInputStream::operator>>(std::string& outputString) +TextInputStream& TextInputStream::operator>>(std::string& outputString) { uint32_t numberOfLines; char inputChar; diff --git a/src/Base/Stream.h b/src/Base/Stream.h index 7193275fe609..e7bec16d547c 100644 --- a/src/Base/Stream.h +++ b/src/Base/Stream.h @@ -142,38 +142,38 @@ class BaseExport InputStream: public Stream }; /** - * The ASCIIInputStream class provides reading of ASCII data from an istream, with custom handling + * The TextInputStream class provides reading of ASCII data from an istream, with custom handling * for std::string to make it easier to read a single multi-line (or multi-word) string. This is * designed for easy compatibility with the LinkStage3 implementation of the InputStream class, used * to store StringHashers for the toponaming mitigation technique. */ -class BaseExport ASCIIInputStream: public Stream +class BaseExport TextInputStream: public Stream { public: /** Constructor * @param rin: upstream input */ - explicit ASCIIInputStream(std::istream& rin) + explicit TextInputStream(std::istream& rin) : _in(rin) {} - ASCIIInputStream(const ASCIIInputStream&) = delete; + TextInputStream(const TextInputStream&) = delete; - ASCIIInputStream(const ASCIIInputStream&&) noexcept = delete; + TextInputStream(const TextInputStream&&) noexcept = delete; - void operator=(const ASCIIInputStream&) = delete; + void operator=(const TextInputStream&) = delete; - void operator=(const ASCIIInputStream&&) = delete; + void operator=(const TextInputStream&&) = delete; - ~ASCIIInputStream() override = default; + ~TextInputStream() override = default; - ASCIIInputStream& operator>>(bool& input) + TextInputStream& operator>>(bool& input) { _in >> input; return *this; } - ASCIIInputStream& operator>>(int8_t& ch) + TextInputStream& operator>>(int8_t& ch) { int index {}; _in >> index; @@ -181,7 +181,7 @@ class BaseExport ASCIIInputStream: public Stream return *this; } - ASCIIInputStream& operator>>(uint8_t& uch) + TextInputStream& operator>>(uint8_t& uch) { unsigned uns {}; _in >> uns; @@ -189,57 +189,57 @@ class BaseExport ASCIIInputStream: public Stream return *this; } - ASCIIInputStream& operator>>(int16_t& int16) + TextInputStream& operator>>(int16_t& int16) { _in >> int16; return *this; } - ASCIIInputStream& operator>>(uint16_t& us) + TextInputStream& operator>>(uint16_t& us) { _in >> us; return *this; } - ASCIIInputStream& operator>>(int32_t& int32) + TextInputStream& operator>>(int32_t& int32) { _in >> int32; return *this; } - ASCIIInputStream& operator>>(uint32_t& ui) + TextInputStream& operator>>(uint32_t& ui) { _in >> ui; return *this; } - ASCIIInputStream& operator>>(int64_t& int64) + TextInputStream& operator>>(int64_t& int64) { _in >> int64; return *this; } - ASCIIInputStream& operator>>(uint64_t& ul) + TextInputStream& operator>>(uint64_t& ul) { _in >> ul; return *this; } - ASCIIInputStream& operator>>(float& flt) + TextInputStream& operator>>(float& flt) { _in >> flt; return *this; } - ASCIIInputStream& operator>>(double& dbl) + TextInputStream& operator>>(double& dbl) { _in >> dbl; return *this; } - ASCIIInputStream& operator>>(std::string& str); + TextInputStream& operator>>(std::string& str); - ASCIIInputStream& operator>>(char& chr) + TextInputStream& operator>>(char& chr) { chr = (char)_in.get(); return *this; diff --git a/src/Gui/PythonWrapper.cpp b/src/Gui/PythonWrapper.cpp index e6480f8362cc..2c78794a559f 100644 --- a/src/Gui/PythonWrapper.cpp +++ b/src/Gui/PythonWrapper.cpp @@ -157,7 +157,6 @@ constexpr auto &SbkPySide_QtGuiTypes = SbkPySide2_QtGuiTypes; constexpr auto &SbkPySide_QtWidgetsTypes = SbkPySide2_QtWidgetsTypes; constexpr auto &SbkPySide_QtPrintSupportTypes = SbkPySide2_QtPrintSupportTypes; constexpr auto &SbkPySide_QtUiToolsTypes = SbkPySide2_QtUiToolsTypes; -constexpr const char* ModuleShiboken = "shiboken2"; constexpr const char* ModulePySide = "PySide2"; #else PyTypeObject** SbkPySide6_QtCoreTypes = nullptr; @@ -170,7 +169,6 @@ constexpr auto &SbkPySide_QtGuiTypes = SbkPySide6_QtGuiTypes; constexpr auto &SbkPySide_QtWidgetsTypes = SbkPySide6_QtWidgetsTypes; constexpr auto &SbkPySide_QtPrintSupportTypes = SbkPySide6_QtPrintSupportTypes; constexpr auto &SbkPySide_QtUiToolsTypes = SbkPySide6_QtUiToolsTypes; -constexpr const char* ModuleShiboken = "shiboken6"; constexpr const char* ModulePySide = "PySide6"; #endif #else diff --git a/src/Gui/propertyeditor/PropertyEditor.cpp b/src/Gui/propertyeditor/PropertyEditor.cpp index e9aa88ca2d6f..f9dc427a4724 100644 --- a/src/Gui/propertyeditor/PropertyEditor.cpp +++ b/src/Gui/propertyeditor/PropertyEditor.cpp @@ -866,7 +866,11 @@ bool PropertyEditor::eventFilter(QObject* object, QEvent* event) { else if (mouse_event->type() == QEvent::MouseButtonPress && mouse_event->button() == Qt::LeftButton && !dragInProgress) { if (indexResizable(mouse_event->pos()).isValid()) { dragInProgress = true; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) dragPreviousPos = mouse_event->x(); +#else + dragPreviousPos = mouse_event->position().toPoint().x(); +#endif dragSection = indexResizable(mouse_event->pos()).column(); return true; } diff --git a/tests/src/App/Expression.cpp b/tests/src/App/Expression.cpp index 8a7c1a50fb12..fb04c5b3cd45 100644 --- a/tests/src/App/Expression.cpp +++ b/tests/src/App/Expression.cpp @@ -15,7 +15,237 @@ TEST(Expression, tokenize) EXPECT_EQ(App::ExpressionTokenizer().perform(QString::fromUtf8("0.00000 deg"), 11), QString::fromLatin1("deg")); } +TEST(Expression, tokenizeQuantity) +{ + auto result = App::ExpressionParser::tokenize("0.00000 deg"); + EXPECT_EQ(result.size(), 2); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::NUM); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "0.00000"); + EXPECT_EQ(std::get<0>(result[1]), App::ExpressionParser::UNIT); + EXPECT_EQ(std::get<1>(result[1]), 8); + EXPECT_EQ(std::get<2>(result[1]), "deg"); +} + +TEST(Expression, tokenizeFunc) +{ + auto result = App::ExpressionParser::tokenize("sin(0.00000)"); + EXPECT_EQ(result.size(), 3); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::FUNC); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "sin("); + EXPECT_EQ(std::get<0>(result[1]), App::ExpressionParser::NUM); + EXPECT_EQ(std::get<1>(result[1]), 4); + EXPECT_EQ(std::get<2>(result[1]), "0.00000"); + EXPECT_EQ(std::get<1>(result[2]), 11); + EXPECT_EQ(std::get<2>(result[2]), ")"); +} + +TEST(Expression, tokenizeOne) +{ + auto result = App::ExpressionParser::tokenize("1"); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::ONE); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "1"); +} + +TEST(Expression, tokenizeNum) +{ + auto result = App::ExpressionParser::tokenize("1.2341"); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::NUM); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "1.2341"); +} + +TEST(Expression, tokenizeID) +{ + auto result = App::ExpressionParser::tokenize("Something"); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::IDENTIFIER); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "Something"); +} + +TEST(Expression, tokenizeUnit) +{ + auto result = App::ExpressionParser::tokenize("km"); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::UNIT); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "km"); +} + +TEST(Expression, tokenizeUSUnit) +{ + auto result = App::ExpressionParser::tokenize("\""); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::USUNIT); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "\""); +} + +TEST(Expression, tokenizeInt) +{ + auto result = App::ExpressionParser::tokenize("123456"); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::INTEGER); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "123456"); +} + TEST(Expression, tokenizePi) +{ + auto result = App::ExpressionParser::tokenize("pi"); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::CONSTANT); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "pi"); +} + +TEST(Expression, tokenizeE) +{ + auto result = App::ExpressionParser::tokenize("e"); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::CONSTANT); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "e"); +} + +TEST(Expression, tokenizeConstant) +{ + auto result = App::ExpressionParser::tokenize("True False true false None"); + EXPECT_EQ(result.size(), 5); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::CONSTANT); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "True"); + EXPECT_EQ(std::get<0>(result[1]), App::ExpressionParser::CONSTANT); + EXPECT_EQ(std::get<0>(result[2]), App::ExpressionParser::CONSTANT); + EXPECT_EQ(std::get<0>(result[3]), App::ExpressionParser::CONSTANT); + EXPECT_EQ(std::get<0>(result[4]), App::ExpressionParser::CONSTANT); +} + +TEST(Expression, tokenizeEqual) +{ + auto result = App::ExpressionParser::tokenize("=="); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::EQ); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "=="); +} + +TEST(Expression, tokenizeNotEqual) +{ + auto result = App::ExpressionParser::tokenize("!="); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::NEQ); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "!="); +} + +TEST(Expression, tokenizeLessThan) +{ + auto result = App::ExpressionParser::tokenize("<"); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::LT); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "<"); +} + +TEST(Expression, tokenizeLessThanEqual) +{ + auto result = App::ExpressionParser::tokenize("<="); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::LTE); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "<="); +} + +TEST(Expression, tokenizeGreaterThan) +{ + auto result = App::ExpressionParser::tokenize(">"); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::GT); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), ">"); +} + +TEST(Expression, tokenizeGreaterThanEqual) +{ + auto result = App::ExpressionParser::tokenize(">="); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::GTE); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), ">="); +} + +TEST(Expression, tokenizeMinus) +{ + auto result = App::ExpressionParser::tokenize("1-1"); + EXPECT_EQ(result.size(), 3); + EXPECT_EQ(std::get<0>(result[1]), App::ExpressionParser::MINUSSIGN); + EXPECT_EQ(std::get<1>(result[1]), 1); + EXPECT_EQ(std::get<2>(result[1]), "-"); +} + +TEST(Expression, tokenizeCell1) +{ + auto result = App::ExpressionParser::tokenize("$A$12"); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::CELLADDRESS); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "$A$12"); +} + +TEST(Expression, tokenizeCell2) +{ + auto result = App::ExpressionParser::tokenize("A$12"); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::CELLADDRESS); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "A$12"); +} + +TEST(Expression, tokenizeCell3) +{ + auto result = App::ExpressionParser::tokenize("$A12"); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::CELLADDRESS); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "$A12"); +} + +TEST(Expression, tokenizeString) +{ + auto result = App::ExpressionParser::tokenize("<>"); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(std::get<0>(result[0]), App::ExpressionParser::STRING); + EXPECT_EQ(std::get<1>(result[0]), 0); + EXPECT_EQ(std::get<2>(result[0]), "<>"); +} + +TEST(Expression, tokenizeExponent) +{ + // TODO +} + +TEST(Expression, tokenizeNumAndUnit) +{ + // TODO +} + +TEST(Expression, tokenizePos) +{ + // TODO +} + +TEST(Expression, tokenizeNeg) +{ + // TODO +} + +TEST(Expression, tokenizePi_rad) { EXPECT_EQ(App::ExpressionTokenizer().perform(QString::fromLatin1("p"), 1), QString::fromLatin1("p")); EXPECT_EQ(App::ExpressionTokenizer().perform(QString::fromLatin1("pi"), 2), QString());