author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 08 Apr 2010 14:19:33 +0300 | |
branch | RCL_3 |
changeset 7 | 3f74d0d4af4c |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the Qt Assistant of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "profile.h" |
|
43 |
#include <QTextCodec> |
|
44 |
#include <QFileInfo> |
|
45 |
#include <QRegExp> |
|
46 |
#include <QDir> |
|
47 |
#include <QList> |
|
48 |
#include <QLibraryInfo> |
|
49 |
||
50 |
QT_BEGIN_NAMESPACE |
|
51 |
||
52 |
#define QT_TITLE QLatin1String("Qt Reference Documentation") |
|
53 |
#define DESIGNER_TITLE QLatin1String("Qt Designer Manual") |
|
54 |
#define ASSISTANT_TITLE QLatin1String("Qt Assistant Manual") |
|
55 |
#define LINGUIST_TITLE QLatin1String("Qt Linguist Manual") |
|
56 |
#define QMAKE_TITLE QLatin1String("qmake Manual") |
|
57 |
||
58 |
Profile *Profile::createDefaultProfile(const QString &docPath) |
|
59 |
{ |
|
60 |
QString path = QLibraryInfo::location(QLibraryInfo::DocumentationPath); |
|
61 |
if (!docPath.isEmpty()) |
|
62 |
path = docPath; |
|
63 |
path = QDir::cleanPath(path) + QLatin1String("/html/"); |
|
64 |
||
65 |
Profile *profile = new Profile; |
|
66 |
profile->valid = true; |
|
67 |
profile->type = DefaultProfile; |
|
68 |
profile->props[QLatin1String("name")] = QLatin1String("default"); |
|
69 |
profile->props[QLatin1String("applicationicon")] = QLatin1String("assistant.png"); |
|
70 |
profile->props[QLatin1String("aboutmenutext")] = QLatin1String("About Qt"); |
|
71 |
profile->props[QLatin1String("abouturl")] = QLatin1String("about_qt"); |
|
72 |
profile->props[QLatin1String("basepath")] = path; |
|
73 |
profile->props[QLatin1String("startpage")] = path + QLatin1String("index.html"); |
|
74 |
||
75 |
profile->addDCFTitle( path + QLatin1String("qt.dcf"), QT_TITLE ); |
|
76 |
profile->addDCFTitle( path + QLatin1String("designer.dcf"), DESIGNER_TITLE ); |
|
77 |
profile->addDCFTitle( path + QLatin1String("assistant.dcf"), ASSISTANT_TITLE ); |
|
78 |
profile->addDCFTitle( path + QLatin1String("linguist.dcf"), LINGUIST_TITLE ); |
|
79 |
profile->addDCFTitle( path + QLatin1String("qmake.dcf"), QMAKE_TITLE ); |
|
80 |
||
81 |
profile->addDCFIcon( QT_TITLE, QLatin1String("qt.png") ); |
|
82 |
profile->addDCFIcon( DESIGNER_TITLE, QLatin1String("designer.png") ); |
|
83 |
profile->addDCFIcon( ASSISTANT_TITLE, QLatin1String("assistant.png") ); |
|
84 |
profile->addDCFIcon( LINGUIST_TITLE, QLatin1String("linguist.png") ); |
|
85 |
||
86 |
profile->addDCFIndexPage( QT_TITLE, path + QLatin1String("index.html") ); |
|
87 |
profile->addDCFIndexPage( DESIGNER_TITLE, path + QLatin1String("designer-manual.html") ); |
|
88 |
profile->addDCFIndexPage( ASSISTANT_TITLE, path + QLatin1String("assistant-manual.html") ); |
|
89 |
profile->addDCFIndexPage( LINGUIST_TITLE, path + QLatin1String("linguist-manual.html") ); |
|
90 |
profile->addDCFIndexPage( QMAKE_TITLE, path + QLatin1String("qmake-manual.html") ); |
|
91 |
||
92 |
profile->addDCFImageDir( QT_TITLE, QLatin1String("../../gif/") ); |
|
93 |
profile->addDCFImageDir( DESIGNER_TITLE, QLatin1String("../../gif/") ); |
|
94 |
profile->addDCFImageDir( ASSISTANT_TITLE, QLatin1String("../../gif/") ); |
|
95 |
profile->addDCFImageDir( LINGUIST_TITLE, QLatin1String("../../gif/") ); |
|
96 |
profile->addDCFImageDir( QMAKE_TITLE, QLatin1String("../../gif/") ); |
|
97 |
||
98 |
return profile; |
|
99 |
} |
|
100 |
||
101 |
Profile::Profile() |
|
102 |
: valid( true ), dparser( 0 ) |
|
103 |
{ |
|
104 |
type = DefaultProfile; |
|
105 |
} |
|
106 |
||
107 |
bool Profile::isValid() const |
|
108 |
{ |
|
109 |
return valid; |
|
110 |
} |
|
111 |
||
112 |
void Profile::addDCFTitle(const QString &dcf, const QString &title) |
|
113 |
{ |
|
114 |
QString absdcf = QFileInfo(dcf).absoluteFilePath(); |
|
115 |
dcfTitles[title] = absdcf; |
|
116 |
if (!docs.contains(absdcf)) |
|
117 |
docs << absdcf; |
|
118 |
} |
|
119 |
||
120 |
void Profile::addDCF(const QString &docfile) |
|
121 |
{ |
|
122 |
if( !docs.contains( docfile ) == 0 ) |
|
123 |
docs << docfile; |
|
124 |
} |
|
125 |
||
126 |
void Profile::addDCFIcon(const QString docfile, const QString &icon) |
|
127 |
{ |
|
128 |
icons[docfile] = icon; |
|
129 |
} |
|
130 |
||
131 |
void Profile::addDCFIndexPage(const QString title, const QString &indexPage) |
|
132 |
{ |
|
133 |
indexPages[title] = indexPage; |
|
134 |
} |
|
135 |
||
136 |
void Profile::addDCFImageDir(const QString docfile, const QString &imgDir) |
|
137 |
{ |
|
138 |
imageDirs[docfile] = imgDir; |
|
139 |
} |
|
140 |
||
141 |
void Profile::addProperty(const QString &name, const QString &value) |
|
142 |
{ |
|
143 |
props[name] = value; |
|
144 |
} |
|
145 |
||
146 |
bool Profile::hasDocFile(const QString &name) |
|
147 |
{ |
|
148 |
return docs.contains( name ); |
|
149 |
} |
|
150 |
||
151 |
void Profile::removeDocFileEntry(const QString &docfile) |
|
152 |
{ |
|
153 |
docs.removeAll(docfile); |
|
154 |
QStringList titles; |
|
155 |
||
156 |
for( QMap<QString,QString>::Iterator it = dcfTitles.begin(); |
|
157 |
it != dcfTitles.end(); ++it ) { |
|
158 |
if( (*it) == docfile ) { |
|
159 |
indexPages.remove( *it ); |
|
160 |
icons.remove( *it ); |
|
161 |
imageDirs.remove( *it ); |
|
162 |
titles << it.key(); |
|
163 |
} |
|
164 |
} |
|
165 |
||
166 |
for( QStringList::ConstIterator title = titles.constBegin(); |
|
167 |
title != titles.constEnd(); ++title ) |
|
168 |
dcfTitles.remove( *title ); |
|
169 |
||
170 |
#ifdef ASSISTANT_DEBUG |
|
171 |
qDebug() << "docs:\n - " << docs.join("\n - "); |
|
172 |
qDebug() << "titles:\n - " << titles.join("\n - "); |
|
173 |
qDebug() << "keys:\n - " << ((QStringList*)&(dcfTitles.keys()))->join("\n - "); |
|
174 |
qDebug() << "values:\n - " << ((QStringList*)&(dcfTitles.values()))->join("\n - "); |
|
175 |
#endif |
|
176 |
} |
|
177 |
||
178 |
QString Profile::storableFilePath(const QString &fileName) |
|
179 |
{ |
|
180 |
QString path = QLibraryInfo::location(QLibraryInfo::DocumentationPath).replace(QLatin1String("\\"), QLatin1String("/")); |
|
181 |
QString fName = fileName; |
|
182 |
if (fName.startsWith(path)) |
|
183 |
fName.replace(0, path.length(), QLatin1String("$DOCPATH$")); |
|
184 |
return fName; |
|
185 |
} |
|
186 |
||
187 |
QString Profile::loadableFilePath(const QString &fileName) |
|
188 |
{ |
|
189 |
QString path = QLibraryInfo::location(QLibraryInfo::DocumentationPath).replace(QLatin1String("\\"), QLatin1String("/")); |
|
190 |
QString fName = fileName; |
|
191 |
if (fName.startsWith(QLatin1String("$DOCPATH$"))) |
|
192 |
fName.replace(0, 9, path); |
|
193 |
return fName; |
|
194 |
} |
|
195 |
||
196 |
QT_END_NAMESPACE |