File tree Expand file tree Collapse file tree 4 files changed +41
-3
lines changed
Expand file tree Collapse file tree 4 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -856,8 +856,16 @@ void MainWindow::LoadProjectFile(const QString &filePath)
856856 mUI .mActionEditProjectFile ->setEnabled (true );
857857 delete mProject ;
858858 mProject = new Project (filePath, this );
859- mProject ->Open ();
860- const QString rootpath = mProject ->GetProjectFile ()->GetRootPath ();
859+ CheckProject (mProject );
860+ }
861+
862+ void MainWindow::CheckProject (Project *project)
863+ {
864+ if (!project->IsOpen ())
865+ project->Open ();
866+
867+ QFileInfo inf (project->Filename ());
868+ const QString rootpath = project->GetProjectFile ()->GetRootPath ();
861869
862870 // If the root path is not given or is not "current dir", use project
863871 // file's location directory as root path
@@ -866,7 +874,7 @@ void MainWindow::LoadProjectFile(const QString &filePath)
866874 else
867875 mCurrentDirectory = rootpath;
868876
869- QStringList paths = mProject ->GetProjectFile ()->GetCheckPaths ();
877+ QStringList paths = project ->GetProjectFile ()->GetCheckPaths ();
870878
871879 // If paths not given then check the root path (which may be the project
872880 // file's location, see above). This is to keep the compatibility with
@@ -911,6 +919,7 @@ void MainWindow::NewProjectFile()
911919 mProject ->Edit ();
912920 }
913921 AddProjectMRU (filepath);
922+ CheckProject (mProject );
914923}
915924
916925void MainWindow::CloseProjectFile ()
Original file line number Diff line number Diff line change @@ -169,6 +169,12 @@ public slots:
169169 */
170170 void Save ();
171171
172+ /* *
173+ * @brief Check the project.
174+ * @param project Pointer to the project to check.
175+ */
176+ void CheckProject (Project *project);
177+
172178 /* *
173179 * @brief Slot to create new project file..
174180 *
Original file line number Diff line number Diff line change @@ -47,11 +47,21 @@ Project::~Project()
4747 delete mPFile ;
4848}
4949
50+ QString Project::Filename () const
51+ {
52+ return mFilename ;
53+ }
54+
5055void Project::SetFilename (const QString &filename)
5156{
5257 mFilename = filename;
5358}
5459
60+ bool Project::IsOpen () const
61+ {
62+ return mPFile != NULL ;
63+ }
64+
5565bool Project::Open ()
5666{
5767 mPFile = new ProjectFile (mFilename , this );
Original file line number Diff line number Diff line change @@ -41,12 +41,25 @@ class Project : public QObject
4141 Project (const QString &filename, QWidget *parent = 0 );
4242 ~Project ();
4343
44+ /* *
45+ * @brief Return the filename of the project.
46+ * @return Project's filename.
47+ */
48+ QString Filename () const ;
49+
4450 /* *
4551 * @brief Set filename for the project file.
4652 * @param filename Filename.
4753 */
4854 void SetFilename (const QString &filename);
4955
56+ /* *
57+ * @brief Is the project open?
58+ * The project is considered to be open if it has an opened project file.
59+ * @return true if the project is open, false otherwise.
60+ */
61+ bool IsOpen () const ;
62+
5063 /* *
5164 * @brief Open existing project file.
5265 */
You can’t perform that action at this time.
0 commit comments