logic: More fixes for release

* Fixed crash on undoing aggregation edge
* Avoid mutex locking in logging classes when logging is disabled
* Readded dark color scheme
* Fixed font size of type label in autocompletion list
* Fixed text drawing in autocompletion list
* Only give camelcase score when no noletter score was given
* Added MessageShowErrors to undo stack
* Select error line in table when undoing MessageShowErrors
* Notify user about new Plugin in description of From Visual Studio project setup
* Fixed row height of Project File Location label in project setup
This commit is contained in:
Eberhard Graether
2016-10-14 00:45:37 +02:00
parent 2dc9995cc1
commit 30d222b7db
19 changed files with 626 additions and 137 deletions
+23
View File
@@ -13,6 +13,10 @@
#include "settings/ApplicationSettings.h"
#include "utility/AppPath.h"
#include "utility/commandline/CommandLineParser.h"
#include "utility/logging/ConsoleLogger.h"
#include "utility/logging/FileLogger.h"
#include "utility/logging/logging.h"
#include "utility/logging/LogManager.h"
#include "utility/ResourcePaths.h"
#include "utility/ScopedFunctor.h"
#include "utility/UserPaths.h"
@@ -20,6 +24,21 @@
#include "utility/Version.h"
#include "version.h"
void setupLogging()
{
LogManager::createInstance();
LogManager* logManager = LogManager::getInstance().get();
std::shared_ptr<ConsoleLogger> consoleLogger = std::make_shared<ConsoleLogger>();
consoleLogger->setLogLevel(Logger::LOG_WARNINGS | Logger::LOG_ERRORS);
logManager->addLogger(consoleLogger);
std::shared_ptr<FileLogger> fileLogger = std::make_shared<FileLogger>();
fileLogger->setLogDirectory(UserPaths::getLogPath());
fileLogger->setLogLevel(Logger::LOG_ALL);
logManager->addLogger(fileLogger);
}
void prefillJavaRuntimePath()
{
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
@@ -92,6 +111,8 @@ int main(int argc, char *argv[])
setupApp(argc, argv);
setupLogging();
Application::createInstance(version, nullptr, nullptr);
ScopedFunctor f([](){
Application::destroyInstance();
@@ -130,6 +151,8 @@ int main(int argc, char *argv[])
setupApp(argc, argv);
setupLogging();
qtApp.setAttribute(Qt::AA_UseHighDpiPixmaps);
QtViewFactory viewFactory;
+1 -17
View File
@@ -1,7 +1,5 @@
#include "Application.h"
#include "utility/logging/ConsoleLogger.h"
#include "utility/logging/FileLogger.h"
#include "utility/logging/logging.h"
#include "utility/logging/LogManager.h"
#include "utility/messaging/MessageQueue.h"
@@ -76,21 +74,7 @@ void Application::loadSettings()
settings->load(FilePath(UserPaths::getAppSettingsPath()));
LogManager* logManager = LogManager::getInstance().get();
if (!settings->getLoggingEnabled())
{
logManager->clearLoggers();
}
else if (!logManager->getLoggerCount())
{
std::shared_ptr<ConsoleLogger> consoleLogger = std::make_shared<ConsoleLogger>();
consoleLogger->setLogLevel(Logger::LOG_WARNINGS | Logger::LOG_ERRORS);
logManager->addLogger(consoleLogger);
std::shared_ptr<FileLogger> fileLogger = std::make_shared<FileLogger>();
fileLogger->setLogDirectory(UserPaths::getLogPath());
fileLogger->setLogLevel(Logger::LOG_ALL);
logManager->addLogger(fileLogger);
}
logManager->setLoggingEnabled(settings->getLoggingEnabled());
loadStyle(settings->getColorSchemePath());
}
@@ -42,6 +42,10 @@ void ErrorController::handleMessage(MessageShowErrors* message)
{
if (message->errorId)
{
if (message->isReplayed())
{
getView()->setErrorId(message->errorId);
}
return;
}
@@ -7,6 +7,7 @@
#include "utility/messaging/type/MessageActivateTokens.h"
#include "utility/messaging/type/MessageChangeFileView.h"
#include "utility/messaging/type/MessageColorSchemeTest.h"
#include "utility/messaging/type/MessageFlushUpdates.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageShowErrors.h"
#include "utility/messaging/type/MessageStatus.h"
@@ -138,8 +139,9 @@ void FeatureController::handleMessage(MessageSearch* message)
case SearchMatch::COMMAND_ERROR:
{
MessageShowErrors msg(m_storageAccess->getErrorCount());
msg.setIsReplayed(message->isReplayed());
msg.dispatchImmediately();
msg.setIsReplayed(true);
msg.dispatch();
MessageFlushUpdates().dispatch();
return;
}
@@ -235,6 +235,18 @@ void UndoRedoController::handleMessage(MessageSearchFullText* message)
processCommand(command);
}
void UndoRedoController::handleMessage(MessageShowErrors* message)
{
if (sameMessageTypeAsLast(message) &&
static_cast<MessageShowErrors*>(lastMessage())->errorId == message->errorId)
{
return;
}
Command command(std::make_shared<MessageShowErrors>(*message), Command::ORDER_ACTIVATE);
processCommand(command);
}
void UndoRedoController::handleMessage(MessageShowScope* message)
{
Command command(std::make_shared<MessageShowScope>(*message), Command::ORDER_VIEW);
@@ -347,6 +359,11 @@ void UndoRedoController::replayCommands(std::list<Command>::iterator it)
void UndoRedoController::processCommand(Command command)
{
if (command.message->isReplayed())
{
return;
}
if (command.order != Command::ORDER_ACTIVATE && m_iterator == m_list.begin())
{
return;
@@ -357,40 +374,37 @@ void UndoRedoController::processCommand(Command command)
command.order = Command::ORDER_ADAPT;
}
if (!command.message->isReplayed())
if (command.order == Command::ORDER_ACTIVATE)
{
if (command.order == Command::ORDER_ACTIVATE)
m_iterator = m_list.erase(m_iterator, m_list.end());
}
else if (command.order == Command::ORDER_ADAPT)
{
std::list<Command>::iterator end = m_iterator;
while (end != m_list.end())
{
m_iterator = m_list.erase(m_iterator, m_list.end());
}
else if (command.order == Command::ORDER_ADAPT)
{
std::list<Command>::iterator end = m_iterator;
while (end != m_list.end())
if (end->order == Command::ORDER_ACTIVATE)
{
if (end->order == Command::ORDER_ACTIVATE)
{
break;
}
std::advance(end, 1);
break;
}
m_iterator = m_list.erase(m_iterator, end);
std::advance(end, 1);
}
m_list.insert(m_iterator, command);
m_iterator = m_list.erase(m_iterator, end);
}
if (command.order != Command::ORDER_VIEW)
m_list.insert(m_iterator, command);
if (command.order != Command::ORDER_VIEW)
{
if (m_list.begin() != std::prev(m_iterator))
{
if (m_list.begin() != std::prev(m_iterator))
{
getView()->setUndoButtonEnabled(true);
}
getView()->setUndoButtonEnabled(true);
}
if (m_list.end() == m_iterator)
{
getView()->setRedoButtonEnabled(false);
}
if (m_list.end() == m_iterator)
{
getView()->setRedoButtonEnabled(false);
}
}
}
@@ -20,6 +20,7 @@
#include "utility/messaging/type/MessageScrollCode.h"
#include "utility/messaging/type/MessageSearch.h"
#include "utility/messaging/type/MessageSearchFullText.h"
#include "utility/messaging/type/MessageShowErrors.h"
#include "utility/messaging/type/MessageShowScope.h"
#include "utility/messaging/type/MessageUndo.h"
@@ -45,6 +46,7 @@ class UndoRedoController
, public MessageListener<MessageScrollCode>
, public MessageListener<MessageSearch>
, public MessageListener<MessageSearchFullText>
, public MessageListener<MessageShowErrors>
, public MessageListener<MessageShowScope>
, public MessageListener<MessageUndo>
{
@@ -88,6 +90,7 @@ private:
virtual void handleMessage(MessageScrollCode* message);
virtual void handleMessage(MessageSearch* message);
virtual void handleMessage(MessageSearchFullText* message);
virtual void handleMessage(MessageShowErrors* message);
virtual void handleMessage(MessageShowScope* message);
virtual void handleMessage(MessageUndo* message);
+1
View File
@@ -18,6 +18,7 @@ public:
virtual void clear() = 0;
virtual void addError(const StorageError& error) = 0;
virtual void setErrorId(Id errorId) = 0;
};
#endif // ERROR_VIEW_H
+7 -8
View File
@@ -389,8 +389,14 @@ int SearchIndex::score(const std::string& text, const std::vector<size_t>& indic
size_t index = indices[i];
// after no letter
bool prevIsNoLetter = (index == 0 || noLetters.find(text[index - 1]) != noLetters.end());
if (prevIsNoLetter)
{
noLetterScore += noLetterBonus;
}
// camel case
if (isupper(text[index]))
else if (isupper(text[index]))
{
bool prevIsLower = (index > 0 && islower(text[index - 1]));
bool nextIsLower = (index + 1 == text.size() || islower(text[index + 1]));
@@ -400,13 +406,6 @@ int SearchIndex::score(const std::string& text, const std::vector<size_t>& indic
camelCaseScore += camelCaseBonus;
}
}
// after no letter
bool prevIsNoLetter = (index == 0 || noLetters.find(text[index - 1]) != noLetters.end());
if (prevIsNoLetter)
{
noLetterScore += noLetterBonus;
}
}
int leadingStartScore = std::max(int(indices[0]) * delayedStartBonus, minDelayedStartBonus);
+24 -7
View File
@@ -4,9 +4,8 @@
#include "utility/logging/LogMessage.h"
std::shared_ptr<LogManager> LogManager::getInstance()
std::shared_ptr<LogManager> LogManager::createInstance()
{
std::lock_guard<std::mutex> lockGuard(s_instanceMutex);
if (s_instance.use_count() == 0)
{
s_instance = std::shared_ptr<LogManager>(new LogManager());
@@ -14,9 +13,13 @@ std::shared_ptr<LogManager> LogManager::getInstance()
return s_instance;
}
std::shared_ptr<LogManager> LogManager::getInstance()
{
return s_instance;
}
void LogManager::destroyInstance()
{
std::lock_guard<std::mutex> lockGuard(s_instanceMutex);
s_instance.reset();
}
@@ -24,6 +27,11 @@ LogManager::~LogManager()
{
}
void LogManager::setLoggingEnabled(bool enabled)
{
m_loggingEnabled = enabled;
}
void LogManager::addLogger(std::shared_ptr<Logger> logger)
{
m_logManagerImplementation.addLogger(logger);
@@ -56,7 +64,10 @@ void LogManager::logInfo(
const unsigned int line
)
{
m_logManagerImplementation.logInfo(message, file, function, line);
if (m_loggingEnabled)
{
m_logManagerImplementation.logInfo(message, file, function, line);
}
}
void LogManager::logWarning(
@@ -66,7 +77,10 @@ void LogManager::logWarning(
const unsigned int line
)
{
m_logManagerImplementation.logWarning(message, file, function, line);
if (m_loggingEnabled)
{
m_logManagerImplementation.logWarning(message, file, function, line);
}
}
void LogManager::logError(
@@ -76,12 +90,15 @@ void LogManager::logError(
const unsigned int line
)
{
m_logManagerImplementation.logError(message, file, function, line);
if (m_loggingEnabled)
{
m_logManagerImplementation.logError(message, file, function, line);
}
}
std::shared_ptr<LogManager> LogManager::s_instance;
std::mutex LogManager::s_instanceMutex;
LogManager::LogManager()
: m_loggingEnabled(false)
{
}
+4 -2
View File
@@ -2,7 +2,6 @@
#define LOG_MANAGER_H
#include <memory>
#include <mutex>
#include "utility/logging/Logger.h"
#include "utility/logging/LogManagerImplementation.h"
@@ -10,11 +9,14 @@
class LogManager
{
public:
static std::shared_ptr<LogManager> createInstance();
static std::shared_ptr<LogManager> getInstance();
static void destroyInstance();
~LogManager();
void setLoggingEnabled(bool enabled);
void addLogger(std::shared_ptr<Logger> logger);
void removeLogger(std::shared_ptr<Logger> logger);
void removeLoggersByType(const std::string& type);
@@ -42,13 +44,13 @@ public:
private:
static std::shared_ptr<LogManager> s_instance;
static std::mutex s_instanceMutex;
LogManager();
LogManager(const LogManager&);
void operator=(const LogManager&);
LogManagerImplementation m_logManagerImplementation;
bool m_loggingEnabled;
};
#endif // LOG_MANAGER_H
@@ -17,7 +17,10 @@ public:
, fromNameHierarchy(fromName)
, toNameHierarchy(toName)
{
setKeepContent(true);
if (!isAggregation())
{
setKeepContent(true);
}
}
static const std::string getStaticType()
@@ -270,7 +270,10 @@ std::string SolutionParserVisualStudio::getButtonText() const
std::string SolutionParserVisualStudio::getDescription() const
{
return "Create a new project from an existing Visual Studio Solution file. <b>Unstable!</b>";
return "Create a new project from an existing Visual Studio Solution file. "
"<b>Unstable: Please install our new <a href=\"https://coati.io/documentation/index.html#VisualStudio\">Visual "
"Studio plugin</a> and use the \"Create CDB\" menu option, then continue with project setup from "
"Compilation Database.</b>";
}
std::string SolutionParserVisualStudio::getIconPath() const
@@ -125,7 +125,6 @@ void QtAutocompletionDelegate::paint(QPainter* painter, const QStyleOptionViewIt
"----------------------------------------------------------------------------------------------------"
"----------------------------------------------------------------------------------------------------"
) / 500.0f;
painter->drawText(option.rect.adjusted(charWidth + 2, -1, 0, 0), Qt::AlignLeft, name);
QString highlightName(name.size(), ' ');
@@ -136,11 +135,12 @@ void QtAutocompletionDelegate::paint(QPainter* painter, const QStyleOptionViewIt
{
int idx = indices[i].toInt();
QRect rect = option.rect.adjusted(charWidth * (idx + 1) + 1, 2, 0, -1);
rect.setWidth(charWidth + 2);
QRect rect = option.rect.adjusted(charWidth * (idx + 1) + 2, 2, 0, -1);
rect.setWidth(charWidth + 1);
painter->fillRect(rect, color);
highlightName[idx] = name.at(idx);
name[idx] = ' ';
}
}
else
@@ -150,6 +150,8 @@ void QtAutocompletionDelegate::paint(QPainter* painter, const QStyleOptionViewIt
painter->fillRect(rect, color);
}
painter->drawText(option.rect.adjusted(charWidth + 2, -1, 0, 0), Qt::AlignLeft, name);
painter->save();
QPen highlightPen = painter->pen();
highlightPen.setColor(textColor);
@@ -160,12 +162,8 @@ void QtAutocompletionDelegate::paint(QPainter* painter, const QStyleOptionViewIt
if (type.size())
{
QFont font = painter->font();
if (font.pointSize() > 0)
{
QFont typeFont = font;
typeFont.setPointSize(ApplicationSettings::getInstance()->getFontSize() - 4);
painter->setFont(typeFont);
}
font.setPixelSize(ApplicationSettings::getInstance()->getFontSize() - 4);
painter->setFont(font);
QPen typePen = painter->pen();
typePen.setColor(scheme->getColor("search/popup/by_text").c_str());
+18 -2
View File
@@ -24,6 +24,8 @@ QtErrorView::QtErrorView(ViewLayout* viewLayout)
, m_clearFunctor(std::bind(&QtErrorView::doClear, this))
, m_refreshFunctor(std::bind(&QtErrorView::doRefreshView, this))
, m_addErrorFunctor(std::bind(&QtErrorView::doAddError, this, std::placeholders::_1))
, m_setErrorIdFunctor(std::bind(&QtErrorView::doSetErrorId, this, std::placeholders::_1))
, m_ignoreNextSelection(false)
{
}
@@ -76,7 +78,7 @@ void QtErrorView::initView()
connect(m_table->selectionModel(), &QItemSelectionModel::currentRowChanged,
[=](const QModelIndex& index, const QModelIndex& previousIndex)
{
if (index.isValid())
if (index.isValid() && !m_ignoreNextSelection)
{
if (m_model->item(index.row(), COLUMN::FILE) == nullptr)
{
@@ -85,6 +87,8 @@ void QtErrorView::initView()
MessageShowErrors(m_model->item(index.row(), COLUMN::ID)->text().toUInt()).dispatch();
}
m_ignoreNextSelection = false;
});
layout->addWidget(m_table);
@@ -120,8 +124,9 @@ void QtErrorView::addError(const StorageError& error)
m_addErrorFunctor(error);
}
void QtErrorView::clickedInEmptySpace()
void QtErrorView::setErrorId(Id errorId)
{
m_setErrorIdFunctor(errorId);
}
void QtErrorView::doRefreshView()
@@ -151,6 +156,17 @@ void QtErrorView::doAddError(const StorageError& error)
addErrorToTable(error);
}
void QtErrorView::doSetErrorId(Id errorId)
{
QList<QStandardItem*> items = m_model->findItems(QString::number(errorId), Qt::MatchExactly, COLUMN::ID);
if (items.size() == 1)
{
m_ignoreNextSelection = true;
m_table->selectRow(items.at(0)->row());
}
}
void QtErrorView::setStyleSheet() const
{
QWidget* widget = QtViewWidgetWrapper::getWidgetOfView(this);
+5 -3
View File
@@ -30,9 +30,7 @@ public:
// ErrorView implementation
virtual void clear();
virtual void addError(const StorageError& error);
private slots:
void clickedInEmptySpace();
virtual void setErrorId(Id errorId);
private:
enum COLUMN {
@@ -47,6 +45,7 @@ private:
void doRefreshView();
void doClear();
void doAddError(const StorageError& error);
void doSetErrorId(Id errorId);
void setStyleSheet() const;
@@ -58,6 +57,7 @@ private:
QtThreadedFunctor<void> m_clearFunctor;
QtThreadedFunctor<void> m_refreshFunctor;
QtThreadedFunctor<const StorageError&> m_addErrorFunctor;
QtThreadedFunctor<Id> m_setErrorIdFunctor;
QCheckBox* m_showErrors;
QCheckBox* m_showFatals;
@@ -69,6 +69,8 @@ private:
std::vector<StorageError> m_errors;
QPalette* m_palette;
bool m_ignoreNextSelection;
};
#endif // QT_ERROR_VIEW_H
@@ -137,7 +137,8 @@ void QtProjectWizzardContentData::addNameAndLocation(QGridLayout* layout, int& r
m_projectFileLocation->setPickDirectory(true);
layout->addWidget(locationLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_projectFileLocation, row, QtProjectWizzardWindow::BACK_COL);
layout->addWidget(m_projectFileLocation, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignTop);
layout->setRowMinimumHeight(row, 30);
row++;
}
+6 -2
View File
@@ -18,8 +18,12 @@ TestSuiteFixture::~TestSuiteFixture()
bool TestSuiteFixture::setUpWorld()
{
LogManager::getInstance()->addLogger(std::make_shared<PlainFileLogger>("data/log/test_log.txt"));
LogManager::getInstance()->addLogger(std::make_shared<FileLogger>());
LogManager* logManager = LogManager::createInstance().get();
logManager->setLoggingEnabled(true);
logManager->addLogger(std::make_shared<PlainFileLogger>("data/log/test_log.txt"));
logManager->addLogger(std::make_shared<FileLogger>());
ApplicationSettings::getInstance()->load(FilePath("data/TestSettings.xml"));
return true;