2017-12-05 21:03:03 +01:00
|
|
|
#include "timeassignmentdialog.h"
|
|
|
|
|
#include "ui_timeassignmentdialog.h"
|
2017-12-02 10:50:30 +01:00
|
|
|
|
2017-12-02 19:11:49 +01:00
|
|
|
#include <QMap>
|
2017-12-02 10:50:30 +01:00
|
|
|
#include <QStringBuilder>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
2017-12-03 22:22:07 +01:00
|
|
|
#include "zeiterfassungsettings.h"
|
|
|
|
|
|
2017-12-05 21:16:46 +01:00
|
|
|
TimeAssignmentDialog::TimeAssignmentDialog(const QMap<QString, QString> &projects, const ZeiterfassungSettings &settings,
|
2017-12-03 18:54:03 +01:00
|
|
|
QWidget *parent) :
|
2017-12-02 10:50:30 +01:00
|
|
|
QDialog(parent),
|
2017-12-05 21:03:03 +01:00
|
|
|
ui(new Ui::TimeAssignmentDialog)
|
2017-12-02 10:50:30 +01:00
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
2017-12-03 18:54:03 +01:00
|
|
|
{
|
2017-12-05 21:16:46 +01:00
|
|
|
for(const auto &preferedProject : settings.projects())
|
2017-12-03 18:54:03 +01:00
|
|
|
{
|
2017-12-05 21:16:46 +01:00
|
|
|
if(!projects.contains(preferedProject))
|
2017-12-03 18:54:03 +01:00
|
|
|
{
|
2017-12-05 21:16:46 +01:00
|
|
|
qWarning() << "cannot find project" << preferedProject;
|
2017-12-03 18:54:03 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-05 21:16:46 +01:00
|
|
|
ui->comboBoxProject->addItem(projects.value(preferedProject) % " (" % preferedProject % ')', preferedProject);
|
2017-12-03 18:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-05 21:16:46 +01:00
|
|
|
if(settings.projects().count())
|
|
|
|
|
ui->comboBoxProject->insertSeparator(ui->comboBoxProject->count());
|
2017-12-03 18:54:03 +01:00
|
|
|
|
2017-12-05 21:16:46 +01:00
|
|
|
for(auto iter = projects.constBegin(); iter != projects.constEnd(); iter++)
|
2017-12-03 18:54:03 +01:00
|
|
|
{
|
2017-12-05 21:16:46 +01:00
|
|
|
if(!settings.projects().contains(iter.key()))
|
|
|
|
|
ui->comboBoxProject->addItem(iter.value() % " (" % iter.key() % ')', iter.key());
|
2017-12-03 18:54:03 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-05 21:16:46 +01:00
|
|
|
for(const auto &subproject : settings.subprojects())
|
|
|
|
|
ui->comboBoxSubproject->addItem(subproject);
|
|
|
|
|
ui->comboBoxSubproject->clearEditText();
|
2017-12-03 18:54:03 +01:00
|
|
|
|
2017-12-03 22:22:07 +01:00
|
|
|
for(const auto &workpackage : settings.workpackages())
|
2017-12-03 18:54:03 +01:00
|
|
|
ui->comboBoxWorkpackage->addItem(workpackage);
|
|
|
|
|
ui->comboBoxWorkpackage->clearEditText();
|
|
|
|
|
|
2017-12-03 22:22:07 +01:00
|
|
|
for(const auto &text : settings.texte())
|
2017-12-03 18:54:03 +01:00
|
|
|
ui->comboBoxText->addItem(text);
|
|
|
|
|
ui->comboBoxText->clearEditText();
|
2017-12-02 10:50:30 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-05 21:03:03 +01:00
|
|
|
TimeAssignmentDialog::~TimeAssignmentDialog()
|
2017-12-02 10:50:30 +01:00
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-05 21:03:03 +01:00
|
|
|
QTime TimeAssignmentDialog::getTime() const
|
2017-12-02 10:50:30 +01:00
|
|
|
{
|
|
|
|
|
return ui->timeEditTime->time();
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-05 21:03:03 +01:00
|
|
|
void TimeAssignmentDialog::setTime(const QTime &time)
|
2017-12-02 10:50:30 +01:00
|
|
|
{
|
|
|
|
|
ui->timeEditTime->setTime(time);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-05 21:03:03 +01:00
|
|
|
QTime TimeAssignmentDialog::getTimespan() const
|
2017-12-02 10:50:30 +01:00
|
|
|
{
|
|
|
|
|
return ui->timeEditTimespan->time();
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-05 21:03:03 +01:00
|
|
|
void TimeAssignmentDialog::setTimespan(const QTime ×pan)
|
2017-12-02 10:50:30 +01:00
|
|
|
{
|
|
|
|
|
ui->timeEditTimespan->setTime(timespan);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-05 21:16:46 +01:00
|
|
|
QString TimeAssignmentDialog::getProject() const
|
2017-12-02 10:50:30 +01:00
|
|
|
{
|
2017-12-05 21:16:46 +01:00
|
|
|
return ui->comboBoxProject->currentData().toString();
|
2017-12-02 10:50:30 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-05 21:16:46 +01:00
|
|
|
void TimeAssignmentDialog::setProject(const QString &project)
|
2017-12-02 10:50:30 +01:00
|
|
|
{
|
2017-12-05 21:16:46 +01:00
|
|
|
auto index = ui->comboBoxProject->findData(project);
|
2017-12-02 10:50:30 +01:00
|
|
|
if(index >= 0)
|
2017-12-05 21:16:46 +01:00
|
|
|
ui->comboBoxProject->setCurrentIndex(index);
|
2017-12-02 10:50:30 +01:00
|
|
|
else
|
2017-12-05 21:16:46 +01:00
|
|
|
qWarning() << "could not find project" << project;
|
2017-12-02 10:50:30 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-05 21:16:46 +01:00
|
|
|
QString TimeAssignmentDialog::getSubproject() const
|
2017-12-02 10:50:30 +01:00
|
|
|
{
|
2017-12-05 21:16:46 +01:00
|
|
|
return ui->comboBoxSubproject->currentText();
|
2017-12-02 10:50:30 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-05 21:16:46 +01:00
|
|
|
void TimeAssignmentDialog::setSubproject(const QString &subproject)
|
2017-12-02 10:50:30 +01:00
|
|
|
{
|
2017-12-05 21:16:46 +01:00
|
|
|
ui->comboBoxSubproject->setCurrentText(subproject);
|
2017-12-02 10:50:30 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-05 21:03:03 +01:00
|
|
|
QString TimeAssignmentDialog::getWorkpackage() const
|
2017-12-02 10:50:30 +01:00
|
|
|
{
|
2017-12-03 18:54:03 +01:00
|
|
|
return ui->comboBoxWorkpackage->currentText();
|
2017-12-02 10:50:30 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-05 21:03:03 +01:00
|
|
|
void TimeAssignmentDialog::setWorkpackage(const QString &workpackage)
|
2017-12-02 10:50:30 +01:00
|
|
|
{
|
2017-12-03 18:54:03 +01:00
|
|
|
ui->comboBoxWorkpackage->setCurrentText(workpackage);
|
2017-12-02 10:50:30 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-05 21:03:03 +01:00
|
|
|
QString TimeAssignmentDialog::getText() const
|
2017-12-02 10:50:30 +01:00
|
|
|
{
|
2017-12-03 18:54:03 +01:00
|
|
|
return ui->comboBoxText->currentText();
|
2017-12-02 10:50:30 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-05 21:03:03 +01:00
|
|
|
void TimeAssignmentDialog::setText(const QString &text)
|
2017-12-02 10:50:30 +01:00
|
|
|
{
|
2017-12-03 18:54:03 +01:00
|
|
|
ui->comboBoxText->setCurrentText(text);
|
2017-12-02 10:50:30 +01:00
|
|
|
}
|