Salome HOME
dc6d4dba47359af469703cee65525cf8e21885b1
[samples/light.git] / src / LIGHTGUI / LIGHTGUI_DataModel.h
1 // Copyright (C) 2005-2020  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 // File   : LIGHTGUI_DataModel.h
20 // Author : Julia DOROVSKIKH
21
22 #ifndef LIGHTGUI_DATAMODEL_H
23 #define LIGHTGUI_DATAMODEL_H
24
25 #include "LIGHTGUI_Exports.h"
26
27 #include <LightApp_DataModel.h>
28
29 class LIGHTGUI_DataObject;
30
31 class LIGHT_EXPORT LIGHTGUI_DataModel : public LightApp_DataModel
32 {
33   Q_OBJECT
34
35 public:
36   LIGHTGUI_DataModel( CAM_Module* theModule );
37   virtual ~LIGHTGUI_DataModel();
38
39   virtual bool         open( const QString&, CAM_Study*, QStringList );
40   virtual bool         save( QStringList& );
41   virtual bool         saveAs( const QString&, CAM_Study*, QStringList& );
42   virtual bool         close();
43   virtual bool         create( CAM_Study* );
44
45   virtual bool         isModified() const;
46   virtual bool         isSaved() const;
47
48   virtual void         update( LightApp_DataObject* = 0, LightApp_Study* = 0 );
49
50   bool                 loadFile( const QString&, CAM_Study* = 0 );
51   bool                 dumpFile( const QString& = QString() );
52   QString              fileName() const;
53
54   QString              getLineText( const int ) const;
55   bool                 setLineText( const int, const QString& );
56   bool                 insertLineBefore( const int, const QString& );
57   bool                 deleteTextLine( const int );
58
59   void                 clearAll();
60
61   int                  generateId();
62
63   static int           id( const QString& );
64   static QString       entry( const int );
65
66   int                  lineNb( const QString& );
67   int                  lineNb( const int );
68
69   QList<int>           getIds() const;
70
71 private:
72   void                 buildTree( SUIT_DataObject*, const QStringList& );
73   LIGHTGUI_DataObject* findObject( const int ) const;
74
75 private:
76   QString              myFileName;
77   QString              myStudyURL;
78   int                  myMaxId;
79 };
80
81 #endif // LIGHTGUI_DATAMODEL_H