UIProject.h 3.48 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 *	(c) LSIIT, UMR CNRS/UdS
 *	Authors: F. Larue.
 *
 *	See licence.txt for additional information.
 */


#ifndef PROJECT_H
#define PROJECT_H




#include "UIDataDefs.h"
#include <QtCore>
17 18
class UIDATA_API GenericUIData;
template <typename T> class UIDATA_API UIData;
19 20


21
class UIDATA_API UIProject
22
{
Frédéric Larue's avatar
Frédéric Larue committed
23 24
    using UIDataMap = QMap<QString,GenericUIData*>;

Frédéric Larue's avatar
Frédéric Larue committed
25 26 27
    QString                             m_FileFullPath;
    QString                             m_FileBaseName;
    QString                             m_FileExtension;
28
    QString                             m_FileName;
Frédéric Larue's avatar
Frédéric Larue committed
29 30
    QString                             m_Directory;

31
    QString                             m_Name;
Frédéric Larue's avatar
Frédéric Larue committed
32
    UIDataMap                           m_ItemByNames;
33 34 35

    void                                EnsureUniqueNameFor( GenericUIData* data );

Frédéric Larue's avatar
Frédéric Larue committed
36 37
    void                                SetFullPath( const QString& path );

38
public:
39
    inline                              UIProject( const QString &name ) : m_Name(name) {}
40
    virtual                             ~UIProject();
41

42
    inline const QString&               Name() const                                    { return m_Name; }
43
    inline void                         SetName( const QString &name )                  { m_Name = name; OnRenaming(name); }
44

45 46 47
    void                                Rename( GenericUIData* data, const QString& newFileName );
    bool                                Add( GenericUIData* data );
    void                                Remove( GenericUIData* data );
48
    void                                RemoveAll();
49 50
    void                                RemoveAndDelete( GenericUIData* data );
    void                                RemoveAndDeleteAll();
Frédéric Larue's avatar
Frédéric Larue committed
51
    GenericUIData*                      GetByFilename( const QString& filename );
52
    GenericUIData*                      GetByContent( const void* content );
Frédéric Larue's avatar
Frédéric Larue committed
53
    inline const UIDataMap&             GetAll() const                                  { return m_ItemByNames; }
54

55
    virtual void                        OnRenaming( const QString& newProjectName )     {}
56 57 58
    virtual void                        OnAddingData( GenericUIData *data )             {}
    virtual void                        OnRemovingData( GenericUIData *data )           {}
    virtual void                        OnRenamingData( GenericUIData* data,
59
                                                        const QString& oldFileName,
60
                                                        const QString& newFileName )    {}
61
    virtual void                        OnDeletingData( GenericUIData *data )           {}
62

Frédéric Larue's avatar
Frédéric Larue committed
63 64 65 66
    inline const QString&               GetSaveDir() const                              { return m_Directory; }
    inline const QString&               GetFileBaseName() const                         { return m_FileBaseName; }
    inline const QString&               GetFileExtension() const                        { return m_FileExtension; }
    inline const QString&               GetFileFullPath() const                         { return m_FileFullPath; }
67
    inline QString                      GetFileName() const                             { return m_FileName; }
Frédéric Larue's avatar
Frédéric Larue committed
68 69 70 71

    bool                                Save( const QString& fullPath );
    bool                                Load( const QString& fullPath );

Frédéric Larue's avatar
Frédéric Larue committed
72
    virtual bool                        OnSaving( const QString& fullPath )             { return true; }
Frédéric Larue's avatar
Frédéric Larue committed
73
    virtual bool                        OnLoading( const QString& fullPath )            { return true; }
74 75 76 77 78 79
};




#endif // PROJECT_H