lib Library API Documentation

koTemplates.h

00001 /*
00002    This file is part of the KDE project
00003    Copyright (C) 2000 Werner Trobin <trobin@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #ifndef koTemplates_h
00022 #define koTemplates_h
00023 
00024 #include <qptrlist.h>
00025 #include <qstringlist.h>
00026 #include <qpixmap.h>
00027 
00028 class KInstance;
00029 
00031 class KoTemplate {
00032 
00033 public:
00034     KoTemplate(const QString &name,
00035                const QString &description=QString::null,
00036            const QString &file=QString::null,
00037            const QString &picture=QString::null,
00038            const QString &fileName=QString::null,
00039            bool hidden=false, bool touched=false);
00040     ~KoTemplate() {}
00041 
00042     QString name() const { return m_name; }
00043     QString description() const { return m_descr; };
00044     QString file() const { return m_file; }
00045     QString picture() const { return m_picture; }
00046     QString fileName() const { return m_fileName; }
00047     const QPixmap &loadPicture( KInstance* instance );
00048 
00049     bool isHidden() const { return m_hidden; }
00050     void setHidden(bool hidden=true) { m_hidden=hidden; m_touched=true; }
00051 
00052     bool touched() const { return m_touched; }
00053 
00054 private:
00055     QString m_name, m_descr, m_file, m_picture, m_fileName;
00056     bool m_hidden;
00057     mutable bool m_touched;
00058     bool m_cached;
00059     QPixmap m_pixmap;
00060 };
00061 
00062 
00063 class KoTemplateGroup {
00064 
00065 public:
00066     KoTemplateGroup(const QString &name,
00067             const QString &dir=QString::null,
00068             bool touched=false);
00069     ~KoTemplateGroup() {}
00070 
00071     QString name() const { return m_name; }
00072     QStringList dirs() const { return m_dirs; }
00073     void addDir(const QString &dir) { m_dirs.append(dir); m_touched=true; }
00074 
00076     bool isHidden() const;
00078     void setHidden(bool hidden=true) const;
00079 
00080     KoTemplate *first() { return m_templates.first(); }
00081     KoTemplate *next() { return m_templates.next(); }
00082     KoTemplate *last() { return m_templates.last(); }
00083     KoTemplate *prev() { return m_templates.prev(); }
00084     KoTemplate *current() { return m_templates.current(); }
00085 
00086     bool add(KoTemplate *t, bool force=false, bool touch=true);
00087     KoTemplate *find(const QString &name) const;
00088 
00089     bool touched() const { return m_touched; }
00090 
00091 private:
00092     QString m_name;
00093     QStringList m_dirs;
00094     QPtrList<KoTemplate> m_templates;
00095     mutable bool m_touched;
00096 };
00097 
00098 
00099 class KoTemplateTree {
00100 
00101 public:
00102     KoTemplateTree(const QCString &templateType, KInstance *instance,
00103            bool readTree=false);
00104     ~KoTemplateTree() {}
00105 
00106     QCString templateType() const { return m_templateType; }
00107     KInstance *instance() const { return m_instance; }
00108     void readTemplateTree();
00109     void writeTemplateTree();
00110 
00111     KoTemplateGroup *first() { return m_groups.first(); }
00112     KoTemplateGroup *next() { return m_groups.next(); }
00113     KoTemplateGroup *last() { return m_groups.last(); }
00114     KoTemplateGroup *prev() { return m_groups.prev(); }
00115     KoTemplateGroup *current() { return m_groups.current(); }
00116 
00117     void add(KoTemplateGroup *g);
00118     KoTemplateGroup *find(const QString &name) const;
00119 
00120     KoTemplateGroup *defaultGroup() const { return m_defaultGroup; }
00121     KoTemplate *defaultTemplate() const { return m_defaultTemplate; }
00122 
00123 private:
00124     void readGroups();
00125     void readTemplates();
00126     void writeTemplate(KoTemplate *t, KoTemplateGroup *group,
00127                const QString &localDir);
00128 
00129     QCString m_templateType;
00130     KInstance *m_instance;
00131     QPtrList<KoTemplateGroup> m_groups;
00132     KoTemplateGroup *m_defaultGroup;
00133     KoTemplate *m_defaultTemplate;
00134 };
00135 
00136 
00137 namespace KoTemplates {
00138 QString stripWhiteSpace(const QString &string);
00139 }
00140 
00141 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:40:08 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003