-TEMPLATE = subdirs
+unix:TEMPLATE = subdirs
+win32:TEMPLATE = vcsubdirs
+
CONFIG += ordered
+win32:CONFIG += embed_manifest_exe
+
SUBDIRS = src/Qtx \
src/Style \
src/ObjBrowser \
-TEMPLATE = lib
+unix:TEMPLATE = lib
+win32:TEMPLATE = vclib
DESTDIR = ../../$(CONFIG_ID)/lib
MOC_DIR = ../../moc
lrelease.name = LRELASE ${QMAKE_FILE_IN}
unix:lrelease.commands = $(QTDIR)/bin/lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}/${QMAKE_FILE_BASE}.qm
-win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
+win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_IN} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
unix:lrelease.output = $${GUIResources}/${QMAKE_FILE_BASE}.qm
win32:lrelease.output = $${GUIResources}\\${QMAKE_FILE_BASE}.qm
lrelease.input = TRANSLATIONS
-TEMPLATE = lib
+unix:TEMPLATE = lib
+win32:TEMPLATE = vclib
DESTDIR = ../../$(CONFIG_ID)/lib
MOC_DIR = ../../moc
INCLUDEPATH += ../../include $${CAS_CPPFLAGS}
LIBS += -L../../$(CONFIG_ID)/lib $${CAS_KERNEL} $${CAS_VIEWER}
+win32:LIBS *= -L$(QTLIB)
+win32:INCLUDEPATH *= $(QTINC) $(QTINC)\QtCore $(QTINC)\QtGui $(QTINC)\QtXml
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared
-win32:DEFINES += WIN32
+win32:copy_hdr.name = Install ${QMAKE_FILE_IN}
+win32:copy_hdr.commands = type ${QMAKE_FILE_IN} > ../../include/${QMAKE_FILE_BASE}.hxx
+win32:copy_hdr.output = ../../include/${QMAKE_FILE_BASE}.hxx
+win32:copy_hdr.input = HEADERS
+win32:QMAKE_EXTRA_COMPILERS += copy_hdr
+
+win32:DEFINES += WNT WIN32
DEFINES += HTMLSERVICE_EXPORTS $(CASDEFINES) OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS
HEADERS = *.hxx
-// File: HTMLService_HTML.hxx\r
-// Created: 12.10.2006\r
-// Author: Sergey TELKOV\r
-// Copyright (C) AREVA NP 2006\r
-\r
-#ifndef HTMLSERVICE_HTML_H\r
-#define HTMLSERVICE_HTML_H\r
-\r
-#include <HTMLService.hxx>\r
-\r
-#include <MMgt_TShared.hxx>\r
-#include <Standard_DefineHandle.hxx>\r
-\r
-#include <NCollection_Sequence.hxx>\r
-#include <TCollection_ExtendedString.hxx>\r
-\r
-class Quantity_Color;\r
-class Handle(HTMLService_HTML);\r
-\r
-typedef NCollection_Sequence<TCollection_ExtendedString> SequenceOfHTMLLine;\r
-\r
-/*!\r
- Class HTMLService_HTML. Base class for HTML generation.\r
-*/\r
-\r
-class HTMLSERVICE_EXPORT HTMLService_HTML : public MMgt_TShared\r
-{\r
-public:\r
- enum { Left = 0x01, Right = 0x02, Center = 0x04,\r
- Top = 0x08, Bottom = 0x10, Middle = 0x20,\r
- HAlignment = Left | Right | Center, VAlignment = Top | Bottom | Middle } AlignmentFlags;\r
-\r
-public:\r
- Standard_EXPORT HTMLService_HTML();\r
- Standard_EXPORT HTMLService_HTML( const Handle(HTMLService_HTML)& );\r
- Standard_EXPORT ~HTMLService_HTML();\r
-\r
- Standard_EXPORT TCollection_ExtendedString GetTitle() const;\r
- Standard_EXPORT void SetTitle( const TCollection_ExtendedString& );\r
-\r
- Standard_EXPORT Standard_Boolean GenerateFile( const TCollection_ExtendedString&,\r
- const Standard_Boolean = Standard_False ) const;\r
- Standard_EXPORT SequenceOfHTMLLine GenerateText( const Standard_Boolean = Standard_False ) const;\r
-\r
- Standard_EXPORT static TCollection_ExtendedString ColorString( const Quantity_Color& );\r
- Standard_EXPORT static TCollection_ExtendedString AlignString( const Standard_Integer );\r
-\r
- Standard_EXPORT Standard_Boolean IsVisible() const;\r
- Standard_EXPORT void SetVisible( const Standard_Boolean );\r
-\r
-protected:\r
- Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const = 0;\r
- Standard_EXPORT virtual void SubItemsHTML( SequenceOfHTMLLine& ) const;\r
-\r
- Standard_EXPORT TCollection_ExtendedString EncloseToTag( const TCollection_ExtendedString&, const TCollection_ExtendedString&,\r
- const TCollection_ExtendedString& = TCollection_ExtendedString() ) const;\r
-\r
- Standard_EXPORT void ClearSubItems();\r
- Standard_EXPORT void InsertSubItem( const Handle(HTMLService_HTML)& );\r
- Standard_EXPORT void RemoveSubItem( const Handle(HTMLService_HTML)& );\r
-\r
- void AppendIndent( SequenceOfHTMLLine& ) const;\r
- void AppendIndent( TCollection_ExtendedString& ) const;\r
- void Concatenate( SequenceOfHTMLLine&, const SequenceOfHTMLLine& ) const;\r
-\r
-private:\r
- void BeginDocument( SequenceOfHTMLLine& ) const;\r
- void EndDocument( SequenceOfHTMLLine& ) const;\r
-\r
-private:\r
- typedef NCollection_Sequence<Handle(HTMLService_HTML)> HTMLSequence;\r
-\r
-private:\r
- TCollection_ExtendedString myTitle;\r
- Standard_Boolean myVisible;\r
- HTMLSequence mySubItems;\r
-\r
-public:\r
- DEFINE_STANDARD_RTTI(HTMLService_HTML)\r
-};\r
-\r
-DEFINE_STANDARD_HANDLE(HTMLService_HTML, MMgt_TShared)\r
-\r
-#endif\r
+// File: HTMLService_HTML.hxx
+// Created: 12.10.2006
+// Author: Sergey TELKOV
+// Copyright (C) AREVA NP 2006
+
+#ifndef HTMLSERVICE_HTML_H
+#define HTMLSERVICE_HTML_H
+
+#include <HTMLService.hxx>
+
+#include <MMgt_TShared.hxx>
+#include <Standard_DefineHandle.hxx>
+
+#include <NCollection_Sequence.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+class Quantity_Color;
+class Handle(HTMLService_HTML);
+
+typedef NCollection_Sequence<TCollection_ExtendedString> SequenceOfHTMLLine;
+
+/*!
+ Class HTMLService_HTML. Base class for HTML generation.
+*/
+
+class HTMLService_HTML : public MMgt_TShared
+{
+public:
+ enum { Left = 0x01, Right = 0x02, Center = 0x04,
+ Top = 0x08, Bottom = 0x10, Middle = 0x20,
+ HAlignment = Left | Right | Center, VAlignment = Top | Bottom | Middle } AlignmentFlags;
+
+public:
+ Standard_EXPORT HTMLService_HTML();
+ Standard_EXPORT HTMLService_HTML( const Handle(HTMLService_HTML)& );
+ Standard_EXPORT ~HTMLService_HTML();
+
+ Standard_EXPORT TCollection_ExtendedString GetTitle() const;
+ Standard_EXPORT void SetTitle( const TCollection_ExtendedString& );
+
+ Standard_EXPORT Standard_Boolean GenerateFile( const TCollection_ExtendedString&,
+ const Standard_Boolean = Standard_False ) const;
+ Standard_EXPORT SequenceOfHTMLLine GenerateText( const Standard_Boolean = Standard_False ) const;
+
+ Standard_EXPORT static TCollection_ExtendedString ColorString( const Quantity_Color& );
+ Standard_EXPORT static TCollection_ExtendedString AlignString( const Standard_Integer );
+
+ Standard_EXPORT Standard_Boolean IsVisible() const;
+ Standard_EXPORT void SetVisible( const Standard_Boolean );
+
+protected:
+ Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const = 0;
+ Standard_EXPORT virtual void SubItemsHTML( SequenceOfHTMLLine& ) const;
+
+ Standard_EXPORT TCollection_ExtendedString EncloseToTag( const TCollection_ExtendedString&, const TCollection_ExtendedString&,
+ const TCollection_ExtendedString& = TCollection_ExtendedString() ) const;
+
+ Standard_EXPORT void ClearSubItems();
+ Standard_EXPORT void InsertSubItem( const Handle(HTMLService_HTML)& );
+ Standard_EXPORT void RemoveSubItem( const Handle(HTMLService_HTML)& );
+
+ void AppendIndent( SequenceOfHTMLLine& ) const;
+ void AppendIndent( TCollection_ExtendedString& ) const;
+ void Concatenate( SequenceOfHTMLLine&, const SequenceOfHTMLLine& ) const;
+
+private:
+ void BeginDocument( SequenceOfHTMLLine& ) const;
+ void EndDocument( SequenceOfHTMLLine& ) const;
+
+private:
+ typedef NCollection_Sequence<Handle(HTMLService_HTML)> HTMLSequence;
+
+private:
+ TCollection_ExtendedString myTitle;
+ Standard_Boolean myVisible;
+ HTMLSequence mySubItems;
+
+public:
+ DEFINE_STANDARD_RTTI(HTMLService_HTML)
+};
+
+DEFINE_STANDARD_HANDLE(HTMLService_HTML, MMgt_TShared)
+
+#endif
-// File: HTMLService_HTMLImage.hxx\r
-// Created: 13.10.2006\r
-// Author: Sergey TELKOV\r
-// Copyright (C) AREVA NP 2006\r
-\r
-#ifndef HTMLSERVICE_HTMLIMAGE_H\r
-#define HTMLSERVICE_HTMLIMAGE_H\r
-\r
-#include <HTMLService.hxx>\r
-#include <HTMLService_HTML.hxx>\r
-\r
-#include <Quantity_Color.hxx>\r
-\r
-/*!\r
- Class HTMLService_HTMLImage. Generator of the HTML image.\r
-*/\r
-\r
-class HTMLSERVICE_EXPORT HTMLService_HTMLImage : public HTMLService_HTML\r
-{\r
-public:\r
- enum { SP_Unknown, SP_File, SP_HTTP, SP_FTP } SourceProtocol;\r
-\r
-public:\r
- Standard_EXPORT HTMLService_HTMLImage( const TCollection_ExtendedString& = TCollection_ExtendedString() );\r
- Standard_EXPORT HTMLService_HTMLImage( const Handle(HTMLService_HTML)&,\r
- const TCollection_ExtendedString& = TCollection_ExtendedString() );\r
- Standard_EXPORT virtual ~HTMLService_HTMLImage();\r
-\r
- Standard_EXPORT Standard_Integer GetWidth() const;\r
- Standard_EXPORT Standard_Integer GetHeight() const;\r
- Standard_EXPORT TCollection_ExtendedString GetSource() const;\r
- Standard_EXPORT Standard_Integer GetAlignment() const;\r
- Standard_EXPORT Standard_Integer GetSourceProtocol() const;\r
-\r
- Standard_EXPORT void SetWidth( const Standard_Integer );\r
- Standard_EXPORT void SetHeight( const Standard_Integer );\r
- Standard_EXPORT void SetAlignment( const Standard_Integer );\r
- Standard_EXPORT void SetSource( const TCollection_ExtendedString& );\r
- Standard_EXPORT void SetSourceProtocol( const Standard_Integer& );\r
-\r
-protected:\r
- Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const;\r
-\r
-private:\r
- TCollection_ExtendedString SourcePrefix() const;\r
-\r
-private:\r
- Standard_Integer myAlign;\r
- Standard_Integer myWidth;\r
- Standard_Integer myHeight;\r
- TCollection_ExtendedString mySource;\r
- Standard_Integer mySrcProto;\r
-\r
-public:\r
- DEFINE_STANDARD_RTTI(HTMLService_HTMLImage)\r
-};\r
-\r
-DEFINE_STANDARD_HANDLE(HTMLService_HTMLImage, HTMLService_HTML)\r
-\r
-#endif\r
+// File: HTMLService_HTMLImage.hxx
+// Created: 13.10.2006
+// Author: Sergey TELKOV
+// Copyright (C) AREVA NP 2006
+
+#ifndef HTMLSERVICE_HTMLIMAGE_H
+#define HTMLSERVICE_HTMLIMAGE_H
+
+#include <HTMLService.hxx>
+#include <HTMLService_HTML.hxx>
+
+#include <Quantity_Color.hxx>
+
+/*!
+ Class HTMLService_HTMLImage. Generator of the HTML image.
+*/
+
+class HTMLService_HTMLImage : public HTMLService_HTML
+{
+public:
+ enum { SP_Unknown, SP_File, SP_HTTP, SP_FTP } SourceProtocol;
+
+public:
+ Standard_EXPORT HTMLService_HTMLImage( const TCollection_ExtendedString& = TCollection_ExtendedString() );
+ Standard_EXPORT HTMLService_HTMLImage( const Handle(HTMLService_HTML)&,
+ const TCollection_ExtendedString& = TCollection_ExtendedString() );
+ Standard_EXPORT virtual ~HTMLService_HTMLImage();
+
+ Standard_EXPORT Standard_Integer GetWidth() const;
+ Standard_EXPORT Standard_Integer GetHeight() const;
+ Standard_EXPORT TCollection_ExtendedString GetSource() const;
+ Standard_EXPORT Standard_Integer GetAlignment() const;
+ Standard_EXPORT Standard_Integer GetSourceProtocol() const;
+
+ Standard_EXPORT void SetWidth( const Standard_Integer );
+ Standard_EXPORT void SetHeight( const Standard_Integer );
+ Standard_EXPORT void SetAlignment( const Standard_Integer );
+ Standard_EXPORT void SetSource( const TCollection_ExtendedString& );
+ Standard_EXPORT void SetSourceProtocol( const Standard_Integer& );
+
+protected:
+ Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const;
+
+private:
+ TCollection_ExtendedString SourcePrefix() const;
+
+private:
+ Standard_Integer myAlign;
+ Standard_Integer myWidth;
+ Standard_Integer myHeight;
+ TCollection_ExtendedString mySource;
+ Standard_Integer mySrcProto;
+
+public:
+ DEFINE_STANDARD_RTTI(HTMLService_HTMLImage)
+};
+
+DEFINE_STANDARD_HANDLE(HTMLService_HTMLImage, HTMLService_HTML)
+
+#endif
-// File: HTMLService_HTMLParagraph.hxx\r
-// Created: 13.10.2006\r
-// Author: Sergey TELKOV\r
-// Copyright (C) AREVA NP 2006\r
-\r
-#ifndef HTMLSERVICE_HTMLPARAGRAPH_H\r
-#define HTMLSERVICE_HTMLPARAGRAPH_H\r
-\r
-#include <HTMLService.hxx>\r
-#include <HTMLService_HTMLText.hxx>\r
-\r
-/*!\r
- Class HTMLService_HTMLParagraph. Generator of the HTML paragraph text.\r
-*/\r
-\r
-class HTMLSERVICE_EXPORT HTMLService_HTMLParagraph : public HTMLService_HTMLText\r
-{\r
-public:\r
- Standard_EXPORT HTMLService_HTMLParagraph();\r
- Standard_EXPORT HTMLService_HTMLParagraph( const Handle(HTMLService_HTML)& );\r
- Standard_EXPORT virtual ~HTMLService_HTMLParagraph();\r
-\r
- Standard_EXPORT Standard_Boolean GetNoBreak() const;\r
- Standard_EXPORT void SetNoBreak( const Standard_Boolean& );\r
-\r
- Standard_EXPORT void Clear();\r
- Standard_EXPORT void Insert( const Handle(HTMLService_HTML)& );\r
- Standard_EXPORT void InsertText( const TCollection_ExtendedString& );\r
- Standard_EXPORT void InsertImage( const TCollection_ExtendedString&,\r
- const Standard_Integer = -1, const Standard_Integer = -1 );\r
-\r
-protected:\r
- Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const;\r
-\r
-private:\r
- Standard_Boolean myNoBr;\r
-\r
-public:\r
- DEFINE_STANDARD_RTTI(HTMLService_HTMLParagraph)\r
-};\r
-\r
-DEFINE_STANDARD_HANDLE(HTMLService_HTMLParagraph, HTMLService_HTMLText)\r
-\r
-#endif\r
+// File: HTMLService_HTMLParagraph.hxx
+// Created: 13.10.2006
+// Author: Sergey TELKOV
+// Copyright (C) AREVA NP 2006
+
+#ifndef HTMLSERVICE_HTMLPARAGRAPH_H
+#define HTMLSERVICE_HTMLPARAGRAPH_H
+
+#include <HTMLService.hxx>
+#include <HTMLService_HTMLText.hxx>
+
+/*!
+ Class HTMLService_HTMLParagraph. Generator of the HTML paragraph text.
+*/
+
+class HTMLService_HTMLParagraph : public HTMLService_HTMLText
+{
+public:
+ Standard_EXPORT HTMLService_HTMLParagraph();
+ Standard_EXPORT HTMLService_HTMLParagraph( const Handle(HTMLService_HTML)& );
+ Standard_EXPORT virtual ~HTMLService_HTMLParagraph();
+
+ Standard_EXPORT Standard_Boolean GetNoBreak() const;
+ Standard_EXPORT void SetNoBreak( const Standard_Boolean& );
+
+ Standard_EXPORT void Clear();
+ Standard_EXPORT void Insert( const Handle(HTMLService_HTML)& );
+ Standard_EXPORT void InsertText( const TCollection_ExtendedString& );
+ Standard_EXPORT void InsertImage( const TCollection_ExtendedString&,
+ const Standard_Integer = -1, const Standard_Integer = -1 );
+
+protected:
+ Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const;
+
+private:
+ Standard_Boolean myNoBr;
+
+public:
+ DEFINE_STANDARD_RTTI(HTMLService_HTMLParagraph)
+};
+
+DEFINE_STANDARD_HANDLE(HTMLService_HTMLParagraph, HTMLService_HTMLText)
+
+#endif
-// File: HTMLService_HTMLTable.hxx\r
-// Created: 12.10.2006\r
-// Author: Sergey TELKOV\r
-// Copyright (C) AREVA NP 2006\r
-\r
-#ifndef HTMLSERVICE_HTMLTABLE_H\r
-#define HTMLSERVICE_HTMLTABLE_H\r
-\r
-#include <HTMLService.hxx>\r
-#include <HTMLService_HTML.hxx>\r
-\r
-#include <HTMLService_HTMLTableRow.hxx>\r
-\r
-#include <TColStd_HArray1OfTransient.hxx>\r
-\r
-#include <Quantity_Color.hxx>\r
-\r
-/*!\r
- Class HTMLService_HTMLTable. Generator of the HTML Table text.\r
-*/\r
-\r
-class HTMLSERVICE_EXPORT HTMLService_HTMLTable : public HTMLService_HTML\r
-{\r
-public:\r
- Standard_EXPORT HTMLService_HTMLTable( const Standard_Integer = 0, const Standard_Integer = 0 );\r
- Standard_EXPORT HTMLService_HTMLTable( const Handle(HTMLService_HTML)&, const Standard_Integer = 0, const Standard_Integer = 0 );\r
- Standard_EXPORT virtual ~HTMLService_HTMLTable();\r
-\r
- Standard_EXPORT Standard_Integer GetNumRows() const;\r
- Standard_EXPORT Standard_Integer GetNumCols() const;\r
-\r
- Standard_EXPORT Handle(HTMLService_HTMLTableRow) GetRow( const Standard_Integer ) const;\r
- Standard_EXPORT Handle(HTMLService_HTMLTableCell) GetCell( const Standard_Integer, const Standard_Integer ) const;\r
-\r
- Standard_EXPORT Standard_Integer GetBorder() const;\r
- Standard_EXPORT Standard_Integer GetCellSpacing() const;\r
- Standard_EXPORT Standard_Integer GetCellPadding() const;\r
- Standard_EXPORT Quantity_Color GetBackgroundColor() const;\r
- Standard_EXPORT Standard_Integer GetWidth( Standard_Boolean* = 0 ) const;\r
-\r
- Standard_EXPORT void SetBorder( const Standard_Integer );\r
- Standard_EXPORT void SetCellSpacing( const Standard_Integer );\r
- Standard_EXPORT void SetCellPadding( const Standard_Integer );\r
- Standard_EXPORT void SetBackgroundColor( const Quantity_Color& );\r
- Standard_EXPORT void SetWidth( const Standard_Integer,\r
- const Standard_Boolean = Standard_False );\r
-\r
- Standard_EXPORT void SetRowSpan( const Standard_Integer, const Standard_Integer );\r
- Standard_EXPORT void SetColumnSpan( const Standard_Integer, const Standard_Integer );\r
- Standard_EXPORT void SetColumnWidth( const Standard_Integer, const Standard_Integer,\r
- const Standard_Boolean = Standard_False );\r
-\r
-protected:\r
- Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const;\r
-\r
-private:\r
- void PrepareCells() const;\r
- void Initialize( const Standard_Integer, const Standard_Integer );\r
-\r
-private:\r
- Handle(TColStd_HArray1OfTransient) myRows;\r
-\r
- Standard_Boolean myUseBC;\r
- Standard_Integer myWidth;\r
- Standard_Integer myBorder;\r
- Standard_Boolean myPercent;\r
- Quantity_Color myBgColor;\r
- Standard_Integer mySpacing;\r
- Standard_Integer myPadding;\r
-\r
-public:\r
- DEFINE_STANDARD_RTTI(HTMLService_HTMLTable)\r
-};\r
-\r
-DEFINE_STANDARD_HANDLE(HTMLService_HTMLTable, HTMLService_HTML)\r
-\r
-#endif\r
+// File: HTMLService_HTMLTable.hxx
+// Created: 12.10.2006
+// Author: Sergey TELKOV
+// Copyright (C) AREVA NP 2006
+
+#ifndef HTMLSERVICE_HTMLTABLE_H
+#define HTMLSERVICE_HTMLTABLE_H
+
+#include <HTMLService.hxx>
+#include <HTMLService_HTML.hxx>
+
+#include <HTMLService_HTMLTableRow.hxx>
+
+#include <TColStd_HArray1OfTransient.hxx>
+
+#include <Quantity_Color.hxx>
+
+/*!
+ Class HTMLService_HTMLTable. Generator of the HTML Table text.
+*/
+
+class HTMLService_HTMLTable : public HTMLService_HTML
+{
+public:
+ Standard_EXPORT HTMLService_HTMLTable( const Standard_Integer = 0, const Standard_Integer = 0 );
+ Standard_EXPORT HTMLService_HTMLTable( const Handle(HTMLService_HTML)&, const Standard_Integer = 0, const Standard_Integer = 0 );
+ Standard_EXPORT virtual ~HTMLService_HTMLTable();
+
+ Standard_EXPORT Standard_Integer GetNumRows() const;
+ Standard_EXPORT Standard_Integer GetNumCols() const;
+
+ Standard_EXPORT Handle(HTMLService_HTMLTableRow) GetRow( const Standard_Integer ) const;
+ Standard_EXPORT Handle(HTMLService_HTMLTableCell) GetCell( const Standard_Integer, const Standard_Integer ) const;
+
+ Standard_EXPORT Standard_Integer GetBorder() const;
+ Standard_EXPORT Standard_Integer GetCellSpacing() const;
+ Standard_EXPORT Standard_Integer GetCellPadding() const;
+ Standard_EXPORT Quantity_Color GetBackgroundColor() const;
+ Standard_EXPORT Standard_Integer GetWidth( Standard_Boolean* = 0 ) const;
+
+ Standard_EXPORT void SetBorder( const Standard_Integer );
+ Standard_EXPORT void SetCellSpacing( const Standard_Integer );
+ Standard_EXPORT void SetCellPadding( const Standard_Integer );
+ Standard_EXPORT void SetBackgroundColor( const Quantity_Color& );
+ Standard_EXPORT void SetWidth( const Standard_Integer,
+ const Standard_Boolean = Standard_False );
+
+ Standard_EXPORT void SetRowSpan( const Standard_Integer, const Standard_Integer );
+ Standard_EXPORT void SetColumnSpan( const Standard_Integer, const Standard_Integer );
+ Standard_EXPORT void SetColumnWidth( const Standard_Integer, const Standard_Integer,
+ const Standard_Boolean = Standard_False );
+
+protected:
+ Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const;
+
+private:
+ void PrepareCells() const;
+ void Initialize( const Standard_Integer, const Standard_Integer );
+
+private:
+ Handle(TColStd_HArray1OfTransient) myRows;
+
+ Standard_Boolean myUseBC;
+ Standard_Integer myWidth;
+ Standard_Integer myBorder;
+ Standard_Boolean myPercent;
+ Quantity_Color myBgColor;
+ Standard_Integer mySpacing;
+ Standard_Integer myPadding;
+
+public:
+ DEFINE_STANDARD_RTTI(HTMLService_HTMLTable)
+};
+
+DEFINE_STANDARD_HANDLE(HTMLService_HTMLTable, HTMLService_HTML)
+
+#endif
-// File: HTMLService_HTMLTableCell.hxx\r
-// Created: 12.10.2006\r
-// Author: Sergey TELKOV\r
-// Copyright (C) AREVA NP 2006\r
-\r
-#ifndef HTMLService_HTMLTABLECELL_H\r
-#define HTMLService_HTMLTABLECELL_H\r
-\r
-#include <HTMLService.hxx>\r
-#include <HTMLService_HTMLParagraph.hxx>\r
-\r
-#include <Quantity_Color.hxx>\r
-\r
-/*!\r
- Class HTMLService_HTMLTableCell. Generator of the HTML Table cell text.\r
-*/\r
-\r
-class HTMLSERVICE_EXPORT HTMLService_HTMLTableCell : public HTMLService_HTMLParagraph\r
-{\r
-public:\r
- Standard_EXPORT HTMLService_HTMLTableCell();\r
- Standard_EXPORT HTMLService_HTMLTableCell( const Handle(HTMLService_HTML)& );\r
- Standard_EXPORT virtual ~HTMLService_HTMLTableCell();\r
-\r
- Standard_EXPORT Standard_Integer GetColSpan() const;\r
- Standard_EXPORT Standard_Integer GetRowSpan() const;\r
- Standard_EXPORT Standard_Integer GetAlignment() const;\r
- Standard_EXPORT Standard_Integer GetWidth( Standard_Boolean* = 0 ) const;\r
-\r
- Standard_EXPORT Quantity_Color GetBackgroundColor() const;\r
- Standard_EXPORT Standard_Boolean IsHeaderCell() const;\r
-\r
- Standard_EXPORT void SetColSpan( const Standard_Integer );\r
- Standard_EXPORT void SetRowSpan( const Standard_Integer );\r
- Standard_EXPORT void SetAlignment( const Standard_Integer );\r
- Standard_EXPORT void SetWidth( const Standard_Integer,\r
- const Standard_Boolean = Standard_False );\r
- Standard_EXPORT void SetBackgroundColor( const Quantity_Color& );\r
- Standard_EXPORT void SetHeaderCell( const Standard_Boolean );\r
-\r
-protected:\r
- Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const;\r
-\r
-private:\r
- TCollection_ExtendedString CellString() const;\r
-\r
-private:\r
- Standard_Integer myWidth;\r
- Standard_Integer myAlign;\r
- Standard_Boolean myUseBC;\r
- Standard_Boolean myPercent;\r
- Standard_Integer myColSpan;\r
- Standard_Integer myRowSpan;\r
- Quantity_Color myBgColor;\r
- Standard_Boolean myIsHeader;\r
-\r
-public:\r
- DEFINE_STANDARD_RTTI(HTMLService_HTMLTableCell)\r
-};\r
-\r
-DEFINE_STANDARD_HANDLE(HTMLService_HTMLTableCell, HTMLService_HTMLParagraph)\r
-\r
-#endif\r
+// File: HTMLService_HTMLTableCell.hxx
+// Created: 12.10.2006
+// Author: Sergey TELKOV
+// Copyright (C) AREVA NP 2006
+
+#ifndef HTMLService_HTMLTABLECELL_H
+#define HTMLService_HTMLTABLECELL_H
+
+#include <HTMLService.hxx>
+#include <HTMLService_HTMLParagraph.hxx>
+
+#include <Quantity_Color.hxx>
+
+/*!
+ Class HTMLService_HTMLTableCell. Generator of the HTML Table cell text.
+*/
+
+class HTMLService_HTMLTableCell : public HTMLService_HTMLParagraph
+{
+public:
+ Standard_EXPORT HTMLService_HTMLTableCell();
+ Standard_EXPORT HTMLService_HTMLTableCell( const Handle(HTMLService_HTML)& );
+ Standard_EXPORT virtual ~HTMLService_HTMLTableCell();
+
+ Standard_EXPORT Standard_Integer GetColSpan() const;
+ Standard_EXPORT Standard_Integer GetRowSpan() const;
+ Standard_EXPORT Standard_Integer GetAlignment() const;
+ Standard_EXPORT Standard_Integer GetWidth( Standard_Boolean* = 0 ) const;
+
+ Standard_EXPORT Quantity_Color GetBackgroundColor() const;
+ Standard_EXPORT Standard_Boolean IsHeaderCell() const;
+
+ Standard_EXPORT void SetColSpan( const Standard_Integer );
+ Standard_EXPORT void SetRowSpan( const Standard_Integer );
+ Standard_EXPORT void SetAlignment( const Standard_Integer );
+ Standard_EXPORT void SetWidth( const Standard_Integer,
+ const Standard_Boolean = Standard_False );
+ Standard_EXPORT void SetBackgroundColor( const Quantity_Color& );
+ Standard_EXPORT void SetHeaderCell( const Standard_Boolean );
+
+protected:
+ Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const;
+
+private:
+ TCollection_ExtendedString CellString() const;
+
+private:
+ Standard_Integer myWidth;
+ Standard_Integer myAlign;
+ Standard_Boolean myUseBC;
+ Standard_Boolean myPercent;
+ Standard_Integer myColSpan;
+ Standard_Integer myRowSpan;
+ Quantity_Color myBgColor;
+ Standard_Boolean myIsHeader;
+
+public:
+ DEFINE_STANDARD_RTTI(HTMLService_HTMLTableCell)
+};
+
+DEFINE_STANDARD_HANDLE(HTMLService_HTMLTableCell, HTMLService_HTMLParagraph)
+
+#endif
-// File: HTMLService_HTMLTableRow.hxx\r
-// Created: 12.10.2006\r
-// Author: Sergey TELKOV\r
-// Copyright (C) AREVA NP 2006\r
-\r
-#ifndef HTMLService_HTMLTABLEROW_H\r
-#define HTMLService_HTMLTABLEROW_H\r
-\r
-#include <HTMLService.hxx>\r
-#include <HTMLService_HTML.hxx>\r
-\r
-#include <HTMLService_HTMLTableCell.hxx>\r
-\r
-#include <TColStd_HArray1OfTransient.hxx>\r
-\r
-/*!\r
- Class HTMLService_HTMLTableRow. Generator of the HTML Table row text.\r
-*/\r
-\r
-class HTMLSERVICE_EXPORT HTMLService_HTMLTableRow : public HTMLService_HTML\r
-{\r
-public:\r
- Standard_EXPORT HTMLService_HTMLTableRow( const Standard_Integer = 0 );\r
- Standard_EXPORT HTMLService_HTMLTableRow( const Handle(HTMLService_HTML)&, const Standard_Integer = 0 );\r
- Standard_EXPORT virtual ~HTMLService_HTMLTableRow();\r
-\r
- Standard_EXPORT Standard_Integer GetSize() const;\r
- Standard_EXPORT Handle(HTMLService_HTMLTableCell) GetCell( const Standard_Integer ) const;\r
-\r
- Standard_EXPORT Quantity_Color GetBackgroundColor() const;\r
- Standard_EXPORT void SetBackgroundColor( const Quantity_Color& );\r
-\r
-protected:\r
- Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const;\r
-\r
-private:\r
- void Initialize( const Standard_Integer );\r
-\r
-private:\r
- Handle(TColStd_HArray1OfTransient) myCells;\r
- Standard_Boolean myUseBC;\r
- Quantity_Color myBgColor;\r
-\r
-public:\r
- DEFINE_STANDARD_RTTI(HTMLService_HTMLTableRow)\r
-};\r
-\r
-DEFINE_STANDARD_HANDLE(HTMLService_HTMLTableRow, HTMLService_HTML)\r
-\r
-#endif\r
+// File: HTMLService_HTMLTableRow.hxx
+// Created: 12.10.2006
+// Author: Sergey TELKOV
+// Copyright (C) AREVA NP 2006
+
+#ifndef HTMLService_HTMLTABLEROW_H
+#define HTMLService_HTMLTABLEROW_H
+
+#include <HTMLService.hxx>
+#include <HTMLService_HTML.hxx>
+
+#include <HTMLService_HTMLTableCell.hxx>
+
+#include <TColStd_HArray1OfTransient.hxx>
+
+/*!
+ Class HTMLService_HTMLTableRow. Generator of the HTML Table row text.
+*/
+
+class HTMLService_HTMLTableRow : public HTMLService_HTML
+{
+public:
+ Standard_EXPORT HTMLService_HTMLTableRow( const Standard_Integer = 0 );
+ Standard_EXPORT HTMLService_HTMLTableRow( const Handle(HTMLService_HTML)&, const Standard_Integer = 0 );
+ Standard_EXPORT virtual ~HTMLService_HTMLTableRow();
+
+ Standard_EXPORT Standard_Integer GetSize() const;
+ Standard_EXPORT Handle(HTMLService_HTMLTableCell) GetCell( const Standard_Integer ) const;
+
+ Standard_EXPORT Quantity_Color GetBackgroundColor() const;
+ Standard_EXPORT void SetBackgroundColor( const Quantity_Color& );
+
+protected:
+ Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const;
+
+private:
+ void Initialize( const Standard_Integer );
+
+private:
+ Handle(TColStd_HArray1OfTransient) myCells;
+ Standard_Boolean myUseBC;
+ Quantity_Color myBgColor;
+
+public:
+ DEFINE_STANDARD_RTTI(HTMLService_HTMLTableRow)
+};
+
+DEFINE_STANDARD_HANDLE(HTMLService_HTMLTableRow, HTMLService_HTML)
+
+#endif
-// File: HTMLService_HTMLText.hxx\r
-// Created: 13.10.2006\r
-// Author: Sergey TELKOV\r
-// Copyright (C) AREVA NP 2006\r
-\r
-#ifndef HTMLSERVICE_HTMLTEXT_H\r
-#define HTMLSERVICE_HTMLTEXT_H\r
-\r
-#include <HTMLService.hxx>\r
-#include <HTMLService_HTML.hxx>\r
-\r
-#include <Quantity_Color.hxx>\r
-\r
-/*!\r
- Class HTMLService_HTMLText. Generator of the simple HTML text.\r
-*/\r
-\r
-class HTMLSERVICE_EXPORT HTMLService_HTMLText : public HTMLService_HTML\r
-{\r
-public:\r
- enum { Normal = 0x00, Bold = 0x01, Italic = 0x02, Underline = 0x04,\r
- StrikeOut = 0x08, Subscript = 0x10, Superscript = 0x20 } FontFlags;\r
-\r
-public:\r
- Standard_EXPORT HTMLService_HTMLText( const TCollection_ExtendedString& = TCollection_ExtendedString(),\r
- const Standard_Integer = Normal );\r
- Standard_EXPORT HTMLService_HTMLText( const Handle(HTMLService_HTML)&,\r
- const TCollection_ExtendedString& = TCollection_ExtendedString(),\r
- const Standard_Integer = Normal );\r
- Standard_EXPORT virtual ~HTMLService_HTMLText();\r
-\r
- Standard_EXPORT TCollection_ExtendedString GetText() const;\r
- Standard_EXPORT Standard_Integer GetFontFlags() const;\r
- Standard_EXPORT Standard_Integer GetHeadingLevel() const;\r
- Standard_EXPORT Quantity_Color GetForegroundColor() const;\r
-\r
- Standard_EXPORT void SetFontFlags( const Standard_Integer );\r
- Standard_EXPORT void SetHeadingLevel( const Standard_Integer );\r
- Standard_EXPORT void SetForegroundColor( const Quantity_Color& );\r
- Standard_EXPORT void SetText( const TCollection_ExtendedString& );\r
-\r
-protected:\r
- Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const;\r
-\r
-private:\r
- TCollection_ExtendedString myText;\r
- Quantity_Color myColor;\r
- Standard_Integer myHeading;\r
- Standard_Boolean myUseColor;\r
- Standard_Integer myFontFlags;\r
-\r
-public:\r
- DEFINE_STANDARD_RTTI(HTMLService_HTMLText)\r
-};\r
-\r
-DEFINE_STANDARD_HANDLE(HTMLService_HTMLText, HTMLService_HTML)\r
-\r
-#endif\r
+// File: HTMLService_HTMLText.hxx
+// Created: 13.10.2006
+// Author: Sergey TELKOV
+// Copyright (C) AREVA NP 2006
+
+#ifndef HTMLSERVICE_HTMLTEXT_H
+#define HTMLSERVICE_HTMLTEXT_H
+
+#include <HTMLService.hxx>
+#include <HTMLService_HTML.hxx>
+
+#include <Quantity_Color.hxx>
+
+/*!
+ Class HTMLService_HTMLText. Generator of the simple HTML text.
+*/
+
+class HTMLService_HTMLText : public HTMLService_HTML
+{
+public:
+ enum { Normal = 0x00, Bold = 0x01, Italic = 0x02, Underline = 0x04,
+ StrikeOut = 0x08, Subscript = 0x10, Superscript = 0x20 } FontFlags;
+
+public:
+ Standard_EXPORT HTMLService_HTMLText( const TCollection_ExtendedString& = TCollection_ExtendedString(),
+ const Standard_Integer = Normal );
+ Standard_EXPORT HTMLService_HTMLText( const Handle(HTMLService_HTML)&,
+ const TCollection_ExtendedString& = TCollection_ExtendedString(),
+ const Standard_Integer = Normal );
+ Standard_EXPORT virtual ~HTMLService_HTMLText();
+
+ Standard_EXPORT TCollection_ExtendedString GetText() const;
+ Standard_EXPORT Standard_Integer GetFontFlags() const;
+ Standard_EXPORT Standard_Integer GetHeadingLevel() const;
+ Standard_EXPORT Quantity_Color GetForegroundColor() const;
+
+ Standard_EXPORT void SetFontFlags( const Standard_Integer );
+ Standard_EXPORT void SetHeadingLevel( const Standard_Integer );
+ Standard_EXPORT void SetForegroundColor( const Quantity_Color& );
+ Standard_EXPORT void SetText( const TCollection_ExtendedString& );
+
+protected:
+ Standard_EXPORT virtual void Generate( SequenceOfHTMLLine& ) const;
+
+private:
+ TCollection_ExtendedString myText;
+ Quantity_Color myColor;
+ Standard_Integer myHeading;
+ Standard_Boolean myUseColor;
+ Standard_Integer myFontFlags;
+
+public:
+ DEFINE_STANDARD_RTTI(HTMLService_HTMLText)
+};
+
+DEFINE_STANDARD_HANDLE(HTMLService_HTMLText, HTMLService_HTML)
+
+#endif
-TEMPLATE = lib
+unix:TEMPLATE = lib
+win32:TEMPLATE = vclib
+
+win32:QMAKE_MOC=$(QTDIR)\bin\moc.exe
DESTDIR = ../../$(CONFIG_ID)/lib
MOC_DIR = ../../moc
OBJECTS_DIR = ../../$(CONFIG_ID)/obj/$$TARGET
INCLUDEPATH = ../../include
-win32:LIBS += ../../lib/suit.lib ../../lib/qtx.lib
-unix:LIBS += -L../../$(CONFIG_ID)/lib -lSUIT -lQtx
+LIBS += -L../../$(CONFIG_ID)/lib -lSUIT -lQtx
+win32:LIBS *= -L$(QTLIB)
+win32:INCLUDEPATH *= $(QTINC) $(QTINC)\QtCore $(QTINC)\QtGui $(QTINC)\QtXml
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared
-win32:DEFINES += WIN32
+win32:DEFINES += WNT WIN32
DEFINES += LOGWINDOW_EXPORTS
HEADERS = *.h
lrelease.name = LRELASE ${QMAKE_FILE_IN}
unix:lrelease.commands = $(QTDIR)/bin/lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}/${QMAKE_FILE_BASE}.qm
-win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
+win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_IN} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
unix:lrelease.output = $${GUIResources}/${QMAKE_FILE_BASE}.qm
win32:lrelease.output = $${GUIResources}\\${QMAKE_FILE_BASE}.qm
lrelease.input = TRANSLATIONS
lrelease.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += lrelease
+win32:copy_hdr.name = Install ${QMAKE_FILE_IN}
+win32:copy_hdr.commands = type ${QMAKE_FILE_IN} > ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.output = ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.input = HEADERS
+win32:QMAKE_EXTRA_COMPILERS += copy_hdr
+
includes.files = $$HEADERS
includes.path = ../../include
-TEMPLATE = lib
+unix:TEMPLATE = lib
+win32:TEMPLATE = vclib
+
+win32:QMAKE_MOC=$(QTDIR)\bin\moc.exe
DESTDIR = ../../$(CONFIG_ID)/lib
MOC_DIR = ../../moc
CAS_CPPFLAGS = $(CASINC)
-CAS_LDPATH = -L$(CASLIB) -lTKV3d
+unix:CAS_LDPATH = -L$(CASLIB) -lTKV3d
+win32:CAS_LDPATH = -L$(CASLIB) -lTKernel -lTKMath -lTKV3d
INCLUDEPATH += ../../include $${CAS_CPPFLAGS}
LIBS += $${CAS_LDPATH}
+win32:LIBS *= -L$(QTLIB)
+win32:INCLUDEPATH *= $(QTINC) $(QTINC)\QtCore $(QTINC)\QtGui $(QTINC)\QtXml
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared
-win32:DEFINES += WIN32
+win32:DEFINES += WNT WIN32
DEFINES += $(CASDEFINES) OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS
HEADERS = *.hxx
SOURCES = *.cxx
+win32:COPY_FILES = *.hxx *.h
+win32:copy_hxx.name = Install(.hxx) ${QMAKE_FILE_IN}
+win32:copy_hxx.commands = type ${QMAKE_FILE_IN} > ../../include/${QMAKE_FILE_BASE}.hxx
+win32:copy_hxx.output = ../../include/${QMAKE_FILE_BASE}.hxx
+win32:copy_hxx.input = COPY_FILES
+win32:QMAKE_EXTRA_COMPILERS += copy_hxx
+
includes.files = $$HEADERS
includes.path = ../../include
-TEMPLATE = lib
+unix:TEMPLATE = lib
+win32:TEMPLATE = vclib
+
+win32:QMAKE_MOC=$(QTDIR)\bin\moc.exe
DESTDIR = ../../$(CONFIG_ID)/lib
MOC_DIR = ../../moc
INCLUDEPATH += ../../include ../Qtx
LIBS += -L../../$(CONFIG_ID)/lib -lQtx
+win32:LIBS *= -L$(QTLIB)
+win32:INCLUDEPATH *= $(QTINC) $(QTINC)\QtCore $(QTINC)\QtGui $(QTINC)\QtXml
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared
-win32:DEFINES += WIN32
-DEFINES += LOGWINDOW_EXPORTS
+win32:DEFINES += WNT WIN32
+DEFINES += OB_EXPORTS
HEADERS = *.h
lrelease.name = LRELASE ${QMAKE_FILE_IN}
unix:lrelease.commands = $(QTDIR)/bin/lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}/${QMAKE_FILE_BASE}.qm
-win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
+win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_IN} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
unix:lrelease.output = $${GUIResources}/${QMAKE_FILE_BASE}.qm
win32:lrelease.output = $${GUIResources}\\${QMAKE_FILE_BASE}.qm
lrelease.input = TRANSLATIONS
lrelease.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += lrelease
+win32:copy_hdr.name = Install ${QMAKE_FILE_IN}
+win32:copy_hdr.commands = type ${QMAKE_FILE_IN} > ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.output = ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.input = HEADERS
+win32:QMAKE_EXTRA_COMPILERS += copy_hdr
+
+
includes.files = $$HEADERS
includes.path = ../../include
-TEMPLATE = lib
+unix:TEMPLATE = lib
+win32:TEMPLATE = vclib
+
+win32:QMAKE_MOC=$(QTDIR)\bin\moc.exe
DESTDIR = ../../$(CONFIG_ID)/lib
MOC_DIR = ../../moc
INCLUDEPATH += ../../include $$(QWTINC) $$(PYTHONINC)
INCLUDEPATH += ../Qtx ../SUIT
unix:LIBS += -L$$(QWTLIB) -lqwt
-win32:LIBS += /LIBPATH:$$(QWTLIB)
+win32:LIBS += /LIBPATH:$$(QWTLIB) -lqwt5
LIBS += -L../../$(CONFIG_ID)/lib -lQtx -lSUIT
+win32:LIBS *= -L$(QTLIB)
+win32:INCLUDEPATH *= $(QTINC) $(QTINC)\QtCore $(QTINC)\QtGui $(QTINC)\QtXml
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared
-win32:DEFINES += WIN32
+win32:DEFINES += WNT WIN32 QWT_DLL
DEFINES += PLOT2D_EXPORTS
HEADERS = *.h
unix:GUIResources = ../../resources
win32:GUIResources = ..\\..\\resources
+win32:copy_hdr.name = Install headers ${QMAKE_FILE_IN}
+win32:copy_hdr.commands = type ${QMAKE_FILE_IN} > ${QMAKE_FILE_OUT}
+win32:copy_hdr.output = ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.input = HEADERS
+win32:QMAKE_EXTRA_COMPILERS += copy_hdr
+
lrelease.name = LRELASE ${QMAKE_FILE_IN}
-unix:lrelease.commands = $(QTDIR)/bin/lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}/${QMAKE_FILE_BASE}.qm
-win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
+unix:lrelease.commands = $(QTDIR)/bin/lrelease ${QMAKE_FILE_NAME} -qm ${QMAKE_FILE_OUT}
+win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT}
unix:lrelease.output = $${GUIResources}/${QMAKE_FILE_BASE}.qm
win32:lrelease.output = $${GUIResources}\\${QMAKE_FILE_BASE}.qm
lrelease.input = TRANSLATIONS
ICONS = resources/*.png
+win32:SOURCES+=$$ICONS
+win32:Resource=$$ICONS
+win32:copy_res.name = Install resources ${QMAKE_FILE_IN}
+win32:copy_res.commands = type ${QMAKE_FILE_IN} > ${QMAKE_FILE_OUT}
+win32:copy_res.output = $${GUIResources}\\${QMAKE_FILE_BASE}.png
+win32:copy_res.input = Resource
+win32:QMAKE_EXTRA_COMPILERS += copy_res
+
includes.files = $$HEADERS
includes.path = ../../include
{
QRect aRect = theRect;
// theRect has inversed coordinates on Y axis. The top of the rect is bottom in standard QRect coordinates, and it bottom is the top.
- if ( m_bCrossed && theOr == Qt::Horizontal )
+ if ( m_bCrossed )//&& theOr == Qt::Horizontal )
aRect.setTop( getCrossedTop( theRect ) );
drawBar( thePainter, Qt::Horizontal, aRect );
protected:
void init();
- class PrivateData;
PrivateData* m_pData;
};
void setCrossItems( const bool& theCross ) { m_bCrossed = theCross; }
bool isCrossItems() const { return m_bCrossed; }
-private:
+protected:
void drawRectAndLowers( QPainter* , Qt::Orientation, const QRect& ) const;
int getCrossedTop( const QRect& ) const;
-private:
+protected:
QList<QRect> m_BarItems;
bool m_bCrossed;
};
#include <QList>
#include <qwt_plot.h>
-typedef struct
+struct PLOT2D_EXPORT Plot2d_Point
{
double x;
double y;
QString text;
-} Plot2d_Point;
+};
typedef QList<Plot2d_Point> pointList;
Q_OBJECT
public:
Plot2d_Plot2d( QWidget* parent );
+ virtual ~Plot2d_Plot2d() {};
void setLogScale( int axisId, bool log10 );
-TEMPLATE = lib
+unix:TEMPLATE = lib
+win32:TEMPLATE = vclib
+
+win32:QMAKE_MOC=$(QTDIR)\bin\moc.exe
DESTDIR = ../../$(CONFIG_ID)/lib
MOC_DIR = ../../moc
OBJECTS_DIR = ../../$(CONFIG_ID)/obj/$$TARGET
+win32:LIBS *= -L$(QTLIB)
+win32:INCLUDEPATH *= $(QTINC) $(QTINC)\QtCore $(QTINC)\QtGui $(QTINC)\QtXml
+
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared
-win32:DEFINES += WIN32
+win32:DEFINES += WNT WIN32
DEFINES += PRS_EXPORTS
HEADERS = *.h
SOURCES = *.cxx
+win32:copy_hdr.name = Install ${QMAKE_FILE_IN}
+win32:copy_hdr.commands = type ${QMAKE_FILE_IN} > ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.output = ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.input = HEADERS
+win32:QMAKE_EXTRA_COMPILERS += copy_hdr
+
includes.files = $$HEADERS
includes.path = ../../include
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#if !defined ( _PYTHONCONSOLE_H )
-#define _PYTHONCONSOLE_H
+// File : PyConsole.h
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//
+
+#if !defined ( PYCONSOLE_H )
+#define PYCONSOLE_H
// ========================================================
// set dllexport type for Win platform
#ifdef WIN32
-
-#ifdef PYCONSOLE_EXPORTS
-#define PYCONSOLE_EXPORT __declspec(dllexport)
-#else
-#define PYCONSOLE_EXPORT __declspec(dllimport)
-#endif
-
+# ifdef PYCONSOLE_EXPORTS
+# define PYCONSOLE_EXPORT __declspec(dllexport)
+# else
+# define PYCONSOLE_EXPORT __declspec(dllimport)
+# endif
#else // WIN32
-
-#define PYCONSOLE_EXPORT
-
+# define PYCONSOLE_EXPORT
#endif // WIN32
-// ========================================================
-// little trick - we do not have debug python libraries
-#ifdef _DEBUG
-
-#undef _DEBUG
-//#include <Python.h>
-#define _DEBUG
-
-#else // _DEBUG
-
-//#include <Python.h>
-
-#endif // _DEBUG
-
// ========================================================
// avoid warning messages
#ifdef WIN32
#pragma warning (disable : 4251)
#endif
-#endif // _PYTHONCONSOLE_H
+#endif // PYCONSOLE_H
-TEMPLATE = lib
+unix:TEMPLATE = lib
+win32:TEMPLATE = vclib
+
+win32:QMAKE_MOC=$(QTDIR)\bin\moc.exe
DESTDIR = ../../$(CONFIG_ID)/lib
MOC_DIR = ../../moc
INCLUDEPATH += ../../include $$(PYTHONINC)
unix:LIBS += -L../../$(CONFIG_ID)/lib -L$$(PYTHONLIB) -lpython2.5 -lSUIT -lPyInterp
-win32:LIBS += /LIBPATH:$$(PYTHONLIB) ../../lib/pyinterp.lib ../../lib/suit.lib
+win32:LIBS += -L../../$(CONFIG_ID)/lib -L$$(PYTHONLIB) -lpython25_d -lSUIT -lPyInterp -lQtx
+win32:LIBS *= -L$(QTLIB)
+win32:INCLUDEPATH *= $(QTINC) $(QTINC)\QtCore $(QTINC)\QtGui $(QTINC)\QtXml
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared
-win32:DEFINES += WIN32
+win32:DEFINES += WNT WIN32 HAVE_DEBUG_PYTHON
DEFINES += PYCONSOLE_EXPORTS
HEADERS = *.h
lrelease.name = LRELASE ${QMAKE_FILE_IN}
unix:lrelease.commands = $(QTDIR)/bin/lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}/${QMAKE_FILE_BASE}.qm
-win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
+win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_IN} ${QMAKE_FILE_NAME} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
unix:lrelease.output = $${GUIResources}/${QMAKE_FILE_BASE}.qm
win32:lrelease.output = $${GUIResources}\\${QMAKE_FILE_BASE}.qm
lrelease.input = TRANSLATIONS
lrelease.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += lrelease
+win32:copy_hdr.name = Install ${QMAKE_FILE_IN}
+win32:copy_hdr.commands = type ${QMAKE_FILE_IN} > ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.output = ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.input = HEADERS
+win32:QMAKE_EXTRA_COMPILERS += copy_hdr
+
includes.files = $$HEADERS
includes.path = ../../include
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// File : PythonConsole_PyConcole.cxx
-// Author : Vadim SANDLER
-// Module : SALOME
+// File : PyConsole_Console.cxx
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//
/*!
- \class PythonConsole
+ \class PyConsole_Console
\brief Python console widget.
*/
-#include <Python.h>
-
+#include "PyConsole_Interp.h" /// !!! WARNING !!! THIS INCLUDE MUST BE VERY FIRST !!!
#include "PyConsole_Console.h"
#include "PyConsole_Editor.h"
-#include <PyInterp_base.h>
-
-#include <QtGui/qmenu.h>
-#include <QtGui/qevent.h>
-#include <QtGui/qaction.h>
-#include <QtGui/qlayout.h>
-#include <QtGui/qclipboard.h>
-#include <QtGui/qapplication.h>
+#include <Qtx.h>
-using namespace std;
+#include <QAction>
+#include <QApplication>
+#include <QClipboard>
+#include <QEvent>
+#include <QMenu>
+#include <QVBoxLayout>
/*!
\brief Constructor.
\param parent parent widget
\param interp python interpreter
*/
-PythonConsole::PythonConsole( QWidget* parent, PyInterp_base* interp )
-: QFrame( parent ),
-myEditor( 0 )
+PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* interp )
+: QWidget( parent ),
+ myEditor( 0 )
{
// create python interpreter
myInterp = interp;
// create editor console
QVBoxLayout* lay = new QVBoxLayout( this );
- lay->setMargin( 5 );
+ lay->setMargin( 0 );
myEditor = new PyConsole_Editor( myInterp, this );
myEditor->viewport()->installEventFilter( this );
lay->addWidget( myEditor );
Does nothing for the moment.
*/
-PythonConsole::~PythonConsole()
+PyConsole_Console::~PyConsole_Console()
{
}
/*!
\brief Execute python command in the interpreter.
- \param command - string with command and arguments
+ \param command string with command and arguments
*/
-void PythonConsole::exec( const QString& command )
+void PyConsole_Console::exec( const QString& command )
{
if ( myEditor )
myEditor->exec( command );
and wait until it is finished.
Block execution of main application until the python command is executed.
- \param command - string with command and arguments
+ \param command string with command and arguments
*/
-void PythonConsole::execAndWait( const QString& command )
+void PyConsole_Console::execAndWait( const QString& command )
{
if ( myEditor )
myEditor->execAndWait( command );
}
-bool PythonConsole::isSync() const
+/*!
+ \brief Get synchronous mode flag value.
+
+ \sa setIsSync()
+ \return True if python console works in synchronous mode
+*/
+bool PyConsole_Console::isSync() const
{
return myEditor->isSync();
}
-void PythonConsole::setIsSync( const bool s )
+/*!
+ \brief Set synchronous mode flag value.
+
+ In synhronous mode the Python commands are executed in the GUI thread
+ and the GUI is blocked until the command is finished. In the asynchronous
+ mode each Python command is executed in the separate thread that does not
+ block the main GUI loop.
+
+ \param on synhronous mode flag
+*/
+void PyConsole_Console::setIsSync( const bool on )
{
- myEditor->setIsSync( s );
+ myEditor->setIsSync( on );
}
/*!
\brief Change the python console's font.
- \param f - new font
+ \param f new font
*/
-void PythonConsole::setFont( const QFont& f )
+void PyConsole_Console::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 PyConsole_Console::font() const
{
QFont res;
if( myEditor )
}
/*!
- Custom event handler
+ \brief Event handler.
+
+ Handles context menu request event.
+
+ \param o object
+ \param e event
+ \return True if the event is processed and further processing should be stopped
*/
-bool PythonConsole::eventFilter( QObject* o, QEvent* e )
+bool PyConsole_Console::eventFilter( QObject* o, QEvent* e )
{
if ( o == myEditor->viewport() && e->type() == QEvent::ContextMenu )
{
contextMenuRequest( (QContextMenuEvent*)e );
return true;
}
- return QFrame::eventFilter( o, e );
+ return QWidget::eventFilter( o, e );
}
/*!
- \brief Process context popup menu event.
+ \brief Create the context popup menu.
+
+ Fill in the popup menu with the commands.
- Show popup menu which includes standard copy/paste operations.
- \param event context menu event
+ \param menu context popup menu
*/
-void PythonConsole::contextMenuPopup( QMenu* menu )
+void PyConsole_Console::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] );
+
+ Qtx::simplifySeparators( menu );
+
+ updateActions();
}
-void PythonConsole::createActions()
+/*!
+ \brief Set actions to be visible in the context popup menu.
+
+ Actions, which IDs are set in \a flags parameter, will be shown in the
+ context popup menu. Other actions will not be shown.
+
+ \param flags ORed together actions flags
+*/
+void PyConsole_Console::setMenuActions( const int flags )
{
- QAction* copyAction = new QAction( tr( "EDIT_COPY_CMD" ), this );
- connect( copyAction, SIGNAL( triggered( bool ) ), myEditor, SLOT( copy() ) );
- myActions.insert( CopyId, copyAction );
+ myActions[CopyId]->setVisible( flags & CopyId );
+ myActions[PasteId]->setVisible( flags & PasteId );
+ myActions[ClearId]->setVisible( flags & ClearId );
+ myActions[SelectAllId]->setVisible( flags & SelectAllId );
+}
- QAction* pasteAction = new QAction( tr( "EDIT_PASTE_CMD" ), this );
- connect( pasteAction, SIGNAL( triggered( bool ) ), myEditor, SLOT( paste() ) );
- myActions.insert( PasteId, pasteAction );
+/*!
+ \brief Get menu actions which are currently visible in the context popup menu.
+ \return ORed together actions flags
+ \sa setMenuActions()
+*/
+int PyConsole_Console::menuActions() const
+{
+ int ret = 0;
+ ret = ret | ( myActions[CopyId]->isVisible() ? CopyId : 0 );
+ ret = ret | ( myActions[PasteId]->isVisible() ? PasteId : 0 );
+ ret = ret | ( myActions[ClearId]->isVisible() ? ClearId : 0 );
+ ret = ret | ( myActions[SelectAllId]->isVisible() ? SelectAllId : 0 );
+ return ret;
+}
- QAction* clearAction = new QAction( tr( "EDIT_CLEAR_CMD" ), this );
- connect( clearAction, SIGNAL( triggered( bool ) ), myEditor, SLOT( clear() ) );
- myActions.insert( ClearId, clearAction );
+/*!
+ \brief Create menu actions.
+
+ Create context popup menu actions.
+*/
+void PyConsole_Console::createActions()
+{
+ QAction* a = new QAction( tr( "EDIT_COPY_CMD" ), this );
+ a->setStatusTip( tr( "EDIT_COPY_CMD" ) );
+ connect( a, SIGNAL( triggered( bool ) ), myEditor, SLOT( copy() ) );
+ myActions.insert( CopyId, a );
+
+ a = new QAction( tr( "EDIT_PASTE_CMD" ), this );
+ a->setStatusTip( tr( "EDIT_PASTE_CMD" ) );
+ connect( a, SIGNAL( triggered( bool ) ), myEditor, SLOT( paste() ) );
+ myActions.insert( PasteId, a );
- QAction* selAllAction = new QAction( tr( "EDIT_SELECTALL_CMD" ), this );
- connect( selAllAction, SIGNAL( triggered( bool ) ), myEditor, SLOT( selectAll() ) );
- myActions.insert( SelectAllId, selAllAction );
+ a = new QAction( tr( "EDIT_CLEAR_CMD" ), this );
+ a->setStatusTip( tr( "EDIT_CLEAR_CMD" ) );
+ connect( a, SIGNAL( triggered( bool ) ), myEditor, SLOT( clear() ) );
+ myActions.insert( ClearId, a );
+
+ a = new QAction( tr( "EDIT_SELECTALL_CMD" ), this );
+ a->setStatusTip( tr( "EDIT_SELECTALL_CMD" ) );
+ connect( a, SIGNAL( triggered( bool ) ), myEditor, SLOT( selectAll() ) );
+ myActions.insert( SelectAllId, a );
}
-void PythonConsole::updateActions()
+/*!
+ \brief Update menu actions.
+
+ Update context popup menu action state.
+*/
+void PyConsole_Console::updateActions()
{
myActions[CopyId]->setEnabled( myEditor->textCursor().hasSelection() );
myActions[PasteId]->setEnabled( !myEditor->isReadOnly() && !QApplication::clipboard()->text().isEmpty() );
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// File : PythonConsole_PyConsole.h
-// Author : Vadim SANDLER
-// Module : SALOME
+// File : PyConsole_Console.h
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//
#ifndef PYCONSOLE_CONSOLE_H
#define PYCONSOLE_CONSOLE_H
#include "PyConsole.h"
-#include <QtCore/qmap.h>
-#include <QtGui/qframe.h>
-
#include <SUIT_PopupClient.h>
+#include <QWidget>
+#include <QMap>
-class PyInterp_base;
+class PyConsole_Interp;
class PyConsole_Editor;
-class PYCONSOLE_EXPORT PythonConsole : public QFrame, public SUIT_PopupClient
+class PYCONSOLE_EXPORT PyConsole_Console : public QWidget, public SUIT_PopupClient
{
Q_OBJECT
public:
+ //! Context popup menu actions flags
enum
{
- CopyId = 0x01,
- PasteId = 0x02,
- ClearId = 0x04,
- SelectAllId = 0x08,
- All = CopyId | PasteId | ClearId | SelectAllId
+ CopyId = 0x01, //!< "Copy" menu action
+ PasteId = 0x02, //!< "Paste" menu action
+ ClearId = 0x04, //!< "Clear" menu action
+ SelectAllId = 0x08, //!< "Select All" menu action
+ All = CopyId | PasteId | ClearId | SelectAllId //!< all menu actions
};
public:
- PythonConsole( QWidget* parent, PyInterp_base* interp = 0 );
- virtual ~PythonConsole();
+ PyConsole_Console( QWidget* parent, PyConsole_Interp* interp = 0 );
+ virtual ~PyConsole_Console();
//! \brief Get python interperter
- PyInterp_base* getInterp() { return myInterp; }
- QFont font() const;
- virtual void setFont( const QFont& );
+ PyConsole_Interp* getInterp() { return myInterp; }
+ QFont font() const;
+ virtual void setFont( const QFont& );
+
+ bool isSync() const;
+ void setIsSync( const bool );
- bool isSync() const;
- void setIsSync( const bool );
+ void exec( const QString& );
+ void execAndWait( const QString& );
- void exec( const QString& command );
- void execAndWait( const QString& command );
+ virtual bool eventFilter( QObject*, QEvent* );
- virtual bool eventFilter( QObject* o, QEvent* e );
+ //! \brief Get popup client symbolic name
+ virtual QString popupClientType() const { return QString( "PyConsole" ); }
+ virtual void contextMenuPopup( QMenu* );
- virtual QString popupClientType() const { return QString( "PyConsole" ); }
- virtual void contextMenuPopup( QMenu* );
+ void setMenuActions( const int );
+ int menuActions() const;
private:
void createActions();
void updateActions();
private:
- PyInterp_base* myInterp; //!< python interpreter
+ PyConsole_Interp* myInterp; //!< python interpreter
PyConsole_Editor* myEditor; //!< python console editor widget
- QMap<int, QAction*> myActions;
+ QMap<int, QAction*> myActions; //!< menu actions list
};
-#endif
+#endif // PYCONSOLE_CONSOLE_H
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// File : PyConsole_Editor.cxx
-// Author : Vadim SANDLER
-// Module : SALOME
+// File : PyConsole_Editor.cxx
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//
/*!
\class PyConsole_Editor
- the same for drag-n-drop of multiline text
*/
-#include "PyConsole_Editor.h" // this include must be first (see PyInterp_base.h)!
-
+#include "PyConsole_Interp.h" // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
+#include "PyConsole_Editor.h"
#include <PyInterp_Dispatcher.h>
#include <SUIT_Tools.h>
-#include <SUIT_Session.h>
-
-#include <QtGui/qmenu.h>
-#include <QtGui/qevent.h>
-#include <QtGui/qclipboard.h>
-#include <QtGui/qscrollbar.h>
-#include <QtGui/qtextobject.h>
-#include <QtGui/qtextcursor.h>
-#include <QtGui/qapplication.h>
-#include <QtGui/qtextdocument.h>
-using namespace std;
+#include <QApplication>
+#include <QClipboard>
+#include <QDropEvent>
+#include <QEvent>
+#include <QKeyEvent>
+#include <QMouseEvent>
+#include <QScrollBar>
+#include <QTextBlock>
+#include <QTextCursor>
+#include <QTextDocument>
static QString READY_PROMPT = ">>> ";
static QString DOTS_PROMPT = "... ";
#define PROMPT_SIZE myPrompt.length()
+#define PRINT_EVENT 65432
+
/*!
\class ExecCommand
- \brief Python command execution request [internal].
- */
+ \brief Python command execution request.
+ \internal
+*/
+
class ExecCommand : public PyInterp_LockRequest
{
public:
\param theListener widget to get the notification messages
\param sync if True the request is processed synchronously
*/
- ExecCommand( PyInterp_base* theInterp,
+ ExecCommand( PyInterp_Interp* theInterp,
const QString& theCommand,
PyConsole_Editor* theListener,
bool sync = false )
{
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;
+ myState = PyInterp_Event::ERROR;
else if ( ret > 0 )
- myState = PyInterp_Event::INCOMPLETE;
- myError = getInterp()->getverr().c_str();
- myOutput = getInterp()->getvout().c_str();
+ myState = PyInterp_Event::INCOMPLETE;
}
- else
- {
- myError = "";
- myOutput = "";
- }
}
/*!
*/
virtual QEvent* createEvent() const
{
+ if ( IsSync() )
+ QCoreApplication::sendPostedEvents( listener(), PRINT_EVENT );
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
};
+/*!
+ \class PrintEvent
+ \brief Python command output backend event.
+ \internal
+*/
+
+class PrintEvent : public QEvent
+{
+public:
+ /*!
+ \brief Constructor
+ \param c message text (python trace)
+ */
+ PrintEvent( const char* c ) : QEvent( (QEvent::Type)PRINT_EVENT ), myText( c ) {}
+ /*!
+ \brief Get message
+ \return message text (python trace)
+ */
+ QString text() const { return myText; }
+
+private:
+ QString myText; //!< Event message (python trace)
+};
+
+void staticCallback( void* data, char* c )
+{
+ QApplication::postEvent( (PyConsole_Editor*)data, new PrintEvent( c ) );
+}
+
/*!
\brief Constructor.
\param theInterp python interper
\param theParent parent widget
*/
-PyConsole_Editor::PyConsole_Editor( PyInterp_base* theInterp,
- QWidget* theParent )
+PyConsole_Editor::PyConsole_Editor( PyConsole_Interp* theInterp,
+ QWidget* theParent )
: QTextEdit( theParent ),
myInterp( 0 ),
myCmdInHistory( -1 ),
setUndoRedoEnabled( false );
myPrompt = READY_PROMPT;
- setLineWrapMode( QTextEdit::NoWrap );
- setWordWrapMode( QTextOption::NoWrap );
+ setLineWrapMode( QTextEdit::WidgetWidth );
+ setWordWrapMode( QTextOption::WrapAnywhere );
setAcceptRichText( false );
+ theInterp->setvoutcb( staticCallback, this );
+ theInterp->setverrcb( staticCallback, this );
+
// san - This is necessary for troubleless initialization
onPyInterpChanged( theInterp );
}
{
}
+/*!
+ \brief Get synchronous mode flag value.
+
+ \sa setIsSync()
+ \return True if python console works in synchronous mode
+*/
bool PyConsole_Editor::isSync() const
{
return myIsSync;
}
-void PyConsole_Editor::setIsSync( const bool s )
+/*!
+ \brief Set synchronous mode flag value.
+
+ In synhronous mode the Python commands are executed in the GUI thread
+ and the GUI is blocked until the command is finished. In the asynchronous
+ mode each Python command is executed in the separate thread that does not
+ block the main GUI loop.
+
+ \param on synhronous mode flag
+*/
+void PyConsole_Editor::setIsSync( const bool on )
{
- myIsSync = s;
+ myIsSync = on;
}
/*!
\param newBlock if True, then the string is printed on a new line
*/
void PyConsole_Editor::addText( const QString& str,
- const bool newBlock )
+ const bool newBlock )
{
moveCursor( QTextCursor::End );
if ( newBlock )
PyInterp_Dispatcher::Get()->Exec( createRequest( cmd ) );
}
-PyInterp_Request* PyConsole_Editor::createRequest( const QString& cmd )
+/*!
+ \brief Create request to the python dispatcher for the command execution.
+
+ \param command python command to be executed
+ */
+PyInterp_Request* PyConsole_Editor::createRequest( const QString& command )
{
- return new ExecCommand( myInterp, cmd, this, isSync() );
+ return new ExecCommand( myInterp, command, this, isSync() );
}
/*!
\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 )
// add command to the history
if ( !cmd.trimmed().isEmpty() )
myHistory.push_back( cmd );
+
+ // IPAL19397
+ addText( "", true );
// set read-only mode
setReadOnly( true );
moveCursor( QTextCursor::End );
moveCursor( QTextCursor::StartOfBlock, QTextCursor::KeepAnchor );
textCursor().removeSelectedText();
- addText( myPrompt + ( nextCommand != TOP_HISTORY_PY ? nextCommand : myCurrentCommand ) );
+ addText( myPrompt + nextCommand );
// move cursor to the end
moveCursor( QTextCursor::End );
}
{
switch( event->type() )
{
+ case PRINT_EVENT:
+ {
+ PrintEvent* pe=(PrintEvent*)event;
+ addText( pe->text() );
+ return;
+ }
case PyInterp_Event::OK:
case PyInterp_Event::ERROR:
{
- PyInterp_Event* pe = dynamic_cast<PyInterp_Event*>( event );
- if ( pe )
- {
- ExecCommand* ec = dynamic_cast<ExecCommand*>( 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 );
+ // add caret return line if necessary
+ QTextBlock par = document()->end().previous();
+ QString txt = par.text();
+ txt.truncate( txt.length() - 1 );
+ // IPAL19397 : addText moved to handleReturn() method
+ //if ( !txt.isEmpty() )
+ // addText( "", true );
// set "ready" prompt
myPrompt = READY_PROMPT;
addText( myPrompt );
{
// extend command buffer (multi-line command)
myCommandBuffer.append( "\n" );
+ // add caret return line if necessary
+ QTextBlock par = document()->end().previous();
+ QString txt = par.text();
+ txt.truncate( txt.length() - 1 );
+ // IPAL19397 : addText moved to handleReturn() method
+ //if ( !txt.isEmpty() )
+ // addText( "", true );
// set "dot" prompt
myPrompt = DOTS_PROMPT;
- addText( myPrompt, true );
+ addText( myPrompt/*, true*/ ); // IPAL19397
// unset busy cursor
unsetCursor();
// stop event loop (if running)
Perform initialization actions if the interpreter is changed.
\param interp python interpreter is being set
*/
-void PyConsole_Editor::onPyInterpChanged( PyInterp_base* interp )
+void PyConsole_Editor::onPyInterpChanged( PyConsole_Interp* interp )
{
if ( myInterp != interp
// Force read-only state and wait cursor when myInterp is NULL
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// File : PyConsole_Editor.h
-// Author : Vadim SANDLER
-// Module : SALOME
+// File : PyConsole_Editor.h
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//
#ifndef PYCONSOLE_EDITOR_H
#define PYCONSOLE_EDITOR_H
-#include "PyConsole_Interp.h" // this include must be first (see PyInterp_base.h)!
+#include "PyConsole.h"
-#include <QtGui/qtextedit.h>
+#include <QTextEdit>
-class QMenu;
-class QEventLoop;
class PyConsole_Interp;
class PyInterp_Request;
+class QEventLoop;
class PYCONSOLE_EXPORT PyConsole_Editor : public QTextEdit
{
Q_OBJECT;
public:
- PyConsole_Editor( PyInterp_base* theInterp, QWidget *theParent = 0 );
+ PyConsole_Editor( PyConsole_Interp* theInterp, QWidget *theParent = 0 );
~PyConsole_Editor();
virtual void addText( const QString& str, const bool newBlock = false );
virtual void customEvent( QEvent* event);
virtual PyInterp_Request* createRequest( const QString& );
-
+
public slots:
void cut();
void paste();
void clear();
void handleReturn();
- void onPyInterpChanged( PyInterp_base* );
+ void onPyInterpChanged( PyConsole_Interp* );
private:
- PyInterp_base* myInterp; //!< python interpreter
+ PyConsole_Interp* 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
- bool myIsSync;
+ 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
+ bool myIsSync; //!< synchronous mode flag
};
-#endif
+#endif // PYCONSOLE_EDITOR_H
\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().
+
+ Call initialize method defined in the base class PyInterp_Interp,
+ to intialize interpreter after instance creation.
+
+ The method initialize() calls virtuals methods
+ - initPython() to initialize global Python interpreter
+ - initState() to initialize embedded interpreter state
+ - initContext() to initialize interpreter internal context
+ - initRun() to prepare interpreter for running commands
/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.<br>
+ This is fine because every study has its own modules (sys.modules) stdout and stderr.
+
<b>But</b> 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
+ 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.<br>
+ the other interpreters.
+
<b>But</b> 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
have identical __builtin__ module.
*/
-using namespace std;
-
/*!
\brief Constructor.
Creates new python interpreter.
*/
-PyConsole_Interp::PyConsole_Interp(): PyInterp_base()
+PyConsole_Interp::PyConsole_Interp(): PyInterp_Interp()
{
}
/*!
\brief Initialize internal Python interpreter state.
+ \return \c true on success
*/
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
-
-/* LLS
PyEval_AcquireLock();
_tstate = Py_NewInterpreter(); // create an interpreter and save current state
- PySys_SetArgv(PyInterp_base::_argc,PyInterp_base::_argv); // initialize sys.argv
-*/
-
- PyEval_AcquireLock();
-#ifdef WIN32
- _tstate = PyGILState_GetThisThreadState();
- // if no thread state defined
- if ( _tstate )
- PyThreadState_Swap(_tstate);
- else
-#endif
- {
- _tstate = Py_NewInterpreter(); // create an interpreter and save current state
- PySys_SetArgv(PyInterp_base::_argc,PyInterp_base::_argv); // initialize sys.argv
- //if(MYDEBUG) MESSAGE("PythonConsole_PyInterp::initState - this = "<<this<<"; _tstate = "<<_tstate);
- }
-
+ PySys_SetArgv(PyInterp_Interp::_argc,PyInterp_Interp::_argv); // initialize sys.argv
//If builtinmodule has been initialized all the sub interpreters
// will have the same __builtin__ module
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.
+
+ \return \c true on success
*/
bool PyConsole_Interp::initContext()
{
#include "PyConsole.h"
-#include <PyInterp_base.h> // this include must be first (see PyInterp_base.h)!
+#include <PyInterp_Interp.h> /// !!! WARNING !!! THIS INCLUDE MUST BE VERY FIRST !!!
-class PYCONSOLE_EXPORT PyConsole_Interp : public PyInterp_base
+class PYCONSOLE_EXPORT PyConsole_Interp : public PyInterp_Interp
{
public:
PyConsole_Interp();
virtual bool initContext();
};
-#endif
+#endif // PYCONSOLE_INTERP_H
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#if !defined ( _PYINTERP_H )
-#define _PYINTERP_H
+// File : PyInterp.h
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//
+
+#if !defined ( PYINTERP_H )
+#define PYINTERP_H
// ========================================================
// set dllexport type for Win platform
#ifdef WIN32
-
-#ifdef PYINTERP_EXPORTS
-#define PYINTERP_EXPORT __declspec(dllexport)
-#else
-#define PYINTERP_EXPORT __declspec(dllimport)
-#endif
-
+# ifdef PYINTERP_EXPORTS
+# define PYINTERP_EXPORT __declspec(dllexport)
+# else
+# define PYINTERP_EXPORT __declspec(dllimport)
+# endif
#else // WIN32
-
-#define PYINTERP_EXPORT
-
+# define PYINTERP_EXPORT
#endif // WIN32
// ========================================================
-// little trick - we do not have debug python libraries
+// little trick - if we do not have debug python libraries
#ifdef _DEBUG
-
-#undef _DEBUG
-#include <Python.h>
-#define _DEBUG
-
-#else // _DEBUG
+ #ifndef HAVE_DEBUG_PYTHON
+ #undef _DEBUG
+ #endif
+#endif
#include <Python.h>
-#endif // _DEBUG
+#ifdef _DEBUG
+ #ifndef HAVE_DEBUG_PYTHON
+ #define _DEBUG
+ #endif
+#endif
// ========================================================
// avoid warning messages
#pragma warning (disable : 4251)
#endif
-#endif // _PYINTERP_H
+#endif // PYINTERP_H
-TEMPLATE = lib
+unix:TEMPLATE = lib
+win32:TEMPLATE = vclib
+
+win32:QMAKE_MOC=$(QTDIR)\bin\moc.exe
DESTDIR = ../../$(CONFIG_ID)/lib
MOC_DIR = ../../moc
INCLUDEPATH += ../../include $$(PYTHONINC)
unix:LIBS += -L$$(PYTHONLIB) -lpython2.5
-win32:LIBS += /LIBPATH:$$(PYTHONLIB)
+win32:LIBS += -L$$(PYTHONLIB) -lpython25_d
+win32:LIBS *= -L$(QTLIB)
+win32:INCLUDEPATH *= $(QTINC) $(QTINC)\QtCore $(QTINC)\QtGui $(QTINC)\QtXml
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared
-win32:DEFINES += WIN32
+win32:DEFINES += WNT WIN32 HAVE_DEBUG_PYTHON
DEFINES += PYINTERP_EXPORTS
HEADERS = *.h
SOURCES = *.cxx
+win32:copy_hdr.name = Install ${QMAKE_FILE_IN}
+win32:copy_hdr.commands = type ${QMAKE_FILE_IN} > ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.output = ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.input = HEADERS
+win32:QMAKE_EXTRA_COMPILERS += copy_hdr
+
includes.files = $$HEADERS
includes.path = ../../include
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// SALOME SALOMEGUI : implementation of desktop and GUI kernel
-//
// File : PyInterp_Dispatcher.cxx
// Author : Sergey ANIKIN, OCC
// Module : GUI
-// $Header$
-
-#include "PyInterp_base.h"
+#include "PyInterp_Dispatcher.h" // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
+#include "PyInterp_Interp.h"
#include "PyInterp_Watcher.h"
-#include "PyInterp_Dispatcher.h"
-#include <QtCore/qobject.h>
-#include <QtCore/qcoreapplication.h>
+#include <QObject>
+#include <QCoreApplication>
using namespace std;
// Clear the request queue
myQueueMutex.lock();
- for ( std::list<PyInterp_Request*>::iterator it = myQueue.begin(); it != myQueue.end(); ++it )
- PyInterp_Request::Destroy( *it );
+ QListIterator<RequestPtr> it( myQueue );
+ while ( it.hasNext() )
+ PyInterp_Request::Destroy( it.next() );
myQueue.clear();
myQueueMutex.unlock();
else // asynchronous processing
{
myQueueMutex.lock();
- myQueue.push_back( theRequest );
+ myQueue.enqueue( theRequest );
if ( theRequest->listener() )
QObject::connect( theRequest->listener(), SIGNAL( destroyed( QObject* ) ), myWatcher, SLOT( onDestroyed( QObject* ) ) );
myQueueMutex.unlock();
while( myQueue.size() ) {
// MESSAGE("*** PyInterp_Dispatcher::run(): next request taken from the queue")
- aRequest = myQueue.front();
+ aRequest = myQueue.head();
// let other threads append their requests to the end of the queue
myQueueMutex.unlock();
// prepare for removal of the first request in the queue
myQueueMutex.lock();
// IMPORTANT: the first item could have been removed by objectDestroyed() --> we have to check it
- if ( myQueue.front() == aRequest ) // It's still here --> remove it
- myQueue.pop_front();
+ if ( myQueue.head() == aRequest ) // It's still here --> remove it
+ myQueue.dequeue();
// MESSAGE("*** PyInterp_Dispatcher::run(): request processed")
}
// prepare for modification of the queue
myQueueMutex.lock();
- for ( std::list<RequestPtr>::iterator it = myQueue.begin(); it != myQueue.end(); ++it )
+ QMutableListIterator<RequestPtr> it( myQueue );
+ while ( it.hasNext() )
{
- if ( o == (*it)->listener() )
+ RequestPtr r = it.next();
+ if ( o == r->listener() )
{
- (*it)->setListener( 0 ); // to prevent event posting
- it = myQueue.erase( it );
+ r->setListener( 0 ); // to prevent event posting
+ it.remove();
}
}
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// SALOME SALOMEGUI : implementation of desktop and GUI kernel
-//
// File : PyInterp_Dispatcher.h
// Author : Sergey Anikin, OCC
// Module : SALOME
-#ifndef _PYINTERP_DISPATCHER_H_
-#define _PYINTERP_DISPATCHER_H_
-
-#include "PyInterp.h"
-
-#include <QtCore/qmutex.h>
-#include <QtCore/qthread.h>
+#ifndef PYINTERP_DISPATCHER_H
+#define PYINTERP_DISPATCHER_H
-#include <QtGui/qevent.h>
+#include "PyInterp.h" // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
-#include <list>
+#include <QMutex>
+#include <QThread>
+#include <QEvent>
+#include <QQueue>
class QObject;
-class PyInterp_base;
+class PyInterp_Interp;
class PyInterp_Watcher;
class PyInterp_Dispatcher;
virtual void processEvent( QObject* );
-private:
- void process();
QObject* listener() const { return myListener; }
void setListener( QObject* );
+private:
+ void process();
+
private:
QMutex myMutex;
bool myIsSync;
class PYINTERP_EXPORT PyInterp_LockRequest : public PyInterp_Request
{
public:
- PyInterp_LockRequest( PyInterp_base* interp, QObject* listener = 0, bool sync = false )
+ PyInterp_LockRequest( PyInterp_Interp* interp, QObject* listener = 0, bool sync = false )
: PyInterp_Request( listener, sync ), myInterp( interp ) {}
protected:
- PyInterp_base* getInterp() const { return myInterp; }
+ PyInterp_Interp* getInterp() const { return myInterp; }
- virtual void safeExecute();
+ virtual void safeExecute();
private:
- PyInterp_base* myInterp;
+ PyInterp_Interp* myInterp;
};
class PYINTERP_EXPORT PyInterp_Event : public QEvent
private:
typedef PyInterp_Request* RequestPtr;
- std::list<RequestPtr> myQueue;
+ QQueue<RequestPtr> myQueue;
QMutex myQueueMutex;
PyInterp_Watcher* myWatcher;
friend class PyInterp_Watcher;
};
-#endif
+#endif // PYINTERP_DISPATCHER_H
--- /dev/null
+// 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 : PyInterp_Interp.cxx
+// Author : Christian CAREMOLI, Paul RASCLE, EDF
+// Module : SALOME
+
+#include "PyInterp_Interp.h" // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
+
+#include <cStringIO.h>
+#include <structmember.h>
+
+#include <string>
+#include <vector>
+#include <iostream>
+
+#define TOP_HISTORY_PY "--- top of history ---"
+#define BEGIN_HISTORY_PY "--- begin of history ---"
+
+/*!
+ \class PyLockWrapper
+ \brief Python GIL wrapper.
+*/
+
+/*!
+ \brief Constructor. Automatically acquires GIL.
+ \param theThreadState python thread state
+*/
+PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState):
+ myThreadState(theThreadState),
+ mySaveThreadState(0)
+{
+ if (myThreadState->interp == PyInterp_Interp::_interp)
+ _savestate = PyGILState_Ensure();
+ else
+ PyEval_AcquireThread(myThreadState);
+}
+
+/*!
+ \brief Desstructor. Automatically releases GIL.
+*/
+PyLockWrapper::~PyLockWrapper()
+{
+ if (myThreadState->interp == PyInterp_Interp::_interp)
+ PyGILState_Release(_savestate);
+ else
+ PyEval_ReleaseThread(myThreadState);
+}
+
+/*!
+ \brief Get Python GIL wrapper.
+ \return GIL lock wrapper (GIL is automatically acquired here)
+*/
+PyLockWrapper PyInterp_Interp::GetLockWrapper()
+{
+ return _tstate;
+}
+
+/*
+ The following functions are used to hook the Python
+ interpreter output.
+*/
+
+static void
+PyStdOut_dealloc(PyStdOut *self)
+{
+ PyObject_Del(self);
+}
+
+static PyObject*
+PyStdOut_write(PyStdOut *self, PyObject *args)
+{
+ char *c;
+ int l;
+ if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
+ return NULL;
+ if(self->_cb==NULL) {
+ if ( self->_iscerr )
+ std::cerr << c ;
+ else
+ std::cout << c ;
+ }
+ else {
+ self->_cb(self->_data,c);
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMethodDef PyStdOut_methods[] = {
+ {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
+ PyDoc_STR("write(string) -> None")},
+ {NULL, NULL} /* sentinel */
+};
+
+static PyMemberDef PyStdOut_memberlist[] = {
+ {"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
+ "flag indicating that a space needs to be printed; used by print"},
+ {NULL} /* Sentinel */
+};
+
+static PyTypeObject PyStdOut_Type = {
+ /* The ob_type field must be initialized in the module init function
+ * to be portable to Windows without using C++. */
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "PyOut", /*tp_name*/
+ sizeof(PyStdOut), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ /* methods */
+ (destructor)PyStdOut_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ PyObject_GenericGetAttr, /*tp_getattro*/
+ /* softspace is writable: we must supply tp_setattro */
+ PyObject_GenericSetAttr, /* tp_setattro */
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ PyStdOut_methods, /*tp_methods*/
+ PyStdOut_memberlist, /*tp_members*/
+ 0, /*tp_getset*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ 0, /*tp_init*/
+ 0, /*tp_alloc*/
+ 0, /*tp_new*/
+ 0, /*tp_free*/
+ 0, /*tp_is_gc*/
+};
+
+#define PyStdOut_Check(v) ((v)->ob_type == &PyStdOut_Type)
+
+static PyStdOut* newPyStdOut( bool iscerr )
+{
+ PyStdOut *self;
+ self = PyObject_New(PyStdOut, &PyStdOut_Type);
+ if (self == NULL)
+ return NULL;
+ self->softspace = 0;
+ self->_cb = NULL;
+ self->_iscerr = iscerr;
+ return self;
+}
+
+/*!
+ \class PyInterp_Interp
+ \brief Generic embedded Python interpreter.
+*/
+
+int PyInterp_Interp::_argc = 1;
+char* PyInterp_Interp::_argv[] = {""};
+PyObject* PyInterp_Interp::builtinmodule = NULL;
+PyThreadState* PyInterp_Interp::_gtstate = NULL;
+PyInterpreterState* PyInterp_Interp::_interp = NULL;
+
+/*!
+ \brief Basic constructor.
+
+ After construction the interpreter instance successor classes
+ must call virtual method initalize().
+*/
+PyInterp_Interp::PyInterp_Interp():
+ _tstate(0), _vout(0), _verr(0), _g(0)
+{
+}
+
+/*!
+ \brief Destructor.
+*/
+PyInterp_Interp::~PyInterp_Interp()
+{
+}
+
+/*!
+ \brief Initialize embedded interpreter.
+
+ This method shoud be called after construction of the interpreter.
+ The method initialize() calls virtuals methods
+ - initPython() to initialize global Python interpreter
+ - initState() to initialize embedded interpreter state
+ - initContext() to initialize interpreter internal context
+ - initRun() to prepare interpreter for running commands
+ which should be implemented in the successor classes, according to the
+ embedded Python interpreter policy (mono or multi interpreter, etc).
+*/
+void PyInterp_Interp::initialize()
+{
+ _history.clear(); // start a new list of user's commands
+ _ith = _history.begin();
+
+ initPython();
+ // Here the global lock is released
+
+ initState();
+
+ PyLockWrapper aLock = GetLockWrapper();
+
+ initContext();
+
+ // used to interpret & compile commands
+ PyObjWrapper m(PyImport_ImportModule("codeop"));
+ if(!m) {
+ PyErr_Print();
+ return;
+ }
+
+ // Create python objects to capture stdout and stderr
+ _vout=(PyObject*)newPyStdOut( false ); // stdout
+ _verr=(PyObject*)newPyStdOut( true ); // stderr
+
+ // All the initRun outputs are redirected to the standard output (console)
+ initRun();
+}
+
+/*!
+ \brief Initialize Python interpreter.
+
+ Set program name, initialize interpreter, set program arguments,
+ initiaize threads.
+ */
+void PyInterp_Interp::initPython()
+{
+ if (Py_IsInitialized())
+ return;
+
+ // Python is not initialized
+ Py_SetProgramName(_argv[0]);
+ Py_Initialize(); // Initialize the interpreter
+ PySys_SetArgv(_argc, _argv);
+ PyEval_InitThreads(); // Create (and acquire) the interpreter lock
+ _interp = PyThreadState_Get()->interp;
+ if (PyType_Ready(&PyStdOut_Type) < 0) {
+ PyErr_Print();
+ }
+ _gtstate = PyEval_SaveThread(); // Release global thread state
+}
+
+/*!
+ \brief Get embedded Python interpreter banner.
+ \return banner string
+ */
+std::string PyInterp_Interp::getbanner()
+{
+ // Should we take the lock ?
+ // PyEval_RestoreThread(_tstate);
+ std::string aBanner("Python ");
+ aBanner = aBanner + Py_GetVersion() + " on " + Py_GetPlatform() ;
+ aBanner = aBanner + "\ntype help to get general information on environment\n";
+ //PyEval_SaveThread();
+ return aBanner;
+}
+
+/*!
+ \brief Initialize run command.
+
+ This method is used to prepare interpreter for running
+ Python commands.
+
+ \return \c true on success and \c false on error
+*/
+bool PyInterp_Interp::initRun()
+{
+ //
+ // probably all below code isn't required
+ //
+ /*
+ PySys_SetObject("stderr",_verr);
+ PySys_SetObject("stdout",_vout);
+
+ //PyObject *m = PyImport_GetModuleDict();
+
+ PySys_SetObject("stdout",PySys_GetObject("__stdout__"));
+ PySys_SetObject("stderr",PySys_GetObject("__stderr__"));
+ */
+ return true;
+}
+
+/*!
+ \brief Compile Python command and evaluate it in the
+ python dictionary context if possible.
+ \internal
+ \param command Python command string
+ \param context Python context (dictionary)
+ \return -1 on fatal error, 1 if command is incomplete and 0
+ if command is executed successfully
+ */
+static int compile_command(const char *command,PyObject *context)
+{
+ PyObject *m = PyImport_AddModule("codeop");
+ if(!m) { // Fatal error. No way to go on.
+ PyErr_Print();
+ return -1;
+ }
+ PyObjWrapper v(PyObject_CallMethod(m,"compile_command","s",command));
+ if(!v) {
+ // Error encountered. It should be SyntaxError,
+ //so we don't write out traceback
+ PyObjWrapper exception, value, tb;
+ PyErr_Fetch(&exception, &value, &tb);
+ PyErr_NormalizeException(&exception, &value, &tb);
+ PyErr_Display(exception, value, NULL);
+ return -1;
+ }
+ else if (v == Py_None) {
+ // Incomplete text we return 1 : we need a complete text to execute
+ return 1;
+ }
+ else {
+ // Complete and correct text. We evaluate it.
+ //#if PY_VERSION_HEX < 0x02040000 // python version earlier than 2.4.0
+ // PyObjWrapper r(PyEval_EvalCode(v,context,context));
+ //#else
+ PyObjWrapper r(PyEval_EvalCode((PyCodeObject *)(void *)v,context,context));
+ //#endif
+ if(!r) {
+ // Execution error. We return -1
+ PyErr_Print();
+ return -1;
+ }
+ // The command has been successfully executed. Return 0
+ return 0;
+ }
+}
+
+/*!
+ \brief Run Python command.
+ \param command Python command
+ \return command status
+*/
+int PyInterp_Interp::run(const char *command)
+{
+ beforeRun();
+ return simpleRun(command);
+}
+
+/*!
+ \brief Run Python command (used internally).
+ \param command Python command
+ \param addToHistory if \c true (default), the command is added to the commands history
+ \return command status
+*/
+int PyInterp_Interp::simpleRun(const char *command, const bool addToHistory)
+{
+ if( addToHistory && strcmp(command,"") != 0 ) {
+ _history.push_back(command);
+ _ith = _history.end();
+ }
+
+ // We come from C++ to enter Python world
+ // We need to acquire the Python global lock
+ //PyLockWrapper aLock(_tstate); // san - lock is centralized now
+
+ // Reset redirected outputs before treatment
+ PySys_SetObject("stderr",_verr);
+ PySys_SetObject("stdout",_vout);
+
+ int ier = compile_command(command,_g);
+
+ // Outputs are redirected on standards outputs (console)
+ PySys_SetObject("stdout",PySys_GetObject("__stdout__"));
+ PySys_SetObject("stderr",PySys_GetObject("__stderr__"));
+
+ return ier;
+}
+
+/*!
+ \brief Get previous command in the commands history.
+ \return previous command
+*/
+const char * PyInterp_Interp::getPrevious()
+{
+ if(_ith != _history.begin()){
+ _ith--;
+ return (*_ith).c_str();
+ }
+ else
+ return BEGIN_HISTORY_PY;
+}
+
+/*!
+ \brief Get next command in the commands history.
+ \return next command
+*/
+const char * PyInterp_Interp::getNext()
+{
+ if(_ith != _history.end()){
+ _ith++;
+ }
+ if (_ith == _history.end())
+ return TOP_HISTORY_PY;
+ else
+ return (*_ith).c_str();
+}
+
+/*!
+ \brief Set Python standard output device hook.
+ \param cb callback function
+ \param data callback function parameters
+*/
+void PyInterp_Interp::setvoutcb(PyOutChanged* cb, void* data)
+{
+ ((PyStdOut*)_vout)->_cb=cb;
+ ((PyStdOut*)_vout)->_data=data;
+}
+
+/*!
+ \brief Set Python standard error device hook.
+ \param cb callback function
+ \param data callback function parameters
+*/
+void PyInterp_Interp::setverrcb(PyOutChanged* cb, void* data)
+{
+ ((PyStdOut*)_verr)->_cb=cb;
+ ((PyStdOut*)_verr)->_data=data;
+}
--- /dev/null
+// 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 : PyInterp_Interp.h
+// Author : Christian CAREMOLI, Paul RASCLE, EDF
+// Module : SALOME
+
+#ifndef PYINTERP_INTERP_H
+#define PYINTERP_INTERP_H
+
+#include "PyInterp.h" // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
+
+#include <list>
+#include <string>
+
+class PYINTERP_EXPORT PyLockWrapper
+{
+ PyThreadState* myThreadState;
+ PyThreadState* mySaveThreadState;
+ PyGILState_STATE _savestate;
+public:
+ PyLockWrapper(PyThreadState* theThreadState);
+ ~PyLockWrapper();
+};
+
+typedef void PyOutChanged(void* data,char * c);
+
+class PYINTERP_EXPORT PyInterp_Interp
+{
+public:
+ static int _argc;
+ static char* _argv[];
+ static PyObject *builtinmodule;
+ static PyThreadState *_gtstate;
+ static PyInterpreterState *_interp;
+
+ PyInterp_Interp();
+ virtual ~PyInterp_Interp();
+
+ void initialize();
+
+ virtual int run(const char *command);
+
+ PyLockWrapper GetLockWrapper();
+
+ std::string getbanner();
+ void setverrcb(PyOutChanged*,void*);
+ void setvoutcb(PyOutChanged*,void*);
+
+ const char * getPrevious();
+ const char * getNext();
+
+protected:
+ PyThreadState * _tstate;
+ PyObject * _vout;
+ PyObject * _verr;
+ PyObject * _g;
+ PyObject * _codeop;
+ std::list<std::string> _history;
+ std::list<std::string>::iterator _ith;
+
+ virtual int beforeRun() { return 0; }
+ int simpleRun(const char* command, const bool addToHistory = true);
+
+ virtual bool initRun();
+ virtual void initPython();
+ virtual bool initState() = 0;
+ virtual bool initContext() = 0;
+};
+
+class PYINTERP_EXPORT PyObjWrapper
+{
+ PyObject* myObject;
+public:
+ PyObjWrapper(PyObject* theObject) : myObject(theObject) {}
+ PyObjWrapper() : myObject(0) {}
+ virtual ~PyObjWrapper() { Py_XDECREF(myObject); }
+
+ operator PyObject*() { return myObject; }
+ PyObject* operator->() { return myObject; }
+ PyObject* get() { return myObject; }
+ bool operator!() { return !myObject; }
+ bool operator==(PyObject* theObject) { return myObject == theObject; }
+ PyObject** operator&() { return &myObject; }
+ PyObjWrapper& operator=(PyObjWrapper* theObjWrapper)
+ {
+ Py_XDECREF(myObject);
+ myObject = theObjWrapper->myObject;
+ return *this;
+ }
+};
+
+typedef struct {
+ PyObject_HEAD
+ int softspace;
+ PyOutChanged* _cb;
+ void* _data;
+ bool _iscerr;
+} PyStdOut;
+
+#endif // PYINTERP_INTERP_H
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#ifndef _PYINTERP_WATCHER_H_
-#define _PYINTERP_WATCHER_H_
+// File : PyInterp_Watcher.h
+// Author : Sergey Anikin, OCC
+// Module : SALOME
-#include "PyInterp.h"
+#ifndef PYINTERP_WATCHER_H
+#define PYINTERP_WATCHER_H
+
+#include "PyInterp.h" // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
#include "PyInterp_Dispatcher.h"
-#include <QtCore/qobject.h>
+#include <QObject>
// Private class that keeps track of destructions of request listeners
class PYINTERP_EXPORT PyInterp_Watcher : public QObject
void onDestroyed( QObject* o ) { PyInterp_Dispatcher::Get()->objectDestroyed( o ); }
};
-#endif // _PYINTERP_WATCHER_H_
+#endif // PYINTERP_WATCHER_H
+++ /dev/null
-// 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
-//
-// SALOME SALOMEGUI : implementation of desktop and GUI kernel
-//
-// File : PyInterp_base.cxx
-// Author : Christian CAREMOLI, Paul RASCLE, EDF
-// Module : SALOME
-// $Header$
-
-
-#include "PyInterp_base.h" // this include must be first (see PyInterp_base.h)!
-
-#include <cStringIO.h>
-
-#include <string>
-#include <vector>
-
-using namespace std;
-
-PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState):
- myThreadState(theThreadState),
- mySaveThreadState(0)
-{
-#if defined(USE_GILSTATE)
- if (myThreadState->interp == PyInterp_base::_interp) {
- _savestate = PyGILState_Ensure();
- } else {
- PyEval_AcquireThread(myThreadState);
- }
-#else
- PyEval_AcquireThread(myThreadState);
-#endif
-}
-
-PyLockWrapper::~PyLockWrapper()
-{
-#if defined(USE_GILSTATE)
- if (myThreadState->interp == PyInterp_base::_interp) {
- PyGILState_Release(_savestate);
- } else {
- PyEval_ReleaseThread(myThreadState);
- }
-#else
- PyEval_ReleaseThread(myThreadState);
-#endif
-}
-
-class PyReleaseLock{
-public:
- ~PyReleaseLock(){
- PyEval_ReleaseLock();
- }
-};
-
-
-PyLockWrapper PyInterp_base::GetLockWrapper(){
- return _tstate;
-}
-
-
-// main python interpreter (static attributes)
-
-int PyInterp_base::_argc = 1;
-char* PyInterp_base::_argv[] = {""};
-
-PyObject *PyInterp_base::builtinmodule = NULL;
-
-PyThreadState *PyInterp_base::_gtstate = NULL;
-PyInterpreterState *PyInterp_base::_interp = NULL;
-
-
-/*!
- * basic constructor here : herited classes constructors must call initalize() method
- * defined here.
- */
-PyInterp_base::PyInterp_base(): _tstate(0), _vout(0), _verr(0), _g(0), _atFirst(true)
-{
-}
-
-PyInterp_base::~PyInterp_base()
-{
-}
-
-
-/*!
- * Must be called by herited classes constructors. initialize() calls virtuals methods
- * initstate & initcontext, not defined here in base class. initstate & initcontext methods
- * must be implemented in herited classes, following the Python interpreter policy
- * (mono or multi interpreter...).
- */
-void PyInterp_base::initialize()
-{
- _history.clear(); // start a new list of user's commands
- _ith = _history.begin();
-
- init_python();
- // Here the global lock is released
-
- initState();
-
- PyLockWrapper aLock= GetLockWrapper();
-
- initContext();
-
- // used to interpret & compile commands
- PyObjWrapper m(PyImport_ImportModule("codeop"));
- if(!m){
- PyErr_Print();
- return;
- }
-
- // Create cStringIO to capture stdout and stderr
- PycString_IMPORT;
- if (PycStringIO) { // CTH11627 : additional check
- _vout = PycStringIO->NewOutput(128);
- _verr = PycStringIO->NewOutput(128);
- }
-
- // All the initRun outputs are redirected to the standard output (console)
- initRun();
-}
-
-void PyInterp_base::init_python()
-{
- _atFirst = false;
- if (Py_IsInitialized())
- return;
-
- // Python is not initialized
- Py_SetProgramName(_argv[0]);
- Py_Initialize(); // Initialize the interpreter
- PySys_SetArgv(_argc, _argv);
- PyEval_InitThreads(); // Create (and acquire) the interpreter lock
- _interp = PyThreadState_Get()->interp;
- _gtstate = PyEval_SaveThread(); // Release global thread state
-}
-
-string PyInterp_base::getbanner()
-{
- // Should we take the lock ?
- // PyEval_RestoreThread(_tstate);
- string aBanner("Python ");
- aBanner = aBanner + Py_GetVersion() + " on " + Py_GetPlatform() ;
- aBanner = aBanner + "\ntype help to get general information on environment\n";
- //PyEval_SaveThread();
- return aBanner;
-}
-
-
-int PyInterp_base::initRun()
-{
- PySys_SetObject("stderr",_verr);
- PySys_SetObject("stdout",_vout);
-
- PyObjWrapper verr(PyObject_CallMethod(_verr,"reset",""));
- PyObjWrapper vout(PyObject_CallMethod(_vout,"reset",""));
-
- //PyObject *m = PyImport_GetModuleDict();
-
- PySys_SetObject("stdout",PySys_GetObject("__stdout__"));
- PySys_SetObject("stderr",PySys_GetObject("__stderr__"));
-
- return 0;
-}
-
-
-/*!
- * This function compiles a string (command) and then evaluates it in the dictionnary
- * context if possible.
- * Returns :
- * -1 : fatal error
- * 1 : incomplete text
- * 0 : complete text executed with success
- */
-int compile_command(const char *command,PyObject *context)
-{
- PyObject *m = PyImport_AddModule("codeop");
- if(!m){ // Fatal error. No way to go on.
- PyErr_Print();
- return -1;
- }
- PyObjWrapper v(PyObject_CallMethod(m,"compile_command","s",command));
- if(!v){
- // Error encountered. It should be SyntaxError,
- //so we don't write out traceback
- PyObjWrapper exception, value, tb;
- PyErr_Fetch(&exception, &value, &tb);
- PyErr_NormalizeException(&exception, &value, &tb);
- PyErr_Display(exception, value, NULL);
- return -1;
- }else if (v == Py_None){
- // Incomplete text we return 1 : we need a complete text to execute
- return 1;
- }else{
- // Complete and correct text. We evaluate it.
- //#if PY_VERSION_HEX < 0x02040000 // python version earlier than 2.4.0
- // PyObjWrapper r(PyEval_EvalCode(v,context,context));
- //#else
- PyObjWrapper r(PyEval_EvalCode((PyCodeObject *)(void *)v,context,context));
- //#endif
- if(!r){
- // Execution error. We return -1
- PyErr_Print();
- return -1;
- }
- // The command has been successfully executed. Return 0
- return 0;
- }
-}
-
-
-int PyInterp_base::run(const char *command)
-{
- if(_atFirst){
- int ret = 0;
- ret = simpleRun("from Help import *");
- if (ret) {
- _atFirst = false;
- return ret;
- }
- ret = simpleRun("import salome");
- if (ret) {
- _atFirst = false;
- return ret;
- }
- ret = simpleRun("salome.salome_init(0,1)");
- if (ret) {
- _atFirst = false;
- return ret;
- }
- _atFirst = false;
- }
- return simpleRun(command);
-}
-
-
-int PyInterp_base::simpleRun(const char *command)
-{
- if( !_atFirst && strcmp(command,"") != 0 ) {
- _history.push_back(command);
- _ith = _history.end();
- }
-
- // We come from C++ to enter Python world
- // We need to acquire the Python global lock
- //PyLockWrapper aLock(_tstate); // san - lock is centralized now
-
- // Reset redirected outputs before treatment
- PySys_SetObject("stderr",_verr);
- PySys_SetObject("stdout",_vout);
-
- PyObjWrapper verr(PyObject_CallMethod(_verr,"reset",""));
- PyObjWrapper vout(PyObject_CallMethod(_vout,"reset",""));
-
- int ier = compile_command(command,_g);
-
- // Outputs are redirected on standards outputs (console)
- PySys_SetObject("stdout",PySys_GetObject("__stdout__"));
- PySys_SetObject("stderr",PySys_GetObject("__stderr__"));
-
- return ier;
-}
-
-
-const char * PyInterp_base::getPrevious()
-{
- if(_ith != _history.begin()){
- _ith--;
- return (*_ith).c_str();
- }
- else
- return BEGIN_HISTORY_PY;
-}
-
-
-const char * PyInterp_base::getNext()
-{
- if(_ith != _history.end()){
- _ith++;
- }
- if (_ith == _history.end())
- return TOP_HISTORY_PY;
- else
- return (*_ith).c_str();
-}
-
-
-string PyInterp_base::getverr(){
- //PyLockWrapper aLock(_tstate);
- PyObjWrapper v(PycStringIO->cgetvalue(_verr));
- string aRet(PyString_AsString(v));
- return aRet;
-}
-
-
-string PyInterp_base::getvout(){
- //PyLockWrapper aLock(_tstate);
- PyObjWrapper v(PycStringIO->cgetvalue(_vout));
- string aRet(PyString_AsString(v));
- return aRet;
-}
+++ /dev/null
-// 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
-//
-// SALOME SALOMEGUI : implementation of desktop and GUI kernel
-//
-// File : PyInterp_base.h
-// Author : Christian CAREMOLI, Paul RASCLE, EDF
-// Module : SALOME
-
-#ifndef _PYINTERP_BASE_H_
-#define _PYINTERP_BASE_H_
-
-#include "PyInterp.h"
-
-#include <list>
-#include <string>
-#include <iostream>
-
-// include order important!
-// pthread then python then qt
-//#include <pthread.h> // must be before Python.h !
-
-#include <Python.h> // must be before qt includes ...
-#include <compile.h> // Python include needed for versions before 2.4. Included in Python.h now.
-#include <eval.h> // Python include needed for versions before 2.4. Included in Python.h now.
-
-//#if PY_VERSION_HEX < 0x02040000 // python version earlier than 2.4.0
-//extern "C" PyObject * PyEval_EvalCode(PyObject *co, PyObject *g, PyObject *l);
-//#endif
-
-/* For 2.3, use the PyGILState_ calls */
-#if (PY_VERSION_HEX >= 0x02030000)
-#define USE_GILSTATE
-#endif
-
-#define TOP_HISTORY_PY "--- top of history ---"
-#define BEGIN_HISTORY_PY "--- begin of history ---"
-
-class PYINTERP_EXPORT PyLockWrapper
-{
- PyThreadState* myThreadState;
- PyThreadState* mySaveThreadState;
-#if defined(USE_GILSTATE)
- PyGILState_STATE _savestate ;
-#endif
- public:
- PyLockWrapper(PyThreadState* theThreadState);
- ~PyLockWrapper();
-};
-
-class PYINTERP_EXPORT PyInterp_base{
- public:
- static int _argc;
- static char* _argv[];
- static PyObject *builtinmodule;
- static PyThreadState *_gtstate;
- static PyInterpreterState *_interp;
-
- PyInterp_base();
- virtual ~PyInterp_base();
-
- virtual void initialize();
- virtual void init_python();
- // init_python() made virtual to:
- // 1. Remove dependency on KERNEL in light SALOME configuration
- // 2. Allow redefinition of this method in SalomeApp_PyInterp class (it should be empty there and rely on KERNEL_PYTHON)
-
- virtual int run(const char *command);
-
- PyLockWrapper GetLockWrapper();
-
- std::string getbanner();
- std::string getverr();
- std::string getvout();
-
- const char * getPrevious();
- const char * getNext();
-
- protected:
- PyThreadState * _tstate;
- PyObject * _vout;
- PyObject * _verr;
- PyObject * _g;
- PyObject * _codeop;
- std::list<std::string> _history;
- std::list<std::string>::iterator _ith;
- bool _atFirst;
-
- int simpleRun(const char* command);
- int initRun();
-
- virtual bool initState() = 0;
- virtual bool initContext() = 0;
-};
-
-
-class PYINTERP_EXPORT PyObjWrapper{
- PyObject* myObject;
-public:
- PyObjWrapper(PyObject* theObject): myObject(theObject) {}
- PyObjWrapper(): myObject(0) {}
- operator PyObject*(){
- return myObject;
- }
- PyObject* operator->(){
- return myObject;
- }
- PyObject* get(){
- return myObject;
- }
- bool operator!(){
- return !myObject;
- }
- bool operator==(PyObject* theObject){
- return myObject == theObject;
- }
- PyObject** operator&(){
- return &myObject;
- }
- PyObjWrapper& operator=(PyObjWrapper* theObjWrapper){
- Py_XDECREF(myObject);
- myObject = theObjWrapper->myObject;
- return *this;
- }
- virtual ~PyObjWrapper(){
- Py_XDECREF(myObject);
- }
-};
-
-#endif
-TEMPLATE = lib
+win32:TEMPLATE = vclib
+unix:TEMPLATE = lib
+
+CONFIG += embed_manifest_exe
+
+win32:QMAKE_MOC=$(QTDIR)\bin\moc.exe
DESTDIR = ../../$(CONFIG_ID)/lib
MOC_DIR = ../../moc
OBJECTS_DIR = ../../$(CONFIG_ID)/obj/$$TARGET
+win32:LIBS *= -L$(QTLIB)
+win32:INCLUDEPATH *= $(QTINC) $(QTINC)\QtCore $(QTINC)\QtGui $(QTINC)\QtXml
+
QT += xml
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared
-win32:DEFINES += WIN32
+win32:DEFINES += WNT WIN32
DEFINES += QTX_EXPORTS
HEADERS = *.h
SOURCES = *.cxx
+win32:copy_hdr.name = Install ${QMAKE_FILE_IN}
+win32:copy_hdr.commands = type ${QMAKE_FILE_IN} > ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.output = ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.input = HEADERS
+win32:QMAKE_EXTRA_COMPILERS += copy_hdr
+
includes.files = $$HEADERS
includes.path = ../../include
// 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
+// 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
+//
+// 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
+// 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
\param parent parent object
*/
QtxMRUAction::QtxMRUAction( QObject* parent )
-: QtxAction( "Most Recently Used", "Most Recently Used", 0, parent ),
+: QtxAction( tr( "Most Recently Used" ), tr( "Most Recently Used" ), 0, parent ),
myVisCount( 5 ),
+ myHistoryCount( -1 ),
+ myLinkType( LinkAuto ),
myInsertMode( MoveFirst )
{
+ myClear = new QAction( tr( "Clear" ), this );
+ myClear->setVisible( false );
+
setMenu( new QMenu( 0 ) );
+
connect( menu(), SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) );
+ connect( myClear, SIGNAL( triggered( bool ) ), this, SLOT( onCleared( bool ) ) );
}
/*!
QtxMRUAction::QtxMRUAction( const QString& text, const QString& menuText, QObject* parent )
: QtxAction( text, menuText, 0, parent ),
myVisCount( 5 ),
+ myHistoryCount( -1 ),
+ myLinkType( LinkAuto ),
myInsertMode( MoveFirst )
{
+ myClear = new QAction( tr( "Clear" ), this );
+ myClear->setVisible( false );
+
setMenu( new QMenu( 0 ) );
connect( menu(), SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) );
+ connect( myClear, SIGNAL( triggered( bool ) ), this, SLOT( onCleared( bool ) ) );
}
/*!
QtxMRUAction::QtxMRUAction( const QString& text, const QIcon& icon,
const QString& menuText, QObject* parent )
: QtxAction( text, icon, menuText, 0, parent ),
-myVisCount( 5 ),
-myInsertMode( MoveFirst )
+ myVisCount( 5 ),
+ myHistoryCount( -1 ),
+ myLinkType( LinkAuto ),
+ myInsertMode( MoveFirst )
{
+ myClear = new QAction( tr( "Clear" ), this );
+ myClear->setVisible( false );
+
setMenu( new QMenu( 0 ) );
connect( menu(), SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) );
+ connect( myClear, SIGNAL( triggered( bool ) ), this, SLOT( onCleared( bool ) ) );
}
/*!
myInsertMode = mode;
}
+/*!
+ \brief Get the type of link menu name.
+ \return link type (QtxMRUAction::LinkType)
+*/
+int QtxMRUAction::linkType() const
+{
+ return myLinkType;
+}
+
+/*!
+ \brief Set the type of link menu name.
+ \param link type (QtxMRUAction::LinkType)
+*/
+void QtxMRUAction::setLinkType( const int type )
+{
+ myLinkType = type;
+}
+
/*!
\brief Get number of MRU items.
\return number of MRU items
/*!
\brief Set number of visible MRU items.
-
+
This method sets the maximum number of MRU items
to be displayed in the popup menu (5 by default).
myVisCount = num;
}
+/*!
+ \brief Return visible status of the menu item which clear all MRU items.
+*/
+bool QtxMRUAction::isClearPossible() const
+{
+ return myClear->isVisible();
+}
+
+/*!
+ \brief Set visible the menu item which clear all MRU items.
+*/
+void QtxMRUAction::setClearPossible( const bool on )
+{
+ myClear->setVisible( on );
+}
+
+/*!
+ \brief Get number of totally stored MRU items.
+ \return number of MRU items stored in the preferences
+ \sa setHistoryCount(), saveLinks(), loadLinks()
+*/
+int QtxMRUAction::historyCount() const
+{
+ return myHistoryCount;
+}
+
+/*!
+ \brief Set number of totally stored MRU items.
+
+ This option allows setting number of MRU items to be stored
+ in the preferences file.
+
+ If \a num < 0, then number of stored MRU items is not limited.
+
+ \return number of MRU items stored in the preferences
+ \sa historyCount(), saveLinks(), loadLinks()
+*/
+void QtxMRUAction::setHistoryCount( const int num )
+{
+ myHistoryCount = num;
+}
+
/*!
\brief Insert MRU item.
myLinks.removeAll( link );
}
+/*!
+ \brief Remove all MRU items.
+*/
+void QtxMRUAction::clear()
+{
+ myLinks.clear();
+}
+
/*!
\brief Get MRU item
\param idx MRU item index
if ( !(*it).startsWith( itemPrefix ) )
continue;
- QString link = resMgr->stringValue( section, *it, QString::null );
+ QString link = resMgr->stringValue( section, *it, QString() );
if ( link.isEmpty() || map.contains( link ) )
continue;
if ( !resMgr || section.isEmpty() )
return;
- if ( clear )
- resMgr->remove( section );
+ QString itemPrefix( "item_" );
+
+ if ( clear ) {
+ QStringList items = resMgr->parameters( section );
+ for ( QStringList::const_iterator it = items.begin(); it != items.end(); ++it )
+ {
+ if ( (*it).startsWith( itemPrefix ) )
+ resMgr->remove( section, *it );
+ }
+ }
QStringList lst;
QMap<QString, int> map;
map.insert( *itr, 0 );
}
- QString itemPrefix( "item_" );
QStringList items = resMgr->parameters( section );
for ( QStringList::const_iterator it = items.begin(); it != items.end(); ++it )
{
if ( !(*it).startsWith( itemPrefix ) )
continue;
- QString link = resMgr->stringValue( section, *it, QString::null );
+ QString link = resMgr->stringValue( section, *it, QString() );
if ( !link.isEmpty() && !map.contains( link ) )
{
lst.append( link );
}
int counter = 0;
- for ( QStringList::const_iterator iter = lst.begin(); iter != lst.end(); ++iter, counter++ )
+ for ( QStringList::const_iterator iter = lst.begin();
+ iter != lst.end() && ( myHistoryCount < 0 || counter < myHistoryCount );
+ ++iter, counter++ )
resMgr->setValue( section, itemPrefix + QString().sprintf( "%03d", counter ), *iter );
}
/*!
\brief Prepare MRU items popup menu.
-
+
This method is called when the parent menu is shown.
Enables or disables sub menu item according to the number of MRU items.
*/
if ( !a )
return;
- QString link = a->text();
+ QString link = a->data().toString();
if ( !link.isEmpty() && myLinks.contains( link ) )
emit activated( link );
}
+void QtxMRUAction::onCleared( bool )
+{
+ clear();
+}
+
/*!
\brief Update MRU items popup menu.
*/
pm->clear();
+ QStringList links;
+ QMap<QString, int> map;
int count = visibleCount() < 0 ? myLinks.count() : visibleCount();
- for ( QStringList::const_iterator it = myLinks.begin(); it != myLinks.end() && count > 0; ++it, count-- )
- pm->addAction( *it, this, SLOT( onActivated() ) );
+ int i = insertMode() == AddLast || insertMode() == MoveLast ? qMax( 0, myLinks.count()-count ) : 0;
+ for ( ; i < myLinks.count() && count > 0; ++i, count-- )
+ {
+ links.append( myLinks[i] );
+ if ( linkType() == LinkAuto )
+ {
+ QString shortName = Qtx::file( myLinks[i] );
+ if ( map.contains( shortName ) )
+ map[shortName]++;
+ else
+ map.insert( shortName, 0 );
+ }
+ }
+
+ i = 1;
+ for ( QStringList::const_iterator it = links.begin(); it != links.end(); ++it, i++ )
+ {
+ QString linkName;
+ switch( linkType() )
+ {
+ case LinkAuto:
+ linkName = Qtx::file( *it );
+ if ( map.contains( linkName ) && map[linkName] )
+ linkName = *it;
+ break;
+ case LinkShort:
+ linkName = Qtx::file( *it );
+ break;
+ case LinkFull:
+ default:
+ linkName = *it;
+ break;
+ }
+
+ if ( links.count() < 10 )
+ linkName = QString( "&%1 %2" ).arg( i ).arg( linkName );
+
+ pm->addAction( linkName, this, SLOT( onActivated() ) )->setData( *it );
+ }
+
+ if ( pm->isEmpty() )
+ pm->addAction( tr( "<Empty>" ) )->setEnabled( false );
+
+ if ( isClearPossible() )
+ {
+ pm->addSeparator();
+ pm->addAction( myClear );
+ myClear->setEnabled( !pm->isEmpty() );
+ }
}
/*!
AddLast //!< if specified item doesn't exist, add it to the end
} InsertionMode;
+ typedef enum { LinkAuto, //!< put the full path of link into the menu if link file names of severals link are same
+ LinkShort, //!< put the only file name of link into the menu
+ LinkFull //!< put the full path of link into the menu
+ } LinkType;
+
public:
QtxMRUAction( QObject* = 0 );
QtxMRUAction( const QString&, const QString&, QObject* = 0 );
int insertMode() const;
void setInsertMode( const int );
+ int linkType() const;
+ void setLinkType( const int );
+
int count() const;
bool isEmpty() const;
int visibleCount() const;
void setVisibleCount( const int );
+ bool isClearPossible() const;
+ void setClearPossible( const bool );
+
+ int historyCount() const;
+ void setHistoryCount( const int );
+
void remove( const int );
void remove( const QString& );
void insert( const QString& );
virtual void loadLinks( QtxResourceMgr*, const QString&, const bool = true );
virtual void saveLinks( QtxResourceMgr*, const QString&, const bool = true ) const;
+public slots:
+ void clear();
+
signals:
void activated( const QString& );
private slots:
void onActivated();
void onAboutToShow();
+ void onCleared( bool );
private:
void updateMenu();
private:
QStringList myLinks; //!< most recent used items
+ QAction* myClear; //!< clear item
int myVisCount; //!< number of visible MRU items
+ int myHistoryCount; //!< number of stored MRU items
+ int myLinkType; //!< type of link names in menu
int myInsertMode; //!< items insertion policy
};
// 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
+// 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
+//
+// 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
+// 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 <QSplitter>
#include <QTabWidget>
#include <QListWidget>
+#include <QApplication>
#include <QDateTimeEdit>
#include <QStackedWidget>
{
myBox = new QtxGridBox( 1, Qt::Horizontal, this, 0 );
QVBoxLayout* base = new QVBoxLayout( this );
- base->setMargin( 0 );
+ base->setMargin( 5 );
base->setSpacing( 0 );
base->addWidget( myBox );
}
*/
QSize QtxPagePrefMgr::sizeHint() const
{
- initialize();
-
return QFrame::sizeHint();
}
*/
QSize QtxPagePrefMgr::minimumSizeHint() const
{
- initialize();
-
return QFrame::minimumSizeHint();
}
/*!
\brief Customize show/hide widget operation.
- \param on if \c true the widget is being shown, otherswise
+ \param on if \c true the widget is being shown, otherswise
it is being hidden
*/
void QtxPagePrefMgr::setVisible( bool on )
{
- if ( on && !myInit )
- updateContents();
+ if ( on )
+ initialize();
+
+ QApplication::instance()->processEvents();
QFrame::setVisible( on );
}
QList<QtxPreferenceItem*> lst = childItems();
for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end(); ++it )
{
- if ( (*it)->rtti() == QtxPagePrefItem::RTTI() )
- {
- QtxPagePrefItem* item = (QtxPagePrefItem*)(*it);
- if ( item->widget() && item->widget()->parent() != myBox )
- item->widget()->setParent( myBox );
- }
+ QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( *it );
+ if ( item && item->widget() && item->widget()->parent() != myBox )
+ item->widget()->setParent( myBox );
}
setWindowIcon( icon() );
*/
void QtxPagePrefMgr::initialize() const
{
- if ( myInit )
- return;
+ // if ( myInit )
+ // return;
QtxPagePrefMgr* that = (QtxPagePrefMgr*)this;
-
- that->updateContents();
+ that->initialize( that );
+
+ // that->myInit = true;
+}
+
+void QtxPagePrefMgr::initialize( QtxPreferenceItem* item )
+{
+ if ( !item )
+ return;
- QList<QtxPreferenceItem*> lst = childItems( true );
+ QList<QtxPreferenceItem*> lst = item->childItems( false );
for ( QList<QtxPreferenceItem*>::iterator it = lst.begin(); it != lst.end(); ++it )
- (*it)->updateContents();
+ initialize( *it );
- that->myInit = true;
+ updateContents();
}
/*!
preference items.
*/
+class QtxPagePrefItem::Listener : public QObject
+{
+public:
+ Listener( QtxPagePrefItem* );
+ virtual ~Listener();
+
+ virtual bool eventFilter( QObject*, QEvent* );
+
+private:
+ QtxPagePrefItem* myItem;
+};
+
+QtxPagePrefItem::Listener::Listener( QtxPagePrefItem* item )
+: QObject( 0 ),
+ myItem( item )
+{
+}
+
+QtxPagePrefItem::Listener::~Listener()
+{
+}
+
+bool QtxPagePrefItem::Listener::eventFilter( QObject* o, QEvent* e )
+{
+ if ( !myItem || myItem->widget() != o )
+ return false;
+
+ if ( e->type() == QEvent::Show || e->type() == QEvent::ShowToParent )
+ myItem->widgetShown();
+ if ( e->type() == QEvent::Hide || e->type() == QEvent::HideToParent )
+ myItem->widgetHided();
+
+ return false;
+}
+
/*!
\brief Constructor.
\param title preference item title
QtxPagePrefItem::QtxPagePrefItem( const QString& title, QtxPreferenceItem* parent,
const QString& sect, const QString& param )
: QtxPreferenceItem( title, sect, param, parent ),
- myWidget( 0 )
+ myWidget( 0 ),
+ myListener( 0 )
{
}
QtxPagePrefItem::~QtxPagePrefItem()
{
delete myWidget;
-}
-
-/*!
- \brief Get unique item type identifier.
- \return item type ID
-*/
-int QtxPagePrefItem::rtti() const
-{
- return QtxPagePrefItem::RTTI();
+ delete myListener;
}
/*!
return myWidget;
}
-/*!
- \brief Specify unique item class identifier.
- \return item class ID
-*/
-int QtxPagePrefItem::RTTI()
-{
- return 1000;
-}
-
/*!
\brief Set preference item editor widget.
\param wid editor widget
*/
void QtxPagePrefItem::setWidget( QWidget* wid )
{
+ if ( myWidget && myListener )
+ myWidget->removeEventFilter( myListener );
+
myWidget = wid;
+
+ if ( myWidget )
+ {
+ if ( !myListener )
+ myListener = new Listener( this );
+ myWidget->installEventFilter( myListener );
+ }
+
sendItemChanges();
}
/*!
\brief Store preference item to the resource manager.
-
+
This method should be reimplemented in the subclasses.
Base implementation does nothing.
/*!
\brief Retrieve preference item from the resource manager.
-
+
This method should be reimplemented in the subclasses.
Base implementation does nothing.
{
}
+/*!
+ \brief Invoked when preference item widget is shown.
+*/
+void QtxPagePrefItem::widgetShown()
+{
+}
+
+/*!
+ \brief Invoked when preference item widget is hided.
+*/
+void QtxPagePrefItem::widgetHided()
+{
+}
+
+void QtxPagePrefItem::ensureVisible( QtxPreferenceItem* i )
+{
+ QtxPreferenceItem::ensureVisible();
+
+ QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
+ if ( item && item->widget() )
+ item->widget()->setVisible( true );
+}
+
/*!
\brief Find all child items of the QtxPagePrefItem type.
\param list used to return list of child items
QList<QtxPreferenceItem*> lst = childItems( rec );
for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end(); ++it )
{
- if ( (*it)->rtti() == QtxPagePrefItem::RTTI() )
- list.append( (QtxPagePrefItem*)*it );
+ QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( *it );
+ if ( item )
+ list.append( item );
}
}
/*!
\brief Called when contents is changed (item is added, removed or modified).
-
+
Triggers the item update.
*/
void QtxPagePrefItem::contentChanged()
myControl( 0 )
{
QWidget* main = new QWidget();
- QHBoxLayout* base = new QHBoxLayout( main );
- base->setMargin( 0 );
- base->setSpacing( 5 );
- myLabel = new QLabel( title, main );
- base->addWidget( myLabel );
+ // QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parent);
+ // if ( !aGroup )
+ // {
+ QHBoxLayout* base = new QHBoxLayout( main );
+ base->setMargin( 0 );
+ base->setSpacing( 5 );
+
+ myLabel = new QLabel( title, main );
+ base->addWidget( myLabel );
+ // }
+ // else
+ // myLabel = new QLabel( title, aGroup->gridBox() );
setWidget( main );
myControl = wid;
if ( myControl )
- widget()->layout()->addWidget( myControl );
+ {
+ // QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parentItem());
+ // if ( !aGroup )
+ widget()->layout()->addWidget( myControl );
+ // else myControl->setParent( aGroup->gridBox() );
+ }
+}
+
+void QtxPageNamedPrefItem::adjustLabels( QtxPagePrefItem* parent )
+{
+ if ( !parent )
+ return;
+
+ QList<QtxPreferenceItem*> childList = parent->childItems();
+
+ QList<QtxPageNamedPrefItem*> namedItems;
+ for ( QList<QtxPreferenceItem*>::iterator it = childList.begin(); it != childList.end(); ++it )
+ {
+ QtxPageNamedPrefItem* item = dynamic_cast<QtxPageNamedPrefItem*>( *it );
+ if ( item )
+ namedItems.append( item );
+ }
+
+ int sz = 0;
+ for ( QList<QtxPageNamedPrefItem*>::iterator it1 = namedItems.begin(); it1 != namedItems.end(); ++it1 )
+ {
+ QtxPageNamedPrefItem* item = *it1;
+ if ( item->label() )
+ sz = qMax( sz, item->label()->sizeHint().width() );
+ }
+
+ for ( QList<QtxPageNamedPrefItem*>::iterator it2 = namedItems.begin(); it2 != namedItems.end(); ++it2 )
+ {
+ QtxPageNamedPrefItem* item = *it2;
+ if ( item->label() )
+ item->label()->setMinimumWidth( sz );
+ }
}
/*!
*/
void QtxPagePrefListItem::updateContents()
{
+ QtxPagePrefItem::updateContents();
updateVisible();
}
QtxPagePrefItem::setOptionValue( name, val );
}
+void QtxPagePrefListItem::widgetShown()
+{
+ updateState();
+}
+
+void QtxPagePrefListItem::ensureVisible( QtxPreferenceItem* i )
+{
+ if ( !i )
+ return;
+
+ QtxPreferenceItem::ensureVisible( i );
+
+ setSelected( i->id() );
+ updateState();
+}
+
/*!
\brief Called when the selection in the list box is changed.
*/
/*!
\class QtxPagePrefToolBoxItem
+ \brief GUI implementation of the tool box container preference item.
*/
+/*!
+ \brief Constructor.
+ \param title preference item title
+ \param parent parent preference item
+ \param sect resource file section associated with the preference item
+ \param param resource file parameter associated with the preference item
+*/
QtxPagePrefToolBoxItem::QtxPagePrefToolBoxItem( const QString& title, QtxPreferenceItem* parent,
const QString& sect, const QString& param )
: QtxPagePrefItem( title, parent, sect, param )
setWidget( myToolBox = new QToolBox( 0 ) );
}
+/*!
+ \brief Destructor.
+*/
QtxPagePrefToolBoxItem::~QtxPagePrefToolBoxItem()
{
}
+/*!
+ \brief Update widget contents.
+*/
void QtxPagePrefToolBoxItem::updateContents()
{
+ QtxPagePrefItem::updateContents();
updateToolBox();
}
+/*!
+ \brief Update tool box widget.
+*/
void QtxPagePrefToolBoxItem::updateToolBox()
{
QList<QtxPagePrefItem*> items;
myToolBox->setCurrentWidget( cur );
}
+void QtxPagePrefToolBoxItem::ensureVisible( QtxPreferenceItem* i )
+{
+ if ( !i )
+ return;
+
+ QtxPreferenceItem::ensureVisible( i );
+
+ QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
+ if ( item && item->widget() )
+ myToolBox->setCurrentWidget( item->widget() );
+}
+
/*!
\class QtxPagePrefTabsItem
\brief GUI implementation of the tab widget container.
*/
void QtxPagePrefTabsItem::updateContents()
{
+ QtxPagePrefItem::updateContents();
updateTabs();
}
QtxPagePrefItem::setOptionValue( name, val );
}
+void QtxPagePrefTabsItem::ensureVisible( QtxPreferenceItem* i )
+{
+ if ( !i )
+ return;
+
+ QtxPreferenceItem::ensureVisible( i );
+
+ QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
+ if ( item && item->widget() )
+ myTabs->setCurrentWidget( item->widget() );
+}
+
/*!
\brief Update tabs.
*/
*/
void QtxPagePrefFrameItem::updateContents()
{
+ QtxPagePrefItem::updateContents();
+
updateFrame();
+
+ QtxPageNamedPrefItem::adjustLabels( this );
}
/*!
myBox->setOrientation( o );
}
+/*!
+ \brief Check if the frame widget stretching is enabled.
+ \return \c true if the widget is stretchable
+ \sa setStretch()
+*/
bool QtxPagePrefFrameItem::stretch() const
{
QSpacerItem* s = 0;
for ( int i = 0; l && i < l->count() && !s; i++ )
s = l->itemAt( i )->spacerItem();
- return s ? ( s->expandingDirections() & Qt::Vertical ) != 0 : false;
+ return s ? (bool)( s->expandingDirections() & Qt::Vertical ) : false;
}
+/*!
+ \brief Enable/disable frame widget stretching.
+ \param on new stretchable state
+ \sa stretch()
+*/
void QtxPagePrefFrameItem::setStretch( const bool on )
{
QSpacerItem* s = 0;
QtxPagePrefItem::setOptionValue( name, val );
}
+void QtxPagePrefFrameItem::widgetShown()
+{
+ QtxPagePrefItem::widgetShown();
+
+ QtxPageNamedPrefItem::adjustLabels( this );
+}
+
/*!
\brief Update frame widget.
*/
myGroup->setWidget( myBox );
setWidget( myGroup );
+
+ updateState();
}
/*!
myGroup->setWidget( myBox );
setWidget( myGroup );
+
+ updateState();
}
/*!
*/
void QtxPagePrefGroupItem::updateContents()
{
+ QtxPagePrefItem::updateContents();
+
myGroup->setTitle( title() );
updateState();
updateGroup();
+
+ QtxPageNamedPrefItem::adjustLabels( this );
}
/*!
setBoolean( myGroup->isChecked() );
}
+/*!
+ \brief Return widget contained grid layout of this group.
+*/
+QtxGridBox* QtxPagePrefGroupItem::gridBox() const
+{
+ return myBox;
+}
+
/*!
\brief Retrieve preference item from the resource manager.
\sa store()
QtxPagePrefItem::setOptionValue( name, val );
}
+void QtxPagePrefGroupItem::widgetShown()
+{
+ QtxPagePrefItem::widgetShown();
+
+ QtxPageNamedPrefItem::adjustLabels( this );
+}
+
/*!
\brief Update widget state.
*/
/*!
\brief Constructor.
- Creates spacer item with zero width and height and expanding
+ Creates spacer item with zero width and height and expanding
on both directions (by height and width).
\param parent parent preference item
/*!
\brief Constructor.
- Creates spacer item with zero width and height and expanding
+ Creates spacer item with zero width and height and expanding
according to the specified orientation.
\param o spacer orientation
sp.setVerticalStretch( sf );
sp.setVerticalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
}
-
+
widget()->setSizePolicy( sp );
}
QSizePolicy sp;
sp.setHorizontalPolicy( hs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
sp.setVerticalPolicy( vs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
-
+
sp.setHorizontalStretch( hs );
sp.setVerticalStretch( vs );
wid->setSizePolicy( sp );
wid->setMinimumSize( w, h );
-
+
setWidget( wid );
}
myCheck->setText( title() );
}
-
+
/*!
\brief Store preference item to the resource manager.
\sa retrieve()
\param param resource file parameter associated with the preference item
*/
QtxPagePrefEditItem::QtxPagePrefEditItem( const int type, const QString& title,
- QtxPreferenceItem* parent, const QString& sect,
+ QtxPreferenceItem* parent, const QString& sect,
const QString& param )
: QtxPageNamedPrefItem( title, parent, sect, param ),
myType( type )
/*!
\class QtxPagePrefSelectItem
- \brief GUI implementation of the resources selector item
+ \brief GUI implementation of the resources selector item
(string, integer or double values list).
All items in the list (represented as combo box) should be specified
/*!
\brief Constructor.
-
+
Creates preference item with combo box widget which is not editable
(direct value entering is disabled).
/*!
\brief Constructor.
-
+
Creates preference item with combo box widget which is editable
according to the specified input type (integer, double or string values).
QStringList QtxPagePrefSelectItem::strings() const
{
QStringList res;
- for ( int i = 0; i < mySelector->count(); i++ )
+ for ( uint i = 0; i < mySelector->count(); i++ )
res.append( mySelector->itemText( i ) );
return res;
}
QList<int> QtxPagePrefSelectItem::numbers() const
{
QList<int> res;
- for ( int i = 0; i < mySelector->count(); i++ )
+ for ( uint i = 0; i < mySelector->count(); i++ )
{
if ( mySelector->hasId( i ) )
res.append( mySelector->id( i ) );
*/
void QtxPagePrefSelectItem::setNumbers( const QList<int>& ids )
{
- int i = 0;
+ uint i = 0;
for ( QList<int>::const_iterator it = ids.begin(); it != ids.end() && i < mySelector->count(); ++it, i++ )
mySelector->setId( i, *it );
}
idx = mySelector->index( num );
else
{
- for ( int i = 0; i < mySelector->count() && idx == -1; i++ )
+ for ( uint i = 0; i < mySelector->count() && idx == -1; i++ )
{
if ( mySelector->itemText( i ) == txt )
idx = i;
\param param resource file parameter associated with the preference item
*/
QtxPagePrefSpinItem::QtxPagePrefSpinItem( const int type, const QString& title,
- QtxPreferenceItem* parent, const QString& sect,
+ QtxPreferenceItem* parent, const QString& sect,
const QString& param )
: QtxPageNamedPrefItem( title, parent, sect, param ),
myType( type )
}
/*!
- \brief Get spin box preference item special value text (which is shown
+ \brief Get spin box preference item special value text (which is shown
when the spin box reaches minimum value).
\return spin box special value text
\sa setSpecialValueText()
}
/*!
- \brief Set spin box preference item special value text (which is shown
+ \brief Set spin box preference item special value text (which is shown
when the spin box reaches minimum value).
\param txt new spin box special value text
\sa specialValueText()
\param sect resource file section associated with the preference item
\param param resource file parameter associated with the preference item
*/
-QtxPagePrefTextItem::QtxPagePrefTextItem( QtxPreferenceItem* parent, const QString& sect,
+QtxPagePrefTextItem::QtxPagePrefTextItem( QtxPreferenceItem* parent, const QString& sect,
const QString& param )
: QtxPageNamedPrefItem( QString(), parent, sect, param )
{
const QString& sect, const QString& param )
: QtxPageNamedPrefItem( title, parent, sect, param )
{
- setControl( myColor = new QtxColorButton() );
+ // QtxPagePrefGroupItem* aGroup 0; //= dynamic_cast<QtxPagePrefGroupItem*>( parent );
+
+ // setControl( myColor = new QtxColorButton( aGroup ? aGroup->gridBox() : 0 ) );
+ setControl( myColor = new QtxColorButton( 0 ) );
myColor->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
}
\param param resource file parameter associated with the preference item
*/
QtxPagePrefFontItem::QtxPagePrefFontItem( const int feat, const QString& title,
- QtxPreferenceItem* parent, const QString& sect,
+ QtxPreferenceItem* parent, const QString& sect,
const QString& param )
: QtxPageNamedPrefItem( title, parent, sect, param )
{
}
/*!
- \class QtxPagePrefPathListItem
- \brief GUI implementation of resources directory list item.
+ \class QtxPagePrefPathListItem
+ \brief GUI implementation of the resources files/directories list item.
*/
/*!
\brief GUI implementation of resources date/time item.
*/
+/*!
+ \brief Constructor.
+
+ Creates an item to enter date and time.
+
+ \param title preference item title
+ \param parent parent preference item
+ \param sect resource file section associated with the preference item
+ \param param resource file parameter associated with the preference item
+*/
QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const QString& title, QtxPreferenceItem* parent,
const QString& sect, const QString& param )
: QtxPageNamedPrefItem( title, parent, sect, param ),
-myType( DateTime )
+ myType( DateTime )
{
setControl( myDateTime = new QDateTimeEdit() );
myDateTime->setCalendarPopup( true );
updateDateTime();
}
+/*!
+ \brief Constructor.
+
+ Creates preference item for editing of the date and/or time value:
+ the type is specified by parameter \a type.
+
+ \param type preference item input type (QtxPagePrefDateTimeItem::InputType)
+ \param title preference item title
+ \param parent parent preference item
+ \param sect resource file section associated with the preference item
+ \param param resource file parameter associated with the preference item
+*/
QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const int type, const QString& title, QtxPreferenceItem* parent,
const QString& sect, const QString& param )
: QtxPageNamedPrefItem( title, parent, sect, param ),
-myType( type )
+ myType( type )
{
setControl( myDateTime = new QDateTimeEdit() );
myDateTime->setCalendarPopup( true );
updateDateTime();
}
+/*!
+ \brief Destructor.
+*/
QtxPagePrefDateTimeItem::~QtxPagePrefDateTimeItem()
{
}
+/*!
+ \brief Get date/time box preference item input type.
+ \return preference item input type (QtxPagePrefDateTimeItem::InputType)
+ \sa setInputType()
+*/
int QtxPagePrefDateTimeItem::inputType() const
{
return myType;
}
+/*!
+ \brief Set date/time box preference item input type.
+ \param type new preference item input type (QtxPagePrefDateTimeItem::InputType)
+ \sa inputType()
+*/
void QtxPagePrefDateTimeItem::setInputType( const int type )
{
if ( myType == type )
updateDateTime();
}
+/*!
+ \brief Check if the popup calendar menu is enabled.
+ \return \c true if calendar popup menu is enabled
+*/
bool QtxPagePrefDateTimeItem::calendar() const
{
return myDateTime->calendarPopup();
}
+/*!
+ \brief Enable/disable popup calendar menu.
+ \param on new flag state
+*/
void QtxPagePrefDateTimeItem::setCalendar( const bool on )
{
myDateTime->setCalendarPopup( on );
}
+/*!
+ \brief Get maximum date value.
+ \return maximum date value
+ \sa setMaximumDate(), minimumDate(), maximumTime(), minimumTime()
+*/
QDate QtxPagePrefDateTimeItem::maximumDate() const
{
return myDateTime->maximumDate();
}
+/*!
+ \brief Get maximum time value.
+ \return maximum time value
+ \sa setMaximumTime(), minimumTime(), maximumDate(), minimumDate()
+*/
QTime QtxPagePrefDateTimeItem::maximumTime() const
{
return myDateTime->maximumTime();
}
+/*!
+ \brief Get minimum date value.
+ \return minimum date value
+ \sa setMinimumDate(), maximumDate(), maximumTime(), minimumTime()
+*/
QDate QtxPagePrefDateTimeItem::minimumDate() const
{
return myDateTime->minimumDate();
}
+/*!
+ \brief Get minimum time value.
+ \return maximum time value
+ \sa setMinimumTime(), maximumTime(), maximumDate(), minimumDate()
+*/
QTime QtxPagePrefDateTimeItem::minimumTime() const
{
return myDateTime->minimumTime();
}
+/*!
+ \brief Set maximum date value.
+ \param d new maximum date value
+ \sa maximumDate(), minimumDate(), maximumTime(), minimumTime()
+*/
void QtxPagePrefDateTimeItem::setMaximumDate( const QDate& d )
{
if ( d.isValid() )
myDateTime->clearMaximumDate();
}
+/*!
+ \brief Set maximum time value.
+ \param t new maximum time value
+ \sa maximumTime(), minimumTime(), maximumDate(), minimumDate()
+*/
void QtxPagePrefDateTimeItem::setMaximumTime( const QTime& t )
{
if ( t.isValid() )
myDateTime->clearMaximumTime();
}
+/*!
+ \brief Set minimum date value.
+ \param d new minimum date value
+ \sa minimumDate(), maximumDate(), maximumTime(), minimumTime()
+*/
void QtxPagePrefDateTimeItem::setMinimumDate( const QDate& d )
{
if ( d.isValid() )
myDateTime->clearMinimumDate();
}
+/*!
+ \brief Set minimum time value.
+ \param t new minimum time value
+ \sa minimumTime(), maximumTime(), maximumDate(), minimumDate()
+*/
void QtxPagePrefDateTimeItem::setMinimumTime( const QTime& t )
{
if ( t.isValid() )
myDateTime->clearMinimumTime();
}
+/*!
+ \brief Store preference item to the resource manager.
+ \sa retrieve()
+*/
void QtxPagePrefDateTimeItem::store()
{
QString str;
setString( str );
}
+/*!
+ \brief Retrieve preference item from the resource manager.
+ \sa store()
+*/
void QtxPagePrefDateTimeItem::retrieve()
{
QString str = getString();
}
}
+/*!
+ \brief Get preference item option value.
+ \param name option name
+ \return property value or null QVariant if option is not set
+ \sa setOptionValue()
+*/
QVariant QtxPagePrefDateTimeItem::optionValue( const QString& name ) const
{
if ( name == "input_type" || name == "type" )
return QtxPageNamedPrefItem::optionValue( name );
}
+/*!
+ \brief Set preference item option value.
+ \param name option name
+ \param val new property value
+ \sa optionValue()
+*/
void QtxPagePrefDateTimeItem::setOptionValue( const QString& name, const QVariant& val )
{
if ( name == "input_type" || name == "type" )
QtxPageNamedPrefItem::setOptionValue( name, val );
}
+/*!
+ \brief Update date/time widget.
+*/
void QtxPagePrefDateTimeItem::updateDateTime()
{
QString dispFmt;
// 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
+// 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
+//
+// 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
+// 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
private:
void initialize() const;
+ void initialize( QtxPreferenceItem* );
private:
QtxGridBox* myBox;
class QTX_EXPORT QtxPagePrefItem : public QtxPreferenceItem
{
+ class Listener;
+
public:
QtxPagePrefItem( const QString&, QtxPreferenceItem* = 0,
const QString& = QString(), const QString& = QString() );
virtual ~QtxPagePrefItem();
- virtual int rtti() const;
-
QWidget* widget() const;
- static int RTTI();
-
protected:
void setWidget( QWidget* );
virtual void store();
virtual void retrieve();
+ virtual void widgetShown();
+ virtual void widgetHided();
+
+ virtual void ensureVisible( QtxPreferenceItem* );
+
private:
virtual void contentChanged();
private:
QPointer<QWidget> myWidget;
+ Listener* myListener;
};
class QTX_EXPORT QtxPageNamedPrefItem : public QtxPagePrefItem
virtual void setTitle( const QString& );
+ static void adjustLabels( QtxPagePrefItem* );
+
protected:
QLabel* label() const;
QWidget* control() const;
protected:
virtual QVariant optionValue( const QString& ) const;
virtual void setOptionValue( const QString&, const QVariant& );
+ virtual void ensureVisible( QtxPreferenceItem* );
+
+ virtual void widgetShown();
private:
void updateInfo();
virtual void updateContents();
+protected:
+ virtual void ensureVisible( QtxPreferenceItem* );
+
private:
void updateToolBox();
protected:
virtual QVariant optionValue( const QString& ) const;
virtual void setOptionValue( const QString&, const QVariant& );
+ virtual void ensureVisible( QtxPreferenceItem* );
private:
void updateTabs();
virtual QVariant optionValue( const QString& ) const;
virtual void setOptionValue( const QString&, const QVariant& );
+ virtual void widgetShown();
+
private:
void updateFrame();
virtual void store();
virtual void retrieve();
+ QtxGridBox* gridBox() const;
+
protected:
virtual QVariant optionValue( const QString& ) const;
virtual void setOptionValue( const QString&, const QVariant& );
+ virtual void widgetShown();
+
private:
void updateState();
void updateGroup();
protected:
virtual QVariant optionValue( const QString& ) const;
virtual void setOptionValue( const QString&, const QVariant& );
-
+
private:
QtxPathEdit* myPath;
};
// 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
+// 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
+//
+// 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
+// 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
\class QtxPreferenceItem
\brief Base class for implementing of all the preference items.
- To implement any specific preference item, cubclass from the
+ To implement any specific preference item, cubclass from the
QtxPreferenceItem and redefine store() and retrieve() methods.
*/
return item;
}
+void QtxPreferenceItem::ensureVisible()
+{
+ if ( parentItem() )
+ parentItem()->ensureVisible( this );
+}
/*!
\brief Get integer resources value corresponding to the item.
/*!
\brief Callback function which is called when the child
preference item is added.
-
+
This function can be reimplemented in the subclasses to customize
child item addition operation. Base implementation does nothing.
/*!
\brief Callback function which is called when the child
preference item is removed.
-
+
This function can be reimplemented in the subclasses to customize
child item removal operation. Base implementation does nothing.
/*!
\brief Callback function which is called when the child
preference item is modified.
-
+
This function can be reimplemented in the subclasses to customize
child item modifying operation. Base implementation does nothing.
\param item child item being modified
\sa itemAdded(), itemRemoved()
*/
-void QtxPreferenceItem::itemChanged( QtxPreferenceItem* /*item*/ )
+void QtxPreferenceItem::itemChanged( QtxPreferenceItem* )
+{
+}
+
+void QtxPreferenceItem::ensureVisible( QtxPreferenceItem* )
{
+ ensureVisible();
}
/*!
This function can be reimplemented in the subclasses.
Base implementation does nothing.
-
+
\param name option name
\return property value or null QVariant if option is not set
\sa setOptionValue()
This function can be reimplemented in the subclasses.
Base implementation does nothing.
-
+
\param name option name
\param val new property value
\sa optionValue()
return (QtxPreferenceMgr*)this;
}
-/*
- \brief Add new preference item.
- \param label label of widget to edit preference item
- \param pId parent preference item id
- \param type preference item type
- \param section resource file section associated to the preference item
- \param param resource file parameter associated to the preference item
-*/
-/*
-int QtxPreferenceMgr::addItem( const QString& label, const int pId, const int type,
- const QString& section, const QString& param )
-{
- Item* i = createItem( label, type, pId );
- if ( !i )
- return -1;
-
- if ( !myItems.contains( i->id() ) )
- {
- myItems.insert( i->id(), i );
-
- i->setTitle( label );
- i->setResource( section, param );
-
- if ( !i->parentItem() && !myChildren.contains( i ) )
- myChildren.append( i );
-
- itemAdded( i );
- }
-
- return i->id();
-}
-*/
-
/*!
\brief Get preference item option value.
\param id preference item ID
/*!
\brief Update preferences manager.
-
+
Base implementation does nothing.
*/
void QtxPreferenceMgr::update()
{
}
-/*
- \brief Create preference item.
- \param label preference item title
- \param type preference item type
- \param pId parent preference item ID
- \return new item
-*/
-/*
-QtxPreferenceItem* QtxPreferenceMgr::createItem( const QString& label, const int type, const int pId )
-{
- Item* i = 0;
- if ( pId < 0 )
- i = createItem( label, type );
- else
- {
- Item* pItem = item( pId );
- if ( pItem )
- {
- i = pItem->createItem( label, type );
- pItem->insertChild( i );
- }
- }
-
- return i;
-}
-*/
-
/*!
\brief Get all resources items values.
\param map used as container filled with the resources values (<ID>:<value>)
This method is called from store() and fromBackup() methods.
Base implementation does nothing.
-
+
\sa store(), fromBackup()
*/
void QtxPreferenceMgr::changedResources( const ResourceMap& )
// 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
+// 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
+//
+// 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
+// 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
virtual QtxResourceMgr* resourceMgr() const;
virtual QtxPreferenceMgr* preferenceMgr() const;
+ void ensureVisible();
+
static int RTTI();
protected:
bool getBoolean( const bool = false ) const;
QColor getColor( const QColor& = QColor() ) const;
QFont getFont( const QFont& = QFont() ) const;
- QString getString( const QString& = QString::null ) const;
+ QString getString( const QString& = QString() ) const;
void setInteger( const int );
void setDouble( const double );
void setBoolean( const bool );
void setColor( const QColor& );
- void setFont( const QFont& );
+ void setFont( const QFont& );
void setString( const QString& );
virtual void itemAdded( QtxPreferenceItem* );
virtual void itemRemoved( QtxPreferenceItem* );
virtual void itemChanged( QtxPreferenceItem* );
+ virtual void ensureVisible( QtxPreferenceItem* );
+
void sendItemChanges();
virtual void triggerUpdate();
void setResourceValues( QMap<int, QString>& ) const;
void setResourceValues( ResourceMap& ) const;
-
+
void differentValues( const QMap<int, QString>&, const QMap<int, QString>&,
QMap<int, QString>&, const bool fromFirst = false ) const;
void differentValues( const ResourceMap&, const ResourceMap&,
-TEMPLATE = lib
+unix:TEMPLATE = lib
+win32:TEMPLATE = vclib
+
+win32:QMAKE_MOC=$(QTDIR)\bin\moc.exe
DESTDIR = ../../$(CONFIG_ID)/lib
MOC_DIR = ../../moc
INCLUDEPATH = ../../include
LIBS += -L../../$(CONFIG_ID)/lib -lSUIT -lQtx
+win32:LIBS *= -L$(QTLIB)
+win32:INCLUDEPATH *= $(QTINC) $(QTINC)\QtCore $(QTINC)\QtGui $(QTINC)\QtXml
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared
-win32:DEFINES += WIN32
+win32:DEFINES += WNT WIN32
DEFINES += STD_EXPORTS
HEADERS = *.h
lrelease.name = LRELASE ${QMAKE_FILE_IN}
unix:lrelease.commands = $(QTDIR)/bin/lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}/${QMAKE_FILE_BASE}.qm
-win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
+win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_IN} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
unix:lrelease.output = $${GUIResources}/${QMAKE_FILE_BASE}.qm
win32:lrelease.output = $${GUIResources}\\${QMAKE_FILE_BASE}.qm
lrelease.input = TRANSLATIONS
lrelease.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += lrelease
+win32:copy_hdr.name = Install ${QMAKE_FILE_IN}
+win32:copy_hdr.commands = type ${QMAKE_FILE_IN} > ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.output = ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.input = HEADERS
+win32:QMAKE_EXTRA_COMPILERS += copy_hdr
+
ICONS = resources/*.png
+win32:SOURCES+=$$ICONS
+win32:Resource=$$ICONS
+win32:copy_res.name = Install resources ${QMAKE_FILE_IN}
+win32:copy_res.commands = type ${QMAKE_FILE_IN} > ${QMAKE_FILE_OUT}
+win32:copy_res.output = $${GUIResources}\\${QMAKE_FILE_BASE}.png
+win32:copy_res.input = Resource
+win32:QMAKE_EXTRA_COMPILERS += copy_res
+
includes.files = $$HEADERS
includes.path = ../../include
-TEMPLATE = lib
+unix:TEMPLATE = lib
+win32:TEMPLATE = vclib
+
+win32:QMAKE_MOC=$(QTDIR)\bin\moc.exe
DESTDIR = ../../$(CONFIG_ID)/lib
MOC_DIR = ../../moc
INCLUDEPATH = ../../include
LIBS += -L../../$(CONFIG_ID)/lib -lQtx -lObjBrowser
+win32:LIBS *= -L$(QTLIB)
+win32:INCLUDEPATH *= $(QTINC) $(QTINC)\QtCore $(QTINC)\QtGui $(QTINC)\QtXml
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared
-win32:DEFINES += WIN32
+win32:DEFINES += WNT WIN32
DEFINES += SUIT_EXPORTS
HEADERS = *.h
lrelease.name = LRELASE ${QMAKE_FILE_IN}
unix:lrelease.commands = $(QTDIR)/bin/lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}/${QMAKE_FILE_BASE}.qm
-win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
+win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_IN} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
unix:lrelease.output = $${GUIResources}/${QMAKE_FILE_BASE}.qm
win32:lrelease.output = $${GUIResources}\\${QMAKE_FILE_BASE}.qm
lrelease.input = TRANSLATIONS
lrelease.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += lrelease
+win32:copy_hdr.name = Install ${QMAKE_FILE_IN}
+win32:copy_hdr.commands = type ${QMAKE_FILE_IN} > ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.output = ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.input = HEADERS
+win32:QMAKE_EXTRA_COMPILERS += copy_hdr
+
ICONS = resources/*.png
+win32:SOURCES+=$$ICONS
+win32:Resource=$$ICONS
+win32:copy_res.name = Install resources ${QMAKE_FILE_IN}
+win32:copy_res.commands = type ${QMAKE_FILE_IN} > ${QMAKE_FILE_OUT}
+win32:copy_res.output = $${GUIResources}\\${QMAKE_FILE_BASE}.png
+win32:copy_res.input = Resource
+win32:QMAKE_EXTRA_COMPILERS += copy_res
+
includes.files = $$HEADERS
includes.path = ../../include
automatically when data tree is changed.
\param on 'auto-update tree' flag value
+ \param updateImmediately if \c true, the tree is updated immediately;
+ otherwise the tree must be updated manually
\sa autoUpdate(), updateTree()
*/
-void SUIT_DataBrowser::setAutoUpdate( const bool on )
+void SUIT_DataBrowser::setAutoUpdate( const bool on, const bool updateImmediately )
{
SUIT_ProxyModel* m = qobject_cast<SUIT_ProxyModel*>( model() );
if ( m )
- m->setAutoUpdate( on );
+ m->setAutoUpdate( on, updateImmediately );
}
/*!
void setRoot( SUIT_DataObject* );
bool autoUpdate() const;
- void setAutoUpdate( const bool );
+ void setAutoUpdate( const bool, const bool = true );
void updateTree( SUIT_DataObject* = 0, const bool = true );
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+// File : SUIT_FileDlg.cxx
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//
/*!
- SUIT_FileDlg class is the extension of the Qt's Open/Save file dialog box.
- To get the file/directory name(s) call static methods:
-
- to invoke "Open file" or "Save file" dialog box
- static QString getFileName(QWidget* parent, const QString& initial, const QStringList& filters,
- const QString& caption, const bool open, const bool showQuickDir = true,
- SUIT_FileValidator* validator = 0);
-
- to invoke "Open files" dialog box (to get the multiple file selection)
- static QStringList getOpenFileNames(QWidget* parent, const QString& initial, const QStringList& filters,
- const QString& caption, bool showQuickDir = true,
- SUIT_FileValidator* validator = 0);
-
- to invoke "Select directory" dialog box
- static QString getExistingDirectory(QWidget* parent, const QString& initial,
- const QString& caption, const bool showQuickDir = true);
-
- The parameters:
- - parent parent widget (if 0, the current desktop is used)
- - initial starting directory or file name (if null, last visited directory is used)
- - filters file filters list; patterns inside the filter can be separated by ';','|' or ' '
- symbols
- - caption dialog box's caption: if null, the default one is used
- - open open flag - true for "Open File" and false for "Save File" dialog box
- - showQuickDir this flag enables/disables "Quick directory list" controls
- - validator you can provide custom file validator with this parameter
-
- Examples:
- ...
- QStringList flist;
- flist.append( "Image files (*.bmp *.gif *.jpg )" );
- flist.append( "All files (*.*)" );
- QMyFileValidator* v = new QMyFileValidator( 0 );
- QString fileName = SUIT_FileDlg::getFileName( 0, QString::null, flist, "Dump view", false, true, v );
- if ( !fileName.isEmpty() ) {
- ... writing image to the file
- }
- ...
- QStringList flist;
- flist.append( "*.cpp | *.cxx | *.c++" );
- flist.append( "*.h | *.hpp | *.hxx" );
- QString fileName = SUIT_FileDlg::getFileName( desktop(), QString::null, flist, QString::null, true, true );
+ \class SUIT_FileDlg
+ \brief An extension of the Qt Open/Save file dialog box.
+
+ The class SUIT_FileDlg provides a set of static methods which canbe used
+ for file or directories selection:
+ - getFileName() for single file opening or saving
+ - getOpenFileNames() for mulktiple files opening
+ - getExistingDirectory() for existing directory selection
+
+ Examples:
+ \code
+ // select file to dump contents of the view
+ QStringList filters;
+ filters << "Image files (*.bmp *.gif *.jpg )" << "All files (*)";
+ QString fileName = SUIT_FileDlg::getFileName( desktop(),
+ QString(),
+ filters,
+ "Dump view",
+ false );
+ if ( !fileName.isEmpty() ) {
+ ... writing image to the file
+ }
+
+ // select list of files to open in the editor windows
+ QStringList filters;
+ filters << "*.cpp | *.cxx | *.c++" << "*.h | *.hpp | *.hxx";
+ QStringList fileNames = SUIT_FileDlg::getOpenFileName( desktop(),
+ QString(),
+ filters,
+ QString() );
+ if ( !fileNames.isEmpty() ) {
+ ... open files
+ }
+ \endcode
+
+ The class SUIT_FileDlg can be subclassed to implement custom file
+ dialog boxes. The class provides a set of methods which can be used
+ in subclasses:
+ - setCheckPermissions() - to enable/disable check of files/directories
+ permissions
+ - setValidator() - to use custom file validator
+ - addWidgets() - to add custom widgets to the lower part of the
+ dialog box
+ - getLastVisitedDirectory() - to get last visited directory
+ - acceptData() - can be used ti customize user selection validation
+
+ \sa SUIT_FileValidator class.
*/
#include "SUIT_FileDlg.h"
#include <QPushButton>
#include <QGridLayout>
#include <QApplication>
+#include <QListView>
+#include <QLineEdit>
-#define MIN_COMBO_SIZE 100
+/*!
+ \brief Defines extension behavior.
-/*! If the selected file name has extension which does not match the selected filter
- * this extension is ignored (and new one will be added). See below for details.
- */
+ If the selected file name has extension which does not match the selected filter
+ and this variable is set to \c true, the file extension is ignored and new one
+ (from current file filter will be added.
+ \sa addExtension()
+*/
const bool IGNORE_NON_MATCHING_EXTENSION = true;
QString SUIT_FileDlg::myLastVisitedPath;
-/*! Constructor */
+/*!
+ \brief Constructor.
+ \param parent parent widget
+ \param open if \c true dialog box is used for file opening, otherwise - for saving
+ \param showQuickDir if \c true the quick directory list widgets will be shown
+ \param modal if \c true the dialog box will be modal
+*/
SUIT_FileDlg::SUIT_FileDlg( QWidget* parent, bool open, bool showQuickDir, bool modal )
: QFileDialog( parent ),
-myOpen( open ),
-myValidator( 0 ),
-myQuickLab( 0 ),
-myQuickCombo( 0 ),
-myQuickButton( 0 )//,
-//myAccepted( false )
+ myValidator( 0 ),
+ myQuickLab( 0 ),
+ myQuickCombo( 0 ),
+ myQuickButton( 0 ),
+ myCheckPermissions( true )
{
setModal( modal );
-
- const QObjectList& child = children();
- for ( QObjectList::const_iterator anIt = child.begin(); anIt != child.end(); ++anIt )
- {
- QPushButton* pb = ::qobject_cast<QPushButton*>( *anIt );
- if ( pb )
- {
- pb->setDefault( false );
- pb->setAutoDefault( false );
- }
- }
-
+ setSizeGripEnabled( true );
if ( parent )
setWindowIcon( parent->windowIcon() );
- setSizeGripEnabled( true );
-
- QGridLayout* grid = ::qobject_cast<QGridLayout*>( layout() );
- if ( showQuickDir && grid )
- {
- // inserting quick dir combo box
- myQuickLab = new QLabel( tr( "LAB_QUICK_PATH" ), this );
- myQuickCombo = new QComboBox( this );
- myQuickCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myQuickCombo->setMinimumSize( MIN_COMBO_SIZE, 0 );
-
- myQuickButton = new QPushButton( tr( "BUT_ADD_PATH" ), this );
- connect( myQuickCombo, SIGNAL( activated( const QString& ) ), this, SLOT( quickDir( const QString& ) ) );
- connect( myQuickButton, SIGNAL( clicked() ), this, SLOT( addQuickDir() ) );
+ // add quick directories widgets
+ if ( showQuickDir ) {
+ myQuickLab = new QLabel( tr( "LAB_QUICK_PATH" ), this );
+ myQuickCombo = new QComboBox( this );
+ myQuickButton = new QPushButton( tr( "BUT_ADD_PATH" ), this );
+
+ if ( addWidgets( myQuickLab, myQuickCombo, myQuickButton ) ) {
+ connect( myQuickCombo, SIGNAL( activated( const QString& ) ), this, SLOT( quickDir( const QString& ) ) );
+ connect( myQuickButton, SIGNAL( clicked() ), this, SLOT( addQuickDir() ) );
- int row = grid->rowCount();
- grid->addWidget( myQuickLab, row, 0 );
- grid->addWidget( myQuickCombo, row, 1, 1, 3 );
- grid->addWidget( myQuickButton, row, 5 );
+ // retrieve directories list from the resources
+ QStringList dirList;
+
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ if ( resMgr )
+ dirList = resMgr->stringValue( "FileDlg", QString( "QuickDirList" ) ).split( ';', QString::SkipEmptyParts );
- // getting dir list from settings
- QString dirs;
- SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
- if ( resMgr )
- dirs = resMgr->stringValue( "FileDlg", QString( "QuickDirList" ) );
+ if ( dirList.isEmpty() )
+ dirList << QDir::homePath();
- QStringList dirList = dirs.split( ';' );
- if ( dirList.count() > 0 )
- {
for ( int i = 0; i < dirList.count(); i++ )
- myQuickCombo->addItem( dirList[i] );
+ myQuickCombo->addItem( dirList[i] );
+ }
+ else {
+ delete myQuickLab; myQuickLab = 0;
+ delete myQuickCombo; myQuickCombo = 0;
+ delete myQuickButton; myQuickButton = 0;
}
- else
- myQuickCombo->addItem( QDir::homePath() );
}
- setAcceptMode( myOpen ? AcceptOpen: AcceptSave );
- setWindowTitle( myOpen ? tr( "INF_DESK_DOC_OPEN" ) : tr( "INF_DESK_DOC_SAVE" ) );
+
+ setAcceptMode( open ? AcceptOpen: AcceptSave );
+ setWindowTitle( open ? tr( "INF_DESK_DOC_OPEN" ) : tr( "INF_DESK_DOC_SAVE" ) );
// If last visited path doesn't exist -> switch to the first preferred path
- if ( !myLastVisitedPath.isEmpty() )
- {
+ if ( !myLastVisitedPath.isEmpty() ) {
if ( !processPath( myLastVisitedPath ) && showQuickDir )
processPath( myQuickCombo->itemText( 0 ) );
}
- else
- {
- if ( showQuickDir )
- processPath( myQuickCombo->itemText( 0 ) );
+ else if ( showQuickDir ) {
+ processPath( myQuickCombo->itemText( 0 ) );
}
// set default file validator
- myValidator = new SUIT_FileValidator(this);
+ myValidator = new SUIT_FileValidator( this );
}
-/*! Destructor*/
+/*!
+ \brief Destructor.
+*/
SUIT_FileDlg::~SUIT_FileDlg()
{
setValidator( 0 );
}
-bool SUIT_FileDlg::event( QEvent* e )
-{
- bool res = QFileDialog::event( e );
- if ( e->type() == QEvent::Polish )
- polish();
+/*!
+ \brief Check if the dialog box is used for opening or saving the file.
+ \return \c true if dialog is used for file opening and \c false otherwise
+*/
+bool SUIT_FileDlg::isOpenDlg() const
+{
+ return acceptMode() == AcceptOpen;
+}
- return res;
+/*!
+ \brief Get 'check file permissions' flag.
+ \return flag value
+ \sa setCheckPermissions()
+*/
+bool SUIT_FileDlg::checkPermissions() const
+{
+ return myCheckPermissions;
}
-/*! Redefined from QFileDialog.*/
-void SUIT_FileDlg::polish()
+/*!
+ \brief Set 'check file permissions' flag.
+
+ If this flag is set and file validator is not null,
+ the validator will check the file permissions also.
+
+ \param checkPerm new flag value
+ \sa checkPermissions()
+*/
+void SUIT_FileDlg::setCheckPermissions( const bool checkPerm )
{
-/*
- if ( myQuickButton && myQuickLab )
- {
- // the following is a workaround for proper layouting of custom widgets
- QValueList<QPushButton*> buttonList;
- QValueList<QLabel*> labelList;
- const QObjectList *list = children();
- QObjectListIt it(*list);
- int maxButWidth = myQuickLab->sizeHint().width();
- int maxLabWidth = myQuickButton->sizeHint().width();
-
- for (; it.current() ; ++it) {
- if ( it.current()->isA( "QLabel" ) ) {
- int tempW = ((QLabel*)it.current())->minimumWidth();
- if ( maxLabWidth < tempW ) maxLabWidth = tempW;
- labelList.append( (QLabel*)it.current() );
- }
- else if( it.current()->isA("QPushButton") ) {
- int tempW = ((QPushButton*)it.current())->minimumWidth();
- if ( maxButWidth < tempW ) maxButWidth = tempW;
- buttonList.append( (QPushButton*)it.current() );
- }
- }
- if (maxButWidth > 0) {
- QValueList<QPushButton*>::Iterator bListIt;
- for ( bListIt = buttonList.begin(); bListIt != buttonList.end(); ++bListIt )
- (*bListIt)->setFixedWidth( maxButWidth );
- }
- if (maxLabWidth > 0) {
- QValueList<QLabel*>::Iterator lListIt;
- for ( lListIt = labelList.begin(); lListIt != labelList.end(); ++lListIt )
- (*lListIt)->setFixedWidth( maxLabWidth );
- }
- }
+ myCheckPermissions = checkPerm;
+}
+
+/*!
+ \brief Get file validator.
+ \return current file validator
+ \sa setValidator()
*/
+SUIT_FileValidator* SUIT_FileDlg::validator() const
+{
+ return myValidator;
}
-/*! Sets validator for file names to open/save
- * Deletes previous validator if the dialog owns it.
- */
+/*!
+ \brief Set file validator.
+
+ Destroys previous validator if the dialog owns it.
+
+ \param v new file validator
+ \sa validator()
+*/
void SUIT_FileDlg::setValidator( SUIT_FileValidator* v )
{
if ( myValidator && myValidator->parent() == this )
myValidator = v;
}
-/*! Returns the selected file */
+/*!
+ \brief Adds the specified widgets to the bottom of the file dialog.
+
+ The first widget (usually label) \a l is placed underneath the "file name"
+ and the "file types" labels.
+ The widget \a w is placed underneath the file types combobox.
+ The last widget (usually button) \a b is placed underneath the Cancel push button.
+
+ In general, the widgets can be arbitrary. This method is added to support
+ the functionality provided by the Qt series 3.x.
+
+ If you don't want to have one of the widgets added, pass 0 in that widget's position.
+ Every time this function is called, a new row of widgets is added to the bottom of the
+ file dialog.
+
+ \param l first widget (e.g. text label)
+ \param w second widget (e.g. combo box)
+ \param b third widget (e.g. push button)
+ \return \c true if widgets have been added successfully
+*/
+bool SUIT_FileDlg::addWidgets( QWidget* l, QWidget* w, QWidget* b )
+{
+ QGridLayout* grid = ::qobject_cast<QGridLayout*>( layout() );
+ if ( grid ) {
+ int row = grid->rowCount();
+ int columns = grid->columnCount();
+ if ( l )
+ grid->addWidget( l, row, 0 );
+ if ( w )
+#if QT_VERSION < 0x040303
+ grid->addWidget( w, row, 1, 1, columns-3 );
+#else
+ grid->addWidget( w, row, 1, 1, columns-2 );
+#endif
+ if ( b )
+ grid->addWidget( b, row, columns-1 );
+ return true;
+ }
+ return false;
+}
+
+/*!
+ \brief Get list of selected files.
+ \return selected file names
+*/
+QStringList SUIT_FileDlg::selectedFiles() const
+{
+ QStringList files = QFileDialog::selectedFiles();
+ if ( fileMode() != DirectoryOnly && fileMode() != Directory ) {
+ QMutableListIterator<QString> it( files );
+ while ( it.hasNext() ) {
+ QString f = it.next();
+ QFileInfo finfo( f );
+ if ( !finfo.isDir() )
+ it.setValue( addExtension( f ) );
+ }
+ }
+ return files;
+}
+
+/*!
+ \brief Get selected file.
+ \return selected file name or null string if file is not selected
+*/
QString SUIT_FileDlg::selectedFile() const
{
- return mySelectedFile;
+ QStringList files = selectedFiles();
+ return files.count() > 0 ? files[0] : QString();
}
-/*! Returns 'true' if this is 'Open File' dialog
- * and 'false' if 'Save File' dialog
- */
-bool SUIT_FileDlg::isOpenDlg() const
+/*!
+ \brief Get last visited directory.
+
+ Note, that last visited path is memorized only if the
+ dialog box is accepted.
+
+ \return last visited directory
+*/
+QString SUIT_FileDlg::getLastVisitedDirectory()
{
- return myOpen;
+ return myLastVisitedPath;
}
-/*! Closes this dialog and sets the return code to 'Accepted'
- * if the selected name is valid ( see 'acceptData()' )
- */
-void SUIT_FileDlg::accept()
+/*!
+ \brief Customize events processing.
+ \param e event
+ \return \c true if the event e was recognized and processed
+*/
+bool SUIT_FileDlg::event( QEvent* e )
{
- /* myAccepted
- * flag is used to warkaround the Qt 2.2.2 BUG:
- * accept() method is called twice if user presses 'Enter' key
- * in file name editor while file name is not acceptable by acceptData()
- * (e.g. permission denied)
- */
-// if ( !myAccepted ) {
- if ( acceptMode() != AcceptOpen )
- {
- QString fn;
- QStringList lst = QFileDialog::selectedFiles();
- if ( !lst.isEmpty() )
- fn = lst.first();
- mySelectedFile = fn;
- addExtension();
- }
+ bool res = QFileDialog::event( e );
- if ( acceptData() )
- {
- // NDS: needs to fill string mySelected file
- QString fn;
- QStringList lst = QFileDialog::selectedFiles();
- if ( !lst.isEmpty() )
- fn = lst.first();
- mySelectedFile = fn;
- // end NDS
- myLastVisitedPath = directory().path();
- QFileDialog::accept();
-// myAccepted = true;
- }
-// }
-// myAccepted = !myAccepted;
+ if ( e->type() == QEvent::Polish )
+ polish();
+
+ return res;
}
-/*! Closes this dialog and sets the return code to 'Rejected' */
-void SUIT_FileDlg::reject()
+/*!
+ \brief Get line edit which is used to enter file name.
+ \return line edit widget or0 if it could not be found
+*/
+QLineEdit* SUIT_FileDlg::lineEdit() const
{
- mySelectedFile = QString::null;
- QFileDialog::reject();
+ QLineEdit* ebox = 0;
+ QList<QLineEdit*> editBoxes = findChildren<QLineEdit*>();
+ QGridLayout* grid = ::qobject_cast<QGridLayout*>( layout() );
+ if ( grid ) {
+ int idx = 10000;
+ for ( int i = 0; i < editBoxes.count(); i++ ) {
+ int widx = grid->indexOf( editBoxes[ i ] );
+ if ( widx >= 0 )
+ idx = qMin( idx, widx );
+ }
+ if ( grid->itemAt( idx ) )
+ ebox = qobject_cast<QLineEdit*>( grid->itemAt( idx )->widget() );
+ }
+ return ebox;
}
-/*! Returns 'true' if selected file is valid.
- * The validity is checked by a file validator,
- * if there is no validator the file is always
- * considered as valid
- */
+/*!
+ \brief Validate user selection.
+
+ The validation is done by calling the corresponding methods
+ of the validator. If the validator is not set, this method
+ always returns \c true.
+
+ This method can be re-implemented in the subclasses to customize
+ the file dialog behavior.
+ Another solution could be implementing own file validator class.
+
+ \return \c true if user selection (file(s) or directory) is valid
+ \sa SUIT_FileValidator class, validator(), setValidator()
+*/
bool SUIT_FileDlg::acceptData()
{
- if ( myValidator )
- {
- if ( isOpenDlg() )
+ QStringList files = selectedFiles();
+ if ( files.isEmpty() )
+ return false;
+
+ // special case for ".."
+ if ( lineEdit() ) {
+ QString txt = lineEdit()->text();
+ if ( txt == ".." ) {
+ QDir dir = directory();
+ if ( dir.cdUp() ) {
+ setDirectory( dir );
+ bool block = lineEdit()->blockSignals( true );
+ lineEdit()->setText( ".." );
+ lineEdit()->selectAll();
+ lineEdit()->setFocus( Qt::OtherFocusReason );
+ lineEdit()->blockSignals( block );
+ return false;
+ }
+ }
+ else if ( fileMode() != DirectoryOnly ) {
+ QStringList fs = txt.split( " ", QString::SkipEmptyParts );
+ for ( int i = 0; i < fs.count(); i++ ) {
+ QString wc = fs.at( i );
+ if ( wc.startsWith( "\"" ) && wc.endsWith( "\"" ) )
+ wc = wc.mid( 1, wc.length()-2 );
+ if ( hasWildCards( wc ) ) {
+ addFilter( wc );
+ lineEdit()->clear();
+ return false;
+ }
+ }
+ }
+ }
+
+ // special case for wildcards
+ for ( int i = 0; i < files.count(); ++i ) {
+ }
+
+ bool bOk = true;
+
+ switch ( fileMode() ) {
+ case DirectoryOnly:
+ case Directory:
{
- if ( acceptMode() == AcceptOpen )
- {
- QStringList fileNames = selectedFiles();
- for ( int i = 0; i < (int)fileNames.count(); i++ )
- {
- if ( !myValidator->canOpen( fileNames[i] ) )
- return false;
- }
- return true;
+ QString fn = files.first();
+ if ( validator() ) {
+ bOk = isOpenDlg() ? validator()->canReadDir( fn, checkPermissions() ) :
+ validator()->canWriteDir( fn, checkPermissions() );
}
- else
- {
- return myValidator->canOpen( selectedFile() );
+ break;
+ }
+ case AnyFile:
+ {
+ QString fn = files.first();
+ QFileInfo info( fn );
+ if ( info.isDir() ) {
+ setDirectory( info.absoluteFilePath() );
+ if ( lineEdit() ) {
+ lineEdit()->selectAll();
+ lineEdit()->setFocus( Qt::OtherFocusReason );
+ }
+ return false;
+ }
+ // validation is not required
+ if ( validator() ) {
+ bOk = isOpenDlg() ? validator()->canOpen( fn, checkPermissions() ) :
+ validator()->canSave( fn, checkPermissions() );
}
+ break;
+ }
+ case ExistingFile:
+ case ExistingFiles:
+ {
+ for ( int i = 0; i < files.count(); ++i ) {
+ QFileInfo info( files.at( i ) );
+ if ( info.isDir() ) {
+ setDirectory( info.absoluteFilePath() );
+ if ( lineEdit() ) {
+ lineEdit()->selectAll();
+ lineEdit()->setFocus( Qt::OtherFocusReason );
+ }
+ return false;
+ }
+ if ( validator() ) {
+ bOk = isOpenDlg() ? validator()->canOpen( files.at( i ), checkPermissions() ) :
+ validator()->canSave( files.at( i ), checkPermissions() );
+ if ( !bOk )
+ return false;
+ }
+ }
+ break;
}
- else
- return myValidator->canSave( selectedFile() );
}
- return true;
+
+ if ( bOk )
+ emit filesSelected( files );
+
+ return bOk;
}
-/*! Adds an extension to the selected file name
- * if the file has not it.
- * The extension is extracted from the active filter.
- */
-void SUIT_FileDlg::addExtension()
+/*!
+ \brief Add an extension to the specified file name.
+
+ The extension is extracted from the active filter.
+
+ \param fileName file name to be processed
+ \return fileName with the extension added
+*/
+QString SUIT_FileDlg::addExtension( const QString& fileName ) const
{
+ QString fname = fileName.trimmed();
+
// check if file name entered is empty
- if ( mySelectedFile.trimmed().isEmpty() )
- return;
+ if ( fname.isEmpty() )
+ return fileName;
// current file extension
- QString anExt = "." + SUIT_Tools::extension( mySelectedFile.trimmed() ).trimmed();
+ QString anExt = "." + SUIT_Tools::extension( fname ).trimmed();
// If the file already has extension and it does not match the filter there are two choices:
// - to leave it 'as is'
// - to ignore it
// The behavior is defined by IGNORE_NON_MATCHING_EXTENSION constant
if ( anExt != "." && !IGNORE_NON_MATCHING_EXTENSION )
- return;
+ return fileName;
QRegExp r( QString::fromLatin1("\\(?[a-zA-Z0-9.*? +;#|]*\\)?$") );
int index = r.indexIn( selectedFilter().trimmed() );
// now we get the list of all extension masks and remove all which does not contain wildcard symbols
QStringList extList = aPattern.split( "|", QString::SkipEmptyParts );
- for ( int i = extList.count() - 1; i >= 0; i-- )
- {
+ for ( int i = extList.count() - 1; i >= 0; i-- ) {
if ( !extList[i].contains( "." ) )
extList.removeAt( i );
}
QRegExp anExtRExp( "^("+ aPattern + ")$" );
// Check if the current file extension matches the pattern
- if ( !anExtRExp.exactMatch( anExt ) )
- {
+ if ( !anExtRExp.exactMatch( anExt ) ) {
// find first appropriate extension in the selected filter
// (it should be without wildcard symbols)
- for ( int i = 0; i < (int)extList.count(); i++ )
- {
+ for ( int i = 0; i < extList.count(); i++ ) {
QString newExt = extList[i].replace( QRegExp( "[\\\\][+]" ),"+" );
int res = newExt.lastIndexOf( '.' );
if ( res >= 0 )
newExt = newExt.mid( res + 1 );
- if ( newExt.indexOf( QRegExp("[*|?]" ) ) < 0 )
- {
- mySelectedFile.trimmed();
- mySelectedFile += mySelectedFile.endsWith(".") ? newExt : QString(".") + newExt;
- break;
+ if ( newExt.indexOf( QRegExp("[*|?]" ) ) < 0 ) {
+ fname += fname.endsWith( "." ) ? newExt : QString( "." ) + newExt;
+ return fname;
}
}
}
}
+ return fileName;
}
-/*! Processes selection : tries to set given path or filename as selection */
+/*!
+ \brief Processes selection : tries to set specified sirectory or filename
+ as current file dialog selection.
+ \param path file or directory path
+ \return \c true if \a path is processed correctly and \c false otherwise
+*/
bool SUIT_FileDlg::processPath( const QString& path )
{
- if ( !path.isNull() )
- {
+ if ( !path.isNull() ) {
QFileInfo fi( path );
- if ( fi.exists() )
- {
+ if ( fi.exists() ) {
if ( fi.isFile() )
- selectFile( path );
+ selectFile( path );
else if ( fi.isDir() )
- setDirectory( path );
+ setDirectory( path );
return true;
}
- else
- {
- if ( QFileInfo( SUIT_Tools::dir( path ) ).exists() )
- {
- setDirectory( SUIT_Tools::dir( path ) );
- selectFile( path );
- return true;
- }
+ else if ( QFileInfo( SUIT_Tools::dir( path ) ).exists() ) {
+ setDirectory( SUIT_Tools::dir( path ) );
+ selectFile( path );
+ return true;
}
}
return false;
}
-/*! Called when user selects item from "Quick Dir" combo box */
-void SUIT_FileDlg::quickDir(const QString& dirPath)
+
+/*!
+ \brief Add file filter and activates it.
+ \param filter new file filter
+*/
+void SUIT_FileDlg::addFilter( const QString& filter )
{
- QString aPath = dirPath;
- if ( !QDir(aPath).exists() )
- {
- aPath = QDir::homePath();
- SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "ERR_DIR_NOT_EXIST" ).arg( dirPath ) );
+ QStringList flist = filters();
+ if ( !flist.contains( filter ) ) {
+ flist << filter;
+ setFilters( flist );
}
+ selectFilter( filter );
+}
+
+/*!
+ \brief Check if the string contains wildcard symbols.
+ \param s string to be checked (for example, file name)
+ \return \c true if string contains "*" or "?" symbols
+*/
+bool SUIT_FileDlg::hasWildCards( const QString& s )
+{
+ return s.contains( QRegExp("[*|?]") );
+}
+
+/*!
+ \brief Called when the user presses "Open"or "Save" button.
+
+ Verifies the user choice and closes dialog box, setting the return code to QDialog::Accepted
+
+ \sa acceptData()
+*/
+void SUIT_FileDlg::accept()
+{
+ if ( acceptData() ) {
+ myLastVisitedPath = directory().path();
+ QDialog::accept();
+ }
+}
+
+/*!
+ \brief Called when user selects directory from the "Quick Dir" combo box.
+
+ Browses the file dialog to the specified directory (if it is valid).
+
+ \param dirPath selected directory
+*/
+void SUIT_FileDlg::quickDir( const QString& dirPath )
+{
+ if ( !QDir( dirPath ).exists() )
+ SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "ERR_DIR_NOT_EXIST" ).arg( dirPath ) );
else
- processPath( aPath );
+ processPath( dirPath );
}
+
/*!
- Called when user presses "Add" button - adds current directory to quick directory
- list and to the preferences
+ \brief Called when user presses "Quick Dir Add" button.
+
+ Adds current directory to the quick directories list and to the preferences.
*/
void SUIT_FileDlg::addQuickDir()
{
QString dp = directory().path();
- if ( !dp.isEmpty() )
- {
+ if ( !dp.isEmpty() ) {
QDir dir( dp );
- // getting dir list from settings
- QString dirs;
+
+ QStringList dirList;
+
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
if ( resMgr )
- dirs = resMgr->stringValue( "FileDlg", QString( "QuickDirList" ) );
- QStringList dirList = dirs.split( ';', QString::SkipEmptyParts );
+ dirList = resMgr->stringValue( "FileDlg", QString( "QuickDirList" ) ).split( ';', QString::SkipEmptyParts );
+
bool found = false;
bool emptyAndHome = false;
- if ( dirList.count() > 0 )
- {
- for ( int i = 0; i < dirList.count(); i++ )
- {
- QDir aDir( dirList[i] );
- if ( aDir.canonicalPath().isNull() && dirList[i] == dir.absolutePath() ||
- !aDir.canonicalPath().isNull() && aDir.exists() && aDir.canonicalPath() == dir.canonicalPath() )
- {
- found = true;
- break;
- }
+ if ( dirList.count() > 0 ) {
+ for ( int i = 0; i < dirList.count() && !found; i++ ) {
+ QDir aDir( dirList[i] );
+ if ( aDir.canonicalPath().isNull() && dirList[i] == dir.absolutePath() ||
+ !aDir.canonicalPath().isNull() && aDir.exists() &&
+ aDir.canonicalPath() == dir.canonicalPath() ) {
+ found = true;
+ }
}
}
- else
+ else {
emptyAndHome = dir.canonicalPath() == QDir( QDir::homePath() ).canonicalPath();
+ }
- if ( !found )
- {
+ if ( !found ) {
dirList.append( dp );
resMgr->setValue( "FileDlg", QString( "QuickDirList" ), dirList.join( ";" ) );
if ( !emptyAndHome )
- myQuickCombo->addItem( dp );
+ myQuickCombo->addItem( dp );
}
}
}
+
/*!
- Returns the file name for Open/Save [ static ]
+ \brief Polish the dialog box.
+*/
+void SUIT_FileDlg::polish()
+{
+ QList<QPushButton*> buttons = findChildren<QPushButton*>();
+
+ int maxBtnWidth = 0;
+
+ for ( QList<QPushButton*>::const_iterator it = buttons.begin();
+ it != buttons.end(); ++it )
+ maxBtnWidth = qMax( maxBtnWidth, (*it)->sizeHint().width() );
+
+ for ( QList<QPushButton*>::const_iterator it = buttons.begin();
+ it != buttons.end(); ++it ) {
+ (*it)->setDefault( false );
+ (*it)->setAutoDefault( false );
+ (*it)->setFixedWidth( maxBtnWidth );
+ }
+
+ QList<QListView*> views = findChildren<QListView*>();
+ for ( QList<QListView*>::const_iterator it = views.begin();
+ it != views.end(); ++it ) {
+ (*it)->setViewMode( QListView::ListMode );
+ }
+}
+
+/*!
+ \brief Show dialog box for the file opening/saving.
+
+ This method can be used to select the file for opening
+ or saving. The behavior is defined by the \a open parameter.
+ Note, that selection validation depends on the dialog mode used.
+
+ If \a initial parameter is not null string it is used as starting directory
+ or file at which dialog box is opened.
+
+ The parameter \a filters defines file filters (wildcards) to be used.
+ If filters list is empty, "All files (*)" is used by default.
+
+ The parameter \a caption is used as dialog box title. If it is
+ is empty, the default title is used.
+
+ The parameter \a showQuickDir specifies if it is necessary to
+ show additional quick directories list controls in the bottom part
+ of the dialog box.
+
+ The validation of the user selection is done with help of the file
+ validator (SUIT_FileValidator class). The last parameter \a validator
+ can be used to pass the custom file validator to the dialog box.
+
+ \param parent parent widget
+ \param initial initial file (or directory) dialog box to be opened on
+ \param filters file filters list
+ \param caption dialog box title
+ \param open if \c true dialog box is used for file opening, otherwise - for saving
+ \param showQuickDir if \c true the quick directory list widgets will be shown
+ \param validator custom file validator
+ \return selected file name or null string if dialog box is cancelled
+ \sa getOpenFileNames(), getExistingDirectory()
*/
-QString SUIT_FileDlg::getFileName( QWidget* parent, const QString& initial, const QStringList& filters,
- const QString& caption, bool open, bool showQuickDir,
+QString SUIT_FileDlg::getFileName( QWidget* parent, const QString& initial,
+ const QStringList& filters, const QString& caption,
+ const bool open, const bool showQuickDir,
SUIT_FileValidator* validator )
{
- SUIT_FileDlg* fd = new SUIT_FileDlg( parent, open, showQuickDir, true );
+ SUIT_FileDlg fd( parent, open, showQuickDir, true );
+
+ fd.setFileMode( open ? ExistingFile : AnyFile );
+
+ if ( filters.isEmpty() )
+ fd.setFilter( tr( "ALL_FILES_FILTER" ) ); // All files (*)
+ else
+ fd.setFilters( filters );
+
if ( !caption.isEmpty() )
- fd->setWindowTitle( caption );
+ fd.setWindowTitle( caption );
+
if ( !initial.isEmpty() )
- fd->processPath( initial ); // VSR 24/03/03 check for existing of directory has been added to avoid QFileDialog's bug
+ fd.processPath( initial );
- fd->setFilters( filters );
if ( validator )
- fd->setValidator( validator );
+ fd.setValidator( validator );
- fd->exec();
+ QString filename;
- QString filename = fd->selectedFile();
- delete fd;
+ if ( fd.exec() == QDialog::Accepted )
+ filename = fd.selectedFile();
QApplication::processEvents();
}
/*!
- Returns the list of files to be opened [ static ]
+ \brief Show dialog box for the file opening/saving.
+ \overload
+
+ This method can be used to select the file for opening
+ or saving. The behavior is defined by the \a open parameter.
+ Note, that selection validation depends on the dialog mode used.
+
+ If \a initial parameter is not null string it is used as starting directory
+ or file at which dialog box is opened.
+
+ The parameter \a filters defines file filters (wildcards) to be used.
+ This is the list of wildcards, separated by the ";;" symbols.
+ If filters list is empty, "All files (*)" is used by default.
+
+ The parameter \a caption is used as dialog box title. If it is
+ is empty, the default title is used.
+
+ The parameter \a showQuickDir specifies if it is necessary to
+ show additional quick directories list controls in the bottom part
+ of the dialog box.
+
+ The validation of the user selection is done with help of the file
+ validator (SUIT_FileValidator class). The last parameter \a validator
+ can be used to pass the custom file validator to the dialog box.
+
+ \param parent parent widget
+ \param initial initial file (or directory) dialog box to be opened on
+ \param filters file filters separated by ";;"
+ \param caption dialog box title
+ \param open if \c true dialog box is used for file opening, otherwise - for saving
+ \param showQuickDir if \c true the quick directory list widgets will be shown
+ \param validator custom file validator
+ \return selected file name or null string if dialog box is cancelled
+ \sa getOpenFileNames(), getExistingDirectory()
+*/
+QString SUIT_FileDlg::getFileName( QWidget* parent, const QString& initial,
+ const QString& filters, const QString& caption,
+ const bool open, const bool showQuickDir,
+ SUIT_FileValidator* validator )
+{
+ return getFileName( parent, initial, filters.split( ";;", QString::SkipEmptyParts ),
+ caption, open, showQuickDir, validator );
+}
+
+/*!
+ \brief Show dialog box for the multiple files selection.
+
+ If \a initial parameter is not null string it is used as starting directory
+ or file at which dialog box is opened.
+
+ The parameter \a filters defines file filters (wildcards) to be used.
+ If filters list is empty, "All files (*)" is used by default.
+
+ The parameter \a caption is used as dialog box title. If it is
+ is empty, the default title is used.
+
+ The parameter \a showQuickDir specifies if it is necessary to
+ show additional quick directories list controls in the bottom part
+ of the dialog box.
+
+ The validation of the user selection is done with help of the file
+ validator (SUIT_FileValidator class). The last parameter \a validator
+ can be used to pass the custom file validator to the dialog box.
+
+ \param parent parent widget
+ \param initial initial file (or directory) dialog box to be opened on
+ \param filters file filters list
+ \param caption dialog box title
+ \param showQuickDir if \c true the quick directory list widgets will be shown
+ \param validator custom file validator
+ \return selected file names or empty list if dialog box is cancelled
+ \sa getFileName(), getExistingDirectory()
*/
-QStringList SUIT_FileDlg::getOpenFileNames( QWidget* parent, const QString& initial, const QStringList& filters,
- const QString& caption, bool showQuickDir, SUIT_FileValidator* validator )
+QStringList SUIT_FileDlg::getOpenFileNames( QWidget* parent, const QString& initial,
+ const QStringList& filters, const QString& caption,
+ const bool showQuickDir,
+ SUIT_FileValidator* validator )
{
- SUIT_FileDlg* fd = new SUIT_FileDlg( parent, true, showQuickDir, true );
- fd->setFileMode( ExistingFiles );
+ SUIT_FileDlg fd( parent, true, showQuickDir, true );
+
+ fd.setFileMode( ExistingFiles );
+
+ if ( filters.isEmpty() )
+ fd.setFilter( tr( "ALL_FILES_FILTER" ) ); // All files (*)
+ else
+ fd.setFilters( filters );
+
if ( !caption.isEmpty() )
- fd->setWindowTitle( caption );
+ fd.setWindowTitle( caption );
+
if ( !initial.isEmpty() )
- fd->processPath( initial ); // VSR 24/03/03 check for existing of directory has been added to avoid QFileDialog's bug
+ fd.processPath( initial );
- fd->setFilters( filters );
if ( validator )
- fd->setValidator( validator );
+ fd.setValidator( validator );
+
+ QStringList filenames;
- fd->exec();
- QStringList filenames = fd->selectedFiles();
- delete fd;
+ if ( fd.exec() == QDialog::Accepted )
+ filenames = fd.selectedFiles();
QApplication::processEvents();
+
return filenames;
}
/*!
- Existing directory selection dialog [ static ]
+ \brief Show dialog box for the multiple file opening.
+ \overload
+
+ If \a initial parameter is not null string it is used as starting directory
+ or file at which dialog box is opened.
+
+ The parameter \a filters defines file filters (wildcards) to be used.
+ This is the list of wildcards, separated by the ";;" symbols.
+ If filters list is empty, "All files (*)" is used by default.
+
+ The parameter \a caption is used as dialog box title. If it is
+ is empty, the default title is used.
+
+ The parameter \a showQuickDir specifies if it is necessary to
+ show additional quick directories list controls in the bottom part
+ of the dialog box.
+
+ The validation of the user selection is done with help of the file
+ validator (SUIT_FileValidator class). The last parameter \a validator
+ can be used to pass the custom file validator to the dialog box.
+
+ \param parent parent widget
+ \param initial initial file (or directory) dialog box to be opened on
+ \param filters file filters separated by ";;"
+ \param caption dialog box title
+ \param showQuickDir if \c true the quick directory list widgets will be shown
+ \param validator custom file validator
+ \return selected file names or empty list if dialog box is cancelled
+ \sa getFileName(), getExistingDirectory()
+*/
+QStringList SUIT_FileDlg::getOpenFileNames( QWidget* parent, const QString& initial,
+ const QString& filters, const QString& caption,
+ const bool showQuickDir,
+ SUIT_FileValidator* validator )
+{
+ return getOpenFileNames( parent, initial, filters.split( ";;", QString::SkipEmptyParts ),
+ caption, showQuickDir, validator );
+}
+
+/*!
+ \brief Show dialog box for the existing directory selection.
+
+ If \a initial parameter is not null string it is used as starting directory
+ at which dialog box is opened.
+
+ The parameter \a caption is used as dialog box title. If it is
+ is empty, the default title is used.
+
+ The parameter \a showQuickDir specifies if it is necessary to
+ show additional quick directories list controls in the bottom part
+ of the dialog box.
+
+ The validation of the user selection is done with help of the file
+ validator (SUIT_FileValidator class). The last parameter \a validator
+ can be used to pass the custom file validator to the dialog box.
+
+ \param parent parent widget
+ \param initial initial directory dialog box to be opened on
+ \param caption dialog box title
+ \param showQuickDir if \c true the quick directory list widgets will be shown
+ \param validator custom file validator
+ \return selected directory name or null string if dialog box is cancelled
+ \sa getFileName(), getOpenFileNames()
*/
QString SUIT_FileDlg::getExistingDirectory( QWidget* parent, const QString& initial,
- const QString& caption, bool showQuickDir )
+ const QString& caption, const bool showQuickDir,
+ SUIT_FileValidator* validator )
{
- SUIT_FileDlg* fd = new SUIT_FileDlg( parent, true, showQuickDir, true );
+ SUIT_FileDlg fd( parent, true, showQuickDir, true );
+
+ fd.setFileMode( DirectoryOnly );
+
if ( !caption.isEmpty() )
- fd->setWindowTitle( caption );
- if ( !initial.isEmpty() )
- fd->processPath( initial ); // VSR 24/03/03 check for existing of directory has been added to avoid QFileDialog's bug
+ fd.setWindowTitle( caption );
- fd->setFileMode( DirectoryOnly );
- fd->setFilters( QStringList( tr( "INF_DIRECTORIES_FILTER" ) ) );
+ if ( !initial.isEmpty() )
+ fd.processPath( initial );
+
+ if ( validator )
+ fd.setValidator( validator );
- fd->exec();
+ QString dirname;
- QString dirname = fd->selectedFile();
- delete fd;
+ if ( fd.exec() == QDialog::Accepted )
+ dirname = fd.selectedFile();
QApplication::processEvents();
+
return dirname;
}
+/*!
+ \brief Get last visited path
+ \return last visited path
+*/
+QString SUIT_FileDlg::getLastVisitedPath()
+{
+ return myLastVisitedPath;
+}
+
/*!
\brief Selects current file
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#ifndef SUIT_FILEDIALOG_H
-#define SUIT_FILEDIALOG_H
+// File : SUIT_FileDlg.h
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//
+
+#ifndef SUIT_FILEDLG_H
+#define SUIT_FILEDLG_H
#include "SUIT.h"
#include <QFileDialog>
class QLabel;
+class QLineEdit;
class QComboBox;
class QPushButton;
class SUIT_FileValidator;
-/*! \class QFileDialog
- * For more information see <a href="http://doc.trolltech.com">QT documentation</a>.
-*/
class SUIT_EXPORT SUIT_FileDlg : public QFileDialog
{
Q_OBJECT
public:
- SUIT_FileDlg( QWidget*, bool open, bool showQuickDir = true, bool modal = true );
+ SUIT_FileDlg( QWidget*, bool, bool = true, bool = true );
virtual ~SUIT_FileDlg();
-public:
bool isOpenDlg() const;
+
+ bool checkPermissions() const;
+ void setCheckPermissions( const bool );
+
+ SUIT_FileValidator* validator() const;
+ void setValidator( SUIT_FileValidator* );
+
+ bool addWidgets( QWidget*, QWidget*, QWidget* );
+
+ QStringList selectedFiles() const;
QString selectedFile() const;
- void selectFile( const QString& );
+ void selectFile( const QString& );
- void setValidator( SUIT_FileValidator* );
+ static QString getLastVisitedDirectory();
- static QString getFileName( QWidget* parent, const QString& initial, const QStringList& filters,
- const QString& caption, const bool open, const bool showQuickDir = true,
- SUIT_FileValidator* validator = 0 );
- static QStringList getOpenFileNames( QWidget* parent, const QString& initial, const QStringList& filters,
- const QString& caption, bool showQuickDir = true,
- SUIT_FileValidator* validator = 0 );
- static QString getExistingDirectory( QWidget* parent, const QString& initial,
- const QString& caption, const bool showQuickDir = true );
+ static QString getFileName( QWidget*,
+ const QString&,
+ const QStringList&,
+ const QString& = QString(),
+ const bool = true,
+ const bool = true,
+ SUIT_FileValidator* = 0 );
+ static QString getFileName( QWidget*,
+ const QString&,
+ const QString&,
+ const QString& = QString(),
+ const bool = true,
+ const bool = true,
+ SUIT_FileValidator* = 0 );
-private:
- void polish();
- bool acceptData();
- void addExtension();
- bool processPath( const QString& path );
+ static QStringList getOpenFileNames( QWidget*,
+ const QString&,
+ const QStringList&,
+ const QString& = QString(),
+ const bool = true,
+ SUIT_FileValidator* = 0 );
+ static QStringList getOpenFileNames( QWidget*,
+ const QString&,
+ const QString&,
+ const QString& = QString(),
+ const bool = true,
+ SUIT_FileValidator* = 0 );
+
+ static QString getExistingDirectory( QWidget*,
+ const QString&,
+ const QString& = QString(),
+ const bool = true,
+ SUIT_FileValidator* = 0 );
+
+ static QString getLastVisitedPath();
+
+protected:
+ virtual bool event( QEvent* );
+ QLineEdit* lineEdit() const;
+ virtual bool acceptData();
+ QString addExtension( const QString& ) const;
+ bool processPath( const QString& );
+ void addFilter( const QString& );
+ static bool hasWildCards( const QString& );
protected slots:
void accept();
- void reject();
void quickDir( const QString& );
void addQuickDir();
-protected:
- virtual bool event( QEvent* );
+private:
+ void polish();
-protected:
- bool myOpen; //!< open/save selector
- QString mySelectedFile; //!< selected filename
+private:
SUIT_FileValidator* myValidator; //!< file validator
QLabel* myQuickLab; //!< quick dir combo box
QComboBox* myQuickCombo; //!< quick dir combo box
QPushButton* myQuickButton; //!< quick dir add button
-
- /*! \var myAccepted
- * \brief flag is used to warkaround the Qt 2.2.2
- * \bug accept() method is called twice if user presses 'Enter' key
- * in file name editor while file name is not acceptable by acceptData()
- * (e.g. permission denied)
- */
-// bool myAccepted;
- /*! ASL: this bug can be fixed with help of call setDefault( false )
- * and setAutoDefault( false ) methods for all QPushButtons of this dialog
- */
-
+ bool myCheckPermissions; //!< check permissions option
static QString myLastVisitedPath; //!< last visited path
};
-#endif
+#endif // SUIT_FILEDLG_H
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include "SUIT_FileValidator.h"
+// File : SUIT_FileValidator.cxx
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//
+#include "SUIT_FileValidator.h"
#include "SUIT_MessageBox.h"
-
-#include <QFile>
+#include "SUIT_Tools.h"
#include <QFileInfo>
-/*! constructor */
-SUIT_FileValidator::SUIT_FileValidator(QWidget* parent) :
-myParent(parent)
+/*!
+ \class SUIT_FileValidator
+ \brief Provides functionality to check the file or directory
+ existance and permissions.
+ \sa SUIT_FileDlg class
+*/
+
+/*!
+ \brief Constructor.
+ \param parent parent widget (used as parent when displaying
+ information message boxes)
+*/
+SUIT_FileValidator::SUIT_FileValidator( QWidget* parent )
+: myParent( parent )
{
}
-/*! returns false if can't open file */
-bool SUIT_FileValidator::canOpen( const QString& file )
+/*!
+ \brief Check if the specified file exists and (optionally) can be read.
+
+ If file does not exists or can not be read (if \a checkPermission is \c true)
+ and parent() is not null, shows error message box.
+
+ \param fileName file path
+ \param checkPermission if \c true (default) check also file permissions
+ \return \c false if file does not exist or if it does not have
+ read permissions (if \a checkPermission is \c true)
+*/
+bool SUIT_FileValidator::canOpen( const QString& fileName, bool checkPermission )
{
- if ( !QFile::exists( file ) )
- {
- SUIT_MessageBox::critical( myParent, QObject::tr( "ERR_ERROR" ),
- QObject::tr( "ERR_FILE_NOT_EXIST" ).arg( file ) );
- return false;
+ if ( !QFile::exists( fileName ) ) {
+ if ( parent() )
+ SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ),
+ QObject::tr( "ERR_FILE_NOT_EXIST" ).arg( fileName ) );
+ return false;
}
- if ( !QFileInfo( file ).isReadable() )
- {
- SUIT_MessageBox::critical( myParent, QObject::tr( "ERR_ERROR" ),
- QObject::tr( "ERR_PERMISSION_DENIED" ).arg( file ) );
+ if ( checkPermission && !QFileInfo( fileName ).isReadable() ) {
+ if ( parent() )
+ SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ),
+ QObject::tr( "ERR_PERMISSION_DENIED" ).arg( fileName ) );
return false;
}
return true;
}
-/*! returns false if can't save file */
-bool SUIT_FileValidator::canSave( const QString& file )
+/*!
+ \brief Check if the specified file can be written.
+
+ If file already exists and parent() is not null, prompts
+ question message box to the user to confirm file overwriting.
+
+ If file can not be written (if \a checkPermission is \c true)
+ and parent() is not null, shows error message box.
+
+ \param fileName file path
+ \param checkPermission if \c true (default) check also file permissions
+ \return \c false if file exists and user rejects file overwriting
+ or if file does not have write permissions (if \a checkPermission is \c true)
+*/
+bool SUIT_FileValidator::canSave( const QString& fileName, bool checkPermission )
{
- if ( QFile::exists( file ) )
- {
- // if file exists - raise warning...
- if ( SUIT_MessageBox::question( myParent, QObject::tr( "WRN_WARNING" ),
- QObject::tr( "QUE_DOC_FILEEXISTS" ).arg( file ),
- SUIT_MessageBox::Yes | SUIT_MessageBox::No,
- SUIT_MessageBox::No ) != SUIT_MessageBox::Yes )
- {
- return false;
- }
- // ... and if user wants to overwrite file, check it for writeability
- if ( !QFileInfo( file ).isWritable() )
- {
- SUIT_MessageBox::critical( myParent, QObject::tr( "ERR_ERROR" ),
- QObject::tr( "ERR_PERMISSION_DENIED" ).arg( file ) );
+ if ( QFile::exists( fileName ) ) {
+ if ( parent() )
+ if ( SUIT_MessageBox::question( parent(), QObject::tr( "WRN_WARNING" ),
+ QObject::tr( "QUE_DOC_FILEEXISTS" ).arg( fileName ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::No ) != SUIT_MessageBox::Yes )
+ return false;
+
+ if ( checkPermission && !QFileInfo( fileName ).isWritable() ) {
+ if ( parent() )
+ SUIT_MessageBox::critical( myParent, QObject::tr( "ERR_ERROR" ),
+ QObject::tr( "ERR_PERMISSION_DENIED" ).arg( fileName ) );
return false;
}
}
- else
- {
- // if file doesn't exist - try to create it
- QFile qf( file );
- if ( !qf.open( QFile::WriteOnly ) )
- {
- SUIT_MessageBox::critical( myParent, QObject::tr( "ERR_ERROR" ),
- QObject::tr( "ERR_PERMISSION_DENIED" ).arg( file ) );
+ else {
+ QString dirName = SUIT_Tools::dir( fileName );
+ if ( checkPermission && !QFileInfo( dirName ).isWritable() ) {
+ if ( parent() )
+ SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ),
+ QObject::tr( "ERR_PERMISSION_DENIED" ).arg( fileName ) );
return false;
}
- else
- {
- // remove just created file
- qf.close();
- qf.remove();
- }
}
return true;
}
+
+/*!
+ \brief Check if the specified directory exists and (optionally) can be read.
+
+ If directory does not exists or can not be read (if \a checkPermission is \c true)
+ and parent() is not null, shows error message box.
+
+ \param dirName directory path
+ \param checkPermission if \c true (default) check also directory permissions
+ \return \c false if directory does not exist or if it does not have
+ read permissions (if \a checkPermission is \c true)
+*/
+bool SUIT_FileValidator::canReadDir( const QString& dirName, bool checkPermission )
+{
+ QFileInfo info( dirName );
+ if ( !info.exists() ) {
+ if ( parent() )
+ SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ),
+ QObject::tr( "ERR_DIR_NOT_EXIST" ).arg( dirName ) );
+ return false;
+ }
+ if ( !info.isDir() ) {
+ if ( parent() )
+ SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ),
+ QObject::tr( "ERR_FILE_NOT_DIR" ).arg( dirName ) );
+ return false;
+ }
+ if ( checkPermission && !info.isReadable() ) {
+ if ( parent() )
+ SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ),
+ QObject::tr( "ERR_PERMISSION_DENIED" ).arg( dirName ) );
+ return false;
+ }
+ return true;
+}
+
+/*!
+ \brief Check if the specified directory can be written.
+
+ If directory does not exists or can not be modified (if \a checkPermission is \c true)
+ and parent() is not null, shows error message box.
+
+ \param dirName directory path
+ \param checkPermission if \c true (default) check also directory permissions
+ \return \c false if directory does not exist or if it does not have
+ write permissions (if \a checkPermission is \c true)
+*/
+bool SUIT_FileValidator::canWriteDir( const QString& dirName, bool checkPermission )
+{
+ QFileInfo info( dirName );
+ if ( !info.exists() ) {
+ if ( parent() )
+ SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ),
+ QObject::tr( "ERR_DIR_NOT_EXIST" ).arg( dirName ) );
+ return false;
+ }
+ if ( !info.isDir() ) {
+ if ( parent() )
+ SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ),
+ QObject::tr( "ERR_FILE_NOT_DIR" ).arg( dirName ) );
+ return false;
+ }
+ if ( checkPermission && !info.isWritable() ) {
+ if ( parent() )
+ SUIT_MessageBox::critical( parent(), QObject::tr( "ERR_ERROR" ),
+ QObject::tr( "ERR_PERMISSION_DENIED" ).arg( dirName ) );
+ return false;
+ }
+ return true;
+}
+
+/*!
+ \brief Get parent widget.
+ \return parent widget
+*/
+QWidget* SUIT_FileValidator::parent() const
+{
+ return myParent;
+}
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// SALOME SALOMEGUI : implementation of desktop and GUI kernel
+// File : SUIT_FileValidator.h
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
//
+
#ifndef SUIT_FILEVALIDATOR_H
#define SUIT_FILEVALIDATOR_H
class QWidget;
class QString;
-/*!
- \class SUIT_FileValidator
- Provides functionality to check file
-*/
class SUIT_EXPORT SUIT_FileValidator
{
public:
- SUIT_FileValidator(QWidget* parent = 0);
+ SUIT_FileValidator( QWidget* = 0 );
- virtual bool canOpen( const QString& file );
- virtual bool canSave( const QString& file );
+ virtual bool canOpen( const QString&, bool = true );
+ virtual bool canSave( const QString&, bool = true );
- //! Return parent widget
- QWidget* parent() const { return myParent; }
-
- private:
+ virtual bool canReadDir( const QString&, bool = true );
+ virtual bool canWriteDir( const QString&, bool = true );
+
+ QWidget* parent() const;
+private:
QWidget* myParent;
};
-#endif
+#endif // SUIT_FILEVALIDATOR_H
automatically when data tree is changed.
\param on 'auto-update tree' flag value
+ \param updateImmediately if \c true, the tree is updated immediately;
+ otherwise the tree must be updated manually
\sa autoUpdate(), updateTree()
*/
-void SUIT_TreeModel::setAutoUpdate( const bool on )
+void SUIT_TreeModel::setAutoUpdate( const bool on, const bool updateImmediately )
{
if ( myAutoUpdate == on )
return;
SUIT_DataObject::connect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
- updateTree();
+ if ( updateImmediately )
+ updateTree();
}
}
automatically when data tree is changed.
\param on 'auto-update tree' flag value
+ \param updateImmediately if \c true, the tree is updated immediately;
+ otherwise the tree must be updated manually
\sa autoUpdate(), updateTree()
*/
-void SUIT_ProxyModel::setAutoUpdate( const bool on )
+void SUIT_ProxyModel::setAutoUpdate( const bool on, const bool updateImmediately )
{
if ( treeModel() )
- treeModel()->setAutoUpdate( on );
+ treeModel()->setAutoUpdate( on, updateImmediately );
}
/*!
void setAutoDeleteTree( const bool );
bool autoUpdate() const;
- void setAutoUpdate( const bool );
+ void setAutoUpdate( const bool, const bool = true );
virtual bool customSorting( const int ) const;
virtual bool lessThan( const QModelIndex& left, const QModelIndex& right ) const;
void setAutoDeleteTree( const bool );
bool autoUpdate() const;
- void setAutoUpdate( const bool );
+ void setAutoUpdate( const bool, const bool = true );
bool isSortingEnabled() const;
-TEMPLATE = app
+unix:TEMPLATE = app
+win32:TEMPLATE = vcapp
+
+CONFIG -= embed_manifest_exe
+
+win32:QMAKE_MOC=$(QTDIR)\bin\moc.exe
DESTDIR = ../../$(CONFIG_ID)/bin
MOC_DIR = ../../moc
INCLUDEPATH = ../../include
LIBS += -L../../$(CONFIG_ID)/lib -lSUIT -lQtx -lStyle -lObjBrowser
+win32:LIBS *= -L$(QTLIB)
+win32:INCLUDEPATH *= $(QTINC) $(QTINC)\QtCore $(QTINC)\QtGui $(QTINC)\QtXml
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared
-win32:DEFINES += WIN32
+win32:DEFINES += WNT WIN32
HEADERS = *.h
SOURCES = *.cxx
+
+win32:copy_hdr.name = Install ${QMAKE_FILE_IN}
+win32:copy_hdr.commands = type ${QMAKE_FILE_IN} > ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.output = ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.input = HEADERS
+win32:QMAKE_EXTRA_COMPILERS += copy_hdr
-TEMPLATE = lib
+unix:TEMPLATE = lib
+win32:TEMPLATE = vclib
+
+win32:QMAKE_MOC=$(QTDIR)\bin\moc.exe
DESTDIR = ../../$(CONFIG_ID)/lib
MOC_DIR = ../../moc
OBJECTS_DIR = ../../$(CONFIG_ID)/obj/$$TARGET
-VTK_LIBS = -L$$(VTKLIB) -lvtkCommon -lvtkGraphics -lvtkImaging -lvtkFiltering -lvtkIO -lvtkRendering -lvtkHybrid -lvtkParallel -lvtkWidgets -lGL -L/usr/X11R6/lib -lGLU -L/usr/X11R6/lib -lX11 -lXt
+unix:VTK_LIBS = -L$$(VTKLIB) -lvtkCommon -lvtkGraphics -lvtkImaging -lvtkFiltering -lvtkIO -lvtkRendering -lvtkHybrid -lvtkParallel -lvtkWidgets -lGL -L/usr/X11R6/lib -lGLU -L/usr/X11R6/lib -lX11 -lXt
+win32:VTK_LIBS = -L$$(VTKLIB) -lvtkCommon -lvtkGraphics -lvtkImaging -lvtkFiltering -lvtkIO -lvtkRendering -lvtkHybrid -lvtkParallel -lvtkWidgets -lopengl32
CAS_CPPFLAGS = $(CASINC)
-OCC_LIBS =
+unix:OCC_LIBS =
+win32:OCC_LIBS = -L$(CASLIB) -lTKernel
INCLUDEPATH += ../../include $${CAS_CPPFLAGS} $$(VTKINC) $$(BOOSTINC) ../Qtx ../SUIT ../OBJECT ../Prs ../VTKViewer
LIBS += -L../../$(CONFIG_ID)/lib -lQtx -lSUIT -lOBJECT -lPrs -lVTKViewer $${OCC_LIBS} $${VTK_LIBS}
+win32: LIBS += -lTKernel
+win32:LIBS *= -L$(QTLIB)
+win32:INCLUDEPATH *= $(QTINC) $(QTINC)\QtCore $(QTINC)\QtGui $(QTINC)\QtXml
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared
-win32:DEFINES += WIN32
+win32:DEFINES += WNT WIN32
DEFINES += SVTK_EXPORTS $(CASDEFINES) OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS
HEADERS = SVTK.h
lrelease.name = LRELASE ${QMAKE_FILE_IN}
unix:lrelease.commands = $(QTDIR)/bin/lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}/${QMAKE_FILE_BASE}.qm
-win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
+win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_IN} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
unix:lrelease.output = $${GUIResources}/${QMAKE_FILE_BASE}.qm
win32:lrelease.output = $${GUIResources}\\${QMAKE_FILE_BASE}.qm
lrelease.input = TRANSLATIONS
lrelease.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += lrelease
+win32:copy_hdr.name = Install ${QMAKE_FILE_IN}
+win32:copy_hdr.commands = type ${QMAKE_FILE_IN} > ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.output = ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.input = HEADERS
+win32:QMAKE_EXTRA_COMPILERS += copy_hdr
+
ICONS = resources/*.png
includes.files = $$HEADERS
#ifndef WIN32
for(int i=0;i<2; i++){
#else
- for(i=0;i<2; i++){
+ for(int i=0;i<2; i++){
#endif
tmp = aRange1[i]; aRange1[i] = aRange2[i]; aRange2[i] = tmp;
}
// QT Includes
// Put Qt includes before the X11 includes which #define the symbol None
// (see SVTK_SpaceMouse.h) to avoid the compilation error.
+#ifndef WIN32
#include <QX11Info>
+#endif
+
#include <QMouseEvent>
#include "SVTK_SpaceMouse.h"
/*!
To handle native Win32 events (from such devices as SpaceMouse)
*/
-bool QVTK_RenderWindowInteractor::winEvent( MSG* msg )
+bool QVTK_RenderWindowInteractor::winEvent( MSG* msg, long* result )
{
// TODO: Implement event handling for SpaceMouse
- return QWidget::winEvent( msg );
+ return QWidget::winEvent( msg, result );
}
#else
if ( aSpaceMouse->isSpaceMouseOn() && xEvent->type == ClientMessage )
{
SVTK_SpaceMouse::MoveEvent anEvent;
- int type = aSpaceMouse->translateEvent( QX11Info::display(), xEvent, &anEvent, 1.0, 1.0 );
+ int type = aSpaceMouse->translateEvent( QX11Info::display(), xEvent, &anEvent, 1.0, 1.0 );
switch ( type )
{
case SVTK_SpaceMouse::SpaceMouseMove:
//! To handle native events (from such devices as SpaceMouse)
#ifdef WIN32
- virtual bool winEvent( MSG* );
+ virtual bool winEvent( MSG*, long* );
#else
virtual bool x11Event( XEvent *e );
#endif
-TEMPLATE = lib
+unix:TEMPLATE = lib
+win32:TEMPLATE = vclib
+
+win32:QMAKE_MOC=$(QTDIR)\bin\moc.exe
DESTDIR = ../../$(CONFIG_ID)/lib
MOC_DIR = ../../moc
OBJECTS_DIR = ../../$(CONFIG_ID)/obj/$$TARGET
INCLUDEPATH = ../../include
-LIBS += -L ../../$(CONFIG_ID)/lib -lQtx
+LIBS += -L../../$(CONFIG_ID)/lib -lQtx
+win32:LIBS *= -L$(QTLIB)
+win32:INCLUDEPATH *= $(QTINC) $(QTINC)\QtCore $(QTINC)\QtGui $(QTINC)\QtXml
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared
-win32:DEFINES += WIN32
+win32:DEFINES += WNT WIN32
DEFINES += STYLE_SALOME_EXPORTS
HEADERS = *.h
SOURCES = *.cxx
+win32:copy_hdr.name = Install ${QMAKE_FILE_IN}
+win32:copy_hdr.commands = type ${QMAKE_FILE_IN} > ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.output = ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.input = HEADERS
+win32:QMAKE_EXTRA_COMPILERS += copy_hdr
+
includes.files = $$HEADERS
includes.path = ../../include
-TEMPLATE = lib
+unix:TEMPLATE = lib
+win32:TEMPLATE = vclib
+
+win32:QMAKE_MOC=$(QTDIR)\bin\moc.exe
DESTDIR = ../../$(CONFIG_ID)/lib
MOC_DIR = ../../moc
CAS_KERNEL = -L$(CASLIB) -lTKernel
INCLUDEPATH = ../../include $${CAS_CPPFLAGS}
-LIBS += -L../../$(CONFIG_ID)/lib -lSUIT $${CAS_KERNEL} -lHTMLService
+LIBS += -L../../$(CONFIG_ID)/lib -lQtx -lSUIT $${CAS_KERNEL} -lHTMLService
+win32:LIBS *= -L$(QTLIB)
+win32:INCLUDEPATH *= $(QTINC) $(QTINC)\QtCore $(QTINC)\QtGui $(QTINC)\QtXml
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared
-win32:DEFINES += WIN32
-DEFINES += TABLE_VIEWER_EXPORTS $(CASDEFINES) OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS
+win32:DEFINES += WNT WIN32
+DEFINES += TABLEVIEWER_EXPORTS $(CASDEFINES) OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS
HEADERS = *.h
lrelease.name = LRELASE ${QMAKE_FILE_IN}
unix:lrelease.commands = $(QTDIR)/bin/lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}/${QMAKE_FILE_BASE}.qm
-win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
+win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_IN} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
unix:lrelease.output = $${GUIResources}/${QMAKE_FILE_BASE}.qm
win32:lrelease.output = $${GUIResources}\\${QMAKE_FILE_BASE}.qm
lrelease.input = TRANSLATIONS
lrelease.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += lrelease
+win32:copy_hdr.name = Install ${QMAKE_FILE_IN}
+win32:copy_hdr.commands = type ${QMAKE_FILE_IN} > ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.output = ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.input = HEADERS
+win32:QMAKE_EXTRA_COMPILERS += copy_hdr
+
ICONS = resources/*.png
+win32:Resource=$$ICONS
+win32:SOURCES+=$$ICONS
+win32:copy_res.name = Install resources ${QMAKE_FILE_IN}
+win32:copy_res.commands = type ${QMAKE_FILE_IN} > ${QMAKE_FILE_OUT}
+win32:copy_res.output = $${GUIResources}\\${QMAKE_FILE_BASE}.png
+win32:copy_res.input = Resource
+win32:QMAKE_EXTRA_COMPILERS += copy_res
+
includes.files = $$HEADERS
includes.path = ../../include
{
bool anEnable = myTable->getSelectedIndexes().count() > 0;
myActionsMap[CopyId]->setEnabled( anEnable );
- myActionsMap[PasteId]->setEnabled( anEnable & myCopyLst.count() > 0 );
+ myActionsMap[PasteId]->setEnabled( anEnable && myCopyLst.count() > 0 );
}
void TableViewer_ViewWindow::onActivated()
-TEMPLATE = lib
+unix:TEMPLATE = lib
+win32:TEMPLATE = vclib
+
+win32:QMAKE_MOC=$(QTDIR)\bin\moc.exe
DESTDIR = ../../$(CONFIG_ID)/lib
MOC_DIR = ../../moc
OBJECTS_DIR = ../../$(CONFIG_ID)/obj/$$TARGET
-VTK_LIBS = -L$$(VTKLIB) -lvtkCommon -lvtkGraphics -lvtkImaging -lvtkFiltering -lvtkIO -lvtkRendering -lvtkHybrid -lvtkParallel -lvtkWidgets -lGL -L/usr/X11R6/lib -lGLU -L/usr/X11R6/lib -lX11 -lXt
+unix:VTK_LIBS = -L$$(VTKLIB) -lvtkCommon -lvtkGraphics -lvtkImaging -lvtkFiltering -lvtkIO -lvtkRendering -lvtkHybrid -lvtkParallel -lvtkWidgets -lGL -L/usr/X11R6/lib -lGLU -L/usr/X11R6/lib -lX11 -lXt
+win32:VTK_LIBS = -L$$(VTKLIB) -lvtkCommon -lvtkGraphics -lvtkImaging -lvtkFiltering -lvtkIO -lvtkRendering -lvtkHybrid -lvtkParallel -lvtkWidgets
CAS_CPPFLAGS = $(CASINC)
INCLUDEPATH += ../../include $$(VTKINC) $${CAS_CPPFLAGS} ../Qtx ../SUIT
LIBS += -L../../$(CONFIG_ID)/lib -lQtx -lSUIT $${VTK_LIBS} $${CAS_KERNEL}
+win32:LIBS *= -L$(QTLIB)
+win32:INCLUDEPATH *= $(QTINC) $(QTINC)\QtCore $(QTINC)\QtGui $(QTINC)\QtXml
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared
-win32:DEFINES += WIN32
+win32:DEFINES += WNT WIN32
DEFINES += VTKVIEWER_EXPORTS $(CASDEFINES) OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS
HEADERS = VTKViewer.h
SOURCES += VTKViewer_ConvexTool.cxx
SOURCES += VTKViewer_ViewWindow.cxx
-message ( "Sources: $$SOURCES " )
+unix:message ( "Sources: $$SOURCES " )
TRANSLATIONS = resources/VTKViewer_images.ts \
resources/VTKViewer_msg_en.ts
lrelease.name = LRELASE ${QMAKE_FILE_IN}
unix:lrelease.commands = $(QTDIR)/bin/lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}/${QMAKE_FILE_BASE}.qm
-win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_NAME} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
+win32:lrelease.commands = $(QTDIR)\\bin\\lrelease ${QMAKE_FILE_IN} -qm $${GUIResources}\\${QMAKE_FILE_BASE}.qm
unix:lrelease.output = $${GUIResources}/${QMAKE_FILE_BASE}.qm
win32:lrelease.output = $${GUIResources}\\${QMAKE_FILE_BASE}.qm
lrelease.input = TRANSLATIONS
lrelease.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += lrelease
+win32:copy_hdr.name = Install ${QMAKE_FILE_IN}
+win32:copy_hdr.commands = type ${QMAKE_FILE_IN} > ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.output = ../../include/${QMAKE_FILE_BASE}.h
+win32:copy_hdr.input = HEADERS
+win32:QMAKE_EXTRA_COMPILERS += copy_hdr
+
ICONS = resources/*.png
+win32:SOURCES+=$$ICONS
+win32:Resource=$$ICONS
+win32:copy_res.name = Install resources ${QMAKE_FILE_IN}
+win32:copy_res.commands = type ${QMAKE_FILE_IN} > ${QMAKE_FILE_OUT}
+win32:copy_res.output = $${GUIResources}\\${QMAKE_FILE_BASE}.png
+win32:copy_res.input = Resource
+win32:QMAKE_EXTRA_COMPILERS += copy_res
+
includes.files = $$HEADERS
includes.path = ../../include