Skip to content
Snippets Groups Projects
Commit da449098 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

simplify logic

parent 0a389851
No related branches found
No related tags found
1 merge request!427Reduce include dependences in GUI; break cyclic dependence between View and Model
Pipeline #48763 passed
......@@ -72,6 +72,13 @@ QString ProjectDocument::projectDir() const
return m_project_dir;
}
QString ProjectDocument::validProjectDir() const
{
if (m_project_name.isEmpty())
return "";
return m_project_dir;
}
void ProjectDocument::setProjectDir(const QString& text)
{
m_project_dir = text;
......
......@@ -62,6 +62,7 @@ public:
void setProjectName(const QString& text);
QString projectDir() const;
QString validProjectDir() const;
void setProjectDir(const QString& text);
QString projectFileName() const;
......
......@@ -123,11 +123,9 @@ void ProjectManager::writeSettings()
QStringList ProjectManager::recentProjects()
{
QStringList updatedList;
for (QString fileName : m_recentProjects) {
QFile fin(fileName);
if (fin.exists())
for (QString fileName : m_recentProjects)
if (QFile fin(fileName); fin.exists())
updatedList.append(fileName);
}
m_recentProjects = updatedList;
return m_recentProjects;
}
......@@ -136,8 +134,8 @@ QStringList ProjectManager::recentProjects()
QString ProjectManager::projectDir() const
{
if (gSessionData->projectDocument && gSessionData->projectDocument->hasValidNameAndPath())
return gSessionData->projectDocument->projectDir();
if (gSessionData->projectDocument)
return gSessionData->projectDocument->validProjectDir();
return "";
}
......@@ -146,11 +144,9 @@ QString ProjectManager::projectDir() const
QString ProjectManager::userExportDir() const
{
QString result = projectDir();
if (result.isEmpty())
result = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
return result;
if (QString dir = projectDir(); !dir.isEmpty())
return dir;
return QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
}
//! Returns directory name which was used by the user to import files.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment