Skip to content

Commit

Permalink
Fix formating
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-hannes committed Oct 25, 2024
1 parent a7e97e1 commit ecfed0e
Show file tree
Hide file tree
Showing 26 changed files with 131 additions and 148 deletions.
9 changes: 4 additions & 5 deletions src/additive/additive.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class Additive : public QObject, public Meta {
Q_OBJECT

public:

/**
* @brief Index for additive type
*/
Expand Down Expand Up @@ -61,12 +60,12 @@ class Additive : public QObject, public Meta {
Additive(const QJsonObject& json); /**< @brief Create Additive from JSON */

// setter and getter
float get(Value what) const; /**< @brief get requested amount */
void set(Value what, float value); /**< @brief set given type with amount */
float get(Value what) const; /**< @brief get requested amount */
void set(Value what, float value); /**< @brief set given type with amount */

// JSON conversion
bool fromJson(const QJsonObject& json); /**< @brief Update Additive from JSON */
QJsonObject toJson() const; /**< @brief convert this Additive to JSON */
bool fromJson(const QJsonObject& json); /**< @brief Update Additive from JSON */
QJsonObject toJson() const; /**< @brief convert this Additive to JSON */

/**
* @brief Additive::operator + calculates effect of additive to water values
Expand Down
5 changes: 2 additions & 3 deletions src/additive/additivewindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
/**
* @brief Window for managing your additions
*/
class AdditiveWindow : public QWidget
{
class AdditiveWindow : public QWidget {
Q_OBJECT

public:
Expand All @@ -47,4 +46,4 @@ class AdditiveWindow : public QWidget
QComboBox* unitSelect;
};

#endif // ADDITIVEWINDOW_H
#endif // ADDITIVEWINDOW_H
5 changes: 2 additions & 3 deletions src/common/jsonhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
/**
* @brief Class with common JSON functions
*/
class JsonHelper
{
class JsonHelper {
public:
JsonHelper() = delete;

Expand All @@ -37,4 +36,4 @@ class JsonHelper
static void mergeJson(QJsonObject& into, const QJsonObject from);
};

#endif // JSONHELPER_H
#endif // JSONHELPER_H
6 changes: 2 additions & 4 deletions src/common/meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ void Meta::setName(const QString& newName) {
updateEditTime();
}

void Meta::updateEditTime()
{
void Meta::updateEditTime() {
edit = QDateTime::currentDateTime();
}

void Meta::updateCreationTime()
{
void Meta::updateCreationTime() {
create = QDateTime::currentDateTime();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <QLocale>
#include <QTranslator>

int main(int argc, char *argv[]) {
int main(int argc, char* argv[]) {
QApplication a(argc, argv);

a.setOrganizationName("jo-hannes");
Expand All @@ -19,7 +19,7 @@ int main(int argc, char *argv[]) {
QTranslator trMyApp;
QTranslator trQt;
const QStringList uiLanguages = QLocale::system().uiLanguages();
for (const QString &locale : uiLanguages) {
for (const QString& locale : uiLanguages) {
const QString languageCode = QLocale::languageToCode(QLocale(locale).language());
if (trMyApp.load(":/i18n/Aqua-mixtura_" + languageCode)) {
a.installTranslator(&trMyApp);
Expand Down
6 changes: 3 additions & 3 deletions src/mainmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class MainModel : public QObject {
MainModel();

public slots:
void load(); /**< @brief Load all data from JSON files */
void save(); /**< @brief Save all data to JSON files */
void load(); /**< @brief Load all data from JSON files */
void save(); /**< @brief Save all data to JSON files */

public:
Mixtures mixtures; /**< @brief Model of mixtures */
};

#endif // MAINMODEL_H
#endif // MAINMODEL_H
3 changes: 1 addition & 2 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) {
setCentralWidget(mainWidget);
}

MainWindow::~MainWindow() {
}
MainWindow::~MainWindow() {}

void MainWindow::closeEvent(QCloseEvent* event) {
// close all other windows
Expand Down
12 changes: 6 additions & 6 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "mainmodel.h"

#include "additive/additivewindow.h"
#include "settings/settingswindow.h"
#include "malt/maltwindow.h"
#include "settings/settingswindow.h"
#include "style/styleswindow.h"
#include "water/watersourcewindow.h"

Expand Down Expand Up @@ -40,11 +40,11 @@ class MainWindow : public QMainWindow {
void settings(); /**< @brief Slot to show window with settings */

// mixtures slots
void mixAdd(); /**< @brief Slot for adding a new mixture */
void mixCopy(); /**< @brief Slot to copy the currently selected mixture */
void mixDelete(); /**< @brief Slot to delete the currently selected mixture */
void mixImport(); /**< @brief Slot for importing a mixture form JSON */
void mixExport(); /**< @brief Slot for exporting a mixture to JSON */
void mixAdd(); /**< @brief Slot for adding a new mixture */
void mixCopy(); /**< @brief Slot to copy the currently selected mixture */
void mixDelete(); /**< @brief Slot to delete the currently selected mixture */
void mixImport(); /**< @brief Slot for importing a mixture form JSON */
void mixExport(); /**< @brief Slot for exporting a mixture to JSON */
void mixDoubleClicked(const QModelIndex& idx); /**< @brief Slot for double clicks on mixtures */

private:
Expand Down
12 changes: 6 additions & 6 deletions src/malt/malt.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ class Malt : public Meta {
static float calcualtePhRoestmalz();

// JSON conversion
bool fromJson(const QJsonObject& json); /**< @brief Update Malt from JSON */
QJsonObject toJson() const; /**< @brief convert this Malt to JSON */
bool fromJson(const QJsonObject& json); /**< @brief Update Malt from JSON */
QJsonObject toJson() const; /**< @brief convert this Malt to JSON */

private:
float mass; /**< Amount of malt in kg */
float ebc; /**< Color of malt in EBC */
float ph; /**< pH of malt in purified water */
float mass; /**< Amount of malt in kg */
float ebc; /**< Color of malt in EBC */
float ph; /**< pH of malt in purified water */
};

#endif // MALT_H
#endif // MALT_H
4 changes: 1 addition & 3 deletions src/malt/maltphedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
#include <QGridLayout>
#include <QPushButton>

MaltPhEdit::MaltPhEdit(QWidget *parent)
: QWidget{parent}
{
MaltPhEdit::MaltPhEdit(QWidget* parent) : QWidget{parent} {
QGridLayout* mainLayout = new QGridLayout(this);
// malt names
QLabel* txtMalt = new QLabel(tr("Malze <120 EBC") + ":");
Expand Down
5 changes: 2 additions & 3 deletions src/malt/maltphedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
#include <QLabel>
#include <QWidget>

class MaltPhEdit : public QWidget
{
class MaltPhEdit : public QWidget {
Q_OBJECT
public:
explicit MaltPhEdit(QWidget* parent = nullptr);
Expand All @@ -33,4 +32,4 @@ class MaltPhEdit : public QWidget
QDoubleSpinBox* phSpinBox;
};

#endif // MALTPHEDIT_H
#endif // MALTPHEDIT_H
6 changes: 2 additions & 4 deletions src/malt/malts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ Qt::ItemFlags Malts::flags(const QModelIndex& index) const {
return Qt::ItemIsEditable | QAbstractItemModel::flags(index);
}

void Malts::load()
{
void Malts::load() {
const QString fileName = "malts.json";
Download::loadDefaults(fileName);
QString file = Paths::dataDir() + "/" + fileName;
Expand All @@ -209,8 +208,7 @@ void Malts::load()
}
}

void Malts::save()
{
void Malts::save() {
QString file = Paths::dataDir() + "/malts.json";
JsonHelper::saveFile(file, this->toJson());
setChanged(false);
Expand Down
12 changes: 6 additions & 6 deletions src/malt/malts.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ class Malts : public QAbstractTableModel {
Malts(const QJsonObject& json); /**< @brief Create Malts from JSON */

// JSON conversion
bool fromJson(const QJsonObject& json); /**< @brief Update Malts from JSON */
QJsonObject toJson() const; /**< @brief convert this Malts to JSON */
bool importMalt(const QString& path); /**< @brief import and add a Malt from JSON */
bool fromJson(const QJsonObject& json); /**< @brief Update Malts from JSON */
QJsonObject toJson() const; /**< @brief convert this Malts to JSON */
bool importMalt(const QString& path); /**< @brief import and add a Malt from JSON */
bool exportMalt(const QString& path, qsizetype i) const; /**< @brief export a Malt at index as JSON */

const Malt& getMalt(qsizetype i); /**< @brief Get malt at index */
void addMalt(const Malt& malt); /**< @brief Add a malt */
void deleteMalt(qsizetype i); /**< @brief Delete malt at index */
const Malt& getMalt(qsizetype i); /**< @brief Get malt at index */
void addMalt(const Malt& malt); /**< @brief Add a malt */
void deleteMalt(qsizetype i); /**< @brief Delete malt at index */

bool isChanged() const; /**< @brief True if changes not saved */

Expand Down
2 changes: 1 addition & 1 deletion src/malt/malttabledelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#ifndef MALTTABLEDELEGATE_H
#define MALTTABLEDELEGATE_H

#include <QStyledItemDelegate>
#include <QObject>
#include <QStyledItemDelegate>

/**
* @brief Delegate to use a spin box for entering the EBC value of a malt
Expand Down
14 changes: 7 additions & 7 deletions src/malt/maltwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class MaltWindow : public QWidget {
void closeEvent(QCloseEvent* event) override;

private slots:
void maltAdd(); /**< @brief Slot for adding a new malt */
void maltCopy(); /**< @brief Slot to copy the currently selected malt */
void maltDelete(); /**< @brief Slot to delete the currently selected malt */
void maltImport(); /**< @brief Slot for importing a malt form JSON */
void maltExport(); /**< @brief Slot for exporting a malt to JSON */
void unsavedMalts(); /**< @brief Slot for checking if unsaved changes exist */
void maltAdd(); /**< @brief Slot for adding a new malt */
void maltCopy(); /**< @brief Slot to copy the currently selected malt */
void maltDelete(); /**< @brief Slot to delete the currently selected malt */
void maltImport(); /**< @brief Slot for importing a malt form JSON */
void maltExport(); /**< @brief Slot for exporting a malt to JSON */
void unsavedMalts(); /**< @brief Slot for checking if unsaved changes exist */

signals:
void load();
Expand All @@ -42,4 +42,4 @@ class MaltWindow : public QWidget {
QString title; /**< @brief Window tittle */
};

#endif // MALTWINDOW_H
#endif // MALTWINDOW_H
2 changes: 1 addition & 1 deletion src/mixture/mixadditivewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MixAdditiveWidget : public QFrame {
QLabel* liquidUnit; /**< @brief Unit for liquids */

QLabel* percents[static_cast<int>(Additive::Value::lastLiquid) + 1]; /**< @brief Weight percent for liquids */
QDoubleSpinBox* amounts[static_cast<int>(Additive::Value::Size)]; /** @brief Spin boxes of additive */
QDoubleSpinBox* amounts[static_cast<int>(Additive::Value::Size)]; /**< @brief Spin boxes of additive */
};

#endif // MIXADDITIVEWIDGET_H
2 changes: 1 addition & 1 deletion src/mixture/mixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ class Mixture : public Meta {
QString path;
};

#endif // MIXTURE_H
#endif // MIXTURE_H
9 changes: 3 additions & 6 deletions src/mixture/mixtures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

#include <QJsonArray>

Mixtures::Mixtures(QObject* parent) : QAbstractTableModel{parent} {
}
Mixtures::Mixtures(QObject* parent) : QAbstractTableModel{parent} {}

Mixtures::Mixtures(const QJsonObject& json, QObject* parent) : Mixtures(parent) {
fromJson(json);
Expand Down Expand Up @@ -193,16 +192,14 @@ QVariant Mixtures::headerData(int section, Qt::Orientation orientation, int role
}
}

void Mixtures::load()
{
void Mixtures::load() {
QString file = Paths::dataDir() + "/mixtures.json";
if (QFile::exists(file)) {
this->fromJson(JsonHelper::loadFile(file));
}
}

void Mixtures::save()
{
void Mixtures::save() {
QString file = Paths::dataDir() + "/mixtures.json";
JsonHelper::saveFile(file, this->toJson());
}
2 changes: 1 addition & 1 deletion src/style/style.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ class Style : public QAbstractTableModel, public Meta {
static const inline QString jsonKeys[static_cast<int>(Limit::Size)] = {"Min", "Target", "Max"};
};

#endif // STYLE_H
#endif // STYLE_H
6 changes: 2 additions & 4 deletions src/style/styles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ QVariant Styles::data(const QModelIndex& index, int role) const {
return styles.at(row)->getName();
}

void Styles::load()
{
void Styles::load() {
const QString fileName = "styles.json";
Download::loadDefaults(fileName);
QString file = Paths::dataDir() + "/" + fileName;
Expand All @@ -140,8 +139,7 @@ void Styles::load()
}
}

void Styles::save()
{
void Styles::save() {
QString file = Paths::dataDir() + "/styles.json";
JsonHelper::saveFile(file, this->toJson());
setChanged(false);
Expand Down
10 changes: 5 additions & 5 deletions src/style/styles.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class Styles : public QAbstractListModel {
~Styles();

// JSON conversion
bool fromJson(const QJsonObject& json); /**< @brief Update Styles from JSON */
QJsonObject toJson() const; /**< @brief convert Styles to JSON */
bool importStyle(const QString& path); /**< @brief import and add a Style from JSON */
bool fromJson(const QJsonObject& json); /**< @brief Update Styles from JSON */
QJsonObject toJson() const; /**< @brief convert Styles to JSON */
bool importStyle(const QString& path); /**< @brief import and add a Style from JSON */
bool exportStyle(const QString& path, qsizetype i) const; /**< @brief export a Style at index as JSON */

Style* getStyle(qsizetype i); /**< @brief Get style at index */
Expand All @@ -48,7 +48,7 @@ class Styles : public QAbstractListModel {
void clear(); /**< @brief Clear/remove all Styles*/

QVector<Style*> styles;
Style* noStyle; /**< @brief Empty style used to return no style on error */
Style* noStyle; /**< @brief Empty style used to return no style on error */
};

#endif // STYLES_H
#endif // STYLES_H
6 changes: 3 additions & 3 deletions src/water/water.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class Water : public Meta {
void set(Value what, float value); /**< @brief set given type with value */

// JSON conversion
bool fromJson(const QJsonObject& json); /**< @brief Update Water from JSON */
QJsonObject toJson() const; /**< @brief convert this Water to JSON */
bool fromJson(const QJsonObject& json); /**< @brief Update Water from JSON */
QJsonObject toJson() const; /**< @brief convert this Water to JSON */
QJsonObject profileToJson() const; /**< @brief convert this Water profile to JSON (A profile is without volume) */

// Operators
Expand Down Expand Up @@ -155,4 +155,4 @@ class Water : public Meta {
float values[static_cast<int>(Value::LastAnion) + 1];
};

#endif // WATER_H
#endif // WATER_H
5 changes: 2 additions & 3 deletions src/water/waterprofileedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
#include <QObject>
#include <QWidget>

class WaterProfileEdit : public QWidget
{
class WaterProfileEdit : public QWidget {
Q_OBJECT

public:
Expand Down Expand Up @@ -56,4 +55,4 @@ class WaterProfileEdit : public QWidget
QLabel *restalkallität, *gesammtHaerte, *carbonHaerte, *caHaerte, *mgHaerte, *nichtcarbonHaerte, *so4cl;
};

#endif // WATERPROFILEEDIT_H
#endif // WATERPROFILEEDIT_H
Loading

0 comments on commit ecfed0e

Please sign in to comment.