From e09fac792eb53d6bedd9755f382f061da552bd19 Mon Sep 17 00:00:00 2001 From: rnv Date: Fri, 3 Apr 2015 14:59:40 +0300 Subject: [PATCH] Remove dependency on QScintilla - Use built-in python editor. --- CMakeLists.txt | 23 ++++----- SalomeYACSConfig.cmake.in | 5 +- src/genericgui/CMakeLists.txt | 2 - src/genericgui/EditionPyFunc.cxx | 5 +- src/genericgui/EditionScript.cxx | 75 +++--------------------------- src/genericgui/EditionScript.hxx | 8 ++-- src/genericgui/FormHPContainer.cxx | 22 ++------- src/genericgui/FormHPContainer.hxx | 8 ++-- src/salomegui/CMakeLists.txt | 2 - 9 files changed, 33 insertions(+), 117 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eba3a363d..a4d0ca23f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,8 +96,13 @@ OPTION(SALOME_BUILD_TESTS "Build SALOME YACS tests" ON) OPTION(SALOME_YACS_USE_SWIG "Enable Python wrapper" ON) OPTION(SALOME_YACS_USE_DSC "Use DSC KERNEL extension" ON) -CMAKE_DEPENDENT_OPTION(SALOME_YACS_USE_QSCINTILLA "Use QScintilla" ON - "SALOME_BUILD_GUI" OFF) + +CMAKE_DEPENDENT_OPTION(SALOME_YACS_USE_PYEDITOR "Use built-in py editor" ON + "SALOME_USE_PYVIEWER" OFF) + +IF(SALOME_YACS_USE_PYEDITOR) + ADD_DEFINITIONS(-DHAS_PYEDITOR) +ENDIF(SALOME_YACS_USE_PYEDITOR) # Advanced options: IF(SALOME_YACS_USE_KERNEL AND SALOME_YACS_USE_DSC) @@ -157,13 +162,6 @@ IF(SALOME_BUILD_GUI) FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui) ENDIF(SALOME_BUILD_GUI) -# QScintilla -IF(SALOME_YACS_USE_QSCINTILLA) - FIND_PACKAGE(SalomeQScintilla) - SALOME_LOG_OPTIONAL_PACKAGE(QScintilla SALOME_YACS_USE_QSCINTILLA) - ADD_DEFINITIONS(-DHAS_QSCI4) -ENDIF(SALOME_YACS_USE_QSCINTILLA) - ## ## YACS specifics ## @@ -308,18 +306,17 @@ EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets} SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}") SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}") SET(QT4_ROOT_DIR "${QT4_ROOT_DIR}") -SET(QSCINTILLA_ROOT_DIR "${QSCINTILLA_ROOT_DIR}") SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include") # Build variables that will be expanded when configuring SalomeConfig.cmake: -SALOME_CONFIGURE_PREPARE(QScintilla Qt4) +SALOME_CONFIGURE_PREPARE(Qt4) CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX - KERNEL_ROOT_DIR GUI_ROOT_DIR QT4_ROOT_DIR QSCINTILLA_ROOT_DIR) + KERNEL_ROOT_DIR GUI_ROOT_DIR QT4_ROOT_DIR) # - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?): # Get the relative path of the include directory so @@ -329,7 +326,7 @@ CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in # ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake # INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" # PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX -# KERNEL_ROOT_DIR GUI_ROOT_DIR QT4_ROOT_DIR QSCINTILLA_ROOT_DIR) +# KERNEL_ROOT_DIR GUI_ROOT_DIR QT4_ROOT_DIR) WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake VERSION ${${PROJECT_NAME_UC}_VERSION} diff --git a/SalomeYACSConfig.cmake.in b/SalomeYACSConfig.cmake.in index e7c7a3005..2243e3c50 100644 --- a/SalomeYACSConfig.cmake.in +++ b/SalomeYACSConfig.cmake.in @@ -56,7 +56,7 @@ SET(SALOME_YACS_BUILD_TESTS @SALOME_BUILD_TESTS@) SET(SALOME_YACS_BUILD_GUI @SALOME_BUILD_GUI@) SET(SALOME_YACS_USE_KERNEL @SALOME_YACS_USE_KERNEL@) SET(SALOME_YACS_USE_DSC @SALOME_YACS_USE_DSC@) -SET(SALOME_YACS_USE_QSCINTILLA @SALOME_YACS_USE_QSCINTILLA@) +SET(SALOME_YACS_USE_PYEDITOR @SALOME_YACS_USE_PYEDITOR@) SET(SALOME_YACS_USE_SWIG @SALOME_YACS_USE_SWIG@) # Optional level 1 prerequisites: @@ -80,9 +80,6 @@ ENDIF() IF(SALOME_YACS_BUILD_GUI) SET_AND_CHECK(GUI_ROOT_DIR_EXP "@PACKAGE_GUI_ROOT_DIR@") LIST(APPEND YACS_DEFINITIONS "@GUI_DEFINITIONS@") - IF(SALOME_YACS_USE_QSCINTILLA) - SET_AND_CHECK(QSCINTILLA_ROOT_DIR_EXP "@PACKAGE_QSCINTILLA_ROOT_DIR@") - ENDIF() ENDIF() # For all prerequisites, load the corresponding targets if the package was used diff --git a/src/genericgui/CMakeLists.txt b/src/genericgui/CMakeLists.txt index 52a9d9230..37095fa76 100644 --- a/src/genericgui/CMakeLists.txt +++ b/src/genericgui/CMakeLists.txt @@ -26,7 +26,6 @@ INCLUDE_DIRECTORIES( ${LIBXML2_INCLUDE_DIR} ${GRAPHVIZ_INCLUDE_DIRS} ${QT_INCLUDES} - ${QSCINTILLA_INCLUDE_DIRS} ${KERNEL_INCLUDE_DIRS} ${GUI_INCLUDE_DIRS} ${PROJECT_BINARY_DIR}/src/genericgui @@ -56,7 +55,6 @@ ADD_DEFINITIONS( # libraries to link to SET(_link_LIBRARIES ${QT_LIBRARIES} - ${QSCINTILLA_LIBRARIES} YACSRuntimeSALOME YACSloader SalomeWrap diff --git a/src/genericgui/EditionPyFunc.cxx b/src/genericgui/EditionPyFunc.cxx index 182d1a455..6c4f31960 100644 --- a/src/genericgui/EditionPyFunc.cxx +++ b/src/genericgui/EditionPyFunc.cxx @@ -26,9 +26,8 @@ #include -#if HAS_QSCI4>0 -#include -#include +#ifdef HAS_PYEDITOR +#include #endif #include diff --git a/src/genericgui/EditionScript.cxx b/src/genericgui/EditionScript.cxx index c571a10af..20f33e99b 100644 --- a/src/genericgui/EditionScript.cxx +++ b/src/genericgui/EditionScript.cxx @@ -25,9 +25,9 @@ #include "FormContainer.hxx" #include "Message.hxx" -#if HAS_QSCI4>0 -#include -#include +#ifdef HAS_PYEDITOR +#include +#include #endif #include @@ -46,31 +46,6 @@ using namespace std; using namespace YACS; using namespace YACS::HMI; -#if HAS_QSCI4>0 -class myQsciScintilla: public QsciScintilla -{ -public: - myQsciScintilla(QWidget *parent=0) - : QsciScintilla(parent) {}; - ~myQsciScintilla(){}; - virtual QSize sizeHint() const { return QSize(350, 150); }; -protected: - virtual bool event(QEvent *e); -}; - -bool myQsciScintilla::event(QEvent *e) -{ - if (e->type() == QEvent::ShortcutOverride) - { - e->accept(); - return true; - } - return QsciScintilla::event(e); -} - -#endif - - EditionScript::EditionScript(Subject* subject, QWidget* parent, const char* name) @@ -149,8 +124,8 @@ EditionScript::EditionScript(Subject* subject, setEditablePorts(true); _haveScript = true; -#if HAS_QSCI4>0 - _sci = new myQsciScintilla(this); +#ifdef HAS_PYEDITOR + _sci = new PyEditor_Editor(false, 0, this); #else _sci = new QTextEdit(this); #endif @@ -164,22 +139,6 @@ EditionScript::EditionScript(Subject* subject, } _glayout->addWidget( _sci ); -#if HAS_QSCI4>0 - _sci->setUtf8(1); - QsciLexerPython *lex = new QsciLexerPython(_sci); - lex->setFont(Resource::pythonfont); - _sci->setLexer(lex); - _sci->setBraceMatching(QsciScintilla::SloppyBraceMatch); - _sci->setAutoIndent(1); - _sci->setIndentationWidth(4); - _sci->setIndentationGuides(1); - _sci->setIndentationsUseTabs(0); - _sci->setAutoCompletionThreshold(2); - //_sci->setMarginLineNumbers(1,true); - _sci->setMarginWidth(1,0); - _sci->setFolding(QsciScintilla::PlainFoldStyle); -#endif - if (!QtGuiContext::getQtCurrent()->isEdition()) _sci->setReadOnly(true); @@ -222,8 +181,8 @@ void EditionScript::onApply() { DEBTRACE("EditionScript::onApply"); bool scriptEdited = false; -#if HAS_QSCI4>0 - _sci->lexer()->setFont(Resource::pythonfont); +#ifdef HAS_PYEDITOR + _sci->settings()->p_Font = Resource::pythonfont; #endif if(Resource::pythonExternalEditor.isEmpty()) @@ -240,17 +199,6 @@ void EditionScript::onApply() if (_haveScript) { -#if HAS_QSCI4>0 - if (_sci->isModified()) - { - scriptEdited = true; - std::string text=_sci->text().toStdString(); - if(text[text.length()-1] != '\n') - text=text+'\n'; - bool ret = _subInlineNode->setScript(text); - if (ret) scriptEdited = false; - } -#else if (_sci->document()->isModified()) { scriptEdited = true; @@ -260,7 +208,6 @@ void EditionScript::onApply() bool ret = _subInlineNode->setScript(text); if (ret) scriptEdited = false; } -#endif } bool containerEdited = true; @@ -300,11 +247,7 @@ void EditionScript::onEdit() return; QString fileName = outFile.fileName(); QTextStream out(&outFile); -#if HAS_QSCI4>0 - out << _sci->text(); -#else out << _sci->toPlainText(); -#endif outFile.close(); QStringList options=Resource::pythonExternalEditor.split(" "); @@ -315,11 +258,7 @@ void EditionScript::onEdit() if (!inFile.open(QIODevice::ReadOnly)) return; QTextStream in(&inFile); -#if HAS_QSCI4>0 - _sci->setText(in.readAll()); -#else _sci->setPlainText(in.readAll()); -#endif onApply(); } diff --git a/src/genericgui/EditionScript.hxx b/src/genericgui/EditionScript.hxx index 81d3c2960..bb85add78 100644 --- a/src/genericgui/EditionScript.hxx +++ b/src/genericgui/EditionScript.hxx @@ -28,8 +28,8 @@ class FormContainer; -#if HAS_QSCI4>0 -class QsciScintilla; +#ifdef HAS_PYEDITOR +class PyEditor_Editor; #endif namespace YACS @@ -61,8 +61,8 @@ namespace YACS protected: SubjectInlineNode *_subInlineNode; -#if HAS_QSCI4>0 - QsciScintilla* _sci; +#ifdef HAS_PYEDITOR + PyEditor_Editor* _sci; #else QTextEdit* _sci; #endif diff --git a/src/genericgui/FormHPContainer.cxx b/src/genericgui/FormHPContainer.cxx index 5eed0e356..0731da900 100644 --- a/src/genericgui/FormHPContainer.cxx +++ b/src/genericgui/FormHPContainer.cxx @@ -29,9 +29,8 @@ #include #include -#if HAS_QSCI4>0 -#include -#include +#ifdef HAS_PYEDITOR +#include #endif #include @@ -50,19 +49,8 @@ FormHPContainer::FormHPContainer(QWidget *parent):FormContainerBase(parent),_poo ch_aoc->setEnabled(false); ch_aoc->setCheckState(Qt::Checked); // -#if HAS_QSCI4>0 - _initScript=new QsciScintilla(_advancedParams->tw_advance); - QsciLexerPython *lex(new QsciLexerPython(_initScript)); - lex->setFont(YACS::HMI::Resource::pythonfont); - _initScript->setLexer(lex); - _initScript->setBraceMatching(QsciScintilla::SloppyBraceMatch); - _initScript->setAutoIndent(1); - _initScript->setIndentationWidth(4); - _initScript->setIndentationGuides(1); - _initScript->setIndentationsUseTabs(0); - _initScript->setAutoCompletionThreshold(2); - _initScript->setMarginWidth(1,0); - _initScript->setFolding(QsciScintilla::PlainFoldStyle); +#ifdef HAS_PYEDITOR + _initScript=new PyEditor_Editor(false, 0, _advancedParams->tw_advance); #else _initScript=new QTextEdit(this); #endif @@ -128,7 +116,7 @@ bool FormHPContainer::onApply() std::map properties(_properties); if(_initScriptModified) { - std::string text(_initScript->text().toStdString()); + std::string text(_initScript->toPlainText().toStdString()); std::string text2(BuildWithFinalEndLine(text)); properties[YACS::ENGINE::HomogeneousPoolContainer::INITIALIZE_SCRIPT_KEY]=text2; } diff --git a/src/genericgui/FormHPContainer.hxx b/src/genericgui/FormHPContainer.hxx index 966c7ac86..05aa01b11 100644 --- a/src/genericgui/FormHPContainer.hxx +++ b/src/genericgui/FormHPContainer.hxx @@ -30,8 +30,8 @@ namespace YACS } } -#if HAS_QSCI4>0 -class QsciScintilla; +#ifdef HAS_PYEDITOR +class PyEditor_Editor; #endif class QTextEdit; @@ -54,8 +54,8 @@ public: static std::string BuildWithFinalEndLine(const std::string& script); private: QLineEdit *_poolSz; -#if HAS_QSCI4>0 - QsciScintilla* _initScript; +#ifdef HAS_PYEDITOR + PyEditor_Editor* _initScript; #else QTextEdit* _initScript; #endif diff --git a/src/salomegui/CMakeLists.txt b/src/salomegui/CMakeLists.txt index b7dca0d00..e64460b37 100644 --- a/src/salomegui/CMakeLists.txt +++ b/src/salomegui/CMakeLists.txt @@ -49,7 +49,6 @@ ADD_DEFINITIONS( ${OMNIORB_DEFINITIONS} ${BOOST_DEFINITIONS} ${QT_DEFINITIONS} - ${QSCINTILLA_DEFINITIONS} ${GRAPHVIZ_DEFINITIONS} ) @@ -57,7 +56,6 @@ ADD_DEFINITIONS( SET(_link_LIBRARIES GenericGui ${QT_LIBRARIES} - ${QSCINTILLA_LIBRARIES} ${GUI_Event} ${GUI_SalomeApp} ${GUI_SalomeSession} -- 2.39.2