connected meta-data widget
This commit is contained in:
parent
c7c4104f1a
commit
64400a0e94
6 changed files with 42 additions and 73 deletions
|
@ -1,6 +1,8 @@
|
|||
#include "DataModel.h"
|
||||
|
||||
DataModel::DataModel(QObject *parent) : QObject(parent), m_metaData(this)
|
||||
DataModel::DataModel(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_metaData(this)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
#include "MetaDataWidget.h"
|
||||
#include "ui_MetaDataWidget.h"
|
||||
|
||||
#include "MetaDataModel.h"
|
||||
|
||||
#include <QDataWidgetMapper>
|
||||
|
||||
MetaDataWidget::MetaDataWidget(QWidget *parent)
|
||||
: QWidget(parent), ui(new Ui::MetaDataWidget)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::MetaDataWidget)
|
||||
, m_widgetMapper(new QDataWidgetMapper(this))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
@ -12,3 +18,18 @@ MetaDataWidget::~MetaDataWidget()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
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->toFirst();
|
||||
}
|
||||
|
||||
void MetaDataWidget::toFirst()
|
||||
{
|
||||
m_widgetMapper->toFirst();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
#include <QWidget>
|
||||
|
||||
class QDataWidgetMapper;
|
||||
class MetaDataModel;
|
||||
|
||||
namespace Ui {
|
||||
class MetaDataWidget;
|
||||
};
|
||||
|
@ -12,8 +15,12 @@ class MetaDataWidget : public QWidget
|
|||
|
||||
private:
|
||||
Ui::MetaDataWidget *ui;
|
||||
QDataWidgetMapper *m_widgetMapper;
|
||||
|
||||
public:
|
||||
MetaDataWidget(QWidget *parent = nullptr);
|
||||
~MetaDataWidget();
|
||||
|
||||
void setModel(MetaDataModel *model);
|
||||
void toFirst();
|
||||
};
|
||||
|
|
|
@ -11,25 +11,21 @@
|
|||
#include <QDataWidgetMapper>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow),
|
||||
m_dataModel(new DataModel(parent))
|
||||
, m_widgetMapper(new QDataWidgetMapper(parent))
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
, m_dataModel(new DataModel(parent))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->actionSave_as->setIcon(QIcon::fromTheme("document-save-as", QIcon("/usr/share/gtk-doc/html/gtk2/document-save-as.png")));
|
||||
ui->actionLoad->setIcon(QIcon::fromTheme("document-open", QIcon("/usr/share/gtk-doc/html/gtk2/document-open.png")));
|
||||
ui->actionSave_as->setIcon(QIcon::fromTheme("document-save-as",
|
||||
QIcon("/usr/share/gtk-doc/html/gtk2/document-save-as.png")));
|
||||
ui->actionLoad->setIcon(QIcon::fromTheme("document-open",
|
||||
QIcon("/usr/share/gtk-doc/html/gtk2/document-open.png")));
|
||||
|
||||
connect(ui->actionSave_as, SIGNAL(triggered()), this, SLOT(saveAs()));
|
||||
connect(ui->actionLoad, SIGNAL(triggered()), this, SLOT(load()));
|
||||
|
||||
m_widgetMapper->setModel(&m_dataModel->m_metaData);
|
||||
m_widgetMapper->addMapping(ui->lineEdit, 0);
|
||||
m_widgetMapper->addMapping(ui->lineEdit_2, 1);
|
||||
m_widgetMapper->addMapping(ui->dateEdit, 2);
|
||||
m_widgetMapper->addMapping(ui->dateEdit_2, 3);
|
||||
m_widgetMapper->addMapping(ui->plainTextEdit, 4);
|
||||
m_widgetMapper->toFirst();
|
||||
ui->metaDataWidget->setModel(&m_dataModel->m_metaData);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -76,5 +72,5 @@ void MainWindow::load()
|
|||
|
||||
m_dataModel->read(loadDoc.object());
|
||||
|
||||
m_widgetMapper->toFirst();
|
||||
ui->metaDataWidget->toFirst();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ class MainWindow : public QMainWindow
|
|||
private:
|
||||
Ui::MainWindow *ui;
|
||||
DataModel *m_dataModel;
|
||||
QDataWidgetMapper *m_widgetMapper;
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
|
|
|
@ -15,62 +15,6 @@
|
|||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Untersuchungsdatum</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Geburtsdatum</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Name, Vorname</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLineEdit" name="lineEdit_2"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Untersucher(in)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDateEdit" name="dateEdit"/>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QDateEdit" name="dateEdit_2"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Bemerkungen</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
|
|
Loading…
Reference in a new issue