Salome HOME
Remove dependency on QScintilla V7_6_0a1
authorrnv <rnv@opencascade.com>
Fri, 3 Apr 2015 11:59:40 +0000 (14:59 +0300)
committerrnv <rnv@opencascade.com>
Fri, 3 Apr 2015 11:59:40 +0000 (14:59 +0300)
- Use built-in python editor.

CMakeLists.txt
SalomeYACSConfig.cmake.in
src/genericgui/CMakeLists.txt
src/genericgui/EditionPyFunc.cxx
src/genericgui/EditionScript.cxx
src/genericgui/EditionScript.hxx
src/genericgui/FormHPContainer.cxx
src/genericgui/FormHPContainer.hxx
src/salomegui/CMakeLists.txt

index eba3a363d600481b68716b6700222ea75212f142..a4d0ca23fe21164ec67b5a3b4e7db397ca613b5b 100644 (file)
@@ -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 Salome<MODULE>Config.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}
index e7c7a30050602145f73b6226f334ffbc9ffb8455..2243e3c500a8b5da265cbcd57ec239f727c7e4e6 100644 (file)
@@ -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 
index 52a9d9230cde8424ade675b92383e7c77d853594..37095fa7689f234ff173d1eaac65d3f203068105 100644 (file)
@@ -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
index 182d1a45586e6c4cc3a08911082bc3e9c78576ff..6c4f3196011b00eabd85dd3e45f8814b1c410378 100644 (file)
@@ -26,9 +26,8 @@
 
 #include <QToolButton>
 
-#if HAS_QSCI4>0
-#include <qsciscintilla.h>
-#include <qscilexerpython.h>
+#ifdef HAS_PYEDITOR
+#include <PyEditor_Editor.h>
 #endif
 
 #include <cassert>
index c571a10af5c3fa4aa2b6eb039dd9a0add4fe5aa2..20f33e99b2c0211b2556841b0459a25585b9bf0e 100644 (file)
@@ -25,9 +25,9 @@
 #include "FormContainer.hxx"
 #include "Message.hxx"
 
-#if HAS_QSCI4>0
-#include <qsciscintilla.h>
-#include <qscilexerpython.h>
+#ifdef HAS_PYEDITOR
+#include <PyEditor_Editor.h>
+#include <PyEditor_Settings.h>
 #endif
 
 #include <QToolButton>
@@ -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();
 }
 
index 81d3c29603058b9bd7b20e2d718ae9c87871026f..bb85add78b8ec9187d4286c78218c62561ca2f74 100644 (file)
@@ -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
index 5eed0e356bcb728844bb05833d99e3f3126cc203..0731da9002fc22db6a7b5ae30c2b5ff29d4f9c56 100644 (file)
@@ -29,9 +29,8 @@
 #include <QIntValidator>
 #include <QLineEdit>
 
-#if HAS_QSCI4>0
-#include <qsciscintilla.h>
-#include <qscilexerpython.h>
+#ifdef HAS_PYEDITOR
+#include <PyEditor_Editor.h>
 #endif
 
 #include <sstream>
@@ -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<std::string,std::string> 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;
     }
index 966c7ac868b90257e9ffbbd0b975a583255a3d2b..05aa01b11b994a96f3df7975a040f2b3373df12e 100644 (file)
@@ -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
index b7dca0d00b7bbb1cdde56a96c6288f79e14d72e4..e64460b37f10d6fe45a405c8c39bf7a805e3a6e5 100644 (file)
@@ -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}