initial commit

This commit is contained in:
2019-10-08 23:22:18 +02:00
parent f7593bd416
commit cee60c1a25
4 changed files with 37 additions and 1 deletions
+9
View File
@@ -97,16 +97,25 @@ void cMonthlyItemDelegate::setModelData ( QWidget *editor, QAbstractItemModel *m
model->setData(index, "", Qt::EditRole); model->setData(index, "", Qt::EditRole);
else else
model->setData(index, lpTimeEdit->time().toString(), Qt::EditRole); model->setData(index, lpTimeEdit->time().toString(), Qt::EditRole);
emit timeChanged(index.row()+1, index.column(), lpTimeEdit->time());
break; break;
} }
case COL_CODE: case COL_CODE:
{ {
QComboBox* lpComboBox = qobject_cast<QComboBox*>(editor); QComboBox* lpComboBox = qobject_cast<QComboBox*>(editor);
model->setData(index, m_code.key(lpComboBox->currentText()), Qt::EditRole); model->setData(index, m_code.key(lpComboBox->currentText()), Qt::EditRole);
emit textChanged(index.row()+1, index.column(), lpComboBox->currentText());
break; break;
} }
case COL_INFORMATION: case COL_INFORMATION:
QStyledItemDelegate::setModelData(editor, model, index); QStyledItemDelegate::setModelData(editor, model, index);
emit textChanged(index.row()+1, index.column(), model->data(index, Qt::EditRole).toString());
break; break;
default: default:
break; break;
+2
View File
@@ -22,6 +22,8 @@ public:
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
signals: signals:
void timeChanged(const int day, const int field, const QTime& time) const;
void textChanged(const int day, const int field, const QString& text) const;
private: private:
QMap<QString, QString> m_code; QMap<QString, QString> m_code;
+20
View File
@@ -3,6 +3,8 @@
#include "common.h" #include "common.h"
#include <QDebug>
cMonthlyView::cMonthlyView(const QDate& date, QWidget *parent) : cMonthlyView::cMonthlyView(const QDate& date, QWidget *parent) :
QWidget(parent), QWidget(parent),
@@ -18,9 +20,13 @@ cMonthlyView::cMonthlyView(const QDate& date, QWidget *parent) :
m_lpMonthlyListModel = new QStandardItemModel(0, 1); m_lpMonthlyListModel = new QStandardItemModel(0, 1);
ui->m_lpMonthlyList->setModel(m_lpMonthlyListModel); ui->m_lpMonthlyList->setModel(m_lpMonthlyListModel);
ui->m_lpMonthlyList->setItemDelegate(new cMonthlyItemDelegate(m_code)); ui->m_lpMonthlyList->setItemDelegate(new cMonthlyItemDelegate(m_code));
setDate(date); setDate(date);
connect(static_cast<cMonthlyItemDelegate*>(ui->m_lpMonthlyList->itemDelegate()), &cMonthlyItemDelegate::timeChanged, this, &cMonthlyView::onTimeChanged);
connect(static_cast<cMonthlyItemDelegate*>(ui->m_lpMonthlyList->itemDelegate()), &cMonthlyItemDelegate::textChanged, this, &cMonthlyView::onTextChanged);
} }
void cMonthlyView::setDate(const QDate& date) void cMonthlyView::setDate(const QDate& date)
@@ -116,3 +122,17 @@ cMonthlyView::~cMonthlyView()
{ {
delete ui; delete ui;
} }
void cMonthlyView::onTimeChanged(const int day, const int field, const QTime& time)
{
qDebug() << "Day: " << day;
qDebug() << "field: " << field;
qDebug() << "time: " << time;
}
void cMonthlyView::onTextChanged(const int day, const int field, const QString& text)
{
qDebug() << "Day: " << day;
qDebug() << "field: " << field;
qDebug() << "time: " << text;
}
+6 -1
View File
@@ -7,6 +7,7 @@
#include <QWidget> #include <QWidget>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QMap> #include <QMap>
#include <QTime>
namespace Ui { namespace Ui {
@@ -21,11 +22,15 @@ public:
explicit cMonthlyView(const QDate& date, QWidget *parent = nullptr); explicit cMonthlyView(const QDate& date, QWidget *parent = nullptr);
~cMonthlyView(); ~cMonthlyView();
void setDate(const QDate& date); void setDate(const QDate& date);
private: private:
Ui::cMonthlyView* ui; Ui::cMonthlyView* ui;
QStandardItemModel* m_lpMonthlyListModel; QStandardItemModel* m_lpMonthlyListModel;
QMap<QString, QString> m_code; QMap<QString, QString> m_code;
private slots:
void onTimeChanged(const int day, const int field, const QTime& time);
void onTextChanged(const int day, const int field, const QString& text);
}; };
#endif // CMONTHLYVIEW_H #endif // CMONTHLYVIEW_H