QCodeEdit 2.2
lib/snippets/qsnippetmanager.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2006-2009 fullmetalcoder <fullmetalcoder@hotmail.fr>
00004 **
00005 ** This file is part of the Edyuk project <http://edyuk.org>
00006 ** 
00007 ** This file may be used under the terms of the GNU General Public License
00008 ** version 3 as published by the Free Software Foundation and appearing in the
00009 ** file GPL.txt included in the packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ****************************************************************************/
00015 
00016 #ifndef _QSNIPPET_MANAGER_H_
00017 #define _QSNIPPET_MANAGER_H_
00018 
00019 #include "qce-config.h"
00020 
00026 #include <QStringList>
00027 
00028 class QSnippet;
00029 class QSnippetPatternLoader;
00030 
00031 class QCE_EXPORT QSnippetManager : public QObject
00032 {
00033     Q_OBJECT
00034     
00035     public:
00036         QSnippetManager(QObject *p = 0);
00037         virtual ~QSnippetManager();
00038         
00039         int snippetCount() const;
00040         QSnippet* snippet(int i) const;
00041         void removeSnippet(int i, bool cleanup = true);
00042         
00043         bool loadSnippetFromFile(const QString& file, const QString& type = QString());
00044         bool loadSnippetFromString(const QString& name, const QString& pattern, const QString& type = QString());
00045         
00046         void saveSnippetsToDirectory(const QString& path);
00047         void loadSnippetsFromDirectory(const QString& path);
00048         
00049     public slots:
00050         void addSnippet(QSnippet *s);
00051         void removeSnippet(QSnippet *s);
00052         
00053         void addPatternLoader(QSnippetPatternLoader *pl);
00054         void removePatternLoader(QSnippetPatternLoader *pl);
00055         
00056     signals:
00057         void snippetAdded(QSnippet *s);
00058         
00059         void snippetRemoved(int i);
00060         void snippetRemoved(QSnippet *s);
00061         
00062     private:
00063         QString typeGuess(const QString& pattern) const;
00064         QSnippetPatternLoader* patternLoader(const QString& type) const;
00065         
00066         QList<QSnippet*> m_snippets;
00067         QList<QSnippetPatternLoader*> m_patternLoaders;
00068 };
00069 
00070 #endif // !_SNIPPETS_H_