build: Fixed clang errors and warnings, incremented storage version

This commit is contained in:
Eberhard Graether
2017-02-13 00:32:52 +01:00
parent 97fd40fe9b
commit 17d9c87a5d
9 changed files with 70 additions and 165 deletions
+43 -44
View File
@@ -1,50 +1,6 @@
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
Token.cpp ERROR: Location Id was not referenced by this Token. Token.cpp ERROR: Location Id was not referenced by this Token.
Node.cpp WARNING: Cannot change NodeType after it was already set from namespace to class Node.cpp WARNING: Cannot change NodeType after it was already set from namespace to class
Edge.cpp ERROR: Nodes are not plain copies. Edge.cpp ERROR: Nodes are not plain copies.
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: send MessageStatus Enabled console and file logging. INFO: send MessageStatus Enabled console and file logging.
INFO: send TestMessage INFO: send TestMessage
INFO: send TestMessage INFO: send TestMessage
@@ -73,3 +29,46 @@ TextAccess.cpp WARNING: Line numbers start with one, is 0
TextAccess.cpp WARNING: Line numbers start with one, is 0 TextAccess.cpp WARNING: Line numbers start with one, is 0
TokenLocationCollection.cpp ERROR: TokenLocation has wrong boundaries: file.c 2:3 2:1 TokenLocationCollection.cpp ERROR: TokenLocation has wrong boundaries: file.c 2:3 2:1
TokenLocationCollection.cpp ERROR: TokenLocation has wrong boundaries: file.c 4:1 1:10 TokenLocationCollection.cpp ERROR: TokenLocation has wrong boundaries: file.c 4:1 1:10
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
INFO: Indexer - indexing source file: input.cc
+4 -93
View File
@@ -9,7 +9,7 @@
#include "utility/text/TextAccess.h" #include "utility/text/TextAccess.h"
#include "utility/Version.h" #include "utility/Version.h"
const size_t SqliteStorage::STORAGE_VERSION = 8; const size_t SqliteStorage::STORAGE_VERSION = 9;
SqliteStorage::SqliteStorage(const FilePath& dbFilePath) SqliteStorage::SqliteStorage(const FilePath& dbFilePath)
: m_dbFilePath(dbFilePath.canonical()) : m_dbFilePath(dbFilePath.canonical())
@@ -340,35 +340,6 @@ Id SqliteStorage::addNodeBookmark(const NodeBookmark& bookmark)
/*tokenName = utility::replace(tokenName, "\\", "/"); /*tokenName = utility::replace(tokenName, "\\", "/");
comment = utility::replace(comment, "\\", "/");*/ comment = utility::replace(comment, "\\", "/");*/
// for backwards compatibility
m_database.execDML(
"CREATE TABLE IF NOT EXISTS nodeBookmark("
"id INTEGER NOT NULL, "
"name TEXT, "
"comment TEXT, "
"timestamp TEXT, "
"category INTEGER, "
"PRIMARY KEY(id), "
"FOREIGN KEY(category) REFERENCES bookmarkCategory(id));"
);
m_database.execDML(
"CREATE TABLE IF NOT EXISTS nodeBookmarkToken("
"id INTEGER NOT NULL, "
"bookmarkId INTEGER NOT NULL, "
"name TEXT, "
"type INTEGER, "
"PRIMARY KEY(id), "
"FOREIGN KEY(bookmarkId) REFERENCES nodeBookmark(id) ON DELETE CASCADE);"
);
m_database.execDML(
"CREATE TABLE IF NOT EXISTS bookmarkCategory("
"id INTEGER NOT NULL, "
"name TEXT, "
"PRIMARY KEY(id));"
);
std::string statement = "INSERT INTO nodeBookmark(name, comment, timestamp, category) " std::string statement = "INSERT INTO nodeBookmark(name, comment, timestamp, category) "
"VALUES (?, ?, ?, ?);"; "VALUES (?, ?, ?, ?);";
@@ -397,7 +368,7 @@ Id SqliteStorage::addNodeBookmark(const NodeBookmark& bookmark)
stmt.execDML(); stmt.execDML();
} }
return id; return id;
} }
@@ -410,46 +381,6 @@ Id SqliteStorage::addEdgeBookmark(const EdgeBookmark& bookmark)
tokenName = utility::replace(tokenName, "'", "''"); tokenName = utility::replace(tokenName, "'", "''");
comment = utility::replace(comment, "'", "''"); comment = utility::replace(comment, "'", "''");
// for backwards compatibility
m_database.execDML(
"CREATE TABLE IF NOT EXISTS edgeBookmark("
"id INTEGER NOT NULL, "
"name TEXT, "
"comment TEXT, "
"timestamp TEXT, "
"category INTEGER, "
"PRIMARY KEY(id), "
"FOREIGN KEY(category) REFERENCES bookmarkCategory(id));"
);
m_database.execDML(
"CREATE TABLE IF NOT EXISTS edgeBookmarkToken("
"id INTEGER NOT NULL, "
"bookmarkId INTEGER NOT NULL, "
"name TEXT, "
"type INTEGER, "
"PRIMARY KEY(id), "
"FOREIGN KEY(bookmarkId) REFERENCES edgeBookmark(id) ON DELETE CASCADE);"
);
m_database.execDML(
"CREATE TABLE IF NOT EXISTS edgeBaseBookmark("
"id INTEGER NOT NULL, "
"edgeId INTEGER, "
"PRIMARY KEY(id), "
"FOREIGN KEY(edgeId) REFERENCES edgeBookmark(id) ON DELETE CASCADE);"
);
m_database.execDML(
"CREATE TABLE IF NOT EXISTS edgeBaseBookmarkToken("
"id INTEGER NOT NULL, "
"bookmarkId INTEGER NOT NULL, "
"name TEXT, "
"type INTEGER, "
"PRIMARY KEY(id), "
"FOREIGN KEY(bookmarkId) REFERENCES edgeBaseBookmark(id) ON DELETE CASCADE);"
);
std::string statement = "INSERT INTO edgeBookmark(name, comment, timestamp, category) " std::string statement = "INSERT INTO edgeBookmark(name, comment, timestamp, category) "
"VALUES (?, ?, ?, ?);"; "VALUES (?, ?, ?, ?);";
@@ -487,9 +418,6 @@ Id SqliteStorage::addEdgeBookmark(const EdgeBookmark& bookmark)
for (unsigned int i = 0; i < bookmark.getTokenNames().size(); i++) for (unsigned int i = 0; i < bookmark.getTokenNames().size(); i++)
{ {
std::string name = bookmark.getTokenNames()[i];
int type = bookmark.getTokenTypes()[i];
statement = "INSERT INTO edgeBaseBookmarkToken(bookmarkId, name, type) " statement = "INSERT INTO edgeBaseBookmarkToken(bookmarkId, name, type) "
"VALUES (" + std::to_string(baseId) + ", ?, " + std::to_string(bookmark.getTokenTypes()[i]) + ");"; "VALUES (" + std::to_string(baseId) + ", ?, " + std::to_string(bookmark.getTokenTypes()[i]) + ");";
@@ -504,14 +432,6 @@ Id SqliteStorage::addEdgeBookmark(const EdgeBookmark& bookmark)
Id SqliteStorage::addBookmarkCategory(const std::string& name) Id SqliteStorage::addBookmarkCategory(const std::string& name)
{ {
// for backwards compatibility
m_database.execDML(
"CREATE TABLE IF NOT EXISTS bookmarkCategory("
"id INTEGER NOT NULL, "
"name TEXT, "
"PRIMARY KEY(id));"
);
std::string statement = "INSERT INTO bookmarkCategory(name) " std::string statement = "INSERT INTO bookmarkCategory(name) "
"VALUES (?);"; "VALUES (?);";
@@ -1064,7 +984,7 @@ bool SqliteStorage::checkNodeBookmarkExistsByNames(const std::vector<std::string
insert = false; insert = false;
} }
return true; return true;
} }
@@ -1262,15 +1182,6 @@ void SqliteStorage::removeBookmarkCategory(Id id)
); );
} }
Id SqliteStorage::getTokenIdByName(const std::string& name) const
{
/*CppSQLite3Query q = m_database.execQuery((
"SELECT id FROM bookmark WHERE " + " foo " + ";"
).c_str());*/
return -1;
}
int SqliteStorage::getNodeCount() const int SqliteStorage::getNodeCount() const
{ {
return executeScalar("SELECT COUNT(*) FROM node;"); return executeScalar("SELECT COUNT(*) FROM node;");
@@ -1521,7 +1432,7 @@ void SqliteStorage::setupTables()
{ {
LOG_ERROR(std::to_string(e.errorCode()) + ": " + e.errorMessage()); LOG_ERROR(std::to_string(e.errorCode()) + ": " + e.errorMessage());
throw(std::exception("fail")); throw(std::exception());
// todo: cancel project creation and destroy created files, display message // todo: cancel project creation and destroy created files, display message
} }
-2
View File
@@ -150,8 +150,6 @@ public:
bool checkBookmarkCategoryExists(const std::string& name) const; bool checkBookmarkCategoryExists(const std::string& name) const;
void removeBookmarkCategory(Id id); void removeBookmarkCategory(Id id);
Id getTokenIdByName(const std::string& name) const;
template <typename ResultType> template <typename ResultType>
ResultType getFirstById(const Id id) const ResultType getFirstById(const Id id) const
{ {
@@ -63,6 +63,8 @@ StorageEdge StorageAccessProxy::getEdgeById(Id edgeId) const
{ {
return m_subject->getEdgeById(edgeId); return m_subject->getEdgeById(edgeId);
} }
return StorageEdge();
} }
bool StorageAccessProxy::checkEdgeExists(Id edgeId) const bool StorageAccessProxy::checkEdgeExists(Id edgeId) const
+1 -1
View File
@@ -86,7 +86,7 @@ public:
virtual void removeEdgeBookmark(Id id); virtual void removeEdgeBookmark(Id id);
virtual void editEdgeBookmark(const EdgeBookmark& bookmark); virtual void editEdgeBookmark(const EdgeBookmark& bookmark);
virtual virtual std::vector<BookmarkCategory> getAllBookmarkCategories() const; virtual std::vector<BookmarkCategory> getAllBookmarkCategories() const;
virtual bool checkBookmarkCategoryExists(const std::string& name) const; virtual bool checkBookmarkCategoryExists(const std::string& name) const;
virtual void removeBookmarkCategory(Id id); virtual void removeBookmarkCategory(Id id);
+3 -5
View File
@@ -100,8 +100,6 @@ void QtBookmark::setBookmark(const std::shared_ptr<Bookmark> bookmark)
m_activateButton->setText(bookmark->getDisplayName().c_str()); m_activateButton->setText(bookmark->getDisplayName().c_str());
bool isValid = m_bookmark->isValid();
if (m_bookmark->isValid() == false) if (m_bookmark->isValid() == false)
{ {
m_activateButton->setEnabled(false); m_activateButton->setEnabled(false);
@@ -173,8 +171,8 @@ void QtBookmark::deleteClicked()
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText("Delete Bookmark"); msgBox.setText("Delete Bookmark");
msgBox.setInformativeText("Do you really want to delete this bookmark?"); msgBox.setInformativeText("Do you really want to delete this bookmark?");
QAbstractButton* yesButton = msgBox.addButton("Delete", QMessageBox::ButtonRole::YesRole); msgBox.addButton("Delete", QMessageBox::ButtonRole::YesRole);
QAbstractButton* noButton = msgBox.addButton("Keep", QMessageBox::ButtonRole::NoRole); msgBox.addButton("Keep", QMessageBox::ButtonRole::NoRole);
msgBox.setIcon(QMessageBox::Icon::Question); msgBox.setIcon(QMessageBox::Icon::Question);
int ret = msgBox.exec(); int ret = msgBox.exec();
@@ -235,7 +233,7 @@ std::string QtBookmark::getDateString() const
std::string result = "n/a"; std::string result = "n/a";
TimePoint creationDate = m_bookmark->getTimeStamp(); TimePoint creationDate = m_bookmark->getTimeStamp();
float delta = TimePoint::now() - creationDate; float delta = TimePoint::now() - creationDate;
if (delta < 3600.0f) // less than an hour ago if (delta < 3600.0f) // less than an hour ago
+5 -5
View File
@@ -137,13 +137,13 @@ void QtBookmarkBar::createBookmarkClicked()
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText("Edit Bookmark"); msgBox.setText("Edit Bookmark");
msgBox.setInformativeText("Do you want to update or delete the Bookmark for the active Token?"); msgBox.setInformativeText("Do you want to update or delete the Bookmark for the active Token?");
QAbstractButton* editButton = msgBox.addButton("Edit", QMessageBox::ButtonRole::YesRole); msgBox.addButton("Edit", QMessageBox::ButtonRole::YesRole);
QAbstractButton* deleteButton = msgBox.addButton("Delete", QMessageBox::ButtonRole::DestructiveRole); msgBox.addButton("Delete", QMessageBox::ButtonRole::DestructiveRole);
QAbstractButton* cancelButton = msgBox.addButton("Cancel", QMessageBox::ButtonRole::NoRole); msgBox.addButton("Cancel", QMessageBox::ButtonRole::NoRole);
msgBox.setIcon(QMessageBox::Icon::Question); msgBox.setIcon(QMessageBox::Icon::Question);
int ret = msgBox.exec(); int ret = msgBox.exec();
if (ret == 0) // QMessageBox::Yes) if (ret == 0) // QMessageBox::Yes
{ {
MessageDisplayBookmarkCreator().dispatch(); MessageDisplayBookmarkCreator().dispatch();
} }
@@ -214,7 +214,7 @@ void QtBookmarkBar::doDisplayBookmarks(const std::vector<std::shared_ptr<Bookmar
m_bookmarkBrowser = new QtBookmarkBrowser(); m_bookmarkBrowser = new QtBookmarkBrowser();
m_bookmarkBrowser->setupBookmarkBrowser(); m_bookmarkBrowser->setupBookmarkBrowser();
} }
m_bookmarkBrowser->setBookmarks(bookmarks); m_bookmarkBrowser->setBookmarks(bookmarks);
m_bookmarkBrowser->show(); m_bookmarkBrowser->show();
} }
@@ -9,11 +9,11 @@
#include "qt/utility/utilityQt.h" #include "qt/utility/utilityQt.h"
QtBookmarkCategory::QtBookmarkCategory() QtBookmarkCategory::QtBookmarkCategory()
: m_name(NULL) : m_layout(NULL)
, m_layout(NULL) , m_name(NULL)
, m_deleteButton(NULL) , m_deleteButton(NULL)
, m_id(-1)
, m_treeItem(NULL) , m_treeItem(NULL)
, m_id(-1)
{ {
setObjectName("bookmark_category"); setObjectName("bookmark_category");
@@ -133,12 +133,12 @@ void QtBookmarkCategory::deleteClicked()
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText("Delete Category"); msgBox.setText("Delete Category");
msgBox.setInformativeText("Do you really want to delete this category AND all containing bookmarks?"); msgBox.setInformativeText("Do you really want to delete this category AND all containing bookmarks?");
QAbstractButton* yesButton = msgBox.addButton("Delete", QMessageBox::ButtonRole::YesRole); msgBox.addButton("Delete", QMessageBox::ButtonRole::YesRole);
QAbstractButton* noButton = msgBox.addButton("Keep", QMessageBox::ButtonRole::NoRole); msgBox.addButton("Keep", QMessageBox::ButtonRole::NoRole);
msgBox.setIcon(QMessageBox::Icon::Question); msgBox.setIcon(QMessageBox::Icon::Question);
int ret = msgBox.exec(); int ret = msgBox.exec();
if (ret == 0) if (ret == 0) // QMessageBox::Yes
{ {
MessageDeleteBookmarkCategoryWithBookmarks(m_id).dispatch(); MessageDeleteBookmarkCategoryWithBookmarks(m_id).dispatch();
} }
+6 -9
View File
@@ -51,20 +51,17 @@ void QtRecentProjectButton::handleButtonClick()
} }
else else
{ {
std::string text = "Couldn't find " + m_projectFilePath.str()
+ " in your filesystem. Delete it from this recent Proejct list?";
// int ret = QMessageBox::question(this, "Missing Project File", text.c_str(), QMessageBox::Yes | QMessageBox::No);
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText("Missing Project File"); msgBox.setText("Missing Project File");
msgBox.setInformativeText(text.c_str()); msgBox.setInformativeText((
QAbstractButton* yesButton = msgBox.addButton("Delete", QMessageBox::ButtonRole::YesRole); "Couldn't find " + m_projectFilePath.str() + " in your filesystem. Delete it from this recent Proejct list?"
QAbstractButton* noButton = msgBox.addButton("Keep", QMessageBox::ButtonRole::NoRole); ).c_str());
msgBox.addButton("Delete", QMessageBox::ButtonRole::YesRole);
msgBox.addButton("Keep", QMessageBox::ButtonRole::NoRole);
msgBox.setIcon(QMessageBox::Icon::Question); msgBox.setIcon(QMessageBox::Icon::Question);
int ret = msgBox.exec(); int ret = msgBox.exec();
if (ret == 0) // QMessageBox::Yes) if (ret == 0) // QMessageBox::Yes
{ {
std::vector<FilePath> recentProjects = ApplicationSettings::getInstance()->getRecentProjects(); std::vector<FilePath> recentProjects = ApplicationSettings::getInstance()->getRecentProjects();
const int maxRecentProjectsCount = ApplicationSettings::getInstance()->getMaxRecentProjectsCount(); const int maxRecentProjectsCount = ApplicationSettings::getInstance()->getMaxRecentProjectsCount();