KoTemplates.h
1/*
2 This file is part of the KDE project
3 Copyright (C) 2000 Werner Trobin <trobin@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef koTemplates_h
22#define koTemplates_h
23
24#include <tqptrlist.h>
25#include <tqstringlist.h>
26#include <tqpixmap.h>
27#include <koffice_export.h>
28
29class TDEInstance;
30
32class KOFFICECORE_EXPORT KoTemplate {
33
34public:
35 KoTemplate(const TQString &name,
36 const TQString &description=TQString(),
37 const TQString &file=TQString(),
38 const TQString &picture=TQString(),
39 const TQString &fileName=TQString(),
40 const TQString &_measureSystem=TQString(),
41 bool hidden=false, bool touched=false);
42 ~KoTemplate() {}
43
44 TQString name() const { return m_name; }
45 TQString description() const { return m_descr; };
46 TQString file() const { return m_file; }
47 TQString picture() const { return m_picture; }
48 TQString fileName() const { return m_fileName; }
49 const TQPixmap &loadPicture( TDEInstance* instance );
50
51 bool isHidden() const { return m_hidden; }
52 void setHidden(bool hidden=true) { m_hidden=hidden; m_touched=true; }
53
54 bool touched() const { return m_touched; }
55
56 TQString measureSystem() const { return m_measureSystem; }
57 void setMeasureSystem(const TQString& system) { m_measureSystem = system; }
58
59private:
60 TQString m_name, m_descr, m_file, m_picture, m_fileName;
61 bool m_hidden;
62 mutable bool m_touched;
63 bool m_cached;
64 TQPixmap m_pixmap;
65 TQString m_measureSystem;
66};
67
68
69class KOFFICECORE_EXPORT KoTemplateGroup {
70
71public:
72 KoTemplateGroup(const TQString &name,
73 const TQString &dir=TQString(),
74 int _sortingWeight=0,
75 bool touched=false);
76 ~KoTemplateGroup() {}
77
78 TQString name() const { return m_name; }
79 TQStringList dirs() const { return m_dirs; }
80 void addDir(const TQString &dir) { m_dirs.append(dir); m_touched=true; }
81 int sortingWeight() const { return m_sortingWeight; }
82 void setSortingWeight(int weight) { m_sortingWeight = weight; }
84 bool isHidden() const;
86 void setHidden(bool hidden=true) const;
87
88 KoTemplate *first() { return m_templates.first(); }
89 KoTemplate *next() { return m_templates.next(); }
90 KoTemplate *last() { return m_templates.last(); }
91 KoTemplate *prev() { return m_templates.prev(); }
92 KoTemplate *current() { return m_templates.current(); }
93
94 bool add(KoTemplate *t, bool force=false, bool touch=true);
95 KoTemplate *find(const TQString &name) const;
96
97 bool touched() const { return m_touched; }
98
99private:
100 TQString m_name;
101 TQStringList m_dirs;
102 TQPtrList<KoTemplate> m_templates;
103 mutable bool m_touched;
104 int m_sortingWeight;
105};
106
107
108class KoTemplateTree {
109
110public:
111 KoTemplateTree(const TQCString &templateType, TDEInstance *instance,
112 bool readTree=false);
113 ~KoTemplateTree() {}
114
115 TQCString templateType() const { return m_templateType; }
116 TDEInstance *instance() const { return m_instance; }
117 void readTemplateTree();
118 void writeTemplateTree();
119
120 KoTemplateGroup *first() { return m_groups.first(); }
121 KoTemplateGroup *next() { return m_groups.next(); }
122 KoTemplateGroup *last() { return m_groups.last(); }
123 KoTemplateGroup *prev() { return m_groups.prev(); }
124 KoTemplateGroup *current() { return m_groups.current(); }
125
126 void add(KoTemplateGroup *g);
127 KoTemplateGroup *find(const TQString &name) const;
128
129 KoTemplateGroup *defaultGroup() const { return m_defaultGroup; }
130 KoTemplate *defaultTemplate() const { return m_defaultTemplate; }
131
132private:
133 void readGroups();
134 void readTemplates();
135 void writeTemplate(KoTemplate *t, KoTemplateGroup *group,
136 const TQString &localDir);
137
138 TQCString m_templateType;
139 TDEInstance *m_instance;
140 TQPtrList<KoTemplateGroup> m_groups;
141 KoTemplateGroup *m_defaultGroup;
142 KoTemplate *m_defaultTemplate;
143};
144
145
146namespace KoTemplates {
147TQString stripWhiteSpace(const TQString &string);
148}
149
150#endif
TDEAction * next(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * find(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
const char * name(StdAction id)