mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/calculation] Create input and output layout according to display
mode set in preference Change-Id: If161958b2fcdad802fda5f8e0c44f8a5fc9d9ef1
This commit is contained in:
@@ -11,59 +11,6 @@ Calculation::Calculation() :
|
||||
{
|
||||
}
|
||||
|
||||
Calculation & Calculation::operator= (const Calculation & other) {
|
||||
strlcpy(m_text, other.m_text, sizeof(m_text));
|
||||
if (m_input != nullptr) {
|
||||
delete m_input;
|
||||
}
|
||||
m_input = nullptr;
|
||||
if (other.m_input) {
|
||||
m_input = Expression::parse(m_text);
|
||||
}
|
||||
if (m_inputLayout != nullptr) {
|
||||
delete m_inputLayout;
|
||||
}
|
||||
m_inputLayout = nullptr;
|
||||
if (m_input && other.m_inputLayout) {
|
||||
m_inputLayout = m_input->createLayout();
|
||||
}
|
||||
if (m_output != nullptr) {
|
||||
delete m_output;
|
||||
}
|
||||
m_output = nullptr;
|
||||
if (other.m_output) {
|
||||
m_output = other.m_output->clone();
|
||||
}
|
||||
if (m_outputLayout != nullptr) {
|
||||
delete m_outputLayout;
|
||||
}
|
||||
m_outputLayout = nullptr;
|
||||
if (m_output && other.m_outputLayout) {
|
||||
m_outputLayout = m_output->createLayout();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Calculation::setContent(const char * c, Context * context) {
|
||||
strlcpy(m_text, c, sizeof(m_text));
|
||||
if (m_input != nullptr) {
|
||||
delete m_input;
|
||||
}
|
||||
m_input = Expression::parse(m_text);
|
||||
if (m_inputLayout != nullptr) {
|
||||
delete m_inputLayout;
|
||||
}
|
||||
m_inputLayout = m_input->createLayout();
|
||||
if (m_output != nullptr) {
|
||||
delete m_outputLayout;
|
||||
}
|
||||
m_output = m_input->evaluate(*context);
|
||||
if (m_outputLayout != nullptr) {
|
||||
delete m_outputLayout;
|
||||
}
|
||||
m_outputLayout = m_output->createLayout();
|
||||
}
|
||||
|
||||
Calculation::~Calculation() {
|
||||
if (m_inputLayout != nullptr) {
|
||||
delete m_inputLayout;
|
||||
@@ -79,6 +26,46 @@ Calculation::~Calculation() {
|
||||
}
|
||||
}
|
||||
|
||||
void Calculation::reset() {
|
||||
m_text[0] = 0;
|
||||
if (m_input != nullptr) {
|
||||
delete m_input;
|
||||
}
|
||||
m_input = nullptr;
|
||||
if (m_inputLayout != nullptr) {
|
||||
delete m_inputLayout;
|
||||
}
|
||||
m_inputLayout = nullptr;
|
||||
if (m_output != nullptr) {
|
||||
delete m_output;
|
||||
}
|
||||
m_output = nullptr;
|
||||
if (m_outputLayout != nullptr) {
|
||||
delete m_outputLayout;
|
||||
}
|
||||
m_outputLayout = nullptr;
|
||||
}
|
||||
|
||||
void Calculation::setContent(const char * c, Context * context, Preferences * preferences) {
|
||||
strlcpy(m_text, c, sizeof(m_text));
|
||||
if (m_input != nullptr) {
|
||||
delete m_input;
|
||||
}
|
||||
m_input = Expression::parse(m_text);
|
||||
if (m_inputLayout != nullptr) {
|
||||
delete m_inputLayout;
|
||||
}
|
||||
m_inputLayout = m_input->createLayout(preferences->displayMode());
|
||||
if (m_output != nullptr) {
|
||||
delete m_output;
|
||||
}
|
||||
m_output = m_input->evaluate(*context);
|
||||
if (m_outputLayout != nullptr) {
|
||||
delete m_outputLayout;
|
||||
}
|
||||
m_outputLayout = m_output->createLayout(preferences->displayMode());
|
||||
}
|
||||
|
||||
const char * Calculation::text() {
|
||||
return m_text;
|
||||
}
|
||||
@@ -100,7 +87,7 @@ ExpressionLayout * Calculation::outputLayout() {
|
||||
}
|
||||
|
||||
bool Calculation::isEmpty() {
|
||||
if (m_input == nullptr) {
|
||||
if (m_output == nullptr) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user