MagicSmoke  $VERSION$
templates.h
Go to the documentation of this file.
1 //
2 // C++ Interface: templates
3 //
4 // Description:
5 //
6 //
7 // Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2008-2011
8 //
9 // Copyright: See README/COPYING.GPL files that come with this distribution
10 //
11 //
12 
13 #ifndef MAGICSMOKE_TEMPLATES_H
14 #define MAGICSMOKE_TEMPLATES_H
15 
16 #include <QString>
17 #include <QList>
18 #include <functional>
19 
20 #ifndef MSIFACE_EXPORT
21 #define MSIFACE_EXPORT Q_DECL_IMPORT
22 #endif
23 
26 {
27  public:
29  MTemplate();
30 
32  MTemplate(QString fn);
33 
35  MTemplate(const MTemplate&)=default;
36 
38  MTemplate& operator=(const MTemplate&)=default;
39 
41  void setFile(const QString&);
42 
44  QString cacheFileName()const;
45 
47  QString fileName()const;
48 
50  QString completeFileName()const;
51 
53  QString baseName()const;
54 
56  QString extension()const;
57 
59  QString variantID()const;
60 
62  QString checksum()const;
63 
65  QString description()const;
66 
68  bool isValid()const;
69 
71  QString targetExtension()const;
72 
74  bool isOdf()const;
75 
77  bool isLabel()const;
78 
80  bool isZip()const;
81 
83  bool isHtml()const;
84 
86  QString flags()const{return m_flags;}
87 
89  enum Type{
91  UnknownTemplate=0,
93  OdtTemplate=1,
95  OdsTemplate=2,
97  OdpTemplate=4,
99  OdgTemplate=8,
101  OdbTemplate=0x10,
103  OdfTemplateMask=0xff,
105  LabelTemplate=0x100,
107  ZipTemplate=0x200,
109  HtmlTemplate=0x400,
111  MimeTemplate=0x800
112  };
113  Q_DECLARE_FLAGS(Types,Type)
114 
115 
116  Type type()const;
117 
119  static QStringList legalBaseNames();
120 
122  static Types legalTypes(QString);
123 
125  static QStringList legalSuffixes(QString);
126 
127  typedef std::function<MTemplate(const QList<MTemplate>&)>TemplateChoserFunction;
128 
131  static void setTemplateChoiceFunction(const TemplateChoserFunction&);
132 
133  protected:
134  friend class MTemplateStore;
135  friend class MTemplateChoice;
142  MTemplate(QString fn,QString chk,QString dsc,QString flg);
143  private:
144  QString m_fname,m_checksum,m_descr,m_flags;
145 };
147 
149 class MSIFACE_EXPORT MTemplateStore
150 {
151  protected:
152  friend class MSInterface;
153  friend class MTemplateEditor;
155  MTemplateStore(QString);
156 
158  bool setTemplate(QString templatename,QString localfile);
159 
161  bool setTemplateDescription(QString templatename,QString description);
162 
164  bool setTemplateFlags(QString templatename,QString flags);
165 
167  bool deleteTemplate(QString);
168 
170  void updateTemplates(bool force);
171 
172  private:
174  MTemplateStore()=delete;
175 
177  bool retrieveFile(QString,QString);
178 
179  public:
184  MTemplate getTemplate(QString base,bool useFirst=false);
187  MTemplate getTemplateByFile(QString full);
188 
190  QList<MTemplate> allTemplates();
191 
192  private:
193  QString profileid;
194 };
195 
196 #endif
this class wraps a single template
Definition: templates.h:25
gives the user a choice of template variants; used by MTemplateStore only!
Definition: templatedlg.h:28
std::function< MTemplate(const QList< MTemplate > &)> TemplateChoserFunction
Definition: templates.h:127
Type
template type; currently only ODF and Labels are known
Definition: templates.h:89
Q_DECLARE_OPERATORS_FOR_FLAGS(MLocalFormat::MoneyFlags)
lets the user add and remove templates and variants to/from the database; used by MWebRequest! ...
Definition: templatedlg.h:44
this class implements the storage end of the template subsystem, its only instance exists in the webr...
Definition: templates.h:149
QString flags() const
returns the flags of this template
Definition: templates.h:86
#define MSIFACE_EXPORT
Definition: templates.h:21
the MagicSmoke specific interface class - enhances the basic interface by some functionality needed i...
Definition: msinterface.h:29