ui: removed 'Save Project' and 'Save Project As' actions

* removed save actions from menu in QtMainWindow
* removed MessageSaveProject and all Listeners
* updated project loading to ask whether old project and db file should be kept at old location
* fixed crash for missing include files
* fixed simple header search within source paths was broken
This commit is contained in:
Eberhard Graether
2016-06-28 15:59:22 +02:00
parent 2cf033d43a
commit 8ca54f2091
16 changed files with 123 additions and 202 deletions
+43 -26
View File
@@ -1,5 +1,6 @@
#include "Application.h"
#include "utility/file/FileSystem.h"
#include "utility/logging/logging.h"
#include "utility/messaging/MessageQueue.h"
#include "utility/messaging/type/MessageActivateNodes.h"
@@ -201,18 +202,6 @@ void Application::refreshProject()
}
}
void Application::saveProject(const FilePath& projectSettingsFilePath)
{
if (!m_project->save(projectSettingsFilePath))
{
LOG_ERROR("No Project Settings File defined");
}
else
{
MessageStatus("Project saved").dispatch();
}
}
void Application::handleMessage(MessageActivateWindow* message)
{
if (m_hasGUI)
@@ -248,17 +237,50 @@ void Application::handleMessage(MessageLoadProject* message)
{
if (m_hasGUI)
{
std::vector<std::string> options;
options.push_back("Yes");
options.push_back("No");
int result = m_mainView->confirm(
"Some settings were changed, the project needs to be fully reindexed. "
"Do you want to reindex the project?", options);
FilePath path = projectSettingsFilePath;
FilePath oldPath = m_project->getProjectSettingsFilePath();
if (result == 1)
if (oldPath.exists() && oldPath != path)
{
m_project->load(projectSettingsFilePath);
return;
std::vector<std::string> options;
options.push_back("Yes");
options.push_back("No");
int result = m_mainView->confirm(
"You changed the project location. The project file (.coatiproject) and the database file (.coatidb) will "
"be moved to the new location. Do you want to keep a copy of the files in the previous location?"
, options);
FilePath dbPath = FilePath(path).replaceExtension("coatidb");
FilePath olddbPath = FilePath(oldPath).replaceExtension("coatidb");
m_project = Project::create(m_storageCache.get());
if (result == 0)
{
FileSystem::copyFile(olddbPath, dbPath);
}
else
{
FileSystem::remove(oldPath);
FileSystem::rename(olddbPath, dbPath);
}
}
else
{
std::vector<std::string> options;
options.push_back("Yes");
options.push_back("No");
int result = m_mainView->confirm(
"Some settings were changed, the project needs to be fully reindexed. "
"Do you want to reindex the project?", options);
if (result == 1)
{
m_project->load(projectSettingsFilePath);
updateRecentProjects(projectSettingsFilePath);
m_mainView->setTitle("Coati - " + projectSettingsFilePath.fileName());
return;
}
}
}
@@ -301,11 +323,6 @@ void Application::handleMessage(MessageRefresh* message)
}
}
void Application::handleMessage(MessageSaveProject* message)
{
saveProject(message->projectSettingsFilePath);
}
void Application::startMessagingAndScheduling()
{
TaskScheduler::getInstance()->startSchedulerLoopThreaded();
-4
View File
@@ -10,7 +10,6 @@
#include "utility/messaging/type/MessageFinishedParsing.h"
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageSaveProject.h"
class IDECommunicationController;
class NetworkFactory;
@@ -24,7 +23,6 @@ class Application
, public MessageListener<MessageFinishedParsing>
, public MessageListener<MessageLoadProject>
, public MessageListener<MessageRefresh>
, public MessageListener<MessageSaveProject>
{
public:
static std::shared_ptr<Application> create(const Version& version, ViewFactory* viewFactory, NetworkFactory* networkFactory);
@@ -36,7 +34,6 @@ public:
void createAndLoadProject(const FilePath& projectSettingsFilePath);
void loadProject(const FilePath& projectSettingsFilePath);
void refreshProject();
void saveProject(const FilePath& projectSettingsFilePath);
bool hasGUI();
private:
@@ -46,7 +43,6 @@ private:
virtual void handleMessage(MessageFinishedParsing* message);
virtual void handleMessage(MessageLoadProject* message);
virtual void handleMessage(MessageRefresh* message);
virtual void handleMessage(MessageSaveProject* message);
void startMessagingAndScheduling();
-1
View File
@@ -255,7 +255,6 @@ add_files(
utility/messaging/type/MessageRedo.h
utility/messaging/type/MessageRefresh.h
utility/messaging/type/MessageResetZoom.h
utility/messaging/type/MessageSaveProject.h
utility/messaging/type/MessageScrollCode.h
utility/messaging/type/MessageSearch.h
utility/messaging/type/MessageSearchAutocomplete.h
+3 -35
View File
@@ -91,36 +91,6 @@ Project::ProjectState Project::reload()
return m_state;
}
bool Project::save(const FilePath& projectSettingsFile)
{
bool differentLocation = (projectSettingsFile != m_projectSettingsFilepath);
if (!projectSettingsFile.empty())
{
setProjectSettingsFilePath(projectSettingsFile);
}
else
{
differentLocation = false;
}
if (m_projectSettingsFilepath.empty())
{
return false;
}
ProjectSettings settings;
settings.load(m_projectSettingsFilepath);
if (differentLocation || settings != *ProjectSettings::getInstance().get())
{
ProjectSettings::getInstance()->save(m_projectSettingsFilepath);
LOG_INFO_STREAM(<< "ProjectSettings saved to file: " << m_projectSettingsFilepath.str());
}
return true;
}
void Project::clearStorage()
{
if (m_state == PROJECT_OUTVERSIONED)
@@ -291,14 +261,12 @@ Parser::Arguments Project::getParserArguments() const
if (projSettings->getUseSourcePathsForHeaderSearch())
{
std::vector<FilePath> headerSearchSubPaths;
for (FilePath p : projSettings->getAbsoluteHeaderSearchPaths())
for (FilePath p : projSettings->getSourcePaths())
{
std::vector<FilePath> tempPaths = FileSystem::getSubDirectories(p);
headerSearchSubPaths.insert( headerSearchSubPaths.end(), tempPaths.begin(), tempPaths.end() );
utility::append(headerSearchSubPaths, FileSystem::getSubDirectories(p));
}
std::unique(headerSearchSubPaths.begin(),headerSearchSubPaths.end());
utility::append(args.systemHeaderSearchPaths, headerSearchSubPaths);
utility::append(args.systemHeaderSearchPaths, utility::unique(headerSearchSubPaths));
}
utility::append(args.frameworkSearchPaths, projSettings->getAbsoluteFrameworkSearchPaths());
-2
View File
@@ -31,8 +31,6 @@ public:
ProjectState load(const FilePath& projectSettingsFile);
ProjectState reload();
bool save(const FilePath& projectSettingsFile);
void clearStorage();
void logStats() const;
-5
View File
@@ -157,11 +157,6 @@ bool ProjectSettings::setSourceExtensions(const std::vector<std::string> &source
return setValues("source/extensions/source_extensions", sourceExtensions);
}
bool ProjectSettings::isUseSourcePathsForHeaderSearchDefined() const
{
return isValueDefined("source/use_source_paths_for_header_search");
}
bool ProjectSettings::getUseSourcePathsForHeaderSearch() const
{
return getValue<bool>("source/use_source_paths_for_header_search", false);
-1
View File
@@ -47,7 +47,6 @@ public:
std::vector<std::string> getSourceExtensions() const;
bool setSourceExtensions(const std::vector<std::string>& sourceExtensions);
bool isUseSourcePathsForHeaderSearchDefined() const;
bool getUseSourcePathsForHeaderSearch() const;
bool setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch);
+62 -39
View File
@@ -116,14 +116,72 @@ std::string FileSystem::getTimeStringNow() // TODO: move to utility
return boost::posix_time::to_iso_string(boost::posix_time::second_clock::universal_time());
}
bool FileSystem::exists(const std::string& path)
bool FileSystem::exists(const FilePath& path)
{
return boost::filesystem::exists(boost::filesystem::path(path));
return boost::filesystem::exists(path.path());
}
bool FileSystem::remove(const std::string& path)
bool FileSystem::remove(const FilePath& path)
{
return boost::filesystem::remove(path);
return boost::filesystem::remove(path.path());
}
bool FileSystem::rename(const FilePath& from, const FilePath& to)
{
if (!from.exists() || to.exists())
{
return false;
}
boost::filesystem::rename(from.path(), to.path());
return true;
}
bool FileSystem::copyFile(const FilePath& from, const FilePath& to)
{
if (!from.exists() || to.exists())
{
return false;
}
boost::filesystem::copy_file(boost::filesystem::path(from.path()), boost::filesystem::path(to.path()));
return true;
}
bool FileSystem::copy_directory(const FilePath& from, const FilePath& to)
{
if (!from.exists() || to.exists())
{
return false;
}
boost::filesystem::copy_directory(boost::filesystem::path(from.path()),boost::filesystem::path(to.path()));
return true;
}
void FileSystem::createDirectory(const FilePath& path)
{
boost::filesystem::create_directories(path.str());
}
std::vector<FilePath> FileSystem::getSubDirectories(const FilePath &path)
{
std::vector<FilePath> v;
if (!path.exists())
{
return v;
}
for (boost::filesystem::recursive_directory_iterator end, dir(path.str()); dir != end; dir++)
{
if (boost::filesystem::is_directory(dir->path()))
{
v.push_back(FilePath(dir->path()));
}
}
return v;
}
std::string FileSystem::fileName(const std::string& path)
@@ -169,38 +227,3 @@ bool FileSystem::equivalent(const std::string& pathA, const std::string& pathB)
return boost::filesystem::path(pathA).compare(boost::filesystem::path(pathB)) == 0;
}
void FileSystem::createDirectory(const FilePath& path)
{
boost::filesystem::create_directories(path.str());
}
bool FileSystem::copy_directory(const FilePath& from, const FilePath& to)
{
if(!from.exists() || to.exists())
{
return false;
}
boost::filesystem::copy_directory(boost::filesystem::path(from.str()),boost::filesystem::path(to.str()));
return true;
}
std::vector<FilePath> FileSystem::getSubDirectories(const FilePath &path)
{
std::vector<FilePath> v;
if (!path.exists())
{
return v;
}
for (boost::filesystem::recursive_directory_iterator end, dir(path.str()); dir != end; dir++)
{
if (boost::filesystem::is_directory(dir->path()))
{
v.push_back(FilePath(dir->path()));
}
}
return v;
}
+7 -4
View File
@@ -23,15 +23,18 @@ public:
static TimePoint getLastWriteTime(const FilePath& filePath);
static std::string getTimeStringNow();
static bool exists(const FilePath& path);
static bool remove(const FilePath& path);
static bool rename(const FilePath& from, const FilePath& to);
static bool copyFile(const FilePath& from, const FilePath& to);
static bool copy_directory(const FilePath& from, const FilePath& to);
static void createDirectory(const FilePath& path);
static std::vector<FilePath> getSubDirectories(const FilePath& path);
static bool exists(const std::string& path);
static std::string fileName(const std::string& path);
static std::string absoluteFilePath(const std::string& path);
static bool remove(const std::string& path);
static bool copy_directory(const FilePath& from, const FilePath& to);
static std::string extension(const std::string& path);
static std::string filePathWithoutExtension(const std::string& path);
@@ -1,12 +1,14 @@
#ifndef MESSAGE_LOAD_PROJECT_H
#define MESSAGE_LOAD_PROJECT_H
#include "utility/file/FilePath.h"
#include "utility/messaging/Message.h"
class MessageLoadProject: public Message<MessageLoadProject>
class MessageLoadProject
: public Message<MessageLoadProject>
{
public:
MessageLoadProject(const std::string& filePath, bool forceRefresh)
MessageLoadProject(const FilePath& filePath, bool forceRefresh)
: projectSettingsFilePath(filePath)
, forceRefresh(forceRefresh)
{
@@ -19,10 +21,10 @@ public:
virtual void print(std::ostream& os) const
{
os << projectSettingsFilePath << ", forceRefresh: " << std::boolalpha << forceRefresh;
os << projectSettingsFilePath.str() << ", forceRefresh: " << std::boolalpha << forceRefresh;
}
const std::string projectSettingsFilePath;
const FilePath projectSettingsFilePath;
const bool forceRefresh;
};
@@ -1,27 +0,0 @@
#ifndef MESSAGE_SAVE_PROJECT_H
#define MESSAGE_SAVE_PROJECT_H
#include "utility/messaging/Message.h"
class MessageSaveProject: public Message<MessageSaveProject>
{
public:
MessageSaveProject(const std::string& filePath)
: projectSettingsFilePath(filePath)
{
}
static const std::string getStaticType()
{
return "MessageSaveProject";
}
virtual void print(std::ostream& os) const
{
os << projectSettingsFilePath;
}
const std::string projectSettingsFilePath;
};
#endif // MESSAGE_SAVE_PROJECT_H
-22
View File
@@ -30,7 +30,6 @@
#include "utility/messaging/type/MessageRedo.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageResetZoom.h"
#include "utility/messaging/type/MessageSaveProject.h"
#include "utility/messaging/type/MessageSearch.h"
#include "utility/messaging/type/MessageSwitchColorScheme.h"
#include "utility/messaging/type/MessageUndo.h"
@@ -446,22 +445,6 @@ void QtMainWindow::forceRefresh()
MessageRefresh().refreshAll().dispatch();
}
void QtMainWindow::saveProject()
{
MessageSaveProject("").dispatch();
}
void QtMainWindow::saveAsProject()
{
QString filename = "";
filename = QFileDialog::getSaveFileName(this, "Save File as", "", "Coati Project Files (*.coatiproject)");
if(!filename.isEmpty())
{
MessageSaveProject(filename.toStdString()).dispatch();
}
}
void QtMainWindow::undo()
{
MessageUndo().dispatch();
@@ -544,11 +527,6 @@ void QtMainWindow::setupProjectMenu()
menu->addAction(tr("&Edit Project..."), this, SLOT(editProject()));
menu->addSeparator();
menu->addAction(tr("&Save Project"), this, SLOT(saveProject()), QKeySequence::Save);
menu->addAction(tr("Save Project as..."), this, SLOT(saveAsProject()), QKeySequence::SaveAs);
menu->addSeparator();
}
menu->addAction(tr("E&xit"), QCoreApplication::instance(), SLOT(quit()), QKeySequence::Quit);
-3
View File
@@ -117,9 +117,6 @@ public slots:
void refresh();
void forceRefresh();
void saveProject();
void saveAsProject();
void undo();
void redo();
void zoomIn();
@@ -555,8 +555,7 @@ void QtProjectWizzard::showSummary()
void QtProjectWizzard::createProject()
{
std::string path = m_settings.getProjectFileLocation().str() + "/" + m_settings.getProjectName() + ".coatiproject";
FilePath path(m_settings.getProjectFileLocation().str() + "/" + m_settings.getProjectName() + ".coatiproject");
m_settings.save(path);
bool edited = false;
@@ -50,7 +50,7 @@ void PreprocessorCallbacks::InclusionDirective(
clang::CharSourceRange fileNameRange, const clang::FileEntry* fileEntry, llvm::StringRef searchPath,
llvm::StringRef relativePath, const clang::Module* imported
){
if (!m_currentPath.empty())
if (!m_currentPath.empty() && fileEntry)
{
FilePath includedFilePath = FilePath(fileEntry->getName()).canonical();
if (m_fileRegister->hasFilePath(includedFilePath))
-26
View File
@@ -878,20 +878,6 @@
<li>Opens the <a href="#EditProjectWindow">Edit Project Window</a> prefilled with your project settings and allows for changing them.</li>
</ul>
</li>
<li>
<strong>Save Project</strong>
<ul>
<li>Shortcut: <a href="#Shortcuts">Save Project</a></li>
<li>Save the project file.</li>
</ul>
</li>
<li>
<strong>Save Project As</strong>
<ul>
<li>Shortcut: <a href="#"Shortcuts>Save Project As</a></li>
<li>Save the project file to another location. The project file will be duplicated.</li>
</ul>
</li>
<li>
<strong>Exit</strong>
<ul>
@@ -1074,18 +1060,6 @@
<td><kbd>Cmd + O</kbd></td>
<td><kbd>Ctrl + O</kbd></td>
</tr>
<tr>
<th scope="row">Save Project</th>
<td><kbd>Ctrl + S</kbd></td>
<td><kbd>Cmd + S</kbd></td>
<td><kbd>Ctrl + S</kbd></td>
</tr>
<tr>
<th scope="row">Save Project As</th>
<td><kbd>Ctrl + Shift + S</kbd></td>
<td><kbd>Cmd + Shift + S</kbd></td>
<td><kbd>Ctrl + Shift + S</kbd></td>
</tr>
<tr>
<th scope="row">Close Window</th>
<td><kbd>Alt + F4</kbd></td>