logic: Ask user before reparsing the project
While the message box with the question is visible the ui is blocked. A message appears when: * when project was edited * when preferences were edited * when project file has more recent changes than db * when db has a different version than Coati
This commit is contained in:
@@ -10,9 +10,10 @@
|
||||
#include "utility/utilityString.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
SqliteStorage::SqliteStorage(const std::string& dbFilePath)
|
||||
SqliteStorage::SqliteStorage(const FilePath& dbFilePath)
|
||||
: m_dbFilePath(dbFilePath)
|
||||
{
|
||||
m_database.open(dbFilePath.c_str());
|
||||
m_database.open(m_dbFilePath.str().c_str());
|
||||
|
||||
m_database.execDML("PRAGMA foreign_keys=ON;");
|
||||
}
|
||||
@@ -22,23 +23,17 @@ SqliteStorage::~SqliteStorage()
|
||||
m_database.close();
|
||||
}
|
||||
|
||||
bool SqliteStorage::init()
|
||||
void SqliteStorage::init()
|
||||
{
|
||||
Version version = getVersion();
|
||||
|
||||
if (version.isEmpty())
|
||||
{
|
||||
setup();
|
||||
return false;
|
||||
}
|
||||
else if (version.isDifferentStorageVersionThan(Version::getApplicationVersion()))
|
||||
{
|
||||
clear();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +66,11 @@ void SqliteStorage::rollbackTransaction()
|
||||
m_database.execDML("ROLLBACK TRANSACTION;");
|
||||
}
|
||||
|
||||
FilePath SqliteStorage::getDbFilePath() const
|
||||
{
|
||||
return m_dbFilePath;
|
||||
}
|
||||
|
||||
Version SqliteStorage::getVersion() const
|
||||
{
|
||||
std::string versionStr = getMetaValue("version");
|
||||
|
||||
@@ -20,10 +20,10 @@ class Version;
|
||||
class SqliteStorage
|
||||
{
|
||||
public:
|
||||
SqliteStorage(const std::string& dbFilePath);
|
||||
SqliteStorage(const FilePath& dbFilePath);
|
||||
~SqliteStorage();
|
||||
|
||||
bool init();
|
||||
void init();
|
||||
void setup();
|
||||
void clear();
|
||||
|
||||
@@ -31,6 +31,8 @@ public:
|
||||
void commitTransaction();
|
||||
void rollbackTransaction();
|
||||
|
||||
FilePath getDbFilePath() const;
|
||||
|
||||
Version getVersion() const;
|
||||
void setVersion(const Version& version);
|
||||
|
||||
@@ -129,6 +131,7 @@ private:
|
||||
ResultType getFirstResult(const std::string& query) const;
|
||||
|
||||
mutable CppSQLite3DB m_database;
|
||||
FilePath m_dbFilePath;
|
||||
};
|
||||
|
||||
template <typename ResultType>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
Storage::Storage(const FilePath& dbPath)
|
||||
: m_sqliteStorage(dbPath.str())
|
||||
: m_sqliteStorage(dbPath)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -33,18 +33,23 @@ Storage::~Storage()
|
||||
{
|
||||
}
|
||||
|
||||
FilePath Storage::getDbFilePath() const
|
||||
{
|
||||
return m_sqliteStorage.getDbFilePath();
|
||||
}
|
||||
|
||||
Version Storage::getVersion() const
|
||||
{
|
||||
return m_sqliteStorage.getVersion();
|
||||
}
|
||||
|
||||
bool Storage::init()
|
||||
void Storage::init()
|
||||
{
|
||||
m_commandIndex.addNode(0, NameHierarchy(SearchMatch::getCommandName(SearchMatch::COMMAND_ALL)));
|
||||
m_commandIndex.addNode(0, NameHierarchy(SearchMatch::getCommandName(SearchMatch::COMMAND_ERROR)));
|
||||
m_commandIndex.finishSetup();
|
||||
|
||||
return m_sqliteStorage.init();
|
||||
m_sqliteStorage.init();
|
||||
}
|
||||
|
||||
void Storage::clear()
|
||||
|
||||
@@ -22,9 +22,10 @@ public:
|
||||
Storage(const FilePath& dbPath);
|
||||
virtual ~Storage();
|
||||
|
||||
FilePath getDbFilePath() const;
|
||||
Version getVersion() const;
|
||||
|
||||
bool init();
|
||||
void init();
|
||||
void clear();
|
||||
void clearCaches();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user