summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmlibraryobject.h
blob: e3699c8fb2478f7c4ba9af44442a49684fc8a790 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//-*-C++-*-
/*
**************************************************************************
                                 description
                             --------------------
    copyright            : (C) 2002 by Luis Carvalho
    email                : lpassos@mail.telepac.pt
**************************************************************************

**************************************************************************
*                                                                        *
*  This program is free software; you can redistribute it and/or modify  *
*  it under the terms of the GNU General Public License as published by  *
*  the Free Software Foundation; either version 2 of the License, or     *
*  (at your option) any later version.                                   *
*                                                                        *
**************************************************************************/

#ifndef PMLIBRARYOBJECT_H
#define PMLIBRARYOBJECT_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <qstring.h>
#include <qmap.h>
#include <qvaluelist.h>
#include <kstaticdeleter.h>
#include <qstringlist.h>

class KURL;
class KArchive;
class KTar;
class QImage;

/**
 * This class implements a library object.
 *
 * A library object has a name, a textual description, a graphical 
 * preview and the object data, of course. It also contains a collection of
 * keywords.
 *
 * When an instance of PMLibraryObject is created, the objects description is
 * loaded.
 *
 * The graphical preview and the objects data are loaded only if needed.
 *
 */
class PMLibraryObject
{
public:
   /** 
    * Constructor for the library object. Creates an empty library object. 
    */
   PMLibraryObject( );
   /** 
    * Constructor for the library object. 
    * Loads the object data from the specified library object file.
    */
   PMLibraryObject( KURL u );
   /** 
    * Destructor 
    */
   ~PMLibraryObject( );

   /** 
    * Name of the library object. 
    */
   QString name( ) const { return m_name; }
   /** 
    * Textual description of the library object. 
    */
   QString description( ) const { return m_description; }
   /** 
    * List of keywords for search of the library object. 
    */
   QString keywords( ) const { return m_keywords; }
   /** 
    * Graphical Preview. 
    */
   QImage* preview( );
   /**
    * True is the preview has been loaded.
    */
   bool isPreviewLoaded( ) const { return m_previewLoaded; }
   /** 
    * Objects for the scene 
    */
   QByteArray* objects( );
   bool areObjectsLoaded( ) const { return m_objectsLoaded; }

   /** 
    * Set the library object name 
    */
   void setName( const QString& str );
   /** 
    * Set the library object description 
    */
   void setDescription( const QString& str );
   /** 
    * Set the library object keywords 
    */
   void setKeywords( const QString& str );
   /** 
    * Set the preview image 
    */
   void setPreview( const QImage& img );
   /** 
    * Set the object data 
    */
   void setObjects( const QByteArray& obj );

   /** 
    * Save the library object to a file 
    */
   void save( const QString& fileName );

private:
   void loadLibraryInfo( );
   void saveLibraryInfo( );
   void savePreview( );
   void saveObjects( );

   bool        m_previewLoaded;
   bool        m_objectsLoaded;
   QString     m_name;
   QString     m_description;
   QString     m_keywords;
   KTar*       m_data;
   QImage*     m_preview;
   QByteArray* m_objects;
   QStringList m_extraFiles;
};

#endif