Opening the last-opened Projects

Andreas Pakulat apaku at gmx.de
Thu Jul 19 10:25:32 UTC 2007


On 19.07.07 12:17:41, Andreas Pakulat wrote:
> Hi,
> 
> David just asked me wether this is supposed to work or not, of course
> its not supposed to work. 
> 
> I had a quick look (and wrote a small "hackish" patch to allow that) and
> turns out that there are some questions:
> 
> How do we want to handle this? The attached patch adds a new member
> function to projectcontroller (not the interface) which reads a config
> setting with the urls. This can be triggered from the application's
> main.cpp as shown in the 2nd patch. The question is: Do project(s) given
> at the commandline disable the loading of last-opened projects or are
> they loaded additionally? 
> 
> How are loadSettings and saveSettings in projectcontroller supposed to
> be used? From where should they be called, whats the bool flag they have
> for?
> 
> Last but not least: Somehow Core doesn't seem to be deleted properly. I
> mean, I added projectcontroller->cleanup() call into Core::cleanup() but
> the debugmessage is not printed and the configuration is not saved. Also
> I wonder why we don't use K_GLOBAL_STATIC for Core?

And here the attachments.

Andreas

-- 
Give thought to your reputation.  Consider changing name and moving to
a new town.
-------------- next part --------------
Index: projectcontroller.cpp
===================================================================
--- projectcontroller.cpp	(Revision 689461)
+++ projectcontroller.cpp	(Arbeitskopie)
@@ -162,8 +162,16 @@
 
 void ProjectController::cleanup()
 {
+    QStringList lastprojects;
+    kDebug(9000) << "Cleaning the project controller" << endl;
     foreach( IProject* project, d->m_projects )
+    {
+        lastprojects << project->projectFileUrl().url();
         closeProject( project );
+    }
+    KConfigGroup group = KGlobal::config()->group( "Projects" );
+    group.writeEntry( "OpenedProjects", lastprojects );
+    KGlobal::config()->sync();
 }
 
 void ProjectController::loadSettings( bool projectIsLoaded )
@@ -176,6 +184,16 @@
     Q_UNUSED( projectIsLoaded );
 }
 
+void ProjectController::loadPreviousProjects()
+{
+    KConfigGroup group = KGlobal::config()->group( "Projects" );
+    QStringList lastprojects = group.readEntry( "OpenedProjects", QStringList() );
+    foreach( QString url, lastprojects )
+    {
+        KUrl u(url);
+        openProject(u);
+    }
+}
 
 int ProjectController::projectCount() const
 {
Index: projectcontroller.h
===================================================================
--- projectcontroller.h	(Revision 689461)
+++ projectcontroller.h	(Arbeitskopie)
@@ -47,6 +47,7 @@
     virtual ProjectModel* projectModel();
 
     IProject* findProjectForUrl( const KUrl& ) const;
+    void loadPreviousProjects();
 
 //     IProject* currentProject() const;
 
Index: core.cpp
===================================================================
--- core.cpp	(Revision 689461)
+++ core.cpp	(Arbeitskopie)
@@ -116,6 +116,7 @@
 void Core::cleanup()
 {
     d->pluginController->cleanup();
+    d->projectController->cleanup();
 }
 
 IUiController *Core::uiController()
-------------- next part --------------
Index: main.cpp
===================================================================
--- main.cpp	(Revision 689461)
+++ main.cpp	(Arbeitskopie)
@@ -47,6 +47,7 @@
 // #include "kdevlanguagecontroller.h"
 #include "splashscreen.h"
 #include <plugincontroller.h>
+#include <projectcontroller.h>
 // #include "kdevprojectcontroller.h"
 // #include "kdevdocumentcontroller.h"
 // #include "kdevbackgroundparser.h"
@@ -155,6 +156,7 @@
         splash->showMessage( i18n( "Starting GUI" ) );
     }
 
+    Core::self()->projectControllerInternal()->loadPreviousProjects();
 //     bool openProject = false;
 //     QString projectName = args->getOption("project");
 //     if ( !projectName.isEmpty() )


More information about the KDevelop-devel mailing list