F:/KPlato/koffice/libs/kofficecore/KoTemplates.h

Aller à la documentation de ce fichier.
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., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef koTemplates_h
00022 #define koTemplates_h
00023 
00024 #include <q3ptrlist.h>
00025 #include <QStringList>
00026 #include <QPixmap>
00027 #include <koffice_export.h>
00028 
00029 class KInstance;
00030 
00032 class KOFFICECORE_EXPORT KoTemplate {
00033 
00034 public:
00035     KoTemplate(const QString &name,
00036                const QString &description=QString::null,
00037                const QString &file=QString::null,
00038                const QString &picture=QString::null,
00039                const QString &fileName=QString::null,
00040                const QString &_measureSystem=QString::null,
00041                bool hidden=false, bool touched=false);
00042     ~KoTemplate() {}
00043 
00044     QString name() const { return m_name; }
00045     QString description() const { return m_descr; };
00046     QString file() const { return m_file; }
00047     QString picture() const { return m_picture; }
00048     QString fileName() const { return m_fileName; }
00049     const QPixmap &loadPicture( KInstance* instance );
00050 
00051     bool isHidden() const { return m_hidden; }
00052     void setHidden(bool hidden=true) { m_hidden=hidden; m_touched=true; }
00053 
00054     bool touched() const { return m_touched; }
00055 
00056     QString measureSystem() const { return m_measureSystem; }
00057     void setMeasureSystem(const QString& system) { m_measureSystem = system; }
00058 
00059 private:
00060     QString m_name, m_descr, m_file, m_picture, m_fileName;
00061     bool m_hidden;
00062     mutable bool m_touched;
00063     bool m_cached;
00064     QPixmap m_pixmap;
00065     QString m_measureSystem;
00066 };
00067 
00068 
00069 class KOFFICECORE_EXPORT KoTemplateGroup {
00070 
00071 public:
00072     KoTemplateGroup(const QString &name,
00073                     const QString &dir=QString::null,
00074                     int _sortingWeight=0,
00075                     bool touched=false);
00076     ~KoTemplateGroup() {}
00077 
00078     QString name() const { return m_name; }
00079     QStringList dirs() const { return m_dirs; }
00080     void addDir(const QString &dir) { m_dirs.append(dir); m_touched=true; }
00081     int sortingWeight() const { return m_sortingWeight; }
00082     void setSortingWeight(int weight) { m_sortingWeight = weight; }
00084     bool isHidden() const;
00086     void setHidden(bool hidden=true) const;
00087 
00088     KoTemplate *first() { return m_templates.first(); }
00089     KoTemplate *next() { return m_templates.next(); }
00090     KoTemplate *last() { return m_templates.last(); }
00091     KoTemplate *prev() { return m_templates.prev(); }
00092     KoTemplate *current() { return m_templates.current(); }
00093 
00094     bool add(KoTemplate *t, bool force=false, bool touch=true);
00095     KoTemplate *find(const QString &name) const;
00096 
00097     bool touched() const { return m_touched; }
00098 
00099 private:
00100     QString m_name;
00101     QStringList m_dirs;
00102     Q3PtrList<KoTemplate> m_templates;
00103     mutable bool m_touched;
00104     int m_sortingWeight;
00105 };
00106 
00107 
00108 class KOFFICECORE_EXPORT KoTemplateTree {
00109 
00110 public:
00111     KoTemplateTree(const QByteArray &templateType, KInstance *instance,
00112                    bool readTree=false);
00113     ~KoTemplateTree() {}
00114 
00115     QByteArray templateType() const { return m_templateType; }
00116     KInstance *instance() const { return m_instance; }
00117     void readTemplateTree();
00118     void writeTemplateTree();
00119 
00120     KoTemplateGroup *first() { return m_groups.first(); }
00121     KoTemplateGroup *next() { return m_groups.next(); }
00122     KoTemplateGroup *last() { return m_groups.last(); }
00123     KoTemplateGroup *prev() { return m_groups.prev(); }
00124     KoTemplateGroup *current() { return m_groups.current(); }
00125 
00126     void add(KoTemplateGroup *g);
00127     KoTemplateGroup *find(const QString &name) const;
00128 
00129     KoTemplateGroup *defaultGroup() const { return m_defaultGroup; }
00130     KoTemplate *defaultTemplate() const { return m_defaultTemplate; }
00131 
00132 private:
00133     void readGroups();
00134     void readTemplates();
00135     void writeTemplate(KoTemplate *t, KoTemplateGroup *group,
00136                        const QString &localDir);
00137 
00138     QByteArray m_templateType;
00139     KInstance *m_instance;
00140     Q3PtrList<KoTemplateGroup> m_groups;
00141     KoTemplateGroup *m_defaultGroup;
00142     KoTemplate *m_defaultTemplate;
00143 };
00144 
00145 
00146 namespace KoTemplates {
00147 KOFFICECORE_EXPORT QString trimmed(const QString &string);
00148 }
00149 
00150 #endif

Généré le Wed Nov 22 23:41:04 2006 pour KPlato par  doxygen 1.5.1-p1