Re-formatted all source files

This commit is contained in:
Michael Mandl 2019-10-05 16:14:45 +02:00
parent 5c6ed8191b
commit d0f64ef440
77 changed files with 2443 additions and 2332 deletions

118
.clang-format Executable file
View file

@ -0,0 +1,118 @@
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeComma
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: '^(BEGIN|IMPLEMENT)_.*_MAP$'
MacroBlockEnd: '^END_.*_MAP$'
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 1000000
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 4
UseTab: Never

View file

@ -9,58 +9,58 @@ Age::Age(unsigned int years, unsigned int months)
{
}
Age::Age(const QDate &birth, const QDate &reference)
Age::Age(const QDate& birth, const QDate& reference)
{
if (reference < birth)
{
qDebug() << "test (" << reference << ") before birth (" << birth << ")";
m_years = 0;
m_months = 0;
if (reference < birth)
{
qDebug() << "test (" << reference << ") before birth (" << birth << ")";
m_years = 0;
m_months = 0;
return;
}
return;
}
int years = reference.year() - birth.year();
int months = reference.month() - birth.month();
int years = reference.year() - birth.year();
int months = reference.month() - birth.month();
if (months == 0 && reference.day() < birth.day())
{
months--;
}
if (months == 0 && reference.day() < birth.day())
{
months--;
}
if (months < 0)
{
years--;
months = (months + 12) % 12;
}
if (months < 0)
{
years--;
months = (months + 12) % 12;
}
m_years = years;
m_months = months;
m_years = years;
m_months = months;
}
bool Age::operator<(const Age &cmp) const
bool Age::operator<(const Age& cmp) const
{
if (m_years == cmp.m_years)
{
return m_months < cmp.m_months;
}
if (m_years == cmp.m_years)
{
return m_months < cmp.m_months;
}
return m_years < cmp.m_years;
return m_years < cmp.m_years;
}
unsigned int Age::years() const
{
return m_years;
return m_years;
}
unsigned int Age::months() const
{
return m_months;
return m_months;
}
std::string Age::toString() const
{
std::ostringstream result;
result << m_years << ";" << m_months;
return result.str();
std::ostringstream result;
result << m_years << ";" << m_months;
return result.str();
}

View file

@ -5,18 +5,18 @@
class Age
{
private:
unsigned int m_years = 0;
unsigned int m_months = 0;
unsigned int m_years = 0;
unsigned int m_months = 0;
public:
Age() = default;
Age(unsigned int years, unsigned int months);
Age(const QDate &birth, const QDate &reference);
Age() = default;
Age(unsigned int years, unsigned int months);
Age(const QDate& birth, const QDate& reference);
bool operator<(const Age &cmp) const;
bool operator<(const Age& cmp) const;
unsigned int years() const;
unsigned int months() const;
unsigned int years() const;
unsigned int months() const;
std::string toString() const;
std::string toString() const;
};

View file

@ -1,36 +1,36 @@
#include "CheckableItem.h"
CheckableItem::CheckableItem(const std::string &text)
: m_text(text)
CheckableItem::CheckableItem(const std::string& text)
: m_text(text)
{
}
std::string CheckableItem::getText() const
{
return m_text;
return m_text;
}
bool CheckableItem::isChecked() const
{
return m_checked;
return m_checked;
}
void CheckableItem::setState(bool checked)
{
m_checked = checked;
m_checked = checked;
}
unsigned int CheckableItem::value() const
{
return m_value;
return m_value;
}
void CheckableItem::setValue(unsigned int value)
{
m_value = value;
m_value = value;
}
unsigned int CheckableItem::points() const
{
return m_checked ? m_value : 0;
return m_checked ? m_value : 0;
}

View file

@ -7,21 +7,21 @@
class CheckableItem
{
private:
bool m_checked = false;
std::string m_text;
unsigned int m_value = 1;
bool m_checked = false;
std::string m_text;
unsigned int m_value = 1;
public:
CheckableItem() = default;
CheckableItem(const std::string &text);
CheckableItem() = default;
CheckableItem(const std::string& text);
std::string getText() const;
std::string getText() const;
bool isChecked() const;
void setState(bool checked);
bool isChecked() const;
void setState(bool checked);
unsigned int value() const;
void setValue(unsigned int value);
unsigned int value() const;
void setValue(unsigned int value);
unsigned int points() const;
unsigned int points() const;
};

View file

@ -6,15 +6,15 @@
CheckableItems::CheckableItems(std::initializer_list<std::string> itemNames)
{
for (const auto &itemName : itemNames)
{
emplace_back(itemName);
}
for (const auto& itemName : itemNames)
{
emplace_back(itemName);
}
}
unsigned int CheckableItems::getPoints() const
{
return std::accumulate(begin(), end(), 0, [](int base, const CheckableItem &item) {
return base + item.points();
});
return std::accumulate(begin(), end(), 0, [](int base, const CheckableItem& item) {
return base + item.points();
});
}

View file

@ -8,7 +8,7 @@
class CheckableItems : public std::vector<CheckableItem>
{
public:
CheckableItems(std::initializer_list<std::string> itemNames);
CheckableItems(std::initializer_list<std::string> itemNames);
unsigned int getPoints() const;
unsigned int getPoints() const;
};

View file

@ -2,34 +2,33 @@
#include <numeric>
CheckableTest::CheckableTest(
const char *name, std::initializer_list<std::string> items)
: m_name(name)
, m_items(items)
CheckableTest::CheckableTest(const char* name, std::initializer_list<std::string> items)
: m_name(name)
, m_items(items)
{
}
size_t CheckableTest::size() const
{
return m_items.size();
return m_items.size();
}
const QString &CheckableTest::name() const
const QString& CheckableTest::name() const
{
return m_name;
return m_name;
}
const CheckableItems &CheckableTest::items() const
const CheckableItems& CheckableTest::items() const
{
return m_items;
return m_items;
}
CheckableItems &CheckableTest::items()
CheckableItems& CheckableTest::items()
{
return m_items;
return m_items;
}
unsigned int CheckableTest::getPoints() const
{
return m_items.getPoints();
return m_items.getPoints();
}

View file

@ -7,18 +7,18 @@
class CheckableTest
{
private:
CheckableItems m_items;
QString m_name;
CheckableItems m_items;
QString m_name;
public:
CheckableTest(const char *name, std::initializer_list<std::string> items);
CheckableTest(const char* name, std::initializer_list<std::string> items);
size_t size() const;
const QString &name() const;
const CheckableItems &items() const;
CheckableItems &items();
size_t size() const;
const QString& name() const;
const CheckableItems& items() const;
CheckableItems& items();
unsigned int getPoints() const;
unsigned int getPoints() const;
};
using CheckableTests = std::vector<CheckableTest>;

View file

@ -4,191 +4,191 @@
#include <QSize>
#include <QDebug>
CheckableTestModel::CheckableTestModel(QObject *parent)
CheckableTestModel::CheckableTestModel(QObject* parent)
: QAbstractTableModel(parent)
{
}
int CheckableTestModel::rowCount(const QModelIndex &) const
int CheckableTestModel::rowCount(const QModelIndex&) const
{
return static_cast<int>(m_tests.size());
return static_cast<int>(m_tests.size());
}
int CheckableTestModel::columnCount(const QModelIndex &) const
int CheckableTestModel::columnCount(const QModelIndex&) const
{
int columnCount = 0;
int columnCount = 0;
for (const auto &test : m_tests)
{
columnCount = std::max(columnCount, static_cast<int>(test.size()));
}
for (const auto& test : m_tests)
{
columnCount = std::max(columnCount, static_cast<int>(test.size()));
}
return columnCount;
return columnCount;
}
QVariant CheckableTestModel::data(const QModelIndex &index, int role) const
QVariant CheckableTestModel::data(const QModelIndex& index, int role) const
{
if (!isValidIndex(index))
{
return {};
}
if (!isValidIndex(index))
{
return {};
}
try
{
auto &item = getItem(index);
try
{
auto& item = getItem(index);
switch (role)
{
case Qt::DisplayRole:
{
return item.getText().c_str();
}
case Qt::CheckStateRole:
{
return item.isChecked() ? Qt::Checked : Qt::Unchecked;
}
}
}
catch (std::runtime_error &e)
{
qDebug() << "CheckableTestModel::data" << index << e.what();
}
switch (role)
{
case Qt::DisplayRole:
{
return item.getText().c_str();
}
case Qt::CheckStateRole:
{
return item.isChecked() ? Qt::Checked : Qt::Unchecked;
}
}
}
catch (std::runtime_error& e)
{
qDebug() << "CheckableTestModel::data" << index << e.what();
}
return {};
return {};
}
Qt::ItemFlags CheckableTestModel::flags(const QModelIndex &index) const
Qt::ItemFlags CheckableTestModel::flags(const QModelIndex& index) const
{
if (isValidIndex(index))
{
return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
}
if (isValidIndex(index))
{
return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
}
return Qt::NoItemFlags;
return Qt::NoItemFlags;
}
bool CheckableTestModel::setData(const QModelIndex &index, const QVariant &value, int role)
bool CheckableTestModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
if (!isValidIndex(index))
{
return false;
}
if (!isValidIndex(index))
{
return false;
}
try
{
if (role == Qt::CheckStateRole)
{
auto &item = getItem(index);
item.setState(value.toBool());
emit dataChanged(index, index);
return true;
}
}
catch (std::runtime_error &e)
{
qDebug() << "CheckableTestModel::setData" << index << e.what();
}
try
{
if (role == Qt::CheckStateRole)
{
auto& item = getItem(index);
item.setState(value.toBool());
emit dataChanged(index, index);
return true;
}
}
catch (std::runtime_error& e)
{
qDebug() << "CheckableTestModel::setData" << index << e.what();
}
return false;
return false;
}
QVariant CheckableTestModel::headerData(int section, Qt::Orientation orientation, int role) const
{
switch (orientation)
{
case Qt::Vertical:
{
switch (role)
{
case Qt::DisplayRole:
{
if (section < m_tests.size())
{
return m_tests.at(section).name();
}
}
case Qt::SizeHintRole:
{
return QSize(200, 0);
}
}
break;
}
default:
break;
}
switch (orientation)
{
case Qt::Vertical:
{
switch (role)
{
case Qt::DisplayRole:
{
if (section < m_tests.size())
{
return m_tests.at(section).name();
}
}
case Qt::SizeHintRole:
{
return QSize(200, 0);
}
}
break;
}
default:
break;
}
return QAbstractTableModel::headerData(section, orientation, role);
return QAbstractTableModel::headerData(section, orientation, role);
}
bool CheckableTestModel::isValidIndex(const QModelIndex &index) const
bool CheckableTestModel::isValidIndex(const QModelIndex& index) const
{
if (index.row() < m_tests.size())
{
return index.column() < m_tests.at(index.row()).size();
}
if (index.row() < m_tests.size())
{
return index.column() < m_tests.at(index.row()).size();
}
return false;
return false;
}
CheckableItems &CheckableTestModel::getItems(const QModelIndex &index)
CheckableItems& CheckableTestModel::getItems(const QModelIndex& index)
{
if (index.row() < m_tests.size())
{
return m_tests.at(index.row()).items();
}
if (index.row() < m_tests.size())
{
return m_tests.at(index.row()).items();
}
throw std::runtime_error("invalid index");
throw std::runtime_error("invalid index");
}
const CheckableItems &CheckableTestModel::getItems(const QModelIndex &index) const
const CheckableItems& CheckableTestModel::getItems(const QModelIndex& index) const
{
if (index.row() < m_tests.size())
{
return m_tests.at(index.row()).items();
}
if (index.row() < m_tests.size())
{
return m_tests.at(index.row()).items();
}
throw std::runtime_error("invalid index");
throw std::runtime_error("invalid index");
}
CheckableItem &CheckableTestModel::getItem(const QModelIndex &index)
CheckableItem& CheckableTestModel::getItem(const QModelIndex& index)
{
auto &items = getItems(index);
if (index.column() < items.size())
{
return items.at(index.column());
}
auto& items = getItems(index);
if (index.column() < items.size())
{
return items.at(index.column());
}
throw std::runtime_error("invalid index");
throw std::runtime_error("invalid index");
}
const CheckableItem &CheckableTestModel::getItem(const QModelIndex &index) const
const CheckableItem& CheckableTestModel::getItem(const QModelIndex& index) const
{
auto &items = getItems(index);
if (index.column() < items.size())
{
return items.at(index.column());
}
auto& items = getItems(index);
if (index.column() < items.size())
{
return items.at(index.column());
}
throw std::runtime_error("invalid index");
throw std::runtime_error("invalid index");
}
unsigned int CheckableTestModel::getPoints() const
{
unsigned int points = 0;
unsigned int points = 0;
for (const auto &test : m_tests)
{
for (const auto &item : test.items())
{
points += item.points();
}
}
for (const auto& test : m_tests)
{
for (const auto& item : test.items())
{
points += item.points();
}
}
return points;
return points;
}
QString CheckableTestModel::getTitle() const
{
return m_title;
return m_title;
}

View file

@ -5,37 +5,36 @@
class CheckableTestModel : public QAbstractTableModel
{
Q_OBJECT
Q_OBJECT
protected:
QString m_title;
CheckableTests m_tests;
QString m_title;
CheckableTests m_tests;
public:
CheckableTestModel(QObject *parent);
CheckableTestModel(QObject* parent);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
unsigned int getPoints() const;
unsigned int getPoints() const;
QString getTitle() const;
QString getTitle() const;
protected:
virtual bool isValidIndex(const QModelIndex &index) const;
virtual bool isValidIndex(const QModelIndex& index) const;
private:
CheckableItems &getItems(const QModelIndex &index);
const CheckableItems &getItems(const QModelIndex &index) const;
CheckableItems& getItems(const QModelIndex& index);
const CheckableItems& getItems(const QModelIndex& index) const;
CheckableItem &getItem(const QModelIndex &index);
const CheckableItem &getItem(const QModelIndex &index) const;
CheckableItem& getItem(const QModelIndex& index);
const CheckableItem& getItem(const QModelIndex& index) const;
};

View file

@ -5,7 +5,7 @@
#include <sstream>
DataModel::DataModel(QObject *parent)
DataModel::DataModel(QObject* parent)
: QObject(parent)
, m_metaData(this)
, m_verbEnd(this)
@ -21,186 +21,186 @@ DataModel::DataModel(QObject *parent)
, m_passiv(this)
, m_genitiv(this)
{
connect(&m_plural, &PluralModel::dataChanged, this, &DataModel::pluralModelChanged);
connect(&m_metaData, &MetaDataModel::dataChanged, this, &DataModel::metaDataChanged);
connect(&m_genus, &GenusModel::dataChanged, this, &DataModel::genusModelChanged);
connect(&m_verbEnd, &VerbEndModel::dataChanged, this, &DataModel::verbEndModelChanged);
connect(&m_akkusativ, &AkkusativModel::dataChanged, this, &DataModel::akkusativModelChanged);
connect(&m_dativ, &DativModel::dataChanged, this, &DataModel::dativModelChanged);
connect(&m_plural, &PluralModel::dataChanged, this, &DataModel::pluralModelChanged);
connect(&m_metaData, &MetaDataModel::dataChanged, this, &DataModel::metaDataChanged);
connect(&m_genus, &GenusModel::dataChanged, this, &DataModel::genusModelChanged);
connect(&m_verbEnd, &VerbEndModel::dataChanged, this, &DataModel::verbEndModelChanged);
connect(&m_akkusativ, &AkkusativModel::dataChanged, this, &DataModel::akkusativModelChanged);
connect(&m_dativ, &DativModel::dataChanged, this, &DataModel::dativModelChanged);
connect(&m_wfModel, &WFModel::dataChanged, this, &DataModel::v2SvkModelChanged);
connect(&m_otModel, &OTModel::dataChanged, this, &DataModel::v2SvkModelChanged);
connect(&m_tPrModel, &TPrModel::dataChanged, this, &DataModel::v2SvkModelChanged);
connect(&m_tPeModel, &TPeModel::dataChanged, this, &DataModel::v2SvkModelChanged);
connect(&m_wfModel, &WFModel::dataChanged, this, &DataModel::v2SvkModelChanged);
connect(&m_otModel, &OTModel::dataChanged, this, &DataModel::v2SvkModelChanged);
connect(&m_tPrModel, &TPrModel::dataChanged, this, &DataModel::v2SvkModelChanged);
connect(&m_tPeModel, &TPeModel::dataChanged, this, &DataModel::v2SvkModelChanged);
connect(&m_passiv, &PassivModel::dataChanged, this, &DataModel::passivModelChanged);
connect(&m_genitiv, &GenitivModel::dataChanged, this, &DataModel::genitivModelChanged);
connect(&m_passiv, &PassivModel::dataChanged, this, &DataModel::passivModelChanged);
connect(&m_genitiv, &GenitivModel::dataChanged, this, &DataModel::genitivModelChanged);
}
void DataModel::write(const QString &filename) const
void DataModel::write(const QString& filename) const
{
ESGRAF48::DataModel dataModel;
ESGRAF48::DataModel dataModel;
m_metaData.write(*dataModel.mutable_metadata());
m_metaData.write(*dataModel.mutable_metadata());
m_wfModel.write(*dataModel.mutable_v2svk());
m_otModel.write(*dataModel.mutable_v2svk());
m_tPrModel.write(*dataModel.mutable_v2svk());
m_tPeModel.write(*dataModel.mutable_v2svk());
m_wfModel.write(*dataModel.mutable_v2svk());
m_otModel.write(*dataModel.mutable_v2svk());
m_tPrModel.write(*dataModel.mutable_v2svk());
m_tPeModel.write(*dataModel.mutable_v2svk());
m_verbEnd.write(*dataModel.mutable_verbend());
m_genus.write(*dataModel.mutable_genus());
m_akkusativ.write(*dataModel.mutable_akkusativ());
m_dativ.write(*dataModel.mutable_dativ());
m_plural.write(*dataModel.mutable_plural());
m_genitiv.write(*dataModel.mutable_lateskillsgenitiv());
m_passiv.write(*dataModel.mutable_lateskillspassiv());
m_verbEnd.write(*dataModel.mutable_verbend());
m_genus.write(*dataModel.mutable_genus());
m_akkusativ.write(*dataModel.mutable_akkusativ());
m_dativ.write(*dataModel.mutable_dativ());
m_plural.write(*dataModel.mutable_plural());
m_genitiv.write(*dataModel.mutable_lateskillsgenitiv());
m_passiv.write(*dataModel.mutable_lateskillspassiv());
QFile outFile(filename);
if (!outFile.open(QIODevice::WriteOnly))
{
throw std::runtime_error("failed to open file");
}
QFile outFile(filename);
if (!outFile.open(QIODevice::WriteOnly))
{
throw std::runtime_error("failed to open file");
}
bool success = dataModel.SerializeToFileDescriptor(outFile.handle());
if (success == false)
{
throw std::runtime_error("filed to write file");
}
bool success = dataModel.SerializeToFileDescriptor(outFile.handle());
if (success == false)
{
throw std::runtime_error("filed to write file");
}
}
void DataModel::read(const QString &filename)
void DataModel::read(const QString& filename)
{
QFile inFile(filename);
if (!inFile.open(QIODevice::ReadOnly))
{
throw std::runtime_error("failed to read file");
}
QFile inFile(filename);
if (!inFile.open(QIODevice::ReadOnly))
{
throw std::runtime_error("failed to read file");
}
ESGRAF48::DataModel dataModel;
bool success = dataModel.ParseFromFileDescriptor(inFile.handle());
if (success == false)
{
throw std::runtime_error("invalid file format");
}
ESGRAF48::DataModel dataModel;
bool success = dataModel.ParseFromFileDescriptor(inFile.handle());
if (success == false)
{
throw std::runtime_error("invalid file format");
}
m_metaData.read(dataModel.metadata());
m_metaData.read(dataModel.metadata());
m_wfModel.read(dataModel.v2svk());
m_otModel.read(dataModel.v2svk());
m_tPrModel.read(dataModel.v2svk());
m_tPeModel.read(dataModel.v2svk());
m_wfModel.read(dataModel.v2svk());
m_otModel.read(dataModel.v2svk());
m_tPrModel.read(dataModel.v2svk());
m_tPeModel.read(dataModel.v2svk());
m_verbEnd.read(dataModel.verbend());
m_genus.read(dataModel.genus());
m_akkusativ.read(dataModel.akkusativ());
m_dativ.read(dataModel.dativ());
m_plural.read(dataModel.plural());
m_genitiv.read(dataModel.lateskillsgenitiv());
m_passiv.read(dataModel.lateskillspassiv());
m_verbEnd.read(dataModel.verbend());
m_genus.read(dataModel.genus());
m_akkusativ.read(dataModel.akkusativ());
m_dativ.read(dataModel.dativ());
m_plural.read(dataModel.plural());
m_genitiv.read(dataModel.lateskillsgenitiv());
m_passiv.read(dataModel.lateskillspassiv());
}
void DataModel::printTo(QPrinter &printer) const
void DataModel::printTo(QPrinter& printer) const
{
QPainter painter;
painter.begin(&printer);
QPainter painter;
painter.begin(&printer);
painter.setFont(PrintableModel::h1Font());
painter.drawText(0, painter.fontMetrics().lineSpacing(), "ESGRAF 4-8 Auswertungsbogen");
painter.translate(0, 3 * painter.fontMetrics().lineSpacing());
painter.setFont(PrintableModel::h1Font());
painter.drawText(0, painter.fontMetrics().lineSpacing(), "ESGRAF 4-8 Auswertungsbogen");
painter.translate(0, 3 * painter.fontMetrics().lineSpacing());
m_metaData.printTo(painter);
m_metaData.printTo(painter);
m_wfModel.printTo(painter);
m_otModel.printTo(painter);
m_tPrModel.printTo(painter);
m_tPeModel.printTo(painter);
V2SvkModel::printSummary(painter,
m_wfModel.getV2Points() + m_otModel.getV2Points()
+ m_tPrModel.getV2Points() + m_tPeModel.getV2Points(),
m_wfModel.getSvkPoints() + m_otModel.getSvkPoints()
+ m_tPrModel.getSvkPoints() + m_tPeModel.getSvkPoints());
m_wfModel.printTo(painter);
m_otModel.printTo(painter);
m_tPrModel.printTo(painter);
m_tPeModel.printTo(painter);
V2SvkModel::printSummary(painter,
m_wfModel.getV2Points() + m_otModel.getV2Points()
+ m_tPrModel.getV2Points() + m_tPeModel.getV2Points(),
m_wfModel.getSvkPoints() + m_otModel.getSvkPoints()
+ m_tPrModel.getSvkPoints() + m_tPeModel.getSvkPoints());
m_verbEnd.printTo(painter);
m_genus.printTo(painter);
m_verbEnd.printTo(painter);
m_genus.printTo(painter);
printer.newPage();
painter.resetTransform();
printer.newPage();
painter.resetTransform();
m_akkusativ.printTo(painter);
m_dativ.printTo(painter);
m_plural.printTo(painter);
m_akkusativ.printTo(painter);
m_dativ.printTo(painter);
m_plural.printTo(painter);
m_passiv.printTo(painter);
m_genitiv.printTo(painter);
m_passiv.printTo(painter);
m_genitiv.printTo(painter);
m_results.printTo(painter);
m_results.printTo(painter);
painter.end();
painter.end();
}
void DataModel::pluralModelChanged()
{
m_results.setPluralResult(m_plural.getPoints());
m_results.setPluralResult(m_plural.getPoints());
emit modelChanged();
emit modelChanged();
}
void DataModel::metaDataChanged()
{
m_results.setAge(m_metaData.getAge());
m_results.setAge(m_metaData.getAge());
emit modelChanged();
emit modelChanged();
}
void DataModel::genusModelChanged()
{
m_results.setGenusResult(m_genus.getPoints());
m_results.setGenusResult(m_genus.getPoints());
emit modelChanged();
emit modelChanged();
}
void DataModel::verbEndModelChanged()
{
m_results.setVerbEndResult(m_verbEnd.getPoints());
m_results.setVerbEndResult(m_verbEnd.getPoints());
emit modelChanged();
emit modelChanged();
}
void DataModel::akkusativModelChanged()
{
m_results.setAkkusativResult(m_akkusativ.getPoints());
m_results.setAkkusativResult(m_akkusativ.getPoints());
emit modelChanged();
emit modelChanged();
}
void DataModel::dativModelChanged()
{
m_results.setDativResult(m_dativ.getPoints());
m_results.setDativResult(m_dativ.getPoints());
emit modelChanged();
emit modelChanged();
}
void DataModel::v2SvkModelChanged()
{
m_results.setV2Result(m_wfModel.getV2Points() + m_otModel.getV2Points()
+ m_tPrModel.getV2Points() + m_tPeModel.getV2Points());
m_results.setSvkResult(m_wfModel.getSvkPoints() + m_otModel.getSvkPoints()
+ m_tPrModel.getSvkPoints() + m_tPeModel.getSvkPoints());
m_results.setV2Result(m_wfModel.getV2Points() + m_otModel.getV2Points()
+ m_tPrModel.getV2Points() + m_tPeModel.getV2Points());
m_results.setSvkResult(m_wfModel.getSvkPoints() + m_otModel.getSvkPoints()
+ m_tPrModel.getSvkPoints() + m_tPeModel.getSvkPoints());
emit modelChanged();
emit modelChanged();
}
void DataModel::passivModelChanged()
{
m_results.setPassivResult(m_passiv.getPoints());
m_results.setPassivResult(m_passiv.getPoints());
emit modelChanged();
emit modelChanged();
}
void DataModel::genitivModelChanged()
{
m_results.setGenitivResult(m_genitiv.getPoints());
m_results.setGenitivResult(m_genitiv.getPoints());
emit modelChanged();
emit modelChanged();
}

View file

@ -23,45 +23,45 @@
class DataModel : public QObject
{
Q_OBJECT
Q_OBJECT
public:
MetaDataModel m_metaData;
VerbEndModel m_verbEnd;
GenusModel m_genus;
PluralModel m_plural;
AkkusativModel m_akkusativ;
DativModel m_dativ;
MetaDataModel m_metaData;
VerbEndModel m_verbEnd;
GenusModel m_genus;
PluralModel m_plural;
AkkusativModel m_akkusativ;
DativModel m_dativ;
WFModel m_wfModel;
OTModel m_otModel;
TPrModel m_tPrModel;
TPeModel m_tPeModel;
WFModel m_wfModel;
OTModel m_otModel;
TPrModel m_tPrModel;
TPeModel m_tPeModel;
PassivModel m_passiv;
GenitivModel m_genitiv;
ResultModel m_results;
ResultModel m_results;
public:
DataModel(QObject *parent);
DataModel(QObject* parent);
void write(const QString &filename) const;
void read(const QString &filename);
void write(const QString& filename) const;
void read(const QString& filename);
void printTo(QPrinter &printer) const;
void printTo(QPrinter& printer) const;
signals:
void modelChanged();
void modelChanged();
private slots:
void pluralModelChanged();
void metaDataChanged();
void genusModelChanged();
void verbEndModelChanged();
void akkusativModelChanged();
void dativModelChanged();
void v2SvkModelChanged();
void pluralModelChanged();
void metaDataChanged();
void genusModelChanged();
void verbEndModelChanged();
void akkusativModelChanged();
void dativModelChanged();
void v2SvkModelChanged();
void passivModelChanged();
void genitivModelChanged();
};

View file

@ -5,33 +5,33 @@
#include <QApplication>
#include <QCommandLineParser>
int main(int argc, char **argv)
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QCoreApplication::setApplicationName(ESGRAF48_DESCRIPTION);
QCoreApplication::setApplicationVersion(ESGRAF48_VERSION);
QApplication app(argc, argv);
QCoreApplication::setApplicationName(ESGRAF48_DESCRIPTION);
QCoreApplication::setApplicationVersion(ESGRAF48_VERSION);
QCommandLineParser cmdParser;
cmdParser.setApplicationDescription(ESGRAF48_DESCRIPTION);
cmdParser.addHelpOption();
cmdParser.addVersionOption();
cmdParser.addPositionalArgument("filename", "file to open");
QCommandLineParser cmdParser;
cmdParser.setApplicationDescription(ESGRAF48_DESCRIPTION);
cmdParser.addHelpOption();
cmdParser.addVersionOption();
cmdParser.addPositionalArgument("filename", "file to open");
cmdParser.process(app);
cmdParser.process(app);
const QStringList args = cmdParser.positionalArguments();
const QStringList args = cmdParser.positionalArguments();
std::unique_ptr<MainWindow> mainWindow;
if (args.empty())
{
mainWindow = std::make_unique<MainWindow>(nullptr);
}
else
{
mainWindow = std::make_unique<MainWindow>(nullptr, args.at(0));
}
std::unique_ptr<MainWindow> mainWindow;
if (args.empty())
{
mainWindow = std::make_unique<MainWindow>(nullptr);
}
else
{
mainWindow = std::make_unique<MainWindow>(nullptr, args.at(0));
}
mainWindow->show();
mainWindow->show();
return app.exec();
return app.exec();
}

View file

@ -4,170 +4,170 @@
#include <sstream>
MetaDataModel::MetaDataModel(QObject *parent)
MetaDataModel::MetaDataModel(QObject* parent)
: PrintableModel(parent)
{
m_dateOfBirth = QDate::currentDate().addYears(-9);
m_dateOfTest = QDate::currentDate();
m_dateOfBirth = QDate::currentDate().addYears(-9);
m_dateOfTest = QDate::currentDate();
}
int MetaDataModel::rowCount(const QModelIndex &parent) const
int MetaDataModel::rowCount(const QModelIndex& parent) const
{
return 1;
return 1;
}
int MetaDataModel::columnCount(const QModelIndex &parent) const
int MetaDataModel::columnCount(const QModelIndex& parent) const
{
return 6;
return 6;
}
QVariant MetaDataModel::data(const QModelIndex &modelIndex, int role) const
QVariant MetaDataModel::data(const QModelIndex& modelIndex, int role) const
{
if (role == Qt::DisplayRole || role == Qt::EditRole)
{
switch (modelIndex.column())
{
case 0:
return m_participant;
case 1:
return m_instructor;
case 2:
return m_dateOfBirth;
case 3:
return m_dateOfTest;
case 4:
return m_remarks;
case 5:
return QString::fromStdString(getAge().toString());
default:
return QVariant();
}
}
if (role == Qt::DisplayRole || role == Qt::EditRole)
{
switch (modelIndex.column())
{
case 0:
return m_participant;
case 1:
return m_instructor;
case 2:
return m_dateOfBirth;
case 3:
return m_dateOfTest;
case 4:
return m_remarks;
case 5:
return QString::fromStdString(getAge().toString());
default:
return QVariant();
}
}
return QVariant();
return QVariant();
}
Qt::ItemFlags MetaDataModel::flags(const QModelIndex &modelIndex) const
Qt::ItemFlags MetaDataModel::flags(const QModelIndex& modelIndex) const
{
return QAbstractTableModel::flags(modelIndex) | Qt::ItemIsEditable;
return QAbstractTableModel::flags(modelIndex) | Qt::ItemIsEditable;
}
bool MetaDataModel::setData(const QModelIndex &modelIndex, const QVariant &value, int role)
bool MetaDataModel::setData(const QModelIndex& modelIndex, const QVariant& value, int role)
{
if (role != Qt::EditRole)
{
return QAbstractTableModel::setData(modelIndex, value, role);
}
if (role != Qt::EditRole)
{
return QAbstractTableModel::setData(modelIndex, value, role);
}
bool valueChanged = false;
bool valueChanged = false;
switch (modelIndex.column())
{
case 0:
if (value.toString() != m_participant)
{
m_participant = value.toString();
valueChanged = true;
}
break;
case 1:
if (value.toString() != m_instructor)
{
m_instructor = value.toString();
valueChanged = true;
}
break;
case 2:
if (value.toDate() != m_dateOfBirth)
{
m_dateOfBirth = value.toDate();
emit dataChanged(index(0, 5), index(0, 5));
valueChanged = true;
}
break;
case 3:
if (value.toDate() != m_dateOfTest)
{
m_dateOfTest = value.toDate();
emit dataChanged(index(0, 5), index(0, 5));
valueChanged = true;
}
break;
case 4:
if (value.toString() != m_remarks)
{
m_remarks = value.toString();
valueChanged = true;
}
break;
default:
break;
}
switch (modelIndex.column())
{
case 0:
if (value.toString() != m_participant)
{
m_participant = value.toString();
valueChanged = true;
}
break;
case 1:
if (value.toString() != m_instructor)
{
m_instructor = value.toString();
valueChanged = true;
}
break;
case 2:
if (value.toDate() != m_dateOfBirth)
{
m_dateOfBirth = value.toDate();
emit dataChanged(index(0, 5), index(0, 5));
valueChanged = true;
}
break;
case 3:
if (value.toDate() != m_dateOfTest)
{
m_dateOfTest = value.toDate();
emit dataChanged(index(0, 5), index(0, 5));
valueChanged = true;
}
break;
case 4:
if (value.toString() != m_remarks)
{
m_remarks = value.toString();
valueChanged = true;
}
break;
default:
break;
}
if (valueChanged)
{
emit dataChanged(modelIndex, modelIndex);
}
if (valueChanged)
{
emit dataChanged(modelIndex, modelIndex);
}
return valueChanged;
return valueChanged;
}
void MetaDataModel::read(const ESGRAF48::MetaDataModel &model)
void MetaDataModel::read(const ESGRAF48::MetaDataModel& model)
{
setData(index(0, 0), QString::fromStdString(model.participantname()));
setData(index(0, 1), QString::fromStdString(model.instructorname()));
setData(index(0, 2), QString::fromStdString(model.dateofbirth()));
setData(index(0, 3), QString::fromStdString(model.dateoftest()));
setData(index(0, 4), QString::fromStdString(model.remarks()));
setData(index(0, 0), QString::fromStdString(model.participantname()));
setData(index(0, 1), QString::fromStdString(model.instructorname()));
setData(index(0, 2), QString::fromStdString(model.dateofbirth()));
setData(index(0, 3), QString::fromStdString(model.dateoftest()));
setData(index(0, 4), QString::fromStdString(model.remarks()));
}
void MetaDataModel::write(ESGRAF48::MetaDataModel &model) const
void MetaDataModel::write(ESGRAF48::MetaDataModel& model) const
{
model.set_participantname(m_participant.toStdString());
model.set_instructorname(m_instructor.toStdString());
model.set_dateofbirth(m_dateOfBirth.toString(Qt::ISODate).toStdString());
model.set_dateoftest(m_dateOfTest.toString(Qt::ISODate).toStdString());
model.set_remarks(m_remarks.toStdString());
model.set_participantname(m_participant.toStdString());
model.set_instructorname(m_instructor.toStdString());
model.set_dateofbirth(m_dateOfBirth.toString(Qt::ISODate).toStdString());
model.set_dateoftest(m_dateOfTest.toString(Qt::ISODate).toStdString());
model.set_remarks(m_remarks.toStdString());
}
void MetaDataModel::printTo(QPainter &painter) const
void MetaDataModel::printTo(QPainter& painter) const
{
painter.setFont(tableFont());
painter.setFont(tableFont());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
auto hasRemarks = !m_remarks.trimmed().isEmpty();
auto hasRemarks = !m_remarks.trimmed().isEmpty();
painter.drawText(0, 0, "Name, Vorname");
painter.drawText(0.25 * width, 0, m_participant);
painter.drawText(0.5 * width, 0, "Untersucher(in)");
painter.drawText(0.75 * width, 0, m_instructor);
painter.drawText(0, 0, "Name, Vorname");
painter.drawText(0.25 * width, 0, m_participant);
painter.drawText(0.5 * width, 0, "Untersucher(in)");
painter.drawText(0.75 * width, 0, m_instructor);
painter.translate(0, height);
painter.translate(0, height);
painter.drawText(0, 0, "Geburtsdatum");
painter.drawText(0.25 * width, 0, m_dateOfBirth.toString("dd.MM.yyyy"));
if (hasRemarks)
{
painter.drawText(0.5 * width, 0, "Bemerkungen:");
painter.drawText(QRect(0.5 * width, 0.5 * height, width, 2 * height), m_remarks);
}
painter.drawText(0, 0, "Geburtsdatum");
painter.drawText(0.25 * width, 0, m_dateOfBirth.toString("dd.MM.yyyy"));
if (hasRemarks)
{
painter.drawText(0.5 * width, 0, "Bemerkungen:");
painter.drawText(QRect(0.5 * width, 0.5 * height, width, 2 * height), m_remarks);
}
painter.translate(0, height);
painter.translate(0, height);
painter.drawText(0, 0, "Untersuchungsdatum");
painter.drawText(0.25 * width, 0, m_dateOfTest.toString("dd.MM.yyyy"));
painter.drawText(0, 0, "Untersuchungsdatum");
painter.drawText(0.25 * width, 0, m_dateOfTest.toString("dd.MM.yyyy"));
painter.translate(0, height);
painter.translate(0, height);
painter.drawText(0, 0, "Alter am Testtag");
painter.drawText(0.25 * width, 0, getAge().toString().c_str());
painter.drawText(0, 0, "Alter am Testtag");
painter.drawText(0.25 * width, 0, getAge().toString().c_str());
painter.translate(0, 2 * height);
painter.translate(0, 2 * height);
}
Age MetaDataModel::getAge() const
{
return {m_dateOfBirth, m_dateOfTest};
return {m_dateOfBirth, m_dateOfTest};
}

View file

@ -12,27 +12,27 @@
class MetaDataModel : public PrintableModel
{
Q_OBJECT
Q_OBJECT
private:
QString m_participant;
QString m_instructor;
QDate m_dateOfBirth;
QDate m_dateOfTest;
QString m_remarks;
QString m_participant;
QString m_instructor;
QDate m_dateOfBirth;
QDate m_dateOfTest;
QString m_remarks;
public:
MetaDataModel(QObject *parent);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
MetaDataModel(QObject* parent);
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
void read(const ESGRAF48::MetaDataModel &model);
void write(ESGRAF48::MetaDataModel &model) const;
void read(const ESGRAF48::MetaDataModel& model);
void write(ESGRAF48::MetaDataModel& model) const;
void printTo(QPainter &painter) const override;
void printTo(QPainter& painter) const override;
Age getAge() const;
Age getAge() const;
};

View file

@ -6,37 +6,37 @@
#include <QDataWidgetMapper>
#include <QDebug>
MetaDataWidget::MetaDataWidget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::MetaDataWidget)
, m_widgetMapper(new QDataWidgetMapper(this))
MetaDataWidget::MetaDataWidget(QWidget* parent)
: QWidget(parent)
, ui(new Ui::MetaDataWidget)
, m_widgetMapper(new QDataWidgetMapper(this))
{
ui->setupUi(this);
ui->setupUi(this);
connect(ui->dateOfTestDateEdit, &QDateEdit::dateChanged, m_widgetMapper,
&QDataWidgetMapper::submit);
connect(ui->dateOfBirthDateEdit, &QDateEdit::dateChanged, m_widgetMapper,
&QDataWidgetMapper::submit);
connect(ui->dateOfTestDateEdit, &QDateEdit::dateChanged, m_widgetMapper,
&QDataWidgetMapper::submit);
connect(ui->dateOfBirthDateEdit, &QDateEdit::dateChanged, m_widgetMapper,
&QDataWidgetMapper::submit);
}
MetaDataWidget::~MetaDataWidget()
{
delete ui;
delete ui;
}
void MetaDataWidget::setModel(MetaDataModel *model)
void MetaDataWidget::setModel(MetaDataModel* model)
{
m_widgetMapper->setModel(model);
m_widgetMapper->addMapping(ui->participantLineEdit, 0);
m_widgetMapper->addMapping(ui->instructorLineEdit, 1);
m_widgetMapper->addMapping(ui->dateOfBirthDateEdit, 2);
m_widgetMapper->addMapping(ui->dateOfTestDateEdit, 3);
m_widgetMapper->addMapping(ui->remarksPlainTextEdit, 4);
m_widgetMapper->addMapping(ui->ageLineEdit, 5);
m_widgetMapper->toFirst();
m_widgetMapper->setModel(model);
m_widgetMapper->addMapping(ui->participantLineEdit, 0);
m_widgetMapper->addMapping(ui->instructorLineEdit, 1);
m_widgetMapper->addMapping(ui->dateOfBirthDateEdit, 2);
m_widgetMapper->addMapping(ui->dateOfTestDateEdit, 3);
m_widgetMapper->addMapping(ui->remarksPlainTextEdit, 4);
m_widgetMapper->addMapping(ui->ageLineEdit, 5);
m_widgetMapper->toFirst();
}
void MetaDataWidget::toFirst()
{
m_widgetMapper->toFirst();
m_widgetMapper->toFirst();
}

View file

@ -6,21 +6,21 @@ class QDataWidgetMapper;
class MetaDataModel;
namespace Ui {
class MetaDataWidget;
class MetaDataWidget;
};
class MetaDataWidget : public QWidget
{
Q_OBJECT
Q_OBJECT
private:
Ui::MetaDataWidget *ui;
QDataWidgetMapper *m_widgetMapper;
Ui::MetaDataWidget* ui;
QDataWidgetMapper* m_widgetMapper;
public:
MetaDataWidget(QWidget *parent = nullptr);
~MetaDataWidget();
MetaDataWidget(QWidget* parent = nullptr);
~MetaDataWidget();
void setModel(MetaDataModel *model);
void toFirst();
void setModel(MetaDataModel* model);
void toFirst();
};

View file

@ -2,183 +2,183 @@
#include <regex>
PrintableModel::PrintableModel(QObject *parent)
PrintableModel::PrintableModel(QObject* parent)
: CheckableTestModel(parent)
{
}
void PrintableModel::printTo(QPainter &painter) const
void PrintableModel::printTo(QPainter& painter) const
{
printHeader(painter);
printTests(painter);
printSummary(painter);
printHeader(painter);
printTests(painter);
printSummary(painter);
}
QFont PrintableModel::h1Font()
{
return QFont("Helvetica", 16);
return QFont("Helvetica", 16);
}
QFont PrintableModel::h2Font()
{
return QFont("Helvetica", 10);
return QFont("Helvetica", 10);
}
QFont PrintableModel::tableFont()
{
return QFont("Helvetica", 8);
return QFont("Helvetica", 8);
}
QPen PrintableModel::tablePen()
{
return QPen(Qt::black, 1, Qt::SolidLine);
return QPen(Qt::black, 1, Qt::SolidLine);
}
QPen PrintableModel::resultPen()
{
return QPen(Qt::black, 2, Qt::SolidLine);
return QPen(Qt::black, 2, Qt::SolidLine);
}
double PrintableModel::headerWidthFactor()
{
return 0.17;
return 0.17;
}
double PrintableModel::cellWidthFactor()
{
return headerWidthFactor() / 2;
return headerWidthFactor() / 2;
}
void PrintableModel::drawTextSquare(QPainter &painter, const QRectF &cell, const QString &text)
void PrintableModel::drawTextSquare(QPainter& painter, const QRectF& cell, const QString& text)
{
auto prevPen = painter.pen();
painter.setPen(tablePen());
auto prevPen = painter.pen();
painter.setPen(tablePen());
painter.drawText(cell, Qt::AlignCenter, text);
painter.drawText(cell, Qt::AlignCenter, text);
painter.drawLine(cell.topLeft(), cell.topRight());
painter.drawLine(cell.topRight(), cell.bottomRight());
painter.drawLine(cell.bottomRight(), cell.bottomLeft());
painter.drawLine(cell.bottomLeft(), cell.topLeft());
painter.drawLine(cell.topLeft(), cell.topRight());
painter.drawLine(cell.topRight(), cell.bottomRight());
painter.drawLine(cell.bottomRight(), cell.bottomLeft());
painter.drawLine(cell.bottomLeft(), cell.topLeft());
painter.setPen(prevPen);
painter.setPen(prevPen);
}
void PrintableModel::drawNumberSquare(QPainter &painter, double x, double y, int number)
void PrintableModel::drawNumberSquare(QPainter& painter, double x, double y, int number)
{
QRectF cell = {x, y, 0.03 * painter.device()->width(),
1.5 * painter.fontMetrics().lineSpacing()};
QRectF cell = {x, y, 0.03 * painter.device()->width(),
1.5 * painter.fontMetrics().lineSpacing()};
painter.drawText(cell, Qt::AlignCenter, QString::number(number));
painter.drawText(cell, Qt::AlignCenter, QString::number(number));
painter.drawLine(cell.topLeft(), cell.topRight());
painter.drawLine(cell.topRight(), cell.bottomRight());
painter.drawLine(cell.bottomRight(), cell.bottomLeft());
painter.drawLine(cell.bottomLeft(), cell.topLeft());
painter.drawLine(cell.topLeft(), cell.topRight());
painter.drawLine(cell.topRight(), cell.bottomRight());
painter.drawLine(cell.bottomRight(), cell.bottomLeft());
painter.drawLine(cell.bottomLeft(), cell.topLeft());
}
void PrintableModel::PrintableModel::drawCheckSquare(QPainter &painter, const QRectF &cell,
void PrintableModel::PrintableModel::drawCheckSquare(QPainter& painter, const QRectF& cell,
bool checked)
{
drawTextSquare(painter, cell, checked ? u8"\u2612" : u8"\u2610");
}
void PrintableModel::drawResultSquare(QPainter &painter, double y, bool rightCell,
void PrintableModel::drawResultSquare(QPainter& painter, double y, bool rightCell,
unsigned int value)
{
double pageWidth = painter.device()->width();
double cellWidth = 0.03 * pageWidth;
double cellHeight = 1.5 * painter.fontMetrics().lineSpacing();
double x = pageWidth - cellWidth - (rightCell ? 0 : 0.04 * pageWidth);
double pageWidth = painter.device()->width();
double cellWidth = 0.03 * pageWidth;
double cellHeight = 1.5 * painter.fontMetrics().lineSpacing();
double x = pageWidth - cellWidth - (rightCell ? 0 : 0.04 * pageWidth);
drawTextSquare(painter, {x, y, cellWidth, cellHeight}, QString::number(value));
drawTextSquare(painter, {x, y, cellWidth, cellHeight}, QString::number(value));
}
void PrintableModel::drawGreySquare(QPainter &painter, const QRectF &cell)
void PrintableModel::drawGreySquare(QPainter& painter, const QRectF& cell)
{
auto prevBrush = painter.brush();
auto prevPen = painter.pen();
auto prevBrush = painter.brush();
auto prevPen = painter.pen();
painter.setBrush(QBrush(QColor(224, 224, 224)));
painter.setPen(QPen(Qt::NoPen));
QPointF points[4] = {cell.topLeft(), cell.topRight(), cell.bottomRight(), cell.bottomLeft()};
painter.drawPolygon(points, 4);
painter.setBrush(QBrush(QColor(224, 224, 224)));
painter.setPen(QPen(Qt::NoPen));
QPointF points[4] = {cell.topLeft(), cell.topRight(), cell.bottomRight(), cell.bottomLeft()};
painter.drawPolygon(points, 4);
painter.setPen(tablePen());
painter.drawLine(cell.topLeft(), cell.topRight());
painter.drawLine(cell.topRight(), cell.bottomRight());
painter.drawLine(cell.bottomRight(), cell.bottomLeft());
painter.drawLine(cell.bottomLeft(), cell.topLeft());
painter.setPen(tablePen());
painter.drawLine(cell.topLeft(), cell.topRight());
painter.drawLine(cell.topRight(), cell.bottomRight());
painter.drawLine(cell.bottomRight(), cell.bottomLeft());
painter.drawLine(cell.bottomLeft(), cell.topLeft());
painter.setBrush(prevBrush);
painter.setPen(prevPen);
painter.setBrush(prevBrush);
painter.setPen(prevPen);
}
void PrintableModel::drawHeader2(QPainter &painter, const QString &text)
void PrintableModel::drawHeader2(QPainter& painter, const QString& text)
{
painter.setFont(h2Font());
painter.drawText(0, 0, text);
painter.translate(0, 0.5 * painter.fontMetrics().lineSpacing());
painter.setFont(h2Font());
painter.drawText(0, 0, text);
painter.translate(0, 0.5 * painter.fontMetrics().lineSpacing());
}
void PrintableModel::printHeader(QPainter &painter) const
void PrintableModel::printHeader(QPainter& painter) const
{
auto title = getTitle();
if (!title.isEmpty())
{
drawHeader2(painter, getTitle());
}
auto title = getTitle();
if (!title.isEmpty())
{
drawHeader2(painter, getTitle());
}
}
void PrintableModel::printTests(QPainter &painter) const
void PrintableModel::printTests(QPainter& painter) const
{
painter.setFont(tableFont());
painter.setPen(tablePen());
painter.setFont(tableFont());
painter.setPen(tablePen());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
double headerWidth = headerWidthFactor() * width;
double cellWidth = cellWidthFactor() * width;
double rowHeight = height;
double headerWidth = headerWidthFactor() * width;
double cellWidth = cellWidthFactor() * width;
double rowHeight = height;
double x = 0;
double y = 0;
for (const auto &test : m_tests)
{
QString testName = QString::fromStdString(
std::regex_replace(test.name().toStdString(), std::regex("\\s"), "\n"));
double x = 0;
double y = 0;
for (const auto& test : m_tests)
{
QString testName = QString::fromStdString(
std::regex_replace(test.name().toStdString(), std::regex("\\s"), "\n"));
drawTextSquare(painter, {0, y, headerWidth, 2 * rowHeight}, testName);
x = headerWidth;
drawTextSquare(painter, {0, y, headerWidth, 2 * rowHeight}, testName);
x = headerWidth;
for (const auto &item : test.items())
{
drawTextSquare(painter, {x, y, cellWidth, rowHeight}, item.getText().c_str());
drawCheckSquare(painter, {x, y + rowHeight, cellWidth, rowHeight}, item.isChecked());
for (const auto& item : test.items())
{
drawTextSquare(painter, {x, y, cellWidth, rowHeight}, item.getText().c_str());
drawCheckSquare(painter, {x, y + rowHeight, cellWidth, rowHeight}, item.isChecked());
x += cellWidth;
}
y += rowHeight;
x += cellWidth;
}
y += rowHeight;
drawResultSquare(painter, y, true, test.getPoints());
y += rowHeight;
}
drawResultSquare(painter, y, true, test.getPoints());
y += rowHeight;
}
painter.translate(0, y + rowHeight);
painter.translate(0, y + rowHeight);
}
void PrintableModel::printSummary(QPainter &painter) const
void PrintableModel::printSummary(QPainter& painter) const
{
painter.setFont(tableFont());
painter.setFont(tableFont());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
painter.drawText(0, 0, 0.95 * width, height, Qt::AlignRight | Qt::AlignVCenter,
"Rohwertpunkte Total:");
painter.setPen(resultPen());
drawNumberSquare(painter, 0.97 * width, 0, getPoints());
painter.drawText(0, 0, 0.95 * width, height, Qt::AlignRight | Qt::AlignVCenter,
"Rohwertpunkte Total:");
painter.setPen(resultPen());
drawNumberSquare(painter, 0.97 * width, 0, getPoints());
painter.translate(0, 3 * height);
painter.translate(0, 3 * height);
}

View file

@ -10,33 +10,33 @@
class PrintableModel : public CheckableTestModel
{
Q_OBJECT
Q_OBJECT
public:
PrintableModel(QObject *parent);
PrintableModel(QObject* parent);
virtual void printTo(QPainter &painter) const;
virtual void printTo(QPainter& painter) const;
static QFont h1Font();
static QFont h2Font();
static QFont tableFont();
static QFont h1Font();
static QFont h2Font();
static QFont tableFont();
static QPen tablePen();
static QPen resultPen();
static QPen tablePen();
static QPen resultPen();
static double headerWidthFactor();
static double cellWidthFactor();
static double headerWidthFactor();
static double cellWidthFactor();
static void drawTextSquare(QPainter &painter, const QRectF &cell, const QString &text);
static void drawNumberSquare(QPainter &painter, double x, double y, int number);
static void drawCheckSquare(QPainter &painter, const QRectF &cell, bool checked);
static void drawResultSquare(QPainter &painter, double y, bool rightCell, unsigned int value);
static void drawGreySquare(QPainter &painter, const QRectF &cell);
static void drawTextSquare(QPainter& painter, const QRectF& cell, const QString& text);
static void drawNumberSquare(QPainter& painter, double x, double y, int number);
static void drawCheckSquare(QPainter& painter, const QRectF& cell, bool checked);
static void drawResultSquare(QPainter& painter, double y, bool rightCell, unsigned int value);
static void drawGreySquare(QPainter& painter, const QRectF& cell);
static void drawHeader2(QPainter &painter, const QString &text);
static void drawHeader2(QPainter& painter, const QString& text);
protected:
virtual void printHeader(QPainter &painter) const;
virtual void printTests(QPainter &painter) const;
virtual void printSummary(QPainter &painter) const;
virtual void printHeader(QPainter& painter) const;
virtual void printTests(QPainter& painter) const;
virtual void printSummary(QPainter& painter) const;
};

View file

@ -5,9 +5,9 @@
class AkkusativPR : public PRMap
{
public:
AkkusativPR()
{
// clang-format off
AkkusativPR()
{
// clang-format off
m_ages = {
{ 4, 0 },
{ 5, 0 },
@ -44,6 +44,6 @@ public:
{ 95, 89, 76, 74, 69 },
{ 100, 100, 100, 100, 100 }
};
// clang-format on
}
// clang-format on
}
};

View file

@ -5,9 +5,9 @@
class DativPR : public PRMap
{
public:
DativPR()
{
// clang-format off
DativPR()
{
// clang-format off
m_ages = {
{ 4, 0 },
{ 5, 0 },
@ -44,6 +44,6 @@ public:
{ 92, 87, 76, 68, 60 },
{ 100, 100, 100, 100, 100 }
};
// clang-format on
}
// clang-format on
}
};

View file

@ -5,9 +5,9 @@
class GenitivPR : public PRMap
{
public:
GenitivPR()
{
// clang-format off
GenitivPR()
{
// clang-format off
m_ages = {
{ 7, 0 },
{ 7, 6 },
@ -34,6 +34,6 @@ public:
{ 96, 92, 87 },
{ 100, 100, 100 }
};
// clang-format on
}
// clang-format on
}
};

View file

@ -5,9 +5,9 @@
class GenusPR : public PRMap
{
public:
GenusPR()
{
// clang-format off
GenusPR()
{
// clang-format off
m_ages = {
{ 4, 0 },
{ 5, 0 },
@ -40,7 +40,6 @@ public:
{ 94, 75, 49, 37, 27 },
{ 100, 100, 100, 100, 100 },
};
// clang-format on
}
// clang-format on
}
};

View file

@ -1,43 +1,43 @@
#include "PRMap.h"
unsigned int PRMap::lookup(const Age &age, const unsigned int &points)
unsigned int PRMap::lookup(const Age& age, const unsigned int& points)
{
if (points >= m_PRs.size())
{
return 0;
}
if (points >= m_PRs.size())
{
return 0;
}
auto ageIndex = [&]() -> size_t {
if (m_ages.empty())
{
return 0;
}
auto ageIndex = [&]() -> size_t {
if (m_ages.empty())
{
return 0;
}
if (age < m_ages.front())
{
return 0;
}
if (age < m_ages.front())
{
return 0;
}
if (m_ages.back() < age)
{
return m_ages.size() - 2;
}
if (m_ages.back() < age)
{
return m_ages.size() - 2;
}
for (size_t index = 1; index < m_ages.size(); ++index)
{
if (age < m_ages.at(index))
{
return index - 1;
}
}
for (size_t index = 1; index < m_ages.size(); ++index)
{
if (age < m_ages.at(index))
{
return index - 1;
}
}
return 0;
}();
}();
if (ageIndex >= m_PRs.at(points).size())
{
return 0;
}
if (ageIndex >= m_PRs.at(points).size())
{
return 0;
}
return m_PRs.at(points).at(ageIndex);
return m_PRs.at(points).at(ageIndex);
}

View file

@ -6,9 +6,9 @@
class PRMap
{
protected:
std::vector<Age> m_ages;
std::vector<std::vector<unsigned int>> m_PRs;
std::vector<Age> m_ages;
std::vector<std::vector<unsigned int>> m_PRs;
public:
unsigned int lookup(const Age &age, const unsigned int &points);
unsigned int lookup(const Age& age, const unsigned int& points);
};

View file

@ -5,9 +5,9 @@
class PassivPR : public PRMap
{
public:
PassivPR()
{
// clang-format off
PassivPR()
{
// clang-format off
m_ages = {
{ 7, 0 },
{ 8, 6 },
@ -27,6 +27,6 @@ public:
{ 94, 84 },
{ 100, 100 }
};
// clang-format on
}
// clang-format on
}
};

View file

@ -5,9 +5,9 @@
class PluralPR : public PRMap
{
public:
PluralPR()
{
// clang-format off
PluralPR()
{
// clang-format off
m_ages = {
{ 4, 0 },
{ 4, 6 },
@ -27,6 +27,6 @@ public:
{ 79, 56, 27 },
{ 100, 100, 100 }
};
// clang-format on
}
// clang-format on
}
};

View file

@ -14,246 +14,246 @@
#include <QDebug>
ResultModel::ResultModel(QObject *parent)
ResultModel::ResultModel(QObject* parent)
: QAbstractTableModel(parent)
{
m_results = {{"V2", "SVK", "VE", "Passiv", "Genus", "Akkusativ", "Dativ", "Genitiv", "Plural"}};
m_results = {{"V2", "SVK", "VE", "Genus", "Akkusativ", "Dativ", "Plural", "Passiv", "Genitiv"}};
m_results = {{"V2", "SVK", "VE", "Passiv", "Genus", "Akkusativ", "Dativ", "Genitiv", "Plural"}};
m_results = {{"V2", "SVK", "VE", "Genus", "Akkusativ", "Dativ", "Plural", "Passiv", "Genitiv"}};
}
int ResultModel::rowCount(const QModelIndex &parent) const
int ResultModel::rowCount(const QModelIndex& parent) const
{
return 4;
return 4;
}
int ResultModel::columnCount(const QModelIndex &parent) const
int ResultModel::columnCount(const QModelIndex& parent) const
{
return 9;
return 9;
}
QVariant ResultModel::data(const QModelIndex &index, int role) const
QVariant ResultModel::data(const QModelIndex& index, int role) const
{
if (role == Qt::DisplayRole && index.column() < m_results.size())
{
switch (index.row())
{
case 0:
{
auto points = m_results[index.column()].points();
if (points != 0)
{
return static_cast<uint>(points);
}
break;
}
case 1:
{
auto pr = m_results[index.column()].pr();
if (pr >= 84)
{
return static_cast<uint>(pr);
}
break;
}
case 2:
{
auto pr = m_results[index.column()].pr();
if (pr < 84 && pr > 16)
{
return static_cast<uint>(pr);
}
break;
}
case 3:
{
auto pr = m_results[index.column()].pr();
if (pr <= 16)
{
return static_cast<uint>(pr);
}
break;
}
default:
break;
};
if (role == Qt::DisplayRole && index.column() < m_results.size())
{
switch (index.row())
{
case 0:
{
auto points = m_results[index.column()].points();
if (points != 0)
{
return static_cast<uint>(points);
}
break;
}
case 1:
{
auto pr = m_results[index.column()].pr();
if (pr >= 84)
{
return static_cast<uint>(pr);
}
break;
}
case 2:
{
auto pr = m_results[index.column()].pr();
if (pr < 84 && pr > 16)
{
return static_cast<uint>(pr);
}
break;
}
case 3:
{
auto pr = m_results[index.column()].pr();
if (pr <= 16)
{
return static_cast<uint>(pr);
}
break;
}
default:
break;
};
return "-";
}
return "-";
}
return {};
return {};
}
QVariant ResultModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role != Qt::DisplayRole)
{
return {};
}
if (role != Qt::DisplayRole)
{
return {};
}
switch (orientation)
{
case Qt::Horizontal:
if (m_results.size() > section)
{
return m_results[section].name();
}
case Qt::Vertical:
switch (section)
{
case 0:
return "RP";
case 1:
return ">= PR 84";
case 2:
return "< PR 84";
case 3:
return "<= PR 16";
default:
return {};
}
default:
return {};
}
switch (orientation)
{
case Qt::Horizontal:
if (m_results.size() > section)
{
return m_results[section].name();
}
case Qt::Vertical:
switch (section)
{
case 0:
return "RP";
case 1:
return ">= PR 84";
case 2:
return "< PR 84";
case 3:
return "<= PR 16";
default:
return {};
}
default:
return {};
}
}
void ResultModel::setAge(const Age &age)
void ResultModel::setAge(const Age& age)
{
m_age = age;
emit dataChanged(index(1, 0), index(4, 8));
m_age = age;
emit dataChanged(index(1, 0), index(4, 8));
}
void ResultModel::setPluralResult(unsigned int points)
{
if (m_results[6].points() != points)
{
m_results[6].setPoints(points);
m_results[6].setPR(PluralPR().lookup(m_age, points));
emit dataChanged(index(0, 6), index(4, 6));
}
if (m_results[6].points() != points)
{
m_results[6].setPoints(points);
m_results[6].setPR(PluralPR().lookup(m_age, points));
emit dataChanged(index(0, 6), index(4, 6));
}
}
void ResultModel::setGenusResult(unsigned int points)
{
if (m_results[3].points() != points)
{
m_results[3].setPoints(points);
m_results[3].setPR(GenusPR().lookup(m_age, points));
emit dataChanged(index(0, 3), index(4, 3));
}
if (m_results[3].points() != points)
{
m_results[3].setPoints(points);
m_results[3].setPR(GenusPR().lookup(m_age, points));
emit dataChanged(index(0, 3), index(4, 3));
}
}
void ResultModel::setVerbEndResult(unsigned int points)
{
if (m_results[2].points() != points)
{
m_results[2].setPoints(points);
m_results[2].setPR(VerbEndPR().lookup(m_age, points));
emit dataChanged(index(0, 2), index(4, 2));
}
if (m_results[2].points() != points)
{
m_results[2].setPoints(points);
m_results[2].setPR(VerbEndPR().lookup(m_age, points));
emit dataChanged(index(0, 2), index(4, 2));
}
}
void ResultModel::setAkkusativResult(unsigned int points)
{
if (m_results[4].points() != points)
{
m_results[4].setPoints(points);
m_results[4].setPR(AkkusativPR().lookup(m_age, points));
emit dataChanged(index(0, 4), index(4, 4));
}
if (m_results[4].points() != points)
{
m_results[4].setPoints(points);
m_results[4].setPR(AkkusativPR().lookup(m_age, points));
emit dataChanged(index(0, 4), index(4, 4));
}
}
void ResultModel::setDativResult(unsigned int points)
{
if (m_results[5].points() != points)
{
m_results[5].setPoints(points);
m_results[5].setPR(DativPR().lookup(m_age, points));
emit dataChanged(index(0, 5), index(4, 5));
}
if (m_results[5].points() != points)
{
m_results[5].setPoints(points);
m_results[5].setPR(DativPR().lookup(m_age, points));
emit dataChanged(index(0, 5), index(4, 5));
}
}
void ResultModel::setV2Result(unsigned int points)
{
if (m_results[0].points() != points)
{
m_results[0].setPoints(points);
m_results[0].setPR(V2PR().lookup(m_age, points));
emit dataChanged(index(0, 0), index(4, 0));
}
if (m_results[0].points() != points)
{
m_results[0].setPoints(points);
m_results[0].setPR(V2PR().lookup(m_age, points));
emit dataChanged(index(0, 0), index(4, 0));
}
}
void ResultModel::setSvkResult(unsigned int points)
{
if (m_results[1].points() != points)
{
m_results[1].setPoints(points);
m_results[1].setPR(SvkPR().lookup(m_age, points));
emit dataChanged(index(0, 1), index(4, 1));
}
if (m_results[1].points() != points)
{
m_results[1].setPoints(points);
m_results[1].setPR(SvkPR().lookup(m_age, points));
emit dataChanged(index(0, 1), index(4, 1));
}
}
void ResultModel::setPassivResult(unsigned int points)
{
if (m_results[7].points() != points)
{
m_results[7].setPoints(points);
m_results[7].setPR(PassivPR().lookup(m_age, points));
emit dataChanged(index(0, 7), index(4, 7));
}
if (m_results[7].points() != points)
{
m_results[7].setPoints(points);
m_results[7].setPR(PassivPR().lookup(m_age, points));
emit dataChanged(index(0, 7), index(4, 7));
}
}
void ResultModel::setGenitivResult(unsigned int points)
{
if (m_results[8].points() != points)
{
m_results[8].setPoints(points);
m_results[8].setPR(GenitivPR().lookup(m_age, points));
emit dataChanged(index(0, 8), index(4, 8));
}
if (m_results[8].points() != points)
{
m_results[8].setPoints(points);
m_results[8].setPR(GenitivPR().lookup(m_age, points));
emit dataChanged(index(0, 8), index(4, 8));
}
}
void ResultModel::printTo(QPainter &painter) const
void ResultModel::printTo(QPainter& painter) const
{
PrintableModel::drawHeader2(painter, "Prozentränge (PR)");
PrintableModel::drawHeader2(painter, "Prozentränge (PR)");
painter.setFont(PrintableModel::tableFont());
painter.setPen(PrintableModel::tablePen());
painter.setFont(PrintableModel::tableFont());
painter.setPen(PrintableModel::tablePen());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
double cellWidth = width / (m_results.size() + 1);
double rowHeight = 2 * height;
double cellWidth = width / (m_results.size() + 1);
double rowHeight = 2 * height;
double x = 0;
double y = 0;
double x = 0;
double y = 0;
PrintableModel::drawTextSquare(painter, {x, y + 0 * rowHeight, cellWidth, rowHeight}, "");
PrintableModel::drawTextSquare(painter, {x, y + 1 * rowHeight, cellWidth, rowHeight},
PrintableModel::drawTextSquare(painter, {x, y + 0 * rowHeight, cellWidth, rowHeight}, "");
PrintableModel::drawTextSquare(painter, {x, y + 1 * rowHeight, cellWidth, rowHeight},
u8"\u2265 PR 84");
PrintableModel::drawTextSquare(painter, {x, y + 2 * rowHeight, cellWidth, rowHeight},
"< PR 84");
PrintableModel::drawTextSquare(painter, {x, y + 2 * rowHeight, cellWidth, rowHeight},
"< PR 84");
PrintableModel::drawGreySquare(painter, {x, y + 3 * rowHeight, cellWidth, rowHeight});
PrintableModel::drawTextSquare(painter, {x, y + 3 * rowHeight, cellWidth, rowHeight},
PrintableModel::drawGreySquare(painter, {x, y + 3 * rowHeight, cellWidth, rowHeight});
PrintableModel::drawTextSquare(painter, {x, y + 3 * rowHeight, cellWidth, rowHeight},
u8"\u2264 PR 16");
x += cellWidth;
for (const auto &result : m_results)
{
PrintableModel::drawTextSquare(painter, {x, y + 0 * rowHeight, cellWidth, rowHeight},
result.name());
const auto pr = result.pr();
x += cellWidth;
for (const auto& result : m_results)
{
PrintableModel::drawTextSquare(painter, {x, y + 0 * rowHeight, cellWidth, rowHeight},
result.name());
const auto pr = result.pr();
PrintableModel::drawTextSquare(painter, {x, y + 1 * rowHeight, cellWidth, rowHeight},
pr >= 84 ? QString::number(pr) : "-");
PrintableModel::drawTextSquare(painter, {x, y + 2 * rowHeight, cellWidth, rowHeight},
pr < 84 && pr > 16 ? QString::number(pr) : "-");
PrintableModel::drawTextSquare(painter, {x, y + 1 * rowHeight, cellWidth, rowHeight},
pr >= 84 ? QString::number(pr) : "-");
PrintableModel::drawTextSquare(painter, {x, y + 2 * rowHeight, cellWidth, rowHeight},
pr < 84 && pr > 16 ? QString::number(pr) : "-");
PrintableModel::drawGreySquare(painter, {x, y + 3 * rowHeight, cellWidth, rowHeight});
PrintableModel::drawTextSquare(painter, {x, y + 3 * rowHeight, cellWidth, rowHeight},
pr <= 16 ? QString::number(pr) : "-");
PrintableModel::drawGreySquare(painter, {x, y + 3 * rowHeight, cellWidth, rowHeight});
PrintableModel::drawTextSquare(painter, {x, y + 3 * rowHeight, cellWidth, rowHeight},
pr <= 16 ? QString::number(pr) : "-");
x += cellWidth;
}
x += cellWidth;
}
}

View file

@ -8,72 +8,71 @@
class TestResult
{
private:
QString m_name;
size_t m_points = 0;
size_t m_pr = 0;
QString m_name;
size_t m_points = 0;
size_t m_pr = 0;
public:
TestResult(const char *name)
: m_name(name)
{
}
TestResult(const char* name)
: m_name(name)
{
}
void setPoints(const size_t &points)
{
m_points = points;
}
void setPoints(const size_t& points)
{
m_points = points;
}
void setPR(const unsigned int &pr)
{
m_pr = pr;
}
void setPR(const unsigned int& pr)
{
m_pr = pr;
}
const QString &name() const
{
return m_name;
}
const QString& name() const
{
return m_name;
}
const size_t points() const
{
return m_points;
}
const size_t pr() const
{
return m_pr;
}
const size_t points() const
{
return m_points;
}
const size_t pr() const
{
return m_pr;
}
};
class ResultModel : public QAbstractTableModel
{
Q_OBJECT
Q_OBJECT
private:
Age m_age;
std::vector<TestResult> m_results;
Age m_age;
std::vector<TestResult> m_results;
public:
ResultModel(QObject *parent);
ResultModel(QObject* parent);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(
const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
void setAge(const Age &age);
void setPluralResult(unsigned int points);
void setGenusResult(unsigned int points);
void setVerbEndResult(unsigned int points);
void setAkkusativResult(unsigned int points);
void setDativResult(unsigned int points);
void setV2Result(unsigned int points);
void setSvkResult(unsigned int points);
void setAge(const Age& age);
void setPluralResult(unsigned int points);
void setGenusResult(unsigned int points);
void setVerbEndResult(unsigned int points);
void setAkkusativResult(unsigned int points);
void setDativResult(unsigned int points);
void setV2Result(unsigned int points);
void setSvkResult(unsigned int points);
void setPassivResult(unsigned int points);
void setGenitivResult(unsigned int points);
void printTo(QPainter &painter) const;
void printTo(QPainter& painter) const;
};

View file

@ -3,19 +3,19 @@
#include "ResultModel.h"
ResultWidget::ResultWidget(QWidget *parent)
: QWidget(parent)
ResultWidget::ResultWidget(QWidget* parent)
: QWidget(parent)
, ui(new Ui::ResultWidget)
{
ui->setupUi(this);
ui->setupUi(this);
}
ResultWidget::~ResultWidget()
{
delete ui;
delete ui;
}
void ResultWidget::setModel(ResultModel *model)
void ResultWidget::setModel(ResultModel* model)
{
ui->resultTableView->setModel(model);
ui->resultTableView->setModel(model);
}

View file

@ -10,14 +10,14 @@ class ResultWidget;
class ResultWidget : public QWidget
{
Q_OBJECT
Q_OBJECT
private:
Ui::ResultWidget *ui;
Ui::ResultWidget* ui;
public:
ResultWidget(QWidget *parent = nullptr);
~ResultWidget();
ResultWidget(QWidget* parent = nullptr);
~ResultWidget();
void setModel(ResultModel *model);
void setModel(ResultModel* model);
};

View file

@ -5,9 +5,9 @@
class SvkPR : public PRMap
{
public:
SvkPR()
{
// clang-format off
SvkPR()
{
// clang-format off
m_ages = {
{ 4, 0 },
{ 5, 0 },
@ -60,6 +60,6 @@ public:
{ 71, 50, 36 },
{ 100, 100, 100 }
};
// clang-format on
}
// clang-format on
}
};

View file

@ -5,9 +5,9 @@
class V2PR : public PRMap
{
public:
V2PR()
{
// clang-format off
V2PR()
{
// clang-format off
m_ages = {
{ 4, 0 },
{ 5, 0 },
@ -63,6 +63,6 @@ public:
{ 69, 52, 37 },
{ 100, 100, 100 }
};
// clang-format on
}
// clang-format on
}
};

View file

@ -5,9 +5,9 @@
class VerbEndPR : public PRMap
{
public:
VerbEndPR()
{
// clang-format off
VerbEndPR()
{
// clang-format off
m_ages = {
{ 4, 0 },
{ 4, 6 },
@ -39,7 +39,6 @@ public:
{ 85, 79, 74, 65 },
{ 100, 100, 100, 100, 100 },
};
// clang-format on
}
// clang-format on
}
};

View file

@ -4,26 +4,26 @@
#include "AkkusativModel.h"
#include "DativModel.h"
AkkusativDativWidget::AkkusativDativWidget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::AkkusativDativWidget)
AkkusativDativWidget::AkkusativDativWidget(QWidget* parent)
: QWidget(parent)
, ui(new Ui::AkkusativDativWidget)
{
ui->setupUi(this);
ui->setupUi(this);
ui->akkusativTableView->horizontalHeader()->hide();
ui->dativTableView->horizontalHeader()->hide();
}
AkkusativDativWidget::~AkkusativDativWidget()
{
delete ui;
delete ui;
}
void AkkusativDativWidget::setAkkusativModel(AkkusativModel *model)
void AkkusativDativWidget::setAkkusativModel(AkkusativModel* model)
{
ui->akkusativTableView->setModel(model);
ui->akkusativTableView->setModel(model);
}
void AkkusativDativWidget::setDativModel(DativModel *model)
void AkkusativDativWidget::setDativModel(DativModel* model)
{
ui->dativTableView->setModel(model);
ui->dativTableView->setModel(model);
}

View file

@ -11,15 +11,15 @@ class AkkusativDativWidget;
class AkkusativDativWidget : public QWidget
{
Q_OBJECT
Q_OBJECT
private:
Ui::AkkusativDativWidget *ui;
Ui::AkkusativDativWidget* ui;
public:
AkkusativDativWidget(QWidget *parent = nullptr);
~AkkusativDativWidget();
AkkusativDativWidget(QWidget* parent = nullptr);
~AkkusativDativWidget();
void setAkkusativModel(AkkusativModel *model);
void setDativModel(DativModel *model);
void setAkkusativModel(AkkusativModel* model);
void setDativModel(DativModel* model);
};

View file

@ -1,112 +1,112 @@
#include "AkkusativModel.h"
AkkusativModel::AkkusativModel(QObject *parent)
AkkusativModel::AkkusativModel(QObject* parent)
: PrintableModel(parent)
{
m_tests = {{"Akkusativ Nominalphrase",
{"Tiger", "Katze", "Affe", "Gans", "Bär", "Pferd", "Hund", "Elefant"}},
{"Präpositionalphrase (Verstecke)",
{"Vorhang", "Kiste", "Holz", "Kiste", "Baum", "Vorhang", "Holz", "Baum"}},
{"Nominalphrase (Futter)",
{"Salat", "Fleisch", "Knochen", "Banane", "Apfel", "Karotte", "Honig", "Zucker"}}};
m_tests = {{"Akkusativ Nominalphrase",
{"Tiger", "Katze", "Affe", "Gans", "Bär", "Pferd", "Hund", "Elefant"}},
{"Präpositionalphrase (Verstecke)",
{"Vorhang", "Kiste", "Holz", "Kiste", "Baum", "Vorhang", "Holz", "Baum"}},
{"Nominalphrase (Futter)",
{"Salat", "Fleisch", "Knochen", "Banane", "Apfel", "Karotte", "Honig", "Zucker"}}};
}
void AkkusativModel::read(const ESGRAF48::AkkusativModel &model)
void AkkusativModel::read(const ESGRAF48::AkkusativModel& model)
{
const auto &tiereModel = model.tiere();
{
auto &testItems = m_tests.at(0).items();
const auto& tiereModel = model.tiere();
{
auto& testItems = m_tests.at(0).items();
testItems[0].setState(tiereModel.tiger());
testItems[1].setState(tiereModel.katze());
testItems[2].setState(tiereModel.affe());
testItems[3].setState(tiereModel.gans());
testItems[4].setState(tiereModel.baer());
testItems[5].setState(tiereModel.pferd());
testItems[6].setState(tiereModel.hund());
testItems[7].setState(tiereModel.elefant());
}
testItems[0].setState(tiereModel.tiger());
testItems[1].setState(tiereModel.katze());
testItems[2].setState(tiereModel.affe());
testItems[3].setState(tiereModel.gans());
testItems[4].setState(tiereModel.baer());
testItems[5].setState(tiereModel.pferd());
testItems[6].setState(tiereModel.hund());
testItems[7].setState(tiereModel.elefant());
}
const auto &versteckeModel = model.verstecke();
{
auto &testItems = m_tests.at(1).items();
const auto& versteckeModel = model.verstecke();
{
auto& testItems = m_tests.at(1).items();
testItems[0].setState(versteckeModel.vorhang1());
testItems[1].setState(versteckeModel.kiste1());
testItems[2].setState(versteckeModel.holz1());
testItems[3].setState(versteckeModel.kiste2());
testItems[4].setState(versteckeModel.baum1());
testItems[5].setState(versteckeModel.vorhang2());
testItems[6].setState(versteckeModel.holz2());
testItems[7].setState(versteckeModel.baum2());
}
testItems[0].setState(versteckeModel.vorhang1());
testItems[1].setState(versteckeModel.kiste1());
testItems[2].setState(versteckeModel.holz1());
testItems[3].setState(versteckeModel.kiste2());
testItems[4].setState(versteckeModel.baum1());
testItems[5].setState(versteckeModel.vorhang2());
testItems[6].setState(versteckeModel.holz2());
testItems[7].setState(versteckeModel.baum2());
}
const auto &futterModel = model.futter();
{
auto &testItems = m_tests.at(2).items();
const auto& futterModel = model.futter();
{
auto& testItems = m_tests.at(2).items();
testItems[0].setState(futterModel.salat());
testItems[1].setState(futterModel.fleisch());
testItems[2].setState(futterModel.knochen());
testItems[3].setState(futterModel.banane());
testItems[4].setState(futterModel.apfel());
testItems[5].setState(futterModel.karotte());
testItems[6].setState(futterModel.honig());
testItems[7].setState(futterModel.zucker());
}
testItems[0].setState(futterModel.salat());
testItems[1].setState(futterModel.fleisch());
testItems[2].setState(futterModel.knochen());
testItems[3].setState(futterModel.banane());
testItems[4].setState(futterModel.apfel());
testItems[5].setState(futterModel.karotte());
testItems[6].setState(futterModel.honig());
testItems[7].setState(futterModel.zucker());
}
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
void AkkusativModel::write(ESGRAF48::AkkusativModel &model) const
void AkkusativModel::write(ESGRAF48::AkkusativModel& model) const
{
auto *tiereModel = model.mutable_tiere();
if (tiereModel != nullptr)
{
const auto &testItems = m_tests.at(0).items();
auto* tiereModel = model.mutable_tiere();
if (tiereModel != nullptr)
{
const auto& testItems = m_tests.at(0).items();
tiereModel->set_tiger(testItems[0].isChecked());
tiereModel->set_katze(testItems[1].isChecked());
tiereModel->set_affe(testItems[2].isChecked());
tiereModel->set_gans(testItems[3].isChecked());
tiereModel->set_baer(testItems[4].isChecked());
tiereModel->set_pferd(testItems[5].isChecked());
tiereModel->set_hund(testItems[6].isChecked());
tiereModel->set_elefant(testItems[7].isChecked());
}
tiereModel->set_tiger(testItems[0].isChecked());
tiereModel->set_katze(testItems[1].isChecked());
tiereModel->set_affe(testItems[2].isChecked());
tiereModel->set_gans(testItems[3].isChecked());
tiereModel->set_baer(testItems[4].isChecked());
tiereModel->set_pferd(testItems[5].isChecked());
tiereModel->set_hund(testItems[6].isChecked());
tiereModel->set_elefant(testItems[7].isChecked());
}
auto *versteckeModel = model.mutable_verstecke();
if (versteckeModel != nullptr)
{
const auto &testItems = m_tests.at(1).items();
auto* versteckeModel = model.mutable_verstecke();
if (versteckeModel != nullptr)
{
const auto& testItems = m_tests.at(1).items();
versteckeModel->set_vorhang1(testItems[0].isChecked());
versteckeModel->set_kiste1(testItems[1].isChecked());
versteckeModel->set_holz1(testItems[2].isChecked());
versteckeModel->set_kiste2(testItems[3].isChecked());
versteckeModel->set_baum1(testItems[4].isChecked());
versteckeModel->set_vorhang2(testItems[5].isChecked());
versteckeModel->set_holz2(testItems[6].isChecked());
versteckeModel->set_baum2(testItems[7].isChecked());
}
versteckeModel->set_vorhang1(testItems[0].isChecked());
versteckeModel->set_kiste1(testItems[1].isChecked());
versteckeModel->set_holz1(testItems[2].isChecked());
versteckeModel->set_kiste2(testItems[3].isChecked());
versteckeModel->set_baum1(testItems[4].isChecked());
versteckeModel->set_vorhang2(testItems[5].isChecked());
versteckeModel->set_holz2(testItems[6].isChecked());
versteckeModel->set_baum2(testItems[7].isChecked());
}
auto *futterModel = model.mutable_futter();
if (futterModel != nullptr)
{
const auto &testItems = m_tests.at(2).items();
auto* futterModel = model.mutable_futter();
if (futterModel != nullptr)
{
const auto& testItems = m_tests.at(2).items();
futterModel->set_salat(testItems[0].isChecked());
futterModel->set_fleisch(testItems[1].isChecked());
futterModel->set_knochen(testItems[2].isChecked());
futterModel->set_banane(testItems[3].isChecked());
futterModel->set_apfel(testItems[4].isChecked());
futterModel->set_karotte(testItems[5].isChecked());
futterModel->set_honig(testItems[6].isChecked());
futterModel->set_zucker(testItems[7].isChecked());
}
futterModel->set_salat(testItems[0].isChecked());
futterModel->set_fleisch(testItems[1].isChecked());
futterModel->set_knochen(testItems[2].isChecked());
futterModel->set_banane(testItems[3].isChecked());
futterModel->set_apfel(testItems[4].isChecked());
futterModel->set_karotte(testItems[5].isChecked());
futterModel->set_honig(testItems[6].isChecked());
futterModel->set_zucker(testItems[7].isChecked());
}
}
void AkkusativModel::printHeader(QPainter &painter) const
void AkkusativModel::printHeader(QPainter& painter) const
{
drawHeader2(painter, "Subtest 4: Akkusativ und Dativ");
drawHeader2(painter, "Subtest 4: Akkusativ und Dativ");
}

View file

@ -5,14 +5,14 @@
class AkkusativModel : public PrintableModel
{
Q_OBJECT
Q_OBJECT
public:
AkkusativModel(QObject *parent);
AkkusativModel(QObject* parent);
void read(const ESGRAF48::AkkusativModel &model);
void write(ESGRAF48::AkkusativModel &model) const;
void read(const ESGRAF48::AkkusativModel& model);
void write(ESGRAF48::AkkusativModel& model) const;
protected:
void printHeader(QPainter &painter) const override;
void printHeader(QPainter& painter) const override;
};

View file

@ -1,112 +1,112 @@
#include "DativModel.h"
DativModel::DativModel(QObject *parent)
DativModel::DativModel(QObject* parent)
: PrintableModel(parent)
{
m_tests = {{"Dativ Nominalphrase",
{"Affe", "Gans", "Tiger", "Hund", "Elefant", "Pferd", "Bär", "Katze"}},
{"Präpositionalphrase (Verstecke)",
{"Vorhang", "Kiste", "Holz", "Kiste", "Baum", "Vorhang", "Holz", "Baum"}},
{"Nominalphrase (Tiere)",
{"Gans", "Tiger", "Hund", "Affe", "Elefant", "Pferd", "Bär", "Katze"}}};
m_tests = {{"Dativ Nominalphrase",
{"Affe", "Gans", "Tiger", "Hund", "Elefant", "Pferd", "Bär", "Katze"}},
{"Präpositionalphrase (Verstecke)",
{"Vorhang", "Kiste", "Holz", "Kiste", "Baum", "Vorhang", "Holz", "Baum"}},
{"Nominalphrase (Tiere)",
{"Gans", "Tiger", "Hund", "Affe", "Elefant", "Pferd", "Bär", "Katze"}}};
}
void DativModel::read(const ESGRAF48::DativModel &model)
void DativModel::read(const ESGRAF48::DativModel& model)
{
const auto &tiereModel = model.tiere();
{
auto &testItems = m_tests.at(0).items();
const auto& tiereModel = model.tiere();
{
auto& testItems = m_tests.at(0).items();
testItems[0].setState(tiereModel.affe());
testItems[1].setState(tiereModel.gans());
testItems[2].setState(tiereModel.tiger());
testItems[3].setState(tiereModel.hund());
testItems[4].setState(tiereModel.elefant());
testItems[5].setState(tiereModel.pferd());
testItems[6].setState(tiereModel.baer());
testItems[7].setState(tiereModel.katze());
}
testItems[0].setState(tiereModel.affe());
testItems[1].setState(tiereModel.gans());
testItems[2].setState(tiereModel.tiger());
testItems[3].setState(tiereModel.hund());
testItems[4].setState(tiereModel.elefant());
testItems[5].setState(tiereModel.pferd());
testItems[6].setState(tiereModel.baer());
testItems[7].setState(tiereModel.katze());
}
const auto &versteckeModel = model.verstecke();
{
auto &testItems = m_tests.at(1).items();
const auto& versteckeModel = model.verstecke();
{
auto& testItems = m_tests.at(1).items();
testItems[0].setState(versteckeModel.vorhang1());
testItems[1].setState(versteckeModel.kiste1());
testItems[2].setState(versteckeModel.holz1());
testItems[3].setState(versteckeModel.kiste2());
testItems[4].setState(versteckeModel.baum1());
testItems[5].setState(versteckeModel.vorhang2());
testItems[6].setState(versteckeModel.holz2());
testItems[7].setState(versteckeModel.baum2());
}
testItems[0].setState(versteckeModel.vorhang1());
testItems[1].setState(versteckeModel.kiste1());
testItems[2].setState(versteckeModel.holz1());
testItems[3].setState(versteckeModel.kiste2());
testItems[4].setState(versteckeModel.baum1());
testItems[5].setState(versteckeModel.vorhang2());
testItems[6].setState(versteckeModel.holz2());
testItems[7].setState(versteckeModel.baum2());
}
const auto &nomTiereModel = model.nomtiere();
{
auto &testItems = m_tests.at(2).items();
const auto& nomTiereModel = model.nomtiere();
{
auto& testItems = m_tests.at(2).items();
testItems[0].setState(nomTiereModel.gans());
testItems[1].setState(nomTiereModel.tiger());
testItems[2].setState(nomTiereModel.hund());
testItems[3].setState(nomTiereModel.affe());
testItems[4].setState(nomTiereModel.elefant());
testItems[5].setState(nomTiereModel.pferd());
testItems[6].setState(nomTiereModel.baer());
testItems[7].setState(nomTiereModel.katze());
}
testItems[0].setState(nomTiereModel.gans());
testItems[1].setState(nomTiereModel.tiger());
testItems[2].setState(nomTiereModel.hund());
testItems[3].setState(nomTiereModel.affe());
testItems[4].setState(nomTiereModel.elefant());
testItems[5].setState(nomTiereModel.pferd());
testItems[6].setState(nomTiereModel.baer());
testItems[7].setState(nomTiereModel.katze());
}
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
void DativModel::write(ESGRAF48::DativModel &model) const
void DativModel::write(ESGRAF48::DativModel& model) const
{
auto *tiereModel = model.mutable_tiere();
if (tiereModel != nullptr)
{
const auto &testItems = m_tests.at(0).items();
auto* tiereModel = model.mutable_tiere();
if (tiereModel != nullptr)
{
const auto& testItems = m_tests.at(0).items();
tiereModel->set_affe(testItems[0].isChecked());
tiereModel->set_gans(testItems[1].isChecked());
tiereModel->set_tiger(testItems[2].isChecked());
tiereModel->set_hund(testItems[3].isChecked());
tiereModel->set_elefant(testItems[4].isChecked());
tiereModel->set_pferd(testItems[5].isChecked());
tiereModel->set_baer(testItems[6].isChecked());
tiereModel->set_katze(testItems[7].isChecked());
}
tiereModel->set_affe(testItems[0].isChecked());
tiereModel->set_gans(testItems[1].isChecked());
tiereModel->set_tiger(testItems[2].isChecked());
tiereModel->set_hund(testItems[3].isChecked());
tiereModel->set_elefant(testItems[4].isChecked());
tiereModel->set_pferd(testItems[5].isChecked());
tiereModel->set_baer(testItems[6].isChecked());
tiereModel->set_katze(testItems[7].isChecked());
}
auto *versteckeModel = model.mutable_verstecke();
if (versteckeModel != nullptr)
{
const auto &testItems = m_tests.at(1).items();
auto* versteckeModel = model.mutable_verstecke();
if (versteckeModel != nullptr)
{
const auto& testItems = m_tests.at(1).items();
versteckeModel->set_vorhang1(testItems[0].isChecked());
versteckeModel->set_kiste1(testItems[1].isChecked());
versteckeModel->set_holz1(testItems[2].isChecked());
versteckeModel->set_kiste2(testItems[3].isChecked());
versteckeModel->set_baum1(testItems[4].isChecked());
versteckeModel->set_vorhang2(testItems[5].isChecked());
versteckeModel->set_holz2(testItems[6].isChecked());
versteckeModel->set_baum2(testItems[7].isChecked());
}
versteckeModel->set_vorhang1(testItems[0].isChecked());
versteckeModel->set_kiste1(testItems[1].isChecked());
versteckeModel->set_holz1(testItems[2].isChecked());
versteckeModel->set_kiste2(testItems[3].isChecked());
versteckeModel->set_baum1(testItems[4].isChecked());
versteckeModel->set_vorhang2(testItems[5].isChecked());
versteckeModel->set_holz2(testItems[6].isChecked());
versteckeModel->set_baum2(testItems[7].isChecked());
}
auto *nomTiereModel = model.mutable_nomtiere();
if (nomTiereModel != nullptr)
{
const auto &testItems = m_tests.at(2).items();
auto* nomTiereModel = model.mutable_nomtiere();
if (nomTiereModel != nullptr)
{
const auto& testItems = m_tests.at(2).items();
nomTiereModel->set_gans(testItems[0].isChecked());
nomTiereModel->set_tiger(testItems[1].isChecked());
nomTiereModel->set_hund(testItems[2].isChecked());
nomTiereModel->set_affe(testItems[3].isChecked());
nomTiereModel->set_elefant(testItems[4].isChecked());
nomTiereModel->set_pferd(testItems[5].isChecked());
nomTiereModel->set_baer(testItems[6].isChecked());
nomTiereModel->set_katze(testItems[7].isChecked());
}
nomTiereModel->set_gans(testItems[0].isChecked());
nomTiereModel->set_tiger(testItems[1].isChecked());
nomTiereModel->set_hund(testItems[2].isChecked());
nomTiereModel->set_affe(testItems[3].isChecked());
nomTiereModel->set_elefant(testItems[4].isChecked());
nomTiereModel->set_pferd(testItems[5].isChecked());
nomTiereModel->set_baer(testItems[6].isChecked());
nomTiereModel->set_katze(testItems[7].isChecked());
}
}
void DativModel::printHeader(QPainter &painter) const
void DativModel::printHeader(QPainter& painter) const
{
painter.translate(0, -1.5 * painter.fontMetrics().lineSpacing());
painter.translate(0, -1.5 * painter.fontMetrics().lineSpacing());
}

View file

@ -5,14 +5,14 @@
class DativModel : public PrintableModel
{
Q_OBJECT
Q_OBJECT
public:
DativModel(QObject *parent);
DativModel(QObject* parent);
void read(const ESGRAF48::DativModel &model);
void write(ESGRAF48::DativModel &model) const;
void read(const ESGRAF48::DativModel& model);
void write(ESGRAF48::DativModel& model) const;
protected:
void printHeader(QPainter &painter) const override;
void printHeader(QPainter& painter) const override;
};

View file

@ -1,99 +1,99 @@
#include "GenusModel.h"
GenusModel::GenusModel(QObject *parent)
GenusModel::GenusModel(QObject* parent)
: PrintableModel(parent)
{
m_title = "Subtest 3: Genus";
m_title = "Subtest 3: Genus";
m_tests = {{"Tiere", {"Tiger", "Bär", "Katze", "Pferd", "Gans", "Elefant", "Affe", "Hund"}},
{"Futter",
{"Salat", "Fleisch", "Knochen", "Banane", "Apfel", "Karotte", "Honig", "Zucker"}},
{"Zirkus", {"Kiste", "Holz", "Vorhang", "Baum"}}};
m_tests = {{"Tiere", {"Tiger", "Bär", "Katze", "Pferd", "Gans", "Elefant", "Affe", "Hund"}},
{"Futter",
{"Salat", "Fleisch", "Knochen", "Banane", "Apfel", "Karotte", "Honig", "Zucker"}},
{"Zirkus", {"Kiste", "Holz", "Vorhang", "Baum"}}};
}
void GenusModel::read(const ESGRAF48::GenusModel &model)
void GenusModel::read(const ESGRAF48::GenusModel& model)
{
const auto &tiereModel = model.tiere();
{
auto &testItems = m_tests.at(0).items();
const auto& tiereModel = model.tiere();
{
auto& testItems = m_tests.at(0).items();
testItems[0].setState(tiereModel.tiger());
testItems[1].setState(tiereModel.baer());
testItems[2].setState(tiereModel.katze());
testItems[3].setState(tiereModel.pferd());
testItems[4].setState(tiereModel.gans());
testItems[5].setState(tiereModel.elefant());
testItems[6].setState(tiereModel.affe());
testItems[7].setState(tiereModel.hund());
}
testItems[0].setState(tiereModel.tiger());
testItems[1].setState(tiereModel.baer());
testItems[2].setState(tiereModel.katze());
testItems[3].setState(tiereModel.pferd());
testItems[4].setState(tiereModel.gans());
testItems[5].setState(tiereModel.elefant());
testItems[6].setState(tiereModel.affe());
testItems[7].setState(tiereModel.hund());
}
const auto &futterModel = model.futter();
{
auto &testItems = m_tests.at(1).items();
const auto& futterModel = model.futter();
{
auto& testItems = m_tests.at(1).items();
testItems[0].setState(futterModel.salat());
testItems[1].setState(futterModel.fleisch());
testItems[2].setState(futterModel.knochen());
testItems[3].setState(futterModel.banane());
testItems[4].setState(futterModel.apfel());
testItems[5].setState(futterModel.karotte());
testItems[6].setState(futterModel.honig());
testItems[7].setState(futterModel.zucker());
}
testItems[0].setState(futterModel.salat());
testItems[1].setState(futterModel.fleisch());
testItems[2].setState(futterModel.knochen());
testItems[3].setState(futterModel.banane());
testItems[4].setState(futterModel.apfel());
testItems[5].setState(futterModel.karotte());
testItems[6].setState(futterModel.honig());
testItems[7].setState(futterModel.zucker());
}
const auto &zirkusModel = model.zirkus();
{
auto &testItems = m_tests.at(2).items();
const auto& zirkusModel = model.zirkus();
{
auto& testItems = m_tests.at(2).items();
testItems[0].setState(zirkusModel.kiste());
testItems[1].setState(zirkusModel.holz());
testItems[2].setState(zirkusModel.vorhang());
testItems[3].setState(zirkusModel.baum());
}
testItems[0].setState(zirkusModel.kiste());
testItems[1].setState(zirkusModel.holz());
testItems[2].setState(zirkusModel.vorhang());
testItems[3].setState(zirkusModel.baum());
}
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
void GenusModel::write(ESGRAF48::GenusModel &model) const
void GenusModel::write(ESGRAF48::GenusModel& model) const
{
auto *tiereModel = model.mutable_tiere();
if (tiereModel != nullptr)
{
const auto &testItems = m_tests.at(0).items();
auto* tiereModel = model.mutable_tiere();
if (tiereModel != nullptr)
{
const auto& testItems = m_tests.at(0).items();
tiereModel->set_tiger(testItems[0].isChecked());
tiereModel->set_baer(testItems[1].isChecked());
tiereModel->set_katze(testItems[2].isChecked());
tiereModel->set_pferd(testItems[3].isChecked());
tiereModel->set_gans(testItems[4].isChecked());
tiereModel->set_elefant(testItems[5].isChecked());
tiereModel->set_affe(testItems[6].isChecked());
tiereModel->set_hund(testItems[7].isChecked());
}
tiereModel->set_tiger(testItems[0].isChecked());
tiereModel->set_baer(testItems[1].isChecked());
tiereModel->set_katze(testItems[2].isChecked());
tiereModel->set_pferd(testItems[3].isChecked());
tiereModel->set_gans(testItems[4].isChecked());
tiereModel->set_elefant(testItems[5].isChecked());
tiereModel->set_affe(testItems[6].isChecked());
tiereModel->set_hund(testItems[7].isChecked());
}
auto *futterModel = model.mutable_futter();
if (futterModel != nullptr)
{
const auto &testItems = m_tests.at(1).items();
auto* futterModel = model.mutable_futter();
if (futterModel != nullptr)
{
const auto& testItems = m_tests.at(1).items();
futterModel->set_salat(testItems[0].isChecked());
futterModel->set_fleisch(testItems[1].isChecked());
futterModel->set_knochen(testItems[2].isChecked());
futterModel->set_banane(testItems[3].isChecked());
futterModel->set_apfel(testItems[4].isChecked());
futterModel->set_karotte(testItems[5].isChecked());
futterModel->set_honig(testItems[6].isChecked());
futterModel->set_zucker(testItems[7].isChecked());
}
futterModel->set_salat(testItems[0].isChecked());
futterModel->set_fleisch(testItems[1].isChecked());
futterModel->set_knochen(testItems[2].isChecked());
futterModel->set_banane(testItems[3].isChecked());
futterModel->set_apfel(testItems[4].isChecked());
futterModel->set_karotte(testItems[5].isChecked());
futterModel->set_honig(testItems[6].isChecked());
futterModel->set_zucker(testItems[7].isChecked());
}
auto *zirkusModel = model.mutable_zirkus();
if (zirkusModel != nullptr)
{
const auto &testItems = m_tests.at(2).items();
auto* zirkusModel = model.mutable_zirkus();
if (zirkusModel != nullptr)
{
const auto& testItems = m_tests.at(2).items();
zirkusModel->set_kiste(testItems[0].isChecked());
zirkusModel->set_holz(testItems[1].isChecked());
zirkusModel->set_vorhang(testItems[2].isChecked());
zirkusModel->set_baum(testItems[3].isChecked());
}
zirkusModel->set_kiste(testItems[0].isChecked());
zirkusModel->set_holz(testItems[1].isChecked());
zirkusModel->set_vorhang(testItems[2].isChecked());
zirkusModel->set_baum(testItems[3].isChecked());
}
}

View file

@ -5,11 +5,11 @@
class GenusModel : public PrintableModel
{
Q_OBJECT
Q_OBJECT
public:
GenusModel(QObject *parent);
GenusModel(QObject* parent);
void read(const ESGRAF48::GenusModel &model);
void write(ESGRAF48::GenusModel &model) const;
void read(const ESGRAF48::GenusModel& model);
void write(ESGRAF48::GenusModel& model) const;
};

View file

@ -3,21 +3,21 @@
#include "GenusModel.h"
GenusWidget::GenusWidget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::GenusWidget)
GenusWidget::GenusWidget(QWidget* parent)
: QWidget(parent)
, ui(new Ui::GenusWidget)
{
ui->setupUi(this);
ui->setupUi(this);
ui->genusTableView->horizontalHeader()->hide();
ui->genusTableView->horizontalHeader()->hide();
}
GenusWidget::~GenusWidget()
{
delete ui;
delete ui;
}
void GenusWidget::setModel(GenusModel *model)
void GenusWidget::setModel(GenusModel* model)
{
ui->genusTableView->setModel(model);
ui->genusTableView->setModel(model);
}

View file

@ -10,14 +10,14 @@ class GenusWidget;
class GenusWidget : public QWidget
{
Q_OBJECT
Q_OBJECT
private:
Ui::GenusWidget *ui;
Ui::GenusWidget* ui;
public:
GenusWidget(QWidget *parent = nullptr);
~GenusWidget();
GenusWidget(QWidget* parent = nullptr);
~GenusWidget();
void setModel(GenusModel *model);
void setModel(GenusModel* model);
};

View file

@ -1,114 +1,114 @@
#include "GenitivModel.h"
GenitivModel::GenitivModel(QObject *parent)
GenitivModel::GenitivModel(QObject* parent)
: LateSkillsModel(parent)
{
m_tests = {
{"Genitiv Präpositionen",
{"anstelle (1)", "anstelle (2)", "außerhalb (1)", "außerhalb (2)", "mithilfe (1)",
"mithilfe (2)"}},
{"Attributierung",
{"Schuhe (1)", "Schuhe (2)", "Zauberstab (1)", "Zauberstab (2)", "Hut (1)", "Hut (2)",
"Brille (1)", "Brille (2)", "Gürtel (1)", "Gürtel (2)"}},
};
m_tests = {
{"Genitiv Präpositionen",
{"anstelle (1)", "anstelle (2)", "außerhalb (1)", "außerhalb (2)", "mithilfe (1)",
"mithilfe (2)"}},
{"Attributierung",
{"Schuhe (1)", "Schuhe (2)", "Zauberstab (1)", "Zauberstab (2)", "Hut (1)", "Hut (2)",
"Brille (1)", "Brille (2)", "Gürtel (1)", "Gürtel (2)"}},
};
for (auto index : {1, 3, 5})
{
m_tests[0].items()[index].setValue(2);
}
for (auto index : {1, 3, 5})
{
m_tests[0].items()[index].setValue(2);
}
for (auto index : {1, 3, 5, 7, 9})
{
m_tests[1].items()[index].setValue(2);
}
for (auto index : {1, 3, 5, 7, 9})
{
m_tests[1].items()[index].setValue(2);
}
}
bool GenitivModel::setData(const QModelIndex &modelIndex, const QVariant &value, int role)
bool GenitivModel::setData(const QModelIndex& modelIndex, const QVariant& value, int role)
{
if (role == Qt::CheckStateRole && value.toBool() == true)
{
if (modelIndex.column() % 2 == 0)
{
CheckableTestModel::setData(index(modelIndex.row(), modelIndex.column() + 1), false,
role);
}
else
{
CheckableTestModel::setData(index(modelIndex.row(), modelIndex.column() - 1), false,
role);
}
}
if (role == Qt::CheckStateRole && value.toBool() == true)
{
if (modelIndex.column() % 2 == 0)
{
CheckableTestModel::setData(index(modelIndex.row(), modelIndex.column() + 1), false,
role);
}
else
{
CheckableTestModel::setData(index(modelIndex.row(), modelIndex.column() - 1), false,
role);
}
}
return CheckableTestModel::setData(modelIndex, value, role);
return CheckableTestModel::setData(modelIndex, value, role);
}
void GenitivModel::read(const ESGRAF48::LateSkillsGenitivModel &model)
void GenitivModel::read(const ESGRAF48::LateSkillsGenitivModel& model)
{
const auto &praepositionenModel = model.praepositionen();
{
auto &testItems = m_tests.at(0).items();
const auto& praepositionenModel = model.praepositionen();
{
auto& testItems = m_tests.at(0).items();
testItems[0].setState(praepositionenModel.anstelle1());
testItems[1].setState(praepositionenModel.anstelle2());
testItems[2].setState(praepositionenModel.ausserhalb1());
testItems[3].setState(praepositionenModel.ausserhalb2());
testItems[4].setState(praepositionenModel.mithilfe1());
testItems[5].setState(praepositionenModel.mithilfe2());
}
testItems[0].setState(praepositionenModel.anstelle1());
testItems[1].setState(praepositionenModel.anstelle2());
testItems[2].setState(praepositionenModel.ausserhalb1());
testItems[3].setState(praepositionenModel.ausserhalb2());
testItems[4].setState(praepositionenModel.mithilfe1());
testItems[5].setState(praepositionenModel.mithilfe2());
}
const auto &attributierungModel = model.attributierung();
{
auto &testItems = m_tests.at(1).items();
const auto& attributierungModel = model.attributierung();
{
auto& testItems = m_tests.at(1).items();
testItems[0].setState(attributierungModel.schuhe1());
testItems[1].setState(attributierungModel.schuhe2());
testItems[2].setState(attributierungModel.zauberstab1());
testItems[3].setState(attributierungModel.zauberstab2());
testItems[4].setState(attributierungModel.hut1());
testItems[5].setState(attributierungModel.hut2());
testItems[6].setState(attributierungModel.brille1());
testItems[7].setState(attributierungModel.brille2());
testItems[8].setState(attributierungModel.guertel1());
testItems[9].setState(attributierungModel.guertel2());
}
testItems[0].setState(attributierungModel.schuhe1());
testItems[1].setState(attributierungModel.schuhe2());
testItems[2].setState(attributierungModel.zauberstab1());
testItems[3].setState(attributierungModel.zauberstab2());
testItems[4].setState(attributierungModel.hut1());
testItems[5].setState(attributierungModel.hut2());
testItems[6].setState(attributierungModel.brille1());
testItems[7].setState(attributierungModel.brille2());
testItems[8].setState(attributierungModel.guertel1());
testItems[9].setState(attributierungModel.guertel2());
}
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
void GenitivModel::write(ESGRAF48::LateSkillsGenitivModel &model) const
void GenitivModel::write(ESGRAF48::LateSkillsGenitivModel& model) const
{
auto *praepositionenModel = model.mutable_praepositionen();
if (praepositionenModel != nullptr)
{
const auto &testItems = m_tests.at(0).items();
auto* praepositionenModel = model.mutable_praepositionen();
if (praepositionenModel != nullptr)
{
const auto& testItems = m_tests.at(0).items();
praepositionenModel->set_anstelle1(testItems[0].isChecked());
praepositionenModel->set_anstelle2(testItems[1].isChecked());
praepositionenModel->set_ausserhalb1(testItems[2].isChecked());
praepositionenModel->set_ausserhalb2(testItems[3].isChecked());
praepositionenModel->set_mithilfe1(testItems[4].isChecked());
praepositionenModel->set_mithilfe2(testItems[5].isChecked());
}
praepositionenModel->set_anstelle1(testItems[0].isChecked());
praepositionenModel->set_anstelle2(testItems[1].isChecked());
praepositionenModel->set_ausserhalb1(testItems[2].isChecked());
praepositionenModel->set_ausserhalb2(testItems[3].isChecked());
praepositionenModel->set_mithilfe1(testItems[4].isChecked());
praepositionenModel->set_mithilfe2(testItems[5].isChecked());
}
auto *attributierungModel = model.mutable_attributierung();
if (attributierungModel != nullptr)
{
const auto &testItems = m_tests.at(1).items();
auto* attributierungModel = model.mutable_attributierung();
if (attributierungModel != nullptr)
{
const auto& testItems = m_tests.at(1).items();
attributierungModel->set_schuhe1(testItems[0].isChecked());
attributierungModel->set_schuhe2(testItems[1].isChecked());
attributierungModel->set_zauberstab1(testItems[2].isChecked());
attributierungModel->set_zauberstab2(testItems[3].isChecked());
attributierungModel->set_hut1(testItems[4].isChecked());
attributierungModel->set_hut2(testItems[5].isChecked());
attributierungModel->set_brille1(testItems[6].isChecked());
attributierungModel->set_brille2(testItems[7].isChecked());
attributierungModel->set_guertel1(testItems[8].isChecked());
attributierungModel->set_guertel2(testItems[9].isChecked());
}
attributierungModel->set_schuhe1(testItems[0].isChecked());
attributierungModel->set_schuhe2(testItems[1].isChecked());
attributierungModel->set_zauberstab1(testItems[2].isChecked());
attributierungModel->set_zauberstab2(testItems[3].isChecked());
attributierungModel->set_hut1(testItems[4].isChecked());
attributierungModel->set_hut2(testItems[5].isChecked());
attributierungModel->set_brille1(testItems[6].isChecked());
attributierungModel->set_brille2(testItems[7].isChecked());
attributierungModel->set_guertel1(testItems[8].isChecked());
attributierungModel->set_guertel2(testItems[9].isChecked());
}
}
void GenitivModel::printHeader(QPainter &painter) const
void GenitivModel::printHeader(QPainter& painter) const
{
painter.translate(0, -1.5 * painter.fontMetrics().lineSpacing());
painter.translate(0, -1.5 * painter.fontMetrics().lineSpacing());
}

View file

@ -5,16 +5,15 @@
class GenitivModel : public LateSkillsModel
{
Q_OBJECT
Q_OBJECT
public:
GenitivModel(QObject *parent);
bool setData(const QModelIndex &index, const QVariant &value,
int role = Qt::EditRole) override;
GenitivModel(QObject* parent);
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
void read(const ESGRAF48::LateSkillsGenitivModel &model);
void write(ESGRAF48::LateSkillsGenitivModel &model) const;
void read(const ESGRAF48::LateSkillsGenitivModel& model);
void write(ESGRAF48::LateSkillsGenitivModel& model) const;
protected:
void printHeader(QPainter &painter) const override;
void printHeader(QPainter& painter) const override;
};

View file

@ -2,63 +2,63 @@
#include <regex>
LateSkillsModel::LateSkillsModel(QObject *parent)
LateSkillsModel::LateSkillsModel(QObject* parent)
: PrintableModel(parent)
{
}
void LateSkillsModel::printTests(QPainter &painter) const
void LateSkillsModel::printTests(QPainter& painter) const
{
painter.setFont(tableFont());
painter.setPen(tablePen());
painter.setFont(tableFont());
painter.setPen(tablePen());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
double headerWidth = headerWidthFactor() * width;
double cellHeaderWidth = cellWidthFactor() * width;
double cellWidth = 0.5 * cellHeaderWidth;
double rowHeight = height;
double headerWidth = headerWidthFactor() * width;
double cellHeaderWidth = cellWidthFactor() * width;
double cellWidth = 0.5 * cellHeaderWidth;
double rowHeight = height;
double x = 0;
double y = 0;
for (const auto &test : m_tests)
{
QString testName = QString::fromStdString(
std::regex_replace(test.name().toStdString(), std::regex("\\s"), "\n"));
double x = 0;
double y = 0;
for (const auto& test : m_tests)
{
QString testName = QString::fromStdString(
std::regex_replace(test.name().toStdString(), std::regex("\\s"), "\n"));
drawTextSquare(painter, {0, y, headerWidth, 3 * rowHeight}, testName);
drawTextSquare(painter, {0, y, headerWidth, 3 * rowHeight}, testName);
const auto &items = test.items();
const auto& items = test.items();
x = headerWidth;
for (unsigned int i = 0; i < items.size(); i += 2)
{
const auto &item = test.items().at(i);
QString itemText = QString::fromStdString(item.getText()).split(" ").at(0);
x = headerWidth;
for (unsigned int i = 0; i < items.size(); i += 2)
{
const auto& item = test.items().at(i);
QString itemText = QString::fromStdString(item.getText()).split(" ").at(0);
drawTextSquare(painter, {x, y, cellHeaderWidth, rowHeight}, itemText);
drawTextSquare(painter, {x, y, cellHeaderWidth, rowHeight}, itemText);
x += cellHeaderWidth;
}
y += rowHeight;
x += cellHeaderWidth;
}
y += rowHeight;
x = headerWidth;
for (const auto &item : items)
{
drawTextSquare(painter, {x, y, cellWidth, rowHeight}, QString::number(item.value()));
drawCheckSquare(painter, {x, y + rowHeight, cellWidth, rowHeight}, item.isChecked());
x = headerWidth;
for (const auto& item : items)
{
drawTextSquare(painter, {x, y, cellWidth, rowHeight}, QString::number(item.value()));
drawCheckSquare(painter, {x, y + rowHeight, cellWidth, rowHeight}, item.isChecked());
x += cellWidth;
}
x += cellWidth;
}
if (m_tests.size() > 1)
{
drawResultSquare(painter, y + rowHeight, true, test.getPoints());
}
if (m_tests.size() > 1)
{
drawResultSquare(painter, y + rowHeight, true, test.getPoints());
}
y += 2 * rowHeight;
}
y += 2 * rowHeight;
}
painter.translate(0, y + rowHeight);
painter.translate(0, y + rowHeight);
}

View file

@ -5,11 +5,11 @@
class LateSkillsModel : public PrintableModel
{
Q_OBJECT
Q_OBJECT
public:
LateSkillsModel(QObject *parent);
LateSkillsModel(QObject* parent);
protected:
void printTests(QPainter &painter) const override;
void printTests(QPainter& painter) const override;
};

View file

@ -4,26 +4,26 @@
#include "PassivModel.h"
#include "GenitivModel.h"
LateSkillsWidget::LateSkillsWidget(QWidget *parent)
: QWidget(parent)
LateSkillsWidget::LateSkillsWidget(QWidget* parent)
: QWidget(parent)
, ui(new Ui::LateSkillsWidget)
{
ui->setupUi(this);
ui->setupUi(this);
ui->passivTableView->horizontalHeader()->hide();
ui->genitivTableView->horizontalHeader()->hide();
}
LateSkillsWidget::~LateSkillsWidget()
{
delete ui;
delete ui;
}
void LateSkillsWidget::setPassivModel(PassivModel *model)
void LateSkillsWidget::setPassivModel(PassivModel* model)
{
ui->passivTableView->setModel(model);
}
void LateSkillsWidget::setGenitivModel(GenitivModel *model)
void LateSkillsWidget::setGenitivModel(GenitivModel* model)
{
ui->genitivTableView->setModel(model);
}

View file

@ -11,15 +11,15 @@ class LateSkillsWidget;
class LateSkillsWidget : public QWidget
{
Q_OBJECT
Q_OBJECT
private:
Ui::LateSkillsWidget *ui;
Ui::LateSkillsWidget* ui;
public:
LateSkillsWidget(QWidget *parent = nullptr);
~LateSkillsWidget();
LateSkillsWidget(QWidget* parent = nullptr);
~LateSkillsWidget();
void setPassivModel(PassivModel *model);
void setGenitivModel(GenitivModel *model);
void setPassivModel(PassivModel* model);
void setGenitivModel(GenitivModel* model);
};

View file

@ -1,72 +1,72 @@
#include "PassivModel.h"
PassivModel::PassivModel(QObject *parent)
PassivModel::PassivModel(QObject* parent)
: LateSkillsModel(parent)
{
m_tests = {{"Passiv",
{"Elefant (1)", "Elefant (2)", "Pferde (1)", "Pferde (2)", "Bälle (1)", "Bälle (2)",
"Ball (1)", "Ball (2)", "Fleisch (1)", "Fleisch (2)"}}};
m_tests = {{"Passiv",
{"Elefant (1)", "Elefant (2)", "Pferde (1)", "Pferde (2)", "Bälle (1)", "Bälle (2)",
"Ball (1)", "Ball (2)", "Fleisch (1)", "Fleisch (2)"}}};
for (auto index : {1, 3, 5, 7, 9})
{
m_tests[0].items()[index].setValue(2);
}
for (auto index : {1, 3, 5, 7, 9})
{
m_tests[0].items()[index].setValue(2);
}
}
bool PassivModel::setData(const QModelIndex &modelIndex, const QVariant &value, int role)
bool PassivModel::setData(const QModelIndex& modelIndex, const QVariant& value, int role)
{
if (role == Qt::CheckStateRole && value.toBool() == true)
{
if (modelIndex.column() % 2 == 0)
{
CheckableTestModel::setData(index(modelIndex.row(), modelIndex.column() + 1), false,
role);
}
else
{
CheckableTestModel::setData(index(modelIndex.row(), modelIndex.column() - 1), false,
role);
}
}
if (role == Qt::CheckStateRole && value.toBool() == true)
{
if (modelIndex.column() % 2 == 0)
{
CheckableTestModel::setData(index(modelIndex.row(), modelIndex.column() + 1), false,
role);
}
else
{
CheckableTestModel::setData(index(modelIndex.row(), modelIndex.column() - 1), false,
role);
}
}
return CheckableTestModel::setData(modelIndex, value, role);
return CheckableTestModel::setData(modelIndex, value, role);
}
void PassivModel::read(const ESGRAF48::LateSkillsPassivModel &model)
void PassivModel::read(const ESGRAF48::LateSkillsPassivModel& model)
{
auto &testItems = m_tests.at(0).items();
auto& testItems = m_tests.at(0).items();
testItems[0].setState(model.elefant1());
testItems[1].setState(model.elefant2());
testItems[2].setState(model.pferde1());
testItems[3].setState(model.pferde2());
testItems[4].setState(model.baelle1());
testItems[5].setState(model.baelle2());
testItems[6].setState(model.ball1());
testItems[7].setState(model.ball2());
testItems[8].setState(model.fleisch1());
testItems[9].setState(model.fleisch2());
testItems[0].setState(model.elefant1());
testItems[1].setState(model.elefant2());
testItems[2].setState(model.pferde1());
testItems[3].setState(model.pferde2());
testItems[4].setState(model.baelle1());
testItems[5].setState(model.baelle2());
testItems[6].setState(model.ball1());
testItems[7].setState(model.ball2());
testItems[8].setState(model.fleisch1());
testItems[9].setState(model.fleisch2());
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
void PassivModel::write(ESGRAF48::LateSkillsPassivModel &model) const
void PassivModel::write(ESGRAF48::LateSkillsPassivModel& model) const
{
const auto &testItems = m_tests.at(0).items();
const auto& testItems = m_tests.at(0).items();
model.set_elefant1(testItems[0].isChecked());
model.set_elefant2(testItems[1].isChecked());
model.set_pferde1(testItems[2].isChecked());
model.set_pferde2(testItems[3].isChecked());
model.set_baelle1(testItems[4].isChecked());
model.set_baelle2(testItems[5].isChecked());
model.set_ball1(testItems[6].isChecked());
model.set_ball2(testItems[7].isChecked());
model.set_fleisch1(testItems[8].isChecked());
model.set_fleisch2(testItems[9].isChecked());
model.set_elefant1(testItems[0].isChecked());
model.set_elefant2(testItems[1].isChecked());
model.set_pferde1(testItems[2].isChecked());
model.set_pferde2(testItems[3].isChecked());
model.set_baelle1(testItems[4].isChecked());
model.set_baelle2(testItems[5].isChecked());
model.set_ball1(testItems[6].isChecked());
model.set_ball2(testItems[7].isChecked());
model.set_fleisch1(testItems[8].isChecked());
model.set_fleisch2(testItems[9].isChecked());
}
void PassivModel::printHeader(QPainter &painter) const
void PassivModel::printHeader(QPainter& painter) const
{
drawHeader2(painter, "Subtest 6: Späte Fähigkeiten (7;0-8;11)");
drawHeader2(painter, "Subtest 6: Späte Fähigkeiten (7;0-8;11)");
}

View file

@ -5,15 +5,15 @@
class PassivModel : public LateSkillsModel
{
Q_OBJECT
Q_OBJECT
public:
PassivModel(QObject *parent);
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
PassivModel(QObject* parent);
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
void read(const ESGRAF48::LateSkillsPassivModel &model);
void write(ESGRAF48::LateSkillsPassivModel &model) const;
void read(const ESGRAF48::LateSkillsPassivModel& model);
void write(ESGRAF48::LateSkillsPassivModel& model) const;
protected:
void printHeader(QPainter &painter) const override;
void printHeader(QPainter& painter) const override;
};

View file

@ -4,80 +4,80 @@
#include <regex>
PluralModel::PluralModel(QObject *parent)
PluralModel::PluralModel(QObject* parent)
: PrintableModel(parent)
{
m_title = "Subtest 5: Plural";
m_title = "Subtest 5: Plural";
m_tests = {{"Plural",
{"Fisch /-e/", "Banane /-n/", "Bonbon /-s/", "Ei /-er/", "Eimer /-ø/",
"Korn UML+/-er/", "Nuss UML+/-e/", "Bär /-en/", "Apfel UML"}}};
m_tests = {{"Plural",
{"Fisch /-e/", "Banane /-n/", "Bonbon /-s/", "Ei /-er/", "Eimer /-ø/",
"Korn UML+/-er/", "Nuss UML+/-e/", "Bär /-en/", "Apfel UML"}}};
}
void PluralModel::read(const ESGRAF48::PluralModel &model)
void PluralModel::read(const ESGRAF48::PluralModel& model)
{
auto &testItems = m_tests.at(0).items();
auto& testItems = m_tests.at(0).items();
testItems[0].setState(model.fisch());
testItems[1].setState(model.banane());
testItems[2].setState(model.bonbon());
testItems[3].setState(model.ei());
testItems[4].setState(model.eimer());
testItems[5].setState(model.korn());
testItems[6].setState(model.nuss());
testItems[7].setState(model.baer());
testItems[8].setState(model.apfel());
testItems[0].setState(model.fisch());
testItems[1].setState(model.banane());
testItems[2].setState(model.bonbon());
testItems[3].setState(model.ei());
testItems[4].setState(model.eimer());
testItems[5].setState(model.korn());
testItems[6].setState(model.nuss());
testItems[7].setState(model.baer());
testItems[8].setState(model.apfel());
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
void PluralModel::write(ESGRAF48::PluralModel &model) const
void PluralModel::write(ESGRAF48::PluralModel& model) const
{
const auto &testItems = m_tests.at(0).items();
const auto& testItems = m_tests.at(0).items();
model.set_fisch(testItems[0].isChecked());
model.set_banane(testItems[1].isChecked());
model.set_bonbon(testItems[2].isChecked());
model.set_ei(testItems[3].isChecked());
model.set_eimer(testItems[4].isChecked());
model.set_korn(testItems[5].isChecked());
model.set_nuss(testItems[6].isChecked());
model.set_baer(testItems[7].isChecked());
model.set_apfel(testItems[8].isChecked());
model.set_fisch(testItems[0].isChecked());
model.set_banane(testItems[1].isChecked());
model.set_bonbon(testItems[2].isChecked());
model.set_ei(testItems[3].isChecked());
model.set_eimer(testItems[4].isChecked());
model.set_korn(testItems[5].isChecked());
model.set_nuss(testItems[6].isChecked());
model.set_baer(testItems[7].isChecked());
model.set_apfel(testItems[8].isChecked());
}
void PluralModel::printTests(QPainter &painter) const
void PluralModel::printTests(QPainter& painter) const
{
painter.setFont(tableFont());
painter.setPen(tablePen());
painter.setFont(tableFont());
painter.setPen(tablePen());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
double headerWidth = headerWidthFactor() * width;
double cellWidth = cellWidthFactor() * width;
double rowHeight = height;
double headerWidth = headerWidthFactor() * width;
double cellWidth = cellWidthFactor() * width;
double rowHeight = height;
double x = 0;
double y = 0;
for (const auto &test : m_tests)
{
drawTextSquare(painter, {0, y, headerWidth, 3 * rowHeight}, test.name());
x = headerWidth;
double x = 0;
double y = 0;
for (const auto& test : m_tests)
{
drawTextSquare(painter, {0, y, headerWidth, 3 * rowHeight}, test.name());
x = headerWidth;
for (const auto &item : test.items())
{
QString itemText =
QString::fromStdString(std::regex_replace(item.getText(), std::regex("\\s"), "\n"));
for (const auto& item : test.items())
{
QString itemText =
QString::fromStdString(std::regex_replace(item.getText(), std::regex("\\s"), "\n"));
drawTextSquare(painter, {x, y, cellWidth, 2 * rowHeight}, itemText);
drawCheckSquare(painter, {x, y + 2 * rowHeight, cellWidth, rowHeight},
item.isChecked());
drawTextSquare(painter, {x, y, cellWidth, 2 * rowHeight}, itemText);
drawCheckSquare(painter, {x, y + 2 * rowHeight, cellWidth, rowHeight},
item.isChecked());
x += cellWidth;
}
y += 2 * rowHeight;
}
x += cellWidth;
}
y += 2 * rowHeight;
}
painter.translate(0, y + 2 * rowHeight);
painter.translate(0, y + 2 * rowHeight);
}

View file

@ -5,14 +5,14 @@
class PluralModel : public PrintableModel
{
Q_OBJECT
Q_OBJECT
public:
PluralModel(QObject *parent);
PluralModel(QObject* parent);
void read(const ESGRAF48::PluralModel &model);
void write(ESGRAF48::PluralModel &model) const;
void read(const ESGRAF48::PluralModel& model);
void write(ESGRAF48::PluralModel& model) const;
protected:
virtual void printTests(QPainter &painter) const;
virtual void printTests(QPainter& painter) const;
};

View file

@ -3,21 +3,21 @@
#include "PluralModel.h"
PluralWidget::PluralWidget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::PluralWidget)
PluralWidget::PluralWidget(QWidget* parent)
: QWidget(parent)
, ui(new Ui::PluralWidget)
{
ui->setupUi(this);
ui->setupUi(this);
ui->pluralTableView->horizontalHeader()->hide();
ui->pluralTableView->horizontalHeader()->hide();
}
PluralWidget::~PluralWidget()
{
delete ui;
delete ui;
}
void PluralWidget::setModel(PluralModel *model)
void PluralWidget::setModel(PluralModel* model)
{
ui->pluralTableView->setModel(model);
ui->pluralTableView->setModel(model);
}

View file

@ -10,14 +10,14 @@ class PluralWidget;
class PluralWidget : public QWidget
{
Q_OBJECT
Q_OBJECT
private:
Ui::PluralWidget *ui;
Ui::PluralWidget* ui;
public:
PluralWidget(QWidget *parent = nullptr);
~PluralWidget();
PluralWidget(QWidget* parent = nullptr);
~PluralWidget();
void setModel(PluralModel *model);
void setModel(PluralModel* model);
};

View file

@ -1,115 +1,115 @@
#include "OTModel.h"
OTModel::OTModel(QObject *parent)
OTModel::OTModel(QObject* parent)
: V2SvkModel(parent)
{
m_tests = {
{"Objekt-Topikalisierung",
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
"Gans", "Gans", "Gans"}},
{"SVK: Stamm",
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
"Gans", "Gans", "Gans"}},
};
m_tests = {
{"Objekt-Topikalisierung",
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
"Gans", "Gans", "Gans"}},
{"SVK: Stamm",
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
"Gans", "Gans", "Gans"}},
};
}
unsigned int OTModel::getV2Points() const
{
unsigned int points = 0;
unsigned int points = 0;
for (auto testIndex : {0})
{
const auto &test = m_tests.at(testIndex);
for (auto testIndex : {0})
{
const auto& test = m_tests.at(testIndex);
for (const auto &item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
for (const auto& item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
return points;
return points;
}
unsigned int OTModel::getSvkPoints() const
{
unsigned int points = 0;
unsigned int points = 0;
for (auto testIndex : {1})
{
const auto &test = m_tests.at(testIndex);
for (auto testIndex : {1})
{
const auto& test = m_tests.at(testIndex);
for (const auto &item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
for (const auto& item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
return points;
return points;
}
void OTModel::write(ESGRAF48::V2SvkModel &model) const
void OTModel::write(ESGRAF48::V2SvkModel& model) const
{
auto writeFourVals = [&](ESGRAF48::V2SvkModel::FourEach *modelData, int testIndex) {
if (modelData != nullptr)
{
const auto &testItems = m_tests.at(testIndex).items();
auto writeFourVals = [&](ESGRAF48::V2SvkModel::FourEach* modelData, int testIndex) {
if (modelData != nullptr)
{
const auto& testItems = m_tests.at(testIndex).items();
modelData->set_affe1(testItems[0].isChecked());
modelData->set_affe2(testItems[1].isChecked());
modelData->set_affe3(testItems[2].isChecked());
modelData->set_affe4(testItems[3].isChecked());
modelData->set_schwein1(testItems[4].isChecked());
modelData->set_schwein2(testItems[5].isChecked());
modelData->set_schwein3(testItems[6].isChecked());
modelData->set_schwein4(testItems[7].isChecked());
modelData->set_gans1(testItems[8].isChecked());
modelData->set_gans2(testItems[9].isChecked());
modelData->set_gans3(testItems[10].isChecked());
modelData->set_gans4(testItems[11].isChecked());
}
};
modelData->set_affe1(testItems[0].isChecked());
modelData->set_affe2(testItems[1].isChecked());
modelData->set_affe3(testItems[2].isChecked());
modelData->set_affe4(testItems[3].isChecked());
modelData->set_schwein1(testItems[4].isChecked());
modelData->set_schwein2(testItems[5].isChecked());
modelData->set_schwein3(testItems[6].isChecked());
modelData->set_schwein4(testItems[7].isChecked());
modelData->set_gans1(testItems[8].isChecked());
modelData->set_gans2(testItems[9].isChecked());
modelData->set_gans3(testItems[10].isChecked());
modelData->set_gans4(testItems[11].isChecked());
}
};
writeFourVals(model.mutable_objtop(), 0);
writeFourVals(model.mutable_svkstamm(), 1);
writeFourVals(model.mutable_objtop(), 0);
writeFourVals(model.mutable_svkstamm(), 1);
}
void OTModel::read(const ESGRAF48::V2SvkModel &model)
void OTModel::read(const ESGRAF48::V2SvkModel& model)
{
auto readFourVals = [&](const ESGRAF48::V2SvkModel::FourEach &modelData, int testIndex) {
auto &testItems = m_tests.at(testIndex).items();
auto readFourVals = [&](const ESGRAF48::V2SvkModel::FourEach& modelData, int testIndex) {
auto& testItems = m_tests.at(testIndex).items();
testItems[0].setState(modelData.affe1());
testItems[1].setState(modelData.affe2());
testItems[2].setState(modelData.affe3());
testItems[3].setState(modelData.affe4());
testItems[4].setState(modelData.schwein1());
testItems[5].setState(modelData.schwein2());
testItems[6].setState(modelData.schwein3());
testItems[7].setState(modelData.schwein4());
testItems[8].setState(modelData.gans1());
testItems[9].setState(modelData.gans2());
testItems[10].setState(modelData.gans3());
testItems[11].setState(modelData.gans4());
};
testItems[0].setState(modelData.affe1());
testItems[1].setState(modelData.affe2());
testItems[2].setState(modelData.affe3());
testItems[3].setState(modelData.affe4());
testItems[4].setState(modelData.schwein1());
testItems[5].setState(modelData.schwein2());
testItems[6].setState(modelData.schwein3());
testItems[7].setState(modelData.schwein4());
testItems[8].setState(modelData.gans1());
testItems[9].setState(modelData.gans2());
testItems[10].setState(modelData.gans3());
testItems[11].setState(modelData.gans4());
};
readFourVals(model.objtop(), 0);
readFourVals(model.svkstamm(), 1);
readFourVals(model.objtop(), 0);
readFourVals(model.svkstamm(), 1);
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
std::set<int> OTModel::v2Tests() const
{
return {0};
return {0};
};
std::set<int> OTModel::svkTests() const
{
return {1};
return {1};
};

View file

@ -5,20 +5,20 @@
class OTModel : public V2SvkModel
{
Q_OBJECT
Q_OBJECT
public:
OTModel(QObject *parent);
OTModel(QObject* parent);
unsigned int getV2Points() const override;
unsigned int getSvkPoints() const override;
unsigned int getV2Points() const override;
unsigned int getSvkPoints() const override;
void write(ESGRAF48::V2SvkModel &model) const override;
void read(const ESGRAF48::V2SvkModel &model) override;
void write(ESGRAF48::V2SvkModel& model) const override;
void read(const ESGRAF48::V2SvkModel& model) override;
protected:
void printHeader(QPainter &) const override {};
void printHeader(QPainter&) const override{};
std::set<int> v2Tests() const override;
std::set<int> svkTests() const override;
std::set<int> v2Tests() const override;
std::set<int> svkTests() const override;
};

View file

@ -1,105 +1,105 @@
#include "TPeModel.h"
TPeModel::TPeModel(QObject *parent)
TPeModel::TPeModel(QObject* parent)
: V2SvkModel(parent)
{
m_tests = {
{"Temporaladverb Perfekt", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
{"Verbtrennung", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
{"SVK: /-e/ o. Stamm", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
{"Partizip", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
};
m_tests = {
{"Temporaladverb Perfekt", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
{"Verbtrennung", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
{"SVK: /-e/ o. Stamm", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
{"Partizip", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
};
}
unsigned int TPeModel::getV2Points() const
{
unsigned int points = 0;
unsigned int points = 0;
for (auto testIndex : {0, 1})
{
const auto &test = m_tests.at(testIndex);
for (auto testIndex : {0, 1})
{
const auto& test = m_tests.at(testIndex);
for (const auto &item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
for (const auto& item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
return points;
return points;
}
unsigned int TPeModel::getSvkPoints() const
{
unsigned int points = 0;
unsigned int points = 0;
for (auto testIndex : {2, 3})
{
const auto &test = m_tests.at(testIndex);
for (auto testIndex : {2, 3})
{
const auto& test = m_tests.at(testIndex);
for (const auto &item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
for (const auto& item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
return points;
return points;
}
void TPeModel::write(ESGRAF48::V2SvkModel &model) const
void TPeModel::write(ESGRAF48::V2SvkModel& model) const
{
auto writeTwoVals = [&](ESGRAF48::V2SvkModel::TwoEach *modelData, int testIndex) {
if (modelData != nullptr)
{
const auto &testItems = m_tests.at(testIndex).items();
auto writeTwoVals = [&](ESGRAF48::V2SvkModel::TwoEach* modelData, int testIndex) {
if (modelData != nullptr)
{
const auto& testItems = m_tests.at(testIndex).items();
modelData->set_affe1(testItems[0].isChecked());
modelData->set_affe2(testItems[1].isChecked());
modelData->set_schwein1(testItems[2].isChecked());
modelData->set_schwein2(testItems[3].isChecked());
modelData->set_gans1(testItems[4].isChecked());
modelData->set_gans2(testItems[5].isChecked());
}
};
modelData->set_affe1(testItems[0].isChecked());
modelData->set_affe2(testItems[1].isChecked());
modelData->set_schwein1(testItems[2].isChecked());
modelData->set_schwein2(testItems[3].isChecked());
modelData->set_gans1(testItems[4].isChecked());
modelData->set_gans2(testItems[5].isChecked());
}
};
writeTwoVals(model.mutable_tempperf(), 0);
writeTwoVals(model.mutable_verbtrennung2(), 1);
writeTwoVals(model.mutable_svke2(), 2);
writeTwoVals(model.mutable_partizip(), 3);
writeTwoVals(model.mutable_tempperf(), 0);
writeTwoVals(model.mutable_verbtrennung2(), 1);
writeTwoVals(model.mutable_svke2(), 2);
writeTwoVals(model.mutable_partizip(), 3);
}
void TPeModel::read(const ESGRAF48::V2SvkModel &model)
void TPeModel::read(const ESGRAF48::V2SvkModel& model)
{
auto readTwoVals = [&](const ESGRAF48::V2SvkModel::TwoEach &modelData, int testIndex) {
auto &testItems = m_tests.at(testIndex).items();
auto readTwoVals = [&](const ESGRAF48::V2SvkModel::TwoEach& modelData, int testIndex) {
auto& testItems = m_tests.at(testIndex).items();
testItems[0].setState(modelData.affe1());
testItems[1].setState(modelData.affe2());
testItems[2].setState(modelData.schwein1());
testItems[3].setState(modelData.schwein2());
testItems[4].setState(modelData.gans1());
testItems[5].setState(modelData.gans2());
};
testItems[0].setState(modelData.affe1());
testItems[1].setState(modelData.affe2());
testItems[2].setState(modelData.schwein1());
testItems[3].setState(modelData.schwein2());
testItems[4].setState(modelData.gans1());
testItems[5].setState(modelData.gans2());
};
readTwoVals(model.tempperf(), 0);
readTwoVals(model.verbtrennung2(), 1);
readTwoVals(model.svke2(), 2);
readTwoVals(model.partizip(), 3);
readTwoVals(model.tempperf(), 0);
readTwoVals(model.verbtrennung2(), 1);
readTwoVals(model.svke2(), 2);
readTwoVals(model.partizip(), 3);
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
std::set<int> TPeModel::v2Tests() const
{
return {0, 1};
return {0, 1};
};
std::set<int> TPeModel::svkTests() const
{
return {2, 3};
return {2, 3};
};

View file

@ -5,20 +5,20 @@
class TPeModel : public V2SvkModel
{
Q_OBJECT
Q_OBJECT
public:
TPeModel(QObject *parent);
TPeModel(QObject* parent);
unsigned int getV2Points() const override;
unsigned int getSvkPoints() const override;
unsigned int getV2Points() const override;
unsigned int getSvkPoints() const override;
void write(ESGRAF48::V2SvkModel &model) const override;
void read(const ESGRAF48::V2SvkModel &model) override;
void write(ESGRAF48::V2SvkModel& model) const override;
void read(const ESGRAF48::V2SvkModel& model) override;
protected:
void printHeader(QPainter &) const override {};
void printHeader(QPainter&) const override{};
std::set<int> v2Tests() const override;
std::set<int> svkTests() const override;
std::set<int> v2Tests() const override;
std::set<int> svkTests() const override;
};

View file

@ -1,99 +1,99 @@
#include "TPrModel.h"
TPrModel::TPrModel(QObject *parent)
TPrModel::TPrModel(QObject* parent)
: V2SvkModel(parent)
{
m_tests = {
{"Temporaladverb Präsens", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
{"SKV: /-e/ o. Stamm", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
};
m_tests = {
{"Temporaladverb Präsens", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
{"SKV: /-e/ o. Stamm", {"Affe", "Affe", "Schwein", "Schwein", "Gans", "Gans"}},
};
}
unsigned int TPrModel::getV2Points() const
{
unsigned int points = 0;
unsigned int points = 0;
for (auto testIndex : {0})
{
const auto &test = m_tests.at(testIndex);
for (auto testIndex : {0})
{
const auto& test = m_tests.at(testIndex);
for (const auto &item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
for (const auto& item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
return points;
return points;
}
unsigned int TPrModel::getSvkPoints() const
{
unsigned int points = 0;
unsigned int points = 0;
for (auto testIndex : {1})
{
const auto &test = m_tests.at(testIndex);
for (auto testIndex : {1})
{
const auto& test = m_tests.at(testIndex);
for (const auto &item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
for (const auto& item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
return points;
return points;
}
void TPrModel::write(ESGRAF48::V2SvkModel &model) const
void TPrModel::write(ESGRAF48::V2SvkModel& model) const
{
auto writeTwoVals = [&](ESGRAF48::V2SvkModel::TwoEach *modelData, int testIndex) {
if (modelData != nullptr)
{
const auto &testItems = m_tests.at(testIndex).items();
auto writeTwoVals = [&](ESGRAF48::V2SvkModel::TwoEach* modelData, int testIndex) {
if (modelData != nullptr)
{
const auto& testItems = m_tests.at(testIndex).items();
modelData->set_affe1(testItems[0].isChecked());
modelData->set_affe2(testItems[1].isChecked());
modelData->set_schwein1(testItems[2].isChecked());
modelData->set_schwein2(testItems[3].isChecked());
modelData->set_gans1(testItems[4].isChecked());
modelData->set_gans2(testItems[5].isChecked());
}
};
modelData->set_affe1(testItems[0].isChecked());
modelData->set_affe2(testItems[1].isChecked());
modelData->set_schwein1(testItems[2].isChecked());
modelData->set_schwein2(testItems[3].isChecked());
modelData->set_gans1(testItems[4].isChecked());
modelData->set_gans2(testItems[5].isChecked());
}
};
writeTwoVals(model.mutable_temppraes(), 0);
writeTwoVals(model.mutable_svke1(), 1);
writeTwoVals(model.mutable_temppraes(), 0);
writeTwoVals(model.mutable_svke1(), 1);
}
void TPrModel::read(const ESGRAF48::V2SvkModel &model)
void TPrModel::read(const ESGRAF48::V2SvkModel& model)
{
auto readTwoVals = [&](const ESGRAF48::V2SvkModel::TwoEach &modelData, int testIndex) {
auto &testItems = m_tests.at(testIndex).items();
auto readTwoVals = [&](const ESGRAF48::V2SvkModel::TwoEach& modelData, int testIndex) {
auto& testItems = m_tests.at(testIndex).items();
testItems[0].setState(modelData.affe1());
testItems[1].setState(modelData.affe2());
testItems[2].setState(modelData.schwein1());
testItems[3].setState(modelData.schwein2());
testItems[4].setState(modelData.gans1());
testItems[5].setState(modelData.gans2());
};
testItems[0].setState(modelData.affe1());
testItems[1].setState(modelData.affe2());
testItems[2].setState(modelData.schwein1());
testItems[3].setState(modelData.schwein2());
testItems[4].setState(modelData.gans1());
testItems[5].setState(modelData.gans2());
};
readTwoVals(model.temppraes(), 0);
readTwoVals(model.svke1(), 1);
readTwoVals(model.temppraes(), 0);
readTwoVals(model.svke1(), 1);
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
std::set<int> TPrModel::v2Tests() const
{
return {0};
return {0};
};
std::set<int> TPrModel::svkTests() const
{
return {1};
return {1};
};

View file

@ -5,20 +5,20 @@
class TPrModel : public V2SvkModel
{
Q_OBJECT
Q_OBJECT
public:
TPrModel(QObject *parent);
TPrModel(QObject* parent);
unsigned int getV2Points() const override;
unsigned int getSvkPoints() const override;
unsigned int getV2Points() const override;
unsigned int getSvkPoints() const override;
void write(ESGRAF48::V2SvkModel &model) const override;
void read(const ESGRAF48::V2SvkModel &model) override;
void write(ESGRAF48::V2SvkModel& model) const override;
void read(const ESGRAF48::V2SvkModel& model) override;
protected:
void printHeader(QPainter &) const override{};
void printHeader(QPainter&) const override{};
std::set<int> v2Tests() const override;
std::set<int> svkTests() const override;
std::set<int> v2Tests() const override;
std::set<int> svkTests() const override;
};

View file

@ -2,136 +2,137 @@
#include <regex>
V2SvkModel::V2SvkModel(QObject *parent)
V2SvkModel::V2SvkModel(QObject* parent)
: PrintableModel(parent)
{
}
void V2SvkModel::printTests(QPainter &painter) const
void V2SvkModel::printTests(QPainter& painter) const
{
painter.setFont(tableFont());
painter.setPen(tablePen());
painter.setFont(tableFont());
painter.setPen(tablePen());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
auto v2TestIndices = v2Tests();
auto svkTestIndices = svkTests();
auto v2TestIndices = v2Tests();
auto svkTestIndices = svkTests();
double x = 0;
double y = 0;
auto testIndex = 0;
for (const auto &test : m_tests)
{
double rowHeaderWidth = headerWidthFactor() * width;
double resultCellWidth = (test.size() > 8 ? 0.5 : 1) * cellWidthFactor() * width;
double rowHeight = height;
double x = 0;
double y = 0;
auto testIndex = 0;
for (const auto& test : m_tests)
{
double rowHeaderWidth = headerWidthFactor() * width;
double resultCellWidth = (test.size() > 8 ? 0.5 : 1) * cellWidthFactor() * width;
double rowHeight = height;
QString testName = test.name();
if (testName.length() > 20)
{
testName = QString::fromStdString(
std::regex_replace(testName.toStdString(), std::regex("[\\s-]"), "\n"));
}
QString testName = test.name();
if (testName.length() > 20)
{
testName = QString::fromStdString(
std::regex_replace(testName.toStdString(), std::regex("[\\s-]"), "\n"));
}
if (testIndex == 0)
{
drawTextSquare(painter, {x, y, rowHeaderWidth, 2 * rowHeight}, testName);
x += rowHeaderWidth;
if (testIndex == 0)
{
drawTextSquare(painter, {x, y, rowHeaderWidth, 2 * rowHeight}, testName);
x += rowHeaderWidth;
std::vector<std::pair<std::string, unsigned int>> columnHeaders;
for (const auto &item : test.items())
{
const auto &itemText = item.getText();
if (!columnHeaders.empty() && columnHeaders.back().first == itemText)
{
columnHeaders.back().second++;
}
else
{
columnHeaders.emplace_back(itemText, 1);
}
}
std::vector<std::pair<std::string, unsigned int>> columnHeaders;
for (const auto& item : test.items())
{
const auto& itemText = item.getText();
if (!columnHeaders.empty() && columnHeaders.back().first == itemText)
{
columnHeaders.back().second++;
}
else
{
columnHeaders.emplace_back(itemText, 1);
}
}
for (const auto &columnHeader : columnHeaders)
{
double cellWidth = columnHeader.second * resultCellWidth;
drawTextSquare(painter, {x, y, cellWidth, rowHeight}, columnHeader.first.c_str());
x += cellWidth;
}
x = rowHeaderWidth;
y += rowHeight;
}
else
{
drawTextSquare(painter, {x, y, rowHeaderWidth, rowHeight}, testName);
x += rowHeaderWidth;
}
for (const auto& columnHeader : columnHeaders)
{
double cellWidth = columnHeader.second * resultCellWidth;
drawTextSquare(painter, {x, y, cellWidth, rowHeight}, columnHeader.first.c_str());
x += cellWidth;
}
x = rowHeaderWidth;
y += rowHeight;
}
else
{
drawTextSquare(painter, {x, y, rowHeaderWidth, rowHeight}, testName);
x += rowHeaderWidth;
}
unsigned int emptyItemsStack = 0;
for (const auto &item : test.items())
{
if (item.getText().empty())
{
emptyItemsStack++;
}
else
{
if (emptyItemsStack > 0)
{
drawGreySquare(painter, {x - emptyItemsStack * resultCellWidth, y,
emptyItemsStack * resultCellWidth, rowHeight});
emptyItemsStack = 0;
}
unsigned int emptyItemsStack = 0;
for (const auto& item : test.items())
{
if (item.getText().empty())
{
emptyItemsStack++;
}
else
{
if (emptyItemsStack > 0)
{
drawGreySquare(painter,
{x - emptyItemsStack * resultCellWidth, y,
emptyItemsStack * resultCellWidth, rowHeight});
emptyItemsStack = 0;
}
drawCheckSquare(painter, {x, y, resultCellWidth, rowHeight}, item.isChecked());
}
x += resultCellWidth;
}
if (emptyItemsStack > 0)
{
drawGreySquare(painter, {x - emptyItemsStack * resultCellWidth, y,
emptyItemsStack * resultCellWidth, rowHeight});
emptyItemsStack = 0;
}
drawCheckSquare(painter, {x, y, resultCellWidth, rowHeight}, item.isChecked());
}
x += resultCellWidth;
}
if (emptyItemsStack > 0)
{
drawGreySquare(painter,
{x - emptyItemsStack * resultCellWidth, y,
emptyItemsStack * resultCellWidth, rowHeight});
emptyItemsStack = 0;
}
if (v2TestIndices.find(testIndex) != v2TestIndices.end())
{
drawResultSquare(painter, y, false, test.getPoints());
}
if (v2TestIndices.find(testIndex) != v2TestIndices.end())
{
drawResultSquare(painter, y, false, test.getPoints());
}
if (svkTestIndices.find(testIndex) != svkTestIndices.end())
{
drawResultSquare(painter, y, true, test.getPoints());
}
if (svkTestIndices.find(testIndex) != svkTestIndices.end())
{
drawResultSquare(painter, y, true, test.getPoints());
}
x = 0;
y += rowHeight;
x = 0;
y += rowHeight;
testIndex++;
}
testIndex++;
}
x = 0;
y += height;
x = 0;
y += height;
painter.translate(0, y);
painter.translate(0, y);
}
void V2SvkModel::printSummary(QPainter &painter, unsigned int v2Points, unsigned int svkPoints)
void V2SvkModel::printSummary(QPainter& painter, unsigned int v2Points, unsigned int svkPoints)
{
painter.setFont(PrintableModel::tableFont());
painter.setPen(PrintableModel::tablePen());
painter.setFont(PrintableModel::tableFont());
painter.setPen(PrintableModel::tablePen());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
painter.drawText(0, 0, 0.91 * width, height, Qt::AlignRight | Qt::AlignVCenter,
"Rohwertpunkte Total:");
painter.drawText(0, 0, 0.91 * width, height, Qt::AlignRight | Qt::AlignVCenter,
"Rohwertpunkte Total:");
painter.setPen(resultPen());
drawNumberSquare(painter, 0.93 * width, 0, v2Points);
drawNumberSquare(painter, 0.97 * width, 0, svkPoints);
painter.setPen(resultPen());
drawNumberSquare(painter, 0.93 * width, 0, v2Points);
drawNumberSquare(painter, 0.97 * width, 0, svkPoints);
painter.translate(0, 3 * height);
painter.translate(0, 3 * height);
}

View file

@ -5,23 +5,23 @@
class V2SvkModel : public PrintableModel
{
Q_OBJECT
Q_OBJECT
public:
V2SvkModel(QObject *parent);
V2SvkModel(QObject* parent);
virtual unsigned int getV2Points() const = 0;
virtual unsigned int getSvkPoints() const = 0;
virtual unsigned int getV2Points() const = 0;
virtual unsigned int getSvkPoints() const = 0;
virtual void write(ESGRAF48::V2SvkModel &model) const = 0;
virtual void read(const ESGRAF48::V2SvkModel &model) = 0;
virtual void write(ESGRAF48::V2SvkModel& model) const = 0;
virtual void read(const ESGRAF48::V2SvkModel& model) = 0;
static void printSummary(QPainter &painter, unsigned int v2Points, unsigned int svkPoints);
static void printSummary(QPainter& painter, unsigned int v2Points, unsigned int svkPoints);
protected:
void printTests(QPainter &painter) const override;
void printSummary(QPainter &painter) const override {};
void printTests(QPainter& painter) const override;
void printSummary(QPainter& painter) const override{};
virtual std::set<int> v2Tests() const = 0;
virtual std::set<int> svkTests() const = 0;
virtual std::set<int> v2Tests() const = 0;
virtual std::set<int> svkTests() const = 0;
};

View file

@ -6,38 +6,38 @@
#include "TPrModel.h"
#include "TPeModel.h"
V2SvkWidget::V2SvkWidget(QWidget *parent)
V2SvkWidget::V2SvkWidget(QWidget* parent)
: QWidget(parent)
, ui(new Ui::V2SvkWidget)
{
ui->setupUi(this);
ui->wfTableView->horizontalHeader()->hide();
ui->otTableView->horizontalHeader()->hide();
ui->tprTableView->horizontalHeader()->hide();
ui->tpeTableView->horizontalHeader()->hide();
ui->setupUi(this);
ui->wfTableView->horizontalHeader()->hide();
ui->otTableView->horizontalHeader()->hide();
ui->tprTableView->horizontalHeader()->hide();
ui->tpeTableView->horizontalHeader()->hide();
}
V2SvkWidget::~V2SvkWidget()
{
delete ui;
delete ui;
}
void V2SvkWidget::setWFModel(WFModel *model)
void V2SvkWidget::setWFModel(WFModel* model)
{
ui->wfTableView->setModel(model);
ui->wfTableView->setModel(model);
}
void V2SvkWidget::setOTModel(OTModel *model)
void V2SvkWidget::setOTModel(OTModel* model)
{
ui->otTableView->setModel(model);
ui->otTableView->setModel(model);
}
void V2SvkWidget::setTPrModel(TPrModel *model)
void V2SvkWidget::setTPrModel(TPrModel* model)
{
ui->tprTableView->setModel(model);
ui->tprTableView->setModel(model);
}
void V2SvkWidget::setTPeModel(TPeModel *model)
void V2SvkWidget::setTPeModel(TPeModel* model)
{
ui->tpeTableView->setModel(model);
ui->tpeTableView->setModel(model);
}

View file

@ -13,17 +13,17 @@ class V2SvkWidget;
class V2SvkWidget : public QWidget
{
Q_OBJECT
Q_OBJECT
private:
Ui::V2SvkWidget *ui;
Ui::V2SvkWidget* ui;
public:
V2SvkWidget(QWidget *parent = nullptr);
~V2SvkWidget();
V2SvkWidget(QWidget* parent = nullptr);
~V2SvkWidget();
void setWFModel(WFModel *model);
void setOTModel(OTModel *model);
void setTPrModel(TPrModel *model);
void setTPeModel(TPeModel *model);
void setWFModel(WFModel* model);
void setOTModel(OTModel* model);
void setTPrModel(TPrModel* model);
void setTPeModel(TPeModel* model);
};

View file

@ -1,147 +1,147 @@
#include "WFModel.h"
WFModel::WFModel(QObject *parent)
WFModel::WFModel(QObject* parent)
: V2SvkModel(parent)
{
m_title = "Subtest 1: Verbzweitstellungsregel (V2) und Subjekt-Verb-Kontrollregel (SVK)";
m_title = "Subtest 1: Verbzweitstellungsregel (V2) und Subjekt-Verb-Kontrollregel (SVK)";
m_tests = {
{"W-Frage",
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
"Gans", "Gans", "Gans"}},
{"Verbtrennung", {"", "Affe", "", "", "", "", "", "Schwein", "", "", "Gans", ""}},
{"SVK: /-st/",
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
"Gans", "Gans", "Gans"}},
};
m_tests = {
{"W-Frage",
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
"Gans", "Gans", "Gans"}},
{"Verbtrennung", {"", "Affe", "", "", "", "", "", "Schwein", "", "", "Gans", ""}},
{"SVK: /-st/",
{"Affe", "Affe", "Affe", "Affe", "Schwein", "Schwein", "Schwein", "Schwein", "Gans",
"Gans", "Gans", "Gans"}},
};
}
unsigned int WFModel::getV2Points() const
{
unsigned int points = 0;
unsigned int points = 0;
for (auto testIndex : {0, 1})
{
const auto &test = m_tests.at(testIndex);
for (auto testIndex : {0, 1})
{
const auto& test = m_tests.at(testIndex);
for (const auto &item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
for (const auto& item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
return points;
return points;
}
unsigned int WFModel::getSvkPoints() const
{
unsigned int points = 0;
unsigned int points = 0;
for (auto testIndex : {2})
{
const auto &test = m_tests.at(testIndex);
for (auto testIndex : {2})
{
const auto& test = m_tests.at(testIndex);
for (const auto &item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
for (const auto& item : test.items())
{
if (item.isChecked())
{
points++;
}
}
}
return points;
return points;
}
bool WFModel::isValidIndex(const QModelIndex &index) const
bool WFModel::isValidIndex(const QModelIndex& index) const
{
if (index.row() == 1)
{
return index.column() == 1 || index.column() == 7 || index.column() == 10;
}
if (index.row() == 1)
{
return index.column() == 1 || index.column() == 7 || index.column() == 10;
}
return CheckableTestModel::isValidIndex(index);
return CheckableTestModel::isValidIndex(index);
}
void WFModel::write(ESGRAF48::V2SvkModel &model) const
void WFModel::write(ESGRAF48::V2SvkModel& model) const
{
auto writeOneVal = [&](ESGRAF48::V2SvkModel::OneEach *modelData, int testIndex) {
if (modelData != nullptr)
{
const auto &testItems = m_tests.at(testIndex).items();
auto writeOneVal = [&](ESGRAF48::V2SvkModel::OneEach* modelData, int testIndex) {
if (modelData != nullptr)
{
const auto& testItems = m_tests.at(testIndex).items();
modelData->set_affe(testItems[1].isChecked());
modelData->set_schwein(testItems[7].isChecked());
modelData->set_gans(testItems[10].isChecked());
}
};
modelData->set_affe(testItems[1].isChecked());
modelData->set_schwein(testItems[7].isChecked());
modelData->set_gans(testItems[10].isChecked());
}
};
auto writeFourVals = [&](ESGRAF48::V2SvkModel::FourEach *modelData, int testIndex) {
if (modelData != nullptr)
{
const auto &testItems = m_tests.at(testIndex).items();
auto writeFourVals = [&](ESGRAF48::V2SvkModel::FourEach* modelData, int testIndex) {
if (modelData != nullptr)
{
const auto& testItems = m_tests.at(testIndex).items();
modelData->set_affe1(testItems[0].isChecked());
modelData->set_affe2(testItems[1].isChecked());
modelData->set_affe3(testItems[2].isChecked());
modelData->set_affe4(testItems[3].isChecked());
modelData->set_schwein1(testItems[4].isChecked());
modelData->set_schwein2(testItems[5].isChecked());
modelData->set_schwein3(testItems[6].isChecked());
modelData->set_schwein4(testItems[7].isChecked());
modelData->set_gans1(testItems[8].isChecked());
modelData->set_gans2(testItems[9].isChecked());
modelData->set_gans3(testItems[10].isChecked());
modelData->set_gans4(testItems[11].isChecked());
}
};
modelData->set_affe1(testItems[0].isChecked());
modelData->set_affe2(testItems[1].isChecked());
modelData->set_affe3(testItems[2].isChecked());
modelData->set_affe4(testItems[3].isChecked());
modelData->set_schwein1(testItems[4].isChecked());
modelData->set_schwein2(testItems[5].isChecked());
modelData->set_schwein3(testItems[6].isChecked());
modelData->set_schwein4(testItems[7].isChecked());
modelData->set_gans1(testItems[8].isChecked());
modelData->set_gans2(testItems[9].isChecked());
modelData->set_gans3(testItems[10].isChecked());
modelData->set_gans4(testItems[11].isChecked());
}
};
writeFourVals(model.mutable_wfrage(), 0);
writeOneVal(model.mutable_verbtrennung1(), 1);
writeFourVals(model.mutable_wfrage(), 0);
writeOneVal(model.mutable_verbtrennung1(), 1);
}
void WFModel::read(const ESGRAF48::V2SvkModel &model)
void WFModel::read(const ESGRAF48::V2SvkModel& model)
{
auto readOneVal = [&](const ESGRAF48::V2SvkModel::OneEach &modelData, int testIndex) {
auto &testItems = m_tests.at(testIndex).items();
auto readOneVal = [&](const ESGRAF48::V2SvkModel::OneEach& modelData, int testIndex) {
auto& testItems = m_tests.at(testIndex).items();
testItems[1].setState(modelData.affe());
testItems[7].setState(modelData.schwein());
testItems[10].setState(modelData.gans());
};
testItems[1].setState(modelData.affe());
testItems[7].setState(modelData.schwein());
testItems[10].setState(modelData.gans());
};
auto readFourVals = [&](const ESGRAF48::V2SvkModel::FourEach &modelData, int testIndex) {
auto &testItems = m_tests.at(testIndex).items();
auto readFourVals = [&](const ESGRAF48::V2SvkModel::FourEach& modelData, int testIndex) {
auto& testItems = m_tests.at(testIndex).items();
testItems[0].setState(modelData.affe1());
testItems[1].setState(modelData.affe2());
testItems[2].setState(modelData.affe3());
testItems[3].setState(modelData.affe4());
testItems[4].setState(modelData.schwein1());
testItems[5].setState(modelData.schwein2());
testItems[6].setState(modelData.schwein3());
testItems[7].setState(modelData.schwein4());
testItems[8].setState(modelData.gans1());
testItems[9].setState(modelData.gans2());
testItems[10].setState(modelData.gans3());
testItems[11].setState(modelData.gans4());
};
testItems[0].setState(modelData.affe1());
testItems[1].setState(modelData.affe2());
testItems[2].setState(modelData.affe3());
testItems[3].setState(modelData.affe4());
testItems[4].setState(modelData.schwein1());
testItems[5].setState(modelData.schwein2());
testItems[6].setState(modelData.schwein3());
testItems[7].setState(modelData.schwein4());
testItems[8].setState(modelData.gans1());
testItems[9].setState(modelData.gans2());
testItems[10].setState(modelData.gans3());
testItems[11].setState(modelData.gans4());
};
readFourVals(model.wfrage(), 0);
readOneVal(model.verbtrennung1(), 1);
readFourVals(model.wfrage(), 0);
readOneVal(model.verbtrennung1(), 1);
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
std::set<int> WFModel::v2Tests() const
{
return {0, 1};
return {0, 1};
};
std::set<int> WFModel::svkTests() const
{
return {2};
return {2};
};

View file

@ -5,20 +5,20 @@
class WFModel : public V2SvkModel
{
Q_OBJECT
Q_OBJECT
public:
WFModel(QObject *parent);
WFModel(QObject* parent);
unsigned int getV2Points() const override;
unsigned int getSvkPoints() const override;
unsigned int getV2Points() const override;
unsigned int getSvkPoints() const override;
void write(ESGRAF48::V2SvkModel &model) const override;
void read(const ESGRAF48::V2SvkModel &model) override;
void write(ESGRAF48::V2SvkModel& model) const override;
void read(const ESGRAF48::V2SvkModel& model) override;
protected:
std::set<int> v2Tests() const override;
std::set<int> svkTests() const override;
std::set<int> v2Tests() const override;
std::set<int> svkTests() const override;
bool isValidIndex(const QModelIndex &index) const override;
bool isValidIndex(const QModelIndex& index) const override;
};

View file

@ -1,128 +1,128 @@
#include "VerbEndModel.h"
VerbEndModel::VerbEndModel(QObject *parent)
VerbEndModel::VerbEndModel(QObject* parent)
: PrintableModel(parent)
{
m_title = "Subtest 2: Verbendstellungsregel (VE)";
m_title = "Subtest 2: Verbendstellungsregel (VE)";
m_tests = {
{"Telefonat", {"Kausal", "Kausal", "Relativ", "Kausal", "Final", "Temporal", "Temporal"}},
{"Zaubertrick", {"Relativ", "Final", "Kausal", "Final", "Temporal", "Kausal", "Temporal"}},
{"Zauberregel", {"Temporal", "Kausal", "Final", "Relativ", "Temporal", "Relativ"}}};
m_tests = {
{"Telefonat", {"Kausal", "Kausal", "Relativ", "Kausal", "Final", "Temporal", "Temporal"}},
{"Zaubertrick", {"Relativ", "Final", "Kausal", "Final", "Temporal", "Kausal", "Temporal"}},
{"Zauberregel", {"Temporal", "Kausal", "Final", "Relativ", "Temporal", "Relativ"}}};
}
void VerbEndModel::write(ESGRAF48::VerbEndModel &model) const
void VerbEndModel::write(ESGRAF48::VerbEndModel& model) const
{
auto *telefonatModel = model.mutable_telefonat();
if (telefonatModel != nullptr)
{
const auto &testItems = m_tests.at(0).items();
auto* telefonatModel = model.mutable_telefonat();
if (telefonatModel != nullptr)
{
const auto& testItems = m_tests.at(0).items();
telefonatModel->set_kausal1(testItems[0].isChecked());
telefonatModel->set_kausal2(testItems[1].isChecked());
telefonatModel->set_relativ(testItems[2].isChecked());
telefonatModel->set_kausal3(testItems[3].isChecked());
telefonatModel->set_final(testItems[4].isChecked());
telefonatModel->set_temporal1(testItems[5].isChecked());
telefonatModel->set_temporal2(testItems[6].isChecked());
}
telefonatModel->set_kausal1(testItems[0].isChecked());
telefonatModel->set_kausal2(testItems[1].isChecked());
telefonatModel->set_relativ(testItems[2].isChecked());
telefonatModel->set_kausal3(testItems[3].isChecked());
telefonatModel->set_final(testItems[4].isChecked());
telefonatModel->set_temporal1(testItems[5].isChecked());
telefonatModel->set_temporal2(testItems[6].isChecked());
}
auto *zaubertrickModel = model.mutable_zaubertrick();
if (zaubertrickModel != nullptr)
{
const auto &testItems = m_tests.at(1).items();
auto* zaubertrickModel = model.mutable_zaubertrick();
if (zaubertrickModel != nullptr)
{
const auto& testItems = m_tests.at(1).items();
zaubertrickModel->set_relativ(testItems[0].isChecked());
zaubertrickModel->set_final1(testItems[1].isChecked());
zaubertrickModel->set_kausal1(testItems[2].isChecked());
zaubertrickModel->set_final2(testItems[3].isChecked());
zaubertrickModel->set_temporal1(testItems[4].isChecked());
zaubertrickModel->set_kausal2(testItems[5].isChecked());
zaubertrickModel->set_temporal2(testItems[6].isChecked());
}
zaubertrickModel->set_relativ(testItems[0].isChecked());
zaubertrickModel->set_final1(testItems[1].isChecked());
zaubertrickModel->set_kausal1(testItems[2].isChecked());
zaubertrickModel->set_final2(testItems[3].isChecked());
zaubertrickModel->set_temporal1(testItems[4].isChecked());
zaubertrickModel->set_kausal2(testItems[5].isChecked());
zaubertrickModel->set_temporal2(testItems[6].isChecked());
}
auto *zauberregelModel = model.mutable_zauberregel();
if (zauberregelModel != nullptr)
{
const auto &testItems = m_tests.at(2).items();
auto* zauberregelModel = model.mutable_zauberregel();
if (zauberregelModel != nullptr)
{
const auto& testItems = m_tests.at(2).items();
zauberregelModel->set_temporal1(testItems[0].isChecked());
zauberregelModel->set_kausal(testItems[1].isChecked());
zauberregelModel->set_final(testItems[2].isChecked());
zauberregelModel->set_relativ1(testItems[3].isChecked());
zauberregelModel->set_temporal2(testItems[4].isChecked());
zauberregelModel->set_relativ2(testItems[5].isChecked());
}
zauberregelModel->set_temporal1(testItems[0].isChecked());
zauberregelModel->set_kausal(testItems[1].isChecked());
zauberregelModel->set_final(testItems[2].isChecked());
zauberregelModel->set_relativ1(testItems[3].isChecked());
zauberregelModel->set_temporal2(testItems[4].isChecked());
zauberregelModel->set_relativ2(testItems[5].isChecked());
}
}
void VerbEndModel::read(const ESGRAF48::VerbEndModel &model)
void VerbEndModel::read(const ESGRAF48::VerbEndModel& model)
{
const auto &telefonatModel = model.telefonat();
{
auto &testItems = m_tests.at(0).items();
const auto& telefonatModel = model.telefonat();
{
auto& testItems = m_tests.at(0).items();
testItems[0].setState(telefonatModel.kausal1());
testItems[1].setState(telefonatModel.kausal2());
testItems[2].setState(telefonatModel.relativ());
testItems[3].setState(telefonatModel.kausal3());
testItems[4].setState(telefonatModel.final());
testItems[5].setState(telefonatModel.temporal1());
testItems[6].setState(telefonatModel.temporal2());
}
testItems[0].setState(telefonatModel.kausal1());
testItems[1].setState(telefonatModel.kausal2());
testItems[2].setState(telefonatModel.relativ());
testItems[3].setState(telefonatModel.kausal3());
testItems[4].setState(telefonatModel.final());
testItems[5].setState(telefonatModel.temporal1());
testItems[6].setState(telefonatModel.temporal2());
}
const auto &zaubertrickModel = model.zaubertrick();
{
auto &testItems = m_tests.at(1).items();
const auto& zaubertrickModel = model.zaubertrick();
{
auto& testItems = m_tests.at(1).items();
testItems[0].setState(zaubertrickModel.relativ());
testItems[1].setState(zaubertrickModel.final1());
testItems[2].setState(zaubertrickModel.kausal1());
testItems[3].setState(zaubertrickModel.final2());
testItems[4].setState(zaubertrickModel.temporal1());
testItems[5].setState(zaubertrickModel.kausal2());
testItems[6].setState(zaubertrickModel.temporal2());
}
testItems[0].setState(zaubertrickModel.relativ());
testItems[1].setState(zaubertrickModel.final1());
testItems[2].setState(zaubertrickModel.kausal1());
testItems[3].setState(zaubertrickModel.final2());
testItems[4].setState(zaubertrickModel.temporal1());
testItems[5].setState(zaubertrickModel.kausal2());
testItems[6].setState(zaubertrickModel.temporal2());
}
const auto &zauberregelModel = model.zauberregel();
{
auto &testItems = m_tests.at(2).items();
const auto& zauberregelModel = model.zauberregel();
{
auto& testItems = m_tests.at(2).items();
testItems[0].setState(zauberregelModel.temporal1());
testItems[1].setState(zauberregelModel.kausal());
testItems[2].setState(zauberregelModel.final());
testItems[3].setState(zauberregelModel.relativ1());
testItems[4].setState(zauberregelModel.temporal2());
testItems[5].setState(zauberregelModel.relativ2());
}
testItems[0].setState(zauberregelModel.temporal1());
testItems[1].setState(zauberregelModel.kausal());
testItems[2].setState(zauberregelModel.final());
testItems[3].setState(zauberregelModel.relativ1());
testItems[4].setState(zauberregelModel.temporal2());
testItems[5].setState(zauberregelModel.relativ2());
}
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
unsigned int VerbEndModel::getKausalPoints() const
{
auto points = [&](unsigned int testId, unsigned int itemId) {
return m_tests.at(testId).items().at(itemId).points();
};
auto points = [&](unsigned int testId, unsigned int itemId) {
return m_tests.at(testId).items().at(itemId).points();
};
return points(0, 0) + points(0, 1) + points(0, 3) + points(1, 2) + points(1, 5) + points(2, 1);
return points(0, 0) + points(0, 1) + points(0, 3) + points(1, 2) + points(1, 5) + points(2, 1);
}
void VerbEndModel::printSummary(QPainter &painter) const
void VerbEndModel::printSummary(QPainter& painter) const
{
painter.setFont(tableFont());
painter.setFont(tableFont());
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
auto width = painter.device()->width();
auto height = 1.5 * painter.fontMetrics().lineSpacing();
painter.drawText(0, 0, 0.71 * width, height, Qt::AlignRight | Qt::AlignVCenter,
"Rohwertpunkte Kausalsätze:");
painter.drawText(0, 0, 0.95 * width, height, Qt::AlignRight | Qt::AlignVCenter,
"Rohwertpunkte Total:");
painter.drawText(0, 0, 0.71 * width, height, Qt::AlignRight | Qt::AlignVCenter,
"Rohwertpunkte Kausalsätze:");
painter.drawText(0, 0, 0.95 * width, height, Qt::AlignRight | Qt::AlignVCenter,
"Rohwertpunkte Total:");
drawNumberSquare(painter, 0.73 * width, 0, getKausalPoints());
drawNumberSquare(painter, 0.73 * width, 0, getKausalPoints());
painter.setPen(resultPen());
drawNumberSquare(painter, 0.97 * width, 0, getKausalPoints());
painter.setPen(resultPen());
drawNumberSquare(painter, 0.97 * width, 0, getKausalPoints());
painter.translate(0, 3 * height);
painter.translate(0, 3 * height);
}

View file

@ -5,16 +5,16 @@
class VerbEndModel : public PrintableModel
{
Q_OBJECT
Q_OBJECT
public:
VerbEndModel(QObject *parent);
VerbEndModel(QObject* parent);
void write(ESGRAF48::VerbEndModel &model) const;
void read(const ESGRAF48::VerbEndModel &model);
void write(ESGRAF48::VerbEndModel& model) const;
void read(const ESGRAF48::VerbEndModel& model);
unsigned int getKausalPoints() const;
unsigned int getKausalPoints() const;
protected:
void printSummary(QPainter &painter) const override;
void printSummary(QPainter& painter) const override;
};

View file

@ -3,21 +3,21 @@
#include "VerbEndModel.h"
VerbEndWidget::VerbEndWidget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::VerbEndWidget)
VerbEndWidget::VerbEndWidget(QWidget* parent)
: QWidget(parent)
, ui(new Ui::VerbEndWidget)
{
ui->setupUi(this);
ui->setupUi(this);
ui->verbEndTableView->horizontalHeader()->hide();
ui->verbEndTableView->horizontalHeader()->hide();
}
VerbEndWidget::~VerbEndWidget()
{
delete ui;
delete ui;
}
void VerbEndWidget::setModel(VerbEndModel *model)
void VerbEndWidget::setModel(VerbEndModel* model)
{
ui->verbEndTableView->setModel(model);
ui->verbEndTableView->setModel(model);
}

View file

@ -10,14 +10,14 @@ class VerbEndWidget;
class VerbEndWidget : public QWidget
{
Q_OBJECT
Q_OBJECT
private:
Ui::VerbEndWidget *ui;
Ui::VerbEndWidget* ui;
public:
VerbEndWidget(QWidget *parent = nullptr);
~VerbEndWidget();
VerbEndWidget(QWidget* parent = nullptr);
~VerbEndWidget();
void setModel(VerbEndModel *model);
void setModel(VerbEndModel* model);
};

View file

@ -19,230 +19,230 @@
#include <fstream>
MainWindow::MainWindow(QWidget *parent)
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
, m_dataModel(this)
{
ui->setupUi(this);
setupUi();
ui->setupUi(this);
setupUi();
newFile();
newFile();
}
MainWindow::MainWindow(QWidget *parent, const QString &filename)
MainWindow::MainWindow(QWidget* parent, const QString& filename)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
, m_dataModel(this)
{
ui->setupUi(this);
setupUi();
ui->setupUi(this);
setupUi();
openFile(filename);
openFile(filename);
}
void MainWindow::setupUi()
{
ui->metaDataWidget->setModel(&m_dataModel.m_metaData);
ui->verbEndWidget->setModel(&m_dataModel.m_verbEnd);
ui->genusWidget->setModel(&m_dataModel.m_genus);
ui->pluralWidget->setModel(&m_dataModel.m_plural);
ui->akkusativDativWidget->setAkkusativModel(&m_dataModel.m_akkusativ);
ui->akkusativDativWidget->setDativModel(&m_dataModel.m_dativ);
ui->metaDataWidget->setModel(&m_dataModel.m_metaData);
ui->verbEndWidget->setModel(&m_dataModel.m_verbEnd);
ui->genusWidget->setModel(&m_dataModel.m_genus);
ui->pluralWidget->setModel(&m_dataModel.m_plural);
ui->akkusativDativWidget->setAkkusativModel(&m_dataModel.m_akkusativ);
ui->akkusativDativWidget->setDativModel(&m_dataModel.m_dativ);
ui->v2SvkWidget->setWFModel(&m_dataModel.m_wfModel);
ui->v2SvkWidget->setOTModel(&m_dataModel.m_otModel);
ui->v2SvkWidget->setTPrModel(&m_dataModel.m_tPrModel);
ui->v2SvkWidget->setTPeModel(&m_dataModel.m_tPeModel);
ui->v2SvkWidget->setWFModel(&m_dataModel.m_wfModel);
ui->v2SvkWidget->setOTModel(&m_dataModel.m_otModel);
ui->v2SvkWidget->setTPrModel(&m_dataModel.m_tPrModel);
ui->v2SvkWidget->setTPeModel(&m_dataModel.m_tPeModel);
ui->lateSkillsWidget->setPassivModel(&m_dataModel.m_passiv);
ui->lateSkillsWidget->setGenitivModel(&m_dataModel.m_genitiv);
ui->resultWidget->setModel(&m_dataModel.m_results);
ui->lateSkillsWidget->setPassivModel(&m_dataModel.m_passiv);
ui->lateSkillsWidget->setGenitivModel(&m_dataModel.m_genitiv);
ui->resultWidget->setModel(&m_dataModel.m_results);
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::newFile);
connect(ui->actionOpen, &QAction::triggered, this, qOverload<>(&MainWindow::openFile));
connect(ui->actionSave, &QAction::triggered, this, qOverload<>(&MainWindow::saveFile));
connect(ui->actionSave_as, &QAction::triggered, this, &MainWindow::saveFileAs);
connect(ui->actionPrint, &QAction::triggered, this, &MainWindow::print);
connect(ui->actionExport_PDF, &QAction::triggered, this, qOverload<>(&MainWindow::savePdf));
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::newFile);
connect(ui->actionOpen, &QAction::triggered, this, qOverload<>(&MainWindow::openFile));
connect(ui->actionSave, &QAction::triggered, this, qOverload<>(&MainWindow::saveFile));
connect(ui->actionSave_as, &QAction::triggered, this, &MainWindow::saveFileAs);
connect(ui->actionPrint, &QAction::triggered, this, &MainWindow::print);
connect(ui->actionExport_PDF, &QAction::triggered, this, qOverload<>(&MainWindow::savePdf));
connect(ui->actionAbout, &QAction::triggered, this, &MainWindow::aboutDialog);
connect(ui->actionAbout, &QAction::triggered, this, &MainWindow::aboutDialog);
connect(&m_dataModel, &DataModel::modelChanged, this, &MainWindow::dataModelChanged);
connect(&m_dataModel, &DataModel::modelChanged, this, &MainWindow::dataModelChanged);
}
MainWindow::~MainWindow()
{
delete ui;
delete ui;
}
void MainWindow::newFile()
{
closeFile();
closeFile();
setWindowModified(false);
setWindowTitle("untitled[*]");
m_filename = "";
m_saveOnClose = false;
setWindowModified(false);
setWindowTitle("untitled[*]");
m_filename = "";
m_saveOnClose = false;
}
void MainWindow::openFile()
{
QString filename =
QFileDialog::getOpenFileName(this, "Open file", "", "ESGRAF 4-8 (*.esgraf48)");
if (filename.isEmpty())
{
return;
}
QString filename =
QFileDialog::getOpenFileName(this, "Open file", "", "ESGRAF 4-8 (*.esgraf48)");
if (filename.isEmpty())
{
return;
}
try
{
openFile(filename);
}
catch (std::exception &e)
{
QString errorMessage = QString("Error loading \"") + filename + "\": " + e.what();
QMessageBox::critical(this, "Error", errorMessage);
}
try
{
openFile(filename);
}
catch (std::exception& e)
{
QString errorMessage = QString("Error loading \"") + filename + "\": " + e.what();
QMessageBox::critical(this, "Error", errorMessage);
}
}
void MainWindow::openFile(const QString &filename)
void MainWindow::openFile(const QString& filename)
{
closeFile();
closeFile();
m_dataModel.read(filename);
m_dataModel.read(filename);
setWindowModified(false);
setWindowTitle(filename + "[*]");
m_saveOnClose = false;
m_filename = filename;
setWindowModified(false);
setWindowTitle(filename + "[*]");
m_saveOnClose = false;
m_filename = filename;
ui->metaDataWidget->toFirst();
ui->metaDataWidget->toFirst();
}
void MainWindow::saveFile()
{
if (m_filename.isEmpty())
{
saveFileAs();
}
else
{
saveFile(m_filename);
}
if (m_filename.isEmpty())
{
saveFileAs();
}
else
{
saveFile(m_filename);
}
}
void MainWindow::saveFileAs()
{
QFileDialog saveFilenameDialog(this);
saveFilenameDialog.setAcceptMode(QFileDialog::AcceptSave);
saveFilenameDialog.setDefaultSuffix("esgraf48");
saveFilenameDialog.setFileMode(QFileDialog::AnyFile);
saveFilenameDialog.setNameFilter("ESGRAF 4-8 (*.esgraf48)");
saveFilenameDialog.setWindowTitle("Save file");
QFileDialog saveFilenameDialog(this);
saveFilenameDialog.setAcceptMode(QFileDialog::AcceptSave);
saveFilenameDialog.setDefaultSuffix("esgraf48");
saveFilenameDialog.setFileMode(QFileDialog::AnyFile);
saveFilenameDialog.setNameFilter("ESGRAF 4-8 (*.esgraf48)");
saveFilenameDialog.setWindowTitle("Save file");
if (!saveFilenameDialog.exec())
{
return;
}
if (!saveFilenameDialog.exec())
{
return;
}
saveFile(saveFilenameDialog.selectedFiles().first());
saveFile(saveFilenameDialog.selectedFiles().first());
}
void MainWindow::closeFile()
{
if (m_saveOnClose == true)
{
QMessageBox msgBox;
msgBox.setText("The document has been modified.");
msgBox.setInformativeText("Do you want to save your changes?");
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
msgBox.setDefaultButton(QMessageBox::Save);
if (m_saveOnClose == true)
{
QMessageBox msgBox;
msgBox.setText("The document has been modified.");
msgBox.setInformativeText("Do you want to save your changes?");
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
msgBox.setDefaultButton(QMessageBox::Save);
if (msgBox.exec() == QMessageBox::Save)
{
saveFile();
}
}
if (msgBox.exec() == QMessageBox::Save)
{
saveFile();
}
}
}
void MainWindow::print() const
{
QPrinter printer;
printer.setPaperSize(QPrinter::A4);
printer.setPageMargins(20, 20, 20, 20, QPrinter::Millimeter);
QPrinter printer;
printer.setPaperSize(QPrinter::A4);
printer.setPageMargins(20, 20, 20, 20, QPrinter::Millimeter);
QPrintDialog dialog(&printer);
if (dialog.exec() != QDialog::Accepted)
{
return;
}
QPrintDialog dialog(&printer);
if (dialog.exec() != QDialog::Accepted)
{
return;
}
m_dataModel.printTo(printer);
m_dataModel.printTo(printer);
}
void MainWindow::dataModelChanged()
{
m_saveOnClose = true;
setWindowModified(true);
m_saveOnClose = true;
setWindowModified(true);
}
void MainWindow::savePdf()
{
QFileDialog saveFilenameDialog(this);
saveFilenameDialog.setDefaultSuffix("pdf");
saveFilenameDialog.setFileMode(QFileDialog::AnyFile);
saveFilenameDialog.setNameFilter("PDF File (*.pdf)");
saveFilenameDialog.setWindowTitle("Save file");
QFileDialog saveFilenameDialog(this);
saveFilenameDialog.setDefaultSuffix("pdf");
saveFilenameDialog.setFileMode(QFileDialog::AnyFile);
saveFilenameDialog.setNameFilter("PDF File (*.pdf)");
saveFilenameDialog.setWindowTitle("Save file");
if (!saveFilenameDialog.exec())
{
return;
}
if (!saveFilenameDialog.exec())
{
return;
}
savePdf(saveFilenameDialog.selectedFiles().first());
savePdf(saveFilenameDialog.selectedFiles().first());
}
void MainWindow::closeEvent(QCloseEvent *event)
void MainWindow::closeEvent(QCloseEvent* event)
{
closeFile();
closeFile();
}
void MainWindow::saveFile(const QString &filename)
void MainWindow::saveFile(const QString& filename)
{
try
{
m_dataModel.write(filename);
}
catch (std::exception &e)
{
QString errorMessage = QString("Error saving \"") + filename + "\": " + e.what();
QMessageBox::critical(this, "Error", errorMessage);
return;
}
try
{
m_dataModel.write(filename);
}
catch (std::exception& e)
{
QString errorMessage = QString("Error saving \"") + filename + "\": " + e.what();
QMessageBox::critical(this, "Error", errorMessage);
return;
}
qDebug() << "Wrote" << filename;
qDebug() << "Wrote" << filename;
setWindowTitle(filename + "[*]");
setWindowModified(false);
m_filename = filename;
m_saveOnClose = false;
setWindowTitle(filename + "[*]");
setWindowModified(false);
m_filename = filename;
m_saveOnClose = false;
}
void MainWindow::savePdf(const QString &filename)
void MainWindow::savePdf(const QString& filename)
{
QPrinter printer;
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setPaperSize(QPrinter::A4);
printer.setPageMargins(20, 20, 20, 20, QPrinter::Millimeter);
printer.setOutputFileName(filename);
QPrinter printer;
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setPaperSize(QPrinter::A4);
printer.setPageMargins(20, 20, 20, 20, QPrinter::Millimeter);
printer.setOutputFileName(filename);
m_dataModel.printTo(printer);
m_dataModel.printTo(printer);
}
void MainWindow::aboutDialog()
{
QString infoString =
QString::fromUtf8(ESGRAF48_DESCRIPTION) + " Version " + QString::fromUtf8(ESGRAF48_VERSION);
QMessageBox::information(this, ESGRAF48_DESCRIPTION, infoString);
QString infoString =
QString::fromUtf8(ESGRAF48_DESCRIPTION) + " Version " + QString::fromUtf8(ESGRAF48_VERSION);
QMessageBox::information(this, ESGRAF48_DESCRIPTION, infoString);
}

View file

@ -6,7 +6,6 @@
#include <QString>
#include <QFont>
class DataModel;
class QDataWidgetMapper;
@ -16,36 +15,36 @@ class MainWindow;
class MainWindow : public QMainWindow
{
Q_OBJECT
Q_OBJECT
private:
Ui::MainWindow *ui;
DataModel m_dataModel;
QString m_filename;
bool m_saveOnClose = false;
Ui::MainWindow* ui;
DataModel m_dataModel;
QString m_filename;
bool m_saveOnClose = false;
public:
MainWindow(QWidget *parent);
MainWindow(QWidget *parent, const QString &filename);
~MainWindow();
MainWindow(QWidget* parent);
MainWindow(QWidget* parent, const QString& filename);
~MainWindow();
public slots:
void newFile();
void openFile();
void openFile(const QString &filename);
void saveFile();
void saveFileAs();
void closeFile();
void print() const;
void dataModelChanged();
void savePdf();
void aboutDialog();
void newFile();
void openFile();
void openFile(const QString& filename);
void saveFile();
void saveFileAs();
void closeFile();
void print() const;
void dataModelChanged();
void savePdf();
void aboutDialog();
protected:
void closeEvent(QCloseEvent *event) override;
void closeEvent(QCloseEvent* event) override;
private:
void setupUi();
void saveFile(const QString &filename);
void savePdf(const QString &filename);
void setupUi();
void saveFile(const QString& filename);
void savePdf(const QString& filename);
};

View file

@ -4,37 +4,37 @@
TEST_CASE("default initialization")
{
Age age;
REQUIRE(age.years() == 0);
REQUIRE(age.months() == 0);
REQUIRE(age.toString() == "0;0");
Age age;
REQUIRE(age.years() == 0);
REQUIRE(age.months() == 0);
REQUIRE(age.toString() == "0;0");
Age age2;
REQUIRE(!(age < age));
REQUIRE(!(age < age2));
Age age2;
REQUIRE(!(age < age));
REQUIRE(!(age < age2));
}
TEST_CASE("year/month initialization")
{
for (unsigned int year = 0; year <= 100; ++year)
{
for (unsigned int month = 0; month < 12; ++month)
{
Age age(year, month);
for (unsigned int year = 0; year <= 100; ++year)
{
for (unsigned int month = 0; month < 12; ++month)
{
Age age(year, month);
REQUIRE(age.years() == year);
REQUIRE(age.months() == month);
}
}
REQUIRE(age.years() == year);
REQUIRE(age.months() == month);
}
}
}
TEST_CASE("age by reference")
{
QDate birth(1970, 1, 1);
QDate reference(1980, 1, 1);
QDate birth(1970, 1, 1);
QDate reference(1980, 1, 1);
Age age(birth, reference);
Age age(birth, reference);
REQUIRE(age.years() == 10);
REQUIRE(age.months() == 0);
REQUIRE(age.years() == 10);
REQUIRE(age.months() == 0);
}

View file

@ -2,6 +2,5 @@
TEST_CASE("Dummy")
{
REQUIRE(true == true);
REQUIRE(true == true);
}