source: trunk/tools/assistant/profile.cpp@ 203

Last change on this file since 203 was 191, checked in by rudi, 14 years ago

Qt Assistant added

File size: 4.3 KB
Line 
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#include "profile.h"
27#include <qxml.h>
28#include <qtextcodec.h>
29#include <qfileinfo.h>
30#include <qregexp.h>
31#include <qdir.h>
32
33#define QT_TITLE "Qt Reference Documentation"
34#define DESIGNER_TITLE "Qt Designer Manual"
35#define ASSISTANT_TITLE "Qt Assistant Manual"
36#define LINGUIST_TITLE "Guide to the Qt Translation Tools"
37#define QMAKE_TITLE "qmake User Guide"
38
39Profile *Profile::createDefaultProfile( const QString &docPath )
40{
41 QString path = qInstallPathDocs();
42 if ( !docPath.isEmpty() )
43 path = docPath;
44 path = path + "/html/";
45 Profile *profile = new Profile;
46 profile->valid = TRUE;
47 profile->type = DefaultProfile;
48 profile->props["name"] = "default";
49 profile->props["applicationicon"] = "appicon.png";
50 profile->props["aboutmenutext"] = "About Qt";
51 profile->props["abouturl"] = "about_qt";
52 profile->props["title"] = "Qt Assistant";
53 profile->props["basepath"] = path;
54 profile->props["startpage"] = path + "index.html";
55
56 profile->addDCFTitle( path + "qt.dcf", QT_TITLE );
57 profile->addDCFTitle( path + "designer.dcf", DESIGNER_TITLE );
58 profile->addDCFTitle( path + "assistant.dcf", ASSISTANT_TITLE );
59 profile->addDCFTitle( path + "linguist.dcf", LINGUIST_TITLE );
60 profile->addDCFTitle( path + "qmake.dcf", QMAKE_TITLE );
61
62 profile->addDCFIcon( QT_TITLE, "qt.png" );
63 profile->addDCFIcon( DESIGNER_TITLE, "designer.png" );
64 profile->addDCFIcon( ASSISTANT_TITLE, "assistant.png" );
65 profile->addDCFIcon( LINGUIST_TITLE, "linguist.png" );
66
67 profile->addDCFIndexPage( QT_TITLE, path + "index.html" );
68 profile->addDCFIndexPage( DESIGNER_TITLE, path + "designer-manual.html" );
69 profile->addDCFIndexPage( ASSISTANT_TITLE, path + "assistant.html" );
70 profile->addDCFIndexPage( LINGUIST_TITLE, path + "linguist-manual.html" );
71 profile->addDCFIndexPage( QMAKE_TITLE, path + "qmake-manual.html" );
72
73 profile->addDCFImageDir( QT_TITLE, "../../gif/" );
74 profile->addDCFImageDir( DESIGNER_TITLE, "../../gif/" );
75 profile->addDCFImageDir( ASSISTANT_TITLE, "../../gif/" );
76 profile->addDCFImageDir( LINGUIST_TITLE, "../../gif/" );
77 profile->addDCFImageDir( QMAKE_TITLE, "../../gif/" );
78
79 return profile;
80}
81
82
83Profile::Profile()
84 : valid( TRUE ), dparser( 0 )
85{
86}
87
88
89void Profile::removeDocFileEntry( const QString &docfile )
90{
91 docs.remove( docfile );
92
93 QStringList titles;
94
95 for( QMap<QString,QString>::Iterator it = dcfTitles.begin();
96 it != dcfTitles.end(); ++it ) {
97 if( (*it) == docfile ) {
98 indexPages.remove( *it );
99 icons.remove( *it );
100 imageDirs.remove( *it );
101 titles << it.key();
102 }
103 }
104
105 for( QStringList::ConstIterator title = titles.begin();
106 title != titles.end(); ++title ) {
107
108 dcfTitles.remove( *title );
109 }
110
111#ifdef ASSISTANT_DEBUG
112 qDebug( "docs:\n - " + docs.join( "\n - " ) );
113 qDebug( "titles:\n - " + titles.join( "\n - " ) );
114 qDebug( "keys:\n - " + ( (QStringList*) &(dcfTitles.keys()) )->join( "\n - " ) );
115 qDebug( "values:\n - " + ( (QStringList*) &(dcfTitles.values()) )->join( "\n - " ) );
116#endif
117}
Note: See TracBrowser for help on using the repository browser.