locig: refresh after edit project

* implemented saving project settings force-refreshes the project if something has changed.
* when nothing has changed while editing the project settings, the project is not refreshed anymore.
* new project window is cleared now before it is displayed.
This commit is contained in:
malte_langkabel
2016-01-18 10:59:32 +01:00
parent 3852bb7e5c
commit 743f91e882
11 changed files with 78 additions and 45 deletions
+6 -6
View File
@@ -42,7 +42,7 @@ std::shared_ptr<Application> Application::create(
std::string startupProjectFilePath = ApplicationSettings::getInstance()->getStartupProjectFilePath();
if (startupProjectFilePath.size())
{
MessageLoadProject(startupProjectFilePath).dispatch();
MessageLoadProject(startupProjectFilePath, false).dispatch();
ptr->m_mainView->hideStartScreen();
}
@@ -73,7 +73,7 @@ Application::~Application()
m_mainView->saveLayout();
}
void Application::loadProject(const FilePath& projectSettingsFilePath)
void Application::loadProject(const FilePath& projectSettingsFilePath, bool forceRefresh)
{
MessageStatus("Loading Project: " + projectSettingsFilePath.str()).dispatch();
@@ -88,7 +88,7 @@ void Application::loadProject(const FilePath& projectSettingsFilePath)
m_componentManager->refreshViews();
m_project = Project::create(m_storageCache.get());
m_project->loadProject(projectSettingsFilePath);
m_project->load(projectSettingsFilePath, forceRefresh);
m_mainView->updateRecentProjectMenu();
m_mainView->hideStartScreen();
@@ -101,12 +101,12 @@ void Application::refreshProject()
m_storageCache->clear();
m_componentManager->refreshViews();
m_project->reloadProject();
m_project->reload();
}
void Application::saveProject(const FilePath& projectSettingsFilePath)
{
if (!m_project->saveProject(projectSettingsFilePath))
if (!m_project->save(projectSettingsFilePath))
{
LOG_ERROR("No Project Settings File defined");
}
@@ -138,7 +138,7 @@ void Application::handleMessage(MessageFinishedParsing* message)
void Application::handleMessage(MessageLoadProject* message)
{
loadProject(message->projectSettingsFilePath);
loadProject(message->projectSettingsFilePath, message->forceRefresh);
}
void Application::handleMessage(MessageRefresh* message)
+1 -1
View File
@@ -32,7 +32,7 @@ public:
~Application();
void loadProject(const FilePath& projectSettingsFilePath);
void loadProject(const FilePath& projectSettingsFilePath, bool forceRefresh);
void refreshProject();
void saveProject(const FilePath& projectSettingsFilePath);
+9 -3
View File
@@ -25,7 +25,7 @@ Project::~Project()
{
}
bool Project::loadProject(const FilePath& projectSettingsFile)
bool Project::load(const FilePath& projectSettingsFile, bool forceRefresh)
{
bool success = ProjectSettings::getInstance()->load(projectSettingsFile);
if (success)
@@ -34,6 +34,12 @@ bool Project::loadProject(const FilePath& projectSettingsFile)
updateFileManager();
}
if (forceRefresh)
{
clearStorage();
m_storageWasLoaded = false;
}
if (m_storageWasLoaded)
{
m_storage->startParsing();
@@ -50,7 +56,7 @@ bool Project::loadProject(const FilePath& projectSettingsFile)
return success;
}
bool Project::saveProject(const FilePath& projectSettingsFile)
bool Project::save(const FilePath& projectSettingsFile)
{
if (!projectSettingsFile.empty())
{
@@ -69,7 +75,7 @@ bool Project::saveProject(const FilePath& projectSettingsFile)
return true;
}
void Project::reloadProject()
void Project::reload()
{
if (!m_projectSettingsFilepath.empty())
{
+3 -3
View File
@@ -17,9 +17,9 @@ public:
~Project();
bool loadProject(const FilePath& projectSettingsFile);
bool saveProject(const FilePath& projectSettingsFile);
void reloadProject();
bool load(const FilePath& projectSettingsFile, bool forceRefresh);
bool save(const FilePath& projectSettingsFile);
void reload();
void clearStorage();
@@ -6,8 +6,9 @@
class MessageLoadProject: public Message<MessageLoadProject>
{
public:
MessageLoadProject(const std::string& filePath)
MessageLoadProject(const std::string& filePath, bool forceRefresh)
: projectSettingsFilePath(filePath)
, forceRefresh(forceRefresh)
{
}
@@ -18,10 +19,11 @@ public:
virtual void print(std::ostream& os) const
{
os << projectSettingsFilePath;
os << projectSettingsFilePath << ", forceRefresh: " << std::boolalpha << forceRefresh;
}
const std::string projectSettingsFilePath;
const bool forceRefresh;
};
#endif // MESSAGE_LOAD_PROJECT_H
+7
View File
@@ -1,6 +1,7 @@
#ifndef UTILITY_H
#define UTILITY_H
#include <algorithm>
#include <deque>
#include <set>
#include <time.h>
@@ -35,6 +36,12 @@ namespace utility
template<typename T>
std::vector<std::string> toStrings(const std::vector<T>& d);
template<typename T>
bool isPermutation(const std::vector<T>& a, const std::vector<T>& b)
{
return std::is_permutation(a.begin(), a.end(), b.begin());
}
bool intersectionPoint(Vec2f a1, Vec2f b1, Vec2f a2, Vec2f b2, Vec2f* i);
size_t digits(size_t n);
@@ -58,7 +58,7 @@ void QtCommandLineParser::parseCommandline()
if(isValidProjectfile)
{
MessageLoadProject(projectfile.str()).dispatch();
MessageLoadProject(projectfile.str(), false).dispatch();
}
else
{
+1 -1
View File
@@ -382,7 +382,7 @@ void QtMainWindow::openProject(const QString &path)
if (!fileName.isEmpty())
{
MessageLoadProject(fileName.toStdString()).dispatch();
MessageLoadProject(fileName.toStdString(), false).dispatch();
clearWindows();
}
}
+44 -27
View File
@@ -7,6 +7,7 @@
#include <QSysInfo>
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/utility.h"
#include "settings/ProjectSettings.h"
@@ -43,6 +44,11 @@ void QtTextLine::setText(QString text)
m_data->setText(text);
}
void QtTextLine::clearText()
{
m_data->clear();
}
void QtTextLine::handleButtonPress()
{
QString file = QFileDialog::getExistingDirectory(this, tr("Select Directory"), "");
@@ -66,8 +72,12 @@ QSize QtProjectSetupScreen::sizeHint() const
void QtProjectSetupScreen::clear()
{
m_projectName->setText("");
m_projectFileLocation->setText("");
m_projectName->clear();
m_projectFileLocation->clearText();
m_language->setCurrentIndex(0);
m_cppStandard->setCurrentIndex(0);
m_cStandard->setCurrentIndex(0);
m_sourcePaths->clear();
m_includePaths->clear();
@@ -95,8 +105,7 @@ void QtProjectSetupScreen::loadEmpty()
updateTitle("NEW PROJECT");
updateDoneButton("Create");
m_cppStandard->setCurrentIndex(0);
m_cStandard->setCurrentIndex(0);
clear();
}
void QtProjectSetupScreen::loadProjectSettings()
@@ -238,45 +247,53 @@ void QtProjectSetupScreen::handleUpdateButtonPress()
return;
}
ProjectSettings* projSettings = ProjectSettings::getInstance().get();
projSettings->clear();
std::shared_ptr<ProjectSettings> projectSettings = ProjectSettings::getInstance();
projSettings->setLanguage(m_language->currentText().toStdString());
std::string newLanguage = m_language->currentText().toStdString();
std::string newStandard = "";
if (m_cppStandard->isVisible())
{
projSettings->setStandard(m_cppStandard->currentText().toStdString());
newStandard = m_cppStandard->currentText().toStdString();
}
else if (m_cStandard->isVisible())
{
projSettings->setStandard(m_cStandard->currentText().toStdString());
}
projSettings->setSourcePaths(m_sourcePaths->getList());
projSettings->setHeaderSearchPaths(m_includePaths->getList());
if (m_frameworkPaths)
{
projSettings->setFrameworkSearchPaths(m_frameworkPaths->getList());
newStandard = m_cStandard->currentText().toStdString();
}
std::string projectFile =
std::vector<FilePath> newSourcePaths = m_sourcePaths->getList();
std::vector<FilePath> newHeaderSearchPaths = m_includePaths->getList();
std::vector<FilePath> newFrameworkPaths = m_frameworkPaths ? m_frameworkPaths->getList() : std::vector<FilePath>();
bool somethingChanged = !(
newLanguage == projectSettings->getLanguage() &&
newStandard == projectSettings->getStandard() &&
utility::isPermutation<FilePath>(newSourcePaths, projectSettings->getSourcePaths()) &&
utility::isPermutation<FilePath>(newHeaderSearchPaths, projectSettings->getHeaderSearchPaths()) &&
utility::isPermutation<FilePath>(newFrameworkPaths, projectSettings->getFrameworkSearchPaths())
);
projectSettings->clear();
projectSettings->setLanguage(newLanguage);
projectSettings->setStandard(newStandard);
projectSettings->setSourcePaths(newSourcePaths);
projectSettings->setHeaderSearchPaths(newHeaderSearchPaths);
projectSettings->setFrameworkSearchPaths(newFrameworkPaths);
std::string projectFilePath =
m_projectFileLocation->getText().toStdString() + "/" + m_projectName->text().toStdString() + ".coatiproject";
projSettings->save(projectFile);
projSettings->setLanguage(m_language->currentText().toStdString());
projectSettings->save(projectFilePath);
if (m_cppStandard->isVisible())
if (m_title->text() == "NEW PROJECT")
{
projSettings->setStandard(m_cppStandard->currentText().toStdString());
MessageLoadProject(projectFilePath, false).dispatch();
}
else if (m_cStandard->isVisible())
else if (somethingChanged)
{
projSettings->setStandard(m_cStandard->currentText().toStdString());
MessageLoadProject(projectFilePath, true).dispatch();
}
MessageLoadProject(projectFile).dispatch();
clear();
emit finished();
}
@@ -20,6 +20,7 @@ public:
QtTextLine(QWidget *parent);
QString getText();
void setText(QString text);
void clearText();
private slots:
void handleButtonPress();
+1 -1
View File
@@ -22,7 +22,7 @@ QtRecentProjectButton::QtRecentProjectButton(const QString &text, QWidget *paren
void QtRecentProjectButton::handleButtonClick()
{
MessageLoadProject(m_projectFile).dispatch();
MessageLoadProject(m_projectFile, false).dispatch();
};
QtStartScreen::QtStartScreen(QWidget *parent)