[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/~bcooksley/khelpcenter-ng
From: Ben Cooksley <sourtooth () gmail ! com>
Date: 2010-01-12 9:23:15
Message-ID: 1263288195.806345.20225.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1073425 by bcooksley:
Rearrange where some initialisation takes place, to allow for more things to have delayed initialisation
M +17 -3 HelpCenterApp.cpp
M +6 -0 HelpCenterApp.h
M +6 -23 MainWindow.cpp
M +0 -3 MainWindow.h
M +1 -0 sources/SourceBase.h
--- branches/work/~bcooksley/khelpcenter-ng/HelpCenterApp.cpp #1073424:1073425
@@ -23,11 +23,12 @@
#include "HelpCenterApp.h"
#include <KCmdLineArgs>
-#include <KUniqueApplication>
#include "HelpItem.h"
#include "HelpSource.h"
#include "MainWindow.h"
+#include "KCMProvider.h"
+#include "ApplicationProvider.h"
HelpCenterApp::HelpCenterApp() :
KUniqueApplication()
@@ -35,6 +36,9 @@
m_window = 0;
m_helpRoot = new HelpItem( 0, HelpItem::Root, i18n("Handbook Selection"), KUrl(), "system-help" );
m_helpSource = new HelpSource( this );
+
+ m_helpProviders.append( new ApplicationProvider(this) );
+ m_helpProviders.append( new KCMProvider(this) );
}
HelpCenterApp::~HelpCenterApp()
@@ -47,8 +51,7 @@
return 0;
}
if( !m_window ) {
- m_window = new MainWindow();
- m_window->show();
+ initState();
}
KUrl instanceUrl;
@@ -64,6 +67,17 @@
return KUniqueApplication::newInstance();
}
+void HelpCenterApp::initState()
+{
+ foreach( HelpProvider * provider, m_helpProviders ) {
+ provider->addItems( m_helpRoot );
+ // Other tasks that need to be done by Providers in initialisation go here
+ }
+
+ m_window = new MainWindow();
+ m_window->show();
+}
+
HelpItem * HelpCenterApp::helpRoot()
{
HelpCenterApp * hApp = qobject_cast<HelpCenterApp*>( kapp );
--- branches/work/~bcooksley/khelpcenter-ng/HelpCenterApp.h #1073424:1073425
@@ -25,9 +25,12 @@
#include <KUniqueApplication>
+#include <QList>
+
class HelpItem;
class HelpSource;
class MainWindow;
+class HelpProvider;
class HelpCenterApp : public KUniqueApplication
{
@@ -43,9 +46,12 @@
static HelpSource * helpSource();
private:
+ void initState();
+
MainWindow * m_window;
HelpItem * m_helpRoot;
HelpSource * m_helpSource;
+ QList<HelpProvider*> m_helpProviders;
};
#endif
--- branches/work/~bcooksley/khelpcenter-ng/MainWindow.cpp #1073424:1073425
@@ -26,8 +26,6 @@
#include "HelpCenterApp.h"
#include "HelpBookmarkOwner.h"
#include "HelpBookmarkMenu.h"
-#include "ApplicationProvider.h"
-#include "KCMProvider.h"
#include <KApplication>
#include <KStandardDirs>
@@ -46,10 +44,13 @@
connect( mainArea, SIGNAL(currentChanged(int)), this, SLOT(activeTabChanged()) );
setCentralWidget( mainArea );
- // Commence internal work to build indexes
+ // Get the help tree info available
rootHelpItem = HelpCenterApp::helpRoot();
- prepareHelpProviders();
+ // Add internal items
+ m_homePage = new HelpItem( rootHelpItem, HelpItem::Internal, i18n("KHelpCenter"),
+ KUrl("help:/khelpcenter/index.html"), "system-help" );
+
// Build toolbars / menu
buildToolBar();
buildMenu();
@@ -63,33 +64,15 @@
m_actionMapper = new QSignalMapper( this );
connect( m_actionMapper, SIGNAL(mapped(QObject*)), this, SLOT(openSelection(QObject*)) );
- // Unfortunately this has to be done in-constructor too....
- // Otherwise url's passed to us will be rejected since their items don't exist yet
- buildHelpTree();
+ QMetaObject::invokeMethod( this, "buildHelpTree", Qt::QueuedConnection );
}
MainWindow::~MainWindow()
{
}
-void MainWindow::prepareHelpProviders()
-{
- // Add the various types of provider here
- hProviders.append( new ApplicationProvider(this) );
- hProviders.append( new KCMProvider(this) );
-}
-
void MainWindow::buildHelpTree()
{
- foreach( HelpProvider * provider, hProviders ) {
- provider->addItems( rootHelpItem );
- // Other tasks that need to be done by Providers in initialisation go here
- }
-
- // Add internal items
- m_homePage = new HelpItem( rootHelpItem, HelpItem::Internal, i18n("KHelpCenter"),
- KUrl("help:/khelpcenter/index.html"), "system-help" );
-
// Build the menu
handbookMenu = rootHelpItem->buildMenu( this );
handbookMenu->setDelayed( false );
--- branches/work/~bcooksley/khelpcenter-ng/MainWindow.h #1073424:1073425
@@ -25,7 +25,6 @@
#include "HelpItem.h"
#include "PageBase.h"
-#include "HelpProvider.h"
#include <KLocale>
#include <KTabWidget>
@@ -55,7 +54,6 @@
private slots:
// Get ready to run
- void prepareHelpProviders();
void buildHelpTree();
void buildToolBar();
void buildMenu();
@@ -89,7 +87,6 @@
// The application help list
HelpItem * rootHelpItem;
HelpItem * m_homePage;
- QList<HelpProvider*> hProviders;
KActionMenu * handbookMenu;
// Toolbar actions
--- branches/work/~bcooksley/khelpcenter-ng/sources/SourceBase.h #1073424:1073425
@@ -41,6 +41,7 @@
virtual bool handlesItem( HelpItem * item ) = 0; // Can the source handle the item at all?
virtual bool handlesUrl( const KUrl& url ) = 0; // Can they handle this url?
+ // These 3 functions handle conversion between navigable and internal urls.
virtual KUrl itemToUrl( HelpItem * item ) = 0;
virtual HelpItem * urlToItem( const KUrl& url ) = 0;
virtual KUrl urlToInternal( const KUrl& url ) = 0;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic