Display causal sentence point count below subtest 2

feature/print-as-qtextdocument
mandlm 2018-12-12 21:33:44 +01:00
parent 98196e05d6
commit 8ef56f1855
5 changed files with 71 additions and 2 deletions

View File

@ -1,6 +1,7 @@
#include "VerbEndModel.h"
#include <QTextTable>
#include <QDebug>
VerbEndModel::VerbEndModel(QObject *parent)
: CheckableTestModel(parent)
@ -9,6 +10,8 @@ VerbEndModel::VerbEndModel(QObject *parent)
{"Telefonat", {"Kausal", "Kausal", "Relativ", "Kausal", "Final", "Temporal", "Temporal"}},
{"Zaubertrick", {"Relativ", "Final", "Kausal", "Final", "Temporal", "Kausal", "Temporal"}},
{"Zauberregel", {"Temporal", "Kausal", "Final", "Relativ", "Temporal", "Relativ"}}};
connect(this, &VerbEndModel::dataChanged, this, &VerbEndModel::modelChanged);
}
void VerbEndModel::write(ESGRAF48::VerbEndModel &model) const
@ -98,7 +101,31 @@ void VerbEndModel::read(const ESGRAF48::VerbEndModel &model)
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
unsigned int VerbEndModel::getCausalPoints() const
{
unsigned int points = 0;
for (const auto &test : m_tests)
{
for (const auto &item : test.items())
{
if (item.getText() == "Kausal")
{
points += item.points();
}
}
}
return points;
}
void VerbEndModel::modelChanged()
{
emit causalPointsChanged(getCausalPoints());
}
std::string VerbEndModel::getName() const
{
return "Subtest 2: Verbendstellungsregel (VE)";
};

View File

@ -15,6 +15,14 @@ public:
void write(ESGRAF48::VerbEndModel &model) const;
void read(const ESGRAF48::VerbEndModel &model);
unsigned int getCausalPoints() const;
protected:
std::string getName() const override;
private slots:
void modelChanged();
signals:
void causalPointsChanged(unsigned int points);
};

View File

@ -20,4 +20,11 @@ VerbEndWidget::~VerbEndWidget()
void VerbEndWidget::setModel(VerbEndModel *model)
{
ui->verbEndTableView->setModel(model);
connect(model, &VerbEndModel::causalPointsChanged, this, &VerbEndWidget::causalPointsChanged);
}
void VerbEndWidget::causalPointsChanged(unsigned int points)
{
ui->causalPointsLabel->setText(QString::number(points));
}

View File

@ -20,4 +20,7 @@ public:
~VerbEndWidget();
void setModel(VerbEndModel *model);
public slots:
void causalPointsChanged(unsigned int points);
};

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>556</width>
<height>210</height>
<width>732</width>
<height>381</height>
</rect>
</property>
<property name="windowTitle">
@ -17,6 +17,30 @@
<item>
<widget class="QTableView" name="verbEndTableView"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Kausalsätze: </string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="causalPointsLabel">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>