1 | /**********************************************************************
|
---|
2 | ** Copyright (C) 2000-2007 Trolltech ASA. All rights reserved.
|
---|
3 | **
|
---|
4 | ** This file is part of the Qt Assistant.
|
---|
5 | **
|
---|
6 | ** This file may be distributed and/or modified under the terms of the
|
---|
7 | ** GNU General Public License version 2 as published by the Free Software
|
---|
8 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
9 | ** packaging of this file.
|
---|
10 | **
|
---|
11 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
12 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
13 | ** Agreement provided with the Software.
|
---|
14 | **
|
---|
15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
17 | **
|
---|
18 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
19 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
20 | ** information about Qt Commercial License Agreements.
|
---|
21 | **
|
---|
22 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
23 | ** not clear to you.
|
---|
24 | **
|
---|
25 | **********************************************************************/
|
---|
26 |
|
---|
27 | #ifndef PROFILE_H
|
---|
28 | #define PROFILE_H
|
---|
29 |
|
---|
30 | #include <qfileinfo.h>
|
---|
31 | #include <qstring.h>
|
---|
32 | #include <qstringlist.h>
|
---|
33 | #include <qmap.h>
|
---|
34 |
|
---|
35 | class DocuParser;
|
---|
36 |
|
---|
37 | class Profile
|
---|
38 | {
|
---|
39 | public:
|
---|
40 | enum ProfileType { DefaultProfile, UserProfile };
|
---|
41 | Profile();
|
---|
42 |
|
---|
43 | inline bool isValid() const;
|
---|
44 |
|
---|
45 | inline void addDCF( const QString &docfile );
|
---|
46 | inline void addDCFIcon( const QString title, const QString &icon );
|
---|
47 | inline void addDCFIndexPage( const QString title, const QString &indexPage );
|
---|
48 | inline void addDCFImageDir( const QString title, const QString &imgDir );
|
---|
49 | inline void addDCFTitle( const QString &dcf, const QString &title );
|
---|
50 | inline void addProperty( const QString &name, const QString &value );
|
---|
51 | inline bool hasDocFile( const QString &docFile );
|
---|
52 | void removeDocFileEntry( const QString &title );
|
---|
53 |
|
---|
54 | inline ProfileType profileType() const { return type; }
|
---|
55 | inline void setProfileType( ProfileType t ) { type = t; }
|
---|
56 |
|
---|
57 | inline DocuParser *docuParser() const { return dparser; }
|
---|
58 | inline void setDocuParser( DocuParser *dp ) { dparser = dp; }
|
---|
59 |
|
---|
60 | static Profile* createDefaultProfile( const QString &docPath = QString::null );
|
---|
61 | static QString makeRelativePath( const QString &base, const QString &path );
|
---|
62 |
|
---|
63 | int valid:1;
|
---|
64 | ProfileType type;
|
---|
65 | DocuParser *dparser;
|
---|
66 | QMap<QString,QString> props;
|
---|
67 | QMap<QString,QString> icons;
|
---|
68 | QMap<QString,QString> indexPages;
|
---|
69 | QMap<QString,QString> imageDirs;
|
---|
70 | QMap<QString,QString> dcfTitles;
|
---|
71 | QStringList docs;
|
---|
72 | };
|
---|
73 |
|
---|
74 |
|
---|
75 | inline bool Profile::isValid() const
|
---|
76 | {
|
---|
77 | return valid;
|
---|
78 | }
|
---|
79 |
|
---|
80 | inline void Profile::addDCFTitle(const QString &dcf, const QString &title)
|
---|
81 | {
|
---|
82 | QString absdcf = QFileInfo(dcf).absFilePath();
|
---|
83 | dcfTitles[title] = absdcf;
|
---|
84 | if (docs.contains(absdcf) == 0)
|
---|
85 | docs << absdcf;
|
---|
86 | }
|
---|
87 |
|
---|
88 | inline void Profile::addDCF( const QString &docfile )
|
---|
89 | {
|
---|
90 | if( !docs.contains( docfile ) == 0 )
|
---|
91 | docs << docfile;
|
---|
92 | }
|
---|
93 |
|
---|
94 | inline void Profile::addDCFIcon( const QString docfile,
|
---|
95 | const QString &icon )
|
---|
96 | {
|
---|
97 | icons[docfile] = icon;
|
---|
98 | }
|
---|
99 |
|
---|
100 | inline void Profile::addDCFIndexPage( const QString title,
|
---|
101 | const QString &indexPage )
|
---|
102 | {
|
---|
103 | indexPages[title] = indexPage;
|
---|
104 | }
|
---|
105 |
|
---|
106 | inline void Profile::addDCFImageDir( const QString docfile,
|
---|
107 | const QString &imgDir )
|
---|
108 | {
|
---|
109 | imageDirs[docfile] = imgDir;
|
---|
110 | }
|
---|
111 |
|
---|
112 | inline void Profile::addProperty( const QString &name,
|
---|
113 | const QString &value )
|
---|
114 | {
|
---|
115 | props[name] = value;
|
---|
116 | }
|
---|
117 |
|
---|
118 | inline bool Profile::hasDocFile( const QString &name )
|
---|
119 | {
|
---|
120 | return docs.contains( name ) > 0;
|
---|
121 | }
|
---|
122 |
|
---|
123 | #endif
|
---|