added age display to meta-data tab
This commit is contained in:
parent
017ff01a83
commit
060348fdc5
@ -1,6 +1,7 @@
|
|||||||
#include "Age.h"
|
#include "Age.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
Age::Age(unsigned int years, unsigned int months)
|
Age::Age(unsigned int years, unsigned int months)
|
||||||
: m_years(years)
|
: m_years(years)
|
||||||
@ -56,3 +57,10 @@ 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();
|
||||||
|
}
|
||||||
|
@ -17,4 +17,6 @@ public:
|
|||||||
|
|
||||||
unsigned int years() const;
|
unsigned int years() const;
|
||||||
unsigned int months() const;
|
unsigned int months() const;
|
||||||
|
|
||||||
|
std::string toString() const;
|
||||||
};
|
};
|
||||||
|
@ -15,14 +15,14 @@ int MetaDataModel::rowCount(const QModelIndex &parent) const
|
|||||||
|
|
||||||
int MetaDataModel::columnCount(const QModelIndex &parent) const
|
int MetaDataModel::columnCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
return 5;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant MetaDataModel::data(const QModelIndex &index, int role) const
|
QVariant MetaDataModel::data(const QModelIndex &modelIndex, int role) const
|
||||||
{
|
{
|
||||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
||||||
{
|
{
|
||||||
switch (index.column())
|
switch (modelIndex.column())
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return m_participant;
|
return m_participant;
|
||||||
@ -34,6 +34,8 @@ QVariant MetaDataModel::data(const QModelIndex &index, int role) const
|
|||||||
return m_dateOfTest;
|
return m_dateOfTest;
|
||||||
case 4:
|
case 4:
|
||||||
return m_remarks;
|
return m_remarks;
|
||||||
|
case 5:
|
||||||
|
return QString::fromStdString(getAge().toString());
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -42,22 +44,22 @@ QVariant MetaDataModel::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags MetaDataModel::flags(const QModelIndex &index) const
|
Qt::ItemFlags MetaDataModel::flags(const QModelIndex &modelIndex) const
|
||||||
{
|
{
|
||||||
return QAbstractTableModel::flags(index) | Qt::ItemIsEditable;
|
return QAbstractTableModel::flags(modelIndex) | Qt::ItemIsEditable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MetaDataModel::setData(
|
bool MetaDataModel::setData(
|
||||||
const QModelIndex &index, const QVariant &value, int role)
|
const QModelIndex &modelIndex, const QVariant &value, int role)
|
||||||
{
|
{
|
||||||
if (role != Qt::EditRole)
|
if (role != Qt::EditRole)
|
||||||
{
|
{
|
||||||
return QAbstractTableModel::setData(index, value, role);
|
return QAbstractTableModel::setData(modelIndex, value, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool valueChanged = false;
|
bool valueChanged = false;
|
||||||
|
|
||||||
switch (index.column())
|
switch (modelIndex.column())
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (value.toString() != m_participant)
|
if (value.toString() != m_participant)
|
||||||
@ -77,6 +79,7 @@ bool MetaDataModel::setData(
|
|||||||
if (value.toDate() != m_dateOfBirth)
|
if (value.toDate() != m_dateOfBirth)
|
||||||
{
|
{
|
||||||
m_dateOfBirth = value.toDate();
|
m_dateOfBirth = value.toDate();
|
||||||
|
emit dataChanged(index(0, 5), index(0, 5));
|
||||||
valueChanged = true;
|
valueChanged = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -84,6 +87,7 @@ bool MetaDataModel::setData(
|
|||||||
if (value.toDate() != m_dateOfTest)
|
if (value.toDate() != m_dateOfTest)
|
||||||
{
|
{
|
||||||
m_dateOfTest = value.toDate();
|
m_dateOfTest = value.toDate();
|
||||||
|
emit dataChanged(index(0, 5), index(0, 5));
|
||||||
valueChanged = true;
|
valueChanged = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -100,7 +104,7 @@ bool MetaDataModel::setData(
|
|||||||
|
|
||||||
if (valueChanged)
|
if (valueChanged)
|
||||||
{
|
{
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(modelIndex, modelIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return valueChanged;
|
return valueChanged;
|
||||||
|
@ -26,6 +26,7 @@ void MetaDataWidget::setModel(MetaDataModel *model)
|
|||||||
m_widgetMapper->addMapping(ui->dateOfBirthDateEdit, 2);
|
m_widgetMapper->addMapping(ui->dateOfBirthDateEdit, 2);
|
||||||
m_widgetMapper->addMapping(ui->dateOfTestDateEdit, 3);
|
m_widgetMapper->addMapping(ui->dateOfTestDateEdit, 3);
|
||||||
m_widgetMapper->addMapping(ui->remarksPlainTextEdit, 4);
|
m_widgetMapper->addMapping(ui->remarksPlainTextEdit, 4);
|
||||||
|
m_widgetMapper->addMapping(ui->ageLineEdit, 5);
|
||||||
m_widgetMapper->toFirst();
|
m_widgetMapper->toFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,46 +16,102 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="upperArea" native="true">
|
<widget class="QWidget" name="upperArea" native="true">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item row="2" column="2">
|
<item>
|
||||||
<widget class="QLabel" name="dateOfTestLabel">
|
<layout class="QHBoxLayout" name="personsLayout">
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Untersuchungsdatum</string>
|
<widget class="QLabel" name="participantLabel">
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>Name, Vorname</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="participantLineEdit"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="instructorLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Untersucher(in)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="instructorLineEdit"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item>
|
||||||
<widget class="QLineEdit" name="participantLineEdit"/>
|
<layout class="QHBoxLayout" name="datesLayout">
|
||||||
</item>
|
<item>
|
||||||
<item row="2" column="0">
|
<widget class="QLabel" name="dateOfBirthLabel">
|
||||||
<widget class="QLabel" name="dateOfBirthLabel">
|
<property name="text">
|
||||||
<property name="text">
|
<string>Geburtsdatum</string>
|
||||||
<string>Geburtsdatum</string>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
</widget>
|
</item>
|
||||||
</item>
|
<item>
|
||||||
<item row="1" column="0">
|
<widget class="QDateEdit" name="dateOfBirthDateEdit"/>
|
||||||
<widget class="QLabel" name="participantLabel">
|
</item>
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Name, Vorname</string>
|
<widget class="QLabel" name="dateOfTestLabel">
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>Untersuchungsdatum</string>
|
||||||
</item>
|
</property>
|
||||||
<item row="1" column="3">
|
</widget>
|
||||||
<widget class="QLineEdit" name="instructorLineEdit"/>
|
</item>
|
||||||
</item>
|
<item>
|
||||||
<item row="1" column="2">
|
<widget class="QDateEdit" name="dateOfTestDateEdit"/>
|
||||||
<widget class="QLabel" name="instructorLabel">
|
</item>
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Untersucher(in)</string>
|
<spacer name="horizontalSpacer">
|
||||||
</property>
|
<property name="orientation">
|
||||||
</widget>
|
<enum>Qt::Horizontal</enum>
|
||||||
</item>
|
</property>
|
||||||
<item row="2" column="3">
|
<property name="sizeHint" stdset="0">
|
||||||
<widget class="QDateEdit" name="dateOfTestDateEdit"/>
|
<size>
|
||||||
</item>
|
<width>40</width>
|
||||||
<item row="2" column="1">
|
<height>20</height>
|
||||||
<widget class="QDateEdit" name="dateOfBirthDateEdit"/>
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="ageLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Alter am Testtag</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="ageLineEdit">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::NoFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -122,7 +122,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<action name="actionSave_as">
|
<action name="actionSave_as">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="mainwindow.qrc">
|
<iconset>
|
||||||
<normaloff>:/images/document-save-as.png</normaloff>:/images/document-save-as.png</iconset>
|
<normaloff>:/images/document-save-as.png</normaloff>:/images/document-save-as.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -137,7 +137,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionOpen">
|
<action name="actionOpen">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="mainwindow.qrc">
|
<iconset>
|
||||||
<normaloff>:/images/document-open.png</normaloff>:/images/document-open.png</iconset>
|
<normaloff>:/images/document-open.png</normaloff>:/images/document-open.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -149,7 +149,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionNew">
|
<action name="actionNew">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="mainwindow.qrc">
|
<iconset>
|
||||||
<normaloff>:/images/document-new.png</normaloff>:/images/document-new.png</iconset>
|
<normaloff>:/images/document-new.png</normaloff>:/images/document-new.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -169,7 +169,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionSave">
|
<action name="actionSave">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="mainwindow.qrc">
|
<iconset>
|
||||||
<normaloff>:/images/document-save-as.png</normaloff>:/images/document-save-as.png</iconset>
|
<normaloff>:/images/document-save-as.png</normaloff>:/images/document-save-as.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
Reference in New Issue
Block a user