1 /**************************************************************************
2 ** This file is part of LiteIDE
3 **
4 ** Copyright (c) 2011-2019 LiteIDE. All rights reserved.
5 **
6 ** This library is free software; you can redistribute it and/or
7 ** modify it under the terms of the GNU Lesser General Public
8 ** License as published by the Free Software Foundation; either
9 ** version 2.1 of the License, or (at your option) any later version.
10 **
11 ** This library is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 ** Lesser General Public License for more details.
15 **
16 ** In addition, as a special exception,  that plugins developed for LiteIDE,
17 ** are allowed to remain closed sourced and can be distributed under any license .
18 ** These rights are included in the file LGPL_EXCEPTION.txt in this package.
19 **
20 **************************************************************************/
21 // Module: mimetype.h
22 // Creator: visualfc <visualfc@gmail.com>
23 
24 #ifndef LITEAPI_MIMETYPE_H
25 #define LITEAPI_MIMETYPE_H
26 
27 #include "liteapi/liteapi.h"
28 
29 class MimeType : public LiteApi::IMimeType
30 {
31 public:
MimeType()32     MimeType(): m_tabToSpace(false), m_tabWidth(4)
33     {
34     }
35     virtual QString package() const;
36     virtual QString type() const;
37     virtual QString scheme() const;
38     virtual QString comment() const;
39     virtual QString codec() const;
40     virtual bool tabToSpace() const;
41     virtual int tabWidth() const;
42     virtual QStringList globPatterns() const;
43     virtual QStringList subClassesOf() const;
44     virtual void merge(const IMimeType *mimeType);
45     virtual void setCustomPatterns(const QStringList &custom);
46     virtual QStringList customPatterns() const;
47     virtual QStringList allPatterns() const;
48 
49     void setPackage(const QString &package);
50     void setType(const QString &type);
51     void setScheme(const QString &scheme);
52     void setCodec(const QString &codec);
53     void setTabToSpace(const QString &s);
54     void setTabWidth(const QString &s);
55     void setComment(const QString &comment);
56     void appendGlobPatterns(const QString &globPattern);
57     void appendSubClassesOf(const QString &subClassOf);
58     void appendLocalComment(const QString &local, const QString &commnet);
59     bool isEmpty() const;
60 public:
61     static bool loadMimeTypes(LiteApi::IMimeTypeManager *manager, const QString &fileName);
62     static bool loadMimeTypes(LiteApi::IMimeTypeManager *manager, QIODevice *dev, const QString &fileName);
63 protected:
64     bool    m_tabToSpace; // default false
65     int     m_tabWidth; //default 4
66     QString m_package;
67     QString m_type;
68     QString m_scheme;
69     QString m_codec;
70     QStringList m_comment;
71     QStringList m_globPatterns;
72     QStringList m_subClassesOf;
73     QStringList m_customPatterns;
74     QMap<QString,QString> m_localCommentMap;
75 };
76 
77 #endif // LITEAPI_MIMETYPE_H
78