From fc8ef8181f9296ce817a26cf6c02a06fb0ebef12 Mon Sep 17 00:00:00 2001 From: stv Date: Wed, 14 Feb 2007 18:02:08 +0000 Subject: [PATCH] no message --- src/LogWindow/LogWindow.cxx | 100 +- src/LogWindow/LogWindow.h | 34 +- src/LogWindow/LogWindow.pro | 23 + src/LogWindow/Makefile.in | 47 - src/PyConsole/PyConsole.h | 59 ++ src/PyConsole/PyConsole.pro | 28 + src/PyConsole/PyConsole_Console.cxx | 186 ++++ src/PyConsole/PyConsole_Console.h | 79 ++ src/PyConsole/PyConsole_Editor.cxx | 1004 +++++++++++++++++++ src/PyConsole/PyConsole_Editor.h | 77 ++ src/PyConsole/PyConsole_Interp.cxx | 118 +++ src/PyConsole/PyConsole_Interp.h | 44 + src/PyConsole/resources/PyConsole_msg_en.ts | 26 + src/PyInterp/Makefile.in | 51 - src/PyInterp/PyInterp.h | 26 +- src/PyInterp/PyInterp.pro | 23 + src/PyInterp/PyInterp_Dispatcher.cxx | 20 +- src/PyInterp/PyInterp_Dispatcher.h | 10 +- src/PyInterp/PyInterp_Watcher.h | 6 +- src/PyInterp/PyInterp_base.cxx | 7 +- src/PyInterp/PyInterp_base.h | 2 +- src/STD/Makefile.in | 86 -- src/STD/STD.pro | 30 + src/STD/STD_LoadStudiesDlg.cxx | 84 -- src/STD/STD_LoadStudiesDlg.h | 70 -- src/STD/STD_MDIDesktop.cxx | 54 +- src/STD/STD_MDIDesktop.h | 16 +- src/STD/STD_SDIDesktop.cxx | 51 +- src/STD/STD_SDIDesktop.h | 8 +- src/STD/STD_TabDesktop.cxx | 57 +- src/STD/STD_TabDesktop.h | 14 +- src/STD/resources/STD_images.po | 94 -- src/STD/resources/STD_images.ts | 106 ++ src/STD/resources/STD_msg_en.po | 379 ------- src/STD/resources/STD_msg_en.ts | 480 +++++++++ src/STD/resources/config | 1 - src/SUIT/SUIT.pro | 30 + src/SUIT/resources/SUIT_images.po | 38 - src/SUIT/resources/SUIT_images.ts | 17 + src/SUIT/resources/SUIT_msg_en.po | 118 --- src/SUIT/resources/SUIT_msg_en.ts | 141 +++ 41 files changed, 2702 insertions(+), 1142 deletions(-) create mode 100644 src/LogWindow/LogWindow.pro delete mode 100755 src/LogWindow/Makefile.in create mode 100644 src/PyConsole/PyConsole.h create mode 100644 src/PyConsole/PyConsole.pro create mode 100644 src/PyConsole/PyConsole_Console.cxx create mode 100644 src/PyConsole/PyConsole_Console.h create mode 100644 src/PyConsole/PyConsole_Editor.cxx create mode 100644 src/PyConsole/PyConsole_Editor.h create mode 100644 src/PyConsole/PyConsole_Interp.cxx create mode 100644 src/PyConsole/PyConsole_Interp.h create mode 100644 src/PyConsole/resources/PyConsole_msg_en.ts delete mode 100755 src/PyInterp/Makefile.in create mode 100644 src/PyInterp/PyInterp.pro delete mode 100755 src/STD/Makefile.in create mode 100644 src/STD/STD.pro delete mode 100644 src/STD/STD_LoadStudiesDlg.cxx delete mode 100644 src/STD/STD_LoadStudiesDlg.h delete mode 100755 src/STD/resources/STD_images.po create mode 100644 src/STD/resources/STD_images.ts delete mode 100755 src/STD/resources/STD_msg_en.po create mode 100644 src/STD/resources/STD_msg_en.ts delete mode 100755 src/STD/resources/config create mode 100644 src/SUIT/SUIT.pro delete mode 100755 src/SUIT/resources/SUIT_images.po create mode 100644 src/SUIT/resources/SUIT_images.ts delete mode 100755 src/SUIT/resources/SUIT_msg_en.po create mode 100644 src/SUIT/resources/SUIT_msg_en.ts diff --git a/src/LogWindow/LogWindow.cxx b/src/LogWindow/LogWindow.cxx index 161011c45..2c0669ea8 100755 --- a/src/LogWindow/LogWindow.cxx +++ b/src/LogWindow/LogWindow.cxx @@ -21,13 +21,15 @@ #include "LogWindow.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include +#include +#include #include #include @@ -42,15 +44,18 @@ static QString plainText( const QString& richText ) { QString aText = richText; - int startTag = aText.find('<'); - while ( 1 ) { + int startTag = aText.indexOf( '<' ); + while ( true ) + { if ( startTag < 0 ) break; - int finishTag = aText.find('>',startTag); - if (finishTag < 0) + + int finishTag = aText.indexOf( '>', startTag ); + if ( finishTag < 0 ) break; - aText = aText.remove(startTag, finishTag-startTag+1); - startTag = aText.find('<'); + + aText = aText.remove( startTag, finishTag - startTag + 1 ); + startTag = aText.indexOf( '<' ); } return aText; } @@ -60,7 +65,8 @@ static QString plainText( const QString& richText ) */ LogWindow::LogWindow( QWidget* parent ) : QFrame( parent ), -SUIT_PopupClient() +SUIT_PopupClient(), +myOpFlags( All ) { SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); @@ -68,13 +74,12 @@ SUIT_PopupClient() setFont( SUIT_Tools::stringToFont( fntSet ) ); - myView = new QTextBrowser(this,"myView"); -#if QT_VERSION>0x030007 - myView->setTextFormat( Qt::LogText ); -#endif + myView = new QTextEdit( this ); + myView->setReadOnly( true ); myView->viewport()->installEventFilter( this ); QVBoxLayout* main = new QVBoxLayout( this ); + main->setMargin( 5 ); main->addWidget( myView ); myBannerSize = 0; @@ -143,7 +148,7 @@ void LogWindow::putMessage( const QString& message, bool addSeparator ) myView->append( mySeparator ); // add separator myHistory.append( plainText( mySeparator ) ); } - myView->scrollToBottom(); + myView->moveCursor( QTextCursor::End ); } /*! @@ -159,7 +164,7 @@ void LogWindow::clear( bool clearHistory ) if ( !myBanner.isEmpty() ) { myView->append( myBanner ); - myBannerSize = myView->paragraphs(); + myBannerSize = myView->document()->blockCount(); } else myBannerSize = 0; @@ -172,7 +177,7 @@ void LogWindow::clear( bool clearHistory ) bool LogWindow::saveLog( const QString& fileName ) { QFile file( fileName ); - if ( !file.open( IO_WriteOnly ) ) + if ( !file.open( QFile::WriteOnly ) ) return false; QTextStream stream( &file ); @@ -195,42 +200,48 @@ bool LogWindow::saveLog( const QString& fileName ) */ void LogWindow::createActions() { - QAction* a = new QAction( "", tr( "&Copy" ), 0, this ); + QAction* a = new QAction( tr( "&Copy" ), this ); a->setStatusTip( tr( "&Copy" ) ); - connect( a, SIGNAL( activated() ), SLOT( onCopy())); + connect( a, SIGNAL( triggered( bool ) ), SLOT( onCopy() ) ); myActions.insert( CopyId, a ); - a = new QAction( "", tr( "Clea&r" ), 0, this ); + a = new QAction( tr( "Clea&r" ), this ); a->setStatusTip( tr( "Clea&r" ) ); - connect( a, SIGNAL( activated() ), SLOT( onClear())); + connect( a, SIGNAL( triggered( bool ) ), SLOT( onClear() ) ); myActions.insert( ClearId, a ); - a = new QAction( "", tr( "Select &All" ), 0, this ); + a = new QAction( tr( "Select &All" ), this ); a->setStatusTip( tr( "Select &All" ) ); - connect( a, SIGNAL( activated() ), SLOT( onSelectAll())); + connect( a, SIGNAL( triggered( bool ) ), SLOT( onSelectAll() ) ); myActions.insert( SelectAllId, a ); - a = new QAction( "", tr( "&Save log to file..." ), 0, this ); + a = new QAction( tr( "&Save log to file..." ), this ); a->setStatusTip( tr( "&Save log to file..." ) ); - connect( a, SIGNAL( activated() ), SLOT( onSaveToFile())); + connect( a, SIGNAL( triggered( bool ) ), SLOT( onSaveToFile() ) ); myActions.insert( SaveToFileId, a ); } /*! Redefined virtual method for popup filling */ -void LogWindow::contextMenuPopup( QPopupMenu* popup ) +void LogWindow::contextMenuPopup( QMenu* popup ) { - myActions[ CopyId ]->addTo( popup ); - myActions[ ClearId ]->addTo( popup ); + if ( myOpFlags & CopyId ) + popup->addAction( myActions[ CopyId ] ); + if ( myOpFlags & ClearId ) + popup->addAction( myActions[ ClearId ] ); - popup->insertSeparator(); + popup->addSeparator(); - myActions[ SelectAllId ]->addTo( popup ); + if ( myOpFlags & SelectAllId ) + popup->addAction( myActions[ SelectAllId ] ); - popup->insertSeparator(); + popup->addSeparator(); - myActions[ SaveToFileId ]->addTo( popup ); + if ( myOpFlags & SaveToFileId ) + popup->addAction( myActions[ SaveToFileId ] ); + + Qtx::simplifySeparators( popup ); updateActions(); } @@ -240,15 +251,17 @@ void LogWindow::contextMenuPopup( QPopupMenu* popup ) */ void LogWindow::updateActions() { +/* int paraFrom, paraTo, indexFrom, indexTo; myView->getSelection( ¶From, &indexFrom, ¶To, &indexTo ); bool allSelected = myView->hasSelectedText() && !paraFrom && paraTo == myView->paragraphs() - 1 && !indexFrom && indexTo == myView->paragraphLength( paraTo ); - myActions[ CopyId ]->setEnabled( myView->hasSelectedText() ); - myActions[ ClearId ]->setEnabled( myView->paragraphs() > myBannerSize ); - myActions[ SelectAllId ]->setEnabled( !allSelected ); - myActions[ SaveToFileId ]->setEnabled( myHistory.count() > 0 ); + myActions[ CopyId ]->setEnabled( ( myOpFlags & CopyId )&& myView->hasSelectedText() ); + myActions[ ClearId ]->setEnabled( ( myOpFlags & ClearId ) && myView->document()->blockCount() > myBannerSize ); + myActions[ SelectAllId ]->setEnabled( ( myOpFlags & SelectAllId ) && !allSelected ); + myActions[ SaveToFileId ]->setEnabled( ( myOpFlags & SaveToFileId ) && myHistory.count() > 0 ); +*/ } /*! @@ -265,7 +278,7 @@ void LogWindow::onSaveToFile() if ( aName.isNull() ) return; - QApplication::setOverrideCursor( Qt::waitCursor ); + QApplication::setOverrideCursor( Qt::WaitCursor ); bool bOk = saveLog( aName ); @@ -300,3 +313,8 @@ void LogWindow::onCopy() if ( myView ) myView->copy(); } + +void LogWindow::setOperationsFlags( int flags ) +{ + myOpFlags = flags; +} diff --git a/src/LogWindow/LogWindow.h b/src/LogWindow/LogWindow.h index 0b8b39e98..17460b3bc 100755 --- a/src/LogWindow/LogWindow.h +++ b/src/LogWindow/LogWindow.h @@ -42,15 +42,17 @@ #include -#include -#include +#include +#include + +#include #ifdef WIN32 #pragma warning( disable:4251 ) #endif class QAction; -class QTextBrowser; +class QTextEdit; /*! \class LogWindow @@ -60,16 +62,25 @@ class LOGWINDOW_EXPORT LogWindow : public QFrame, public SUIT_PopupClient { Q_OBJECT - enum { CopyId, ClearId, SelectAllId, SaveToFileId }; +public: + //! popup operation flags + enum + { + CopyId = 0x01, + ClearId = 0x02, + SelectAllId = 0x04, + SaveToFileId = 0x08, + All = CopyId | ClearId | SelectAllId | SaveToFileId, + }; public: - LogWindow( QWidget* theParent ); - virtual ~LogWindow(); + LogWindow( QWidget* theParent ); + virtual ~LogWindow(); virtual QString popupClientType() const { return QString( "LogWindow" ); } - virtual void contextMenuPopup( QPopupMenu* ); + virtual void contextMenuPopup( QMenu* ); - bool eventFilter( QObject* o, QEvent* e ); + virtual bool eventFilter( QObject* o, QEvent* e ); void setBanner( const QString& banner ); void setSeparator( const QString& separator ); @@ -79,6 +90,8 @@ public: bool saveLog( const QString& fileName ); + void setOperationsFlags( int flags ); + protected slots: void onSaveToFile(); void onSelectAll(); @@ -90,12 +103,13 @@ private: void updateActions(); private: - QTextBrowser* myView; + QTextEdit* myView; QString myBanner; - QString mySeparator; QStringList myHistory; + QString mySeparator; int myBannerSize; QMap myActions; + int myOpFlags; }; #ifdef WIN32 diff --git a/src/LogWindow/LogWindow.pro b/src/LogWindow/LogWindow.pro new file mode 100644 index 000000000..40ec097b8 --- /dev/null +++ b/src/LogWindow/LogWindow.pro @@ -0,0 +1,23 @@ +TEMPLATE = lib +DESTDIR = ../../lib +MOC_DIR = ../../moc +OBJECTS_DIR = ../../obj/$$TARGET + +INCLUDEPATH = ../../include +win32:LIBS += ../../lib/suit.lib ../../lib/qtx.lib +unix:LIBS += -L../../lib -lSUIT -lQtx + +CONFIG -= debug release debug_and_release +CONFIG += qt thread debug dll shared + +win32:DEFINES += WIN32 +DEFINES += LOGWINDOW_EXPORTS + +HEADERS = *.h + +SOURCES = *.cxx + +includes.files = $$HEADERS +includes.path = ../../include + +INSTALLS += includes diff --git a/src/LogWindow/Makefile.in b/src/LogWindow/Makefile.in deleted file mode 100755 index d868371af..000000000 --- a/src/LogWindow/Makefile.in +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# File : Makefile.in -# Author : Vladimir Klyachin (OCN) -# Module : LogWindow -# $Header$ - -top_srcdir=@top_srcdir@ -top_builddir=../.. -srcdir=@srcdir@ -VPATH=.:@srcdir@ - -@COMMENCE@ - -# header files -EXPORT_HEADERS= LogWindow.h - -# Libraries targets -LIB = libLogWindow.la - -LIB_SRC= LogWindow.cxx - -LIB_MOC = LogWindow.h - -CPPFLAGS+=$(QT_INCLUDES) - -LDFLAGS+=$(QT_MT_LIBS) - -@CONCLUDE@ - - diff --git a/src/PyConsole/PyConsole.h b/src/PyConsole/PyConsole.h new file mode 100644 index 000000000..10a7106f6 --- /dev/null +++ b/src/PyConsole/PyConsole.h @@ -0,0 +1,59 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#if !defined ( _PYTHONCONSOLE_H ) +#define _PYTHONCONSOLE_H + +// ======================================================== +// set dllexport type for Win platform +#ifdef WIN32 + +#ifdef PYCONSOLE_EXPORTS +#define PYCONSOLE_EXPORT __declspec(dllexport) +#else +#define PYCONSOLE_EXPORT __declspec(dllimport) +#endif + +#else // WIN32 + +#define PYCONSOLE_EXPORT + +#endif // WIN32 + +// ======================================================== +// little trick - we do not have debug python libraries +#ifdef _DEBUG + +#undef _DEBUG +//#include +#define _DEBUG + +#else // _DEBUG + +//#include + +#endif // _DEBUG + +// ======================================================== +// avoid warning messages +#ifdef WIN32 +#pragma warning (disable : 4786) +#pragma warning (disable : 4251) +#endif + +#endif // _PYTHONCONSOLE_H diff --git a/src/PyConsole/PyConsole.pro b/src/PyConsole/PyConsole.pro new file mode 100644 index 000000000..d5b0cda93 --- /dev/null +++ b/src/PyConsole/PyConsole.pro @@ -0,0 +1,28 @@ +TEMPLATE = lib +DESTDIR = ../../lib +MOC_DIR = ../../moc +OBJECTS_DIR = ../../obj/$$TARGET + +INCLUDEPATH += ../../include $$(PYTHONINC) +unix:LIBS += -L../../lib -L$$(PYTHONLIB) -lpython2.3 -lSUIT -lPyInterp +win32:LIBS += /LIBPATH:$$(PYTHONLIB) ../../lib/pyinterp.lib ../../lib/suit.lib + +CONFIG -= debug release debug_and_release +CONFIG += qt thread debug dll shared + +win32:DEFINES += WIN32 +DEFINES += PYCONSOLE_EXPORTS + +HEADERS = *.h + +SOURCES = *.cxx + +TRANSLATIONS = resources/PyConsole_msg_en.ts + +includes.files = $$HEADERS +includes.path = ../../include + +resources.files = resources/*.qm +resources.path = ../../resources + +INSTALLS += includes resources diff --git a/src/PyConsole/PyConsole_Console.cxx b/src/PyConsole/PyConsole_Console.cxx new file mode 100644 index 000000000..c7711b928 --- /dev/null +++ b/src/PyConsole/PyConsole_Console.cxx @@ -0,0 +1,186 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : PythonConsole_PyConcole.cxx +// Author : Vadim SANDLER +// Module : SALOME + +/*! + \class PythonConsole + \brief Python console widget. +*/ + +#include + +#include "PyConsole_Console.h" +#include "PyConsole_Editor.h" + +#include + +#include +#include +#include +#include +#include +#include + +using namespace std; + +/*! + \brief Constructor. + + Creates new python console widget. + \param parent parent widget + \param interp python interpreter +*/ +PythonConsole::PythonConsole( QWidget* parent, PyInterp_base* interp ) +: QFrame( parent ), +myEditor( 0 ) +{ + // create python interpreter + myInterp = interp; + if ( !myInterp ) + myInterp = new PyConsole_Interp(); + + // initialize Python interpretator + myInterp->initialize(); + + // create editor console + QVBoxLayout* lay = new QVBoxLayout( this ); + lay->setMargin( 5 ); + myEditor = new PyConsole_Editor( myInterp, this ); + myEditor->viewport()->installEventFilter( this ); + lay->addWidget( myEditor ); + + createActions(); +} + +/*! + \brief Destructor. + + Does nothing for the moment. +*/ +PythonConsole::~PythonConsole() +{ +} + +/*! + \brief Execute python command in the interpreter. + \param command - string with command and arguments +*/ +void PythonConsole::exec( const QString& command ) +{ + if ( myEditor ) + myEditor->exec( command ); +} + +/*! + \brief Execute python command in the interpreter + and wait until it is finished. + + Block execution of main application until the python command is executed. + \param command - string with command and arguments +*/ +void PythonConsole::execAndWait( const QString& command ) +{ + if ( myEditor ) + myEditor->execAndWait( command ); +} + +/*! + \brief Change the python console's font. + \param f - new font +*/ +void PythonConsole::setFont( const QFont& f ) +{ + if( myEditor ) + myEditor->setFont( f ); +} + +/*! + \brief Get python console font. + \return current python console's font +*/ +QFont PythonConsole::font() const +{ + QFont res; + if( myEditor ) + res = myEditor->font(); + return res; +} + +/*! + Custom event handler +*/ +bool PythonConsole::eventFilter( QObject* o, QEvent* e ) +{ + if ( o == myEditor->viewport() && e->type() == QEvent::ContextMenu ) + { + contextMenuRequest( (QContextMenuEvent*)e ); + return true; + } + return QFrame::eventFilter( o, e ); +} + +/*! + \brief Process context popup menu event. + + Show popup menu which includes standard copy/paste operations. + \param event context menu event +*/ +void PythonConsole::contextMenuPopup( QMenu* menu ) +{ + if ( myEditor->isReadOnly() ) + return; + + updateActions(); + + menu->addAction( myActions[CopyId] ); + menu->addAction( myActions[PasteId] ); + menu->addAction( myActions[ClearId] ); + + menu->addSeparator(); + + menu->addAction( myActions[SelectAllId] ); +} + +void PythonConsole::createActions() +{ + QAction* copyAction = new QAction( tr( "EDIT_COPY_CMD" ), this ); + connect( copyAction, SIGNAL( triggered( bool ) ), myEditor, SLOT( copy() ) ); + myActions.insert( CopyId, copyAction ); + + QAction* pasteAction = new QAction( tr( "EDIT_PASTE_CMD" ), this ); + connect( pasteAction, SIGNAL( triggered( bool ) ), myEditor, SLOT( paste() ) ); + myActions.insert( PasteId, pasteAction ); + + QAction* clearAction = new QAction( tr( "EDIT_CLEAR_CMD" ), this ); + connect( clearAction, SIGNAL( triggered( bool ) ), myEditor, SLOT( clear() ) ); + myActions.insert( ClearId, clearAction ); + + QAction* selAllAction = new QAction( tr( "EDIT_SELECTALL_CMD" ), this ); + connect( selAllAction, SIGNAL( triggered( bool ) ), myEditor, SLOT( selectAll() ) ); + myActions.insert( SelectAllId, selAllAction ); +} + +void PythonConsole::updateActions() +{ + myActions[CopyId]->setEnabled( myEditor->textCursor().hasSelection() ); + myActions[PasteId]->setEnabled( !myEditor->isReadOnly() && !QApplication::clipboard()->text().isEmpty() ); + myActions[SelectAllId]->setEnabled( !myEditor->document()->isEmpty() ); +} diff --git a/src/PyConsole/PyConsole_Console.h b/src/PyConsole/PyConsole_Console.h new file mode 100644 index 000000000..3d07a595e --- /dev/null +++ b/src/PyConsole/PyConsole_Console.h @@ -0,0 +1,79 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : PythonConsole_PyConsole.h +// Author : Vadim SANDLER +// Module : SALOME + +#ifndef PYCONSOLE_CONSOLE_H +#define PYCONSOLE_CONSOLE_H + +#include "PyConsole.h" + +#include +#include + +#include + +class PyInterp_base; +class PyConsole_Editor; + +class PYCONSOLE_EXPORT PythonConsole : public QFrame, public SUIT_PopupClient +{ + Q_OBJECT + +public: + enum + { + CopyId = 0x01, + PasteId = 0x02, + ClearId = 0x04, + SelectAllId = 0x08, + All = CopyId | PasteId | ClearId | SelectAllId + }; + +public: + PythonConsole( QWidget* parent, PyInterp_base* interp = 0 ); + virtual ~PythonConsole(); + + //! \brief Get python interperter + PyInterp_base* getInterp() { return myInterp; } + QFont font() const; + virtual void setFont( const QFont& ); + + void exec( const QString& command ); + void execAndWait( const QString& command ); + + virtual bool eventFilter( QObject* o, QEvent* e ); + + virtual QString popupClientType() const { return QString( "PyConsole" ); } + virtual void contextMenuPopup( QMenu* ); + +private: + void createActions(); + void updateActions(); + +private: + PyInterp_base* myInterp; //!< python interpreter + PyConsole_Editor* myEditor; //!< python console editor widget + QMap myActions; +}; + + + +#endif diff --git a/src/PyConsole/PyConsole_Editor.cxx b/src/PyConsole/PyConsole_Editor.cxx new file mode 100644 index 000000000..c5a371c86 --- /dev/null +++ b/src/PyConsole/PyConsole_Editor.cxx @@ -0,0 +1,1004 @@ +// SALOME SALOMEGUI : implementation of desktop and GUI kernel +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : PyConsole_Editor.cxx +// Author : Vadim SANDLER +// Module : SALOME + +/*! + \class PyConsole_Editor + \brief Python command line interpreter front-end GUI widget. + + This class provides simple GUI interface to the Python interpreter, including basic + navigation operations, executing commands (both interactively and programmatically), + copy-paste operations, history of the commands and so on. + + Here below is the shortcut keyboard boundings used for navigation and other operations: + - : execute current command + - : clear current command + - : clear current command + - : previous command in the history + - : move cursor one row up with selection + - : move cursor one row up without selection + - : move cursor one row up with selection + - : next command in the history + - : move cursor one row down with selection + - : move cursor one row down without selection + - : move cursor one row down with selection + - : move one symbol left without selection + - : move one symbol left with selection + - : move one word left without selection + - : move one word left with selection + - : move one symbol right without selection + - : move one symbol right with selection + - : move one word right without selection + - : move one word right with selection + - : first command in the history + - : move one page up with selection + - : move one page up without selection + - : scroll one page up + - : last command in the history + - : move one page down with selection + - : move one page down without selection + - : scroll one page down + - : move to the beginning of the line without selection + - : move to the beginning of the line with selection + - : move to the very first symbol without selection + - : move to the very first symbol with selection + - : move to the end of the line without selection + - : move to the end of the line with selection + - : move to the very last symbol without selection + - : move to the very last symbol with selection + - : delete symbol before the cursor + / remove selected text and put it to the clipboard (cut) + - : delete previous word + / remove selected text and put it to the clipboard (cut) + - : delete text from the cursor to the beginning of the line + / remove selected text and put it to the clipboard (cut) + - : delete symbol after the cursor + / remove selected text and put it to the clipboard (cut) + - : delete next word + / remove selected text and put it to the clipboard (cut) + - : delete text from the cursor to the end of the line + / remove selected text and put it to the clipboard (cut) + - : copy + - : paste + - : paste + - : copy + - : cut + - : paste + + TODO: + - paste multiline text: process each line as separate command + (including mouse middle-button click pasting) + - the same for drag-n-drop of multiline text +*/ + +#include "PyConsole_Editor.h" // this include must be first (see PyInterp_base.h)! + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +static QString READY_PROMPT = ">>> "; +static QString DOTS_PROMPT = "... "; +#define PROMPT_SIZE myPrompt.length() + +/*! + \class ExecCommand + \brief Python command execution request [internal]. + */ +class ExecCommand : public PyInterp_LockRequest +{ +public: + /*! + \brief Constructor. + + Creates new python command execution request. + \param theInterp python interpreter + \param theCommand python command + \param theListener widget to get the notification messages + \param sync if True the request is processed synchronously + */ + ExecCommand( PyInterp_base* theInterp, + const char* theCommand, + PyConsole_Editor* theListener, + bool sync = false ) + : PyInterp_LockRequest( theInterp, theListener, sync ), + myCommand( theCommand ), myState( PyInterp_Event::OK ) + {} + +protected: + /*! + \brief Execute the python command in the interpreter and + get its execution status. + */ + virtual void execute() + { + if ( myCommand != "" ) + { +// SUIT_Session::SetPythonExecuted( true ); // disable GUI user actions + int ret = getInterp()->run( myCommand.toLatin1() ); +// SUIT_Session::SetPythonExecuted(false); // enable GUI user actions + if ( ret < 0 ) + myState = PyInterp_Event::ERROR; + else if ( ret > 0 ) + myState = PyInterp_Event::INCOMPLETE; + myError = getInterp()->getverr().c_str(); + myOutput = getInterp()->getvout().c_str(); + } + else + { + myError = ""; + myOutput = ""; + } + } + + /*! + \brief Create and return a notification event. + \return new notification event + */ + virtual QEvent* createEvent() const + { + return new PyInterp_Event( myState, (PyInterp_Request*)this ); + } + +public: + QString myError; //!< Python command error message + QString myOutput; //!< Python command output log + +private: + QString myCommand; //!< Python command + int myState; //!< Python command execution status +}; + +/*! + \brief Constructor. + + Creates python editor window. + \param theInterp python interper + \param theParent parent widget +*/ +PyConsole_Editor::PyConsole_Editor( PyInterp_base* theInterp, + QWidget* theParent ) + : QTextEdit( theParent ), + myInterp( 0 ), + myCmdInHistory( -1 ), + myEventLoop( 0 ) +{ + QString fntSet( "" ); + QFont aFont = SUIT_Tools::stringToFont( fntSet ); + setFont( aFont ); + setUndoRedoEnabled( false ); + + myPrompt = READY_PROMPT; + setLineWrapMode( QTextEdit::NoWrap ); + setWordWrapMode( QTextOption::NoWrap ); + setAcceptRichText( false ); + + // san - This is necessary for troubleless initialization + onPyInterpChanged( theInterp ); +} + +/*! + \brief Destructor. + + Does nothing for the moment. +*/ +PyConsole_Editor::~PyConsole_Editor() +{ +} + +/*! + \brief Put the string \a str to the python editor. + \param str string to be put in the command line of the editor + \param newBlock if True, then the string is printed on a new line +*/ +void PyConsole_Editor::addText( const QString& str, + const bool newBlock ) +{ + moveCursor( QTextCursor::End ); + if ( newBlock ) + textCursor().insertBlock(); + textCursor().insertText( str ); + moveCursor( QTextCursor::End ); + ensureCursorVisible(); +} + +/*! + \brief Convenient method for executing a Python command, + as if the user typed it manually. + \param command python command to be executed +*/ +void PyConsole_Editor::exec( const QString& command ) +{ + if ( isReadOnly() ) { + // some interactive command is being executed in this editor... + // shedule the command to the queue + myQueue.push_back( command ); + return; + } + // remove last line + moveCursor( QTextCursor::End ); + moveCursor( QTextCursor::StartOfBlock, QTextCursor::KeepAnchor ); + textCursor().removeSelectedText(); + // set "ready" prompt + myPrompt = READY_PROMPT; + // clear command buffer + myCommandBuffer.truncate( 0 ); + // unset history browsing mode + myCmdInHistory = -1; + // print command line by line + QString cmd = command; + if ( !cmd.endsWith( "\n" ) ) cmd += "\n"; + QStringList lines = command.split( "\n" ); + for ( int i = 0; i < lines.size(); i++ ) { + if ( !lines[i].trimmed().isEmpty() ) + myHistory.push_back( lines[i] ); + addText( ( i == 0 ? READY_PROMPT : DOTS_PROMPT ) + lines[i], i != 0 ); + } + // set read-only mode + setReadOnly( true ); + // set busy cursor + setCursor( Qt::BusyCursor ); + + // post a request to execute Python command; + // editor will be informed via a custom event that execution has been completed + PyInterp_Dispatcher::Get()->Exec( new ExecCommand( myInterp, + cmd.toLatin1(), + this ) ); +} + +/*! + \brief Execute command in the python interpreter + and wait until it is finished. + \param command python command to be executed + */ +void PyConsole_Editor::execAndWait( const QString& command ) +{ + // already running ? + if( myEventLoop ) + return; + + // create new event loop + myEventLoop = new QEventLoop( this ); + // execute command + exec( command ); + // run event loop + myEventLoop->exec(); + // delete event loop after command is processed + delete myEventLoop; + myEventLoop = 0; +} + +/*! + \brief Process "Enter" key press event. + + Execute the command entered by the user. +*/ +void PyConsole_Editor::handleReturn() +{ + // get last line + QTextBlock par = document()->end().previous(); + if ( !par.isValid() ) return; + + // get command + QString cmd = par.text().remove( 0, PROMPT_SIZE ); + // extend the command buffer with the current command + myCommandBuffer.append( cmd ); + // add command to the history + if ( !cmd.trimmed().isEmpty() ) + myHistory.push_back( cmd ); + + // set read-only mode + setReadOnly( true ); + // set busy cursor + setCursor( Qt::BusyCursor ); + + // post a request to execute Python command; + // editor will be informed via a custom event that execution has been completed + PyInterp_Dispatcher::Get()->Exec( new ExecCommand( myInterp, + myCommandBuffer.toLatin1(), + this ) ); +} + +/*! + \brief Process drop event. + + Paste dragged text. + \param event drop event +*/ +void PyConsole_Editor::dropEvent( QDropEvent* event ) +{ + // get the initial drop position + QPoint pos = event->pos(); + QTextCursor cur = cursorForPosition( event->pos() ); + // if the position is not in the last line move it to the end of the command line + if ( cur.position() < document()->end().previous().position() + PROMPT_SIZE ) { + moveCursor( QTextCursor::End ); + pos = cursorRect().center(); + } + // create new drop event and use it instead of the original + QDropEvent de( pos, + event->possibleActions(), + event->mimeData(), + event->mouseButtons(), + event->keyboardModifiers(), + event->type() ); + QTextEdit::dropEvent( &de ); + // accept the original event + event->acceptProposedAction(); +} + +/*! + \brief Process mouse button release event. + + Left mouse button: copy selection to the clipboard. + Middle mouse button: paste clipboard's contents. + \param event mouse event +*/ +void PyConsole_Editor::mouseReleaseEvent( QMouseEvent* event ) +{ + if ( event->button() == Qt::LeftButton ) { + QTextEdit::mouseReleaseEvent( event ); + copy(); + } + else if ( event->button() == Qt::MidButton ) { + QString text; + if ( QApplication::clipboard()->supportsSelection() ) + text = QApplication::clipboard()->text( QClipboard::Selection ); + if ( text.isEmpty() ) + text = QApplication::clipboard()->text( QClipboard::Clipboard ); + QTextCursor cur = cursorForPosition( event->pos() ); + // if the position is not in the last line move it to the end of the command line + if ( cur.position() < document()->end().previous().position() + PROMPT_SIZE ) { + moveCursor( QTextCursor::End ); + } + else { + setTextCursor( cur ); + } + textCursor().clearSelection(); + textCursor().insertText( text ); + } + else { + QTextEdit::mouseReleaseEvent( event ); + } +} + +/*! + \brief Check if the string is command. + + Return True if the string \a str is likely to be the command + (i.e. it is started from the '>>>' or '...'). + \param str string to be checked +*/ +bool PyConsole_Editor::isCommand( const QString& str ) const +{ + return str.startsWith( READY_PROMPT ) || str.startsWith( DOTS_PROMPT ); +} + +/*! + \brief Handle keyboard event. + + Implement navigation, history browsing, copy/paste and other common + operations. + \param event keyboard event +*/ +void PyConsole_Editor::keyPressEvent( QKeyEvent* event ) +{ + // get cursor position + QTextCursor cur = textCursor(); + int curLine = cur.blockNumber(); + int curCol = cur.columnNumber(); + + // get last edited line + int endLine = document()->blockCount()-1; + + // get pressed key code + int aKey = event->key(); + + // check if is pressed + bool ctrlPressed = event->modifiers() & Qt::ControlModifier; + // check if is pressed + bool shftPressed = event->modifiers() & Qt::ShiftModifier; + + if ( aKey == Qt::Key_Escape || ctrlPressed && aKey == -1 ) { + // process + key-binding and key: clear current command + myCommandBuffer.truncate( 0 ); + myPrompt = READY_PROMPT; + addText( myPrompt, true ); + horizontalScrollBar()->setValue( horizontalScrollBar()->minimum() ); + return; + } + else if ( ctrlPressed && aKey == Qt::Key_C ) { + // process + key-binding : copy + copy(); + return; + } + else if ( ctrlPressed && aKey == Qt::Key_X ) { + // process + key-binding : cut + cut(); + return; + } + else if ( ctrlPressed && aKey == Qt::Key_V ) { + // process + key-binding : paste + paste(); + return; + } + + // check for printed key + aKey = ( aKey < Qt::Key_Space || aKey > Qt::Key_ydiaeresis ) ? aKey : 0; + + switch ( aKey ) { + case 0 : + // any printed key: just print it + { + if ( curLine < endLine || curCol < PROMPT_SIZE ) { + moveCursor( QTextCursor::End ); + } + QTextEdit::keyPressEvent( event ); + break; + } + case Qt::Key_Return: + case Qt::Key_Enter: + // key: process the current command + { + handleReturn(); + break; + } + case Qt::Key_Up: + // arrow key: process as follows: + // - without , modifiers: previous command in history + // - with modifier key pressed: move cursor one row up without selection + // - with modifier key pressed: move cursor one row up with selection + // - with + modifier keys pressed: scroll one row up + { + if ( ctrlPressed && shftPressed ) { + int value = verticalScrollBar()->value(); + int spacing = fontMetrics().lineSpacing(); + verticalScrollBar()->setValue( value > spacing ? value-spacing : 0 ); + } + else if ( shftPressed || ctrlPressed ) { + if ( curLine > 0 ) + moveCursor( QTextCursor::Up, + shftPressed ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor ); + } + else { + if ( myCmdInHistory < 0 && myHistory.count() > 0 ) { + // set history browsing mode + myCmdInHistory = myHistory.count(); + // remember current command + QTextBlock par = document()->end().previous(); + myCurrentCommand = par.text().remove( 0, PROMPT_SIZE ); + } + if ( myCmdInHistory > 0 ) { + myCmdInHistory--; + // get previous command in the history + QString previousCommand = myHistory.at( myCmdInHistory ); + // print previous command + moveCursor( QTextCursor::End ); + moveCursor( QTextCursor::StartOfBlock, QTextCursor::KeepAnchor ); + textCursor().removeSelectedText(); + addText( myPrompt + previousCommand ); + // move cursor to the end + moveCursor( QTextCursor::End ); + } + } + break; + } + case Qt::Key_Down: + // arrow key: process as follows: + // - without , modifiers: next command in history + // - with modifier key pressed: move cursor one row down without selection + // - with modifier key pressed: move cursor one row down with selection + // - with + modifier keys pressed: scroll one row down + { + if ( ctrlPressed && shftPressed ) { + int value = verticalScrollBar()->value(); + int maxval = verticalScrollBar()->maximum(); + int spacing = fontMetrics().lineSpacing(); + verticalScrollBar()->setValue( value+spacing < maxval ? value+spacing : maxval ); + } + else if ( shftPressed || ctrlPressed) { + if ( curLine < endLine ) + moveCursor( QTextCursor::Down, + shftPressed ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor ); + } + else { + if ( myCmdInHistory >= 0 ) { + // get next command in the history + myCmdInHistory++; + QString nextCommand; + if ( myCmdInHistory < myHistory.count() ) { + // next command in history + nextCommand = myHistory.at( myCmdInHistory ); + } + else { + // end of history is reached + // last printed command + nextCommand = myCurrentCommand; + // unset history browsing mode + myCmdInHistory = -1; + } + // print next or current command + moveCursor( QTextCursor::End ); + moveCursor( QTextCursor::StartOfBlock, QTextCursor::KeepAnchor ); + textCursor().removeSelectedText(); + addText( myPrompt + ( nextCommand != TOP_HISTORY_PY ? nextCommand : myCurrentCommand ) ); + // move cursor to the end + moveCursor( QTextCursor::End ); + } + } + break; + } + case Qt::Key_Left: + // arrow key: process as follows: + // - without , modifiers: move one symbol left (taking into account prompt) + // - with modifier key pressed: move one word left (taking into account prompt) + // - with modifier key pressed: move one symbol left with selection + // - with + modifier keys pressed: move one word left with selection + { + QString txt = textCursor().block().text(); + if ( !shftPressed && isCommand( txt ) && curCol <= PROMPT_SIZE ) { + moveCursor( QTextCursor::Up ); + moveCursor( QTextCursor::EndOfBlock ); + } + else { + QTextEdit::keyPressEvent( event ); + } + break; + } + case Qt::Key_Right: + // arrow key: process as follows: + // - without , modifiers: move one symbol right (taking into account prompt) + // - with modifier key pressed: move one word right (taking into account prompt) + // - with modifier key pressed: move one symbol right with selection + // - with + modifier keys pressed: move one word right with selection + { + QString txt = textCursor().block().text(); + if ( !shftPressed ) { + if ( curCol < txt.length() ) { + if ( isCommand( txt ) && curCol < PROMPT_SIZE ) { + cur.setPosition( cur.block().position() + PROMPT_SIZE ); + setTextCursor( cur ); + break; + } + } + else { + if ( curLine < endLine && isCommand( textCursor().block().next().text() ) ) { + cur.setPosition( cur.position() + PROMPT_SIZE+1 ); + setTextCursor( cur ); + horizontalScrollBar()->setValue( horizontalScrollBar()->minimum() ); + break; + } + } + } + QTextEdit::keyPressEvent( event ); + break; + } + case Qt::Key_PageUp: + // key: process as follows: + // - without , modifiers: first command in history + // - with modifier key pressed: move cursor one page up without selection + // - with modifier key pressed: move cursor one page up with selection + // - with + modifier keys pressed: scroll one page up + { + if ( ctrlPressed && shftPressed ) { + verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub); + } + else if ( shftPressed || ctrlPressed ) { + bool moved = false; + qreal lastY = cursorRect( cur ).top(); + qreal distance = 0; + // move using movePosition to keep the cursor's x + do { + qreal y = cursorRect( cur ).top(); + distance += qAbs( y - lastY ); + lastY = y; + moved = cur.movePosition( QTextCursor::Up, + shftPressed ? QTextCursor::KeepAnchor : + QTextCursor::MoveAnchor ); + } while ( moved && distance < viewport()->height() ); + if ( moved ) { + cur.movePosition( QTextCursor::Down, + shftPressed ? QTextCursor::KeepAnchor : + QTextCursor::MoveAnchor ); + verticalScrollBar()->triggerAction( QAbstractSlider::SliderPageStepSub ); + } + setTextCursor( cur ); + } + else { + if ( myCmdInHistory < 0 && myHistory.count() > 0 ) { + // set history browsing mode + myCmdInHistory = myHistory.count(); + // remember current command + QTextBlock par = document()->end().previous(); + myCurrentCommand = par.text().remove( 0, PROMPT_SIZE ); + } + if ( myCmdInHistory > 0 ) { + myCmdInHistory = 0; + // get very first command in the history + QString firstCommand = myHistory.at( myCmdInHistory ); + // print first command + moveCursor( QTextCursor::End ); + moveCursor( QTextCursor::StartOfBlock, QTextCursor::KeepAnchor ); + textCursor().removeSelectedText(); + addText( myPrompt + firstCommand ); + // move cursor to the end + moveCursor( QTextCursor::End ); + } + } + break; + } + case Qt::Key_PageDown: + // key: process as follows: + // - without , modifiers: last command in history + // - with modifier key pressed: move cursor one page down without selection + // - with modifier key pressed: move cursor one page down with selection + // - with + modifier keys pressed: scroll one page down + { + if ( ctrlPressed && shftPressed ) { + verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd); + } + else if ( shftPressed || ctrlPressed ) { + bool moved = false; + qreal lastY = cursorRect( cur ).top(); + qreal distance = 0; + // move using movePosition to keep the cursor's x + do { + qreal y = cursorRect( cur ).top(); + distance += qAbs( y - lastY ); + lastY = y; + moved = cur.movePosition( QTextCursor::Down, + shftPressed ? QTextCursor::KeepAnchor : + QTextCursor::MoveAnchor ); + } while ( moved && distance < viewport()->height() ); + if ( moved ) { + cur.movePosition( QTextCursor::Up, + shftPressed ? QTextCursor::KeepAnchor : + QTextCursor::MoveAnchor ); + verticalScrollBar()->triggerAction( QAbstractSlider::SliderPageStepSub ); + } + setTextCursor( cur ); + } + else { + if ( myCmdInHistory >= 0 ) { + // unset history browsing mode + myCmdInHistory = -1; + // print current command + moveCursor( QTextCursor::End ); + moveCursor( QTextCursor::StartOfBlock, QTextCursor::KeepAnchor ); + textCursor().removeSelectedText(); + addText( myPrompt + myCurrentCommand ); + // move cursor to the end + moveCursor( QTextCursor::End ); + } + } + break; + } + case Qt::Key_Home: + // key: process as follows: + // - without , modifiers: move cursor to the beginning of the current line without selection + // - with modifier key pressed: move cursor to the very first symbol without selection + // - with modifier key pressed: move cursor to the beginning of the current line with selection + // - with + modifier keys pressed: move cursor to the very first symbol with selection + { + if ( ctrlPressed ) { + moveCursor( QTextCursor::Start, + shftPressed ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor ); + } + else { + QString txt = textCursor().block().text(); + if ( isCommand( txt ) ) { + if ( shftPressed ) { + if ( curCol > PROMPT_SIZE ) { + cur.movePosition( QTextCursor::StartOfLine, QTextCursor::KeepAnchor ); + cur.movePosition( QTextCursor::Right, QTextCursor::KeepAnchor, PROMPT_SIZE ); + } + } + else { + cur.movePosition( QTextCursor::StartOfLine ); + cur.movePosition( QTextCursor::Right, QTextCursor::MoveAnchor, PROMPT_SIZE ); + } + setTextCursor( cur ); + } + else { + moveCursor( QTextCursor::StartOfBlock, + shftPressed ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor ); + } + horizontalScrollBar()->setValue( horizontalScrollBar()->minimum() ); + } + break; + } + case Qt::Key_End: + // key: process as follows: + // - without , modifiers: move cursor to the end of the current line without selection + // - with modifier key pressed: move cursor to the very last symbol without selection + // - with modifier key pressed: move cursor to the end of the current line with selection + // - with + modifier keys pressed: move cursor to the very last symbol with selection + { + moveCursor( ctrlPressed ? QTextCursor::End : QTextCursor::EndOfBlock, + shftPressed ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor ); + break; + } + case Qt::Key_Backspace : + // key: process as follows + // - without any modifiers : delete symbol before the cursor / selection (taking into account prompt) + // - with modifier key pressed: delete previous word + // - with modifier key pressed: delete text from the cursor to the line beginning + // works only for last (command) line + { + if ( cur.hasSelection() ) { + cut(); + } + else if ( cur.position() > document()->end().previous().position() + PROMPT_SIZE ) { + if ( shftPressed ) { + moveCursor( QTextCursor::PreviousWord, QTextCursor::KeepAnchor ); + textCursor().removeSelectedText(); + } + else if ( ctrlPressed ) { + cur.setPosition( document()->end().previous().position() + PROMPT_SIZE, + QTextCursor::KeepAnchor ); + setTextCursor( cur ); + textCursor().removeSelectedText(); + } + else { + QTextEdit::keyPressEvent( event ); + } + } + else { + cur.setPosition( document()->end().previous().position() + PROMPT_SIZE ); + setTextCursor( cur ); + horizontalScrollBar()->setValue( horizontalScrollBar()->minimum() ); + } + break; + } + case Qt::Key_Delete : + // key: process as follows + // - without any modifiers : delete symbol after the cursor / selection (taking into account prompt) + // - with modifier key pressed: delete next word + // - with modifier key pressed: delete text from the cursor to the end of line + // works only for last (command) line + { + if ( cur.hasSelection() ) { + cut(); + } + else if ( cur.position() > document()->end().previous().position() + PROMPT_SIZE-1 ) { + if ( shftPressed ) { + moveCursor( QTextCursor::NextWord, QTextCursor::KeepAnchor ); + textCursor().removeSelectedText(); + } + else if ( ctrlPressed ) { + moveCursor( QTextCursor::EndOfBlock, QTextCursor::KeepAnchor ); + textCursor().removeSelectedText(); + } + else { + QTextEdit::keyPressEvent( event ); + } + } + else { + cur.setPosition( document()->end().previous().position() + PROMPT_SIZE ); + setTextCursor( cur ); + horizontalScrollBar()->setValue( horizontalScrollBar()->minimum() ); + } + break; + } + case Qt::Key_Insert : + // key: process as follows + // - with modifier key pressed: copy() + // - with modifier key pressed: paste() to the command line + { + if ( ctrlPressed ) { + copy(); + } + else if ( shftPressed ) { + paste(); + } + else + QTextEdit::keyPressEvent( event ); + break; + } + } +} + +/*! + \brief Handle notification event coming from Python dispatcher. + \param event notification event +*/ +void PyConsole_Editor::customEvent( QEvent* event ) +{ + switch( event->type() ) { + case PyInterp_Event::OK: + case PyInterp_Event::ERROR: + { + PyInterp_Event* pe = dynamic_cast( event ); + if ( pe ){ + ExecCommand* ec = dynamic_cast( pe->GetRequest() ); + if ( ec ) { + // The next line has appeared dangerous in case if + // Python command execution has produced very large output. + // A more clever approach is needed... + // print python output + addText( ec->myOutput, true ); + addText( ec->myError ); + } + } + // clear command buffer + myCommandBuffer.truncate( 0 ); + // set "ready" prompt + myPrompt = READY_PROMPT; + addText( myPrompt ); + // unset busy cursor + unsetCursor(); + // stop event loop (if running) + if( myEventLoop ) + myEventLoop->exit(); + break; + } + case PyInterp_Event::INCOMPLETE: + { + // extend command buffer (multi-line command) + myCommandBuffer.append( "\n" ); + // set "dot" prompt + myPrompt = DOTS_PROMPT; + addText( myPrompt, true ); + // unset busy cursor + unsetCursor(); + // stop event loop (if running) + if( myEventLoop ) + myEventLoop->exit(); + break; + } + default: + QTextEdit::customEvent( event ); + } + + // unset read-only state + setReadOnly( false ); + // unset history browsing mode + myCmdInHistory = -1; + + if ( (int)event->type() == (int)PyInterp_Event::OK && myQueue.count() > 0 ) { + // process the next sheduled command from the queue (if there is any) + QString nextcmd = myQueue[0]; + myQueue.pop_front(); + exec( nextcmd ); + } +} + +/*! + \brief Handle Python interpreter change. + + Perform initialization actions if the interpreter is changed. + \param interp python interpreter is being set +*/ +void PyConsole_Editor::onPyInterpChanged( PyInterp_base* interp ) +{ + if ( myInterp != interp + // Force read-only state and wait cursor when myInterp is NULL + || !myInterp ) { + myInterp = interp; + if ( myInterp ) { + // print banner + myBanner = myInterp->getbanner().c_str(); + addText( myBanner ); + // clear command buffer + myCommandBuffer.truncate(0); + // unset read-only state + setReadOnly( false ); + // unset history browsing mode + myCmdInHistory = -1; + // add prompt + addText( myPrompt ); + // unset busy cursor + viewport()->unsetCursor(); + // stop event loop (if running) + if( myEventLoop) + myEventLoop->exit(); + } + else { + // clear contents + clear(); + // set read-only state + setReadOnly( true ); + // set busy cursor + setCursor( Qt::WaitCursor ); + } + } +} + +/*! + \brief "Copy" operation. + + Reimplemented from Qt. + Warning! In Qt4 this method is not virtual. + */ +void PyConsole_Editor::cut() +{ + QTextCursor cur = textCursor(); + if ( cur.hasSelection() ) { + QApplication::clipboard()->setText( cur.selectedText() ); + int startSelection = cur.selectionStart(); + if ( startSelection < document()->end().previous().position() + PROMPT_SIZE ) + startSelection = document()->end().previous().position() + PROMPT_SIZE; + int endSelection = cur.selectionEnd(); + if ( endSelection < document()->end().previous().position() + PROMPT_SIZE ) + endSelection = document()->end().previous().position() + PROMPT_SIZE; + cur.setPosition( startSelection ); + cur.setPosition( endSelection, QTextCursor::KeepAnchor ); + horizontalScrollBar()->setValue( horizontalScrollBar()->minimum() ); + setTextCursor( cur ); + textCursor().removeSelectedText(); + } +} + +/*! + \brief "Paste" operation. + + Reimplemented from Qt. + Warning! In Qt4 this method is not virtual. + */ +void PyConsole_Editor::paste() +{ + QTextCursor cur = textCursor(); + if ( cur.hasSelection() ) { + int startSelection = cur.selectionStart(); + if ( startSelection < document()->end().previous().position() + PROMPT_SIZE ) + startSelection = document()->end().previous().position() + PROMPT_SIZE; + int endSelection = cur.selectionEnd(); + if ( endSelection < document()->end().previous().position() + PROMPT_SIZE ) + endSelection = document()->end().previous().position() + PROMPT_SIZE; + cur.setPosition( startSelection ); + cur.setPosition( endSelection, QTextCursor::KeepAnchor ); + horizontalScrollBar()->setValue( horizontalScrollBar()->minimum() ); + setTextCursor( cur ); + textCursor().removeSelectedText(); + } + if ( textCursor().position() < document()->end().previous().position() + PROMPT_SIZE ) + moveCursor( QTextCursor::End ); + QTextEdit::paste(); +} + +/*! + \brief "Clear" operation. + + Reimplemented from Qt. + Warning! In Qt4 this method is not virtual. + */ +void PyConsole_Editor::clear() +{ + QTextEdit::clear(); + addText( myBanner ); + myPrompt = READY_PROMPT; + addText( myPrompt ); +} diff --git a/src/PyConsole/PyConsole_Editor.h b/src/PyConsole/PyConsole_Editor.h new file mode 100644 index 000000000..d46c3920c --- /dev/null +++ b/src/PyConsole/PyConsole_Editor.h @@ -0,0 +1,77 @@ +// SALOME SALOMEGUI : implementation of desktop and GUI kernel +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : PyConsole_Editor.h +// Author : Vadim SANDLER +// Module : SALOME + +#ifndef PYCONSOLE_EDITOR_H +#define PYCONSOLE_EDITOR_H + +#include "PyConsole_Interp.h" // this include must be first (see PyInterp_base.h)! + +#include + +class QMenu; +class QEventLoop; +class PyConsole_Interp; + +class PYCONSOLE_EXPORT PyConsole_Editor : public QTextEdit +{ + Q_OBJECT; + +public: + PyConsole_Editor( PyInterp_base* theInterp, QWidget *theParent = 0 ); + ~PyConsole_Editor(); + + virtual void addText( const QString& str, const bool newBlock = false ); + bool isCommand( const QString& str ) const; + + virtual void exec( const QString& command ); + void execAndWait( const QString& command ); + +protected: + virtual void dropEvent( QDropEvent* event ); + virtual void mouseReleaseEvent( QMouseEvent* event ); + virtual void keyPressEvent ( QKeyEvent* event); + virtual void customEvent( QEvent* event); + +public slots: + void cut(); + void paste(); + void clear(); + void handleReturn(); + void onPyInterpChanged( PyInterp_base* ); + +private: + PyInterp_base* myInterp; //!< python interpreter + + QString myCommandBuffer; //!< python comman buffer + QString myCurrentCommand; //!< currently being printed command + QString myPrompt; //!< current command line prompt + int myCmdInHistory; //!< current history command index + QStringList myHistory; //!< commands history buffer + QEventLoop* myEventLoop; //!< internal event loop + QString myBanner; //!< current banner + QStringList myQueue; //!< python commands queue +}; + +#endif diff --git a/src/PyConsole/PyConsole_Interp.cxx b/src/PyConsole/PyConsole_Interp.cxx new file mode 100644 index 000000000..a2c0d47a9 --- /dev/null +++ b/src/PyConsole/PyConsole_Interp.cxx @@ -0,0 +1,118 @@ +// SALOME SALOMEGUI : implementation of desktop and GUI kernel +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : PyConsole_Interp.cxx +// Author : Nicolas REJNERI +// Module : SALOME + +#include "PyConsole_Interp.h" + +/*! + \class PyConsole_Interp + \brief Python interpreter to be embedded to the SALOME study's GUI. + + Python interpreter is created one per SALOME study. + Calls initialize method defined in the base class, which calls redefined + virtual methods initState() & initContext(). + + /EDF-CCAR/ + When SALOME uses multi Python interpreter feature, + every study has its own interpreter and thread state (_tstate = Py_NewInterpreter()). + This is fine because every study has its own modules (sys.modules) stdout and stderr.
+ But some Python modules must be imported only once. In multi interpreter + context Python modules (*.py) are imported several times. + For example, the pyqt module must be imported only once because + it registers classes in a C module. + It's quite the same with omniorb modules (internals and generated with omniidl). + This problem is handled with "shared modules" defined in salome_shared_modules.py. + These "shared modules" are imported only once and only copied in all + the other interpreters.
+ But it's not the only problem. Every interpreter has its own + __builtin__ module. That's fine but if we have copied some modules + and imported others problems may arise with operations that are not allowed + in restricted execution environment. So we must impose that all interpreters + have identical __builtin__ module. +*/ + +using namespace std; + +/*! + \brief Constructor. + + Creates new python interpreter. +*/ +PyConsole_Interp::PyConsole_Interp(): PyInterp_base() +{ +} + +/*! + \brief Destructor. + + Does nothing for the moment. +*/ +PyConsole_Interp::~PyConsole_Interp() +{ +} + +/*! + \brief Initialize internal Python interpreter state. +*/ +bool PyConsole_Interp::initState() +{ + // The GIL is acquired and will be held on initState output + // It is the caller responsability to release the lock if needed + PyEval_AcquireLock(); + _tstate = Py_NewInterpreter(); // create an interpreter and save current state + PySys_SetArgv(PyInterp_base::_argc,PyInterp_base::_argv); // initialize sys.argv + + //If builtinmodule has been initialized all the sub interpreters + // will have the same __builtin__ module + if(builtinmodule){ + PyObject *m = PyImport_GetModuleDict(); + PyDict_SetItemString(m, "__builtin__", builtinmodule); + _tstate->interp->builtins = PyModule_GetDict(builtinmodule); + Py_INCREF(_tstate->interp->builtins); + } + PyEval_ReleaseThread(_tstate); + return true; +} + +/*! + \brief Initialize python interpeter context. + + The GIL is assumed to be held. + It is the caller responsability caller to acquire the GIL. + It will still be held on initContext() exit. +*/ +bool PyConsole_Interp::initContext() +{ + PyObject *m = PyImport_AddModule("__main__"); // interpreter main module (module context) + if(!m){ + PyErr_Print(); + return false; + } + _g = PyModule_GetDict(m); // get interpreter dictionnary context + + if(builtinmodule){ + PyDict_SetItemString(_g, "__builtins__", builtinmodule); // assign singleton __builtin__ module + } + return true; +} diff --git a/src/PyConsole/PyConsole_Interp.h b/src/PyConsole/PyConsole_Interp.h new file mode 100644 index 000000000..3d1ed03fa --- /dev/null +++ b/src/PyConsole/PyConsole_Interp.h @@ -0,0 +1,44 @@ +// SALOME SALOMEGUI : implementation of desktop and GUI kernel +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : PyConsole_Interp.h +// Author : Nicolas REJNERI +// Module : SALOME + +#ifndef PYCONSOLE_INTERP_H +#define PYCONSOLE_INTERP_H + +#include "PyConsole.h" + +#include // this include must be first (see PyInterp_base.h)! + +class PYCONSOLE_EXPORT PyConsole_Interp : public PyInterp_base +{ +public: + PyConsole_Interp(); + ~PyConsole_Interp(); + +protected: + virtual bool initState(); + virtual bool initContext(); +}; + +#endif diff --git a/src/PyConsole/resources/PyConsole_msg_en.ts b/src/PyConsole/resources/PyConsole_msg_en.ts new file mode 100644 index 000000000..f016fe6b3 --- /dev/null +++ b/src/PyConsole/resources/PyConsole_msg_en.ts @@ -0,0 +1,26 @@ + + + + PythonConsole + + + EDIT_COPY_CMD + Copy + + + + EDIT_PASTE_CMD + Paste + + + + EDIT_CLEAR_CMD + Clear + + + + EDIT_SELECTALL_CMD + Select All + + + diff --git a/src/PyInterp/Makefile.in b/src/PyInterp/Makefile.in deleted file mode 100755 index d9af0dc9c..000000000 --- a/src/PyInterp/Makefile.in +++ /dev/null @@ -1,51 +0,0 @@ -# SALOME PyInterp : implementation of base thread-safe Python services -# -# Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# -# -# File : Makefile.in -# Module : SALOME - -top_srcdir=@top_srcdir@ -top_builddir=../.. -srcdir=@srcdir@ -VPATH=.:@srcdir@ - - -@COMMENCE@ - -# header files -EXPORT_HEADERS= PyInterp.h \ - PyInterp_base.h \ - PyInterp_Dispatcher.h - -# Libraries targets -LIB = libPyInterp.la - -LIB_SRC= PyInterp_base.cxx \ - PyInterp_Dispatcher.cxx - -LIB_MOC = PyInterp_Watcher.h - -CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_INCLUDES) - -LDFLAGS+= $(PYTHON_LIBS) $(QT_MT_LIBS) - -@CONCLUDE@ diff --git a/src/PyInterp/PyInterp.h b/src/PyInterp/PyInterp.h index af9536fd8..86772a124 100755 --- a/src/PyInterp/PyInterp.h +++ b/src/PyInterp/PyInterp.h @@ -21,7 +21,7 @@ // ======================================================== // set dllexport type for Win platform -#ifdef WNT +#ifdef WIN32 #ifdef PYINTERP_EXPORTS #define PYINTERP_EXPORT __declspec(dllexport) @@ -29,31 +29,29 @@ #define PYINTERP_EXPORT __declspec(dllimport) #endif -#else // WNT +#else // WIN32 #define PYINTERP_EXPORT -#endif // WNT +#endif // WIN32 // ======================================================== -// little trick - if we do not have debug python libraries +// little trick - we do not have debug python libraries #ifdef _DEBUG - #ifndef HAVE_DEBUG_PYTHON - #undef _DEBUG - #endif -#endif +#undef _DEBUG #include +#define _DEBUG -#ifdef _DEBUG - #ifndef HAVE_DEBUG_PYTHON - #define _DEBUG - #endif -#endif +#else // _DEBUG + +#include + +#endif // _DEBUG // ======================================================== // avoid warning messages -#ifdef WNT +#ifdef WIN32 #pragma warning (disable : 4786) #pragma warning (disable : 4251) #endif diff --git a/src/PyInterp/PyInterp.pro b/src/PyInterp/PyInterp.pro new file mode 100644 index 000000000..95781fccd --- /dev/null +++ b/src/PyInterp/PyInterp.pro @@ -0,0 +1,23 @@ +TEMPLATE = lib +DESTDIR = ../../lib +MOC_DIR = ../../moc +OBJECTS_DIR = ../../obj/$$TARGET + +INCLUDEPATH += ../../include $$(PYTHONINC) +unix:LIBS += -L$$(PYTHONLIB) -lpython2.3 +win32:LIBS += /LIBPATH:$$(PYTHONLIB) + +CONFIG -= debug release debug_and_release +CONFIG += qt thread debug dll shared + +win32:DEFINES += WIN32 +DEFINES += PYINTERP_EXPORTS + +HEADERS = *.h + +SOURCES = *.cxx + +includes.files = $$HEADERS +includes.path = ../../include + +INSTALLS += includes diff --git a/src/PyInterp/PyInterp_Dispatcher.cxx b/src/PyInterp/PyInterp_Dispatcher.cxx index dd029a25b..4a2f3d4eb 100755 --- a/src/PyInterp/PyInterp_Dispatcher.cxx +++ b/src/PyInterp/PyInterp_Dispatcher.cxx @@ -24,14 +24,13 @@ // $Header$ -#include -#include -#include +#include "PyInterp_base.h" +#include "PyInterp_Watcher.h" +#include "PyInterp_Dispatcher.h" -#include -#include +#include +#include -//#include using namespace std; PyInterp_Dispatcher* PyInterp_Dispatcher::myInstance = 0; @@ -75,13 +74,8 @@ QEvent* PyInterp_Request::getEvent() void PyInterp_Request::postEvent() { -#if QT_VERSION >= 0x030303 // MESSAGE("*** PyInterp_Request::postEvent(): for Qt 3.3.3") - QApplication::postEvent( getListener(), getEvent() ); -#else -// MESSAGE("*** PyInterp_Request::postEvent(): for Qt 3.0.5") - QThread::postEvent( getListener(), getEvent() ); -#endif + QCoreApplication::postEvent( getListener(), getEvent() ); } void PyInterp_Request::setListener( QObject* o ) @@ -138,7 +132,7 @@ PyInterp_Dispatcher::~PyInterp_Dispatcher() bool PyInterp_Dispatcher::IsBusy() const { - return running(); + return isRunning(); } void PyInterp_Dispatcher::Exec( PyInterp_Request* theRequest ) diff --git a/src/PyInterp/PyInterp_Dispatcher.h b/src/PyInterp/PyInterp_Dispatcher.h index 311c9e66f..cfa43089e 100755 --- a/src/PyInterp/PyInterp_Dispatcher.h +++ b/src/PyInterp/PyInterp_Dispatcher.h @@ -27,8 +27,10 @@ #include "PyInterp.h" -#include -#include +#include +#include + +#include #include @@ -98,7 +100,7 @@ private: PyInterp_base* myInterp; }; -class PYINTERP_EXPORT PyInterp_Event : public QCustomEvent +class PYINTERP_EXPORT PyInterp_Event : public QEvent { PyInterp_Event(); PyInterp_Event( const PyInterp_Event& ); @@ -107,7 +109,7 @@ public: enum { NOTIFY = QEvent::User + 5000, OK, ERROR, INCOMPLETE, LAST }; PyInterp_Event( int type, PyInterp_Request* request ) - : QCustomEvent( (QEvent::Type)type ), myRequest( request ) {} + : QEvent( (QEvent::Type)type ), myRequest( request ) {} virtual ~PyInterp_Event(); diff --git a/src/PyInterp/PyInterp_Watcher.h b/src/PyInterp/PyInterp_Watcher.h index 551eca7d0..f5d776034 100755 --- a/src/PyInterp/PyInterp_Watcher.h +++ b/src/PyInterp/PyInterp_Watcher.h @@ -19,11 +19,11 @@ #ifndef _PYINTERP_WATCHER_H_ #define _PYINTERP_WATCHER_H_ -#include +#include "PyInterp.h" -#include +#include "PyInterp_Dispatcher.h" -#include +#include // Private class that keeps track of destructions of request listeners class PYINTERP_EXPORT PyInterp_Watcher : public QObject diff --git a/src/PyInterp/PyInterp_base.cxx b/src/PyInterp/PyInterp_base.cxx index 7225855fe..1ff7cd241 100644 --- a/src/PyInterp/PyInterp_base.cxx +++ b/src/PyInterp/PyInterp_base.cxx @@ -24,12 +24,13 @@ // $Header$ -#include -#include - #include "PyInterp_base.h" // this include must be first (see PyInterp_base.h)! + #include +#include +#include + using namespace std; PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState): diff --git a/src/PyInterp/PyInterp_base.h b/src/PyInterp/PyInterp_base.h index 71931655c..a00056e86 100644 --- a/src/PyInterp/PyInterp_base.h +++ b/src/PyInterp/PyInterp_base.h @@ -72,7 +72,7 @@ class PYINTERP_EXPORT PyInterp_base{ static PyInterpreterState *_interp; PyInterp_base(); - ~PyInterp_base(); + virtual ~PyInterp_base(); virtual void initialize(); virtual void init_python(); diff --git a/src/STD/Makefile.in b/src/STD/Makefile.in deleted file mode 100755 index cfd6deca0..000000000 --- a/src/STD/Makefile.in +++ /dev/null @@ -1,86 +0,0 @@ -# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# File : Makefile.in -# Author : Vladimir Klyachin (OCN) -# Module : STD -# $Header$ - -top_srcdir=@top_srcdir@ -top_builddir=../.. -srcdir=@srcdir@ -VPATH=.:@srcdir@:@srcdir@/resources - - -@COMMENCE@ - -# header files -EXPORT_HEADERS= STD_Application.h \ - STD.h \ - STD_MDIDesktop.h \ - STD_SDIDesktop.h \ - STD_TabDesktop.h \ - STD_CloseDlg.h \ - STD_LoadStudiesDlg.h - -# .po files to transform in .qm -PO_FILES = STD_images.po \ - STD_msg_en.po - -# Libraries targets -LIB = libstd.la - -LIB_SRC= STD_Application.cxx \ - STD_MDIDesktop.cxx \ - STD_SDIDesktop.cxx \ - STD_TabDesktop.cxx \ - STD_CloseDlg.cxx \ - STD_LoadStudiesDlg.cxx - -LIB_MOC = STD_Application.h \ - STD_MDIDesktop.h \ - STD_SDIDesktop.h \ - STD_TabDesktop.h \ - STD_CloseDlg.h \ - STD_LoadStudiesDlg.h - -RESOURCES_FILES = \ -config \ -cut.png \ -copy.png \ -close.png \ -cursor_rotate.png \ -cursor_zoom.png \ -help.png \ -new.png \ -open.png \ -print.png \ -paste.png \ -redo.png \ -reset.png \ -save.png \ -undo_arrow.png \ -undo.png \ -std.ini - -CPPFLAGS+=$(QT_INCLUDES) - -LDFLAGS+=$(QT_MT_LIBS) -LIBS+= -lsuit - -@CONCLUDE@ diff --git a/src/STD/STD.pro b/src/STD/STD.pro new file mode 100644 index 000000000..7db9dfa0d --- /dev/null +++ b/src/STD/STD.pro @@ -0,0 +1,30 @@ +TEMPLATE = lib +DESTDIR = ../../lib +MOC_DIR = ../../moc +OBJECTS_DIR = ../../obj/$$TARGET + +INCLUDEPATH = ../../include +LIBS += -L../../lib -lSUIT -lQtx + +CONFIG -= debug release debug_and_release +CONFIG += qt thread debug dll shared + +win32:DEFINES += WIN32 +DEFINES += STD_EXPORTS + +HEADERS = *.h + +SOURCES = *.cxx + +TRANSLATIONS = resources/STD_images.ts \ + resources/STD_msg_en.ts + +ICONS = resources/*.png + +includes.files = $$HEADERS +includes.path = ../../include + +resources.files = $$ICONS resources/*.qm resources/*.xml resources/*.ini +resources.path = ../../resources + +INSTALLS += includes resources diff --git a/src/STD/STD_LoadStudiesDlg.cxx b/src/STD/STD_LoadStudiesDlg.cxx deleted file mode 100644 index 3e494d921..000000000 --- a/src/STD/STD_LoadStudiesDlg.cxx +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "STD_LoadStudiesDlg.h" - -#include -#include -#include -#include - -#define SPACING_SIZE 6 -#define MARGIN_SIZE 11 -#define MIN_LISTBOX_WIDTH 150 -#define MIN_LISTBOX_HEIGHT 100 - -/*! -* \brief creates a Load study dialog box -* \param parent a parent widget -* \param modal bool argument, if true the dialog box is a modal dialog box -* \param f style flags -*/ - -STD_LoadStudiesDlg::STD_LoadStudiesDlg( QWidget* parent, bool modal ) -: QDialog( parent ) -{ - setModal( modal ); - setWindowTitle( tr("DLG_LOAD_STUDY_CAPTION") ); - setSizeGripEnabled( true ); - - QGridLayout* aTopLayout = new QGridLayout(this); - aTopLayout->setMargin(MARGIN_SIZE); - aTopLayout->setSpacing(SPACING_SIZE); - - TextLabel1 = new QLabel( this ); - TextLabel1->setGeometry( QRect( 11, 12, 297, 16 ) ); - TextLabel1->setText( tr( "MEN_STUDIES_CHOICE" ) ); - - QHBoxLayout* aBtnLayout = new QHBoxLayout; - aBtnLayout->setSpacing( SPACING_SIZE ); - aBtnLayout->setMargin( 0 ); - - buttonOk = new QPushButton( this ); - buttonOk->setText( tr( "BUT_OK" ) ); - buttonOk->setAutoDefault( true ); - buttonOk->setDefault( true ); - - buttonCancel = new QPushButton( this ); - buttonCancel->setText( tr( "BUT_CANCEL" ) ); - buttonCancel->setAutoDefault( true ); - - aBtnLayout->addWidget( buttonOk ); - aBtnLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); - aBtnLayout->addWidget( buttonCancel ); - - ListComponent = new QListWidget( this ); - ListComponent->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); - ListComponent->setMinimumSize( MIN_LISTBOX_WIDTH, MIN_LISTBOX_HEIGHT ); - ListComponent->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); - ListComponent->setSelectionMode( QListWidget::SingleSelection ); - - aTopLayout->addWidget(TextLabel1, 0, 0); - aTopLayout->addWidget(ListComponent, 1, 0); - aTopLayout->addLayout(aBtnLayout, 2, 0); - - // signals and slots connections - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); -} - diff --git a/src/STD/STD_LoadStudiesDlg.h b/src/STD/STD_LoadStudiesDlg.h deleted file mode 100644 index 2a94a519a..000000000 --- a/src/STD/STD_LoadStudiesDlg.h +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef STD_LOADSTUDIESDLG_H -#define STD_LOADSTUDIESDLG_H - -#include - -#include - -#include - -class QLabel; -class QListBox; -class QPushButton; -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QListWidget; - -/*!\class STD_LoadStudiesDlg - * \brief Describes a dialog box that gives a list of opened studies. - * - */ -class STD_EXPORT STD_LoadStudiesDlg : public QDialog -{ - Q_OBJECT - -public: - STD_LoadStudiesDlg( QWidget* parent = 0, bool modal = false ); - ~STD_LoadStudiesDlg() {} - - /*!\var TextLabel1 - * \brief stores a dialog text label - */ - QLabel* TextLabel1; - - /*!\var buttonOk - * \brief stores a dialog button OK - */ - QPushButton* buttonOk; - - /*!\var buttonCancel - * \brief stores a dialog button Cancel - */ - QPushButton* buttonCancel; - - /*!\var ListComponent - * \brief stores a dialog list compoent - */ - QListWidget* ListComponent; - -}; - -#endif // STD_LOADSTUDIESDLG_H diff --git a/src/STD/STD_MDIDesktop.cxx b/src/STD/STD_MDIDesktop.cxx index 9a446ab64..db06097f2 100755 --- a/src/STD/STD_MDIDesktop.cxx +++ b/src/STD/STD_MDIDesktop.cxx @@ -24,27 +24,31 @@ #include #include -#include +//#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include /*!Constructor.*/ STD_MDIDesktop::STD_MDIDesktop() : SUIT_Desktop(), -myWorkspace( 0 ), -myWorkspaceAction( 0 ) +myWorkspace( 0 )//, +//myWorkspaceAction( 0 ) { - QVBox* base = new QVBox( this ); + QFrame* base = new QFrame( this ); + QVBoxLayout* main = new QVBoxLayout( base ); + main->setMargin( 0 ); base->setFrameStyle( QFrame::Panel | QFrame::Sunken ); setCentralWidget( base ); myWorkspace = new QWorkspace( base ); + main->addWidget( myWorkspace ); connect( myWorkspace, SIGNAL( windowActivated( QWidget* ) ), this, SLOT( onWindowActivated( QWidget* ) ) ); @@ -70,30 +74,34 @@ SUIT_ViewWindow* STD_MDIDesktop::activeWindow() const } /*!\retval QPtrList - return const active window list.*/ -QPtrList STD_MDIDesktop::windows() const +QList STD_MDIDesktop::windows() const { - QPtrList winList; + QList winList; QWidgetList children = myWorkspace->windowList(); - for ( QWidgetListIt it( children ); it.current(); ++it ) + for ( QWidgetList::iterator it = children.begin(); it != children.end(); ++it ) { - if ( it.current()->inherits( "SUIT_ViewWindow" ) ) - winList.append( (SUIT_ViewWindow*)it.current() ); + SUIT_ViewWindow* vw = ::qobject_cast( *it ); + if ( vw ) + winList.append( vw ); } return winList; } -/*!\retval QWidget - pointer to work space.*/ -QWidget* STD_MDIDesktop::parentArea() const +/*! add the new widget into desktop.*/ +void STD_MDIDesktop::addWindow( QWidget* w ) { - return workspace(); + if ( !w || !workspace() ) + return; + + workspace()->addWindow( w ); } /*!Call method perform for operation \a type.*/ void STD_MDIDesktop::windowOperation( const int type ) { - myWorkspaceAction->perform( operationFlag( type ) ); + //myWorkspaceAction->perform( operationFlag( type ) ); } /*!Sets window operations by \a first ... parameters.*/ @@ -102,7 +110,7 @@ void STD_MDIDesktop::setWindowOperations( const int first, ... ) va_list ints; va_start( ints, first ); - QValueList typeList; + QList typeList; int cur = first; while ( cur ) @@ -115,14 +123,14 @@ void STD_MDIDesktop::setWindowOperations( const int first, ... ) } /*!Sets window operations by variable \a opList - operation list.*/ -void STD_MDIDesktop::setWindowOperations( const QValueList& opList ) +void STD_MDIDesktop::setWindowOperations( const QList& opList ) { int flags = 0; - for ( QValueList::const_iterator it = opList.begin(); it != opList.end(); ++it ) + for ( QList::const_iterator it = opList.begin(); it != opList.end(); ++it ) flags = flags | operationFlag( *it ); - myWorkspaceAction->setItems( flags ); +// myWorkspaceAction->setItems( flags ); } /*!\retval QWorkspace pointer - work space.*/ @@ -141,6 +149,7 @@ void STD_MDIDesktop::onWindowActivated( QWidget* w ) /*!Create actions: cascade, Tile, Tile Horizontal, Tile Vertical*/ void STD_MDIDesktop::createActions() { +/* if ( myWorkspaceAction ) return; @@ -186,12 +195,14 @@ void STD_MDIDesktop::createActions() int winMenuId = mMgr->insert( tr( "MEN_DESK_WINDOW" ), -1, 100, MenuWindowId ); mMgr->insert( myWorkspaceAction, winMenuId, -1 ); mMgr->insert( QtxActionMenuMgr::separator(), winMenuId, -1 ); +*/ } /*!Convert STD_MDIDesktop enumerations to QtxWorkspaceAction.*/ int STD_MDIDesktop::operationFlag( const int type ) const { int res = 0; +/* switch ( type ) { case Cascade: @@ -207,5 +218,6 @@ int STD_MDIDesktop::operationFlag( const int type ) const res = QtxWorkspaceAction::VTile; break; } +*/ return res; } diff --git a/src/STD/STD_MDIDesktop.h b/src/STD/STD_MDIDesktop.h index f4136444d..3d338854a 100755 --- a/src/STD/STD_MDIDesktop.h +++ b/src/STD/STD_MDIDesktop.h @@ -26,9 +26,9 @@ class QtxAction; class QPopupMenu; class QWorkspace; -class QtxWorkspaceAction; +//class QtxWorkspaceAction; -#if defined WNT +#if defined WIN32 #pragma warning( disable: 4251 ) #endif @@ -36,6 +36,8 @@ class STD_EXPORT STD_MDIDesktop: public SUIT_Desktop { Q_OBJECT + class Workspace; + public: enum { MenuWindowId = 6 }; enum { Cascade, Tile, HTile, VTile }; @@ -45,12 +47,12 @@ public: virtual ~STD_MDIDesktop(); virtual SUIT_ViewWindow* activeWindow() const; - virtual QPtrList windows() const; + virtual QList windows() const; void windowOperation( const int ); void setWindowOperations( const int, ... ); - void setWindowOperations( const QValueList& ); + void setWindowOperations( const QList& ); QWorkspace* workspace() const; @@ -59,17 +61,17 @@ private slots: protected: void createActions(); - virtual QWidget* parentArea() const; + virtual void addWindow( QWidget* ); private: int operationFlag( const int ) const; private: QWorkspace* myWorkspace; - QtxWorkspaceAction* myWorkspaceAction; +// QtxWorkspaceAction* myWorkspaceAction; }; -#if defined WNT +#if defined WIN32 #pragma warning( default: 4251 ) #endif diff --git a/src/STD/STD_SDIDesktop.cxx b/src/STD/STD_SDIDesktop.cxx index 9bcc92a56..d04923414 100755 --- a/src/STD/STD_SDIDesktop.cxx +++ b/src/STD/STD_SDIDesktop.cxx @@ -20,16 +20,21 @@ #include -#include -#include -#include +#include +#include +#include + +#include /*!Constructor. Create instance of QVBox*/ STD_SDIDesktop::STD_SDIDesktop() : SUIT_Desktop() { - myMainWidget = new QVBox( this ); + myMainWidget = new QFrame( this ); myMainWidget->setFrameStyle( QFrame::Panel | QFrame::Sunken ); + + QVBoxLayout* main = new QVBoxLayout( myMainWidget ); + main->setMargin( 0 ); setCentralWidget( myMainWidget ); } @@ -42,40 +47,42 @@ STD_SDIDesktop::~STD_SDIDesktop() /*!\retval SUIT_ViewWindow - return const active window.*/ SUIT_ViewWindow* STD_SDIDesktop::activeWindow() const { - const QObjectList* children = myMainWidget->children(); - if ( !children ) - return 0; - - QPtrList winList; - for ( QObjectListIt it( *children ); it.current(); ++it ) + const QObjectList& lst = myMainWidget->children(); + QList winList; + for ( QObjectList::const_iterator it = lst.begin(); it != lst.end(); ++it ) { - if ( it.current()->inherits( "SUIT_ViewWindow" ) ) - winList.append( (SUIT_ViewWindow*)it.current() ); + SUIT_ViewWindow* vw = ::qobject_cast( *it ); + if ( vw ) + winList.append( vw ); } SUIT_ViewWindow* win = 0; - for ( QPtrListIterator itr( winList ); itr.current() && !win; ++itr ) + for ( QList::iterator itr = winList.begin(); itr != winList.end() && !win; ++itr ) { - if ( itr.current()->isActiveWindow() ) - win = itr.current(); + if ( (*itr)->isActiveWindow() ) + win = *itr; } if ( !win && !winList.isEmpty() ) - win = winList.getFirst(); + win = winList.first(); return win; } /*!\retval QPtrList - return const active window list.*/ -QPtrList STD_SDIDesktop::windows() const +QList STD_SDIDesktop::windows() const { - QPtrList winList; - winList.append( activeWindow() ); + QList winList; + winList.append( activeWindow() ); return winList; } -/*!\retval QWidget - pointer to main window.*/ -QWidget* STD_SDIDesktop::parentArea() const +/*! add new widget into desktop.*/ +void STD_SDIDesktop::addWindow( QWidget* w ) { - return myMainWidget; + if ( !w || !centralWidget() || !centralWidget()->layout() ) + return; + + w->setParent( centralWidget() ); + centralWidget()->layout()->addWidget( w ); } diff --git a/src/STD/STD_SDIDesktop.h b/src/STD/STD_SDIDesktop.h index 78b1bb78d..c963a28b0 100755 --- a/src/STD/STD_SDIDesktop.h +++ b/src/STD/STD_SDIDesktop.h @@ -23,7 +23,7 @@ #include -class QVBox; +class QFrame; class STD_EXPORT STD_SDIDesktop: public SUIT_Desktop { @@ -34,13 +34,13 @@ public: virtual ~STD_SDIDesktop(); virtual SUIT_ViewWindow* activeWindow() const; - virtual QPtrList windows() const; + virtual QList windows() const; protected: - virtual QWidget* parentArea() const; + virtual void addWindow( QWidget* ); private: - QVBox* myMainWidget; + QFrame* myMainWidget; }; #endif diff --git a/src/STD/STD_TabDesktop.cxx b/src/STD/STD_TabDesktop.cxx index 645188035..8b6c41b08 100644 --- a/src/STD/STD_TabDesktop.cxx +++ b/src/STD/STD_TabDesktop.cxx @@ -25,35 +25,37 @@ #include #include #include -#include +//#include -#include -#include -#include -#include +#include +#include #include /*!Constructor.Create new instances of QVBox and QtxWorkstack.*/ STD_TabDesktop::STD_TabDesktop() : SUIT_Desktop(), -myWorkstack( 0 ), -myWorkstackAction( 0 ) +myWorkstack( 0 )//, +//myWorkstackAction( 0 ) { - QVBox* base = new QVBox( this ); + QFrame* base = new QFrame( this ); base->setFrameStyle( QFrame::Panel | QFrame::Sunken ); + QVBoxLayout* main = new QVBoxLayout( base ); + main->setMargin( 0 ); + setCentralWidget( base ); myWorkstack = new QtxWorkstack( base ); + main->addWidget( myWorkstack ); // setting Expanding size policy for central workstack. If there are several widgets // in central area of Desktop, other widgets will be added below the workstack (CATHARE, TRIPOLI modules). // But the workstack must occupy as much space as possible -- set Expanding for it. myWorkstack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); - myWorkstack->setAccel(QtxWorkstack::SplitVertical, SHIFT + Key_V); - myWorkstack->setAccel(QtxWorkstack::SplitHorizontal, SHIFT + Key_H); - myWorkstack->setAccel(QtxWorkstack::Close, SHIFT + Key_C); + myWorkstack->setAccel( QtxWorkstack::SplitVertical, Qt::SHIFT + Qt::Key_V ); + myWorkstack->setAccel( QtxWorkstack::SplitHorizontal, Qt::SHIFT + Qt::Key_H ); + myWorkstack->setAccel( QtxWorkstack::Close, Qt::SHIFT + Qt::Key_C ); connect( myWorkstack, SIGNAL( windowActivated( QWidget* ) ), this, SLOT( onWindowActivated( QWidget* ) ) ); @@ -79,30 +81,33 @@ SUIT_ViewWindow* STD_TabDesktop::activeWindow() const } /*!\retval QPtrList - return const active window list.*/ -QPtrList STD_TabDesktop::windows() const +QList STD_TabDesktop::windows() const { - QPtrList winList; + QList winList; QWidgetList children = myWorkstack->windowList(); - for ( QWidgetListIt it( children ); it.current(); ++it ) + for ( QWidgetList::iterator it = children.begin(); it != children.end(); ++it ) { - if ( it.current()->inherits( "SUIT_ViewWindow" ) ) - winList.append( (SUIT_ViewWindow*)it.current() ); + if ( (*it)->inherits( "SUIT_ViewWindow" ) ) + winList.append( (SUIT_ViewWindow*)*it ); } return winList; } -/*!\retval QWidget pointer - QT work stack.*/ -QWidget* STD_TabDesktop::parentArea() const +/*! insert new widget into desktop.*/ +void STD_TabDesktop::addWindow( QWidget* w ) { - return workstack(); + if ( !w || !workstack() ) + return; + + workstack()->addWindow( w ); } /*!Call method perform for operation \a type.*/ void STD_TabDesktop::windowOperation( const int type ) { - myWorkstackAction->perform( operationFlag( type ) ); +// myWorkstackAction->perform( operationFlag( type ) ); } /*!Sets window operations by \a first ... parameters.*/ @@ -111,7 +116,7 @@ void STD_TabDesktop::setWindowOperations( const int first, ... ) va_list ints; va_start( ints, first ); - QValueList typeList; + QList typeList; int cur = first; while ( cur ) @@ -124,14 +129,14 @@ void STD_TabDesktop::setWindowOperations( const int first, ... ) } /*!Sets window operations by variable \a opList - operation list.*/ -void STD_TabDesktop::setWindowOperations( const QValueList& opList ) +void STD_TabDesktop::setWindowOperations( const QList& opList ) { int flags = 0; - for ( QValueList::const_iterator it = opList.begin(); it != opList.end(); ++it ) + for ( QList::const_iterator it = opList.begin(); it != opList.end(); ++it ) flags = flags | operationFlag( *it ); - myWorkstackAction->setItems( flags ); +// myWorkstackAction->setItems( flags ); } /*!\retval QtxWorkstack pointer - QT work stack.*/ @@ -150,6 +155,7 @@ void STD_TabDesktop::onWindowActivated( QWidget* w ) /*!Create actions for window.*/ void STD_TabDesktop::createActions() { +/* if ( myWorkstackAction ) return; @@ -180,12 +186,14 @@ void STD_TabDesktop::createActions() int winMenuId = mMgr->insert( tr( "MEN_DESK_WINDOW" ), -1, 100, MenuWindowId ); mMgr->insert( myWorkstackAction, winMenuId, -1 ); mMgr->insert( QtxActionMenuMgr::separator(), winMenuId, -1 ); +*/ } /*!Convert STD_TabDesktop enumerations to QtxWorkstackAction*/ int STD_TabDesktop::operationFlag( const int type ) const { int res = 0; +/* switch ( type ) { case VSplit: @@ -195,5 +203,6 @@ int STD_TabDesktop::operationFlag( const int type ) const res = QtxWorkstackAction::HSplit; break; } +*/ return res; } diff --git a/src/STD/STD_TabDesktop.h b/src/STD/STD_TabDesktop.h index aa63db065..1d5c2ecb8 100644 --- a/src/STD/STD_TabDesktop.h +++ b/src/STD/STD_TabDesktop.h @@ -27,9 +27,9 @@ class QtxAction; class QPopupMenu; class QWorkspace; class QtxWorkstack; -class QtxWorkstackAction; +//class QtxWorkstackAction; -#if defined WNT +#if defined WIN32 #pragma warning( disable: 4251 ) #endif @@ -46,12 +46,12 @@ public: virtual ~STD_TabDesktop(); virtual SUIT_ViewWindow* activeWindow() const; - virtual QPtrList windows() const; + virtual QList windows() const; void windowOperation( const int ); void setWindowOperations( const int, ... ); - void setWindowOperations( const QValueList& ); + void setWindowOperations( const QList& ); QtxWorkstack* workstack() const; @@ -60,17 +60,17 @@ private slots: protected: void createActions(); - virtual QWidget* parentArea() const; + virtual void addWindow( QWidget* ); private: int operationFlag( const int ) const; private: QtxWorkstack* myWorkstack; - QtxWorkstackAction* myWorkstackAction; +// QtxWorkstackAction* myWorkstackAction; }; -#if defined WNT +#if defined WIN32 #pragma warning( default: 4251 ) #endif diff --git a/src/STD/resources/STD_images.po b/src/STD/resources/STD_images.po deleted file mode 100755 index 71e0a9947..000000000 --- a/src/STD/resources/STD_images.po +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# This is a Qt message file in .po format. Each msgid starts with -# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" -# would be translated to "Pub", not "Foo::Pub". -msgid "" -msgstr "" -"Project-Id-Version: example-Qt-message-extraction\n" -"POT-Creation-Date: 1999-02-23 15:38+0200\n" -"PO-Revision-Date: 1999-02-23 15:38+0200\n" -"Last-Translator: \n" -"Content-Type: text/plain; charset=iso-8859-1\n" - -msgid "ICON_DESK_DEFAULTICON" -msgstr "default.png" - -msgid "ICON_APP_DEFAULTICON" -msgstr "default.png" - -msgid "ICON_FILE_NEW" -msgstr "new.png" - -msgid "ICON_FILE_OPEN" -msgstr "open.png" - -msgid "ICON_FILE_SAVE" -msgstr "save.png" - -msgid "ICON_FILE_CLOSE" -msgstr "close.png" - -msgid "ICON_EDIT_CUT" -msgstr "cut.png" - -msgid "ICON_EDIT_COPY" -msgstr "copy.png" - -msgid "ICON_EDIT_PASTE" -msgstr "paste.png" - -msgid "ICON_HELP" -msgstr "help.png" - -msgid "ICON_PRINT" -msgstr "print.png" - -msgid "ICON_RESET" -msgstr "reset.png" - -msgid "ICON_DESK_WINDOW_CASCADE" -msgstr "cascade.png" - -msgid "ICON_DESK_WINDOW_TILE" -msgstr "tile.png" - -msgid "ICON_DESK_WINDOW_VTILE" -msgstr "vtile.png" - -msgid "ICON_DESK_WINDOW_HTILE" -msgstr "htile.png" - -msgid "ICON_DESK_WINDOW_VSPLIT" -msgstr "vtile.png" - -msgid "ICON_DESK_WINDOW_HSPLIT" -msgstr "htile.png" - -msgid "ICON_APP_EDIT_UNDO" -msgstr "undo.png" - -msgid "ICON_APP_EDIT_REDO" -msgstr "redo.png" - -msgid "SUIT_ViewPort::ICON_CURSOR_ROTATE" -msgstr "cursor_rotate.png" - -msgid "SUIT_ViewPort::ICON_CURSOR_ZOOM" -msgstr "cursor_zoom.png" diff --git a/src/STD/resources/STD_images.ts b/src/STD/resources/STD_images.ts new file mode 100644 index 000000000..c7b4d3fd1 --- /dev/null +++ b/src/STD/resources/STD_images.ts @@ -0,0 +1,106 @@ + + + + @default + + + ICON_FILE_NEW + new.png + + + + ICON_DESK_WINDOW_TILE + tile.png + + + + ICON_PRINT + print.png + + + + ICON_RESET + reset.png + + + + ICON_HELP + help.png + + + + ICON_EDIT_CUT + cut.png + + + + ICON_DESK_WINDOW_CASCADE + cascade.png + + + + ICON_EDIT_COPY + copy.png + + + + ICON_APP_DEFAULTICON + default.png + + + + ICON_FILE_SAVE + save.png + + + + ICON_FILE_OPEN + open.png + + + + ICON_DESK_WINDOW_HSPLIT + htile.png + + + + ICON_APP_EDIT_REDO + redo.png + + + + ICON_APP_EDIT_UNDO + undo.png + + + + ICON_DESK_WINDOW_VSPLIT + vtile.png + + + + ICON_DESK_DEFAULTICON + default.png + + + + ICON_DESK_WINDOW_HTILE + htile.png + + + + ICON_DESK_WINDOW_VTILE + vtile.png + + + + ICON_EDIT_PASTE + paste.png + + + + ICON_FILE_CLOSE + close.png + + + diff --git a/src/STD/resources/STD_msg_en.po b/src/STD/resources/STD_msg_en.po deleted file mode 100755 index eef69e683..000000000 --- a/src/STD/resources/STD_msg_en.po +++ /dev/null @@ -1,379 +0,0 @@ -# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# This is a Qt message file in .po format. Each msgid starts with -# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" -# would be translated to "Pub", not "Foo::Pub". -msgid "" -msgstr "" -"Project-Id-Version: example-Qt-message-extraction\n" -"POT-Creation-Date: 1999-02-23 15:38+0200\n" -"PO-Revision-Date: 1999-02-23 15:38+0200\n" -"Last-Translator: \n" -"Content-Type: text/plain; charset=iso-8859-1\n" - -msgid "INF_READY" -msgstr "Ready" - -msgid "BUT_OK" -msgstr "&Ok" - -msgid "BUT_CANCEL" -msgstr "&Cancel" - -msgid "BUT_CLOSE" -msgstr "&Close" - -msgid "BUT_HELP" -msgstr "&Help" - -msgid "BUT_YES" -msgstr "&Yes" - -msgid "BUT_NO" -msgstr "&No" - -msgid "BUT_APPLY" -msgstr "&Apply" - -msgid "ERR_ERROR" -msgstr "Error" - -msgid "WRN_WARNING" -msgstr "Warning" - -msgid "INF_INFO" -msgstr "Information" - -msgid "FILTER_FILES" -msgstr "%1 Files (%2)" - -msgid "ALL_FILES" -msgstr "All Files (*.*)" - -msgid "INF_CANCELLED" -msgstr "Cancelled" - -msgid "ERR_UNKNOWN" -msgstr "Unknown error" - -## ---------------------------------------------------- - -msgid "INF_DESK_DOC_CREATE" -msgstr "Create a new document" - -msgid "ERR_APP_NOAPP" -msgstr "No application" - -msgid "INF_DESK_EXIT" -msgstr "Exit" - -msgid "INF_DESK_TOOLBAR_STANDARD" -msgstr "Standard" - -msgid "MEN_DESK_FILE" -msgstr "&File" - -msgid "MEN_DESK_FILE_CLOSE" -msgstr "&Close" - -msgid "MEN_DESK_FILE_EXIT" -msgstr "E&xit" - -msgid "MEN_DESK_FILE_NEW" -msgstr "&New" - -msgid "MEN_DESK_FILE_OPEN" -msgstr "&Open..." - -msgid "MEN_DESK_FILE_PRINT" -msgstr "&Print" - -msgid "MEN_DESK_FILE_SAVE" -msgstr "&Save" - -msgid "MEN_DESK_FILE_SAVEAS" -msgstr "Save &As..." - -msgid "MEN_DESK_EDIT" -msgstr "&Edit" - -msgid "MEN_DESK_EDIT_CUT" -msgstr "Cu&t" - -msgid "MEN_DESK_EDIT_COPY" -msgstr "&Copy" - -msgid "MEN_DESK_EDIT_PASTE" -msgstr "&Paste" - -msgid "MEN_DESK_HELP" -msgstr "&Help" - -msgid "MEN_DESK_HELP_ABOUT" -msgstr "&About..." - -msgid "MEN_DESK_HELP_CONTENTS" -msgstr "&Contents" - -msgid "MEN_DESK_HELP_SEARCH" -msgstr "&Search..." - -msgid "MEN_DESK_VIEW" -msgstr "&View" - -msgid "MEN_DESK_VIEW_TOOLBARS" -msgstr "T&oolbars" - -msgid "MEN_DESK_VIEW_STATUSBAR" -msgstr "&Status Bar" - -msgid "MEN_DESK_VIEW_STDTOOLBAR" -msgstr "&Standard" - -msgid "PRP_DESK_FILE_CLOSE" -msgstr "Closes the active document" - -msgid "PRP_DESK_FILE_EXIT" -msgstr "Exits the application" - -msgid "PRP_DESK_FILE_NEW" -msgstr "Creates a new document" - -msgid "PRP_DESK_FILE_OPEN" -msgstr "Opens an existing document" - -msgid "PRP_DESK_FILE_PRINT" -msgstr "Prints the active document" - -msgid "PRP_DESK_FILE_SAVE" -msgstr "Saves the active document" - -msgid "PRP_DESK_FILE_SAVEAS" -msgstr "Saves the active document with a new name" - -msgid "PRP_DESK_EDIT_CUT" -msgstr "Cuts the selection and puts it to the Clipboard" - -msgid "PRP_DESK_EDIT_COPY" -msgstr "Copy the selection to the Clipboard" - -msgid "PRP_DESK_EDIT_PASTE" -msgstr "Inserts the Clipboard content at the insertion point" - -msgid "PRP_DESK_HELP_ABOUT" -msgstr "Shows \'About\' dialog" - -msgid "PRP_DESK_HELP_CONTENTS" -msgstr "Shows the whole help contents" - -msgid "PRP_DESK_HELP_SEARCH" -msgstr "Searches help for a topic" - -msgid "PRP_DESK_VIEW_STATUSBAR" -msgstr "Toggles status bar view on/off" - -msgid "PRP_DESK_VIEW_STDTOOLBAR" -msgstr "Toggles standard toolbar on/off" - -msgid "QUE_DESK_EXIT" -msgstr "Do you really want to quit ?" - -msgid "TOT_DESK_FILE_NEW" -msgstr "New document" - -msgid "TOT_DESK_FILE_OPEN" -msgstr "Open document" - -msgid "TOT_DESK_FILE_CLOSE" -msgstr "Close document" - -msgid "TOT_DESK_FILE_PRINT" -msgstr "Print document" - -msgid "TOT_DESK_FILE_SAVE" -msgstr "Save document" - -msgid "TOT_DESK_FILE_SAVEAS" -msgstr "Save document as..." - -msgid "TOT_DESK_FILE_EXIT" -msgstr "Exit from application" - -msgid "TOT_DESK_EDIT_CUT" -msgstr "Cut" - -msgid "TOT_DESK_EDIT_COPY" -msgstr "Copy" - -msgid "TOT_DESK_EDIT_PASTE" -msgstr "Paste" - -msgid "TOT_DESK_HELP_ABOUT" -msgstr "About..." - -msgid "STD_Application::TOT_DOCK_WINDOWS" -msgstr "Show / hide dockable windows and toolbars" - -msgid "STD_Application::MEN_DOCK_WINDOWS" -msgstr "Windows and Toolbars" - -msgid "ERR_DOC_UNKNOWNTYPE_OPEN" -msgstr "You are trying to open a document of an unknown type\n( %1 )" - -msgid "ERR_DOC_UNKNOWNTYPE_SAVE" -msgstr "You are trying to save this document under an unknown type\n( %1 )" - -msgid "ERR_DOC_PERMISSIONDENIED_SAVE" -msgstr "Can not save file %1. Permission denied" - -msgid "ERR_DOC_DIRWITHNAMEEXIST_SAVE" -msgstr "Can not save file %1.\nDirectory with this name exist on disc. Try to use another name" - -msgid "QUE_DOC_FILEEXISTS" -msgstr "The file %1 already exists.\nDo you want to overwrite it ?" - -msgid "ERR_DESK_NOAPP" -msgstr "No applications registered" - -msgid "DESK_DEFAULTTITLE" -msgstr "Qt Application Desktop" - -msgid "QUE_DOC_ALREADYOPEN" -msgstr "The document %1 is already open.\nDo you want to reload it ?" - -msgid "MEN_DESK_WINDOW" -msgstr "&Window" - -msgid "MEN_DESK_NEWWINDOW" -msgstr "&New Window" - -msgid "TOT_DESK_NEWWINDOW" -msgstr "Create new Window" - -msgid "PRP_DESK_NEWWINDOW" -msgstr "Create new Window" - -msgid "MEN_DESK_WINDOW_CASCADE" -msgstr "&Cascade" - -msgid "PRP_DESK_WINDOW_CASCADE" -msgstr "Arranges the windows as overlapping tiles" - -msgid "MEN_DESK_WINDOW_TILE" -msgstr "&Tile" - -msgid "PRP_DESK_WINDOW_TILE" -msgstr "Arranges the windows as nonoverlapping tiles" - -msgid "MEN_DESK_WINDOW_HTILE" -msgstr "Tile &Horizontally" - -msgid "PRP_DESK_WINDOW_HTILE" -msgstr "Arranges the windows as nonoverlapping horizontal tiles" - -msgid "MEN_DESK_WINDOW_VTILE" -msgstr "Tile &Vertically" - -msgid "PRP_DESK_WINDOW_VTILE" -msgstr "Arranges the windows as nonoverlapping vertical tiles" - -msgid "PRP_DESK_WINDOW_ACTIVATE" -msgstr "Activates this window" - -msgid "MEN_DESK_WINDOW_HSPLIT" -msgstr "Split &Horizontally" - -msgid "PRP_DESK_WINDOW_HSPLIT" -msgstr "Splits the active window on two horizontal parts" - -msgid "MEN_DESK_WINDOW_VSPLIT" -msgstr "Split &Vertically" - -msgid "PRP_DESK_WINDOW_VSPLIT" -msgstr "Splits the active window on two vertical parts" - -msgid "INF_DESK_DOCALREADYOPEN" -msgstr "A document cannot be saved under a name of a document already opened.\nPlease, type another name for the document you want to save.\n( %1 )" - -msgid "MEN_DESK_FILE_MRU" -msgstr "Recent &Files" - -msgid "PRP_DESK_FILE_MRU" -msgstr "Opens a document" - -msgid "STD_Application::ABOUT_INFO" -msgstr "SUIT Std application" - -msgid "MSG_FILE_EXISTS" -msgstr "File \"%1\" already exists.\nDo you want to overwrite it?" - -msgid "MSG_CANT_SAVE" -msgstr "Can't save file \"%1\"." - -msgid "TIT_FILE_SAVEAS" -msgstr "Save As" - -msgid "STD_Application::INF_DOC_MODIFIED" -msgstr "Document has been modified.\nDo you want to save changes?" - -msgid "STD_Application::INF_DOCUMENT_MODIFIED" -msgstr "Document \"%1\" has been modified.\nDo you want to save changes?" - -msgid "STD_Application::INF_DOC_SAVED" -msgstr "Study %1 saved" - -msgid "STD_Application::INF_DOC_SAVING" -msgstr "Saving study " - -msgid "STD_Application::INF_DOC_SAVING_FAILS" -msgstr "Can't save file \"%1\".\nPossible reason is permission denied or disc full.\nTry to use another file name." - -msgid "CLOSE_DLG_SAVE_CLOSE" -msgstr "&Save&&Close" - -msgid "CLOSE_DLG_CLOSE" -msgstr "C&lose w/o saving" - -msgid "CLOSE_DLG_UNLOAD" -msgstr "&Unload" - -msgid "TOT_DESK_FILE_LOAD" -msgstr "Load document" - -msgid "PRP_DESK_FILE_LOAD" -msgstr "Load a document" - -msgid "MEN_DESK_FILE_LOAD" -msgstr "Conn&ect..." - -msgid "CLOSE_DLG_CAPTION" -msgstr "Close active study" - -msgid "CLOSE_DLG_DESCRIPTION" -msgstr "Do you want to close or only unload the study" - -msgid "DLG_LOAD_STUDY_CAPTION" -msgstr "Load Study" - -msgid "MEN_STUDIES_CHOICE" -msgstr "Choose existent study." - - - - diff --git a/src/STD/resources/STD_msg_en.ts b/src/STD/resources/STD_msg_en.ts new file mode 100644 index 000000000..0f0c794ab --- /dev/null +++ b/src/STD/resources/STD_msg_en.ts @@ -0,0 +1,480 @@ + + + @default + + TOT_DESK_EDIT_CUT + Cut + + + PRP_DESK_EDIT_CUT + Cuts the selection and puts it to the Clipboard + + + MEN_DESK_EDIT_CUT + Cu&t + + + ERR_APP_NOAPP + No application + + + MEN_DESK_WINDOW + &Window + + + TOT_DESK_EDIT_COPY + Copy + + + MEN_DESK_WINDOW_CASCADE + &Cascade + + + PRP_DESK_EDIT_COPY + Copy the selection to the Clipboard + + + PRP_DESK_WINDOW_CASCADE + Arranges the windows as overlapping tiles + + + TOT_DESK_FILE_SAVEAS + Save document as... + + + MEN_DESK_EDIT_COPY + &Copy + + + MSG_CANT_SAVE + Can't save file "%1". + + + INF_DESK_TOOLBAR_STANDARD + Standard + + + ALL_FILES + All Files (*.*) + + + DESK_DEFAULTTITLE + Qt Application Desktop + + + QUE_DESK_EXIT + Do you really want to quit ? + + + INF_INFO + Information + + + ERR_DOC_UNKNOWNTYPE_OPEN + You are trying to open a document of an unknown type +( %1 ) + + + ERR_DOC_UNKNOWNTYPE_SAVE + You are trying to save this document under an unknown type +( %1 ) + + + CLOSE_DLG_UNLOAD + &Unload + + + TOT_DESK_NEWWINDOW + Create new Window + + + BUT_CANCEL + &Cancel + + + MEN_DESK_HELP_ABOUT + &About... + + + PRP_DESK_NEWWINDOW + Create new Window + + + MEN_DESK_VIEW_STATUSBAR + &Status Bar + + + MEN_DESK_NEWWINDOW + &New Window + + + PRP_DESK_VIEW_STATUSBAR + Toggles status bar view on/off + + + ERR_DOC_DIRWITHNAMEEXIST_SAVE + Can not save file %1. +Directory with this name exist on disc. Try to use another name + + + BUT_NO + &No + + + BUT_OK + &Ok + + + FILTER_FILES + %1 Files (%2) + + + PRP_DESK_WINDOW_ACTIVATE + Activates this window + + + TOT_DESK_FILE_PRINT + Print document + + + TOT_DESK_FILE_CLOSE + Close document + + + TOT_DESK_FILE_NEW + New document + + + PRP_DESK_FILE_NEW + Creates a new document + + + PRP_DESK_FILE_MRU + Opens a document + + + MEN_DESK_FILE_NEW + &New + + + MEN_DESK_FILE_MRU + Recent &Files + + + TOT_DESK_EDIT_PASTE + Paste + + + BUT_YES + &Yes + + + MEN_DESK_VIEW + &View + + + PRP_DESK_HELP_ABOUT + Shows 'About' dialog + + + MEN_DESK_FILE + &File + + + MEN_DESK_EDIT + &Edit + + + MEN_DESK_HELP + &Help + + + ERR_ERROR + Error + + + ERR_DESK_NOAPP + No applications registered + + + CLOSE_DLG_CLOSE + C&lose w/o saving + + + INF_DESK_DOC_CREATE + Create a new document + + + QUE_DOC_ALREADYOPEN + The document %1 is already open. +Do you want to reload it ? + + + BUT_APPLY + &Apply + + + BUT_CLOSE + &Close + + + INF_DESK_EXIT + Exit + + + ERR_UNKNOWN + Unknown error + + + BUT_HELP + &Help + + + PRP_DESK_FILE_CLOSE + Closes the active document + + + PRP_DESK_FILE_PRINT + Prints the active document + + + WRN_WARNING + Warning + + + TOT_DESK_HELP_ABOUT + About... + + + MEN_DESK_VIEW_TOOLBARS + T&oolbars + + + PRP_DESK_WINDOW_HSPLIT + Splits the active window on two horizontal parts + + + MEN_DESK_WINDOW_HSPLIT + Split &Horizontally + + + PRP_DESK_EDIT_PASTE + Inserts the Clipboard content at the insertion point + + + DLG_LOAD_STUDY_CAPTION + Load Study + + + CLOSE_DLG_CAPTION + Close active study + + + PRP_DESK_HELP_SEARCH + Searches help for a topic + + + PRP_DESK_FILE_SAVEAS + Saves the active document with a new name + + + INF_READY + Ready + + + INF_CANCELLED + Cancelled + + + CLOSE_DLG_SAVE_CLOSE + &Save&&Close + + + PRP_DESK_WINDOW_VSPLIT + Splits the active window on two vertical parts + + + MEN_DESK_WINDOW_VSPLIT + Split &Vertically + + + PRP_DESK_WINDOW_TILE + Arranges the windows as nonoverlapping tiles + + + MEN_DESK_HELP_CONTENTS + &Contents + + + PRP_DESK_HELP_CONTENTS + Shows the whole help contents + + + MEN_DESK_WINDOW_HTILE + Tile &Horizontally + + + MEN_DESK_WINDOW_VTILE + Tile &Vertically + + + ERR_DOC_PERMISSIONDENIED_SAVE + Can not save file %1. Permission denied + + + INF_DESK_DOCALREADYOPEN + A document cannot be saved under a name of a document already opened. +Please, type another name for the document you want to save. +( %1 ) + + + TIT_FILE_SAVEAS + Save As + + + MEN_DESK_FILE_CLOSE + &Close + + + MSG_FILE_EXISTS + File "%1" already exists. +Do you want to overwrite it? + + + MEN_DESK_FILE_PRINT + &Print + + + MEN_DESK_HELP_SEARCH + &Search... + + + MEN_DESK_VIEW_STDTOOLBAR + &Standard + + + MEN_DESK_FILE_SAVEAS + Save &As... + + + PRP_DESK_VIEW_STDTOOLBAR + Toggles standard toolbar on/off + + + QUE_DOC_FILEEXISTS + The file %1 already exists. +Do you want to overwrite it ? + + + TOT_DESK_FILE_SAVE + Save document + + + TOT_DESK_FILE_EXIT + Exit from application + + + TOT_DESK_FILE_LOAD + Load document + + + TOT_DESK_FILE_OPEN + Open document + + + CLOSE_DLG_DESCRIPTION + Do you want to close or only unload the study + + + PRP_DESK_FILE_EXIT + Exits the application + + + PRP_DESK_FILE_OPEN + Opens an existing document + + + PRP_DESK_FILE_SAVE + Saves the active document + + + PRP_DESK_FILE_LOAD + Load a document + + + PRP_DESK_WINDOW_HTILE + Arranges the windows as nonoverlapping horizontal tiles + + + PRP_DESK_WINDOW_VTILE + Arranges the windows as nonoverlapping vertical tiles + + + MEN_DESK_WINDOW_TILE + &Tile + + + MEN_DESK_FILE_EXIT + E&xit + + + MEN_DESK_FILE_OPEN + &Open... + + + MEN_DESK_FILE_LOAD + Conn&ect... + + + MEN_DESK_FILE_SAVE + &Save + + + MEN_DESK_EDIT_PASTE + &Paste + + + MEN_STUDIES_CHOICE + Choose existent study. + + + + STD_Application + + INF_DOC_MODIFIED + Document has been modified. +Do you want to save changes? + + + INF_DOC_SAVING + Saving study + + + INF_DOC_SAVED + Study %1 saved + + + TOT_DOCK_WINDOWS + Show / hide dockable windows and toolbars + + + MEN_DOCK_WINDOWS + Windows and Toolbars + + + ABOUT_INFO + SUIT Std application + + + INF_DOC_SAVING_FAILS + Can't save file "%1". +Possible reason is permission denied or disc full. +Try to use another file name. + + + INF_DOCUMENT_MODIFIED + Document "%1" has been modified. +Do you want to save changes? + + + diff --git a/src/STD/resources/config b/src/STD/resources/config deleted file mode 100755 index e3471120d..000000000 --- a/src/STD/resources/config +++ /dev/null @@ -1 +0,0 @@ -language=en diff --git a/src/SUIT/SUIT.pro b/src/SUIT/SUIT.pro new file mode 100644 index 000000000..773dd3402 --- /dev/null +++ b/src/SUIT/SUIT.pro @@ -0,0 +1,30 @@ +TEMPLATE = lib +DESTDIR = ../../lib +MOC_DIR = ../../moc +OBJECTS_DIR = ../../obj/$$TARGET + +INCLUDEPATH = ../../include +LIBS += -L../../lib -lQtx + +CONFIG -= debug release debug_and_release +CONFIG += qt thread debug dll shared + +win32:DEFINES += WIN32 +DEFINES += SUIT_EXPORTS + +HEADERS = *.h + +SOURCES = *.cxx + +TRANSLATIONS = resources/SUIT_images.ts \ + resources/SUIT_msg_en.ts + +ICONS = resources/*.png + +includes.files = $$HEADERS +includes.path = ../../include + +resources.files = $$ICONS resources/*.qm +resources.path = ../../resources + +INSTALLS += includes resources diff --git a/src/SUIT/resources/SUIT_images.po b/src/SUIT/resources/SUIT_images.po deleted file mode 100755 index 88441a5f1..000000000 --- a/src/SUIT/resources/SUIT_images.po +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# This is a Qt message file in .po format. Each msgid starts with -# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" -# would be translated to "Pub", not "Foo::Pub". -msgid "" -msgstr "" -"Project-Id-Version: example-Qt-message-extraction\n" -"POT-Creation-Date: 1999-02-23 15:38+0200\n" -"PO-Revision-Date: 1999-02-23 15:38+0200\n" -"Last-Translator: \n" -"Content-Type: text/plain; charset=iso-8859-1\n" - -msgid "ICON_DESK_WINDOW_CASCADE" -msgstr "cascade.png" - -msgid "ICON_DESK_WINDOW_VTILE" -msgstr "vtile.png" - -msgid "ICON_DESK_WINDOW_TILE" -msgstr "htile.png" - diff --git a/src/SUIT/resources/SUIT_images.ts b/src/SUIT/resources/SUIT_images.ts new file mode 100644 index 000000000..c7c438f3d --- /dev/null +++ b/src/SUIT/resources/SUIT_images.ts @@ -0,0 +1,17 @@ + + + @default + + ICON_DESK_WINDOW_TILE + htile.png + + + ICON_DESK_WINDOW_CASCADE + cascade.png + + + ICON_DESK_WINDOW_VTILE + vtile.png + + + diff --git a/src/SUIT/resources/SUIT_msg_en.po b/src/SUIT/resources/SUIT_msg_en.po deleted file mode 100755 index 480ab305b..000000000 --- a/src/SUIT/resources/SUIT_msg_en.po +++ /dev/null @@ -1,118 +0,0 @@ -# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# This is a Qt message file in .po format. Each msgid starts with -# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" -# would be translated to "Pub", not "Foo::Pub". -msgid "" -msgstr "" -"Project-Id-Version: example-Qt-message-extraction\n" -"POT-Creation-Date: 1999-02-23 15:38+0200\n" -"PO-Revision-Date: 1999-02-23 15:38+0200\n" -"Last-Translator: \n" -"Content-Type: text/plain; charset=iso-8859-1\n" - -msgid "MEN_DESK_WINDOW" -msgstr "&Window" - -msgid "MEN_DESK_WINDOW_CASCADE" -msgstr "&Cascade" - -msgid "PRP_DESK_WINDOW_CASCADE" -msgstr "Arranges the windows as overlapping tiles" - -msgid "MEN_DESK_WINDOW_TILE" -msgstr "&Tile" - -msgid "PRP_DESK_WINDOW_TILE" -msgstr "Arranges the windows as nonoverlapping tiles" - -msgid "MEN_DESK_WINDOW_VTILE" -msgstr "Tile &Vertically" - -msgid "PRP_DESK_WINDOW_VTILE" -msgstr "Arranges the windows as nonoverlapping vertical tiles" - -msgid "PRP_DESK_WINDOW_ACTIVATE" -msgstr "Activates this window" - -msgid "LAB_QUICK_PATH" -msgstr "Quick path:" - -msgid "BUT_ADD_PATH" -msgstr "Add path" - -msgid "INF_DESK_DOC_OPEN" -msgstr "Open File" - -msgid "INF_DESK_DOC_SAVE" -msgstr "Save File" - -msgid "ERR_ERROR" -msgstr "Error" - -msgid "WRN_WARNING" -msgstr "Warning" - -msgid "ERR_DIR_NOT_EXIST" -msgstr "The directory \"%1\" does not exist!" - -msgid "ERR_FILE_NOT_EXIST" -msgstr "The file \"%1\" does not exist!" - -msgid "ERR_PERMISSION_DENIED" -msgstr "Can't save file \"%1\".\nPermission denied." - -msgid "INF_DIRECTORIES_FILTER" -msgstr "Directories" - -msgid "QUE_FILE_EXISTS" -msgstr "The file \"%1\" already exists.\nDo you want to overwrite it?" - -msgid "TLT_DUMP_VIEW" -msgstr "Dump View to File" - -msgid "TLT_IMAGE_FILES" -msgstr "Images Files (*.bmp *.png *.jpg *.jpeg)"" - -msgid "ERR_CANT_DUMP_VIEW" -msgstr "Can't dump view contents to the file." - -msgid "CONTINUE" -msgstr "Continue" - -msgid "CANCEL" -msgstr "Cancel" - -#====================================================================== - -msgid "SUIT_Study::OPERATION_LAUNCH" -msgstr "Operation launch" - -msgid "SUIT_Study::PREVIOUS_NOT_FINISHED" -msgstr "Previous operation is not finished and will be aborted" - -#====================================================================== - - - - - - - - \ No newline at end of file diff --git a/src/SUIT/resources/SUIT_msg_en.ts b/src/SUIT/resources/SUIT_msg_en.ts new file mode 100644 index 000000000..ac28fa7ae --- /dev/null +++ b/src/SUIT/resources/SUIT_msg_en.ts @@ -0,0 +1,141 @@ + + + + @default + + + MEN_DESK_WINDOW + &Window + + + + ERR_CANT_DUMP_VIEW + Can't dump view contents to the file. + + + + TLT_IMAGE_FILES + Images Files (*.bmp *.png *.jpg *.jpeg) + + + + MEN_DESK_WINDOW_CASCADE + &Cascade + + + + PRP_DESK_WINDOW_CASCADE + Arranges the windows as overlapping tiles + + + + ERR_DIR_NOT_EXIST + The directory "%1" does not exist! + + + + LAB_QUICK_PATH + Quick path: + + + + CONTINUE + Continue + + + + CANCEL + Cancel + + + + ERR_FILE_NOT_EXIST + The file "%1" does not exist! + + + + PRP_DESK_WINDOW_ACTIVATE + Activates this window + + + + ERR_PERMISSION_DENIED + Can't save file "%1". +Permission denied. + + + + ERR_ERROR + Error + + + + QUE_FILE_EXISTS + The file "%1" already exists. +Do you want to overwrite it? + + + + WRN_WARNING + Warning + + + + TLT_DUMP_VIEW + Dump View to File + + + + INF_DESK_DOC_OPEN + Open File + + + + INF_DESK_DOC_SAVE + Save File + + + + PRP_DESK_WINDOW_TILE + Arranges the windows as nonoverlapping tiles + + + + BUT_ADD_PATH + Add path + + + + MEN_DESK_WINDOW_VTILE + Tile &Vertically + + + + INF_DIRECTORIES_FILTER + Directories + + + + PRP_DESK_WINDOW_VTILE + Arranges the windows as nonoverlapping vertical tiles + + + + MEN_DESK_WINDOW_TILE + &Tile + + + + SUIT_Study + + + OPERATION_LAUNCH + Operation launch + + + + PREVIOUS_NOT_FINISHED + Previous operation is not finished and will be aborted + + + -- 2.39.2