Commit e1720470 authored by Han Young's avatar Han Young
Browse files

coding style

parent fa2023f4
......@@ -35,7 +35,6 @@ int main(int argc, char *argv[])
engine.rootContext()->setContextProperty("inputManager", InputManager::inst());
engine.rootContext()->setContextProperty("typeModel", typeModel);
engine.rootContext()->setContextProperty("unitModel", unitModel);
engine.rootContext()->setContextProperty("mathEngine", MathEngine::inst());
KAboutData aboutData("kalk", i18n("Calculator"), "0.1", i18n("Calculator in Kirigami"), KAboutLicense::GPL, i18n("© 2020 KDE Community"));
KAboutData::setApplicationData(aboutData);
......
......@@ -7,7 +7,7 @@
void MathEngine::parse(QString expr)
{
mDriver.parse(expr.toStdString());
result_ = QString::number(mDriver.result);
m_driver.parse(expr.toStdString());
m_result = QString::number(m_driver.result);
emit resultChanged();
}
......@@ -21,19 +21,19 @@ public:
Q_INVOKABLE void parse(QString expr);
QString result()
{
return result_;
return m_result;
};
bool error()
{
return mDriver.syntaxError_;
return m_Driver.syntaxError;
};
signals:
void resultChanged();
private:
MathEngine(){};
driver mDriver;
QString result_;
driver m_driver;
QString m_result;
};
#endif
......@@ -12,7 +12,7 @@ driver::driver()
}
int driver::parse(const std::string expr)
{
syntaxError_ = false;
syntaxError = false;
scan_begin(expr);
yy::parser parse(*this);
parse.set_debug_level(trace_parsing);
......
......@@ -32,6 +32,6 @@ public:
bool trace_scanning;
// The token's location used by the scanner.
yy::location location;
bool syntaxError_ = false;
bool syntaxError = false;
};
#endif // ! DRIVER_HH
......@@ -128,5 +128,5 @@ yy::parser::error (const location_type& l, const std::string& m)
{
std::cerr << l << ": " << m << '\n';
if(m != "syntax error, unexpected end of file")
drv.syntaxError_ = true;
drv.syntaxError = true;
}
......@@ -14,11 +14,13 @@ TypeModel::TypeModel()
QVariant TypeModel::data(const QModelIndex &index, int role) const
{
Q_UNUSED(role)
return i18n((unitsType.at(index.row())).toLatin1());
}
int TypeModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return unitsType.size();
}
QHash<int, QByteArray> TypeModel::roleNames() const
......
......@@ -14,6 +14,7 @@ UnitModel::UnitModel()
}
QVariant UnitModel::data(const QModelIndex &index, int role) const
{
Q_UNUSED(role)
if (index.row() >= 0 && index.row() < m_units.count())
return m_units.at(index.row()).symbol() + " " + m_units.at(index.row()).description();
else
......@@ -22,6 +23,7 @@ QVariant UnitModel::data(const QModelIndex &index, int role) const
int UnitModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return m_units.count();
}
QHash<int, QByteArray> UnitModel::roleNames() const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment