Salome HOME
Update copyrights 2014.
[samples/light.git] / src / LIGHTGUI / LIGHTGUI_DataModel.h
1 // Copyright (C) 2005-2014  OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // LIGHT : sample (no-corba-engine) SALOME module
21 // File   : LIGHTGUI_DataModel.h
22 // Author : Julia DOROVSKIKH
23 //
24 #ifndef LIGHTGUI_DATAMODEL_H
25 #define LIGHTGUI_DATAMODEL_H
26
27 #include "LIGHTGUI_Exports.hxx"
28
29 #include <LightApp_DataModel.h>
30
31 class CAM_Module;
32 class LightApp_Study;
33 class LightApp_DataObject;
34 class LIGHTGUI_DataObject;
35
36 class LIGHT_EXPORT LIGHTGUI_DataModel : public LightApp_DataModel
37 {
38   Q_OBJECT
39
40 public:
41   LIGHTGUI_DataModel( CAM_Module* theModule );
42   virtual ~LIGHTGUI_DataModel();
43
44   virtual bool         open( const QString&, CAM_Study*, QStringList );
45   virtual bool         save( QStringList& );
46   virtual bool         saveAs( const QString&, CAM_Study*, QStringList& );
47   virtual bool         close();
48   virtual bool         create( CAM_Study* );
49
50   virtual bool         isModified() const;
51   virtual bool         isSaved() const;
52
53   virtual void         update( LightApp_DataObject* = 0, LightApp_Study* = 0 );
54
55   bool                 loadFile( const QString&, CAM_Study* = 0 );
56   bool                 dumpFile( const QString& = QString() );
57   QString              fileName() const;
58
59   QString              getLineText( const int ) const;
60   bool                 setLineText( const int, const QString& );
61   bool                 insertLineBefore( const int, const QString& );
62   bool                 deleteTextLine( const int );
63
64   void                 clearAll();
65
66   int                  generateId();
67
68   static int           id( const QString& );
69   static QString       entry( const int );
70
71   int                  lineNb( const QString& );
72   int                  lineNb( const int );
73
74   QList<int>           getIds() const;
75
76 private:
77   void                 buildTree( SUIT_DataObject*, const QStringList& );
78   LIGHTGUI_DataObject* findObject( const int ) const;
79
80 private:
81   QString              myFileName;
82   QString              myStudyURL;
83   int                  myMaxId;
84 };
85
86 #endif // LIGHTGUI_DATAMODEL_H