2 * This file is part of the KDE Help Center
4 * Copyright (C) 1999 Matthias Elter (me@kde.org)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program 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
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "plugintraverser.h"
21 #include "docmetainfo.h"
22 #include "navigator.h"
23 #include "navigatorappitem.h"
24 #include "navigatoritem.h"
26 #include <kapplication.h>
28 #include <kconfiggroup.h>
30 #include <kiconloader.h>
32 #include <Qt3Support/Q3CheckListItem>
37 PluginTraverser::PluginTraverser( Navigator
*navigator
, Q3ListView
*parent
)
38 : DocEntryTraverser(),
42 mNavigator( navigator
)
46 PluginTraverser::PluginTraverser( Navigator
*navigator
, NavigatorItem
*parent
)
47 : DocEntryTraverser(),
49 mParentItem( parent
),
51 mNavigator( navigator
)
55 void PluginTraverser::process( DocEntry
*entry
)
57 if ( !mListView
&& !mParentItem
) {
58 kDebug( 1400 ) << "ERROR! Neither mListView nor mParentItem is set.";
62 if ( !entry
->docExists() && !mNavigator
->showMissingDocs() )
66 kDebug() << "PluginTraverser::process(): " << entry
->name()
67 << " (weight: " << entry
->weight() << " parent: "
68 << ( mParentItem
? mParentItem
->name() : "0" ) << ")" << endl
;
71 if ( entry
->khelpcenterSpecial() == QLatin1String("apps") ) {
72 NavigatorAppItem
*appItem
;
73 entry
->setIcon( "kde" );
75 appItem
= new NavigatorAppItem( entry
, mListView
, mCurrentItem
);
77 appItem
= new NavigatorAppItem( entry
, mParentItem
, mCurrentItem
);
78 KConfigGroup
cfg(KGlobal::config(), "General");
79 appItem
->setRelpath( cfg
.readPathEntry( "AppsRoot", QString() ) );
80 mCurrentItem
= appItem
;
81 } else if ( entry
->khelpcenterSpecial() == QLatin1String("scrollkeeper" )) {
83 mCurrentItem
= mNavigator
->insertScrollKeeperDocs( mParentItem
, mCurrentItem
);
88 mCurrentItem
= new NavigatorItem( entry
, mListView
, mCurrentItem
);
90 mCurrentItem
= new NavigatorItem( entry
, mParentItem
, mCurrentItem
);
92 if ( entry
->khelpcenterSpecial() == QLatin1String("konqueror") ) {
93 mNavigator
->insertParentAppDocs( entry
->khelpcenterSpecial(), mCurrentItem
);
94 } else if ( entry
->khelpcenterSpecial() == QLatin1String("kcontrol") ) {
95 mNavigator
->insertKCMDocs( entry
->khelpcenterSpecial(), mCurrentItem
, QString("kcontrol") );
96 } else if ( entry
->khelpcenterSpecial() == QLatin1String("kinfocenter") ) {
97 mNavigator
->insertKCMDocs( entry
->khelpcenterSpecial(), mCurrentItem
, QString("kinfocenter") );
98 } else if ( entry
->khelpcenterSpecial() == QLatin1String("kioslave") ) {
99 mNavigator
->insertIOSlaveDocs( entry
->khelpcenterSpecial(), mCurrentItem
);
100 } else if ( entry
->khelpcenterSpecial() == QLatin1String("info") ) {
101 mNavigator
->insertInfoDocs( mCurrentItem
);
105 // TODO: was contents2 -> needs to be changed to help-contents-alternate or similar
106 mCurrentItem
->setPixmap( 0, SmallIcon( QLatin1String("help-contents") ) );
110 DocEntryTraverser
*PluginTraverser::createChild( DocEntry
* /*entry*/ )
112 if ( mCurrentItem
) {
113 return new PluginTraverser( mNavigator
, mCurrentItem
);
115 kDebug( 1400 ) << "ERROR! mCurrentItem is not set.";