[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdevelop/lib
From: Adam Treat <treat () kde ! org>
Date: 2006-08-31 23:53:55
Message-ID: 1157068435.933860.13140.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 579388 by treat:
The initialization is in pretty good shape now. THe order
of the objects initialized in KDevCore no longer matters.
M +36 -19 kdevcore.cpp
M +53 -8 kdevcore.h
M +6 -6 kdevmainwindow.cpp
M +0 -30 kdevplugincontroller.cpp
M +0 -2 kdevprojectcontroller.cpp
--- trunk/KDE/kdevelop/lib/kdevcore.cpp #579387:579388
@@ -30,8 +30,10 @@
#include "kdevcore.h"
#include <QPointer>
+#include <kcmdlineargs.h>
#include <kstaticdeleter.h>
+#include "kdevconfig.h"
#include "kdevproject.h"
#include "kdevmainwindow.h"
#include "kdevenvironment.h"
@@ -206,8 +208,6 @@
//depend upon one another. Can not do this in the constructor
//as they might depend upon one another.
- //WARNING! the order is important
-
Q_ASSERT( d->environment );
Q_ASSERT( d->partController );
Q_ASSERT( d->languageController );
@@ -222,14 +222,36 @@
d->languageController->initialize();
d->documentController->initialize();
d->projectController->initialize();
+ d->mainWindow->initialize();
+ d->backgroundParser->initialize();
+ d->pluginController->initialize();
- d->mainWindow->initialize(); //createGUI before anything touches the xmlgui...
+ bool success = false;
- d->backgroundParser->initialize();
+ KCmdLineArgs * args = KCmdLineArgs::parsedArgs();
+ if ( args->isSet( "project" ) )
+ {
+ QString project = QString::fromLocal8Bit( args->getOption( "project" ) );
+ success = d->projectController->openProject( KUrl( project ) );
+ }
+ else
+ {
+ KConfig * config = KDevConfig::standard();
+ config->setGroup( "General Options" );
+ QString project = config->readPathEntry( "Last Project" );
+ bool readProject = config->readEntry( "Read Last Project On Startup", true );
- //The pluginController will call loadSettings either directly or through the projectController
- d->pluginController->initialize();
+ if ( !project.isEmpty() && readProject )
+ {
+ success = d->projectController->openProject( KUrl( project ) );
+ }
+ }
+ //If the project opened successfully then projectController will call KDevCore::loadSettings
+ //once the project file has been loaded. Else we will do it here.
+ if ( !success )
+ loadSettings();
+
d->mainWindow->setVisible( true ); //Done initializing
}
@@ -239,8 +261,6 @@
//depend upon one another. Can not do this in the destructor
//as they might depend upon one another.
- //WARNING! the order is important
-
Q_ASSERT( d->environment );
Q_ASSERT( d->partController );
Q_ASSERT( d->languageController );
@@ -250,21 +270,22 @@
Q_ASSERT( d->backgroundParser );
Q_ASSERT( d->pluginController );
- //The projectController will call saveSettings either directly or through closeProject
- d->projectController->cleanup();
+ //If a project is open then projectController will call KDevCore::saveSettings
+ //both before the project is closed and then once after. Else we will do it here.
+ if ( !d->projectController->closeProject() )
+ saveSettings();
d->environment->cleanup();
d->partController->cleanup();
d->languageController->cleanup();
d->documentController->cleanup();
-
+ d->projectController->cleanup();
d->mainWindow->cleanup();
-
d->backgroundParser->cleanup();
d->pluginController->cleanup();
}
-/* This function should be called right after initialization of the objects and a project has a
+/* This function should be called right after initialization of the objects and a project has
been opened, or if no project is opened it should be called before the mainWindow is shown. */
void KDevCore::loadSettings()
{
@@ -284,15 +305,13 @@
d->languageController->loadSettings( projectIsLoaded );
d->documentController->loadSettings( projectIsLoaded );
d->projectController->loadSettings( projectIsLoaded );
-
d->mainWindow->loadSettings( projectIsLoaded );
-
d->backgroundParser->loadSettings( projectIsLoaded );
d->pluginController->loadSettings( projectIsLoaded );
}
-/* This function should be called right before closing of the project, right after closing the
- project, or if no project is opened it should be called upon close. */
+/* This function should be called right before closing of the project and right after closing the
+ project, or if no project is opened it should be called right before cleanup. */
void KDevCore::saveSettings()
{
Q_ASSERT( d->environment );
@@ -311,9 +330,7 @@
d->languageController->saveSettings( projectIsLoaded );
d->documentController->saveSettings( projectIsLoaded );
d->projectController->saveSettings( projectIsLoaded );
-
d->mainWindow->saveSettings( projectIsLoaded );
-
d->backgroundParser->saveSettings( projectIsLoaded );
d->pluginController->saveSettings( projectIsLoaded );
}
--- trunk/KDE/kdevelop/lib/kdevcore.h #579387:579388
@@ -106,8 +106,8 @@
static void setProjectController( KDevProjectController *projectController );
/**
- *
- * @return
+ * @brief Get the active project
+ * @return a KDevProject object representing the currently active project
*/
static KDevProject* activeProject();
@@ -180,38 +180,83 @@
*/
static KDevLanguageSupport *activeLanguage();
- /**
- *
- * @return
- */
+ /**
+ * @brief Get the background parser
+ * @return a KDevBackgroundParser object which controls the parser jobs
+ */
static KDevBackgroundParser *backgroundParser();
/**
- *
+ * @brief Set the background parser
* @param backgroundParser
*/
static void setBackgroundParser( KDevBackgroundParser *backgroundParser );
- //Calls the relevant method for all KDevCoreInterface objects...
+ /**
+ * @brief Load the settings for the KDevCore objects
+ */
static void loadSettings();
+
+ /**
+ * @brief Save the settings of the KDevCore objects
+ */
static void saveSettings();
+
+ /**
+ * @brief Initialize the KDevCore objects
+ */
static void initialize();
+
+ /**
+ * @brief Cleanup the KDevCore objects
+ */
static void cleanup();
};
+
+/**
+ * KDevCoreInterface is a virtual base class for all objects which are provided by KDevCore.
+ * These objects need to inherit the various pure virtual functions which facilitate things like
+ * project loading and inter-object initialization.
+ */
class KDEVINTERFACES_EXPORT KDevCoreInterface
{
public:
+ /**
+ * @brief Load the settings for this KDevCore object
+ */
void load();
+
+ /**
+ * @brief Save the settings of this KDevCore object
+ */
void save();
protected:
+ /** Constructor */
KDevCoreInterface(){}
+
+ /** Destructor */
virtual ~KDevCoreInterface(){}
+ /**
+ * @brief Load the settings for this KDevCore object
+ */
virtual void loadSettings( bool projectIsLoaded ) = 0;
+
+ /**
+ * @brief Save the settings of this KDevCore object
+ */
virtual void saveSettings( bool projectIsLoaded ) = 0;
+
+ /**
+ * @brief Initialize this KDevCore object
+ */
virtual void initialize() = 0;
+
+ /**
+ * @brief Cleanup this KDevCore object
+ */
virtual void cleanup() = 0;
};
--- trunk/KDE/kdevelop/lib/kdevmainwindow.cpp #579387:579388
@@ -80,6 +80,12 @@
setCorner( Qt::TopRightCorner, Qt::RightDockWidgetArea );
setCorner( Qt::BottomLeftCorner, Qt::LeftDockWidgetArea );
setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea );
+
+ setStandardToolBarMenuEnabled( true );
+ setupActions();
+ setStatusBar( new KDevStatusBar( this ) );
+
+ createGUI( ShellExtension::getInstance() ->xmlFile() );
}
KDevMainWindow::~ KDevMainWindow()
@@ -229,12 +235,6 @@
void KDevMainWindow::initialize()
{
- setStandardToolBarMenuEnabled( true );
- setupActions();
- setStatusBar( new KDevStatusBar( this ) );
-
- createGUI( ShellExtension::getInstance() ->xmlFile() );
-
connect( KDevCore::documentController(), SIGNAL( documentActivated( KDevDocument* ) ),
this, SLOT( documentActivated( KDevDocument* ) ) );
connect( KDevCore::projectController(), SIGNAL( projectOpened() ),
--- trunk/KDE/kdevelop/lib/kdevplugincontroller.cpp #579387:579388
@@ -33,7 +33,6 @@
#include <assert.h>
#include <kdebug.h>
#include <kdialog.h>
-#include <kcmdlineargs.h>
#include <kstandarddirs.h>
#include <kiconloader.h>
#include <kaction.h>
@@ -41,7 +40,6 @@
#include <kxmlguifactory.h>
#include "kdevcore.h"
-#include "kdevconfig.h"
#include "kdevplugin.h"
#include "kdevmakeinterface.h"
#include "kdevapplicationinterface.h"
@@ -93,34 +91,6 @@
{
loadPlugins( ProfileEngine::Core );
loadPlugins( ProfileEngine::Global );
-
- bool success = false;
-
- KCmdLineArgs * args = KCmdLineArgs::parsedArgs();
- if ( args->isSet( "project" ) )
- {
- QString project = QString::fromLocal8Bit( args->getOption( "project" ) );
- success = KDevCore::projectController() ->openProject( KUrl( project ) );
- }
- else
- {
- KConfig * config = KDevConfig::standard();
- config->setGroup( "General Options" );
- QString project = config->readPathEntry( "Last Project" );
- bool readProject = config->readEntry( "Read Last Project On Startup", true );
-
- if ( !project.isEmpty() && readProject )
- {
- success = KDevCore::projectController() ->openProject( KUrl( project ) );
- }
- }
-
- //If the project opened successfully then projectController will call KDevCore::loadSettings
- //once the project file has been loaded. Else we will do it here.
- if ( !success )
- {
- KDevCore::loadSettings();
- }
}
void KDevPluginController::cleanup()
--- trunk/KDE/kdevelop/lib/kdevprojectcontroller.cpp #579387:579388
@@ -115,8 +115,6 @@
void KDevProjectController::cleanup()
{
- if ( !closeProject() )
- KDevCore::saveSettings();
}
bool KDevProjectController::isLoaded() const
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic