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 bool hidden=false, bool touched=false); 00039 ~KoTemplate() {} 00040 00041 QString name() const { return m_name; } 00042 QString description() const { return m_descr; }; 00043 QString file() const { return m_file; } 00044 QString picture() const { return m_picture; } 00045 const QPixmap &loadPicture(); 00046 00047 bool isHidden() const { return m_hidden; } 00048 void setHidden(bool hidden=true) { m_hidden=hidden; m_touched=true; } 00049 00050 bool touched() const { return m_touched; } 00051 00052 private: 00053 QString m_name, m_descr, m_file, m_picture; 00054 bool m_hidden; 00055 mutable bool m_touched; 00056 bool m_cached; 00057 QPixmap m_pixmap; 00058 }; 00059 00060 00061 class KoTemplateGroup { 00062 00063 public: 00064 KoTemplateGroup(const QString &name, 00065 const QString &dir=QString::null, 00066 bool touched=false); 00067 ~KoTemplateGroup() {} 00068 00069 QString name() const { return m_name; } 00070 QStringList dirs() const { return m_dirs; } 00071 void addDir(const QString &dir) { m_dirs.append(dir); m_touched=true; } 00072 00073 // If all children are hidden, we are hidden too 00074 bool isHidden() const; 00075 // if we should hide, we hide all the children 00076 void setHidden(bool hidden=true) const; 00077 00078 KoTemplate *first() { return m_templates.first(); } 00079 KoTemplate *next() { return m_templates.next(); } 00080 KoTemplate *last() { return m_templates.last(); } 00081 KoTemplate *prev() { return m_templates.prev(); } 00082 KoTemplate *current() { return m_templates.current(); } 00083 00084 bool add(KoTemplate *t, bool force=false, bool touch=true); 00085 KoTemplate *find(const QString &name) const; 00086 00087 bool touched() const { return m_touched; } 00088 00089 private: 00090 QString m_name; 00091 QStringList m_dirs; 00092 QPtrList<KoTemplate> m_templates; 00093 mutable bool m_touched; 00094 }; 00095 00096 00097 class KoTemplateTree { 00098 00099 public: 00100 KoTemplateTree(const QCString &templateType, KInstance *instance, 00101 bool readTree=false); 00102 ~KoTemplateTree() {} 00103 00104 QCString templateType() const { return m_templateType; } 00105 KInstance *instance() const { return m_instance; } 00106 void readTemplateTree(); 00107 void writeTemplateTree(); 00108 00109 KoTemplateGroup *first() { return m_groups.first(); } 00110 KoTemplateGroup *next() { return m_groups.next(); } 00111 KoTemplateGroup *last() { return m_groups.last(); } 00112 KoTemplateGroup *prev() { return m_groups.prev(); } 00113 KoTemplateGroup *current() { return m_groups.current(); } 00114 00115 void add(KoTemplateGroup *g); 00116 KoTemplateGroup *find(const QString &name) const; 00117 00118 KoTemplateGroup *defaultGroup() const { return m_defaultGroup; } 00119 00120 private: 00121 void readGroups(); 00122 void readTemplates(); 00123 void writeTemplate(KoTemplate *t, KoTemplateGroup *group, 00124 const QString &localDir); 00125 00126 QCString m_templateType; 00127 KInstance *m_instance; 00128 QPtrList<KoTemplateGroup> m_groups; 00129 KoTemplateGroup *m_defaultGroup; 00130 }; 00131 00132 00133 namespace KoTemplates { 00134 QString stripWhiteSpace(const QString &string); 00135 } 00136 00137 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Nov 17 06:54:18 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003